Search in sources :

Example 31 with MemberName

use of org.opendaylight.controller.cluster.access.concepts.MemberName in project controller by opendaylight.

the class ConfigurationImplTest method testAddModuleShardConfiguration.

@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());
}
Also used : ShardStrategy(org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategy) ModuleShardStrategy(org.opendaylight.controller.cluster.datastore.shardstrategy.ModuleShardStrategy) MemberName(org.opendaylight.controller.cluster.access.concepts.MemberName) URI(java.net.URI) Test(org.junit.Test)

Example 32 with MemberName

use of org.opendaylight.controller.cluster.access.concepts.MemberName in project controller by opendaylight.

the class ConfigurationImplTest method testAddMemberReplicaForShard.

@Test
public void testAddMemberReplicaForShard() {
    configuration.addMemberReplicaForShard("people-1", MEMBER_2);
    String shardName = configuration.getShardNameForModule("people");
    assertEquals("ModuleShardName", "people-1", shardName);
    ShardStrategy shardStrategy = configuration.getStrategyForModule("people");
    assertEquals("ModuleStrategy", ModuleShardStrategy.class, shardStrategy.getClass());
    Collection<MemberName> members = configuration.getMembersFromShardName("people-1");
    assertEquals("Members", ImmutableSortedSet.of(MEMBER_1, MEMBER_2), ImmutableSortedSet.copyOf(members));
    configuration.addMemberReplicaForShard("non-existent", MEMBER_2);
    Set<String> shardNames = configuration.getAllShardNames();
    assertEquals("ShardNames", ImmutableSortedSet.of("people-1", "cars-1", "test-1", "default"), ImmutableSortedSet.copyOf(shardNames));
}
Also used : ShardStrategy(org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategy) ModuleShardStrategy(org.opendaylight.controller.cluster.datastore.shardstrategy.ModuleShardStrategy) MemberName(org.opendaylight.controller.cluster.access.concepts.MemberName) Test(org.junit.Test)

Aggregations

MemberName (org.opendaylight.controller.cluster.access.concepts.MemberName)32 Test (org.junit.Test)6 HashMap (java.util.HashMap)5 ActorRef (akka.actor.ActorRef)4 Configuration (org.opendaylight.controller.cluster.datastore.config.Configuration)3 AddressFromURIString (akka.actor.AddressFromURIString)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Entry (java.util.Map.Entry)2 Before (org.junit.Before)2 AbstractShardManagerTest (org.opendaylight.controller.cluster.datastore.AbstractShardManagerTest)2 DatastoreContext (org.opendaylight.controller.cluster.datastore.DatastoreContext)2 DatastoreContextFactory (org.opendaylight.controller.cluster.datastore.DatastoreContextFactory)2 ModuleShardConfiguration (org.opendaylight.controller.cluster.datastore.config.ModuleShardConfiguration)2 ShardIdentifier (org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier)2 CreateShard (org.opendaylight.controller.cluster.datastore.messages.CreateShard)2 ModuleShardStrategy (org.opendaylight.controller.cluster.datastore.shardstrategy.ModuleShardStrategy)2 ShardStrategy (org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategy)2 MockConfiguration (org.opendaylight.controller.cluster.datastore.utils.MockConfiguration)2 Address (akka.actor.Address)1