use of org.infinispan.interceptors.AsyncInterceptorChain in project infinispan by infinispan.
the class AddStoreTest method checkClustered.
private void checkClustered(Cache<?, ?> cache) {
AsyncInterceptorChain asyncInterceptorChain = cache.getAdvancedCache().getAdvancedCache().getAsyncInterceptorChain();
assertNotNull(asyncInterceptorChain.findInterceptorWithClass(ClusteredCacheLoaderInterceptor.class));
}
use of org.infinispan.interceptors.AsyncInterceptorChain in project keycloak by keycloak.
the class PersistenceManagerImpl method disableStore.
@Override
public CompletionStage<Void> disableStore(String storeType) {
if (!enabled) {
return CompletableFutures.completedNull();
}
boolean stillHasAStore = false;
AggregateCompletionStage<Void> aggregateCompletionStage = CompletionStages.aggregateCompletionStage();
long stamp = lock.writeLock();
try {
boolean allAvailable = true;
Iterator<StoreStatus> statusIterator = stores.iterator();
while (statusIterator.hasNext()) {
StoreStatus status = statusIterator.next();
NonBlockingStore<?, ?> nonBlockingStore = unwrapStore(status.store());
if (nonBlockingStore.getClass().getName().equals(storeType) || containedInAdapter(nonBlockingStore, storeType)) {
statusIterator.remove();
aggregateCompletionStage.dependsOn(nonBlockingStore.stop().whenComplete((v, t) -> {
if (t != null) {
log.warn("There was an error stopping the store", t);
}
}));
} else {
stillHasAStore = true;
allAvailable = allAvailable && status.availability;
}
}
if (!stillHasAStore) {
unavailableExceptionMessage = null;
enabled = false;
stopAvailabilityTask();
} else if (allAvailable) {
unavailableExceptionMessage = null;
}
allSegmentedOrShared = allStoresSegmentedOrShared();
} finally {
lock.unlockWrite(stamp);
}
if (!stillHasAStore) {
AsyncInterceptorChain chain = cache.wired().getAsyncInterceptorChain();
AsyncInterceptor loaderInterceptor = chain.findInterceptorExtending(CacheLoaderInterceptor.class);
if (loaderInterceptor == null) {
PERSISTENCE.persistenceWithoutCacheLoaderInterceptor();
} else {
chain.removeInterceptor(loaderInterceptor.getClass());
}
AsyncInterceptor writerInterceptor = chain.findInterceptorExtending(CacheWriterInterceptor.class);
if (writerInterceptor == null) {
writerInterceptor = chain.findInterceptorWithClass(TransactionalStoreInterceptor.class);
if (writerInterceptor == null) {
PERSISTENCE.persistenceWithoutCacheWriteInterceptor();
} else {
chain.removeInterceptor(writerInterceptor.getClass());
}
} else {
chain.removeInterceptor(writerInterceptor.getClass());
}
}
return aggregateCompletionStage.freeze();
}
use of org.infinispan.interceptors.AsyncInterceptorChain in project infinispan by infinispan.
the class PrepareCommand method invokeAsync.
@Override
public CompletionStage<?> invokeAsync(ComponentRegistry registry) throws Throwable {
markTransactionAsRemote(true);
RemoteTxInvocationContext ctx = createContext(registry);
if (ctx == null) {
return CompletableFutures.completedNull();
}
if (log.isTraceEnabled())
log.tracef("Invoking remotely originated prepare: %s with invocation context: %s", this, ctx);
CacheNotifier notifier = registry.getCacheNotifier().running();
CompletionStage<Void> stage = notifier.notifyTransactionRegistered(ctx.getGlobalTransaction(), false);
AsyncInterceptorChain invoker = registry.getInterceptorChain().running();
for (VisitableCommand nested : getModifications()) nested.init(registry);
if (CompletionStages.isCompletedSuccessfully(stage)) {
return invoker.invokeAsync(ctx, this);
} else {
return stage.thenCompose(v -> invoker.invokeAsync(ctx, this));
}
}
use of org.infinispan.interceptors.AsyncInterceptorChain in project infinispan by infinispan.
the class BaseDistFunctionalTest method removeAllBlockingInterceptorsFromCache.
protected static void removeAllBlockingInterceptorsFromCache(Cache<?, ?> cache) {
AsyncInterceptorChain chain = TestingUtil.extractInterceptorChain(cache);
BlockingInterceptor<?> blockingInterceptor = chain.findInterceptorExtending(BlockingInterceptor.class);
while (blockingInterceptor != null) {
blockingInterceptor.suspend(true);
chain.removeInterceptor(blockingInterceptor.getClass());
blockingInterceptor = chain.findInterceptorExtending(BlockingInterceptor.class);
}
}
use of org.infinispan.interceptors.AsyncInterceptorChain in project infinispan by infinispan.
the class AsyncInterceptorChainInvocationTest method testCompletedStage.
public void testCompletedStage() {
AsyncInterceptorChain chain = newInterceptorChain(new BaseAsyncInterceptor() {
@Override
public Object visitCommand(InvocationContext ctx, VisitableCommand command) throws Throwable {
return "v1";
}
}, new BaseAsyncInterceptor() {
@Override
public Object visitCommand(InvocationContext ctx, VisitableCommand command) throws Throwable {
return "v2";
}
});
InvocationContext context = newInvocationContext();
Object returnValue = chain.invoke(context, testCommand);
assertEquals("v1", returnValue);
}
Aggregations