Committed by
Gerrit Code Review
ONOS-5318 Proprietary Config Store
Change-Id: Ic787d73d9d541a93f5e957a3369dbab4b5fa9a6c
Showing
15 changed files
with
931 additions
and
1 deletions
| ... | @@ -86,6 +86,17 @@ public class DocumentPath implements Comparable<DocumentPath> { | ... | @@ -86,6 +86,17 @@ public class DocumentPath implements Comparable<DocumentPath> { |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | /** | 88 | /** |
| 89 | + * Returns the relative path to the given node. | ||
| 90 | + * | ||
| 91 | + * @return relative path to the given node. | ||
| 92 | + */ | ||
| 93 | + public DocumentPath childPath() { | ||
| 94 | + if (pathElements.size() <= 1) { | ||
| 95 | + return null; | ||
| 96 | + } | ||
| 97 | + return new DocumentPath(this.pathElements.subList(pathElements.size() - 1, pathElements.size())); | ||
| 98 | + } | ||
| 99 | + /** | ||
| 89 | * Returns a path for the parent of this node. | 100 | * Returns a path for the parent of this node. |
| 90 | * | 101 | * |
| 91 | * @return parent node path. If this path is for the root, returns {@code null}. | 102 | * @return parent node path. If this path is for the root, returns {@code null}. |
| ... | @@ -183,7 +194,6 @@ public class DocumentPath implements Comparable<DocumentPath> { | ... | @@ -183,7 +194,6 @@ public class DocumentPath implements Comparable<DocumentPath> { |
| 183 | return this.pathElements.get(i).compareTo(that.pathElements.get(i)); | 194 | return this.pathElements.get(i).compareTo(that.pathElements.get(i)); |
| 184 | } | 195 | } |
| 185 | } | 196 | } |
| 186 | - | ||
| 187 | if (this.pathElements.size() > that.pathElements.size()) { | 197 | if (this.pathElements.size() > that.pathElements.size()) { |
| 188 | return 1; | 198 | return 1; |
| 189 | } else if (that.pathElements.size() > this.pathElements.size()) { | 199 | } else if (that.pathElements.size() > this.pathElements.size()) { | ... | ... |
| 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.incubator.elasticcfg; | ||
| 17 | + | ||
| 18 | +import java.util.Set; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * Abstraction for Filters that can be used while traversing the PropConfig stores. | ||
| 22 | + * This abstraction allows to select entries of interest based on various criteria | ||
| 23 | + * defined by this interface. | ||
| 24 | + * Only criteria based on {@code ConfigNodePath} are supported currently. | ||
| 25 | + * Filters can be used with "GET" methods of {@code ProprietaryConfigService} | ||
| 26 | + */ | ||
| 27 | +public interface ConfigFilter { | ||
| 28 | + /** | ||
| 29 | + * Builder for ConfigFilter. | ||
| 30 | + */ | ||
| 31 | + interface Builder { | ||
| 32 | + /** | ||
| 33 | + * Adds new ConfigNodePath filtering criteria to a ConfigFilter object. | ||
| 34 | + * If the same ConfigNodePath is already part of the criteria | ||
| 35 | + * for the object, it will not be added again, but will not throw any exceptions. | ||
| 36 | + * This will not check for the validity of the ConfigNodePath. | ||
| 37 | + * | ||
| 38 | + * @param add new criteria | ||
| 39 | + * @return a ConfigFilter builder | ||
| 40 | + */ | ||
| 41 | + Builder addCriteria(Set<ConfigNodePath> add); | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * Removes the given ConfigNodePath filtering criteria from a ConfigFilter object. | ||
| 45 | + * If the ConfigNodePath was NOT already part of the criteria for | ||
| 46 | + * the object, it will not be removed, but will not throw any exceptions. | ||
| 47 | + * This will not check for the validity of the PropCfgInstancePaths. | ||
| 48 | + * | ||
| 49 | + * @param remove criteria to be removed | ||
| 50 | + * @return a ConfigFilter builder | ||
| 51 | + */ | ||
| 52 | + Builder removeCriteria(Set<ConfigNodePath> remove); | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * Builds an immutable ConfigFilter entity. | ||
| 56 | + * | ||
| 57 | + * @return ConfigFilter | ||
| 58 | + */ | ||
| 59 | + ConfigFilter build(); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + /** | ||
| 63 | + * Method to list all the ConfigNodePath criteria that are in place for a ConfigFilter. | ||
| 64 | + * | ||
| 65 | + * @return Set of ConfigNodePath criteria for this entity | ||
| 66 | + */ | ||
| 67 | + Set<ConfigNodePath> getCriteria(); | ||
| 68 | + | ||
| 69 | + /** | ||
| 70 | + * Method to create a filter that include all entries rejected by the criteria. | ||
| 71 | + * | ||
| 72 | + * @param original filter object with a criteria set | ||
| 73 | + * @return ConfigFilter object with negated criteria set | ||
| 74 | + * @throws InvalidFilterException if the received ConfigFilter object | ||
| 75 | + * was null or if it had an empty criteria set | ||
| 76 | + */ | ||
| 77 | + ConfigFilter negateFilter(ConfigFilter original); | ||
| 78 | + | ||
| 79 | + /** | ||
| 80 | + * Method to check if the ConfigFilter has an empty criteria set. | ||
| 81 | + * | ||
| 82 | + * @return {@code true} if criteria set is empty, {@code true} otherwise. | ||
| 83 | + */ | ||
| 84 | + boolean isEmptyFilter(); | ||
| 85 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 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.incubator.elasticcfg; | ||
| 17 | + | ||
| 18 | +import java.util.List; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * Abstraction of an instance in the elastic config store. | ||
| 22 | + */ | ||
| 23 | +public interface ConfigNode<V> { | ||
| 24 | + /** | ||
| 25 | + * Builder for ConfigNode. | ||
| 26 | + */ | ||
| 27 | + interface Builder<V> { | ||
| 28 | + /** | ||
| 29 | + * Adds the type of the instance node. | ||
| 30 | + * | ||
| 31 | + * @param type node type | ||
| 32 | + * @return a ConfigNode builder | ||
| 33 | + */ | ||
| 34 | + Builder addType(NodeType type); | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * Adds the value of the instance node. | ||
| 38 | + * | ||
| 39 | + * @param value at the node | ||
| 40 | + * @return a ConfigNode builder | ||
| 41 | + */ | ||
| 42 | + Builder addValue(Class<V> value); | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * Adds children to the children field. | ||
| 46 | + * | ||
| 47 | + * @param children to be added | ||
| 48 | + * @return a ConfigNode builder | ||
| 49 | + */ | ||
| 50 | + Builder addChildren(Class<ConfigNode> children); | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * Builds an immutable ConfigNode entity. | ||
| 54 | + * | ||
| 55 | + * @return ConfigNode | ||
| 56 | + */ | ||
| 57 | + ConfigNode build(); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + /** | ||
| 61 | + * Returns the type of the instance node. | ||
| 62 | + * | ||
| 63 | + * @return node type | ||
| 64 | + */ | ||
| 65 | + NodeType type(); | ||
| 66 | + | ||
| 67 | + /** | ||
| 68 | + * Returns the value of the instance node. | ||
| 69 | + * | ||
| 70 | + * @return value at the node | ||
| 71 | + */ | ||
| 72 | + Class<V> value(); | ||
| 73 | + | ||
| 74 | + /** | ||
| 75 | + * Returns the children of the instance node. | ||
| 76 | + * | ||
| 77 | + * @return children of the node | ||
| 78 | + */ | ||
| 79 | + List<ConfigNode> children(); | ||
| 80 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 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.incubator.elasticcfg; | ||
| 17 | + | ||
| 18 | +import org.onlab.util.Identifier; | ||
| 19 | + | ||
| 20 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
| 21 | + | ||
| 22 | +/** | ||
| 23 | + * Abstraction of the key to an instance in the elastic config store. | ||
| 24 | + * Path to each node would contain info about its hierarchy too. | ||
| 25 | + */ | ||
| 26 | +public final class ConfigNodePath extends Identifier<String> { | ||
| 27 | + | ||
| 28 | + private final String parentKey; | ||
| 29 | + private final String nodeKey; | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * Creates a new ConfigNodePath from parentKey and nodeKey. | ||
| 33 | + * | ||
| 34 | + * @param parentKey absolute path to the parent. | ||
| 35 | + * @param nodeKey relative path to the node. | ||
| 36 | + */ | ||
| 37 | + public ConfigNodePath(String parentKey, String nodeKey) { | ||
| 38 | + super(checkNotNull(parentKey, "parent key is null").concat(checkNotNull(nodeKey, "node key is null"))); | ||
| 39 | + this.parentKey = parentKey; | ||
| 40 | + this.nodeKey = nodeKey; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * Returns the parent key. | ||
| 45 | + * | ||
| 46 | + * @return absolute path to the parent | ||
| 47 | + */ | ||
| 48 | + public String parentKey() { | ||
| 49 | + return parentKey; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * Returns the node key. | ||
| 54 | + * | ||
| 55 | + * @return relative path to the node | ||
| 56 | + */ | ||
| 57 | + public String nodeKey() { | ||
| 58 | + return nodeKey; | ||
| 59 | + } | ||
| 60 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 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.incubator.elasticcfg; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * Designates the store type for various Proprietary Config stores. | ||
| 20 | + */ | ||
| 21 | +public enum ConfigStoreType { | ||
| 22 | + /** | ||
| 23 | + * Network Element Config. | ||
| 24 | + */ | ||
| 25 | + NE_CONFIG, | ||
| 26 | + /** | ||
| 27 | + * Network Config. | ||
| 28 | + */ | ||
| 29 | + NW_CONFIG, | ||
| 30 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 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.incubator.elasticcfg; | ||
| 17 | + | ||
| 18 | +import org.onosproject.event.AbstractEvent; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * Describes a ProprietaryConfig event. | ||
| 22 | + */ | ||
| 23 | +public class ElasticConfigEvent extends AbstractEvent<ElasticConfigEvent.Type, ConfigNodePath> { | ||
| 24 | + | ||
| 25 | + private final ConfigNode value; | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * Type of configuration events. | ||
| 29 | + */ | ||
| 30 | + public enum Type { | ||
| 31 | + /** | ||
| 32 | + * Signifies that a prop configuration instance was added. | ||
| 33 | + */ | ||
| 34 | + NODE_ADDED, | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * Signifies that prop configuration instance was updated. | ||
| 38 | + */ | ||
| 39 | + NODE_UPDATED, | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * Signifies that prop configuration instance was removed. | ||
| 43 | + */ | ||
| 44 | + NODE_REMOVED, | ||
| 45 | + /** | ||
| 46 | + * Signifies that a prop configuration subtree was added. | ||
| 47 | + */ | ||
| 48 | + SUBTREE_ADDED, | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * Signifies that prop configuration subtree was updated. | ||
| 52 | + */ | ||
| 53 | + SUBTREE_UPDATED, | ||
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * Signifies that prop configuration subtree was removed. | ||
| 57 | + */ | ||
| 58 | + SUBTREE_REMOVED | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * Creates an event of a given type, config node value and config node path. | ||
| 63 | + * | ||
| 64 | + * @param type config node type | ||
| 65 | + * @param path config node path | ||
| 66 | + * @param value config node value | ||
| 67 | + */ | ||
| 68 | + public ElasticConfigEvent(Type type, ConfigNodePath path, ConfigNode value) { | ||
| 69 | + super(type, path); | ||
| 70 | + this.value = value; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + /** | ||
| 74 | + * Returns the config node value. | ||
| 75 | + * | ||
| 76 | + * @return ConfigNode value | ||
| 77 | + */ | ||
| 78 | + public ConfigNode value() { | ||
| 79 | + return value; | ||
| 80 | + } | ||
| 81 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
incubator/api/src/main/java/org/onosproject/incubator/elasticcfg/ElasticConfigListener.java
0 → 100644
| 1 | +/* | ||
| 2 | + * Copyright 2015-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.incubator.elasticcfg; | ||
| 17 | + | ||
| 18 | +import org.onosproject.event.EventListener; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * Entity capable of receiving elastic config change events. | ||
| 22 | + */ | ||
| 23 | +public interface ElasticConfigListener extends EventListener<ElasticConfigEvent> { | ||
| 24 | +} |
incubator/api/src/main/java/org/onosproject/incubator/elasticcfg/ElasticConfigService.java
0 → 100644
| 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.incubator.elasticcfg; | ||
| 17 | + | ||
| 18 | +import org.onosproject.event.ListenerService; | ||
| 19 | + | ||
| 20 | +import java.util.concurrent.CompletableFuture; | ||
| 21 | + | ||
| 22 | +/** | ||
| 23 | + * Service for storing and distributing elastic configuration data. | ||
| 24 | + */ | ||
| 25 | +public interface ElasticConfigService | ||
| 26 | + extends ListenerService<ElasticConfigEvent, ElasticConfigListener> { | ||
| 27 | + /** | ||
| 28 | + * Adds a new node to the elastic config store. | ||
| 29 | + * | ||
| 30 | + * @param store type of store to which the application wants to add the node to. | ||
| 31 | + * @param path data structure with absolute path to the parent and relative | ||
| 32 | + * path to the node | ||
| 33 | + * @param node data structure with nodetype and value to be stored at the node | ||
| 34 | + * @return future that is completed with {@code true} if the new node was successfully | ||
| 35 | + * added. Future will be completed with {@code false} if a node already exists at | ||
| 36 | + * the specified path. Future will be completed exceptionally with a | ||
| 37 | + * {@code FailedException} if the parent node (for the node to create) does not exist. | ||
| 38 | + */ | ||
| 39 | + CompletableFuture<Boolean> addNode(ConfigStoreType store, | ||
| 40 | + ConfigNodePath path, ConfigNode node); | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * Removes a node from the elastic config store. | ||
| 44 | + * | ||
| 45 | + * @param store type of store which the application wants to access. | ||
| 46 | + * @param path data structure with absolute path to the parent and | ||
| 47 | + * relative path to the node | ||
| 48 | + * @return future for the previous value. Future will be completed with a | ||
| 49 | + * {@code FailedException} if the node to be removed is either the root | ||
| 50 | + * node or has one or more children or if the node to be removed does not exist. | ||
| 51 | + */ | ||
| 52 | + CompletableFuture<ConfigNode> removeNode(ConfigStoreType store, ConfigNodePath path); | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * Creates/Updates a node in the elastic config store. | ||
| 56 | + * | ||
| 57 | + * @param store type of store which the application wants to access. | ||
| 58 | + * @param path data structure with absolute path to the parent and | ||
| 59 | + * relative path to the node | ||
| 60 | + * @param node data structure with nodetype and new value to be stored at the node | ||
| 61 | + * @return future for the previous value. Future will be completed with {@code null} | ||
| 62 | + * if there was no node previously at that path. | ||
| 63 | + * Future will be completed with a {@code FailedException} | ||
| 64 | + * if the parent node (for the node to create/update) does not exist. | ||
| 65 | + */ | ||
| 66 | + CompletableFuture<ConfigNode> updateNode(ConfigStoreType store, | ||
| 67 | + ConfigNodePath path, ConfigNode node); | ||
| 68 | + | ||
| 69 | + /** | ||
| 70 | + * Creates nodes in the elastic config store, recursively by creating | ||
| 71 | + * all missing intermediate nodes in the path. | ||
| 72 | + * | ||
| 73 | + * @param store type of store which the application wants to access. | ||
| 74 | + * @param path data structure with absolute path to the parent and relative | ||
| 75 | + * path to the node | ||
| 76 | + * @param node recursive data structure with nodetype and value to | ||
| 77 | + * be stored at the node | ||
| 78 | + * @return future that is completed with {@code true} if all the new | ||
| 79 | + * nodes were successfully | ||
| 80 | + * created. Future will be completed with {@code false} if any node | ||
| 81 | + * already exists at the specified path | ||
| 82 | + * //TODO | ||
| 83 | + */ | ||
| 84 | + CompletableFuture<Boolean> createRecursive(ConfigStoreType store, | ||
| 85 | + ConfigNodePath path, ConfigNode node); | ||
| 86 | + | ||
| 87 | + /** | ||
| 88 | + * Delete nodes in the elastic config store, recursively by deleting all | ||
| 89 | + * intermediate nodes in the path. | ||
| 90 | + * | ||
| 91 | + * @param store type of store which the appplication wants to access. | ||
| 92 | + * @param path data structure with absolute path to the parent and | ||
| 93 | + * relative path to the node | ||
| 94 | + * @return future that is completed with {@code true} if all the | ||
| 95 | + * nodes under the given path including the node at the path could | ||
| 96 | + * be successfully deleted. Future will be completed with {@code false} | ||
| 97 | + * if the node at the given path or any parent node | ||
| 98 | + * did not exist //TODO | ||
| 99 | + */ | ||
| 100 | + CompletableFuture<Boolean> deleteRecursive(ConfigStoreType store, ConfigNodePath path); | ||
| 101 | + | ||
| 102 | + /** | ||
| 103 | + * Creates/Updates nodes in the elastic config store, recursively by creating | ||
| 104 | + * all missing intermediate nodes in the path. | ||
| 105 | + * | ||
| 106 | + * @param store type of store which the appplication wants to access. | ||
| 107 | + * @param path data structure with absolute path to the parent and | ||
| 108 | + * relative path to the node | ||
| 109 | + * @param node recursive data structure with nodetype and value to | ||
| 110 | + * be stored at the node | ||
| 111 | + * @return future that is completed with {@code true} if all the | ||
| 112 | + * nodes under the given path | ||
| 113 | + * including the node at the path could be successfully updated. | ||
| 114 | + * Future will be completed with {@code false} if the node at the | ||
| 115 | + * given path or any parent node | ||
| 116 | + * did not exist //TODO | ||
| 117 | + */ | ||
| 118 | + CompletableFuture<Boolean> updateRecursive(ConfigStoreType store, | ||
| 119 | + ConfigNodePath path, ConfigNode node); | ||
| 120 | + | ||
| 121 | + /** | ||
| 122 | + * Returns a value node or subtree under the given path. | ||
| 123 | + * | ||
| 124 | + * @param store type of store which the application wants to access. | ||
| 125 | + * @param path data structure with absolute path to the parent and | ||
| 126 | + * relative path to the node | ||
| 127 | + * @param mode whether to retrieve the nodes recursively or not | ||
| 128 | + * @param filter filtering conditions to be applied on the result | ||
| 129 | + * list of nodes. | ||
| 130 | + * @return future that will be completed either with a value node | ||
| 131 | + * or a recursive data structure containing the subtree; | ||
| 132 | + * will be completed with {@code null} if | ||
| 133 | + * after applying the filter, the result is an empty list of nodes. | ||
| 134 | + * Future will be completed with a {@code FailedException} if path | ||
| 135 | + * does not point to a valid node. | ||
| 136 | + * | ||
| 137 | + */ | ||
| 138 | + CompletableFuture<ConfigNode> getNode(ConfigStoreType store, | ||
| 139 | + ConfigNodePath path, TraversalMode mode, | ||
| 140 | + ConfigFilter filter); | ||
| 141 | + | ||
| 142 | + /** | ||
| 143 | + * Returns the number of children under the given path, excluding | ||
| 144 | + * the node at the path. | ||
| 145 | + * | ||
| 146 | + * @param store type of store which the application wants to access. | ||
| 147 | + * @param path data structure with absolute path to the parent and | ||
| 148 | + * relative path to the node | ||
| 149 | + * @param filter how the value nodes should be filtered | ||
| 150 | + * @return future that will be completed with {@code Integer}, the | ||
| 151 | + * count of the children | ||
| 152 | + * after applying the filtering conditions as well. | ||
| 153 | + * Future will be completed with a {@code FailedException} if path | ||
| 154 | + * does not point to a valid node | ||
| 155 | + */ | ||
| 156 | + CompletableFuture<Integer> getNumberOfChildren(ConfigStoreType store, | ||
| 157 | + ConfigNodePath path, ConfigFilter filter); | ||
| 158 | + | ||
| 159 | + //TODO | ||
| 160 | + /** | ||
| 161 | + * Filter | ||
| 162 | + * What should be the filtering conditions? | ||
| 163 | + * a list of keys? node attribute/s? level1 children? | ||
| 164 | + * Merge Trees | ||
| 165 | + * add sub tree | ||
| 166 | + * delete subtree | ||
| 167 | + * update sub tree | ||
| 168 | + * get sub tree | ||
| 169 | + * How to handle big subtrees? | ||
| 170 | + * how many levels? how many results to limit? | ||
| 171 | + */ | ||
| 172 | + | ||
| 173 | + /** | ||
| 174 | + * Registers a listener to be notified when the subtree rooted at | ||
| 175 | + * the specified path | ||
| 176 | + * is modified. | ||
| 177 | + * | ||
| 178 | + * @param store type of store which the application wants to access. | ||
| 179 | + * @param path data structure with absolute path to the parent and | ||
| 180 | + * relative path to the node | ||
| 181 | + * @param listener listener to be notified | ||
| 182 | + * @return a future that is completed when the operation completes | ||
| 183 | + */ | ||
| 184 | + CompletableFuture<Void> addConfigListener(ConfigStoreType store, | ||
| 185 | + ConfigNodePath path, | ||
| 186 | + ElasticConfigListener listener); | ||
| 187 | + | ||
| 188 | + /** | ||
| 189 | + * Unregisters a previously added listener. | ||
| 190 | + * | ||
| 191 | + * @param listener listener to unregister | ||
| 192 | + * @return a future that is completed when the operation completes | ||
| 193 | + */ | ||
| 194 | + CompletableFuture<Void> removeConfigListener(ElasticConfigListener listener); | ||
| 195 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 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.incubator.elasticcfg; | ||
| 17 | + | ||
| 18 | +import org.onosproject.store.Store; | ||
| 19 | + | ||
| 20 | +import java.util.concurrent.CompletableFuture; | ||
| 21 | + | ||
| 22 | +/** | ||
| 23 | + * Store service for storing and distributing elastic configuration data. | ||
| 24 | + */ | ||
| 25 | +public interface ElasticConfigStore | ||
| 26 | + extends Store<ElasticConfigEvent, ElasticConfigStoreDelegate> { | ||
| 27 | + /** | ||
| 28 | + * Adds a new node to the ElasticConfigStore. | ||
| 29 | + * | ||
| 30 | + * @param store type of store to which the application wants to add the node to. | ||
| 31 | + * @param path data structure with absolute path to the parent and relative | ||
| 32 | + * path to the node | ||
| 33 | + * @param node data structure with nodetype and value to be stored at the node | ||
| 34 | + * @return future that is completed with {@code true} if the new node was successfully | ||
| 35 | + * added. Future will be completed with {@code false} if a node already exists at | ||
| 36 | + * the specified path. Future will be completed exceptionally with a | ||
| 37 | + * {@code FailedException} if the parent node (for the node to create) does not exist. | ||
| 38 | + */ | ||
| 39 | + CompletableFuture<Boolean> | ||
| 40 | + addNode(ConfigStoreType store, ConfigNodePath path, ConfigNode node); | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * Removes a node from the ElasticConfigStore. | ||
| 44 | + * | ||
| 45 | + * @param store type of store which the application wants to access. | ||
| 46 | + * @param path data structure with absolute path to the parent and | ||
| 47 | + * relative path to the node | ||
| 48 | + * @return future for the previous value. Future will be completed with a | ||
| 49 | + * {@code FailedException} if the node to be removed is either the root | ||
| 50 | + * node or has one or more children or if the node to be removed does not exist. | ||
| 51 | + */ | ||
| 52 | + CompletableFuture<ConfigNode> | ||
| 53 | + removeNode(ConfigStoreType store, ConfigNodePath path); | ||
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * Creates/Updates a node in the ElasticConfigStore. | ||
| 57 | + * | ||
| 58 | + * @param store type of store which the application wants to access. | ||
| 59 | + * @param path data structure with absolute path to the parent and | ||
| 60 | + * relative path to the node | ||
| 61 | + * @param node data structure with nodetype and new value to be stored at the node | ||
| 62 | + * @return future for the previous value. Future will be completed with {@code null} | ||
| 63 | + * if there was no node previously at that path. | ||
| 64 | + * Future will be completed with a {@code FailedException} | ||
| 65 | + * if the parent node (for the node to create/update) does not exist. | ||
| 66 | + */ | ||
| 67 | + CompletableFuture<ConfigNode> | ||
| 68 | + updateNode(ConfigStoreType store, ConfigNodePath path, ConfigNode node); | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * Creates nodes in the ElasticConfigStore, recursively by creating | ||
| 72 | + * all missing intermediate nodes in the path. | ||
| 73 | + * | ||
| 74 | + * @param store type of store which the application wants to access. | ||
| 75 | + * @param path data structure with absolute path to the parent and relative | ||
| 76 | + * path to the node | ||
| 77 | + * @param node recursive data structure with nodetype and value to | ||
| 78 | + * be stored at the node | ||
| 79 | + * @return future that is completed with {@code true} if all the new | ||
| 80 | + * nodes were successfully | ||
| 81 | + * created. Future will be completed with {@code false} if any node | ||
| 82 | + * already exists at the specified path | ||
| 83 | + * //TODO | ||
| 84 | + */ | ||
| 85 | + CompletableFuture<Boolean> | ||
| 86 | + createRecursive(ConfigStoreType store, ConfigNodePath path, | ||
| 87 | + ConfigNode node); | ||
| 88 | + | ||
| 89 | + /** | ||
| 90 | + * Delete nodes in the ElasticConfigStore, recursively by deleting all | ||
| 91 | + * intermediate nodes in the path. | ||
| 92 | + * | ||
| 93 | + * @param store type of store which the appplication wants to access. | ||
| 94 | + * @param path data structure with absolute path to the parent and | ||
| 95 | + * relative path to the node | ||
| 96 | + * @return future that is completed with {@code true} if all the | ||
| 97 | + * nodes under the given path including the node at the path could | ||
| 98 | + * be successfully deleted. Future will be completed with {@code false} | ||
| 99 | + * if the node at the given path or any parent node | ||
| 100 | + * did not exist //TODO | ||
| 101 | + */ | ||
| 102 | + CompletableFuture<Boolean> | ||
| 103 | + deleteRecursive(ConfigStoreType store, ConfigNodePath path); | ||
| 104 | + | ||
| 105 | + /** | ||
| 106 | + * Creates/Updates nodes in the ElasticConfigStore, recursively by creating | ||
| 107 | + * all missing intermediate nodes in the path. | ||
| 108 | + * | ||
| 109 | + * @param store type of store which the appplication wants to access. | ||
| 110 | + * @param path data structure with absolute path to the parent and | ||
| 111 | + * relative path to the node | ||
| 112 | + * @param node recursive data structure with nodetype and value to | ||
| 113 | + * be stored at the node | ||
| 114 | + * @return future that is completed with {@code true} if all the | ||
| 115 | + * nodes under the given path | ||
| 116 | + * including the node at the path could be successfully updated. | ||
| 117 | + * Future will be completed with {@code false} if the node at the | ||
| 118 | + * given path or any parent node | ||
| 119 | + * did not exist //TODO | ||
| 120 | + */ | ||
| 121 | + CompletableFuture<Boolean> | ||
| 122 | + updateRecursive(ConfigStoreType store, ConfigNodePath path, | ||
| 123 | + ConfigNode node); | ||
| 124 | + | ||
| 125 | + /** | ||
| 126 | + * Returns a value node or subtree under the given path. | ||
| 127 | + * | ||
| 128 | + * @param store type of store which the appplication wants to access. | ||
| 129 | + * @param path data structure with absolute path to the parent and | ||
| 130 | + * relative path to the node | ||
| 131 | + * @param mode wether to retrive the nodes recursivley or not | ||
| 132 | + * @param filter filtering conditions to be applied on the result | ||
| 133 | + * list of nodes. | ||
| 134 | + * @return future that will be completed either with a value node | ||
| 135 | + * or a recursive data structure containing the subtree; | ||
| 136 | + * will be completed with {@code null} if | ||
| 137 | + * after applying the filter, the result is an empty list of nodes. | ||
| 138 | + * Future will be completed with a {@code FailedException} if path | ||
| 139 | + * does not point to a valid node. | ||
| 140 | + * | ||
| 141 | + */ | ||
| 142 | + CompletableFuture<ConfigNode> | ||
| 143 | + getNode(ConfigStoreType store, ConfigNodePath path, | ||
| 144 | + TraversalMode mode, ConfigFilter filter); | ||
| 145 | + | ||
| 146 | + /** | ||
| 147 | + * Returns the number of children under the given path, excluding | ||
| 148 | + * the node at the path. | ||
| 149 | + * | ||
| 150 | + * @param store type of store which the appplication wants to access. | ||
| 151 | + * @param path data structure with absolute path to the parent and | ||
| 152 | + * relative path to the node | ||
| 153 | + * @param filter how the value nodes should be filtered | ||
| 154 | + * @return future that will be completed with {@code Integer}, the | ||
| 155 | + * count of the children | ||
| 156 | + * after applying the filtering conditions as well. | ||
| 157 | + * Future will be completed with a {@code FailedException} if path | ||
| 158 | + * does not point to a valid node | ||
| 159 | + */ | ||
| 160 | + CompletableFuture<Integer> | ||
| 161 | + getNumberOfChildren(ConfigStoreType store, | ||
| 162 | + ConfigNodePath path, ConfigFilter filter); | ||
| 163 | + | ||
| 164 | + //TODO | ||
| 165 | + /** | ||
| 166 | + * Filter | ||
| 167 | + * What should be the filtering conditions? | ||
| 168 | + * a list of keys? node attribute/s? level1 children? | ||
| 169 | + * Merge Trees | ||
| 170 | + * add sub tree | ||
| 171 | + * delete subtree | ||
| 172 | + * update sub tree | ||
| 173 | + * get sub tree | ||
| 174 | + * How to handle big subtrees? | ||
| 175 | + * how many levels? how many results to limit? | ||
| 176 | + */ | ||
| 177 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
incubator/api/src/main/java/org/onosproject/incubator/elasticcfg/ElasticConfigStoreDelegate.java
0 → 100644
| 1 | +/* | ||
| 2 | + * Copyright 2015-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.incubator.elasticcfg; | ||
| 17 | + | ||
| 18 | +import org.onosproject.store.StoreDelegate; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * Proprietary configuration store delegate abstraction. | ||
| 22 | + */ | ||
| 23 | +public interface ElasticConfigStoreDelegate extends StoreDelegate<ElasticConfigEvent> { | ||
| 24 | +} |
| 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.incubator.elasticcfg; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * Exceptions for use by the {@code PropConfigService}. | ||
| 20 | + */ | ||
| 21 | +public class FailedException extends RuntimeException { | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * Constructs a new runtime exception with no error message. | ||
| 25 | + */ | ||
| 26 | + public FailedException() { | ||
| 27 | + super(); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * Constructs a new runtime exception with the given error message. | ||
| 32 | + * | ||
| 33 | + * @param message error message | ||
| 34 | + */ | ||
| 35 | + public FailedException(String message) { | ||
| 36 | + super(message); | ||
| 37 | + } | ||
| 38 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
incubator/api/src/main/java/org/onosproject/incubator/elasticcfg/InvalidFilterException.java
0 → 100644
| 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.incubator.elasticcfg; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * Exceptions for use by the {@code ConfigFilter}. | ||
| 20 | + */ | ||
| 21 | +public class InvalidFilterException extends RuntimeException { | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * Constructs a new runtime exception with no error message. | ||
| 25 | + */ | ||
| 26 | + public InvalidFilterException() { | ||
| 27 | + super(); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * Constructs a new runtime exception with the given error message. | ||
| 32 | + * | ||
| 33 | + * @param message error message | ||
| 34 | + */ | ||
| 35 | + public InvalidFilterException(String message) { | ||
| 36 | + super(message); | ||
| 37 | + } | ||
| 38 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 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.incubator.elasticcfg; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * Node Type representation for applications. | ||
| 20 | + * Indicates the possible node types that would be communicated by/to the applications. | ||
| 21 | + */ | ||
| 22 | +public enum NodeType { | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * ROOT node of the tree. | ||
| 26 | + */ | ||
| 27 | + ROOT, | ||
| 28 | + /** | ||
| 29 | + * LEAF node on the tree. | ||
| 30 | + */ | ||
| 31 | + LEAF, | ||
| 32 | + /** | ||
| 33 | + * Subtree as a recursive data structure. | ||
| 34 | + */ | ||
| 35 | + COMPOSITE, | ||
| 36 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 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.incubator.elasticcfg; | ||
| 18 | + | ||
| 19 | +/** | ||
| 20 | + * Traversal Modes for the PropConfig Stores. | ||
| 21 | + */ | ||
| 22 | + | ||
| 23 | +public enum TraversalMode { | ||
| 24 | + /** | ||
| 25 | + * Tree will be traversed recursively. | ||
| 26 | + */ | ||
| 27 | + RECURSIVE, | ||
| 28 | + /** | ||
| 29 | + * Tree will NOT be traversed. | ||
| 30 | + */ | ||
| 31 | + NON_RECURSIVE; | ||
| 32 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +/* | ||
| 2 | + * Copyright 2015-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 | +/** | ||
| 18 | + * Abstractions for interacting with the elastic configuration subsystem. | ||
| 19 | + */ | ||
| 20 | +package org.onosproject.incubator.elasticcfg; |
-
Please register or login to post a comment