Search in sources :

Example 1 with ReceiveTimeout

use of akka.actor.ReceiveTimeout in project controller by opendaylight.

the class ShardManagerGetSnapshotReplyActor method onReceive.

@Override
public void onReceive(final Object message) {
    if (message instanceof GetSnapshotReply) {
        onGetSnapshotReply((GetSnapshotReply) message);
    } else if (message instanceof Failure) {
        LOG.debug("{}: Received {}", params.id, message);
        params.replyToActor.tell(message, getSelf());
        getSelf().tell(PoisonPill.getInstance(), getSelf());
    } else if (message instanceof ReceiveTimeout) {
        String msg = String.format("Timed out after %s ms while waiting for snapshot replies from %d shard(s). %d shard(s) %s " + "did not respond.", params.receiveTimeout.toMillis(), params.shardNames.size(), remainingShardNames.size(), remainingShardNames);
        LOG.warn("{}: {}", params.id, msg);
        params.replyToActor.tell(new Failure(new TimeoutException(msg)), getSelf());
        getSelf().tell(PoisonPill.getInstance(), getSelf());
    }
}
Also used : ReceiveTimeout(akka.actor.ReceiveTimeout) Failure(akka.actor.Status.Failure) GetSnapshotReply(org.opendaylight.controller.cluster.raft.client.messages.GetSnapshotReply) TimeoutException(java.util.concurrent.TimeoutException)

Example 2 with ReceiveTimeout

use of akka.actor.ReceiveTimeout 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

ReceiveTimeout (akka.actor.ReceiveTimeout)2 TimeoutException (java.util.concurrent.TimeoutException)2 GetSnapshotReply (org.opendaylight.controller.cluster.raft.client.messages.GetSnapshotReply)2 Failure (akka.actor.Status.Failure)1 CaptureSnapshot (org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshot)1 CaptureSnapshotReply (org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshotReply)1 Snapshot (org.opendaylight.controller.cluster.raft.persisted.Snapshot)1