use of org.opendaylight.controller.cluster.access.concepts.MemberName in project controller by opendaylight.
the class ShardManagerTest method testWhenMultipleShardsPresentSyncStatusMustBeTrueForAllShards.
@Test
public void testWhenMultipleShardsPresentSyncStatusMustBeTrueForAllShards() throws Exception {
LOG.info("testWhenMultipleShardsPresentSyncStatusMustBeTrueForAllShards starting");
TestShardManager shardManager = newTestShardManager(newShardMgrProps(new MockConfiguration() {
@Override
public List<String> getMemberShardNames(final MemberName memberName) {
return Arrays.asList("default", "astronauts");
}
}));
// Initially will be false
assertEquals(false, shardManager.getMBean().getSyncStatus());
// Make default shard leader
String defaultShardId = "member-1-shard-default-" + shardMrgIDSuffix;
shardManager.onReceiveCommand(new RoleChangeNotification(defaultShardId, RaftState.Follower.name(), RaftState.Leader.name()));
// default = Leader, astronauts is unknown so sync status remains false
assertEquals(false, shardManager.getMBean().getSyncStatus());
// Make astronauts shard leader as well
String astronautsShardId = "member-1-shard-astronauts-" + shardMrgIDSuffix;
shardManager.onReceiveCommand(new RoleChangeNotification(astronautsShardId, RaftState.Follower.name(), RaftState.Leader.name()));
// Now sync status should be true
assertEquals(true, shardManager.getMBean().getSyncStatus());
// Make astronauts a Follower
shardManager.onReceiveCommand(new RoleChangeNotification(astronautsShardId, RaftState.Leader.name(), RaftState.Follower.name()));
// Sync status is not true
assertEquals(false, shardManager.getMBean().getSyncStatus());
// Make the astronauts follower sync status true
shardManager.onReceiveCommand(new FollowerInitialSyncUpStatus(true, astronautsShardId));
// Sync status is now true
assertEquals(true, shardManager.getMBean().getSyncStatus());
LOG.info("testWhenMultipleShardsPresentSyncStatusMustBeTrueForAllShards ending");
}
use of org.opendaylight.controller.cluster.access.concepts.MemberName in project controller by opendaylight.
the class ShardPeerAddressResolverTest method testResolve.
@Test
public void testResolve() {
String type = "config";
ShardPeerAddressResolver resolver = new ShardPeerAddressResolver(type, MEMBER_1);
MemberName memberName = MEMBER_2;
String peerId = ShardIdentifier.create("default", memberName, type).toString();
assertEquals("resolve", null, resolver.resolve(peerId));
Address address = new Address("tcp", "system");
resolver.addPeerAddress(memberName, address);
String shardAddress = resolver.getShardActorAddress("default", memberName);
assertEquals("getShardActorAddress", address.toString() + "/user/shardmanager-" + type + "/" + memberName.getName() + "-shard-default-" + type, shardAddress);
assertEquals("resolve", shardAddress, resolver.resolve(peerId));
}
use of org.opendaylight.controller.cluster.access.concepts.MemberName in project controller by opendaylight.
the class ShardManager method getPeerAddresses.
private Map<String, String> getPeerAddresses(final String shardName, final Collection<MemberName> members) {
Map<String, String> peerAddresses = new HashMap<>();
MemberName currentMemberName = this.cluster.getCurrentMemberName();
for (MemberName memberName : members) {
if (!currentMemberName.equals(memberName)) {
ShardIdentifier shardId = getShardIdentifier(memberName, shardName);
String address = peerAddressResolver.getShardActorAddress(shardName, memberName);
peerAddresses.put(shardId.toString(), address);
}
}
return peerAddresses;
}
use of org.opendaylight.controller.cluster.access.concepts.MemberName in project controller by opendaylight.
the class ShardManager method memberRemoved.
private void memberRemoved(final ClusterEvent.MemberRemoved message) {
MemberName memberName = memberToName(message.member());
LOG.info("{}: Received MemberRemoved: memberName: {}, address: {}", persistenceId(), memberName, message.member().address());
peerAddressResolver.removePeerAddress(memberName);
for (ShardInformation info : localShards.values()) {
info.peerDown(memberName, getShardIdentifier(memberName, info.getShardName()).toString(), getSelf());
}
}
use of org.opendaylight.controller.cluster.access.concepts.MemberName in project controller by opendaylight.
the class ShardManager method memberUp.
private void memberUp(final ClusterEvent.MemberUp message) {
MemberName memberName = memberToName(message.member());
LOG.info("{}: Received MemberUp: memberName: {}, address: {}", persistenceId(), memberName, message.member().address());
memberUp(memberName, message.member().address());
}
Aggregations