Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 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; |
| 23 | |
| 24 | /** |
| 25 | * Service for storing and distributing dynamic configuration data. |
| 26 | */ |
Sithara Punnassery | 0620879 | 2017-02-10 16:25:29 -0800 | [diff] [blame] | 27 | @Beta |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 28 | public 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 Punnassery | 9306e6b | 2017-02-06 15:38:19 -0800 | [diff] [blame] | 41 | void createNodeRecursive(ResourceId path, DataNode node); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 42 | |
| 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 Punnassery | 9306e6b | 2017-02-06 15:38:19 -0800 | [diff] [blame] | 56 | DataNode readNode(ResourceId path, Filter filter); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 57 | |
| 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 Punnassery | 9306e6b | 2017-02-06 15:38:19 -0800 | [diff] [blame] | 69 | Integer getNumberOfChildren(ResourceId path, Filter filter); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 70 | |
| 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 Punnassery | 9306e6b | 2017-02-06 15:38:19 -0800 | [diff] [blame] | 81 | void updateNode(ResourceId path, DataNode node); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 82 | |
| 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 Punnassery | 9306e6b | 2017-02-06 15:38:19 -0800 | [diff] [blame] | 95 | void updateNodeRecursive(ResourceId path, DataNode node); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 96 | |
| 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 Punnassery | 9306e6b | 2017-02-06 15:38:19 -0800 | [diff] [blame] | 108 | void replaceNode(ResourceId path, DataNode node); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 109 | |
| 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 Punnassery | 9306e6b | 2017-02-06 15:38:19 -0800 | [diff] [blame] | 120 | void deleteNode(ResourceId path); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 121 | |
| 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 Punnassery | 9306e6b | 2017-02-06 15:38:19 -0800 | [diff] [blame] | 132 | void deleteNodeRecursive(ResourceId path); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 133 | |
| 134 | /** |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 135 | * 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 | } |