Search in sources :

Example 51 with AsyncInterceptorChain

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

the class SkipIndexingFlagCheckCommandInterceptor method init.

private SkipIndexingFlagCheckCommandInterceptor init() {
    AsyncInterceptorChain interceptorChain = extractInterceptorChain(cacheManager.getCache(cacheName));
    SkipIndexingFlagCheckCommandInterceptor interceptor = interceptorChain.findInterceptorExtending(SkipIndexingFlagCheckCommandInterceptor.class);
    if (interceptor != null)
        return interceptor;
    SkipIndexingFlagCheckCommandInterceptor ci = new SkipIndexingFlagCheckCommandInterceptor();
    interceptorChain.addInterceptor(ci, 1);
    return ci;
}
Also used : AsyncInterceptorChain(org.infinispan.interceptors.AsyncInterceptorChain)

Example 52 with AsyncInterceptorChain

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

the class LifecycleManager method createQueryInterceptorIfNeeded.

private void createQueryInterceptorIfNeeded(ComponentRegistry cr, Configuration cfg, AdvancedCache<?, ?> cache, Map<String, Class<?>> indexedClasses) {
    CONTAINER.registeringQueryInterceptor(cache.getName());
    BasicComponentRegistry bcr = cr.getComponent(BasicComponentRegistry.class);
    ComponentRef<QueryInterceptor> queryInterceptorRef = bcr.getComponent(QueryInterceptor.class);
    if (queryInterceptorRef != null) {
        // could be already present when two caches share a config
        return;
    }
    ConcurrentMap<GlobalTransaction, Map<Object, Object>> txOldValues = new ConcurrentHashMap<>();
    boolean manualIndexing = HS5_CONF_STRATEGY_MANUAL.equals(cfg.indexing().properties().get(HS5_CONF_STRATEGY_PROPERTY));
    QueryInterceptor queryInterceptor = new QueryInterceptor(manualIndexing, txOldValues, cache, indexedClasses);
    AsyncInterceptorChain ic = bcr.getComponent(AsyncInterceptorChain.class).wired();
    EntryWrappingInterceptor wrappingInterceptor = ic.findInterceptorExtending(EntryWrappingInterceptor.class);
    ic.addInterceptorBefore(queryInterceptor, wrappingInterceptor.getClass());
    bcr.registerComponent(QueryInterceptor.class, queryInterceptor, true);
    bcr.addDynamicDependency(AsyncInterceptorChain.class.getName(), QueryInterceptor.class.getName());
    if (cfg.transaction().transactionMode().isTransactional()) {
        TxQueryInterceptor txQueryInterceptor = new TxQueryInterceptor(txOldValues, queryInterceptor);
        ic.addInterceptorBefore(txQueryInterceptor, wrappingInterceptor.getClass());
        bcr.registerComponent(TxQueryInterceptor.class, txQueryInterceptor, true);
        bcr.addDynamicDependency(AsyncInterceptorChain.class.getName(), TxQueryInterceptor.class.getName());
    }
}
Also used : BasicComponentRegistry(org.infinispan.factories.impl.BasicComponentRegistry) TxQueryInterceptor(org.infinispan.query.backend.TxQueryInterceptor) QueryInterceptor(org.infinispan.query.backend.QueryInterceptor) AsyncInterceptorChain(org.infinispan.interceptors.AsyncInterceptorChain) EntryWrappingInterceptor(org.infinispan.interceptors.impl.EntryWrappingInterceptor) TxQueryInterceptor(org.infinispan.query.backend.TxQueryInterceptor) GlobalTransaction(org.infinispan.transaction.xa.GlobalTransaction) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 53 with AsyncInterceptorChain

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

the class FlagCheckCommandInterceptor method init.

private FlagCheckCommandInterceptor init() {
    AsyncInterceptorChain interceptorChain = cacheManager.getCache(cacheName).getAdvancedCache().getAsyncInterceptorChain();
    FlagCheckCommandInterceptor interceptor = interceptorChain.findInterceptorExtending(FlagCheckCommandInterceptor.class);
    if (interceptor != null)
        return interceptor;
    FlagCheckCommandInterceptor ci = new FlagCheckCommandInterceptor();
    interceptorChain.addInterceptor(ci, 1);
    return ci;
}
Also used : AsyncInterceptorChain(org.infinispan.interceptors.AsyncInterceptorChain)

Aggregations

AsyncInterceptorChain (org.infinispan.interceptors.AsyncInterceptorChain)53 InvocationContext (org.infinispan.context.InvocationContext)15 CompletableFuture (java.util.concurrent.CompletableFuture)13 VisitableCommand (org.infinispan.commands.VisitableCommand)9 AsyncInterceptor (org.infinispan.interceptors.AsyncInterceptor)9 Future (java.util.concurrent.Future)8 SingleKeyNonTxInvocationContext (org.infinispan.context.impl.SingleKeyNonTxInvocationContext)8 BaseAsyncInterceptor (org.infinispan.interceptors.BaseAsyncInterceptor)8 AtomicReference (java.util.concurrent.atomic.AtomicReference)7 TestException (org.infinispan.test.TestException)7 CompletableFutures (org.infinispan.util.concurrent.CompletableFutures)7 SECONDS (java.util.concurrent.TimeUnit.SECONDS)6 ExecutionException (java.util.concurrent.ExecutionException)5 TimeoutException (java.util.concurrent.TimeoutException)5 LockControlCommand (org.infinispan.commands.control.LockControlCommand)5 Test (org.testng.annotations.Test)5 BasicComponentRegistry (org.infinispan.factories.impl.BasicComponentRegistry)4 EntryWrappingInterceptor (org.infinispan.interceptors.impl.EntryWrappingInterceptor)4 AbstractInfinispanTest (org.infinispan.test.AbstractInfinispanTest)4 AssertJUnit.assertEquals (org.testng.AssertJUnit.assertEquals)4