X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FTransactionContextImpl.java;h=b6fe2c29bda9872245c90fa93f7aea7c4eeb6d5c;hp=f34c5a257125026f61f02fcbf18c945160ede2bc;hb=4b9316643d0001c8d36f6bc1ffab79f946f968e8;hpb=254381e31fb8a30db6428e8ebebdbb4416aa1c1a diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContextImpl.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContextImpl.java index f34c5a2571..b6fe2c29bd 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContextImpl.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContextImpl.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -29,7 +30,6 @@ import org.opendaylight.controller.cluster.datastore.utils.ActorContext; import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import scala.concurrent.Future; @@ -37,7 +37,6 @@ import scala.concurrent.Future; public class TransactionContextImpl extends AbstractTransactionContext { private static final Logger LOG = LoggerFactory.getLogger(TransactionContextImpl.class); - private final String transactionChainId; private final ActorContext actorContext; private final ActorSelection actor; private final boolean isTxActorLocal; @@ -45,13 +44,13 @@ public class TransactionContextImpl extends AbstractTransactionContext { private final OperationCompleter operationCompleter; private BatchedModifications batchedModifications; + private int totalBatchedModificationsSent; protected TransactionContextImpl(ActorSelection actor, TransactionIdentifier identifier, - String transactionChainId, ActorContext actorContext, SchemaContext schemaContext, boolean isTxActorLocal, + ActorContext actorContext, boolean isTxActorLocal, short remoteTransactionVersion, OperationCompleter operationCompleter) { super(identifier); this.actor = actor; - this.transactionChainId = transactionChainId; this.actorContext = actorContext; this.isTxActorLocal = isTxActorLocal; this.remoteTransactionVersion = remoteTransactionVersion; @@ -87,13 +86,27 @@ public class TransactionContextImpl extends AbstractTransactionContext { actorContext.sendOperationAsync(getActor(), CloseTransaction.INSTANCE.toSerializable()); } + @Override + public boolean supportsDirectCommit() { + return true; + } + + @Override + public Future directCommit() { + LOG.debug("Tx {} directCommit called", getIdentifier()); + + // Send the remaining batched modifications, if any, with the ready flag set. + + return sendBatchedModifications(true, true); + } + @Override public Future readyTransaction() { LOG.debug("Tx {} readyTransaction called", getIdentifier()); // Send the remaining batched modifications, if any, with the ready flag set. - Future lastModificationsFuture = sendBatchedModifications(true); + Future lastModificationsFuture = sendBatchedModifications(true, false); return transformReadyReply(lastModificationsFuture); } @@ -126,7 +139,7 @@ public class TransactionContextImpl extends AbstractTransactionContext { } private BatchedModifications newBatchedModifications() { - return new BatchedModifications(getIdentifier().toString(), remoteTransactionVersion, transactionChainId); + return new BatchedModifications(getIdentifier().toString(), remoteTransactionVersion, getIdentifier().getChainId()); } private void batchModification(Modification modification) { @@ -143,10 +156,10 @@ public class TransactionContextImpl extends AbstractTransactionContext { } protected Future sendBatchedModifications() { - return sendBatchedModifications(false); + return sendBatchedModifications(false, false); } - protected Future sendBatchedModifications(boolean ready) { + protected Future sendBatchedModifications(boolean ready, boolean doCommitOnReady) { Future sent = null; if(ready || (batchedModifications != null && !batchedModifications.getModifications().isEmpty())) { if(batchedModifications == null) { @@ -159,6 +172,8 @@ public class TransactionContextImpl extends AbstractTransactionContext { } batchedModifications.setReady(ready); + batchedModifications.setDoCommitOnReady(doCommitOnReady); + batchedModifications.setTotalMessagesSent(++totalBatchedModificationsSent); sent = executeOperationAsync(batchedModifications); if(ready) {