blob: e5008a465b32f9785d0d5e61238eb2027500c000 [file] [log] [blame]
Sithara Punnassery589fac22016-10-03 11:51:53 -07001/*
2 * Copyright 2016-present 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.incubator.elasticcfg;
17
18import org.onosproject.store.Store;
19
20import java.util.concurrent.CompletableFuture;
21
22/**
23 * Store service for storing and distributing elastic configuration data.
24 */
25public interface ElasticConfigStore
26 extends Store<ElasticConfigEvent, ElasticConfigStoreDelegate> {
27 /**
28 * Adds a new node to the ElasticConfigStore.
29 *
30 * @param store type of store to which the application wants to add the node to.
31 * @param path data structure with absolute path to the parent and relative
32 * path to the node
33 * @param node data structure with nodetype and value to be stored at the node
34 * @return future that is completed with {@code true} if the new node was successfully
35 * added. Future will be completed with {@code false} if a node already exists at
36 * the specified path. Future will be completed exceptionally with a
37 * {@code FailedException} if the parent node (for the node to create) does not exist.
38 */
39 CompletableFuture<Boolean>
40 addNode(ConfigStoreType store, ConfigNodePath path, ConfigNode node);
41
42 /**
43 * Removes a node from the ElasticConfigStore.
44 *
45 * @param store type of store which the application wants to access.
46 * @param path data structure with absolute path to the parent and
47 * relative path to the node
48 * @return future for the previous value. Future will be completed with a
49 * {@code FailedException} if the node to be removed is either the root
50 * node or has one or more children or if the node to be removed does not exist.
51 */
52 CompletableFuture<ConfigNode>
53 removeNode(ConfigStoreType store, ConfigNodePath path);
54
55 /**
56 * Creates/Updates a node in the ElasticConfigStore.
57 *
58 * @param store type of store which the application wants to access.
59 * @param path data structure with absolute path to the parent and
60 * relative path to the node
61 * @param node data structure with nodetype and new value to be stored at the node
62 * @return future for the previous value. Future will be completed with {@code null}
63 * if there was no node previously at that path.
64 * Future will be completed with a {@code FailedException}
65 * if the parent node (for the node to create/update) does not exist.
66 */
67 CompletableFuture<ConfigNode>
68 updateNode(ConfigStoreType store, ConfigNodePath path, ConfigNode node);
69
70 /**
71 * Creates nodes in the ElasticConfigStore, recursively by creating
72 * all missing intermediate nodes in the path.
73 *
74 * @param store type of store which the application wants to access.
75 * @param path data structure with absolute path to the parent and relative
76 * path to the node
77 * @param node recursive data structure with nodetype and value to
78 * be stored at the node
79 * @return future that is completed with {@code true} if all the new
80 * nodes were successfully
81 * created. Future will be completed with {@code false} if any node
82 * already exists at the specified path
83 * //TODO
84 */
85 CompletableFuture<Boolean>
86 createRecursive(ConfigStoreType store, ConfigNodePath path,
87 ConfigNode node);
88
89 /**
90 * Delete nodes in the ElasticConfigStore, recursively by deleting all
91 * intermediate nodes in the path.
92 *
93 * @param store type of store which the appplication wants to access.
94 * @param path data structure with absolute path to the parent and
95 * relative path to the node
96 * @return future that is completed with {@code true} if all the
97 * nodes under the given path including the node at the path could
98 * be successfully deleted. Future will be completed with {@code false}
99 * if the node at the given path or any parent node
100 * did not exist //TODO
101 */
102 CompletableFuture<Boolean>
103 deleteRecursive(ConfigStoreType store, ConfigNodePath path);
104
105 /**
106 * Creates/Updates nodes in the ElasticConfigStore, recursively by creating
107 * all missing intermediate nodes in the path.
108 *
109 * @param store type of store which the appplication wants to access.
110 * @param path data structure with absolute path to the parent and
111 * relative path to the node
112 * @param node recursive data structure with nodetype and value to
113 * be stored at the node
114 * @return future that is completed with {@code true} if all the
115 * nodes under the given path
116 * including the node at the path could be successfully updated.
117 * Future will be completed with {@code false} if the node at the
118 * given path or any parent node
119 * did not exist //TODO
120 */
121 CompletableFuture<Boolean>
122 updateRecursive(ConfigStoreType store, ConfigNodePath path,
123 ConfigNode node);
124
125 /**
126 * Returns a value node or subtree under the given path.
127 *
128 * @param store type of store which the appplication wants to access.
129 * @param path data structure with absolute path to the parent and
130 * relative path to the node
131 * @param mode wether to retrive the nodes recursivley or not
132 * @param filter filtering conditions to be applied on the result
133 * list of nodes.
134 * @return future that will be completed either with a value node
135 * or a recursive data structure containing the subtree;
136 * will be completed with {@code null} if
137 * after applying the filter, the result is an empty list of nodes.
138 * Future will be completed with a {@code FailedException} if path
139 * does not point to a valid node.
140 *
141 */
142 CompletableFuture<ConfigNode>
143 getNode(ConfigStoreType store, ConfigNodePath path,
144 TraversalMode mode, ConfigFilter filter);
145
146 /**
147 * Returns the number of children under the given path, excluding
148 * the node at the path.
149 *
150 * @param store type of store which the appplication wants to access.
151 * @param path data structure with absolute path to the parent and
152 * relative path to the node
153 * @param filter how the value nodes should be filtered
154 * @return future that will be completed with {@code Integer}, the
155 * count of the children
156 * after applying the filtering conditions as well.
157 * Future will be completed with a {@code FailedException} if path
158 * does not point to a valid node
159 */
160 CompletableFuture<Integer>
161 getNumberOfChildren(ConfigStoreType store,
162 ConfigNodePath path, ConfigFilter filter);
163
164 //TODO
165 /**
166 * Filter
167 * What should be the filtering conditions?
168 * a list of keys? node attribute/s? level1 children?
169 * Merge Trees
170 * add sub tree
171 * delete subtree
172 * update sub tree
173 * get sub tree
174 * How to handle big subtrees?
175 * how many levels? how many results to limit?
176 */
177}