X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FAbstractShardTest.java;h=97c9e923a9b656eb067242f1c27bb8a121dd13e8;hp=1100f3a7fa2c0fd584dc57618a6cd54339aa4b60;hb=a507f19b518f36065c74f4f88c9327ede28ff640;hpb=9f17976f66bc0d3b58bcb96f325a241e34871d54 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractShardTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractShardTest.java index 1100f3a7fa..97c9e923a9 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractShardTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractShardTest.java @@ -92,14 +92,15 @@ public abstract class AbstractShardTest extends AbstractActorTest{ newDatastoreContext(), SCHEMA_CONTEXT); } - protected void testRecovery(Set listEntryKeys) throws Exception { + protected void testRecovery(final Set listEntryKeys) throws Exception { // Create the actor and wait for recovery complete. - int nListEntries = listEntryKeys.size(); + final int nListEntries = listEntryKeys.size(); final CountDownLatch recoveryComplete = new CountDownLatch(1); @SuppressWarnings("serial") + final Creator creator = new Creator() { @Override public Shard create() throws Exception { @@ -117,25 +118,25 @@ public abstract class AbstractShardTest extends AbstractActorTest{ } }; - TestActorRef shard = TestActorRef.create(getSystem(), + final TestActorRef shard = TestActorRef.create(getSystem(), Props.create(new DelegatingShardCreator(creator)).withDispatcher(Dispatchers.DefaultDispatcherId()), "testRecovery"); assertEquals("Recovery complete", true, recoveryComplete.await(5, TimeUnit.SECONDS)); // Verify data in the data store. - NormalizedNode outerList = readStore(shard, TestModel.OUTER_LIST_PATH); + final NormalizedNode outerList = readStore(shard, TestModel.OUTER_LIST_PATH); assertNotNull(TestModel.OUTER_LIST_QNAME.getLocalName() + " not found", outerList); assertTrue(TestModel.OUTER_LIST_QNAME.getLocalName() + " value is not Iterable", outerList.getValue() instanceof Iterable); - for(Object entry: (Iterable) outerList.getValue()) { + for(final Object entry: (Iterable) outerList.getValue()) { assertTrue(TestModel.OUTER_LIST_QNAME.getLocalName() + " entry is not MapEntryNode", entry instanceof MapEntryNode); - MapEntryNode mapEntry = (MapEntryNode)entry; - Optional> idLeaf = + final MapEntryNode mapEntry = (MapEntryNode)entry; + final Optional> idLeaf = mapEntry.getChild(new YangInstanceIdentifier.NodeIdentifier(TestModel.ID_QNAME)); assertTrue("Missing leaf " + TestModel.ID_QNAME.getLocalName(), idLeaf.isPresent()); - Object value = idLeaf.get().getValue(); + final Object value = idLeaf.get().getValue(); assertTrue("Unexpected value for leaf "+ TestModel.ID_QNAME.getLocalName() + ": " + value, listEntryKeys.remove(value)); } @@ -155,7 +156,7 @@ public abstract class AbstractShardTest extends AbstractActorTest{ shard.tell(PoisonPill.getInstance(), ActorRef.noSender()); } - protected void verifyLastApplied(TestActorRef shard, long expectedValue) { + protected void verifyLastApplied(final TestActorRef shard, final long expectedValue) { long lastApplied = -1; for(int i = 0; i < 20 * 5; i++) { lastApplied = shard.underlyingActor().getShardMBean().getLastApplied(); @@ -179,9 +180,9 @@ public abstract class AbstractShardTest extends AbstractActorTest{ final MutableCompositeModification modification, final Function> preCommit) { - ReadWriteShardDataTreeTransaction tx = dataStore.newReadWriteTransaction("setup-mock-" + cohortName, null); + final ReadWriteShardDataTreeTransaction tx = dataStore.newReadWriteTransaction("setup-mock-" + cohortName, null); tx.getSnapshot().write(path, data); - ShardDataTreeCohort cohort = createDelegatingMockCohort(cohortName, dataStore.finishTransaction(tx), preCommit); + final ShardDataTreeCohort cohort = createDelegatingMockCohort(cohortName, dataStore.finishTransaction(tx), preCommit); modification.addModification(new WriteModification(path, data)); @@ -196,7 +197,7 @@ public abstract class AbstractShardTest extends AbstractActorTest{ protected ShardDataTreeCohort createDelegatingMockCohort(final String cohortName, final ShardDataTreeCohort actual, final Function> preCommit) { - ShardDataTreeCohort cohort = mock(ShardDataTreeCohort.class, cohortName); + final ShardDataTreeCohort cohort = mock(ShardDataTreeCohort.class, cohortName); doAnswer(new Answer>() { @Override @@ -240,16 +241,16 @@ public abstract class AbstractShardTest extends AbstractActorTest{ return cohort; } - public static NormalizedNode readStore(final TestActorRef shard, final YangInstanceIdentifier id) + public static NormalizedNode readStore(final TestActorRef shard, final YangInstanceIdentifier id) throws ExecutionException, InterruptedException { return readStore(shard.underlyingActor().getDataStore().getDataTree(), id); } public static NormalizedNode readStore(final DataTree store, final YangInstanceIdentifier id) { - DataTreeSnapshot transaction = store.takeSnapshot(); + final DataTreeSnapshot transaction = store.takeSnapshot(); - Optional> optional = transaction.readNode(id); - NormalizedNode node = optional.isPresent()? optional.get() : null; + final Optional> optional = transaction.readNode(id); + final NormalizedNode node = optional.isPresent()? optional.get() : null; return node; } @@ -261,10 +262,10 @@ public abstract class AbstractShardTest extends AbstractActorTest{ public static void writeToStore(final ShardDataTree store, final YangInstanceIdentifier id, final NormalizedNode node) throws InterruptedException, ExecutionException { - ReadWriteShardDataTreeTransaction transaction = store.newReadWriteTransaction("writeToStore", null); + final ReadWriteShardDataTreeTransaction transaction = store.newReadWriteTransaction("writeToStore", null); transaction.getSnapshot().write(id, node); - ShardDataTreeCohort cohort = transaction.ready(); + final ShardDataTreeCohort cohort = transaction.ready(); cohort.canCommit().get(); cohort.preCommit().get(); cohort.commit(); @@ -272,7 +273,7 @@ public abstract class AbstractShardTest extends AbstractActorTest{ public static void writeToStore(final DataTree store, final YangInstanceIdentifier id, final NormalizedNode node) throws DataValidationFailedException { - DataTreeModification transaction = store.takeSnapshot().newModification(); + final DataTreeModification transaction = store.takeSnapshot().newModification(); transaction.write(id, node); transaction.ready();