blob: 790951a019098030e40ca6014e1eb2961ebe968a [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;
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 createNodeRecursive(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -080042
43 /**
44 * Reads the requested node form the dynamic config store.
45 * This operation would get translated to reading a leaf node or a subtree.
46 * Will return an empty DataNode if after applying the filter, the result
47 * is an empty list of nodes. This method would throw an exception if the
48 * requested node or any parent nodes in the path were not present.
49 * Failure reason will be the error message in the exception.
50 *
51 * @param path data structure with absolute path to the intended node
52 * @param filter filtering conditions to be applied on the result list of nodes
53 * @return a recursive data structure, holding a leaf node or a subtree
54 * @throws FailedException if the requested node could not be read
55 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080056 DataNode readNode(ResourceId path, Filter filter);
Sithara Punnasseryff114552017-01-10 11:40:55 -080057
58 /**
59 * Returns the number of children under the node at the given path.
60 * This method would throw an exception if the requested node or any parent
61 * nodes in the path were not present.
62 * Failure reason will be the error message in the exception.
63 *
64 * @param path data structure with absolute path to the intended node
65 * @param filter filtering conditions to be applied on the result list of nodes
66 * @return the number of children after applying the filtering conditions if any
67 * @throws FailedException if the request failed
68 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080069 Integer getNumberOfChildren(ResourceId path, Filter filter);
Sithara Punnasseryff114552017-01-10 11:40:55 -080070
71 /**
72 * Updates an existing node in the dynamic config store.
73 * This method would throw an exception if the requested node, any of its
74 * children or any parent nodes in the path were not present.
75 * Failure reason will be the error message in the exception.
76 *
77 * @param path data structure with absolute path to the parent
78 * @param node recursive data structure, holding a leaf node or a subtree
79 * @throws FailedException if the update request failed
80 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080081 void updateNode(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -080082
83 /**
84 * Updates an existing node in the dynamic config store.
85 * Any missing children nodes will be created with this request.
86 * This method would throw an exception if the requested node or any of the
87 * parent nodes in the path were not present.
88 * Failure reason will be the error message in the exception.
89 *
90 * @param path data structure with absolute path to the parent
91 * @param node recursive data structure, holding a leaf node or a subtree
92 * @throws FailedException if the update request failed for any reason
93 *
94 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -080095 void updateNodeRecursive(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -080096
97 /**
98 * Replaces nodes in the dynamic config store.
99 * This will ensure that only the tree structure in the given DataNode will
100 * be in place after a replace. This method would throw an exception if
101 * the requested node or any of the parent nodes in the path were not
102 * present. 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 replace request failed
107 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -0800108 void replaceNode(ResourceId path, DataNode node);
Sithara Punnasseryff114552017-01-10 11:40:55 -0800109
110 /**
111 * Removes a leaf node from the dynamic config store.
112 * This method would throw an exception if the requested node or any of the
113 * parent nodes in the path were not present or the specified node is the
114 * root node or has one or more children.
115 * Failure reason will be the error message in the exception.
116 *
117 * @param path data structure with absolute path to the intended node
118 * @throws FailedException if the delete request failed
119 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -0800120 void deleteNode(ResourceId path);
Sithara Punnasseryff114552017-01-10 11:40:55 -0800121
122 /**
123 * Removes a subtree from the dynamic config store.
124 * This method will delete all the children recursively, under the given
125 * node. It will throw an exception if the requested node or any of the
126 * parent nodes in the path were not present.
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 */
Sithara Punnassery9306e6b2017-02-06 15:38:19 -0800132 void deleteNodeRecursive(ResourceId path);
Sithara Punnasseryff114552017-01-10 11:40:55 -0800133
134 /**
Sithara Punnasseryff114552017-01-10 11:40:55 -0800135 * Registers an RPC handler.
136 *
137 * @param handler RPC handler
138 * @param command RPC command
139 * @throws FailedException if the handler could not be added
140 */
141 void registerHandler(RpcHandler handler, RpcCommand command);
142
143 /**
144 * Unregisters an RPC receiver.
145 *
146 * @param handler RPC handler
147 * @param command RPC command
148 * @throws FailedException if the handler could not be removed
149 */
150 void unRegisterHandler(RpcHandler handler, RpcCommand command);
151
152 /**
153 * Invokes an RPC.
154 *
155 * @param caller of the of the RPC
156 * @param msgId RPC message id
157 * @param command RPC command
158 * @param input RPC input
159 * @throws FailedException if the RPC could not be invoked
160 */
161 void invokeRpc(RpcCaller caller, Integer msgId, RpcCommand command, RpcInput input);
162
163 /**
164 * Provides response to a a previously invoked RPC.
165 *
166 * @param msgId of a previously invoked RPC
167 * @param output data from the RPC execution
168 * @throws FailedException if the RPC response was invalid
169 * (or the msg id was not recognised by the store)
170 */
171 void rpcResponse(Integer msgId, RpcOutput output);
172}