blob: ed2e9c9f45a338c73ec7f429a74a3b8d8896baf3 [file] [log] [blame]
Madan Jampania090a112016-01-18 16:38:17 -08001/*
2 * Copyright 2015-2016 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 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 /**
42 * distributed set.
43 */
44 SET,
45
46 /**
47 * atomic counter.
48 */
49 COUNTER,
50
51 /**
52 * Atomic value.
53 */
54 VALUE,
55
56 /**
57 * Distributed queue.
58 */
59 QUEUE
60 }
61
62 /**
63 * Returns the name of this primitive.
64 * @return name
65 */
66 String name();
67
68 /**
69 * Returns the type of primitive.
70 * @return primitive type
71 */
72 Type type();
73
74 /**
75 * Returns the application owning this primitive.
Jian Lidfba7392016-01-22 16:46:58 -080076 * @return application id
Madan Jampania090a112016-01-18 16:38:17 -080077 */
78 default ApplicationId applicationId() {
79 return null;
80 }
Madan Jampanifa242182016-01-22 13:42:54 -080081
82 /**
83 * Purges state associated with this primitive.
84 * <p>
85 * Implementations can override and provide appropriate clean up logic for purging
86 * any state state associated with the primitive. Whether modifications made within the
87 * destroy method have local or global visibility is left unspecified.
88 */
89 default CompletableFuture<Void> destroy() {
90 return CompletableFuture.completedFuture(null);
91 }
Madan Jampania090a112016-01-18 16:38:17 -080092}