use of org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply in project controller by opendaylight.
the class TransactionProxyTest method testReadyWithNoModifications.
@Test
public void testReadyWithNoModifications() throws Exception {
ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), READ_WRITE);
doReturn(readDataReply(null)).when(mockActorContext).executeOperationAsync(eq(actorSelection(actorRef)), eqReadData(), any(Timeout.class));
expectBatchedModificationsReady(actorRef, true);
TransactionProxy transactionProxy = new TransactionProxy(mockComponentFactory, READ_WRITE);
transactionProxy.read(TestModel.TEST_PATH);
DOMStoreThreePhaseCommitCohort ready = transactionProxy.ready();
assertTrue(ready instanceof SingleCommitCohortProxy);
verifyCohortFutures((SingleCommitCohortProxy) ready, new CommitTransactionReply().toSerializable());
List<BatchedModifications> batchedModifications = captureBatchedModifications(actorRef);
assertEquals("Captured BatchedModifications count", 1, batchedModifications.size());
verifyBatchedModifications(batchedModifications.get(0), true, true);
}
use of org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply in project controller by opendaylight.
the class TransactionProxyTest method testReadyWithReadWrite.
@Test
public void testReadyWithReadWrite() throws Exception {
ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), READ_WRITE);
final NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
doReturn(readDataReply(null)).when(mockActorContext).executeOperationAsync(eq(actorSelection(actorRef)), eqReadData(), any(Timeout.class));
expectBatchedModificationsReady(actorRef, true);
TransactionProxy transactionProxy = new TransactionProxy(mockComponentFactory, READ_WRITE);
transactionProxy.read(TestModel.TEST_PATH);
transactionProxy.write(TestModel.TEST_PATH, nodeToWrite);
DOMStoreThreePhaseCommitCohort ready = transactionProxy.ready();
assertTrue(ready instanceof SingleCommitCohortProxy);
verifyCohortFutures((SingleCommitCohortProxy) ready, new CommitTransactionReply().toSerializable());
List<BatchedModifications> batchedModifications = captureBatchedModifications(actorRef);
assertEquals("Captured BatchedModifications count", 1, batchedModifications.size());
verifyBatchedModifications(batchedModifications.get(0), true, true, new WriteModification(TestModel.TEST_PATH, nodeToWrite));
assertEquals("getTotalMessageCount", 1, batchedModifications.get(0).getTotalMessagesSent());
}
use of org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply in project controller by opendaylight.
the class TransactionProxyTest method testReadyWithWriteOnlyAndLastBatchEmpty.
@Test
public void testReadyWithWriteOnlyAndLastBatchEmpty() throws Exception {
dataStoreContextBuilder.shardBatchedModificationCount(1).writeOnlyTransactionOptimizationsEnabled(true);
ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), WRITE_ONLY);
NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
expectBatchedModificationsReady(actorRef, true);
TransactionProxy transactionProxy = new TransactionProxy(mockComponentFactory, WRITE_ONLY);
transactionProxy.write(TestModel.TEST_PATH, nodeToWrite);
DOMStoreThreePhaseCommitCohort ready = transactionProxy.ready();
assertTrue(ready instanceof SingleCommitCohortProxy);
verifyCohortFutures((SingleCommitCohortProxy) ready, new CommitTransactionReply().toSerializable());
List<BatchedModifications> batchedModifications = captureBatchedModifications(actorRef);
assertEquals("Captured BatchedModifications count", 2, batchedModifications.size());
verifyBatchedModifications(batchedModifications.get(0), false, new WriteModification(TestModel.TEST_PATH, nodeToWrite));
verifyBatchedModifications(batchedModifications.get(1), true, true);
}
use of org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply in project controller by opendaylight.
the class TransactionProxyTest method testReadyWithDebugContextEnabled.
@Test
public void testReadyWithDebugContextEnabled() throws Exception {
dataStoreContextBuilder.transactionDebugContextEnabled(true);
ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), READ_WRITE);
expectBatchedModificationsReady(actorRef, true);
TransactionProxy transactionProxy = new TransactionProxy(mockComponentFactory, READ_WRITE);
transactionProxy.merge(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
DOMStoreThreePhaseCommitCohort ready = transactionProxy.ready();
assertTrue(ready instanceof DebugThreePhaseCommitCohort);
verifyCohortFutures((DebugThreePhaseCommitCohort) ready, new CommitTransactionReply().toSerializable());
}
use of org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply in project controller by opendaylight.
the class TransactionProxyTest method testReadyWithLocalTransaction.
@Test
public void testReadyWithLocalTransaction() throws Exception {
ActorRef shardActorRef = getSystem().actorOf(Props.create(DoNothingActor.class));
doReturn(getSystem().actorSelection(shardActorRef.path())).when(mockActorContext).actorSelection(shardActorRef.path().toString());
doReturn(Futures.successful(newPrimaryShardInfo(shardActorRef, createDataTree()))).when(mockActorContext).findPrimaryShardAsync(eq(DefaultShardStrategy.DEFAULT_SHARD));
TransactionProxy transactionProxy = new TransactionProxy(mockComponentFactory, WRITE_ONLY);
expectReadyLocalTransaction(shardActorRef, true);
NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
transactionProxy.write(TestModel.TEST_PATH, nodeToWrite);
DOMStoreThreePhaseCommitCohort ready = transactionProxy.ready();
assertTrue(ready instanceof SingleCommitCohortProxy);
verifyCohortFutures((SingleCommitCohortProxy) ready, new CommitTransactionReply().toSerializable());
}
Aggregations