blob: aa65a86ab143aa3b9c16686dee1d94c46067b612 [file] [log] [blame]
Jordan Halterman980a8c12017-09-22 18:01:19 -07001/*
2 * Copyright 2017-present Open Networking Foundation
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
18/**
19 * Primitive service.
20 * <p>
21 * This service provides builders for various distributed primitives.
22 * <p>
23 * It is expected that services and applications will leverage the primitives indirectly provided by
24 * this service for their distributed state management and coordination.
25 */
26public interface PrimitiveService {
27
28 /**
29 * Creates a new EventuallyConsistentMapBuilder.
30 *
31 * @param <K> key type
32 * @param <V> value type
33 * @return builder for an eventually consistent map
34 */
35 <K, V> EventuallyConsistentMapBuilder<K, V> eventuallyConsistentMapBuilder();
36
37 /**
38 * Creates a new ConsistentMapBuilder.
39 *
40 * @param <K> key type
41 * @param <V> value type
42 * @return builder for a consistent map
43 */
44 <K, V> ConsistentMapBuilder<K, V> consistentMapBuilder();
45
46 /**
47 * Creates a new ConsistentMapBuilder.
48 *
49 * @param <V> value type
50 * @return builder for a document tree
51 */
52 <V> DocumentTreeBuilder<V> documentTreeBuilder();
53
54 /**
55 * Creates a new {@code AsyncConsistentTreeMapBuilder}.
56 *
57 * @param <V> value type
58 * @return builder for a consistent tree map
59 */
60 <V> ConsistentTreeMapBuilder<V> consistentTreeMapBuilder();
61
62 /**
63 * Creates a new {@code AsyncConsistentSetMultimapBuilder}.
64 *
65 * @param <K> key type
66 * @param <V> value type
67 * @return builder for a set based consistent multimap
68 */
69 <K, V> ConsistentMultimapBuilder<K, V> consistentMultimapBuilder();
70
71 /**
72 * Creates a new {@code AtomicCounterMapBuilder}.
73 *
74 * @param <K> key type
75 * @return builder for an atomic counter map
76 */
77 <K> AtomicCounterMapBuilder<K> atomicCounterMapBuilder();
78
79 /**
80 * Creates a new DistributedSetBuilder.
81 *
82 * @param <E> set element type
83 * @return builder for a distributed set
84 */
85 <E> DistributedSetBuilder<E> setBuilder();
86
87 /**
88 * Creates a new AtomicCounterBuilder.
89 *
90 * @return atomic counter builder
91 */
92 AtomicCounterBuilder atomicCounterBuilder();
93
94 /**
95 * Creates a new AtomicIdGeneratorBuilder.
96 *
97 * @return atomic ID generator builder
98 */
99 AtomicIdGeneratorBuilder atomicIdGeneratorBuilder();
100
101 /**
102 * Creates a new AtomicValueBuilder.
103 *
104 * @param <V> atomic value type
105 * @return atomic value builder
106 */
107 <V> AtomicValueBuilder<V> atomicValueBuilder();
108
109 /**
Jordan Halterman9bf9c5d2018-03-12 13:56:57 -0700110 * Creates a new DistributedLockBuilder.
111 *
112 * @return lock builder
113 */
114 DistributedLockBuilder lockBuilder();
115
116 /**
Jordan Halterman980a8c12017-09-22 18:01:19 -0700117 * Creates a new LeaderElectorBuilder.
118 *
119 * @return leader elector builder
120 */
121 LeaderElectorBuilder leaderElectorBuilder();
122
123 /**
124 * Creates a new transaction context builder.
125 *
126 * @return a builder for a transaction context.
127 */
128 TransactionContextBuilder transactionContextBuilder();
129
130 /**
131 * Returns an instance of {@code AsyncAtomicCounter} with specified name.
132 * @param name counter name
133 *
134 * @return AsyncAtomicCounter instance
135 */
Jordan Halterman9bf9c5d2018-03-12 13:56:57 -0700136 AsyncAtomicCounter getAsyncAtomicCounter(String name);
Jordan Halterman980a8c12017-09-22 18:01:19 -0700137
138 /**
139 * Returns an instance of {@code AsyncAtomicIdGenerator} with specified name.
140 *
141 * @param name ID generator name
142 * @return AsyncAtomicIdGenerator instance
143 */
Jordan Halterman9bf9c5d2018-03-12 13:56:57 -0700144 AsyncAtomicIdGenerator getAsyncAtomicIdGenerator(String name);
Jordan Halterman980a8c12017-09-22 18:01:19 -0700145
146 /**
147 * Returns an instance of {@code AtomicCounter} with specified name.
148 * @param name counter name
149 *
150 * @return AtomicCounter instance
151 */
152 default AtomicCounter getAtomicCounter(String name) {
153 return getAsyncAtomicCounter(name).asAtomicCounter();
154 }
155
156 /**
157 * Returns an instance of {@code AtomicIdGenerator} with specified name.
158 *
159 * @param name ID generator name
160 * @return AtomicIdGenerator instance
161 */
162 default AtomicIdGenerator getAtomicIdGenerator(String name) {
163 return getAsyncAtomicIdGenerator(name).asAtomicIdGenerator();
164 }
165
166 /**
167 * Returns an instance of {@code WorkQueue} with specified name.
168 *
169 * @param <E> work element type
170 * @param name work queue name
171 * @param serializer serializer
172 * @return WorkQueue instance
173 */
174 <E> WorkQueue<E> getWorkQueue(String name, Serializer serializer);
175
176 /**
177 * Returns an instance of {@code AsyncDocumentTree} with specified name.
178 *
179 * @param <V> tree node value type
180 * @param name document tree name
181 * @param serializer serializer
182 * @return AsyncDocumentTree instance
183 */
184 <V> AsyncDocumentTree<V> getDocumentTree(String name, Serializer serializer);
185
Jordan Halterman9bf9c5d2018-03-12 13:56:57 -0700186 /**
187 * Returns a set backed instance of {@code AsyncConsistentMultimap} with
Jordan Halterman980a8c12017-09-22 18:01:19 -0700188 * the specified name.
189 *
Jordan Halterman9bf9c5d2018-03-12 13:56:57 -0700190 * @param name the multimap name
Jordan Halterman980a8c12017-09-22 18:01:19 -0700191 * @param serializer serializer
Jordan Halterman9bf9c5d2018-03-12 13:56:57 -0700192 * @param <K> key type
193 * @param <V> value type
Jordan Halterman980a8c12017-09-22 18:01:19 -0700194 * @return set backed {@code AsyncConsistentMultimap} instance
195 */
Jordan Halterman9bf9c5d2018-03-12 13:56:57 -0700196 <K, V> AsyncConsistentMultimap<K, V> getAsyncSetMultimap(String name, Serializer serializer);
Jordan Halterman980a8c12017-09-22 18:01:19 -0700197
198 /**
199 * Returns an instance of {@code AsyncConsistentTreeMap} with the specified
200 * name.
201 *
202 * @param name the treemap name
203 * @param serializer serializer
204 * @param <V> value type
205 * @return set backed {@code AsyncConsistentTreeMap} instance
206 */
Jordan Halterman9bf9c5d2018-03-12 13:56:57 -0700207 <V> AsyncConsistentTreeMap<V> getAsyncTreeMap(String name, Serializer serializer);
Jordan Halterman980a8c12017-09-22 18:01:19 -0700208
209 /**
210 * Returns an instance of {@code Topic} with specified name.
211 *
212 * @param <T> topic message type
213 * @param name topic name
214 * @param serializer serializer
215 *
216 * @return Topic instance
217 */
218 <T> Topic<T> getTopic(String name, Serializer serializer);
219}