Allow AbstractClientActor generation to start from non-zero
[controller.git] / opendaylight / md-sal / cds-access-client / src / main / java / org / opendaylight / controller / cluster / access / client / SavingClientActorBehavior.java
index 05abf8407b1273bc90cc9375d8dbcb9efa7aa39f..42823a19ab04400f70472e71e75b974e5f5a6840 100644 (file)
@@ -7,17 +7,20 @@
  */
 package org.opendaylight.controller.cluster.access.client;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.persistence.DeleteSnapshotsFailure;
 import akka.persistence.DeleteSnapshotsSuccess;
 import akka.persistence.SaveSnapshotFailure;
 import akka.persistence.SaveSnapshotSuccess;
 import akka.persistence.SnapshotSelectionCriteria;
-import com.google.common.base.Preconditions;
 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
+ * Transient behavior handling messages while the new generation is being persisted.
+ *
  * @author Robert Varga
  */
 final class SavingClientActorBehavior extends RecoveredClientActorBehavior<InitialClientActorContext> {
@@ -26,7 +29,7 @@ final class SavingClientActorBehavior extends RecoveredClientActorBehavior<Initi
 
     SavingClientActorBehavior(final InitialClientActorContext context, final ClientIdentifier nextId) {
         super(context);
-        this.myId = Preconditions.checkNotNull(nextId);
+        this.myId = requireNonNull(nextId);
     }
 
     @Override
@@ -37,14 +40,15 @@ final class SavingClientActorBehavior extends RecoveredClientActorBehavior<Initi
         } else if (command instanceof SaveSnapshotSuccess) {
             LOG.debug("{}: got command: {}", persistenceId(), command);
             SaveSnapshotSuccess saved = (SaveSnapshotSuccess)command;
-            context().deleteSnapshots(new SnapshotSelectionCriteria(saved.metadata().sequenceNr(),
+            context().deleteSnapshots(new SnapshotSelectionCriteria(scala.Long.MaxValue(),
                     saved.metadata().timestamp() - 1, 0L, 0L));
             return this;
         } else if (command instanceof DeleteSnapshotsSuccess) {
             LOG.debug("{}: got command: {}", persistenceId(), command);
         } else if (command instanceof DeleteSnapshotsFailure) {
             // Not treating this as a fatal error.
-            LOG.warn("{}: failed to delete prior snapshots", persistenceId(), ((DeleteSnapshotsFailure) command).cause());
+            LOG.warn("{}: failed to delete prior snapshots", persistenceId(),
+                    ((DeleteSnapshotsFailure) command).cause());
         } else {
             LOG.debug("{}: stashing command {}", persistenceId(), command);
             context().stash();
@@ -54,4 +58,4 @@ final class SavingClientActorBehavior extends RecoveredClientActorBehavior<Initi
         context().unstash();
         return context().createBehavior(myId);
     }
-}
\ No newline at end of file
+}