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%2FAbstractTransactionContextFactory.java;h=29b52f75579b57e2fbad4563585de9b10828d154;hb=546cd1fd100dbaa36908b22c2f422320dbd8c4b2;hp=6d573dedf53223b34c8c2ca525bea3435d9bc812;hpb=f662ce8b1fa94b77ba66f7ece8bcaff91dee809e;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionContextFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionContextFactory.java index 6d573dedf5..29b52f7557 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionContextFactory.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionContextFactory.java @@ -10,7 +10,6 @@ package org.opendaylight.controller.cluster.datastore; import static java.util.Objects.requireNonNull; import akka.actor.ActorSelection; -import akka.dispatch.OnComplete; import java.util.Collection; import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; @@ -80,20 +79,48 @@ abstract class AbstractTransactionContextFactory findPrimaryFuture = findPrimaryShard(shardName, parent.getIdentifier()); + final DelayedTransactionContextWrapper contextWrapper = new DelayedTransactionContextWrapper( + parent.getIdentifier(), actorUtils, shardName); + final Future findPrimaryFuture = findPrimaryShard(shardName, parent.getIdentifier()); if (findPrimaryFuture.isCompleted()) { - Try maybe = findPrimaryFuture.value().get(); + final Try maybe = findPrimaryFuture.value().get(); if (maybe.isSuccess()) { - onFindPrimaryShardSuccess(maybe.get(), parent, shardName, transactionContextWrapper); + return maybeCreateDirectTransactionContextWrapper(maybe.get(), parent, shardName, + contextWrapper); } else { - onFindPrimaryShardFailure(maybe.failed().get(), parent, shardName, transactionContextWrapper); + onFindPrimaryShardFailure(maybe.failed().get(), parent, shardName, + contextWrapper); } } else { - findPrimaryFuture.onComplete(new OnComplete() { - @Override - public void onComplete(final Throwable failure, final PrimaryShardInfo primaryShardInfo) { - if (failure == null) { - onFindPrimaryShardSuccess(primaryShardInfo, parent, shardName, transactionContextWrapper); - } else { - onFindPrimaryShardFailure(failure, parent, shardName, transactionContextWrapper); - } + findPrimaryFuture.onComplete(result -> { + if (result.isSuccess()) { + onFindPrimaryShardSuccess(result.get(), parent, shardName, contextWrapper); + } else { + onFindPrimaryShardFailure(result.failed().get(), parent, shardName, contextWrapper); } + return null; }, actorUtils.getClientDispatcher()); } - - return transactionContextWrapper; + return contextWrapper; } private void updateShardInfo(final String shardName, final PrimaryShardInfo primaryShardInfo) { @@ -215,12 +240,12 @@ abstract class AbstractTransactionContextFactory