X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FShardSnapshotCohort.java;h=126e28d9c8c6157794f3b7a12282fb5488d5e2dd;hp=93e1d873579f0c02446b666f897cfcae640db525;hb=987e2e706d0b343304142626bc870f3e8c909b51;hpb=aafb8cb044e992dd784d1f4f66508599cc4cd588 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardSnapshotCohort.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardSnapshotCohort.java index 93e1d87357..126e28d9c8 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardSnapshotCohort.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardSnapshotCohort.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved. + * Copyright (c) 2015, 2017 Brocade Communications Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -7,9 +7,10 @@ */ package org.opendaylight.controller.cluster.datastore; +import static java.util.Objects.requireNonNull; + import akka.actor.ActorContext; import akka.actor.ActorRef; -import com.google.common.base.Preconditions; import com.google.common.io.ByteSource; import java.io.IOException; import java.io.ObjectInputStream; @@ -33,7 +34,7 @@ import org.slf4j.Logger; * * @author Thomas Pantelis */ -class ShardSnapshotCohort implements RaftActorSnapshotCohort { +final class ShardSnapshotCohort implements RaftActorSnapshotCohort { private static final FrontendType SNAPSHOT_APPLY = FrontendType.forName("snapshot-apply"); private final ActorRef snapshotActor; @@ -43,8 +44,8 @@ class ShardSnapshotCohort implements RaftActorSnapshotCohort { private ShardSnapshotCohort(final LocalHistoryIdentifier applyHistoryId, final ActorRef snapshotActor, final ShardDataTree store, final Logger log, final String logId) { - this.snapshotActor = Preconditions.checkNotNull(snapshotActor); - this.store = Preconditions.checkNotNull(store); + this.snapshotActor = requireNonNull(snapshotActor); + this.store = requireNonNull(store); this.log = log; this.logId = logId; } @@ -65,14 +66,17 @@ class ShardSnapshotCohort implements RaftActorSnapshotCohort { @Override public void createSnapshot(final ActorRef actorRef, final Optional installSnapshotStream) { // Forward the request to the snapshot actor - ShardSnapshotActor.requestSnapshot(snapshotActor, store.takeStateSnapshot(), installSnapshotStream, actorRef); + final ShardDataTreeSnapshot snapshot = store.takeStateSnapshot(); + log.debug("{}: requesting serialization of snapshot {}", logId, snapshot); + + ShardSnapshotActor.requestSnapshot(snapshotActor, snapshot, installSnapshotStream, actorRef); } @Override @SuppressWarnings("checkstyle:IllegalCatch") public void applySnapshot(final Snapshot.State snapshotState) { if (!(snapshotState instanceof ShardSnapshotState)) { - log.debug("{}: applySnapshot ignoring snapshot: {}", snapshotState); + log.debug("{}: applySnapshot ignoring snapshot: {}", logId, snapshotState); } final ShardDataTreeSnapshot snapshot = ((ShardSnapshotState)snapshotState).getSnapshot(); @@ -94,9 +98,9 @@ class ShardSnapshotCohort implements RaftActorSnapshotCohort { } @Override - public State deserializeSnapshot(ByteSource snapshotBytes) throws IOException { - try (final ObjectInputStream in = new ObjectInputStream(snapshotBytes.openStream())) { - return new ShardSnapshotState(ShardDataTreeSnapshot.deserialize(in)); + public State deserializeSnapshot(final ByteSource snapshotBytes) throws IOException { + try (ObjectInputStream in = new ObjectInputStream(snapshotBytes.openStream())) { + return ShardDataTreeSnapshot.deserialize(in); } } }