Search in sources :

Example 6 with GetSnapshotReply

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

the class GetSnapshotReplyActor method onReceive.

@Override
public void onReceive(final Object message) {
    if (message instanceof CaptureSnapshotReply) {
        Snapshot snapshot = Snapshot.create(((CaptureSnapshotReply) message).getSnapshotState(), params.captureSnapshot.getUnAppliedEntries(), params.captureSnapshot.getLastIndex(), params.captureSnapshot.getLastTerm(), params.captureSnapshot.getLastAppliedIndex(), params.captureSnapshot.getLastAppliedTerm(), params.electionTerm.getCurrentTerm(), params.electionTerm.getVotedFor(), params.peerInformation);
        LOG.debug("{}: Received CaptureSnapshotReply, sending {}", params.id, snapshot);
        params.replyToActor.tell(new GetSnapshotReply(params.id, snapshot), getSelf());
        getSelf().tell(PoisonPill.getInstance(), getSelf());
    } else if (message instanceof ReceiveTimeout) {
        LOG.warn("{}: Got ReceiveTimeout for inactivity - did not receive CaptureSnapshotReply within {} ms", params.id, params.receiveTimeout.toMillis());
        params.replyToActor.tell(new akka.actor.Status.Failure(new TimeoutException(String.format("Timed out after %d ms while waiting for CaptureSnapshotReply", params.receiveTimeout.toMillis()))), getSelf());
        getSelf().tell(PoisonPill.getInstance(), getSelf());
    }
}
Also used : CaptureSnapshotReply(org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshotReply) CaptureSnapshot(org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshot) Snapshot(org.opendaylight.controller.cluster.raft.persisted.Snapshot) ReceiveTimeout(akka.actor.ReceiveTimeout) GetSnapshotReply(org.opendaylight.controller.cluster.raft.client.messages.GetSnapshotReply) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

GetSnapshotReply (org.opendaylight.controller.cluster.raft.client.messages.GetSnapshotReply)6 ActorRef (akka.actor.ActorRef)4 Failure (akka.actor.Status.Failure)3 TestKit (akka.testkit.javadsl.TestKit)3 Test (org.junit.Test)3 Snapshot (org.opendaylight.controller.cluster.raft.persisted.Snapshot)3 ReceiveTimeout (akka.actor.ReceiveTimeout)2 TimeoutException (java.util.concurrent.TimeoutException)2 AbstractActorTest (org.opendaylight.controller.cluster.datastore.AbstractActorTest)2 ApplySnapshot (org.opendaylight.controller.cluster.raft.base.messages.ApplySnapshot)2 CaptureSnapshot (org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshot)2 CaptureSnapshotReply (org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshotReply)2 GetSnapshot (org.opendaylight.controller.cluster.raft.client.messages.GetSnapshot)2 SaveSnapshotFailure (akka.persistence.SaveSnapshotFailure)1 TestActorRef (akka.testkit.TestActorRef)1 ByteString (com.google.protobuf.ByteString)1 DatastoreSnapshot (org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot)1 ShardSnapshot (org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot)1 ShardManagerSnapshot (org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot)1 MockPayload (org.opendaylight.controller.cluster.raft.MockRaftActorContext.MockPayload)1