X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fshardmanager%2FShardManagerGetSnapshotReplyActor.java;h=42ed9d09d89294d4cb645c46068c3ae2d4cb65b3;hb=4b13f57a2f095a5e837d5d919a52d867ded8d373;hp=bc06c32fa754978fe697cfbfc8be2e49856cd907;hpb=925cb4a228d0fda99c7bfeb432eb25285a223887;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActor.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActor.java index bc06c32fa7..42ed9d09d8 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActor.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActor.java @@ -12,7 +12,7 @@ import akka.actor.PoisonPill; import akka.actor.Props; import akka.actor.ReceiveTimeout; import akka.actor.Status.Failure; -import akka.actor.UntypedActor; +import akka.actor.UntypedAbstractActor; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -20,12 +20,13 @@ import java.util.List; import java.util.Set; import java.util.concurrent.TimeoutException; import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier; -import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot; -import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot.ShardSnapshot; +import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot; +import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot; +import org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot; import org.opendaylight.controller.cluster.raft.client.messages.GetSnapshotReply; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import scala.concurrent.duration.Duration; +import scala.concurrent.duration.FiniteDuration; /** * Temporary actor used by the ShardManager to compile GetSnapshot replies from the Shard actors and return @@ -33,14 +34,14 @@ import scala.concurrent.duration.Duration; * * @author Thomas Pantelis */ -class ShardManagerGetSnapshotReplyActor extends UntypedActor { +final class ShardManagerGetSnapshotReplyActor extends UntypedAbstractActor { private static final Logger LOG = LoggerFactory.getLogger(ShardManagerGetSnapshotReplyActor.class); private final Set remainingShardNames; private final Params params; private final List shardSnapshots = new ArrayList<>(); - private ShardManagerGetSnapshotReplyActor(Params params) { + private ShardManagerGetSnapshotReplyActor(final Params params) { this.params = params; remainingShardNames = new HashSet<>(params.shardNames); @@ -50,7 +51,7 @@ class ShardManagerGetSnapshotReplyActor extends UntypedActor { } @Override - public void onReceive(Object message) { + public void onReceive(final Object message) { if (message instanceof GetSnapshotReply) { onGetSnapshotReply((GetSnapshotReply)message); } else if (message instanceof Failure) { @@ -59,17 +60,18 @@ class ShardManagerGetSnapshotReplyActor extends UntypedActor { 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()); + LOG.warn("{}: Timed out after {} ms while waiting for snapshot replies from {} shard(s). " + + "{} shard(s) {} did not respond", params.id, params.receiveTimeout.toMillis(), + params.shardNames.size(), remainingShardNames.size(), remainingShardNames); + params.replyToActor.tell(new Failure(new TimeoutException(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))), getSelf()); getSelf().tell(PoisonPill.getInstance(), getSelf()); } } - private void onGetSnapshotReply(GetSnapshotReply getSnapshotReply) { + private void onGetSnapshotReply(final GetSnapshotReply getSnapshotReply) { LOG.debug("{}: Received {}", params.id, getSnapshotReply); ShardIdentifier shardId = ShardIdentifier.fromShardIdString(getSnapshotReply.getId()); @@ -86,8 +88,9 @@ class ShardManagerGetSnapshotReplyActor extends UntypedActor { } } - public static Props props(Collection shardNames, String datastoreType, byte[] shardManagerSnapshot, - ActorRef replyToActor, String id, Duration receiveTimeout) { + public static Props props(final Collection shardNames, final String datastoreType, + final ShardManagerSnapshot shardManagerSnapshot, final ActorRef replyToActor, final String id, + final FiniteDuration receiveTimeout) { return Props.create(ShardManagerGetSnapshotReplyActor.class, new Params(shardNames, datastoreType, shardManagerSnapshot, replyToActor, id, receiveTimeout)); } @@ -95,13 +98,14 @@ class ShardManagerGetSnapshotReplyActor extends UntypedActor { private static final class Params { final Collection shardNames; final String datastoreType; - final byte[] shardManagerSnapshot; + final ShardManagerSnapshot shardManagerSnapshot; final ActorRef replyToActor; final String id; - final Duration receiveTimeout; + final FiniteDuration receiveTimeout; - Params(Collection shardNames, String datastoreType, byte[] shardManagerSnapshot, ActorRef replyToActor, - String id, Duration receiveTimeout) { + Params(final Collection shardNames, final String datastoreType, + final ShardManagerSnapshot shardManagerSnapshot, final ActorRef replyToActor, final String id, + final FiniteDuration receiveTimeout) { this.shardNames = shardNames; this.datastoreType = datastoreType; this.shardManagerSnapshot = shardManagerSnapshot;