Search in sources :

Example 11 with TransactionPurgeRequest

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

the class RequestEnvelopeTest method doAdditionalAssertions.

@Override
protected void doAdditionalAssertions(final RequestEnvelope envelope, final RequestEnvelope resolvedObject) {
    final Request<?, ?> actual = resolvedObject.getMessage();
    Assert.assertTrue(actual instanceof TransactionPurgeRequest);
    final TransactionPurgeRequest purgeRequest = (TransactionPurgeRequest) actual;
    Assert.assertEquals(replyTo, purgeRequest.getReplyTo());
    final TransactionPurgeResponse response = new TransactionPurgeResponse(OBJECT, 2L);
    resolvedObject.sendSuccess(response, 11L);
    final SuccessEnvelope successEnvelope = replyToProbe.expectMsgClass(SuccessEnvelope.class);
    Assert.assertEquals(response, successEnvelope.getMessage());
    final RuntimeRequestException failResponse = new RuntimeRequestException("fail", new RuntimeException());
    resolvedObject.sendFailure(failResponse, 11L);
    final FailureEnvelope failureEnvelope = replyToProbe.expectMsgClass(FailureEnvelope.class);
    Assert.assertEquals(failResponse, failureEnvelope.getMessage().getCause());
}
Also used : TransactionPurgeResponse(org.opendaylight.controller.cluster.access.commands.TransactionPurgeResponse) TransactionPurgeRequest(org.opendaylight.controller.cluster.access.commands.TransactionPurgeRequest)

Example 12 with TransactionPurgeRequest

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

the class RemoteProxyTransaction method handleForwardedRequest.

void handleForwardedRequest(final TransactionRequest<?> request, final Consumer<Response<?, ?>> callback) {
    if (request instanceof ModifyTransactionRequest) {
        handleForwardedModifyTransactionRequest(callback, (ModifyTransactionRequest) request);
    } else if (request instanceof ReadTransactionRequest) {
        ensureFlushedBuider();
        sendRequest(new ReadTransactionRequest(getIdentifier(), nextSequence(), localActor(), ((ReadTransactionRequest) request).getPath(), isSnapshotOnly()), resp -> {
            recordFinishedRequest(resp);
            callback.accept(resp);
        });
    } else if (request instanceof ExistsTransactionRequest) {
        ensureFlushedBuider();
        sendRequest(new ExistsTransactionRequest(getIdentifier(), nextSequence(), localActor(), ((ExistsTransactionRequest) request).getPath(), isSnapshotOnly()), resp -> {
            recordFinishedRequest(resp);
            callback.accept(resp);
        });
    } else if (request instanceof TransactionPreCommitRequest) {
        ensureFlushedBuider();
        final TransactionRequest<?> tmp = new TransactionPreCommitRequest(getIdentifier(), nextSequence(), localActor());
        sendRequest(tmp, resp -> {
            recordSuccessfulRequest(tmp);
            callback.accept(resp);
        });
    } else if (request instanceof TransactionDoCommitRequest) {
        ensureFlushedBuider();
        sendRequest(new TransactionDoCommitRequest(getIdentifier(), nextSequence(), localActor()), callback);
    } else if (request instanceof TransactionAbortRequest) {
        ensureFlushedBuider();
        sendDoAbort(callback);
    } else if (request instanceof TransactionPurgeRequest) {
        enqueuePurge(callback);
    } else {
        throw new IllegalArgumentException("Unhandled request {}" + request);
    }
}
Also used : ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) TransactionDelete(org.opendaylight.controller.cluster.access.commands.TransactionDelete) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) AbstractReadTransactionRequest(org.opendaylight.controller.cluster.access.commands.AbstractReadTransactionRequest) DataTreeModification(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification) TransactionWrite(org.opendaylight.controller.cluster.access.commands.TransactionWrite) LoggerFactory(org.slf4j.LoggerFactory) CheckedFuture(com.google.common.util.concurrent.CheckedFuture) IncrementTransactionSequenceRequest(org.opendaylight.controller.cluster.access.commands.IncrementTransactionSequenceRequest) Response(org.opendaylight.controller.cluster.access.concepts.Response) MappingCheckedFuture(org.opendaylight.mdsal.common.api.MappingCheckedFuture) SettableFuture(com.google.common.util.concurrent.SettableFuture) TransactionModification(org.opendaylight.controller.cluster.access.commands.TransactionModification) TransactionPurgeRequest(org.opendaylight.controller.cluster.access.commands.TransactionPurgeRequest) ExistsTransactionSuccess(org.opendaylight.controller.cluster.access.commands.ExistsTransactionSuccess) RequestFailure(org.opendaylight.controller.cluster.access.concepts.RequestFailure) Optional(com.google.common.base.Optional) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) TransactionRequest(org.opendaylight.controller.cluster.access.commands.TransactionRequest) Nullable(javax.annotation.Nullable) AbortLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest) ModifyTransactionRequestBuilder(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder) AbstractLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.AbstractLocalTransactionRequest) CommitLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest) ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest) Logger(org.slf4j.Logger) TransactionDoCommitRequest(org.opendaylight.controller.cluster.access.commands.TransactionDoCommitRequest) TransactionMerge(org.opendaylight.controller.cluster.access.commands.TransactionMerge) PersistenceProtocol(org.opendaylight.controller.cluster.access.commands.PersistenceProtocol) AbstractDataTreeModificationCursor(org.opendaylight.controller.cluster.datastore.util.AbstractDataTreeModificationCursor) ReadTransactionSuccess(org.opendaylight.controller.cluster.access.commands.ReadTransactionSuccess) TransactionAbortRequest(org.opendaylight.controller.cluster.access.commands.TransactionAbortRequest) TransactionPreCommitRequest(org.opendaylight.controller.cluster.access.commands.TransactionPreCommitRequest) Consumer(java.util.function.Consumer) Futures(com.google.common.util.concurrent.Futures) TransactionSuccess(org.opendaylight.controller.cluster.access.commands.TransactionSuccess) PathArgument(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument) ReadTransactionRequest(org.opendaylight.controller.cluster.access.commands.ReadTransactionRequest) TransactionIdentifier(org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier) ExistsTransactionRequest(org.opendaylight.controller.cluster.access.commands.ExistsTransactionRequest) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) TransactionDoCommitRequest(org.opendaylight.controller.cluster.access.commands.TransactionDoCommitRequest) ExistsTransactionRequest(org.opendaylight.controller.cluster.access.commands.ExistsTransactionRequest) TransactionPurgeRequest(org.opendaylight.controller.cluster.access.commands.TransactionPurgeRequest) TransactionAbortRequest(org.opendaylight.controller.cluster.access.commands.TransactionAbortRequest) AbstractReadTransactionRequest(org.opendaylight.controller.cluster.access.commands.AbstractReadTransactionRequest) ReadTransactionRequest(org.opendaylight.controller.cluster.access.commands.ReadTransactionRequest) ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest) AbstractReadTransactionRequest(org.opendaylight.controller.cluster.access.commands.AbstractReadTransactionRequest) TransactionRequest(org.opendaylight.controller.cluster.access.commands.TransactionRequest) AbortLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest) AbstractLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.AbstractLocalTransactionRequest) CommitLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest) ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest) ReadTransactionRequest(org.opendaylight.controller.cluster.access.commands.ReadTransactionRequest) ExistsTransactionRequest(org.opendaylight.controller.cluster.access.commands.ExistsTransactionRequest) TransactionPreCommitRequest(org.opendaylight.controller.cluster.access.commands.TransactionPreCommitRequest)

Example 13 with TransactionPurgeRequest

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

the class AbstractTransmitQueueTest method testPoison.

@Test
public void testPoison() throws Exception {
    final Request<?, ?> request = new TransactionPurgeRequest(TRANSACTION_IDENTIFIER, 0L, probe.ref());
    final Consumer<Response<?, ?>> callback = createConsumerMock();
    final long now = Ticker.systemTicker().read();
    queue.enqueueOrForward(new ConnectionEntry(request, callback, now), now);
    queue.poison(new RuntimeRequestException("fail", new RuntimeException("fail")));
    verify(callback).accept(any(TransactionFailure.class));
    Assert.assertTrue(queue.isEmpty());
}
Also used : TransactionPurgeResponse(org.opendaylight.controller.cluster.access.commands.TransactionPurgeResponse) Response(org.opendaylight.controller.cluster.access.concepts.Response) TransactionFailure(org.opendaylight.controller.cluster.access.commands.TransactionFailure) TransactionPurgeRequest(org.opendaylight.controller.cluster.access.commands.TransactionPurgeRequest) RuntimeRequestException(org.opendaylight.controller.cluster.access.concepts.RuntimeRequestException) Test(org.junit.Test)

Example 14 with TransactionPurgeRequest

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

the class RequestEnvelopeTest method createEnvelope.

@Override
protected RequestEnvelope createEnvelope() {
    replyToProbe = new TestProbe(system);
    replyTo = replyToProbe.ref();
    final TransactionPurgeRequest message = new TransactionPurgeRequest(OBJECT, 2L, replyTo);
    return new RequestEnvelope(message, 1L, 2L);
}
Also used : TransactionPurgeRequest(org.opendaylight.controller.cluster.access.commands.TransactionPurgeRequest) TestProbe(akka.testkit.TestProbe)

Example 15 with TransactionPurgeRequest

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

the class AbstractProxyTransactionTest method testForwardToRemotePurge.

@Test
public void testForwardToRemotePurge() throws Exception {
    final TestProbe probe = new TestProbe(system);
    final TransactionPurgeRequest request = new TransactionPurgeRequest(TRANSACTION_ID, 0L, probe.ref());
    testForwardToRemote(request, TransactionPurgeRequest.class);
}
Also used : TransactionPurgeRequest(org.opendaylight.controller.cluster.access.commands.TransactionPurgeRequest) TestProbe(akka.testkit.TestProbe) Test(org.junit.Test)

Aggregations

TransactionPurgeRequest (org.opendaylight.controller.cluster.access.commands.TransactionPurgeRequest)19 Test (org.junit.Test)12 Response (org.opendaylight.controller.cluster.access.concepts.Response)11 TransactionPurgeResponse (org.opendaylight.controller.cluster.access.commands.TransactionPurgeResponse)10 TestProbe (akka.testkit.TestProbe)4 ModifyTransactionRequestBuilder (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder)4 RequestEnvelope (org.opendaylight.controller.cluster.access.concepts.RequestEnvelope)4 TransactionIdentifier (org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier)4 Nullable (javax.annotation.Nullable)3 AbortLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest)3 CommitLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest)3 IncrementTransactionSequenceRequest (org.opendaylight.controller.cluster.access.commands.IncrementTransactionSequenceRequest)3 ModifyTransactionRequest (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest)3 TransactionSuccess (org.opendaylight.controller.cluster.access.commands.TransactionSuccess)3 Optional (com.google.common.base.Optional)2 CheckedFuture (com.google.common.util.concurrent.CheckedFuture)2 Futures (com.google.common.util.concurrent.Futures)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 SettableFuture (com.google.common.util.concurrent.SettableFuture)2 Consumer (java.util.function.Consumer)2