blob: 9e256d4b5936df80716706c3523c1142b94e0661 [file] [log] [blame]
Sithara Punnasseryff114552017-01-10 11:40:55 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Sithara Punnasseryff114552017-01-10 11:40:55 -08003 *
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.
Sithara Punnasseryff114552017-01-10 11:40:55 -080062 * Any missing children will be created with this request. The update will
63 * fail if the requested node or any of the parent nodes in the path
64 * were not present.
65 *
66 * @param path data structure with absolute path to the parent
67 * @param node recursive data structure, holding a leaf node or a subtree
68 * @return future that is completed with {@code true} if the node was
69 * successfully updated or completed exceptionally with
70 * {@code FailedException} if the update request failed
71 */
Sithara Punnassery0da1a9c2017-05-17 16:16:22 -070072 CompletableFuture<Boolean> updateNode(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -080073
74 /**
75 * Replaces nodes in the dynamic config store.
76 * This will ensure that only the tree structure in the given DataNode will
77 * be in place after a replace. This would fail if the requested node or
78 * any of the parent nodes in the path were not present.
79 *
80 * @param path data structure with absolute path to the parent
81 * @param node recursive data structure, holding a leaf node or a subtree
82 * @return future that is completed with {@code true} if the node was
83 * successfully replaced or completed exceptionally with
84 * {@code FailedException} if the replace request failed
85 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080086 CompletableFuture<Boolean> replaceNode(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -080087
88 /**
89 * Removes a node from the dynamic config store.
90 * This would fail if the requested node or any of the parent nodes in the
91 * path were not present or the specified node is the root node or has one
92 * or more children.
93 *
94 * @param path data structure with absolute path to the intended node
95 * @return future that is completed with {@code true} if the node was
96 * successfully deleted or completed exceptionally with
97 * {@code FailedException} if the delete request failed
98 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080099 CompletableFuture<Boolean> deleteNode(ResourceId path);
Sithara Punnasseryff114552017-01-10 11:40:55 -0800100
101 /**
102 * Removes a subtree from the dynamic config store.
103 * This will delete all the children recursively, under the given node.
104 * Will fail if the requested node or any of the parent nodes in
105 * the path were not present.
106 *
107 * @param path data structure with absolute path to the intended node
108 * @return future that is completed with {@code true} if the delete was
109 * successful or completed exceptionally with
110 * {@code FailedException} if the delete request failed
111 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -0800112 CompletableFuture<Boolean> deleteNodeRecursive(ResourceId path);
Sithara Punnassery18ffcc72017-05-18 14:24:30 -0700113
114 /**
115 * Returns whether the requested node exists in the Dynamic Config store.
116 *
117 * @param path data structure with absolute path to the intended node
118 * @return future that is completed with {@code true} if the node existed
119 * in the store, {@code false} otherwise
120 */
121 CompletableFuture<Boolean> nodeExist(ResourceId path);
Sithara Punnasseryff114552017-01-10 11:40:55 -0800122}