Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | ce2a03d | 2017-08-03 19:21:03 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 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 | |
| 17 | package org.onosproject.config; |
| 18 | |
Sithara Punnassery | 0620879 | 2017-02-10 16:25:29 -0800 | [diff] [blame] | 19 | import com.google.common.annotations.Beta; |
Sithara Punnassery | 4b091dc | 2017-03-02 17:22:40 -0800 | [diff] [blame] | 20 | import org.onosproject.yang.model.DataNode; |
| 21 | import org.onosproject.yang.model.ResourceId; |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 22 | import org.onosproject.event.ListenerService; |
Gaurav Agrawal | 02dbee3 | 2017-05-11 19:04:52 +0530 | [diff] [blame] | 23 | import org.onosproject.yang.model.RpcCaller; |
| 24 | import org.onosproject.yang.model.RpcCommand; |
| 25 | import org.onosproject.yang.model.RpcHandler; |
| 26 | import org.onosproject.yang.model.RpcInput; |
| 27 | import org.onosproject.yang.model.RpcOutput; |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 28 | |
| 29 | /** |
| 30 | * Service for storing and distributing dynamic configuration data. |
| 31 | */ |
Sithara Punnassery | 0620879 | 2017-02-10 16:25:29 -0800 | [diff] [blame] | 32 | @Beta |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 33 | public 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 Punnassery | 9306e6b | 2017-02-06 15:38:19 -0800 | [diff] [blame] | 46 | void createNodeRecursive(ResourceId path, DataNode node); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 47 | |
| 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 Punnassery | 9306e6b | 2017-02-06 15:38:19 -0800 | [diff] [blame] | 61 | DataNode readNode(ResourceId path, Filter filter); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 62 | |
| 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 Punnassery | 9306e6b | 2017-02-06 15:38:19 -0800 | [diff] [blame] | 74 | Integer getNumberOfChildren(ResourceId path, Filter filter); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 75 | |
| 76 | /** |
| 77 | * Updates an existing node in the dynamic config store. |
| 78 | * This method would throw an exception if the requested node, any of its |
| 79 | * children or any parent nodes in the path were not present. |
| 80 | * Failure reason will be the error message in the exception. |
| 81 | * |
| 82 | * @param path data structure with absolute path to the parent |
| 83 | * @param node recursive data structure, holding a leaf node or a subtree |
| 84 | * @throws FailedException if the update request failed |
| 85 | */ |
Sithara Punnassery | 9306e6b | 2017-02-06 15:38:19 -0800 | [diff] [blame] | 86 | void updateNode(ResourceId path, DataNode node); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 87 | |
| 88 | /** |
| 89 | * Updates an existing node in the dynamic config store. |
| 90 | * Any missing children nodes will be created with this request. |
| 91 | * This method would throw an exception if the requested node or any of the |
| 92 | * parent nodes in the path were not present. |
| 93 | * Failure reason will be the error message in the exception. |
| 94 | * |
| 95 | * @param path data structure with absolute path to the parent |
| 96 | * @param node recursive data structure, holding a leaf node or a subtree |
| 97 | * @throws FailedException if the update request failed for any reason |
| 98 | * |
| 99 | */ |
Sithara Punnassery | 9306e6b | 2017-02-06 15:38:19 -0800 | [diff] [blame] | 100 | void updateNodeRecursive(ResourceId path, DataNode node); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 101 | |
| 102 | /** |
| 103 | * Replaces nodes in the dynamic config store. |
| 104 | * This will ensure that only the tree structure in the given DataNode will |
| 105 | * be in place after a replace. This method would throw an exception if |
| 106 | * the requested node or any of the parent nodes in the path were not |
| 107 | * present. Failure reason will be the error message in the exception. |
| 108 | * |
| 109 | * @param path data structure with absolute path to the parent |
| 110 | * @param node recursive data structure, holding a leaf node or a subtree |
| 111 | * @throws FailedException if the replace request failed |
| 112 | */ |
Sithara Punnassery | 9306e6b | 2017-02-06 15:38:19 -0800 | [diff] [blame] | 113 | void replaceNode(ResourceId path, DataNode node); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 114 | |
| 115 | /** |
| 116 | * Removes a leaf node from the dynamic config store. |
| 117 | * This method would throw an exception if the requested node or any of the |
| 118 | * parent nodes in the path were not present or the specified node is the |
| 119 | * root node or has one or more children. |
| 120 | * Failure reason will be the error message in the exception. |
| 121 | * |
| 122 | * @param path data structure with absolute path to the intended node |
| 123 | * @throws FailedException if the delete request failed |
| 124 | */ |
Sithara Punnassery | 9306e6b | 2017-02-06 15:38:19 -0800 | [diff] [blame] | 125 | void deleteNode(ResourceId path); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 126 | |
| 127 | /** |
| 128 | * Removes a subtree from the dynamic config store. |
| 129 | * This method will delete all the children recursively, under the given |
| 130 | * node. It will throw an exception if the requested node or any of the |
| 131 | * parent nodes in the path were not present. |
| 132 | * Failure reason will be the error message in the exception. |
| 133 | * |
| 134 | * @param path data structure with absolute path to the intended node |
| 135 | * @throws FailedException if the delete request failed |
| 136 | */ |
Sithara Punnassery | 9306e6b | 2017-02-06 15:38:19 -0800 | [diff] [blame] | 137 | void deleteNodeRecursive(ResourceId path); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 138 | |
| 139 | /** |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 140 | * Registers an RPC handler. |
| 141 | * |
| 142 | * @param handler RPC handler |
| 143 | * @param command RPC command |
| 144 | * @throws FailedException if the handler could not be added |
| 145 | */ |
| 146 | void registerHandler(RpcHandler handler, RpcCommand command); |
| 147 | |
| 148 | /** |
| 149 | * Unregisters an RPC receiver. |
| 150 | * |
| 151 | * @param handler RPC handler |
| 152 | * @param command RPC command |
| 153 | * @throws FailedException if the handler could not be removed |
| 154 | */ |
| 155 | void unRegisterHandler(RpcHandler handler, RpcCommand command); |
| 156 | |
| 157 | /** |
| 158 | * Invokes an RPC. |
| 159 | * |
| 160 | * @param caller of the of the RPC |
| 161 | * @param msgId RPC message id |
| 162 | * @param command RPC command |
| 163 | * @param input RPC input |
| 164 | * @throws FailedException if the RPC could not be invoked |
| 165 | */ |
| 166 | void invokeRpc(RpcCaller caller, Integer msgId, RpcCommand command, RpcInput input); |
| 167 | |
| 168 | /** |
| 169 | * Provides response to a a previously invoked RPC. |
| 170 | * |
| 171 | * @param msgId of a previously invoked RPC |
| 172 | * @param output data from the RPC execution |
| 173 | * @throws FailedException if the RPC response was invalid |
| 174 | * (or the msg id was not recognised by the store) |
| 175 | */ |
| 176 | void rpcResponse(Integer msgId, RpcOutput output); |
| 177 | } |