X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fpersistence%2FLocalSnapshotStore.java;h=76babc15db7d831403e985c658e3a3cef46f3e99;hb=refs%2Fchanges%2F11%2F80211%2F6;hp=e1589ffb899a955be8fdcf26fa70565b249a8ab8;hpb=877dc93c690dba7b2a834e0cf585d45250eb9aa2;p=controller.git diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/persistence/LocalSnapshotStore.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/persistence/LocalSnapshotStore.java index e1589ffb89..76babc15db 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/persistence/LocalSnapshotStore.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/persistence/LocalSnapshotStore.java @@ -15,6 +15,7 @@ import akka.persistence.SnapshotSelectionCriteria; import akka.persistence.serialization.Snapshot; import akka.persistence.serialization.SnapshotSerializer; import akka.persistence.snapshot.japi.SnapshotStore; +import akka.serialization.JavaSerializer; import com.google.common.annotations.VisibleForTesting; import com.google.common.io.ByteStreams; import com.typesafe.config.Config; @@ -39,10 +40,11 @@ import java.util.Collections; import java.util.Deque; import java.util.List; import java.util.Optional; +import java.util.concurrent.Callable; import java.util.stream.Collector; import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import scala.concurrent.ExecutionContext; @@ -133,15 +135,17 @@ public class LocalSnapshotStore extends SnapshotStore { } private Object deserialize(final File file) throws IOException { - try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(file))) { - return in.readObject(); - } catch (ClassNotFoundException e) { - throw new IOException("Error loading snapshot file " + file, e); - } catch (IOException e) { - LOG.debug("Error loading snapshot file {}", file, e); - - return tryDeserializeAkkaSnapshot(file); - } + return JavaSerializer.currentSystem().withValue((ExtendedActorSystem) context().system(), + (Callable) () -> { + try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(file))) { + return in.readObject(); + } catch (ClassNotFoundException e) { + throw new IOException("Error loading snapshot file " + file, e); + } catch (IOException e) { + LOG.debug("Error loading snapshot file {}", file, e); + return tryDeserializeAkkaSnapshot(file); + } + }); } private Object tryDeserializeAkkaSnapshot(final File file) throws IOException { @@ -267,12 +271,11 @@ public class LocalSnapshotStore extends SnapshotStore { .filter(criteria::matches).collect(Collectors.toList()); } - private static Stream toStream(@Nullable final SnapshotMetadata md) { + private static Stream toStream(final @Nullable SnapshotMetadata md) { return md != null ? Stream.of(md) : Stream.empty(); } - @Nullable - private static SnapshotMetadata extractMetadata(final File file) { + private static @Nullable SnapshotMetadata extractMetadata(final File file) { String name = file.getName(); int sequenceNumberEndIndex = name.lastIndexOf('-'); int persistenceIdEndIndex = name.lastIndexOf('-', sequenceNumberEndIndex - 1);