blob: 991e806279bca6e271625ecb80b4d33e384c2ac7 [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
19import org.onosproject.config.model.ResourceIdentifier;
20import org.onosproject.config.model.DataNode;
21import org.onosproject.event.ListenerService;
22
23/**
24 * Service for storing and distributing dynamic configuration data.
25 */
26public interface DynamicConfigService
27 extends ListenerService<DynamicConfigEvent, DynamicConfigListener> {
28 /**
29 * Creates a new node in the dynamic config store.
30 * This method would throw an exception if there is a node with the same
31 * identifier, already present at the specified path or any of the parent
32 * nodes were not present in the path leading up to the requested node.
33 * Failure reason will be the error message in the exception.
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 * @throws FailedException if the new node could not be created
38 */
39 void createNode(ResourceIdentifier path, DataNode node);
40
41 /**
42 * Creates a new node in the dynamic config store.
43 * Creates any missing parent nodes, leading up to the given node.
44 * This method will throw an exception if there is a node with the same
45 * identifier, already present at the specified path or any of the parent
46 * nodes were not present in the path leading up to the requested node.
47 * Failure reason will be the error message in the exception.
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 * @throws FailedException if the new node could not be created
52 */
53 void createNodeRecursive(ResourceIdentifier path, DataNode node);
54
55 /**
56 * Reads the requested node form the dynamic config store.
57 * This operation would get translated to reading a leaf node or a subtree.
58 * Will return an empty DataNode if after applying the filter, the result
59 * is an empty list of nodes. This method would throw an exception if the
60 * requested node or any parent nodes in the path were not present.
61 * Failure reason will be the error message in the exception.
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 a recursive data structure, holding a leaf node or a subtree
66 * @throws FailedException if the requested node could not be read
67 */
68 DataNode readNode(ResourceIdentifier path, Filter filter);
69
70 /**
71 * Returns the number of children under the node at the given path.
72 * This method would throw an exception if the requested node or any parent
73 * nodes in the path were not present.
74 * Failure reason will be the error message in the exception.
75 *
76 * @param path data structure with absolute path to the intended node
77 * @param filter filtering conditions to be applied on the result list of nodes
78 * @return the number of children after applying the filtering conditions if any
79 * @throws FailedException if the request failed
80 */
81 Integer getNumberOfChildren(ResourceIdentifier path, Filter filter);
82
83 /**
84 * Updates an existing node in the dynamic config store.
85 * This method would throw an exception if the requested node, any of its
86 * children or any parent nodes in the path were not present.
87 * Failure reason will be the error message in the exception.
88 *
89 * @param path data structure with absolute path to the parent
90 * @param node recursive data structure, holding a leaf node or a subtree
91 * @throws FailedException if the update request failed
92 */
93 void updateNode(ResourceIdentifier path, DataNode node);
94
95 /**
96 * Updates an existing node in the dynamic config store.
97 * Any missing children nodes will be created with this request.
98 * This method would throw an exception if the requested node or any of the
99 * parent nodes in the path were not present.
100 * Failure reason will be the error message in the exception.
101 *
102 * @param path data structure with absolute path to the parent
103 * @param node recursive data structure, holding a leaf node or a subtree
104 * @throws FailedException if the update request failed for any reason
105 *
106 */
107 void updateNodeRecursive(ResourceIdentifier path, DataNode node);
108
109 /**
110 * Replaces nodes in the dynamic config store.
111 * This will ensure that only the tree structure in the given DataNode will
112 * be in place after a replace. This method would throw an exception if
113 * the requested node or any of the parent nodes in the path were not
114 * present. Failure reason will be the error message in the exception.
115 *
116 * @param path data structure with absolute path to the parent
117 * @param node recursive data structure, holding a leaf node or a subtree
118 * @throws FailedException if the replace request failed
119 */
120 void replaceNode(ResourceIdentifier path, DataNode node);
121
122 /**
123 * Removes a leaf node from the dynamic config store.
124 * This method would throw an exception if the requested node or any of the
125 * parent nodes in the path were not present or the specified node is the
126 * root node or has one or more children.
127 * Failure reason will be the error message in the exception.
128 *
129 * @param path data structure with absolute path to the intended node
130 * @throws FailedException if the delete request failed
131 */
132 void deleteNode(ResourceIdentifier path);
133
134 /**
135 * Removes a subtree from the dynamic config store.
136 * This method will delete all the children recursively, under the given
137 * node. It will throw an exception if the requested node or any of the
138 * parent nodes in the path were not present.
139 * Failure reason will be the error message in the exception.
140 *
141 * @param path data structure with absolute path to the intended node
142 * @throws FailedException if the delete request failed
143 */
144 void deleteNodeRecursive(ResourceIdentifier path);
145
146 /**
147 * Adds a listener to be notified when a leaf or subtree rooted at the
148 * specified path is modified.
149 *
150 * @param path data structure with absolute path to the node being listened to
151 * @param listener listener to be notified
152 * @throws FailedException if the listener could not be added
153 */
154 void addConfigListener(ResourceIdentifier path, DynamicConfigListener listener);
155
156 /**
157 * Removes a previously added listener.
158 *
159 * @param path data structure with absolute path to the node being listened to
160 * @param listener listener to unregister
161 * @throws FailedException if the listener could not be removed
162 */
163 void removeConfigListener(ResourceIdentifier path, DynamicConfigListener listener);
164
165 /**
166 * Registers an RPC handler.
167 *
168 * @param handler RPC handler
169 * @param command RPC command
170 * @throws FailedException if the handler could not be added
171 */
172 void registerHandler(RpcHandler handler, RpcCommand command);
173
174 /**
175 * Unregisters an RPC receiver.
176 *
177 * @param handler RPC handler
178 * @param command RPC command
179 * @throws FailedException if the handler could not be removed
180 */
181 void unRegisterHandler(RpcHandler handler, RpcCommand command);
182
183 /**
184 * Invokes an RPC.
185 *
186 * @param caller of the of the RPC
187 * @param msgId RPC message id
188 * @param command RPC command
189 * @param input RPC input
190 * @throws FailedException if the RPC could not be invoked
191 */
192 void invokeRpc(RpcCaller caller, Integer msgId, RpcCommand command, RpcInput input);
193
194 /**
195 * Provides response to a a previously invoked RPC.
196 *
197 * @param msgId of a previously invoked RPC
198 * @param output data from the RPC execution
199 * @throws FailedException if the RPC response was invalid
200 * (or the msg id was not recognised by the store)
201 */
202 void rpcResponse(Integer msgId, RpcOutput output);
203}