blob: 09ba79493d44c0501a9458462aaddd754712ea3b [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 /**
Madan Jampani216d8d72015-08-26 13:33:36 -070077 * Provides weak consistency for set reads.
78 * <p>
79 * While this can lead to improved read performance, it can also make the behavior
80 * heard to reason. Only turn this on if you know what you are doing. By default
81 * reads are strongly consistent.
82 *
83 * @return this DistributedSetBuilder
84 */
85 DistributedSetBuilder<E> withRelaxedReadConsistency();
86
87 /**
Madan Jampani50589ac2015-06-08 11:38:46 -070088 * Disables distribution of set entries across multiple database partitions.
89 * <p>
90 * When partitioning is disabled, the returned set will have a single partition
91 * that spans the entire cluster. Furthermore, the changes made to the set are
92 * ephemeral and do not survive a full cluster restart.
93 * </p>
94 * <p>
95 * Disabling partitions is more appropriate when the returned set is used for
96 * simple coordination activities and not for long term data persistence.
97 * </p>
98 * <p>
99 * Note: By default partitions are enabled and entries in the set are durable.
100 * </p>
101 * @return this DistributedSetBuilder
102 */
103 DistributedSetBuilder<E> withPartitionsDisabled();
Madan Jampani02b7fb82015-05-01 13:01:20 -0700104
105 /**
Flavio Castro41b1f3a2015-07-31 13:51:32 -0700106 * Instantiate Metrics service to gather usage and performance metrics.
107 * By default usage information is enabled
108 * @return this DistributedSetBuilder
109 */
110 DistributedSetBuilder<E> withMeteringDisabled();
111
112 /**
Madan Jampanie8af1cc2015-06-23 14:23:31 -0700113 * Purges set contents when the application owning the set is uninstalled.
114 * <p>
115 * When this option is enabled, the caller must provide a applicationId via
116 * the {@code withAppliationId} builder method.
117 * <p>
118 * By default set contents will NOT be purged when owning application is uninstalled.
119 *
120 * @return this DistributedSetBuilder
121 */
122 DistributedSetBuilder<E> withPurgeOnUninstall();
123
124 /**
Madan Jampani08706ce2015-04-01 14:49:28 -0700125 * Builds an set based on the configuration options
126 * supplied to this builder.
127 *
128 * @return new set
129 * @throws java.lang.RuntimeException if a mandatory parameter is missing
130 */
Madan Jampani50589ac2015-06-08 11:38:46 -0700131 DistributedSet<E> build();
Madan Jampania090a112016-01-18 16:38:17 -0800132
133 /**
134 * Builds an {@link AsyncDistributedSet async set} based on the configuration options
135 * supplied to this builder.
136 *
137 * @return new AsyncDistributedSet
138 * @throws java.lang.RuntimeException if a mandatory parameter is missing
139 */
140 AsyncDistributedSet<E> buildAsyncSet();
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700141}