Search in sources :

Example 1 with ServerRemoved

use of org.opendaylight.controller.cluster.raft.messages.ServerRemoved in project controller by opendaylight.

the class ShardManagerTest method testServerRemovedShardActorRunning.

@Test
public void testServerRemovedShardActorRunning() throws Exception {
    LOG.info("testServerRemovedShardActorRunning starting");
    new TestKit(getSystem()) {

        {
            MockConfiguration mockConfig = new MockConfiguration(ImmutableMap.<String, List<String>>builder().put("default", Arrays.asList("member-1", "member-2")).put("astronauts", Arrays.asList("member-2")).put("people", Arrays.asList("member-1", "member-2")).build());
            String shardId = ShardIdentifier.create("default", MEMBER_1, shardMrgIDSuffix).toString();
            ActorRef shard = actorFactory.createActor(MessageCollectorActor.props(), shardId);
            TestActorRef<TestShardManager> shardManager = actorFactory.createTestActor(newTestShardMgrBuilder(mockConfig).addShardActor("default", shard).props().withDispatcher(Dispatchers.DefaultDispatcherId()));
            shardManager.underlyingActor().waitForRecoveryComplete();
            shardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());
            shardManager.tell(new ActorInitialized(), shard);
            waitForShardInitialized(shardManager, "people", this);
            waitForShardInitialized(shardManager, "default", this);
            // Removed the default shard replica from member-1
            shardManager.tell(new ServerRemoved(shardId), getRef());
            shardManager.underlyingActor().verifySnapshotPersisted(Sets.newHashSet("people"));
            MessageCollectorActor.expectFirstMatching(shard, Shutdown.class);
        }
    };
    LOG.info("testServerRemovedShardActorRunning ending");
}
Also used : UpdateSchemaContext(org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext) ActorRef(akka.actor.ActorRef) TestActorRef(akka.testkit.TestActorRef) ServerRemoved(org.opendaylight.controller.cluster.raft.messages.ServerRemoved) MockConfiguration(org.opendaylight.controller.cluster.datastore.utils.MockConfiguration) ActorInitialized(org.opendaylight.controller.cluster.datastore.messages.ActorInitialized) TestKit(akka.testkit.javadsl.TestKit) AddressFromURIString(akka.actor.AddressFromURIString) Test(org.junit.Test) AbstractShardManagerTest(org.opendaylight.controller.cluster.datastore.AbstractShardManagerTest)

Example 2 with ServerRemoved

use of org.opendaylight.controller.cluster.raft.messages.ServerRemoved in project controller by opendaylight.

the class Shard method handleNonRaftCommand.

@Override
protected void handleNonRaftCommand(final Object message) {
    try (MessageTracker.Context context = appendEntriesReplyTracker.received(message)) {
        final Optional<Error> maybeError = context.error();
        if (maybeError.isPresent()) {
            LOG.trace("{} : AppendEntriesReply failed to arrive at the expected interval {}", persistenceId(), maybeError.get());
        }
        store.resetTransactionBatch();
        if (message instanceof RequestEnvelope) {
            handleRequestEnvelope((RequestEnvelope) message);
        } else if (MessageAssembler.isHandledMessage(message)) {
            handleRequestAssemblerMessage(message);
        } else if (message instanceof ConnectClientRequest) {
            handleConnectClient((ConnectClientRequest) message);
        } else if (CreateTransaction.isSerializedType(message)) {
            handleCreateTransaction(message);
        } else if (message instanceof BatchedModifications) {
            handleBatchedModifications((BatchedModifications) message);
        } else if (message instanceof ForwardedReadyTransaction) {
            handleForwardedReadyTransaction((ForwardedReadyTransaction) message);
        } else if (message instanceof ReadyLocalTransaction) {
            handleReadyLocalTransaction((ReadyLocalTransaction) message);
        } else if (CanCommitTransaction.isSerializedType(message)) {
            handleCanCommitTransaction(CanCommitTransaction.fromSerializable(message));
        } else if (CommitTransaction.isSerializedType(message)) {
            handleCommitTransaction(CommitTransaction.fromSerializable(message));
        } else if (AbortTransaction.isSerializedType(message)) {
            handleAbortTransaction(AbortTransaction.fromSerializable(message));
        } else if (CloseTransactionChain.isSerializedType(message)) {
            closeTransactionChain(CloseTransactionChain.fromSerializable(message));
        } else if (message instanceof RegisterChangeListener) {
            changeSupport.onMessage((RegisterChangeListener) message, isLeader(), hasLeader());
        } else if (message instanceof RegisterDataTreeChangeListener) {
            treeChangeSupport.onMessage((RegisterDataTreeChangeListener) message, isLeader(), hasLeader());
        } else if (message instanceof UpdateSchemaContext) {
            updateSchemaContext((UpdateSchemaContext) message);
        } else if (message instanceof PeerAddressResolved) {
            PeerAddressResolved resolved = (PeerAddressResolved) message;
            setPeerAddress(resolved.getPeerId(), resolved.getPeerAddress());
        } else if (TX_COMMIT_TIMEOUT_CHECK_MESSAGE.equals(message)) {
            commitTimeoutCheck();
        } else if (message instanceof DatastoreContext) {
            onDatastoreContext((DatastoreContext) message);
        } else if (message instanceof RegisterRoleChangeListener) {
            roleChangeNotifier.get().forward(message, context());
        } else if (message instanceof FollowerInitialSyncUpStatus) {
            shardMBean.setFollowerInitialSyncStatus(((FollowerInitialSyncUpStatus) message).isInitialSyncDone());
            context().parent().tell(message, self());
        } else if (GET_SHARD_MBEAN_MESSAGE.equals(message)) {
            sender().tell(getShardMBean(), self());
        } else if (message instanceof GetShardDataTree) {
            sender().tell(store.getDataTree(), self());
        } else if (message instanceof ServerRemoved) {
            context().parent().forward(message, context());
        } else if (ShardTransactionMessageRetrySupport.TIMER_MESSAGE_CLASS.isInstance(message)) {
            messageRetrySupport.onTimerMessage(message);
        } else if (message instanceof DataTreeCohortActorRegistry.CohortRegistryCommand) {
            store.processCohortRegistryCommand(getSender(), (DataTreeCohortActorRegistry.CohortRegistryCommand) message);
        } else if (message instanceof PersistAbortTransactionPayload) {
            final TransactionIdentifier txId = ((PersistAbortTransactionPayload) message).getTransactionId();
            persistPayload(txId, AbortTransactionPayload.create(txId), true);
        } else if (message instanceof MakeLeaderLocal) {
            onMakeLeaderLocal();
        } else if (RESUME_NEXT_PENDING_TRANSACTION.equals(message)) {
            store.resumeNextPendingTransaction();
        } else if (!responseMessageSlicer.handleMessage(message)) {
            super.handleNonRaftCommand(message);
        }
    }
}
Also used : UpdateSchemaContext(org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext) RegisterRoleChangeListener(org.opendaylight.controller.cluster.notifications.RegisterRoleChangeListener) RegisterChangeListener(org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListener) ServerRemoved(org.opendaylight.controller.cluster.raft.messages.ServerRemoved) Error(org.opendaylight.controller.cluster.common.actor.MessageTracker.Error) PeerAddressResolved(org.opendaylight.controller.cluster.datastore.messages.PeerAddressResolved) MessageTracker(org.opendaylight.controller.cluster.common.actor.MessageTracker) RegisterDataTreeChangeListener(org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeChangeListener) FollowerInitialSyncUpStatus(org.opendaylight.controller.cluster.raft.base.messages.FollowerInitialSyncUpStatus) BatchedModifications(org.opendaylight.controller.cluster.datastore.messages.BatchedModifications) GetShardDataTree(org.opendaylight.controller.cluster.datastore.messages.GetShardDataTree) MakeLeaderLocal(org.opendaylight.controller.cluster.datastore.messages.MakeLeaderLocal) ConnectClientRequest(org.opendaylight.controller.cluster.access.commands.ConnectClientRequest) ReadyLocalTransaction(org.opendaylight.controller.cluster.datastore.messages.ReadyLocalTransaction) TransactionIdentifier(org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier) RequestEnvelope(org.opendaylight.controller.cluster.access.concepts.RequestEnvelope) ForwardedReadyTransaction(org.opendaylight.controller.cluster.datastore.messages.ForwardedReadyTransaction) PersistAbortTransactionPayload(org.opendaylight.controller.cluster.datastore.messages.PersistAbortTransactionPayload)

Example 3 with ServerRemoved

use of org.opendaylight.controller.cluster.raft.messages.ServerRemoved in project controller by opendaylight.

the class ShardManagerTest method testServerRemovedShardActorNotRunning.

@Test
public void testServerRemovedShardActorNotRunning() throws Exception {
    LOG.info("testServerRemovedShardActorNotRunning starting");
    new TestKit(getSystem()) {

        {
            MockConfiguration mockConfig = new MockConfiguration(ImmutableMap.<String, List<String>>builder().put("default", Arrays.asList("member-1", "member-2")).put("astronauts", Arrays.asList("member-2")).put("people", Arrays.asList("member-1", "member-2")).build());
            TestActorRef<TestShardManager> shardManager = actorFactory.createTestActor(newShardMgrProps(mockConfig).withDispatcher(Dispatchers.DefaultDispatcherId()));
            shardManager.underlyingActor().waitForRecoveryComplete();
            shardManager.tell(new FindLocalShard("people", false), getRef());
            expectMsgClass(duration("5 seconds"), NotInitializedException.class);
            shardManager.tell(new FindLocalShard("default", false), getRef());
            expectMsgClass(duration("5 seconds"), NotInitializedException.class);
            // Removed the default shard replica from member-1
            ShardIdentifier.Builder builder = new ShardIdentifier.Builder();
            ShardIdentifier shardId = builder.shardName("default").memberName(MEMBER_1).type(shardMrgIDSuffix).build();
            shardManager.tell(new ServerRemoved(shardId.toString()), getRef());
            shardManager.underlyingActor().verifySnapshotPersisted(Sets.newHashSet("people"));
        }
    };
    LOG.info("testServerRemovedShardActorNotRunning ending");
}
Also used : ServerRemoved(org.opendaylight.controller.cluster.raft.messages.ServerRemoved) FindLocalShard(org.opendaylight.controller.cluster.datastore.messages.FindLocalShard) ShardIdentifier(org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier) MockConfiguration(org.opendaylight.controller.cluster.datastore.utils.MockConfiguration) TestKit(akka.testkit.javadsl.TestKit) AddressFromURIString(akka.actor.AddressFromURIString) Test(org.junit.Test) AbstractShardManagerTest(org.opendaylight.controller.cluster.datastore.AbstractShardManagerTest)

Example 4 with ServerRemoved

use of org.opendaylight.controller.cluster.raft.messages.ServerRemoved in project controller by opendaylight.

the class ShardTest method testServerRemoved.

@Test
public void testServerRemoved() throws Exception {
    final TestActorRef<MessageCollectorActor> parent = actorFactory.createTestActor(MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()));
    final ActorRef shard = parent.underlyingActor().context().actorOf(newShardBuilder().props().withDispatcher(Dispatchers.DefaultDispatcherId()), "testServerRemoved");
    shard.tell(new ServerRemoved("test"), ActorRef.noSender());
    MessageCollectorActor.expectFirstMatching(parent, ServerRemoved.class);
}
Also used : MessageCollectorActor(org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor) ActorRef(akka.actor.ActorRef) TestActorRef(akka.testkit.TestActorRef) ServerRemoved(org.opendaylight.controller.cluster.raft.messages.ServerRemoved) Test(org.junit.Test)

Aggregations

ServerRemoved (org.opendaylight.controller.cluster.raft.messages.ServerRemoved)4 Test (org.junit.Test)3 ActorRef (akka.actor.ActorRef)2 AddressFromURIString (akka.actor.AddressFromURIString)2 TestActorRef (akka.testkit.TestActorRef)2 TestKit (akka.testkit.javadsl.TestKit)2 AbstractShardManagerTest (org.opendaylight.controller.cluster.datastore.AbstractShardManagerTest)2 UpdateSchemaContext (org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext)2 MockConfiguration (org.opendaylight.controller.cluster.datastore.utils.MockConfiguration)2 ConnectClientRequest (org.opendaylight.controller.cluster.access.commands.ConnectClientRequest)1 RequestEnvelope (org.opendaylight.controller.cluster.access.concepts.RequestEnvelope)1 TransactionIdentifier (org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier)1 MessageTracker (org.opendaylight.controller.cluster.common.actor.MessageTracker)1 Error (org.opendaylight.controller.cluster.common.actor.MessageTracker.Error)1 ShardIdentifier (org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier)1 ActorInitialized (org.opendaylight.controller.cluster.datastore.messages.ActorInitialized)1 BatchedModifications (org.opendaylight.controller.cluster.datastore.messages.BatchedModifications)1 FindLocalShard (org.opendaylight.controller.cluster.datastore.messages.FindLocalShard)1 ForwardedReadyTransaction (org.opendaylight.controller.cluster.datastore.messages.ForwardedReadyTransaction)1 GetShardDataTree (org.opendaylight.controller.cluster.datastore.messages.GetShardDataTree)1