blob: da83d9117436e48f034b42974d8cc074e3b52d02 [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 Punnasseryff114552017-01-10 11:40:55 -080020import org.onosproject.config.model.DataNode;
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080021import org.onosproject.config.model.ResourceId;
Sithara Punnasseryff114552017-01-10 11:40:55 -080022import org.onosproject.event.ListenerService;
23
24/**
25 * Service for storing and distributing dynamic configuration data.
26 */
Sithara Punnassery06208792017-02-10 16:25:29 -080027@Beta
Sithara Punnasseryff114552017-01-10 11:40:55 -080028public interface DynamicConfigService
29 extends ListenerService<DynamicConfigEvent, DynamicConfigListener> {
30 /**
31 * Creates a new node in the dynamic config store.
32 * This method would throw an exception if there is a node with the same
33 * identifier, already present at the specified path or any of the parent
34 * nodes were not present in the path leading up to the requested node.
35 * Failure reason will be the error message in the exception.
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 * @throws FailedException if the new node could not be created
40 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080041 void createNode(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -080042
43 /**
44 * Creates a new node in the dynamic config store.
45 * Creates any missing parent nodes, leading up to the given node.
46 * This method will throw an exception if there is a node with the same
47 * identifier, already present at the specified path or any of the parent
48 * nodes were not present in the path leading up to the requested node.
49 * Failure reason will be the error message in the exception.
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 * @throws FailedException if the new node could not be created
54 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080055 void createNodeRecursive(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -080056
57 /**
58 * Reads the requested node form the dynamic config store.
59 * This operation would get translated to reading a leaf node or a subtree.
60 * Will return an empty DataNode if after applying the filter, the result
61 * is an empty list of nodes. This method would throw an exception if the
62 * requested node or any parent nodes in the path were not present.
63 * Failure reason will be the error message in the exception.
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 a recursive data structure, holding a leaf node or a subtree
68 * @throws FailedException if the requested node could not be read
69 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080070 DataNode readNode(ResourceId path, Filter filter);
Sithara Punnasseryff114552017-01-10 11:40:55 -080071
72 /**
73 * Returns the number of children under the node at the given path.
74 * This method would throw an exception if the requested node or any parent
75 * nodes in the path were not present.
76 * Failure reason will be the error message in the exception.
77 *
78 * @param path data structure with absolute path to the intended node
79 * @param filter filtering conditions to be applied on the result list of nodes
80 * @return the number of children after applying the filtering conditions if any
81 * @throws FailedException if the request failed
82 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080083 Integer getNumberOfChildren(ResourceId path, Filter filter);
Sithara Punnasseryff114552017-01-10 11:40:55 -080084
85 /**
86 * Updates an existing node in the dynamic config store.
87 * This method would throw an exception if the requested node, any of its
88 * children or any parent nodes in the path were not present.
89 * Failure reason will be the error message in the exception.
90 *
91 * @param path data structure with absolute path to the parent
92 * @param node recursive data structure, holding a leaf node or a subtree
93 * @throws FailedException if the update request failed
94 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080095 void updateNode(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -080096
97 /**
98 * Updates an existing node in the dynamic config store.
99 * Any missing children nodes will be created with this request.
100 * This method would throw an exception if the requested node or any of the
101 * parent nodes in the path were not present.
102 * Failure reason will be the error message in the exception.
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 * @throws FailedException if the update request failed for any reason
107 *
108 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -0800109 void updateNodeRecursive(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -0800110
111 /**
112 * Replaces nodes in the dynamic config store.
113 * This will ensure that only the tree structure in the given DataNode will
114 * be in place after a replace. This method would throw an exception if
115 * the requested node or any of the parent nodes in the path were not
116 * present. Failure reason will be the error message in the exception.
117 *
118 * @param path data structure with absolute path to the parent
119 * @param node recursive data structure, holding a leaf node or a subtree
120 * @throws FailedException if the replace request failed
121 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -0800122 void replaceNode(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -0800123
124 /**
125 * Removes a leaf node from the dynamic config store.
126 * This method would throw an exception if the requested node or any of the
127 * parent nodes in the path were not present or the specified node is the
128 * root node or has one or more children.
129 * Failure reason will be the error message in the exception.
130 *
131 * @param path data structure with absolute path to the intended node
132 * @throws FailedException if the delete request failed
133 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -0800134 void deleteNode(ResourceId path);
Sithara Punnasseryff114552017-01-10 11:40:55 -0800135
136 /**
137 * Removes a subtree from the dynamic config store.
138 * This method will delete all the children recursively, under the given
139 * node. It will throw an exception if the requested node or any of the
140 * parent nodes in the path were not present.
141 * Failure reason will be the error message in the exception.
142 *
143 * @param path data structure with absolute path to the intended node
144 * @throws FailedException if the delete request failed
145 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -0800146 void deleteNodeRecursive(ResourceId path);
Sithara Punnasseryff114552017-01-10 11:40:55 -0800147
148 /**
149 * Adds a listener to be notified when a leaf or subtree rooted at the
150 * specified path is modified.
151 *
152 * @param path data structure with absolute path to the node being listened to
153 * @param listener listener to be notified
154 * @throws FailedException if the listener could not be added
155 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -0800156 void addConfigListener(ResourceId path, DynamicConfigListener listener);
Sithara Punnasseryff114552017-01-10 11:40:55 -0800157
158 /**
159 * Removes a previously added listener.
160 *
161 * @param path data structure with absolute path to the node being listened to
162 * @param listener listener to unregister
163 * @throws FailedException if the listener could not be removed
164 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -0800165 void removeConfigListener(ResourceId path, DynamicConfigListener listener);
Sithara Punnasseryff114552017-01-10 11:40:55 -0800166
167 /**
168 * Registers an RPC handler.
169 *
170 * @param handler RPC handler
171 * @param command RPC command
172 * @throws FailedException if the handler could not be added
173 */
174 void registerHandler(RpcHandler handler, RpcCommand command);
175
176 /**
177 * Unregisters an RPC receiver.
178 *
179 * @param handler RPC handler
180 * @param command RPC command
181 * @throws FailedException if the handler could not be removed
182 */
183 void unRegisterHandler(RpcHandler handler, RpcCommand command);
184
185 /**
186 * Invokes an RPC.
187 *
188 * @param caller of the of the RPC
189 * @param msgId RPC message id
190 * @param command RPC command
191 * @param input RPC input
192 * @throws FailedException if the RPC could not be invoked
193 */
194 void invokeRpc(RpcCaller caller, Integer msgId, RpcCommand command, RpcInput input);
195
196 /**
197 * Provides response to a a previously invoked RPC.
198 *
199 * @param msgId of a previously invoked RPC
200 * @param output data from the RPC execution
201 * @throws FailedException if the RPC response was invalid
202 * (or the msg id was not recognised by the store)
203 */
204 void rpcResponse(Integer msgId, RpcOutput output);
205}