+ @Override public Optional<String> getModuleNameFromNameSpace(String nameSpace) {
+
+ Preconditions.checkNotNull(nameSpace, "nameSpace should not be null");
+
+ for(Module m : modules){
+ if(m.getNameSpace().equals(nameSpace)){
+ return Optional.of(m.getName());
+ }
+ }
+ return Optional.absent();
+ }
+
+ @Override public Map<String, ShardStrategy> getModuleNameToShardStrategyMap() {
+ Map<String, ShardStrategy> map = new HashMap<>();
+ for(Module m : modules){
+ map.put(m.getName(), m.getShardStrategy());
+ }
+ return map;
+ }
+
+ @Override public List<String> getShardNamesFromModuleName(String moduleName) {
+
+ Preconditions.checkNotNull(moduleName, "moduleName should not be null");
+
+ for(ModuleShard m : moduleShards){
+ if(m.getModuleName().equals(moduleName)){
+ List<String> l = new ArrayList<>();
+ for(Shard s : m.getShards()){
+ l.add(s.getName());
+ }
+ return l;
+ }
+ }
+
+ return Collections.EMPTY_LIST;
+ }
+
+ @Override public List<String> getMembersFromShardName(String shardName) {
+
+ Preconditions.checkNotNull(shardName, "shardName should not be null");
+
+ if(shardReplicaNames.containsKey(shardName)){
+ return shardReplicaNames.get(shardName);
+ }
+
+ for(ModuleShard ms : moduleShards){
+ for(Shard s : ms.getShards()) {
+ if(s.getName().equals(shardName)){
+ List<String> replicas = s.getReplicas();
+ shardReplicaNames.put(shardName, replicas);
+ return replicas;
+ }
+ }
+ }
+ shardReplicaNames.put(shardName, Collections.EMPTY_LIST);
+ return Collections.EMPTY_LIST;
+ }
+
+ @Override public Set<String> getAllShardNames() {
+ Set<String> shardNames = new LinkedHashSet<>();
+ for(ModuleShard ms : moduleShards){
+ for(Shard s : ms.getShards()) {
+ shardNames.add(s.getName());
+ }
+ }
+ return shardNames;
+ }
+
+