Bug 6540: EOS - Prune pending owner change commits on leader change
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / Shard.java
index c3f76530bccfd8924fb245adb70216de6e5a7e5b..a1e506f6ecba7dca921a6df5d7f871237ca25850 100644 (file)
@@ -610,8 +610,7 @@ public class Shard extends RaftActor {
             // them to transaction messages and send to the new leader.
             ActorSelection leader = getLeader();
             if (leader != null) {
-                Collection<?> messagesToForward = commitCoordinator.convertPendingTransactionsToMessages(
-                            datastoreContext.getShardBatchedModificationCount());
+                Collection<?> messagesToForward = convertPendingTransactionsToMessages();
 
                 if (!messagesToForward.isEmpty()) {
                     LOG.debug("{}: Forwarding {} pending transaction messages to leader {}", persistenceId(),
@@ -633,6 +632,15 @@ public class Shard extends RaftActor {
         }
     }
 
+    /**
+     * Clears all pending transactions and converts them to messages to be forwarded to a new leader.
+     *
+     * @return the converted messages
+     */
+    public Collection<?> convertPendingTransactionsToMessages() {
+        return commitCoordinator.convertPendingTransactionsToMessages(datastoreContext.getShardBatchedModificationCount());
+    }
+
     @Override
     protected void pauseLeader(final Runnable operation) {
         LOG.debug("{}: In pauseLeader, operation: {}", persistenceId(), operation);