X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fsamples%2Fclustering-test-app%2Fprovider%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fclustering%2Fit%2Fprovider%2Fimpl%2FProduceTransactionsHandler.java;h=fc1c9f5545b80ed8509b87c3e58dc36033447663;hb=da174be7e22b16d4ac80cccefdc52b209b700745;hp=164e81ad00b7a19c82ef21460f0c1a20caa760d8;hpb=7c6334fbe717fd51f76984e5789ae3d8ee2eb29a;p=controller.git diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/ProduceTransactionsHandler.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/ProduceTransactionsHandler.java index 164e81ad00..fc1c9f5545 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/ProduceTransactionsHandler.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/ProduceTransactionsHandler.java @@ -5,10 +5,11 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.clustering.it.provider.impl; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + +import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; @@ -19,6 +20,8 @@ import java.util.SplittableRandom; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.mdsal.common.api.CommitInfo; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.dom.api.DOMDataTreeCursorAwareTransaction; import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; @@ -40,6 +43,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@Deprecated(forRemoval = true) public final class ProduceTransactionsHandler extends AbstractTransactionHandler { private static final Logger LOG = LoggerFactory.getLogger(ProduceTransactionsHandler.class); @@ -55,8 +59,8 @@ public final class ProduceTransactionsHandler extends AbstractTransactionHandler private ProduceTransactionsHandler(final DOMDataTreeProducer producer, final DOMDataTreeIdentifier idListItem, final ProduceTransactionsInput input) { super(input); - this.itemProducer = Preconditions.checkNotNull(producer); - this.idListItem = Preconditions.checkNotNull(idListItem); + this.itemProducer = requireNonNull(producer); + this.idListItem = requireNonNull(idListItem); } public static ListenableFuture> start( @@ -64,7 +68,7 @@ public final class ProduceTransactionsHandler extends AbstractTransactionHandler final String id = input.getId(); LOG.debug("Filling the item list {} with initial values.", id); - final YangInstanceIdentifier idListWithKey = ID_INT_YID.node(new NodeIdentifierWithPredicates(ID_INT, ID, id)); + final YangInstanceIdentifier idListWithKey = ID_INT_YID.node(NodeIdentifierWithPredicates.of(ID_INT, ID, id)); final DOMDataTreeProducer itemProducer = domDataTreeService.createProducer( Collections.singleton(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, idListWithKey))); @@ -78,7 +82,7 @@ public final class ProduceTransactionsHandler extends AbstractTransactionHandler cursor.close(); try { - tx.submit().get(INIT_TX_TIMEOUT_SECONDS, TimeUnit.SECONDS); + tx.commit().get(INIT_TX_TIMEOUT_SECONDS, TimeUnit.SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { LOG.warn("Unable to fill the initial item list.", e); closeProducer(itemProducer); @@ -104,12 +108,12 @@ public final class ProduceTransactionsHandler extends AbstractTransactionHandler } @Override - ListenableFuture execWrite(final long txId) { + FluentFuture execWrite(final long txId) { final int i = random.nextInt(MAX_ITEM + 1); final DOMDataTreeCursorAwareTransaction tx = itemProducer.createTransaction(false); final DOMDataTreeWriteCursor cursor = tx.createCursor(idListItem); - final NodeIdentifierWithPredicates entryId = new NodeIdentifierWithPredicates(ITEM, NUMBER, i); + final NodeIdentifierWithPredicates entryId = NodeIdentifierWithPredicates.of(ITEM, NUMBER, i); if (usedValues.contains(i)) { LOG.debug("Deleting item: {}", i); deleteTx++; @@ -128,14 +132,14 @@ public final class ProduceTransactionsHandler extends AbstractTransactionHandler cursor.close(); - return tx.submit(); + return tx.commit(); } @Override - void runFailed(final Throwable cause) { + void runFailed(final Throwable cause, final long txId) { closeProducer(itemProducer); future.set(RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "Submit failed", cause).build()); + .withError(RpcError.ErrorType.APPLICATION, "Commit failed for tx # " + txId, cause).build()); } @Override @@ -151,10 +155,9 @@ public final class ProduceTransactionsHandler extends AbstractTransactionHandler } @Override - void runTimedOut(final Exception cause) { + void runTimedOut(final String cause) { closeProducer(itemProducer); future.set(RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, - "Final submit was timed out by the test provider or was interrupted", cause).build()); + .withError(RpcError.ErrorType.APPLICATION, cause).build()); } }