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 | |
Sithara Punnassery | 0620879 | 2017-02-10 16:25:29 -0800 | [diff] [blame] | 18 | import com.google.common.annotations.Beta; |
Sithara Punnassery | 4b091dc | 2017-03-02 17:22:40 -0800 | [diff] [blame] | 19 | import org.onosproject.yang.model.DataNode; |
| 20 | import org.onosproject.yang.model.ResourceId; |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 21 | import org.onosproject.store.Store; |
| 22 | |
| 23 | import java.util.concurrent.CompletableFuture; |
| 24 | |
| 25 | /** |
| 26 | * Store interface for storing and distributing dynamic configuration data. |
| 27 | */ |
Sithara Punnassery | 0620879 | 2017-02-10 16:25:29 -0800 | [diff] [blame] | 28 | @Beta |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 29 | public interface DynamicConfigStore |
| 30 | extends Store<DynamicConfigEvent, DynamicConfigStoreDelegate> { |
| 31 | /** |
| 32 | * Adds a new node in the dynamic config store. The new node will not be |
| 33 | * added if there is a node with the same identifier, already present at |
| 34 | * the specified path or any of the parent nodes were not present in the |
| 35 | * path leading up to the requested node. |
| 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 | * @return future that is completed with {@code true} if the new node was |
| 40 | * successfully added or completed exceptionally with |
| 41 | * {@code FailedException} if node addition failed |
| 42 | */ |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 43 | |
Sithara Punnassery | 4cd2ced | 2017-03-17 17:36:43 -0700 | [diff] [blame] | 44 | CompletableFuture<Boolean> addNode(ResourceId path, DataNode node); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 45 | |
| 46 | /** |
| 47 | * Reads the requested node from the dynamic config store. |
| 48 | * This operation would get translated to reading a leaf node or a subtree. |
| 49 | * This would fail if the requested node was not present or any parent nodes |
| 50 | * in the path were not present. |
| 51 | * |
| 52 | * @param path data structure with absolute path to the intended node |
| 53 | * @param filter filtering conditions to be applied on the result list of nodes |
| 54 | * @return future that will be completed with a DataNode (will be an empty |
| 55 | * DataNode if after applying the filter, the result is an empty list of nodes) |
| 56 | * or completed with {@code FailedException} if the node could not be read |
| 57 | */ |
Sithara Punnassery | 9306e6b | 2017-02-06 15:38:19 -0800 | [diff] [blame] | 58 | CompletableFuture<DataNode> readNode(ResourceId path, Filter filter); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 59 | |
| 60 | /** |
| 61 | * Updates an existing node in the dynamic config store. |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 62 | * Any missing children will be created with this request. The update will |
| 63 | * fail if the requested node or any of the parent nodes in the path |
| 64 | * were not present. |
| 65 | * |
| 66 | * @param path data structure with absolute path to the parent |
| 67 | * @param node recursive data structure, holding a leaf node or a subtree |
| 68 | * @return future that is completed with {@code true} if the node was |
| 69 | * successfully updated or completed exceptionally with |
| 70 | * {@code FailedException} if the update request failed |
| 71 | */ |
Sithara Punnassery | 0da1a9c | 2017-05-17 16:16:22 -0700 | [diff] [blame] | 72 | CompletableFuture<Boolean> updateNode(ResourceId path, DataNode node); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 73 | |
| 74 | /** |
| 75 | * Replaces nodes in the dynamic config store. |
| 76 | * This will ensure that only the tree structure in the given DataNode will |
| 77 | * be in place after a replace. This would fail if the requested node or |
| 78 | * any of the parent nodes in the path were not present. |
| 79 | * |
| 80 | * @param path data structure with absolute path to the parent |
| 81 | * @param node recursive data structure, holding a leaf node or a subtree |
| 82 | * @return future that is completed with {@code true} if the node was |
| 83 | * successfully replaced or completed exceptionally with |
| 84 | * {@code FailedException} if the replace request failed |
| 85 | */ |
Sithara Punnassery | 9306e6b | 2017-02-06 15:38:19 -0800 | [diff] [blame] | 86 | CompletableFuture<Boolean> replaceNode(ResourceId path, DataNode node); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 87 | |
| 88 | /** |
| 89 | * Removes a node from the dynamic config store. |
| 90 | * This would fail if the requested node or any of the parent nodes in the |
| 91 | * path were not present or the specified node is the root node or has one |
| 92 | * or more children. |
| 93 | * |
| 94 | * @param path data structure with absolute path to the intended node |
| 95 | * @return future that is completed with {@code true} if the node was |
| 96 | * successfully deleted or completed exceptionally with |
| 97 | * {@code FailedException} if the delete request failed |
| 98 | */ |
Sithara Punnassery | 9306e6b | 2017-02-06 15:38:19 -0800 | [diff] [blame] | 99 | CompletableFuture<Boolean> deleteNode(ResourceId path); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 100 | |
| 101 | /** |
| 102 | * Removes a subtree from the dynamic config store. |
| 103 | * This will delete all the children recursively, under the given node. |
| 104 | * Will fail if the requested node or any of the parent nodes in |
| 105 | * the path were not present. |
| 106 | * |
| 107 | * @param path data structure with absolute path to the intended node |
| 108 | * @return future that is completed with {@code true} if the delete was |
| 109 | * successful or completed exceptionally with |
| 110 | * {@code FailedException} if the delete request failed |
| 111 | */ |
Sithara Punnassery | 9306e6b | 2017-02-06 15:38:19 -0800 | [diff] [blame] | 112 | CompletableFuture<Boolean> deleteNodeRecursive(ResourceId path); |
Sithara Punnassery | 18ffcc7 | 2017-05-18 14:24:30 -0700 | [diff] [blame] | 113 | |
| 114 | /** |
| 115 | * Returns whether the requested node exists in the Dynamic Config store. |
| 116 | * |
| 117 | * @param path data structure with absolute path to the intended node |
| 118 | * @return future that is completed with {@code true} if the node existed |
| 119 | * in the store, {@code false} otherwise |
| 120 | */ |
| 121 | CompletableFuture<Boolean> nodeExist(ResourceId path); |
Sithara Punnassery | ff11455 | 2017-01-10 11:40:55 -0800 | [diff] [blame] | 122 | } |