From: Robert Varga Date: Wed, 9 Mar 2022 18:04:16 +0000 (+0100) Subject: Use CommitInfo in AsyncNotifyingSettableFuture X-Git-Tag: v5.0.0~7 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=4d2bbed60d5e0e1ea23a994e87b306416a3e51eb;hp=4e5083390e8f3076b0c6cd9fc43f656c4a109c1d Use CommitInfo in AsyncNotifyingSettableFuture We are performing a future transformation which boils down to converting a null (Void) into an CommitInfo.empty(). Rather than doing that, let's make sure AsyncNotifyingSettableFuture results directly in CommitInfo, removing the need for transformation, saving us an object allocation and a few CPU cycles. Change-Id: I7e34ad5e24dc6470d16243dad5ce7ba7395c5397 Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ConcurrentDOMDataBroker.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ConcurrentDOMDataBroker.java index 36b47eff69..28151cc413 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ConcurrentDOMDataBroker.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ConcurrentDOMDataBroker.java @@ -95,8 +95,7 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker { doCanCommit(clientSubmitFuture, transaction, cohorts); - return FluentFuture.from(clientSubmitFuture).transform(ignored -> CommitInfo.empty(), - MoreExecutors.directExecutor()); + return FluentFuture.from(clientSubmitFuture); } private void doCanCommit(final AsyncNotifyingSettableFuture clientSubmitFuture, @@ -249,8 +248,7 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker { * FIXME: This class should probably be moved to yangtools common utils for re-usability and * unified with AsyncNotifyingListenableFutureTask. */ - private static class AsyncNotifyingSettableFuture extends AbstractFuture { - + private static class AsyncNotifyingSettableFuture extends AbstractFuture { /** * ThreadLocal used to detect if the task completion thread is running the future listener Runnables. */ @@ -279,7 +277,7 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker { boolean set() { ON_TASK_COMPLETION_THREAD_TL.set(Boolean.TRUE); try { - return super.set(null); + return super.set(CommitInfo.empty()); } finally { ON_TASK_COMPLETION_THREAD_TL.set(null); }