blob: 9ea34f2dbfd9038bc77907cd6739eb53ebb33e2f [file] [log] [blame]
Sithara Punnasseryff114552017-01-10 11:40:55 -08001/*
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.config;
17
Sithara Punnassery06208792017-02-10 16:25:29 -080018import com.google.common.annotations.Beta;
Sithara Punnassery4b091dc2017-03-02 17:22:40 -080019import org.onosproject.yang.model.DataNode;
20import org.onosproject.yang.model.ResourceId;
Sithara Punnasseryff114552017-01-10 11:40:55 -080021import org.onosproject.store.Store;
22
23import java.util.concurrent.CompletableFuture;
24
25/**
26 * Store interface for storing and distributing dynamic configuration data.
27 */
Sithara Punnassery06208792017-02-10 16:25:29 -080028@Beta
Sithara Punnasseryff114552017-01-10 11:40:55 -080029public interface DynamicConfigStore
30 extends Store<DynamicConfigEvent, DynamicConfigStoreDelegate> {
31 /**
32 * Adds a new node in the dynamic config store. The new node will not be
33 * added if there is a node with the same identifier, already present at
34 * the specified path or any of the parent nodes were not present in the
35 * path leading up to the requested node.
36 *
37 * @param path data structure with absolute path to the parent
38 * @param node recursive data structure, holding a leaf node or a subtree
39 * @return future that is completed with {@code true} if the new node was
40 * successfully added or completed exceptionally with
41 * {@code FailedException} if node addition failed
42 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080043 CompletableFuture<Boolean> addNode(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -080044
45 /**
46 * Adds a new node in the dynamic config store.
47 * Creates any missing parent nodes, leading up to the given node. Node
48 * will not be added if there is a node with the same identifier, already
49 * present at the specified path.
50 *
51 * @param path data structure with absolute path to the parent
52 * @param node recursive data structure, holding a leaf node or a subtree
53 * @return future that is completed with {@code true} if the node was
54 * successfully added or completed exceptionally with
55 * {@code FailedException} if the node addition failed
56 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080057 CompletableFuture<Boolean> addRecursive(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -080058
59 /**
60 * Reads the requested node from the dynamic config store.
61 * This operation would get translated to reading a leaf node or a subtree.
62 * This would fail if the requested node was not present or any parent nodes
63 * in the path were not present.
64 *
65 * @param path data structure with absolute path to the intended node
66 * @param filter filtering conditions to be applied on the result list of nodes
67 * @return future that will be completed with a DataNode (will be an empty
68 * DataNode if after applying the filter, the result is an empty list of nodes)
69 * or completed with {@code FailedException} if the node could not be read
70 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080071 CompletableFuture<DataNode> readNode(ResourceId path, Filter filter);
Sithara Punnasseryff114552017-01-10 11:40:55 -080072
73 /**
74 * Updates an existing node in the dynamic config store.
75 * This request would fail if the requested node, any of its children or
76 * any parent nodes in the path were not present.
77 *
78 * @param path data structure with absolute path to the parent
79 * @param node recursive data structure, holding a leaf node or a subtree
80 * @return future that is completed with {@code true} if the node was
81 * successfully updated or completed exceptionally with
82 * {@code FailedException} if the update request failed
83 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080084 CompletableFuture<Boolean> updateNode(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -080085
86 /**
87 * Updates an existing node in the dynamic config store.
88 * Any missing children will be created with this request. The update will
89 * fail if the requested node or any of the parent nodes in the path
90 * were not present.
91 *
92 * @param path data structure with absolute path to the parent
93 * @param node recursive data structure, holding a leaf node or a subtree
94 * @return future that is completed with {@code true} if the node was
95 * successfully updated or completed exceptionally with
96 * {@code FailedException} if the update request failed
97 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080098 CompletableFuture<Boolean> updateNodeRecursive(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -080099
100 /**
101 * Replaces nodes in the dynamic config store.
102 * This will ensure that only the tree structure in the given DataNode will
103 * be in place after a replace. This would fail if the requested node or
104 * any of the parent nodes in the path were not present.
105 *
106 * @param path data structure with absolute path to the parent
107 * @param node recursive data structure, holding a leaf node or a subtree
108 * @return future that is completed with {@code true} if the node was
109 * successfully replaced or completed exceptionally with
110 * {@code FailedException} if the replace request failed
111 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -0800112 CompletableFuture<Boolean> replaceNode(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -0800113
114 /**
115 * Removes a node from the dynamic config store.
116 * This would fail if the requested node or any of the parent nodes in the
117 * path were not present or the specified node is the root node or has one
118 * or more children.
119 *
120 * @param path data structure with absolute path to the intended node
121 * @return future that is completed with {@code true} if the node was
122 * successfully deleted or completed exceptionally with
123 * {@code FailedException} if the delete request failed
124 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -0800125 CompletableFuture<Boolean> deleteNode(ResourceId path);
Sithara Punnasseryff114552017-01-10 11:40:55 -0800126
127 /**
128 * Removes a subtree from the dynamic config store.
129 * This will delete all the children recursively, under the given node.
130 * Will fail if the requested node or any of the parent nodes in
131 * the path were not present.
132 *
133 * @param path data structure with absolute path to the intended node
134 * @return future that is completed with {@code true} if the delete was
135 * successful or completed exceptionally with
136 * {@code FailedException} if the delete request failed
137 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -0800138 CompletableFuture<Boolean> deleteNodeRecursive(ResourceId path);
Sithara Punnasseryff114552017-01-10 11:40:55 -0800139}