Search in sources :

Example 16 with InvocationStage

use of org.infinispan.interceptors.InvocationStage in project infinispan by infinispan.

the class CacheMgmtInterceptorTest method testVisitPutMapCommandException.

public void testVisitPutMapCommandException() throws Throwable {
    PutMapCommand command = new PutMapCommand(Collections.singletonMap(KEY, VALUE), null, 0, null);
    InvocationStage stage = makeStage(interceptor.visitPutMapCommand(ctx, command));
    assertFalse(stage.isDone());
    timeService.advance(1);
    nextInterceptor.completeLastInvocationExceptionally(new TestException());
    expectInvocationException(stage);
    assertEquals(1, interceptor.getAverageWriteTime());
}
Also used : InvocationStage(org.infinispan.interceptors.InvocationStage) PutMapCommand(org.infinispan.commands.write.PutMapCommand) TestException(org.infinispan.test.TestException)

Example 17 with InvocationStage

use of org.infinispan.interceptors.InvocationStage in project infinispan by infinispan.

the class CacheMgmtInterceptorTest method testVisitGetAllCommandException.

public void testVisitGetAllCommandException() throws Throwable {
    GetAllCommand command = new GetAllCommand(Collections.singleton(KEY), 0, false);
    InvocationStage stage = makeStage(interceptor.visitGetAllCommand(ctx, command));
    assertFalse(stage.isDone());
    timeService.advance(1);
    nextInterceptor.completeLastInvocationExceptionally(new TestException());
    expectInvocationException(stage);
    assertEquals(1, interceptor.getAverageReadTime());
}
Also used : InvocationStage(org.infinispan.interceptors.InvocationStage) TestException(org.infinispan.test.TestException) GetAllCommand(org.infinispan.commands.read.GetAllCommand)

Example 18 with InvocationStage

use of org.infinispan.interceptors.InvocationStage in project infinispan by infinispan.

the class CacheMgmtInterceptorTest method testVisitGetCacheEntryCommandException.

public void testVisitGetCacheEntryCommandException() throws Throwable {
    GetCacheEntryCommand command = new GetCacheEntryCommand(KEY, 0, 0);
    InvocationStage stage = makeStage(interceptor.visitGetCacheEntryCommand(ctx, command));
    assertFalse(stage.isDone());
    timeService.advance(1);
    nextInterceptor.completeLastInvocationExceptionally(new TestException());
    expectInvocationException(stage);
    assertEquals(1, interceptor.getAverageReadTime());
}
Also used : InvocationStage(org.infinispan.interceptors.InvocationStage) TestException(org.infinispan.test.TestException) GetCacheEntryCommand(org.infinispan.commands.read.GetCacheEntryCommand)

Example 19 with InvocationStage

use of org.infinispan.interceptors.InvocationStage in project infinispan by infinispan.

the class CacheMgmtInterceptorTest method testVisitGetKeyValueCommandException.

public void testVisitGetKeyValueCommandException() throws Throwable {
    GetKeyValueCommand command = new GetKeyValueCommand(KEY, 0, 0);
    InvocationStage stage = makeStage(interceptor.visitGetKeyValueCommand(ctx, command));
    assertFalse(stage.isDone());
    timeService.advance(1);
    nextInterceptor.completeLastInvocationExceptionally(new TestException());
    expectInvocationException(stage);
    assertEquals(1, interceptor.getAverageReadTime());
}
Also used : InvocationStage(org.infinispan.interceptors.InvocationStage) TestException(org.infinispan.test.TestException) GetKeyValueCommand(org.infinispan.commands.read.GetKeyValueCommand)

Example 20 with InvocationStage

use of org.infinispan.interceptors.InvocationStage in project infinispan by infinispan.

the class QueueAsyncInvocationStage method invokeQueuedHandlers.

private void invokeQueuedHandlers(Object rv, Throwable throwable) {
    if (log.isTraceEnabled())
        log.tracef("Resuming invocation of command %s with %d handlers", command, queueSize());
    while (true) {
        InvocationCallback function = queuePoll();
        if (function == null) {
            // We finished running the handlers, and the last pollHandler() call locked the queue.
            if (throwable == null) {
                future.complete(rv);
            } else {
                future.completeExceptionally(throwable);
            }
            return;
        }
        // Run the handler
        try {
            if (throwable != null) {
                throwable = CompletableFutures.extractException(throwable);
            }
            rv = function.apply(ctx, command, rv, throwable);
            throwable = null;
        } catch (Throwable t) {
            rv = null;
            throwable = t;
        }
        if (rv instanceof InvocationStage) {
            InvocationStage currentStage = (InvocationStage) rv;
            currentStage.addCallback(ctx, command, this);
            return;
        }
    // We got a synchronous invocation stage, continue with the next handler
    }
}
Also used : ExceptionSyncInvocationStage(org.infinispan.interceptors.ExceptionSyncInvocationStage) InvocationStage(org.infinispan.interceptors.InvocationStage) InvocationCallback(org.infinispan.interceptors.InvocationCallback)

Aggregations

InvocationStage (org.infinispan.interceptors.InvocationStage)29 TestException (org.infinispan.test.TestException)7 TxInvocationContext (org.infinispan.context.impl.TxInvocationContext)6 SyncInvocationStage (org.infinispan.interceptors.SyncInvocationStage)6 PutKeyValueCommand (org.infinispan.commands.write.PutKeyValueCommand)5 Map (java.util.Map)4 VisitableCommand (org.infinispan.commands.VisitableCommand)4 LockControlCommand (org.infinispan.commands.control.LockControlCommand)4 PrepareCommand (org.infinispan.commands.tx.PrepareCommand)4 PutMapCommand (org.infinispan.commands.write.PutMapCommand)4 RemoveCommand (org.infinispan.commands.write.RemoveCommand)4 ReplaceCommand (org.infinispan.commands.write.ReplaceCommand)4 WriteCommand (org.infinispan.commands.write.WriteCommand)4 InvocationContext (org.infinispan.context.InvocationContext)4 KeyValuePair (org.infinispan.util.KeyValuePair)4 FlagAffectedCommand (org.infinispan.commands.FlagAffectedCommand)3 CommitCommand (org.infinispan.commands.tx.CommitCommand)3 CacheEntry (org.infinispan.container.entries.CacheEntry)3 FlagBitSets (org.infinispan.context.impl.FlagBitSets)3 Inject (org.infinispan.factories.annotations.Inject)3