Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -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.RpcInput; |
| 24 | import org.onosproject.yang.model.RpcOutput; |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 25 | |
Sithara Punnassery | 7b0c15e | 2017-07-07 15:08:19 -0700 | [diff] [blame] | 26 | import java.util.concurrent.CompletableFuture; |
| 27 | |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 28 | /** |
| 29 | * Service for storing and distributing dynamic configuration data. |
| 30 | */ |
Sithara Punnassery | 0620879 | 2017-02-10 16:25:29 -0800 | [diff] [blame] | 31 | @Beta |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 32 | public interface DynamicConfigService |
| 33 | extends ListenerService<DynamicConfigEvent, DynamicConfigListener> { |
Sithara Punnassery | 9d464a3 | 2017-07-23 16:14:02 -0700 | [diff] [blame] | 34 | |
Yuta HIGUCHI | 3b5d64e | 2017-09-12 22:44:22 -0700 | [diff] [blame] | 35 | // FIXME revisit and verify ResourceId documentation. |
| 36 | // it is likely that it actually is not expecting absolute ResourceId |
| 37 | |
| 38 | // TODO revisit which path ResourceId these API should accepting. |
| 39 | // there is inconsistency, some expect parent, some expect node itself |
| 40 | |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 41 | /** |
| 42 | * Creates a new node in the dynamic config store. |
| 43 | * This method would throw an exception if there is a node with the same |
| 44 | * identifier, already present at the specified path or any of the parent |
| 45 | * nodes were not present in the path leading up to the requested node. |
| 46 | * Failure reason will be the error message in the exception. |
| 47 | * |
Yuta HIGUCHI | 3b5d64e | 2017-09-12 22:44:22 -0700 | [diff] [blame] | 48 | * @param parent data structure with absolute path to the parent |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 49 | * @param node recursive data structure, holding a leaf node or a subtree |
| 50 | * @throws FailedException if the new node could not be created |
| 51 | */ |
Yuta HIGUCHI | 3b5d64e | 2017-09-12 22:44:22 -0700 | [diff] [blame] | 52 | void createNode(ResourceId parent, DataNode node); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 53 | |
| 54 | /** |
| 55 | * Reads the requested node form the dynamic config store. |
| 56 | * This operation would get translated to reading a leaf node or a subtree. |
| 57 | * Will return an empty DataNode if after applying the filter, the result |
| 58 | * is an empty list of nodes. This method would throw an exception if the |
| 59 | * requested node or any parent nodes in the path were not present. |
| 60 | * Failure reason will be the error message in the exception. |
| 61 | * |
| 62 | * @param path data structure with absolute path to the intended node |
| 63 | * @param filter filtering conditions to be applied on the result list of nodes |
| 64 | * @return a recursive data structure, holding a leaf node or a subtree |
| 65 | * @throws FailedException if the requested node could not be read |
| 66 | */ |
Sithara Punnassery | 9306e6b | 2017-02-06 15:38:19 -0800 | [diff] [blame] | 67 | DataNode readNode(ResourceId path, Filter filter); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 68 | |
| 69 | /** |
Sithara Punnassery | 18ffcc7 | 2017-05-18 14:24:30 -0700 | [diff] [blame] | 70 | * Returns whether the requested node exists in the Dynamic Config store. |
| 71 | * |
| 72 | * @param path data structure with absolute path to the intended node |
| 73 | * @return {@code true} if the node existed in the store |
| 74 | * {@code false} otherwise |
| 75 | */ |
| 76 | Boolean nodeExist(ResourceId path); |
| 77 | |
| 78 | /** |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 79 | * Updates an existing node in the dynamic config store. |
Sithara Punnassery | 7b0c15e | 2017-07-07 15:08:19 -0700 | [diff] [blame] | 80 | * Existing nodes will be updated and missing nodes will be created as needed. |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 81 | * This method would throw an exception if the requested node or any of the |
| 82 | * parent nodes in the path were not present. |
| 83 | * Failure reason will be the error message in the exception. |
| 84 | * |
Yuta HIGUCHI | 3b5d64e | 2017-09-12 22:44:22 -0700 | [diff] [blame] | 85 | * @param parent data structure with absolute path to the parent |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 86 | * @param node recursive data structure, holding a leaf node or a subtree |
| 87 | * @throws FailedException if the update request failed for any reason |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 88 | */ |
Yuta HIGUCHI | 3b5d64e | 2017-09-12 22:44:22 -0700 | [diff] [blame] | 89 | void updateNode(ResourceId parent, DataNode node); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 90 | |
| 91 | /** |
| 92 | * Replaces nodes in the dynamic config store. |
| 93 | * This will ensure that only the tree structure in the given DataNode will |
| 94 | * be in place after a replace. This method would throw an exception if |
| 95 | * the requested node or any of the parent nodes in the path were not |
| 96 | * present. Failure reason will be the error message in the exception. |
| 97 | * |
Yuta HIGUCHI | 3b5d64e | 2017-09-12 22:44:22 -0700 | [diff] [blame] | 98 | * @param parent data structure with absolute path to the parent |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 99 | * @param node recursive data structure, holding a leaf node or a subtree |
| 100 | * @throws FailedException if the replace request failed |
| 101 | */ |
Yuta HIGUCHI | 3b5d64e | 2017-09-12 22:44:22 -0700 | [diff] [blame] | 102 | void replaceNode(ResourceId parent, DataNode node); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 103 | |
| 104 | /** |
Sithara Punnassery | 7b0c15e | 2017-07-07 15:08:19 -0700 | [diff] [blame] | 105 | * Removes a node from the dynamic config store. |
| 106 | * If the node pointed to a subtree, that will be deleted recursively. |
| 107 | * It will throw an exception if the requested node or any of the parent nodes in the |
| 108 | * path were not present; Failure reason will be the error message in the exception. |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 109 | * |
| 110 | * @param path data structure with absolute path to the intended node |
| 111 | * @throws FailedException if the delete request failed |
| 112 | */ |
Sithara Punnassery | 9306e6b | 2017-02-06 15:38:19 -0800 | [diff] [blame] | 113 | void deleteNode(ResourceId path); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 114 | |
| 115 | /** |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 116 | * Invokes an RPC. |
| 117 | * |
Gaurav Agrawal | 142ceb0 | 2018-02-16 12:19:08 +0530 | [diff] [blame] | 118 | * @param input RPC input with ResourceId and DataNode |
| 119 | * @return future that will be completed with RpcOutput |
| 120 | * @throws FailedException if the RPC could not be invoked |
| 121 | */ |
| 122 | CompletableFuture<RpcOutput> invokeRpc(RpcInput input); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 123 | } |