BUG-2138: Create DistributedShardFrontend
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / config / Configuration.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.cluster.datastore.config;
10
11 import java.util.Collection;
12 import java.util.Map;
13 import java.util.Set;
14 import javax.annotation.Nonnull;
15 import javax.annotation.Nullable;
16 import org.opendaylight.controller.cluster.access.concepts.MemberName;
17 import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategy;
18 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
19
20 public interface Configuration {
21
22     /**
23      * Returns all the shard names that belong on the member by the given name.
24      */
25     @Nonnull Collection<String> getMemberShardNames(@Nonnull MemberName memberName);
26
27     /**
28      * Returns the module name for the given namespace name or null if not found.
29      */
30     @Nullable String getModuleNameFromNameSpace(@Nonnull String nameSpace);
31
32     /**
33      * Returns the first shard name corresponding to the given module name or null if none is configured.
34      */
35     @Nullable String getShardNameForModule(@Nonnull String moduleName);
36
37     /**
38      * Return the shard name corresponding to the prefix, or null if none is configured.
39      */
40     @Nullable String getShardNameForPrefix(@Nonnull DOMDataTreeIdentifier prefix);
41
42     /**
43      * Returns the member replicas for the given shard name.
44      */
45     @Nonnull Collection<MemberName> getMembersFromShardName(@Nonnull String shardName);
46
47     /**
48      * Returns the ShardStrategy for the given module name or null if the module is not found.
49      */
50     @Nullable ShardStrategy getStrategyForModule(@Nonnull String moduleName);
51
52     /**
53      * Returns all the configured shard names.
54      */
55     Set<String> getAllShardNames();
56
57     /**
58      * Adds a new configuration for a module and shard.
59      */
60     void addModuleShardConfiguration(@Nonnull ModuleShardConfiguration config);
61
62     /**
63      * Adds a new configuration for a shard based on prefix.
64      */
65     void addPrefixShardConfiguration(@Nonnull PrefixShardConfiguration config);
66
67     /**
68      * Removes a shard configuration for the specified prefix.
69      */
70     void removePrefixShardConfiguration(@Nonnull DOMDataTreeIdentifier prefix);
71
72     /**
73      * Returns the configuration for all configured prefix shards.
74      *
75      * @return An immutable copy of the currently configured prefix shards.
76      */
77     Map<DOMDataTreeIdentifier, PrefixShardConfiguration> getAllPrefixShardConfigurations();
78
79     /**
80      * Returns a unique set of all member names configured for all shards.
81      */
82     Collection<MemberName> getUniqueMemberNamesForAllShards();
83
84     /*
85      * Verifies if the given module shard in available in the cluster
86      */
87     boolean isShardConfigured(String shardName);
88
89     /**
90      * Adds the given member as the new replica for the given shardName.
91      */
92     void addMemberReplicaForShard(String shardName, MemberName memberName);
93
94     /**
95      * Removes the given member as a replica for the given shardName.
96      */
97     void removeMemberReplicaForShard(String shardName, MemberName memberName);
98
99     /**
100      * Returns the ShardStrategy for the given prefix or null if the prefix is not found.
101      */
102     @Nullable ShardStrategy getStrategyForPrefix(@Nonnull DOMDataTreeIdentifier prefix);
103 }