@Test public void testAddModuleShardConfiguration() throws Exception { URI namespace = new URI("urn:opendaylight:test:oven"); String moduleName = "oven"; String shardName = "oven-shard"; String shardStrategyName = ModuleShardStrategy.NAME; Collection<MemberName> shardMemberNames = ImmutableSortedSet.of(MEMBER_1, MEMBER_4, MEMBER_5); configuration.addModuleShardConfiguration(new ModuleShardConfiguration(namespace, moduleName, shardName, shardStrategyName, shardMemberNames)); assertEquals("getMemberShardNames", ImmutableSortedSet.of("people-1", "cars-1", "test-1", "default", shardName), ImmutableSortedSet.copyOf(configuration.getMemberShardNames(MEMBER_1))); assertEquals("getMemberShardNames", ImmutableSortedSet.of(shardName), ImmutableSortedSet.copyOf(configuration.getMemberShardNames(MEMBER_4))); assertEquals("getMemberShardNames", ImmutableSortedSet.of(shardName), ImmutableSortedSet.copyOf(configuration.getMemberShardNames(MEMBER_5))); assertEquals("getMembersFromShardName", shardMemberNames, ImmutableSortedSet.copyOf(configuration.getMembersFromShardName(shardName))); assertEquals("getShardNameForModule", shardName, configuration.getShardNameForModule(moduleName)); assertEquals("getModuleNameFromNameSpace", moduleName, configuration.getModuleNameFromNameSpace(namespace.toASCIIString())); assertEquals("getAllShardNames", ImmutableSortedSet.of("people-1", "cars-1", "test-1", "default", shardName), ImmutableSortedSet.copyOf(configuration.getAllShardNames())); ShardStrategy strategy = configuration.getStrategyForModule("cars"); assertNotNull("getStrategyForModule null", strategy); assertEquals("getStrategyForModule type", ModuleShardStrategy.class, strategy.getClass()); }
@Override public synchronized void addModuleShardConfiguration(final ModuleShardConfiguration config) { requireNonNull(config, "ModuleShardConfiguration should not be null"); ModuleConfig moduleConfig = ModuleConfig.builder(config.getModuleName()) .nameSpace(config.getNamespace().toASCIIString()) .shardStrategy(createShardStrategy(config.getModuleName(), config.getShardStrategyName())) .shardConfig(config.getShardName(), config.getShardMemberNames()).build(); updateModuleConfigMap(moduleConfig); namespaceToModuleName = ImmutableMap.<String, String>builder().putAll(namespaceToModuleName) .put(moduleConfig.getNamespace(), moduleConfig.getName()).build(); allShardNames = ImmutableSet.<String>builder().addAll(allShardNames).add(config.getShardName()).build(); }
ConfigurationImpl implements Configuration { @Override public synchronized void addModuleShardConfiguration(final ModuleShardConfiguration config) { requireNonNull(config, "ModuleShardConfiguration should not be null"); ModuleConfig moduleConfig = ModuleConfig.builder(config.getModuleName()) .nameSpace(config.getNamespace().toASCIIString()) .shardStrategy(createShardStrategy(config.getModuleName(), config.getShardStrategyName())) .shardConfig(config.getShardName(), config.getShardMemberNames()).build(); updateModuleConfigMap(moduleConfig); namespaceToModuleName = ImmutableMap.<String, String>builder().putAll(namespaceToModuleName) .put(moduleConfig.getNamespace(), moduleConfig.getName()).build(); allShardNames = ImmutableSet.<String>builder().addAll(allShardNames).add(config.getShardName()).build(); } }
ConfigurationImpl implements Configuration { @Override public synchronized void addModuleShardConfiguration(final ModuleShardConfiguration config) { requireNonNull(config, "ModuleShardConfiguration should not be null"); ModuleConfig moduleConfig = ModuleConfig.builder(config.getModuleName()) .nameSpace(config.getNamespace().toASCIIString()) .shardStrategy(createShardStrategy(config.getModuleName(), config.getShardStrategyName())) .shardConfig(config.getShardName(), config.getShardMemberNames()).build(); updateModuleConfigMap(moduleConfig); namespaceToModuleName = ImmutableMap.<String, String>builder().putAll(namespaceToModuleName) .put(moduleConfig.getNamespace(), moduleConfig.getName()).build(); allShardNames = ImmutableSet.<String>builder().addAll(allShardNames).add(config.getShardName()).build(); } ConfigurationImpl(final String moduleShardsConfigPath, final String modulesConfigPath);  ConfigurationImpl(final ModuleShardConfigProvider provider); }
ConfigurationImpl implements Configuration { @Override public synchronized void addModuleShardConfiguration(final ModuleShardConfiguration config) { requireNonNull(config, "ModuleShardConfiguration should not be null"); ModuleConfig moduleConfig = ModuleConfig.builder(config.getModuleName()) .nameSpace(config.getNamespace().toASCIIString()) .shardStrategy(createShardStrategy(config.getModuleName(), config.getShardStrategyName())) .shardConfig(config.getShardName(), config.getShardMemberNames()).build(); updateModuleConfigMap(moduleConfig); namespaceToModuleName = ImmutableMap.<String, String>builder().putAll(namespaceToModuleName) .put(moduleConfig.getNamespace(), moduleConfig.getName()).build(); allShardNames = ImmutableSet.<String>builder().addAll(allShardNames).add(config.getShardName()).build(); } ConfigurationImpl(final String moduleShardsConfigPath, final String modulesConfigPath);  ConfigurationImpl(final ModuleShardConfigProvider provider); @Override Collection<String> getMemberShardNames(final MemberName memberName); @Override String getModuleNameFromNameSpace(final String nameSpace); @Override ShardStrategy getStrategyForModule(final String moduleName); @Override String getShardNameForModule(final String moduleName); @Override String getShardNameForPrefix(final DOMDataTreeIdentifier prefix); @Override Collection<MemberName> getMembersFromShardName(final String shardName); @Override Set<String> getAllShardNames(); @Override Collection<MemberName> getUniqueMemberNamesForAllShards(); @Override synchronized void addModuleShardConfiguration(final ModuleShardConfiguration config); @Override void addPrefixShardConfiguration(final PrefixShardConfiguration config); @Override void removePrefixShardConfiguration(final DOMDataTreeIdentifier prefix); @Override Map<DOMDataTreeIdentifier, PrefixShardConfiguration> getAllPrefixShardConfigurations(); @Override boolean isShardConfigured(final String shardName); @Override void addMemberReplicaForShard(final String shardName, final MemberName newMemberName); @Override void removeMemberReplicaForShard(final String shardName, final MemberName newMemberName); @Override ShardStrategy getStrategyForPrefix(final DOMDataTreeIdentifier prefix); }
ConfigurationImpl implements Configuration { @Override public synchronized void addModuleShardConfiguration(final ModuleShardConfiguration config) { requireNonNull(config, "ModuleShardConfiguration should not be null"); ModuleConfig moduleConfig = ModuleConfig.builder(config.getModuleName()) .nameSpace(config.getNamespace().toASCIIString()) .shardStrategy(createShardStrategy(config.getModuleName(), config.getShardStrategyName())) .shardConfig(config.getShardName(), config.getShardMemberNames()).build(); updateModuleConfigMap(moduleConfig); namespaceToModuleName = ImmutableMap.<String, String>builder().putAll(namespaceToModuleName) .put(moduleConfig.getNamespace(), moduleConfig.getName()).build(); allShardNames = ImmutableSet.<String>builder().addAll(allShardNames).add(config.getShardName()).build(); } ConfigurationImpl(final String moduleShardsConfigPath, final String modulesConfigPath);  ConfigurationImpl(final ModuleShardConfigProvider provider); @Override Collection<String> getMemberShardNames(final MemberName memberName); @Override String getModuleNameFromNameSpace(final String nameSpace); @Override ShardStrategy getStrategyForModule(final String moduleName); @Override String getShardNameForModule(final String moduleName); @Override String getShardNameForPrefix(final DOMDataTreeIdentifier prefix); @Override Collection<MemberName> getMembersFromShardName(final String shardName); @Override Set<String> getAllShardNames(); @Override Collection<MemberName> getUniqueMemberNamesForAllShards(); @Override synchronized void addModuleShardConfiguration(final ModuleShardConfiguration config); @Override void addPrefixShardConfiguration(final PrefixShardConfiguration config); @Override void removePrefixShardConfiguration(final DOMDataTreeIdentifier prefix); @Override Map<DOMDataTreeIdentifier, PrefixShardConfiguration> getAllPrefixShardConfigurations(); @Override boolean isShardConfigured(final String shardName); @Override void addMemberReplicaForShard(final String shardName, final MemberName newMemberName); @Override void removeMemberReplicaForShard(final String shardName, final MemberName newMemberName); @Override ShardStrategy getStrategyForPrefix(final DOMDataTreeIdentifier prefix);  }