blob: 1bed059afc996167c6bece4e22ded46147b64b06 [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 Punnasseryff114552017-01-10 11:40:55 -080043
Sithara Punnassery4cd2ced2017-03-17 17:36:43 -070044 CompletableFuture<Boolean> addNode(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -080045
46 /**
47 * Reads the requested node from the dynamic config store.
48 * This operation would get translated to reading a leaf node or a subtree.
49 * This would fail if the requested node was not present or any parent nodes
50 * in the path were not present.
51 *
52 * @param path data structure with absolute path to the intended node
53 * @param filter filtering conditions to be applied on the result list of nodes
54 * @return future that will be completed with a DataNode (will be an empty
55 * DataNode if after applying the filter, the result is an empty list of nodes)
56 * or completed with {@code FailedException} if the node could not be read
57 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080058 CompletableFuture<DataNode> readNode(ResourceId path, Filter filter);
Sithara Punnasseryff114552017-01-10 11:40:55 -080059
60 /**
61 * Updates an existing node in the dynamic config store.
62 * This request would fail if the requested node, any of its children or
63 * any parent nodes in the path were not present.
64 *
65 * @param path data structure with absolute path to the parent
66 * @param node recursive data structure, holding a leaf node or a subtree
67 * @return future that is completed with {@code true} if the node was
68 * successfully updated or completed exceptionally with
69 * {@code FailedException} if the update request failed
70 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080071 CompletableFuture<Boolean> updateNode(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -080072
73 /**
74 * Updates an existing node in the dynamic config store.
75 * Any missing children will be created with this request. The update will
76 * fail if the requested node or any of the parent nodes in the path
77 * were not present.
78 *
79 * @param path data structure with absolute path to the parent
80 * @param node recursive data structure, holding a leaf node or a subtree
81 * @return future that is completed with {@code true} if the node was
82 * successfully updated or completed exceptionally with
83 * {@code FailedException} if the update request failed
84 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080085 CompletableFuture<Boolean> updateNodeRecursive(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -080086
87 /**
88 * Replaces nodes in the dynamic config store.
89 * This will ensure that only the tree structure in the given DataNode will
90 * be in place after a replace. This would fail if the requested node or
91 * any of the parent nodes in the path were not present.
92 *
93 * @param path data structure with absolute path to the parent
94 * @param node recursive data structure, holding a leaf node or a subtree
95 * @return future that is completed with {@code true} if the node was
96 * successfully replaced or completed exceptionally with
97 * {@code FailedException} if the replace request failed
98 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080099 CompletableFuture<Boolean> replaceNode(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -0800100
101 /**
102 * Removes a node from the dynamic config store.
103 * This would fail if the requested node or any of the parent nodes in the
104 * path were not present or the specified node is the root node or has one
105 * or more children.
106 *
107 * @param path data structure with absolute path to the intended node
108 * @return future that is completed with {@code true} if the node was
109 * successfully deleted or completed exceptionally with
110 * {@code FailedException} if the delete request failed
111 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -0800112 CompletableFuture<Boolean> deleteNode(ResourceId path);
Sithara Punnasseryff114552017-01-10 11:40:55 -0800113
114 /**
115 * Removes a subtree from the dynamic config store.
116 * This will delete all the children recursively, under the given node.
117 * Will fail if the requested node or any of the parent nodes in
118 * the path were not present.
119 *
120 * @param path data structure with absolute path to the intended node
121 * @return future that is completed with {@code true} if the delete was
122 * successful or completed exceptionally with
123 * {@code FailedException} if the delete request failed
124 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -0800125 CompletableFuture<Boolean> deleteNodeRecursive(ResourceId path);
Sithara Punnasseryff114552017-01-10 11:40:55 -0800126}