use of org.opendaylight.controller.cluster.raft.messages.RemoveServerReply in project controller by opendaylight.
the class RaftActorServerConfigurationSupportTest method testRemoveServerNonExistentServer.
@Test
public void testRemoveServerNonExistentServer() {
LOG.info("testRemoveServerNonExistentServer starting");
RaftActorContext initialActorContext = new MockRaftActorContext();
TestActorRef<MockLeaderRaftActor> leaderActor = actorFactory.createTestActor(MockLeaderRaftActor.props(ImmutableMap.of(FOLLOWER_ID, followerActor.path().toString()), initialActorContext).withDispatcher(Dispatchers.DefaultDispatcherId()), actorFactory.generateActorId(LEADER_ID));
leaderActor.tell(new RemoveServer(NEW_SERVER_ID), testKit.getRef());
RemoveServerReply removeServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), RemoveServerReply.class);
assertEquals("getStatus", ServerChangeStatus.DOES_NOT_EXIST, removeServerReply.getStatus());
LOG.info("testRemoveServerNonExistentServer ending");
}
use of org.opendaylight.controller.cluster.raft.messages.RemoveServerReply in project controller by opendaylight.
the class ShardManagerTest method testRemoveShardReplicaLocal.
@Test
public /**
* Primary is Local.
*/
void testRemoveShardReplicaLocal() throws Exception {
new TestKit(getSystem()) {
{
String memberId = "member-1-shard-default-" + shardMrgIDSuffix;
final ActorRef respondActor = actorFactory.createActor(Props.create(MockRespondActor.class, RemoveServer.class, new RemoveServerReply(ServerChangeStatus.OK, null)), memberId);
ActorRef shardManager = getSystem().actorOf(newPropsShardMgrWithMockShardActor(respondActor));
shardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());
shardManager.tell(new ActorInitialized(), respondActor);
shardManager.tell(new ShardLeaderStateChanged(memberId, memberId, mock(DataTree.class), DataStoreVersions.CURRENT_VERSION), getRef());
shardManager.tell(new RoleChangeNotification(memberId, RaftState.Candidate.name(), RaftState.Leader.name()), respondActor);
shardManager.tell(new RemoveShardReplica(Shard.DEFAULT_NAME, MEMBER_1), getRef());
final RemoveServer removeServer = MessageCollectorActor.expectFirstMatching(respondActor, RemoveServer.class);
assertEquals(ShardIdentifier.create("default", MEMBER_1, shardMrgIDSuffix).toString(), removeServer.getServerId());
expectMsgClass(duration("5 seconds"), Success.class);
}
};
}
use of org.opendaylight.controller.cluster.raft.messages.RemoveServerReply in project controller by opendaylight.
the class RaftActorServerConfigurationSupport method onRemoveServer.
private void onRemoveServer(final RemoveServer removeServer, final ActorRef sender) {
LOG.debug("{}: onRemoveServer: {}, state: {}", raftContext.getId(), removeServer, currentOperationState);
boolean isSelf = removeServer.getServerId().equals(raftContext.getId());
if (isSelf && !raftContext.hasFollowers()) {
sender.tell(new RemoveServerReply(ServerChangeStatus.NOT_SUPPORTED, raftActor.getLeaderId()), raftActor.getSelf());
} else if (!isSelf && !raftContext.getPeerIds().contains(removeServer.getServerId())) {
sender.tell(new RemoveServerReply(ServerChangeStatus.DOES_NOT_EXIST, raftActor.getLeaderId()), raftActor.getSelf());
} else {
String serverAddress = isSelf ? raftActor.self().path().toString() : raftContext.getPeerAddress(removeServer.getServerId());
onNewOperation(new RemoveServerContext(removeServer, serverAddress, sender));
}
}
Aggregations