blob: 1706c8f9ea55694309f89568266e995869ce4fe4 [file] [log] [blame]
Madan Jampani08706ce2015-04-01 14:49:28 -07001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.store.service;
17
Madan Jampanie8af1cc2015-06-23 14:23:31 -070018import org.onosproject.core.ApplicationId;
19
Madan Jampani08706ce2015-04-01 14:49:28 -070020/**
21 * Builder for distributed set.
22 *
23 * @param <E> type set elements.
24 */
Madan Jampani50589ac2015-06-08 11:38:46 -070025public interface DistributedSetBuilder<E> {
Madan Jampani08706ce2015-04-01 14:49:28 -070026
27 /**
28 * Sets the name of the set.
29 * <p>
30 * Each set is identified by a unique name.
31 * </p>
32 * <p>
33 * Note: This is a mandatory parameter.
34 * </p>
35 *
36 * @param name name of the set
Madan Jampani50589ac2015-06-08 11:38:46 -070037 * @return this DistributedSetBuilder
Madan Jampani08706ce2015-04-01 14:49:28 -070038 */
Madan Jampani50589ac2015-06-08 11:38:46 -070039 DistributedSetBuilder<E> withName(String name);
Madan Jampani08706ce2015-04-01 14:49:28 -070040
41 /**
Madan Jampanie8af1cc2015-06-23 14:23:31 -070042 * Sets the owner applicationId for the set.
43 * <p>
44 * Note: If {@code purgeOnUninstall} option is enabled, applicationId
45 * must be specified.
46 * </p>
47 *
48 * @param id applicationId owning the set
49 * @return this DistributedSetBuilder
50 */
51 DistributedSetBuilder<E> withApplicationId(ApplicationId id);
52
53 /**
Madan Jampani08706ce2015-04-01 14:49:28 -070054 * Sets a serializer that can be used to serialize
55 * the elements add to the set. The serializer
56 * builder should be pre-populated with any classes that will be
57 * put into the set.
58 * <p>
59 * Note: This is a mandatory parameter.
60 * </p>
61 *
62 * @param serializer serializer
Madan Jampani50589ac2015-06-08 11:38:46 -070063 * @return this DistributedSetBuilder
Madan Jampani08706ce2015-04-01 14:49:28 -070064 */
Madan Jampani50589ac2015-06-08 11:38:46 -070065 DistributedSetBuilder<E> withSerializer(Serializer serializer);
Madan Jampani08706ce2015-04-01 14:49:28 -070066
67 /**
Madan Jampani02b7fb82015-05-01 13:01:20 -070068 * Disables set updates.
69 * <p>
70 * Attempt to update the built set will throw {@code UnsupportedOperationException}.
71 *
Madan Jampani50589ac2015-06-08 11:38:46 -070072 * @return this DistributedSetBuilder
Madan Jampani02b7fb82015-05-01 13:01:20 -070073 */
Madan Jampani50589ac2015-06-08 11:38:46 -070074 DistributedSetBuilder<E> withUpdatesDisabled();
75
76 /**
77 * Disables distribution of set entries across multiple database partitions.
78 * <p>
79 * When partitioning is disabled, the returned set will have a single partition
80 * that spans the entire cluster. Furthermore, the changes made to the set are
81 * ephemeral and do not survive a full cluster restart.
82 * </p>
83 * <p>
84 * Disabling partitions is more appropriate when the returned set is used for
85 * simple coordination activities and not for long term data persistence.
86 * </p>
87 * <p>
88 * Note: By default partitions are enabled and entries in the set are durable.
89 * </p>
90 * @return this DistributedSetBuilder
91 */
92 DistributedSetBuilder<E> withPartitionsDisabled();
Madan Jampani02b7fb82015-05-01 13:01:20 -070093
94 /**
Flavio Castro41b1f3a2015-07-31 13:51:32 -070095 * Instantiate Metrics service to gather usage and performance metrics.
96 * By default usage information is enabled
97 * @return this DistributedSetBuilder
98 */
99 DistributedSetBuilder<E> withMeteringDisabled();
100
101 /**
Madan Jampanie8af1cc2015-06-23 14:23:31 -0700102 * Purges set contents when the application owning the set is uninstalled.
103 * <p>
104 * When this option is enabled, the caller must provide a applicationId via
105 * the {@code withAppliationId} builder method.
106 * <p>
107 * By default set contents will NOT be purged when owning application is uninstalled.
108 *
109 * @return this DistributedSetBuilder
110 */
111 DistributedSetBuilder<E> withPurgeOnUninstall();
112
113 /**
Madan Jampani08706ce2015-04-01 14:49:28 -0700114 * Builds an set based on the configuration options
115 * supplied to this builder.
116 *
117 * @return new set
118 * @throws java.lang.RuntimeException if a mandatory parameter is missing
119 */
Madan Jampani50589ac2015-06-08 11:38:46 -0700120 DistributedSet<E> build();
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700121}