use of org.opendaylight.controller.cluster.datastore.messages.BatchedModifications in project controller by opendaylight.
the class AbstractTransactionProxyTest method verifyBatchedModifications.
protected void verifyBatchedModifications(final Object message, final boolean expIsReady, final boolean expIsDoCommitOnReady, final Modification... expected) {
assertEquals("Message type", BatchedModifications.class, message.getClass());
BatchedModifications batchedModifications = (BatchedModifications) message;
assertEquals("BatchedModifications size", expected.length, batchedModifications.getModifications().size());
assertEquals("isReady", expIsReady, batchedModifications.isReady());
assertEquals("isDoCommitOnReady", expIsDoCommitOnReady, batchedModifications.isDoCommitOnReady());
for (int i = 0; i < batchedModifications.getModifications().size(); i++) {
Modification actual = batchedModifications.getModifications().get(i);
assertEquals("Modification type", expected[i].getClass(), actual.getClass());
assertEquals("getPath", ((AbstractModification) expected[i]).getPath(), ((AbstractModification) actual).getPath());
if (actual instanceof WriteModification) {
assertEquals("getData", ((WriteModification) expected[i]).getData(), ((WriteModification) actual).getData());
}
}
}
use of org.opendaylight.controller.cluster.datastore.messages.BatchedModifications in project controller by opendaylight.
the class AbstractShardTest method newBatchedModifications.
static BatchedModifications newBatchedModifications(final TransactionIdentifier transactionID, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data, final boolean ready, final boolean doCommitOnReady, final int messagesSent) {
final BatchedModifications batched = new BatchedModifications(transactionID, CURRENT_VERSION);
batched.addModification(new WriteModification(path, data));
batched.setReady(ready);
batched.setDoCommitOnReady(doCommitOnReady);
batched.setTotalMessagesSent(messagesSent);
return batched;
}
use of org.opendaylight.controller.cluster.datastore.messages.BatchedModifications in project controller by opendaylight.
the class AbstractShardTest method writeToStore.
public static void writeToStore(final ShardDataTree store, final YangInstanceIdentifier id, final NormalizedNode<?, ?> node) throws DataValidationFailedException {
BatchedModifications batched = newBatchedModifications(nextTransactionId(), id, node, true, true, 1);
DataTreeModification modification = store.getDataTree().takeSnapshot().newModification();
batched.apply(modification);
store.notifyListeners(commitTransaction(store.getDataTree(), modification));
}
use of org.opendaylight.controller.cluster.datastore.messages.BatchedModifications in project controller by opendaylight.
the class AbstractShardTest method mergeToStore.
public void mergeToStore(final ShardDataTree store, final YangInstanceIdentifier id, final NormalizedNode<?, ?> node) throws DataValidationFailedException {
final BatchedModifications batched = new BatchedModifications(nextTransactionId(), CURRENT_VERSION);
batched.addModification(new MergeModification(id, node));
batched.setReady(true);
batched.setDoCommitOnReady(true);
batched.setTotalMessagesSent(1);
DataTreeModification modification = store.getDataTree().takeSnapshot().newModification();
batched.apply(modification);
store.notifyListeners(commitTransaction(store.getDataTree(), modification));
}
use of org.opendaylight.controller.cluster.datastore.messages.BatchedModifications 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);
}
Aggregations