blob: 2a857e468938f595fb2ab3d66c742e84d0982ee6 [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
18import org.onosproject.config.model.DataNode;
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080019import org.onosproject.config.model.ResourceId;
Sithara Punnasseryff114552017-01-10 11:40:55 -080020import org.onosproject.store.Store;
21
22import java.util.concurrent.CompletableFuture;
23
24/**
25 * Store interface for storing and distributing dynamic configuration data.
26 */
27public interface DynamicConfigStore
28 extends Store<DynamicConfigEvent, DynamicConfigStoreDelegate> {
29 /**
30 * Adds a new node in the dynamic config store. The new node will not be
31 * added if there is a node with the same identifier, already present at
32 * the specified path or any of the parent nodes were not present in the
33 * path leading up to the requested node.
34 *
35 * @param path data structure with absolute path to the parent
36 * @param node recursive data structure, holding a leaf node or a subtree
37 * @return future that is completed with {@code true} if the new node was
38 * successfully added or completed exceptionally with
39 * {@code FailedException} if node addition failed
40 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080041 CompletableFuture<Boolean> addNode(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -080042
43 /**
44 * Adds a new node in the dynamic config store.
45 * Creates any missing parent nodes, leading up to the given node. Node
46 * will not be added if there is a node with the same identifier, already
47 * present at the specified path.
48 *
49 * @param path data structure with absolute path to the parent
50 * @param node recursive data structure, holding a leaf node or a subtree
51 * @return future that is completed with {@code true} if the node was
52 * successfully added or completed exceptionally with
53 * {@code FailedException} if the node addition failed
54 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080055 CompletableFuture<Boolean> addRecursive(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -080056
57 /**
58 * Reads the requested node from the dynamic config store.
59 * This operation would get translated to reading a leaf node or a subtree.
60 * This would fail if the requested node was not present or any parent nodes
61 * in the path were not present.
62 *
63 * @param path data structure with absolute path to the intended node
64 * @param filter filtering conditions to be applied on the result list of nodes
65 * @return future that will be completed with a DataNode (will be an empty
66 * DataNode if after applying the filter, the result is an empty list of nodes)
67 * or completed with {@code FailedException} if the node could not be read
68 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080069 CompletableFuture<DataNode> readNode(ResourceId path, Filter filter);
Sithara Punnasseryff114552017-01-10 11:40:55 -080070
71 /**
72 * Updates an existing node in the dynamic config store.
73 * This request would fail if the requested node, any of its children or
74 * any parent nodes in the path were not present.
75 *
76 * @param path data structure with absolute path to the parent
77 * @param node recursive data structure, holding a leaf node or a subtree
78 * @return future that is completed with {@code true} if the node was
79 * successfully updated or completed exceptionally with
80 * {@code FailedException} if the update request failed
81 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080082 CompletableFuture<Boolean> updateNode(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -080083
84 /**
85 * Updates an existing node in the dynamic config store.
86 * Any missing children will be created with this request. The update will
87 * fail if the requested node or any of the parent nodes in the path
88 * were not present.
89 *
90 * @param path data structure with absolute path to the parent
91 * @param node recursive data structure, holding a leaf node or a subtree
92 * @return future that is completed with {@code true} if the node was
93 * successfully updated or completed exceptionally with
94 * {@code FailedException} if the update request failed
95 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080096 CompletableFuture<Boolean> updateNodeRecursive(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -080097
98 /**
99 * Replaces nodes in the dynamic config store.
100 * This will ensure that only the tree structure in the given DataNode will
101 * be in place after a replace. This would fail if the requested node or
102 * any of the parent nodes in the path were not present.
103 *
104 * @param path data structure with absolute path to the parent
105 * @param node recursive data structure, holding a leaf node or a subtree
106 * @return future that is completed with {@code true} if the node was
107 * successfully replaced or completed exceptionally with
108 * {@code FailedException} if the replace request failed
109 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -0800110 CompletableFuture<Boolean> replaceNode(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -0800111
112 /**
113 * Removes a node from the dynamic config store.
114 * This would fail if the requested node or any of the parent nodes in the
115 * path were not present or the specified node is the root node or has one
116 * or more children.
117 *
118 * @param path data structure with absolute path to the intended node
119 * @return future that is completed with {@code true} if the node was
120 * successfully deleted or completed exceptionally with
121 * {@code FailedException} if the delete request failed
122 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -0800123 CompletableFuture<Boolean> deleteNode(ResourceId path);
Sithara Punnasseryff114552017-01-10 11:40:55 -0800124
125 /**
126 * Removes a subtree from the dynamic config store.
127 * This will delete all the children recursively, under the given node.
128 * Will fail if the requested node or any of the parent nodes in
129 * the path were not present.
130 *
131 * @param path data structure with absolute path to the intended node
132 * @return future that is completed with {@code true} if the delete was
133 * successful or completed exceptionally with
134 * {@code FailedException} if the delete request failed
135 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -0800136 CompletableFuture<Boolean> deleteNodeRecursive(ResourceId path);
Sithara Punnasseryff114552017-01-10 11:40:55 -0800137}