Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Remove deprecated Snapshot and related code
[controller.git]
/
opendaylight
/
md-sal
/
sal-distributed-datastore
/
src
/
main
/
java
/
org
/
opendaylight
/
controller
/
cluster
/
datastore
/
ShardSnapshotCohort.java
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 6dc3f03081b71fe18c94e10dfb28d39c7d13d985..455c874229f3c1c86fd6c3fcfc5609a6c81a91bb 100644
(file)
--- 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,
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@
-10,7
+10,11
@@
package org.opendaylight.controller.cluster.datastore;
import akka.actor.ActorContext;
import akka.actor.ActorRef;
import com.google.common.base.Preconditions;
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.IOException;
+import java.io.ObjectInputStream;
+import java.io.OutputStream;
+import java.util.Optional;
import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
import org.opendaylight.controller.cluster.access.concepts.FrontendType;
import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
import org.opendaylight.controller.cluster.access.concepts.FrontendType;
@@
-18,7
+22,10
@@
import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifie
import org.opendaylight.controller.cluster.access.concepts.MemberName;
import org.opendaylight.controller.cluster.datastore.actors.ShardSnapshotActor;
import org.opendaylight.controller.cluster.datastore.persisted.ShardDataTreeSnapshot;
import org.opendaylight.controller.cluster.access.concepts.MemberName;
import org.opendaylight.controller.cluster.datastore.actors.ShardSnapshotActor;
import org.opendaylight.controller.cluster.datastore.persisted.ShardDataTreeSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.ShardSnapshotState;
import org.opendaylight.controller.cluster.raft.RaftActorSnapshotCohort;
import org.opendaylight.controller.cluster.raft.RaftActorSnapshotCohort;
+import org.opendaylight.controller.cluster.raft.persisted.Snapshot;
+import org.opendaylight.controller.cluster.raft.persisted.Snapshot.State;
import org.slf4j.Logger;
/**
import org.slf4j.Logger;
/**
@@
-56,28
+63,29
@@
class ShardSnapshotCohort implements RaftActorSnapshotCohort {
}
@Override
}
@Override
- public void createSnapshot(final ActorRef actorRef) {
+ public void createSnapshot(final ActorRef actorRef
, final Optional<OutputStream> installSnapshotStream
) {
// Forward the request to the snapshot actor
// Forward the request to the snapshot actor
- ShardSnapshotActor.requestSnapshot(snapshotActor, store.takeStateSnapshot(), actorRef);
+ final ShardDataTreeSnapshot snapshot = store.takeStateSnapshot();
+ log.debug("{}: requesting serialization of snapshot {}", logId, snapshot);
+
+ ShardSnapshotActor.requestSnapshot(snapshotActor, snapshot, installSnapshotStream, actorRef);
}
@Override
@SuppressWarnings("checkstyle:IllegalCatch")
}
@Override
@SuppressWarnings("checkstyle:IllegalCatch")
- public void applySnapshot(final byte[] snapshotBytes) {
+ public void applySnapshot(final Snapshot.State snapshotState) {
+ if (!(snapshotState instanceof ShardSnapshotState)) {
+ log.debug("{}: applySnapshot ignoring snapshot: {}", snapshotState);
+ }
+
+ final ShardDataTreeSnapshot snapshot = ((ShardSnapshotState)snapshotState).getSnapshot();
+
// Since this will be done only on Recovery or when this actor is a Follower
// we can safely commit everything in here. We not need to worry about event notifications
// as they would have already been disabled on the follower
log.info("{}: Applying snapshot", logId);
// Since this will be done only on Recovery or when this actor is a Follower
// we can safely commit everything in here. We not need to worry about event notifications
// as they would have already been disabled on the follower
log.info("{}: Applying snapshot", logId);
- final ShardDataTreeSnapshot snapshot;
- try {
- snapshot = ShardDataTreeSnapshot.deserialize(snapshotBytes);
- } catch (IOException e) {
- log.error("{}: Failed to deserialize snapshot", logId, e);
- return;
- }
-
try {
store.applySnapshot(snapshot);
} catch (Exception e) {
try {
store.applySnapshot(snapshot);
} catch (Exception e) {
@@
-87,4
+95,11
@@
class ShardSnapshotCohort implements RaftActorSnapshotCohort {
log.info("{}: Done applying snapshot", logId);
}
log.info("{}: Done applying snapshot", logId);
}
+
+ @Override
+ public State deserializeSnapshot(final ByteSource snapshotBytes) throws IOException {
+ try (ObjectInputStream in = new ObjectInputStream(snapshotBytes.openStream())) {
+ return new ShardSnapshotState(ShardDataTreeSnapshot.deserialize(in));
+ }
+ }
}
}