Handle DeleteSnapshots response messages 00/42800/3
authorTom Pantelis <tpanteli@brocade.com>
Fri, 29 Jul 2016 19:23:23 +0000 (15:23 -0400)
committerTom Pantelis <tpanteli@brocade.com>
Wed, 3 Aug 2016 11:39:52 +0000 (11:39 +0000)
This is a follow-up to https://git.opendaylight.org/gerrit/#/c/42272/.
I didn't think deleteSnapshots returned a response but it does - I see
a warning for unhandled DeleteSnapshotsSuccess. I added handling for
DeleteSnapshotsSuccess and DeleteSnapshotsFailure. For the latter I log
a warning but don't fail the actor.

Change-Id: Ibb41e5124eb22530f98a5ef958abffc556dea4cf
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/actors/client/SavingClientActorBehavior.java

index fc8b005..abccc27 100644 (file)
@@ -7,6 +7,8 @@
  */
 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;
@@ -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) {
-            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));
-
-            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;
         }
+
+        context().unstash();
+        return context().createBehavior(myId);
     }
 }
\ No newline at end of file