Handle DeleteSnapshots response messages
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / actors / client / SavingClientActorBehavior.java
index fc8b0056890e34eca5a1121cfafbdba41e25e961..abccc273cd8842d66b8a2e7d66d028e211f8fa83 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.controller.cluster.datastore.actors.client;
 
  */
 package org.opendaylight.controller.cluster.datastore.actors.client;
 
+import akka.persistence.DeleteSnapshotsFailure;
+import akka.persistence.DeleteSnapshotsSuccess;
 import akka.persistence.SaveSnapshotFailure;
 import akka.persistence.SaveSnapshotSuccess;
 import akka.persistence.SnapshotSelectionCriteria;
 import akka.persistence.SaveSnapshotFailure;
 import akka.persistence.SaveSnapshotSuccess;
 import akka.persistence.SnapshotSelectionCriteria;
@@ -33,17 +35,23 @@ final class SavingClientActorBehavior extends RecoveredClientActorBehavior<Initi
             LOG.error("{}: failed to persist state", persistenceId(), ((SaveSnapshotFailure) command).cause());
             return null;
         } else if (command instanceof SaveSnapshotSuccess) {
             LOG.error("{}: failed to persist state", persistenceId(), ((SaveSnapshotFailure) command).cause());
             return null;
         } else if (command instanceof SaveSnapshotSuccess) {
-            context().unstash();
-
+            LOG.debug("{}: got command: {}", persistenceId(), command);
             SaveSnapshotSuccess saved = (SaveSnapshotSuccess)command;
             context().deleteSnapshots(new SnapshotSelectionCriteria(saved.metadata().sequenceNr(),
                     saved.metadata().timestamp() - 1, 0L, 0L));
             SaveSnapshotSuccess saved = (SaveSnapshotSuccess)command;
             context().deleteSnapshots(new SnapshotSelectionCriteria(saved.metadata().sequenceNr(),
                     saved.metadata().timestamp() - 1, 0L, 0L));
-
-            return context().createBehavior(myId);
+            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());
         } else {
             LOG.debug("{}: stashing command {}", persistenceId(), command);
             context().stash();
             return this;
         }
         } else {
             LOG.debug("{}: stashing command {}", persistenceId(), command);
             context().stash();
             return this;
         }
+
+        context().unstash();
+        return context().createBehavior(myId);
     }
 }
\ No newline at end of file
     }
 }
\ No newline at end of file