X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FTransactionProxy.java;h=74245c42592ca3d6743d0aef3b48bb2e6ace2b45;hb=b3d0ded2590e6a5a61055010f7b24e9a943c8d31;hp=c12276134e99c0bff0e9f3dc6c3d61550c39e4ad;hpb=9d166a0ee8e022ae9ec30fb251584d57f313c077;p=controller.git
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java
index c12276134e..74245c4259 100644
--- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java
+++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java
@@ -34,7 +34,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
-import java.util.concurrent.Executors;
+import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicLong;
/**
@@ -50,7 +50,6 @@ import java.util.concurrent.atomic.AtomicLong;
*
*/
public class TransactionProxy implements DOMStoreReadWriteTransaction {
-
public enum TransactionType {
READ_ONLY,
WRITE_ONLY,
@@ -63,16 +62,20 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
private final ActorContext actorContext;
private final Map remoteTransactionPaths = new HashMap<>();
private final String identifier;
+ private final ExecutorService executor;
public TransactionProxy(
ActorContext actorContext,
- TransactionType transactionType) {
+ TransactionType transactionType,
+ ExecutorService executor
+ ) {
- this.identifier = "transaction-" + counter.getAndIncrement();
+ this.identifier = "txn-" + counter.getAndIncrement();
this.transactionType = transactionType;
this.actorContext = actorContext;
+ this.executor = executor;
- Object response = actorContext.executeShardOperation(Shard.DEFAULT_NAME, new CreateTransaction(), ActorContext.ASK_DURATION);
+ Object response = actorContext.executeShardOperation(Shard.DEFAULT_NAME, new CreateTransaction(identifier), ActorContext.ASK_DURATION);
if(response instanceof CreateTransactionReply){
CreateTransactionReply reply = (CreateTransactionReply) response;
remoteTransactionPaths.put(Shard.DEFAULT_NAME, actorContext.actorSelection(reply.getTransactionPath()));
@@ -91,6 +94,9 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
ActorContext.ASK_DURATION);
if(response instanceof ReadDataReply){
ReadDataReply reply = (ReadDataReply) response;
+ if(reply.getNormalizedNode() == null){
+ return Optional.absent();
+ }
//FIXME : A cast should not be required here ???
return (Optional>) Optional.of(reply.getNormalizedNode());
}
@@ -102,8 +108,7 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
ListenableFutureTask>>
future = ListenableFutureTask.create(call);
- //FIXME : Use a thread pool here
- Executors.newSingleThreadExecutor().submit(future);
+ executor.submit(future);
return future;
}
@@ -142,7 +147,7 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
}
}
- return new ThreePhaseCommitCohortProxy(actorContext, cohortPaths);
+ return new ThreePhaseCommitCohortProxy(actorContext, cohortPaths, identifier, executor);
}
@Override