X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FTransactionProxyTest.java;h=1f9e2f7bde5aa21faf8ea4f6daa30f552dcf003e;hb=a6af137c30470b86d4bc624d4c48cb686495a182;hp=5ab1e5ade3fc5a2333fe14f3f31d36733019d133;hpb=5464f50be733df1bbbe31cf05665d542d3b7c5e7;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java index 5ab1e5ade3..1f9e2f7bde 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java @@ -29,20 +29,24 @@ import akka.actor.ActorSystem; import akka.actor.Props; import akka.dispatch.Futures; import akka.util.Timeout; -import com.google.common.base.Optional; import com.google.common.base.Throwables; +import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.Sets; -import com.google.common.util.concurrent.CheckedFuture; +import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.FutureCallback; +import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.Uninterruptibles; import java.util.Collection; import java.util.List; +import java.util.Optional; +import java.util.SortedSet; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; import org.junit.Assert; import org.junit.Test; +import org.mockito.ArgumentCaptor; import org.mockito.InOrder; import org.mockito.Mockito; import org.opendaylight.controller.cluster.access.concepts.MemberName; @@ -56,6 +60,7 @@ import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction; import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply; import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionReply; import org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo; +import org.opendaylight.controller.cluster.datastore.messages.ReadyLocalTransaction; import org.opendaylight.controller.cluster.datastore.modification.DeleteModification; import org.opendaylight.controller.cluster.datastore.modification.MergeModification; import org.opendaylight.controller.cluster.datastore.modification.WriteModification; @@ -65,8 +70,8 @@ import org.opendaylight.controller.cluster.raft.utils.DoNothingActor; import org.opendaylight.controller.md.cluster.datastore.model.CarsModel; import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; +import org.opendaylight.mdsal.common.api.ReadFailedException; +import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; @@ -77,7 +82,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import scala.concurrent.Promise; -@SuppressWarnings("resource") +@SuppressWarnings({"resource", "checkstyle:IllegalThrows", "checkstyle:AvoidHidingCauseException"}) public class TransactionProxyTest extends AbstractTransactionProxyTest { @SuppressWarnings("serial") @@ -85,7 +90,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { } interface Invoker { - CheckedFuture invoke(TransactionProxy proxy) throws Exception; + FluentFuture invoke(TransactionProxy proxy); } @Test @@ -115,7 +120,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { } @Test(expected = ReadFailedException.class) - public void testReadWithInvalidReplyMessageType() throws Exception { + public void testReadWithInvalidReplyMessageType() throws Throwable { ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), READ_ONLY); doReturn(Futures.successful(new Object())).when(mockActorContext) @@ -123,11 +128,15 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { TransactionProxy transactionProxy = new TransactionProxy(mockComponentFactory, READ_ONLY); - transactionProxy.read(TestModel.TEST_PATH).checkedGet(5, TimeUnit.SECONDS); + try { + transactionProxy.read(TestModel.TEST_PATH).get(5, TimeUnit.SECONDS); + } catch (ExecutionException e) { + throw e.getCause(); + } } @Test(expected = TestException.class) - public void testReadWithAsyncRemoteOperatonFailure() throws Exception { + public void testReadWithAsyncRemoteOperatonFailure() throws Throwable { ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), READ_ONLY); doReturn(Futures.failed(new TestException())).when(mockActorContext) @@ -138,7 +147,8 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { propagateReadFailedExceptionCause(transactionProxy.read(TestModel.TEST_PATH)); } - private void testExceptionOnInitialCreateTransaction(Exception exToThrow, Invoker invoker) throws Exception { + private void testExceptionOnInitialCreateTransaction(final Exception exToThrow, final Invoker invoker) + throws Throwable { ActorRef actorRef = getSystem().actorOf(Props.create(DoNothingActor.class)); if (exToThrow instanceof PrimaryNotFoundException) { @@ -156,23 +166,23 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { propagateReadFailedExceptionCause(invoker.invoke(transactionProxy)); } - private void testReadWithExceptionOnInitialCreateTransaction(Exception exToThrow) throws Exception { + private void testReadWithExceptionOnInitialCreateTransaction(final Exception exToThrow) throws Throwable { testExceptionOnInitialCreateTransaction(exToThrow, proxy -> proxy.read(TestModel.TEST_PATH)); } @Test(expected = PrimaryNotFoundException.class) - public void testReadWhenAPrimaryNotFoundExceptionIsThrown() throws Exception { + public void testReadWhenAPrimaryNotFoundExceptionIsThrown() throws Throwable { testReadWithExceptionOnInitialCreateTransaction(new PrimaryNotFoundException("test")); } - @Test(expected = TimeoutException.class) - public void testReadWhenATimeoutExceptionIsThrown() throws Exception { + @Test(expected = TestException.class) + public void testReadWhenATimeoutExceptionIsThrown() throws Throwable { testReadWithExceptionOnInitialCreateTransaction(new TimeoutException("test", - new Exception("reason"))); + new TestException())); } @Test(expected = TestException.class) - public void testReadWhenAnyOtherExceptionIsThrown() throws Exception { + public void testReadWhenAnyOtherExceptionIsThrown() throws Throwable { testReadWithExceptionOnInitialCreateTransaction(new TestException()); } @@ -212,7 +222,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { } @Test(expected = IllegalArgumentException.class) - public void testInvalidCreateTransactionReply() throws Exception { + public void testInvalidCreateTransactionReply() throws Throwable { ActorRef actorRef = getSystem().actorOf(Props.create(DoNothingActor.class)); doReturn(getSystem().actorSelection(actorRef.path())).when(mockActorContext) @@ -239,26 +249,26 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { doReturn(dataExistsReply(false)).when(mockActorContext).executeOperationAsync( eq(actorSelection(actorRef)), eqDataExists(), any(Timeout.class)); - Boolean exists = transactionProxy.exists(TestModel.TEST_PATH).checkedGet(); + Boolean exists = transactionProxy.exists(TestModel.TEST_PATH).get(); assertEquals("Exists response", false, exists); doReturn(dataExistsReply(true)).when(mockActorContext).executeOperationAsync( eq(actorSelection(actorRef)), eqDataExists(), any(Timeout.class)); - exists = transactionProxy.exists(TestModel.TEST_PATH).checkedGet(); + exists = transactionProxy.exists(TestModel.TEST_PATH).get(); assertEquals("Exists response", true, exists); } @Test(expected = PrimaryNotFoundException.class) - public void testExistsWhenAPrimaryNotFoundExceptionIsThrown() throws Exception { + public void testExistsWhenAPrimaryNotFoundExceptionIsThrown() throws Throwable { testExceptionOnInitialCreateTransaction(new PrimaryNotFoundException("test"), proxy -> proxy.exists(TestModel.TEST_PATH)); } @Test(expected = ReadFailedException.class) - public void testExistsWithInvalidReplyMessageType() throws Exception { + public void testExistsWithInvalidReplyMessageType() throws Throwable { ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), READ_ONLY); doReturn(Futures.successful(new Object())).when(mockActorContext) @@ -266,11 +276,15 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { TransactionProxy transactionProxy = new TransactionProxy(mockComponentFactory, READ_ONLY); - transactionProxy.exists(TestModel.TEST_PATH).checkedGet(5, TimeUnit.SECONDS); + try { + transactionProxy.exists(TestModel.TEST_PATH).get(5, TimeUnit.SECONDS); + } catch (ExecutionException e) { + throw e.getCause(); + } } @Test(expected = TestException.class) - public void testExistsWithAsyncRemoteOperatonFailure() throws Exception { + public void testExistsWithAsyncRemoteOperatonFailure() throws Throwable { ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), READ_ONLY); doReturn(Futures.failed(new TestException())).when(mockActorContext) @@ -296,7 +310,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { transactionProxy.write(TestModel.TEST_PATH, nodeToWrite); - Boolean exists = transactionProxy.exists(TestModel.TEST_PATH).checkedGet(); + Boolean exists = transactionProxy.exists(TestModel.TEST_PATH).get(); assertEquals("Exists response", true, exists); @@ -315,7 +329,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { } @Test - public void testWrite() throws Exception { + public void testWrite() { dataStoreContextBuilder.shardBatchedModificationCount(1); ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), WRITE_ONLY); @@ -355,7 +369,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { com.google.common.util.concurrent.Futures.addCallback(transactionProxy.read(TestModel.TEST_PATH), new FutureCallback>>() { @Override - public void onSuccess(Optional> result) { + public void onSuccess(final Optional> result) { try { transactionProxy.write(TestModel.TEST_PATH, nodeToWrite); } catch (Exception e) { @@ -366,19 +380,20 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { } @Override - public void onFailure(Throwable failure) { + public void onFailure(final Throwable failure) { caughtEx.set(failure); readComplete.countDown(); } - }); + }, MoreExecutors.directExecutor()); createTxPromise.success(createTransactionReply(actorRef, DataStoreVersions.CURRENT_VERSION)); Uninterruptibles.awaitUninterruptibly(readComplete, 5, TimeUnit.SECONDS); - if (caughtEx.get() != null) { - Throwables.propagateIfInstanceOf(caughtEx.get(), Exception.class); - Throwables.propagate(caughtEx.get()); + final Throwable t = caughtEx.get(); + if (t != null) { + Throwables.propagateIfPossible(t, Exception.class); + throw new RuntimeException(t); } // This sends the batched modification. @@ -403,7 +418,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { } @Test - public void testMerge() throws Exception { + public void testMerge() { dataStoreContextBuilder.shardBatchedModificationCount(1); ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), WRITE_ONLY); @@ -419,7 +434,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { } @Test - public void testDelete() throws Exception { + public void testDelete() { dataStoreContextBuilder.shardBatchedModificationCount(1); ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), WRITE_ONLY); @@ -433,7 +448,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { } @Test - public void testReadWrite() throws Exception { + public void testReadWrite() { ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), READ_WRITE); final NormalizedNode nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME); @@ -461,7 +476,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { } @Test - public void testReadyWithReadWrite() throws Exception { + public void testReadyWithReadWrite() { ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), READ_WRITE); final NormalizedNode nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME); @@ -493,7 +508,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { } @Test - public void testReadyWithNoModifications() throws Exception { + public void testReadyWithNoModifications() { ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), READ_WRITE); doReturn(readDataReply(null)).when(mockActorContext).executeOperationAsync( @@ -518,29 +533,66 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { } @Test - public void testReadyWithMultipleShardWrites() throws Exception { + public void testReadyWithMultipleShardWrites() { ActorRef actorRef1 = setupActorContextWithInitialCreateTransaction(getSystem(), WRITE_ONLY); - ActorRef actorRef2 = setupActorContextWithInitialCreateTransaction(getSystem(), WRITE_ONLY, "junk"); + ActorRef actorRef2 = setupActorContextWithInitialCreateTransaction(getSystem(), WRITE_ONLY, + TestModel.JUNK_QNAME.getLocalName()); expectBatchedModificationsReady(actorRef1); expectBatchedModificationsReady(actorRef2); + ActorRef actorRef3 = getSystem().actorOf(Props.create(DoNothingActor.class)); + + doReturn(getSystem().actorSelection(actorRef3.path())).when(mockActorContext) + .actorSelection(actorRef3.path().toString()); + + doReturn(Futures.successful(newPrimaryShardInfo(actorRef3, createDataTree()))).when(mockActorContext) + .findPrimaryShardAsync(eq(CarsModel.BASE_QNAME.getLocalName())); + + expectReadyLocalTransaction(actorRef3, false); + TransactionProxy transactionProxy = new TransactionProxy(mockComponentFactory, WRITE_ONLY); transactionProxy.write(TestModel.JUNK_PATH, ImmutableNodes.containerNode(TestModel.JUNK_QNAME)); transactionProxy.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); + transactionProxy.write(CarsModel.BASE_PATH, ImmutableNodes.containerNode(CarsModel.BASE_QNAME)); DOMStoreThreePhaseCommitCohort ready = transactionProxy.ready(); assertTrue(ready instanceof ThreePhaseCommitCohortProxy); verifyCohortFutures((ThreePhaseCommitCohortProxy)ready, actorSelection(actorRef1), - actorSelection(actorRef2)); + actorSelection(actorRef2), actorSelection(actorRef3)); + + SortedSet expShardNames = + ImmutableSortedSet.of(DefaultShardStrategy.DEFAULT_SHARD, + TestModel.JUNK_QNAME.getLocalName(), CarsModel.BASE_QNAME.getLocalName()); + + ArgumentCaptor batchedMods = ArgumentCaptor.forClass(BatchedModifications.class); + verify(mockActorContext).executeOperationAsync( + eq(actorSelection(actorRef1)), batchedMods.capture(), any(Timeout.class)); + assertEquals("Participating shards present", true, + batchedMods.getValue().getParticipatingShardNames().isPresent()); + assertEquals("Participating shards", expShardNames, batchedMods.getValue().getParticipatingShardNames().get()); + + batchedMods = ArgumentCaptor.forClass(BatchedModifications.class); + verify(mockActorContext).executeOperationAsync( + eq(actorSelection(actorRef2)), batchedMods.capture(), any(Timeout.class)); + assertEquals("Participating shards present", true, + batchedMods.getValue().getParticipatingShardNames().isPresent()); + assertEquals("Participating shards", expShardNames, batchedMods.getValue().getParticipatingShardNames().get()); + + ArgumentCaptor readyLocalTx = ArgumentCaptor.forClass(ReadyLocalTransaction.class); + verify(mockActorContext).executeOperationAsync( + eq(actorSelection(actorRef3)), readyLocalTx.capture(), any(Timeout.class)); + assertEquals("Participating shards present", true, + readyLocalTx.getValue().getParticipatingShardNames().isPresent()); + assertEquals("Participating shards", expShardNames, readyLocalTx.getValue().getParticipatingShardNames().get()); } @Test - public void testReadyWithWriteOnlyAndLastBatchPending() throws Exception { + public void testReadyWithWriteOnlyAndLastBatchPending() { dataStoreContextBuilder.writeOnlyTransactionOptimizationsEnabled(true); ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), WRITE_ONLY); @@ -567,7 +619,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { } @Test - public void testReadyWithWriteOnlyAndLastBatchEmpty() throws Exception { + public void testReadyWithWriteOnlyAndLastBatchEmpty() { dataStoreContextBuilder.shardBatchedModificationCount(1).writeOnlyTransactionOptimizationsEnabled(true); ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), WRITE_ONLY); @@ -595,7 +647,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { } @Test - public void testReadyWithReplyFailure() throws Exception { + public void testReadyWithReplyFailure() { dataStoreContextBuilder.writeOnlyTransactionOptimizationsEnabled(true); ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), WRITE_ONLY); @@ -616,7 +668,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { } @Test - public void testReadyWithDebugContextEnabled() throws Exception { + public void testReadyWithDebugContextEnabled() { dataStoreContextBuilder.transactionDebugContextEnabled(true); ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), READ_WRITE); @@ -635,7 +687,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { } @Test - public void testReadyWithLocalTransaction() throws Exception { + public void testReadyWithLocalTransaction() { ActorRef shardActorRef = getSystem().actorOf(Props.create(DoNothingActor.class)); doReturn(getSystem().actorSelection(shardActorRef.path())).when(mockActorContext) @@ -654,10 +706,16 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { DOMStoreThreePhaseCommitCohort ready = transactionProxy.ready(); assertTrue(ready instanceof SingleCommitCohortProxy); verifyCohortFutures((SingleCommitCohortProxy)ready, new CommitTransactionReply().toSerializable()); + + ArgumentCaptor readyLocalTx = ArgumentCaptor.forClass(ReadyLocalTransaction.class); + verify(mockActorContext).executeOperationAsync( + eq(actorSelection(shardActorRef)), readyLocalTx.capture(), any(Timeout.class)); + assertEquals("Participating shards present", false, + readyLocalTx.getValue().getParticipatingShardNames().isPresent()); } @Test - public void testReadyWithLocalTransactionWithFailure() throws Exception { + public void testReadyWithLocalTransactionWithFailure() { ActorRef shardActorRef = getSystem().actorOf(Props.create(DoNothingActor.class)); doReturn(getSystem().actorSelection(shardActorRef.path())).when(mockActorContext) @@ -682,7 +740,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { verifyCohortFutures((SingleCommitCohortProxy)ready, RuntimeException.class); } - private void testWriteOnlyTxWithFindPrimaryShardFailure(Exception toThrow) throws Exception { + private void testWriteOnlyTxWithFindPrimaryShardFailure(final Exception toThrow) { doReturn(Futures.failed(toThrow)).when(mockActorContext).findPrimaryShardAsync(anyString()); TransactionProxy transactionProxy = new TransactionProxy(mockComponentFactory, WRITE_ONLY); @@ -703,26 +761,27 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { } @Test - public void testWriteOnlyTxWithPrimaryNotFoundException() throws Exception { + public void testWriteOnlyTxWithPrimaryNotFoundException() { testWriteOnlyTxWithFindPrimaryShardFailure(new PrimaryNotFoundException("mock")); } @Test - public void testWriteOnlyTxWithNotInitializedException() throws Exception { + public void testWriteOnlyTxWithNotInitializedException() { testWriteOnlyTxWithFindPrimaryShardFailure(new NotInitializedException("mock")); } @Test - public void testWriteOnlyTxWithNoShardLeaderException() throws Exception { + public void testWriteOnlyTxWithNoShardLeaderException() { testWriteOnlyTxWithFindPrimaryShardFailure(new NoShardLeaderException("mock")); } @Test - public void testReadyWithInvalidReplyMessageType() throws Exception { + public void testReadyWithInvalidReplyMessageType() { dataStoreContextBuilder.writeOnlyTransactionOptimizationsEnabled(true); ActorRef actorRef1 = setupActorContextWithInitialCreateTransaction(getSystem(), WRITE_ONLY); - ActorRef actorRef2 = setupActorContextWithInitialCreateTransaction(getSystem(), WRITE_ONLY, "junk"); + ActorRef actorRef2 = setupActorContextWithInitialCreateTransaction(getSystem(), WRITE_ONLY, + TestModel.JUNK_QNAME.getLocalName()); doReturn(Futures.successful(new Object())).when(mockActorContext).executeOperationAsync( eq(actorSelection(actorRef1)), isA(BatchedModifications.class), any(Timeout.class)); @@ -753,7 +812,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { } @Test - public void testClose() throws Exception { + public void testClose() { ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), READ_WRITE); doReturn(readDataReply(null)).when(mockActorContext).executeOperationAsync( @@ -773,26 +832,27 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { void run(TransactionProxy transactionProxy); } - private PrimaryShardInfo newPrimaryShardInfo(ActorRef actorRef) { + private PrimaryShardInfo newPrimaryShardInfo(final ActorRef actorRef) { return new PrimaryShardInfo(getSystem().actorSelection(actorRef.path()), DataStoreVersions.CURRENT_VERSION); } - private PrimaryShardInfo newPrimaryShardInfo(ActorRef actorRef, DataTree dataTree) { + private PrimaryShardInfo newPrimaryShardInfo(final ActorRef actorRef, final DataTree dataTree) { return new PrimaryShardInfo(getSystem().actorSelection(actorRef.path()), DataStoreVersions.CURRENT_VERSION, dataTree); } - private void throttleOperation(TransactionProxyOperation operation) { + private void throttleOperation(final TransactionProxyOperation operation) { throttleOperation(operation, 1, true); } - private void throttleOperation(TransactionProxyOperation operation, int outstandingOpsLimit, boolean shardFound) { + private void throttleOperation(final TransactionProxyOperation operation, final int outstandingOpsLimit, + final boolean shardFound) { throttleOperation(operation, outstandingOpsLimit, shardFound, TimeUnit.MILLISECONDS.toNanos( mockActorContext.getDatastoreContext().getOperationTimeoutInMillis())); } - private void throttleOperation(TransactionProxyOperation operation, int outstandingOpsLimit, boolean shardFound, - long expectedCompletionTime) { + private void throttleOperation(final TransactionProxyOperation operation, final int outstandingOpsLimit, + final boolean shardFound, final long expectedCompletionTime) { ActorSystem actorSystem = getSystem(); ActorRef shardActorRef = actorSystem.actorOf(Props.create(DoNothingActor.class)); @@ -834,11 +894,11 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { } - private void completeOperation(TransactionProxyOperation operation) { + private void completeOperation(final TransactionProxyOperation operation) { completeOperation(operation, true); } - private void completeOperation(TransactionProxyOperation operation, boolean shardFound) { + private void completeOperation(final TransactionProxyOperation operation, final boolean shardFound) { ActorSystem actorSystem = getSystem(); ActorRef shardActorRef = actorSystem.actorOf(Props.create(DoNothingActor.class)); @@ -878,7 +938,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { expected, end - start), end - start <= expected); } - private void completeOperationLocal(TransactionProxyOperation operation, DataTree dataTree) { + private void completeOperationLocal(final TransactionProxyOperation operation, final DataTree dataTree) { ActorSystem actorSystem = getSystem(); ActorRef shardActorRef = actorSystem.actorOf(Props.create(DoNothingActor.class)); @@ -913,14 +973,15 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { return dataTree; } - private static DataTree createDataTree(NormalizedNode readResponse) { + private static DataTree createDataTree(final NormalizedNode readResponse) { DataTree dataTree = mock(DataTree.class); DataTreeSnapshot dataTreeSnapshot = mock(DataTreeSnapshot.class); DataTreeModification dataTreeModification = mock(DataTreeModification.class); doReturn(dataTreeSnapshot).when(dataTree).takeSnapshot(); doReturn(dataTreeModification).when(dataTreeSnapshot).newModification(); - doReturn(Optional.of(readResponse)).when(dataTreeModification).readNode(any(YangInstanceIdentifier.class)); + doReturn(java.util.Optional.of(readResponse)).when(dataTreeModification).readNode( + any(YangInstanceIdentifier.class)); return dataTree; } @@ -1238,7 +1299,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { .getOperationTimeoutInMillis()) * 2); } - private void testModificationOperationBatching(TransactionType type) throws Exception { + private void testModificationOperationBatching(final TransactionType type) { int shardBatchedModificationCount = 3; dataStoreContextBuilder.shardBatchedModificationCount(shardBatchedModificationCount); @@ -1297,17 +1358,17 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { } @Test - public void testReadWriteModificationOperationBatching() throws Exception { + public void testReadWriteModificationOperationBatching() { testModificationOperationBatching(READ_WRITE); } @Test - public void testWriteOnlyModificationOperationBatching() throws Exception { + public void testWriteOnlyModificationOperationBatching() { testModificationOperationBatching(WRITE_ONLY); } @Test - public void testOptimizedWriteOnlyModificationOperationBatching() throws Exception { + public void testOptimizedWriteOnlyModificationOperationBatching() { dataStoreContextBuilder.writeOnlyTransactionOptimizationsEnabled(true); testModificationOperationBatching(WRITE_ONLY); } @@ -1362,7 +1423,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { transactionProxy.delete(deletePath); - Boolean exists = transactionProxy.exists(TestModel.TEST_PATH).checkedGet(); + Boolean exists = transactionProxy.exists(TestModel.TEST_PATH).get(); assertEquals("Exists response", true, exists); assertEquals("NormalizedNode isPresent", true, readOptional.isPresent()); @@ -1400,7 +1461,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { } @Test - public void testReadRoot() throws ReadFailedException, InterruptedException, ExecutionException, + public void testReadRoot() throws InterruptedException, ExecutionException, java.util.concurrent.TimeoutException { SchemaContext schemaContext = SchemaContextHelper.full(); Configuration configuration = mock(Configuration.class); @@ -1448,7 +1509,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { } - private void setUpReadData(String shardName, NormalizedNode expectedNode) { + private void setUpReadData(final String shardName, final NormalizedNode expectedNode) { ActorSystem actorSystem = getSystem(); ActorRef shardActorRef = getSystem().actorOf(Props.create(DoNothingActor.class));