Search in sources :

Example 1 with TransactionWrite

use of org.opendaylight.controller.cluster.access.commands.TransactionWrite in project controller by opendaylight.

the class LocalReadWriteProxyTransaction method flushState.

@Override
Optional<ModifyTransactionRequest> flushState() {
    final ModifyTransactionRequestBuilder b = new ModifyTransactionRequestBuilder(getIdentifier(), localActor());
    b.setSequence(0);
    sealedModification.applyToCursor(new AbstractDataTreeModificationCursor() {

        @Override
        public void write(final PathArgument child, final NormalizedNode<?, ?> data) {
            b.addModification(new TransactionWrite(current().node(child), data));
        }

        @Override
        public void merge(final PathArgument child, final NormalizedNode<?, ?> data) {
            b.addModification(new TransactionMerge(current().node(child), data));
        }

        @Override
        public void delete(final PathArgument child) {
            b.addModification(new TransactionDelete(current().node(child)));
        }
    });
    return Optional.of(b.build());
}
Also used : AbstractDataTreeModificationCursor(org.opendaylight.controller.cluster.datastore.util.AbstractDataTreeModificationCursor) ModifyTransactionRequestBuilder(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder) TransactionWrite(org.opendaylight.controller.cluster.access.commands.TransactionWrite) PathArgument(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument) TransactionDelete(org.opendaylight.controller.cluster.access.commands.TransactionDelete) TransactionMerge(org.opendaylight.controller.cluster.access.commands.TransactionMerge)

Example 2 with TransactionWrite

use of org.opendaylight.controller.cluster.access.commands.TransactionWrite in project controller by opendaylight.

the class RemoteProxyTransaction method replayLocalCommitRequest.

private void replayLocalCommitRequest(final CommitLocalTransactionRequest request, final Consumer<Response<?, ?>> callback, final long enqueuedTicks) {
    final DataTreeModification mod = request.getModification();
    final Optional<Long> optTicks = Optional.of(Long.valueOf(enqueuedTicks));
    mod.applyToCursor(new AbstractDataTreeModificationCursor() {

        @Override
        public void write(final PathArgument child, final NormalizedNode<?, ?> data) {
            appendModification(new TransactionWrite(current().node(child), data), optTicks);
        }

        @Override
        public void merge(final PathArgument child, final NormalizedNode<?, ?> data) {
            appendModification(new TransactionMerge(current().node(child), data), optTicks);
        }

        @Override
        public void delete(final PathArgument child) {
            appendModification(new TransactionDelete(current().node(child)), optTicks);
        }
    });
    enqueueRequest(commitRequest(request.isCoordinated()), callback, enqueuedTicks);
}
Also used : DataTreeModification(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification) AbstractDataTreeModificationCursor(org.opendaylight.controller.cluster.datastore.util.AbstractDataTreeModificationCursor) TransactionWrite(org.opendaylight.controller.cluster.access.commands.TransactionWrite) PathArgument(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument) TransactionDelete(org.opendaylight.controller.cluster.access.commands.TransactionDelete) TransactionMerge(org.opendaylight.controller.cluster.access.commands.TransactionMerge)

Example 3 with TransactionWrite

use of org.opendaylight.controller.cluster.access.commands.TransactionWrite in project controller by opendaylight.

the class ConnectedClientConnectionTest method testSendSliceableMessageRequest.

@SuppressWarnings("unchecked")
@Test
public void testSendSliceableMessageRequest() {
    final ClientActorConfig config = AccessClientUtil.newMockClientActorConfig();
    doReturn(5).when(config).getMaximumMessageSliceSize();
    context = new ClientActorContext(contextProbe.ref(), PERSISTENCE_ID, system, CLIENT_ID, config);
    connection = createConnection();
    final Consumer<Response<?, ?>> callback = mock(Consumer.class);
    final TransactionIdentifier identifier = new TransactionIdentifier(new LocalHistoryIdentifier(CLIENT_ID, 0L), 0L);
    ModifyTransactionRequestBuilder reqBuilder = new ModifyTransactionRequestBuilder(identifier, replyToProbe.ref());
    reqBuilder.addModification(new TransactionWrite(YangInstanceIdentifier.EMPTY, Builders.containerBuilder().withNodeIdentifier(YangInstanceIdentifier.NodeIdentifier.create(QName.create("namespace", "localName"))).build()));
    reqBuilder.setSequence(0L);
    final Request<?, ?> request = reqBuilder.build();
    connection.sendRequest(request, callback);
    backendProbe.expectMsgClass(MessageSlice.class);
}
Also used : Response(org.opendaylight.controller.cluster.access.concepts.Response) TransactionIdentifier(org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier) ModifyTransactionRequestBuilder(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder) TransactionWrite(org.opendaylight.controller.cluster.access.commands.TransactionWrite) LocalHistoryIdentifier(org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier) Test(org.junit.Test)

Example 4 with TransactionWrite

use of org.opendaylight.controller.cluster.access.commands.TransactionWrite in project controller by opendaylight.

the class LocalReadWriteProxyTransactionTest method applyModifyTransactionRequest.

private void applyModifyTransactionRequest(final boolean coordinated) {
    final TestProbe probe = createProbe();
    final ModifyTransactionRequestBuilder builder = new ModifyTransactionRequestBuilder(TRANSACTION_ID, probe.ref());
    final TransactionModification write = new TransactionWrite(PATH_1, DATA_1);
    final TransactionModification merge = new TransactionMerge(PATH_2, DATA_2);
    final TransactionModification delete = new TransactionDelete(PATH_3);
    builder.addModification(write);
    builder.addModification(merge);
    builder.addModification(delete);
    builder.setSequence(0L);
    builder.setCommit(coordinated);
    final ModifyTransactionRequest request = builder.build();
    final Consumer<Response<?, ?>> callback = createCallbackMock();
    transaction.replayModifyTransactionRequest(request, callback, Ticker.systemTicker().read());
    verify(modification).write(PATH_1, DATA_1);
    verify(modification).merge(PATH_2, DATA_2);
    verify(modification).delete(PATH_3);
    final CommitLocalTransactionRequest commitRequest = getTester().expectTransactionRequest(CommitLocalTransactionRequest.class);
    Assert.assertEquals(modification, commitRequest.getModification());
    Assert.assertEquals(coordinated, commitRequest.isCoordinated());
}
Also used : Response(org.opendaylight.controller.cluster.access.concepts.Response) TransactionModification(org.opendaylight.controller.cluster.access.commands.TransactionModification) ModifyTransactionRequestBuilder(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder) TestProbe(akka.testkit.TestProbe) TransactionWrite(org.opendaylight.controller.cluster.access.commands.TransactionWrite) TransactionDelete(org.opendaylight.controller.cluster.access.commands.TransactionDelete) TransactionMerge(org.opendaylight.controller.cluster.access.commands.TransactionMerge) ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest) CommitLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest)

Aggregations

TransactionWrite (org.opendaylight.controller.cluster.access.commands.TransactionWrite)4 ModifyTransactionRequestBuilder (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder)3 TransactionDelete (org.opendaylight.controller.cluster.access.commands.TransactionDelete)3 TransactionMerge (org.opendaylight.controller.cluster.access.commands.TransactionMerge)3 Response (org.opendaylight.controller.cluster.access.concepts.Response)2 AbstractDataTreeModificationCursor (org.opendaylight.controller.cluster.datastore.util.AbstractDataTreeModificationCursor)2 PathArgument (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument)2 TestProbe (akka.testkit.TestProbe)1 Test (org.junit.Test)1 CommitLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest)1 ModifyTransactionRequest (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest)1 TransactionModification (org.opendaylight.controller.cluster.access.commands.TransactionModification)1 LocalHistoryIdentifier (org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier)1 TransactionIdentifier (org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier)1 DataTreeModification (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification)1