blob: ec856ad8a881895637da0ee81d9258e03ff2a977 [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 */
16
17package org.onosproject.config;
18
Sithara Punnassery06208792017-02-10 16:25:29 -080019import com.google.common.annotations.Beta;
Sithara Punnassery4b091dc2017-03-02 17:22:40 -080020import org.onosproject.yang.model.DataNode;
21import org.onosproject.yang.model.ResourceId;
Sithara Punnasseryff114552017-01-10 11:40:55 -080022import org.onosproject.event.ListenerService;
Gaurav Agrawal02dbee32017-05-11 19:04:52 +053023import org.onosproject.yang.model.RpcCaller;
24import org.onosproject.yang.model.RpcCommand;
25import org.onosproject.yang.model.RpcHandler;
26import org.onosproject.yang.model.RpcInput;
27import org.onosproject.yang.model.RpcOutput;
Sithara Punnasseryff114552017-01-10 11:40:55 -080028
29/**
30 * Service for storing and distributing dynamic configuration data.
31 */
Sithara Punnassery06208792017-02-10 16:25:29 -080032@Beta
Sithara Punnasseryff114552017-01-10 11:40:55 -080033public interface DynamicConfigService
34 extends ListenerService<DynamicConfigEvent, DynamicConfigListener> {
35 /**
36 * Creates a new node in the dynamic config store.
37 * This method would throw an exception if there is a node with the same
38 * identifier, already present at the specified path or any of the parent
39 * nodes were not present in the path leading up to the requested node.
40 * Failure reason will be the error message in the exception.
41 *
42 * @param path data structure with absolute path to the parent
43 * @param node recursive data structure, holding a leaf node or a subtree
44 * @throws FailedException if the new node could not be created
45 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080046 void createNodeRecursive(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -080047
48 /**
49 * Reads the requested node form the dynamic config store.
50 * This operation would get translated to reading a leaf node or a subtree.
51 * Will return an empty DataNode if after applying the filter, the result
52 * is an empty list of nodes. This method would throw an exception if the
53 * requested node or any parent nodes in the path were not present.
54 * Failure reason will be the error message in the exception.
55 *
56 * @param path data structure with absolute path to the intended node
57 * @param filter filtering conditions to be applied on the result list of nodes
58 * @return a recursive data structure, holding a leaf node or a subtree
59 * @throws FailedException if the requested node could not be read
60 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080061 DataNode readNode(ResourceId path, Filter filter);
Sithara Punnasseryff114552017-01-10 11:40:55 -080062
63 /**
64 * Returns the number of children under the node at the given path.
65 * This method would throw an exception if the requested node or any parent
66 * nodes in the path were not present.
67 * Failure reason will be the error message in the exception.
68 *
69 * @param path data structure with absolute path to the intended node
70 * @param filter filtering conditions to be applied on the result list of nodes
71 * @return the number of children after applying the filtering conditions if any
72 * @throws FailedException if the request failed
73 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080074 Integer getNumberOfChildren(ResourceId path, Filter filter);
Sithara Punnasseryff114552017-01-10 11:40:55 -080075
76 /**
Sithara Punnassery18ffcc72017-05-18 14:24:30 -070077 * Returns whether the requested node exists in the Dynamic Config store.
78 *
79 * @param path data structure with absolute path to the intended node
80 * @return {@code true} if the node existed in the store
81 * {@code false} otherwise
82 */
83 Boolean nodeExist(ResourceId path);
84
85 /**
Sithara Punnasseryff114552017-01-10 11:40:55 -080086 * Updates an existing node in the dynamic config store.
Sithara Punnasseryff114552017-01-10 11:40:55 -080087 * Any missing children nodes will be created with this request.
88 * This method would throw an exception if the requested node or any of the
89 * parent nodes in the path were not present.
90 * Failure reason will be the error message in the exception.
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 * @throws FailedException if the update request failed for any reason
Sithara Punnasseryff114552017-01-10 11:40:55 -080095 */
Sithara Punnassery0da1a9c2017-05-17 16:16:22 -070096 void updateNode(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 method would throw an exception if
102 * the requested node or any of the parent nodes in the path were not
103 * present. Failure reason will be the error message in the exception.
104 *
105 * @param path data structure with absolute path to the parent
106 * @param node recursive data structure, holding a leaf node or a subtree
107 * @throws FailedException if the replace request failed
108 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -0800109 void replaceNode(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -0800110
111 /**
112 * Removes a leaf node from the dynamic config store.
113 * This method would throw an exception if the requested node or any of the
114 * parent nodes in the path were not present or the specified node is the
115 * root node or has one or more children.
116 * Failure reason will be the error message in the exception.
117 *
118 * @param path data structure with absolute path to the intended node
119 * @throws FailedException if the delete request failed
120 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -0800121 void deleteNode(ResourceId path);
Sithara Punnasseryff114552017-01-10 11:40:55 -0800122
123 /**
124 * Removes a subtree from the dynamic config store.
125 * This method will delete all the children recursively, under the given
126 * node. It will throw an exception if the requested node or any of the
127 * parent nodes in the path were not present.
128 * Failure reason will be the error message in the exception.
129 *
130 * @param path data structure with absolute path to the intended node
131 * @throws FailedException if the delete request failed
132 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -0800133 void deleteNodeRecursive(ResourceId path);
Sithara Punnasseryff114552017-01-10 11:40:55 -0800134
135 /**
Sithara Punnasseryff114552017-01-10 11:40:55 -0800136 * Registers an RPC handler.
137 *
138 * @param handler RPC handler
139 * @param command RPC command
140 * @throws FailedException if the handler could not be added
141 */
142 void registerHandler(RpcHandler handler, RpcCommand command);
143
144 /**
145 * Unregisters an RPC receiver.
146 *
147 * @param handler RPC handler
148 * @param command RPC command
149 * @throws FailedException if the handler could not be removed
150 */
151 void unRegisterHandler(RpcHandler handler, RpcCommand command);
152
153 /**
154 * Invokes an RPC.
155 *
156 * @param caller of the of the RPC
157 * @param msgId RPC message id
158 * @param command RPC command
159 * @param input RPC input
160 * @throws FailedException if the RPC could not be invoked
161 */
162 void invokeRpc(RpcCaller caller, Integer msgId, RpcCommand command, RpcInput input);
163
164 /**
165 * Provides response to a a previously invoked RPC.
166 *
167 * @param msgId of a previously invoked RPC
168 * @param output data from the RPC execution
169 * @throws FailedException if the RPC response was invalid
170 * (or the msg id was not recognised by the store)
171 */
172 void rpcResponse(Integer msgId, RpcOutput output);
173}