static <T extends AsyncInterceptor> T findInterceptor(Cache<?, ?> cache, Class<T> interceptorClass) { return cache.getAdvancedCache().getAsyncInterceptorChain().findInterceptorExtending(interceptorClass); } }
protected void invoke(Object session, InvocationContext ctx, RemoveCommand command) { invoker.invoke(ctx, command); }
public void testSizeVisibility() throws Exception { updateCache(Visibility.SIZE); }
private boolean verifyChainContainsQueryInterceptor(ComponentRegistry cr) { AsyncInterceptorChain interceptorChain = cr.getComponent(AsyncInterceptorChain.class); return interceptorChain != null && interceptorChain.containsInterceptorType(QueryInterceptor.class, true); }
@Override public Object visitCommand(InvocationContext ctx, VisitableCommand command) throws Throwable { return invokeNextAndHandle(ctx, command, (rCtx, rCommand, rv, t) -> { InvocationSuccessFunction function = (rCtx1, rCommand1, rv1) -> asyncValue(f3); return asyncValue(f2).addCallback(rCtx, rCommand, function); }); } }, new BaseAsyncInterceptor() {
@Override public Object visitGetCacheEntryCommand(InvocationContext ctx, GetCacheEntryCommand command) throws Throwable { latch.await(readDelay, TimeUnit.MILLISECONDS); return super.visitGetCacheEntryCommand(ctx, command); }
@Override public Object visitCommand(InvocationContext ctx, VisitableCommand command) throws Throwable { // Add a handler to force the return value to be a full AsyncInvocationStage InvocationSuccessFunction function = (rCtx, rCommand, rv) -> rv; return asyncValue(f1).addCallback(ctx, command, function); } });
private boolean verifyChainContainsRemoteAvroValueWrapperInterceptor(ComponentRegistry cr) { InterceptorChain interceptorChain = cr.getComponent(InterceptorChain.class); return interceptorChain.containsInterceptorType(RemoteValueWrapperInterceptor.class, true); }
@Override public Object visitInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable { latch.await(10, TimeUnit.SECONDS); return super.visitInvalidateCommand(ctx, command); } }, 0);
public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable { latch.await(writeDelay, TimeUnit.MILLISECONDS); return super.visitPutKeyValueCommand(ctx, command); }
@Override public Object visitRemoveCommand(InvocationContext ctx, RemoveCommand command) throws Throwable { if (isRightType(ctx)) removeOkay = true; return super.visitRemoveCommand(ctx, command); }
@Override public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable { if (isRightType(ctx)) putOkay = true; return super.visitPutKeyValueCommand(ctx, command); }
@Override public Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable { if (isRightType(ctx)) getOkay = true; return super.visitGetKeyValueCommand(ctx, command); }
@Override public Object visitReplaceCommand(InvocationContext ctx, ReplaceCommand command) throws Throwable { if (isRightType(ctx)) replaceOkay = true; return super.visitReplaceCommand(ctx, command); }
private void assertCallback(int index, InvocationCallback callback) throws Throwable { assertEquals("v" + index, callback.apply(null, null, null, null)); }
private static CacheLoaderInterceptor cacheLoaderInterceptor(Cache<?, ?> cache) { AsyncInterceptorChain chain = TestingUtil.extractComponent(cache, AsyncInterceptorChain.class); return chain.findInterceptorExtending( CacheLoaderInterceptor.class); }
private boolean verifyChainContainsQueryInterceptor(ComponentRegistry cr) { AsyncInterceptorChain interceptorChain = cr.getComponent(AsyncInterceptorChain.class); return interceptorChain != null && interceptorChain.containsInterceptorType(QueryInterceptor.class, true); }
@Override public Object visitGetCacheEntryCommand(InvocationContext ctx, GetCacheEntryCommand command) throws Throwable { if (arrival != null) arrival.countDown(); // the timeout has to be longer than remoteTimeout! release.await(30, TimeUnit.SECONDS); return super.visitGetCacheEntryCommand(ctx, command); } }
@Test(groups = "unstable") public void testGetVisibility() throws Exception { updateCache(Visibility.GET); }
public static Class<?> findUniqueClass(AsyncInterceptorChain chain) { for (Class<? extends AsyncInterceptor> clazz : uniqueInterceptorClasses) { if (!chain.containsInterceptorType(clazz)) { return clazz; } } throw new IllegalStateException("Too many sequencer interceptors added to the same chain"); }