blob: e8111d63383dd44b8958df961dd0a074bf058f12 [file] [log] [blame]
Madan Jampania090a112016-01-18 16:38:17 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Madan Jampania090a112016-01-18 16:38:17 -08003 *
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 Jampanifa242182016-01-22 13:42:54 -080018import java.util.concurrent.CompletableFuture;
19
Madan Jampania090a112016-01-18 16:38:17 -080020import org.onosproject.core.ApplicationId;
21
22/**
23 * Interface for all distributed primitives.
24 */
25public interface DistributedPrimitive {
26
27 /**
28 * Type of distributed primitive.
29 */
30 public enum Type {
31 /**
32 * Map with strong consistency semantics.
33 */
34 CONSISTENT_MAP,
35
36 /**
37 * Map with eventual consistency semantics.
38 */
39 EVENTUALLY_CONSISTENT_MAP,
40
41 /**
Aaron Kruglikov99702652016-04-11 16:24:18 -070042 * Consistent Multimap.
43 */
44 CONSISTENT_MULTIMAP,
45
46 /**
Madan Jampania090a112016-01-18 16:38:17 -080047 * distributed set.
48 */
49 SET,
50
51 /**
52 * atomic counter.
53 */
54 COUNTER,
55
56 /**
57 * Atomic value.
58 */
59 VALUE,
60
61 /**
62 * Distributed queue.
63 */
Madan Jampani4124bc32016-01-30 23:53:56 -080064 QUEUE,
65
66 /**
67 * Leader elector.
68 */
Madan Jampanicadd70b2016-02-08 13:45:43 -080069 LEADER_ELECTOR,
70
71 /**
72 * Transaction Context.
73 */
74 TRANSACTION_CONTEXT
Madan Jampania090a112016-01-18 16:38:17 -080075 }
76
Madan Jampanib98d97e2016-04-01 11:08:25 -070077 static final long DEFAULT_OPERTATION_TIMEOUT_MILLIS = 60000L;
Madan Jampanie17d3282016-02-03 15:30:57 -080078
Madan Jampania090a112016-01-18 16:38:17 -080079 /**
80 * Returns the name of this primitive.
81 * @return name
82 */
83 String name();
84
85 /**
86 * Returns the type of primitive.
87 * @return primitive type
88 */
Madan Jampani39fff102016-02-14 13:17:28 -080089 Type primitiveType();
Madan Jampania090a112016-01-18 16:38:17 -080090
91 /**
92 * Returns the application owning this primitive.
Jian Lidfba7392016-01-22 16:46:58 -080093 * @return application id
Madan Jampania090a112016-01-18 16:38:17 -080094 */
95 default ApplicationId applicationId() {
96 return null;
97 }
Madan Jampanifa242182016-01-22 13:42:54 -080098
99 /**
100 * Purges state associated with this primitive.
101 * <p>
102 * Implementations can override and provide appropriate clean up logic for purging
103 * any state state associated with the primitive. Whether modifications made within the
104 * destroy method have local or global visibility is left unspecified.
Madan Jampani4124bc32016-01-30 23:53:56 -0800105 * @return {@code CompletableFuture} that is completed when the operation completes
Madan Jampanifa242182016-01-22 13:42:54 -0800106 */
107 default CompletableFuture<Void> destroy() {
108 return CompletableFuture.completedFuture(null);
109 }
Madan Jampania090a112016-01-18 16:38:17 -0800110}