CDS: Implement front-end support for local transactions
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / OperationCompleter.java
index 09fa61b570996919805aa24ff90d0975eb7c62c6..ec867dda0bb924d7ffbab7ca3ded58f52ad90fb8 100644 (file)
@@ -10,8 +10,9 @@ package org.opendaylight.controller.cluster.datastore;
 import akka.dispatch.OnComplete;
 import com.google.common.base.Preconditions;
 import java.util.concurrent.Semaphore;
+import org.opendaylight.controller.cluster.datastore.messages.BatchedModificationsReply;
 
-final class OperationCompleter extends OnComplete<Object> {
+public final class OperationCompleter extends OnComplete<Object> {
     private final Semaphore operationLimiter;
 
     OperationCompleter(Semaphore operationLimiter){
@@ -19,7 +20,11 @@ final class OperationCompleter extends OnComplete<Object> {
     }
 
     @Override
-    public void onComplete(Throwable throwable, Object o){
-        this.operationLimiter.release();
+    public void onComplete(Throwable throwable, Object message) {
+        if(message instanceof BatchedModificationsReply) {
+            this.operationLimiter.release(((BatchedModificationsReply)message).getNumBatched());
+        } else {
+            this.operationLimiter.release();
+        }
     }
 }
\ No newline at end of file