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 | package org.onosproject.config; |
| 17 | |
| 18 | import org.onosproject.config.model.DataNode; |
| 19 | import org.onosproject.config.model.ResourceIdentifier; |
| 20 | import org.onosproject.store.Store; |
| 21 | |
| 22 | import java.util.concurrent.CompletableFuture; |
| 23 | |
| 24 | /** |
| 25 | * Store interface for storing and distributing dynamic configuration data. |
| 26 | */ |
| 27 | public interface DynamicConfigStore |
| 28 | extends Store<DynamicConfigEvent, DynamicConfigStoreDelegate> { |
| 29 | /** |
| 30 | * Adds a new node in the dynamic config store. The new node will not be |
| 31 | * added if there is a node with the same identifier, already present at |
| 32 | * the specified path or any of the parent nodes were not present in the |
| 33 | * path leading up to the requested node. |
| 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 | * @return future that is completed with {@code true} if the new node was |
| 38 | * successfully added or completed exceptionally with |
| 39 | * {@code FailedException} if node addition failed |
| 40 | */ |
| 41 | CompletableFuture<Boolean> addNode(ResourceIdentifier path, DataNode node); |
| 42 | |
| 43 | /** |
| 44 | * Adds a new node in the dynamic config store. |
| 45 | * Creates any missing parent nodes, leading up to the given node. Node |
| 46 | * will not be added if there is a node with the same identifier, already |
| 47 | * present at the specified path. |
| 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 | * @return future that is completed with {@code true} if the node was |
| 52 | * successfully added or completed exceptionally with |
| 53 | * {@code FailedException} if the node addition failed |
| 54 | */ |
| 55 | CompletableFuture<Boolean> addRecursive(ResourceIdentifier path, DataNode node); |
| 56 | |
| 57 | /** |
| 58 | * Reads the requested node from the dynamic config store. |
| 59 | * This operation would get translated to reading a leaf node or a subtree. |
| 60 | * This would fail if the requested node was not present or any parent nodes |
| 61 | * in the path were not present. |
| 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 future that will be completed with a DataNode (will be an empty |
| 66 | * DataNode if after applying the filter, the result is an empty list of nodes) |
| 67 | * or completed with {@code FailedException} if the node could not be read |
| 68 | */ |
| 69 | CompletableFuture<DataNode> readNode(ResourceIdentifier path, Filter filter); |
| 70 | |
| 71 | /** |
| 72 | * Updates an existing node in the dynamic config store. |
| 73 | * This request would fail if the requested node, any of its children or |
| 74 | * any parent nodes in the path were not present. |
| 75 | * |
| 76 | * @param path data structure with absolute path to the parent |
| 77 | * @param node recursive data structure, holding a leaf node or a subtree |
| 78 | * @return future that is completed with {@code true} if the node was |
| 79 | * successfully updated or completed exceptionally with |
| 80 | * {@code FailedException} if the update request failed |
| 81 | */ |
| 82 | CompletableFuture<Boolean> updateNode(ResourceIdentifier path, DataNode node); |
| 83 | |
| 84 | /** |
| 85 | * Updates an existing node in the dynamic config store. |
| 86 | * Any missing children will be created with this request. The update will |
| 87 | * fail if the requested node or any of the parent nodes in the path |
| 88 | * were not present. |
| 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 | * @return future that is completed with {@code true} if the node was |
| 93 | * successfully updated or completed exceptionally with |
| 94 | * {@code FailedException} if the update request failed |
| 95 | */ |
| 96 | CompletableFuture<Boolean> updateNodeRecursive(ResourceIdentifier path, DataNode node); |
| 97 | |
| 98 | /** |
| 99 | * Replaces nodes in the dynamic config store. |
| 100 | * This will ensure that only the tree structure in the given DataNode will |
| 101 | * be in place after a replace. This would fail if the requested node or |
| 102 | * any of the parent nodes in the path were not present. |
| 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 | * @return future that is completed with {@code true} if the node was |
| 107 | * successfully replaced or completed exceptionally with |
| 108 | * {@code FailedException} if the replace request failed |
| 109 | */ |
| 110 | CompletableFuture<Boolean> replaceNode(ResourceIdentifier path, DataNode node); |
| 111 | |
| 112 | /** |
| 113 | * Removes a node from the dynamic config store. |
| 114 | * This would fail if the requested node or any of the parent nodes in the |
| 115 | * path were not present or the specified node is the root node or has one |
| 116 | * or more children. |
| 117 | * |
| 118 | * @param path data structure with absolute path to the intended node |
| 119 | * @return future that is completed with {@code true} if the node was |
| 120 | * successfully deleted or completed exceptionally with |
| 121 | * {@code FailedException} if the delete request failed |
| 122 | */ |
| 123 | CompletableFuture<Boolean> deleteNode(ResourceIdentifier path); |
| 124 | |
| 125 | /** |
| 126 | * Removes a subtree from the dynamic config store. |
| 127 | * This will delete all the children recursively, under the given node. |
| 128 | * Will fail if the requested node or any of the parent nodes in |
| 129 | * the path were not present. |
| 130 | * |
| 131 | * @param path data structure with absolute path to the intended node |
| 132 | * @return future that is completed with {@code true} if the delete was |
| 133 | * successful or completed exceptionally with |
| 134 | * {@code FailedException} if the delete request failed |
| 135 | */ |
| 136 | CompletableFuture<Boolean> deleteNodeRecursive(ResourceIdentifier path); |
| 137 | } |