/** * {@inheritDoc} */ public String getName() { return parentCache.getName(); }
private String getPendingPutsName(AdvancedCache cache) { return cache.getName() + "-" + InfinispanProperties.DEF_PENDING_PUTS_RESOURCE; }
@Override public String getCacheName() { return cache.getName(); }
/** * Clear all regions from this command factory. * * @param regions collection of regions to clear */ public void clearRegions(Collection<? extends InfinispanBaseRegion> regions) { regions.forEach(region -> allRegions.remove(ByteString.fromString(region.getCache().getName()))); }
/** * Add region so that commands can be cleared on shutdown. * * @param region instance to keep track of */ public void addRegion(InfinispanBaseRegion region) { allRegions.put(ByteString.fromString(region.getCache().getName()), region); }
@Override public void close() { embeddedCache.stop(); cacheFactory.cacheClosed(embeddedCache.getName()); }
private PutFromLoadValidator findValidator(AdvancedCache cache) { CacheCommandInitializer cmdInit = cache.getComponentRegistry().getComponent(CacheCommandInitializer.class); return cmdInit.findPutFromLoadValidator(cache.getName()); }
protected void stopCacheRegions() { log.debug( "Clear region references" ); getCacheCommandFactory().clearRegions( regions ); // Ensure we cleanup any caches we created regions.forEach( region -> { region.destroy(); manager.undefineConfiguration( region.getCache().getName() ); } ); regions.clear(); }
protected void registerClusteredInvalidation(Object session, Object lockOwner, Object key) { SessionAccess.TransactionCoordinatorAccess transactionCoordinator = SESSION_ACCESS.getTransactionCoordinator(session); if (transactionCoordinator == null) { return; } if (trace) { log.tracef("Registering synchronization on transaction in %s, cache %s: %s", lockOwner, cache.getName(), key); } transactionCoordinator.registerLocalSynchronization(new InvalidationSynchronization(nonTxPutFromLoadInterceptor, key, lockOwner)); } }
protected void registerLocalInvalidation(Object session, Object lockOwner, Object key) { SessionAccess.TransactionCoordinatorAccess transactionCoordinator = SESSION_ACCESS.getTransactionCoordinator(session); if (transactionCoordinator == null) { return; } if (trace) { log.tracef("Registering synchronization on transaction in %s, cache %s: %s", lockOwner, cache.getName(), key); } transactionCoordinator.registerLocalSynchronization(new LocalInvalidationSynchronization(putValidator, key, lockOwner)); }
public <E> CacheQuery<E> buildCacheQuery(QueryDefinition queryDefinition, IndexedQueryMode indexedQueryMode, KeyTransformationHandler keyTransformationHandler, TimeoutExceptionFactory timeoutExceptionFactory, ExecutorService asyncExecutor, IndexedTypeMap<CustomTypeMetadata> indexedTypeMap) { if (!isIndexed) { throw log.cannotRunLuceneQueriesIfNotIndexed(cache.getName()); } if (indexedQueryMode == IndexedQueryMode.BROADCAST) { return new ClusteredCacheQueryImpl<>(queryDefinition, asyncExecutor, cache, keyTransformationHandler, indexedTypeMap); } else { queryDefinition.initialize(cache); return new CacheQueryImpl<>(queryDefinition.getHsQuery(), cache, keyTransformationHandler); } }
void iterationNext(HotRodHeader header, Subject subject, String iterationId) { AdvancedCache<byte[], byte[]> cache = server.cache(header, subject); executor.execute(() -> { try { IterableIterationResult iterationResult = server.getIterationManager().next(cache.getName(), iterationId); writeResponse(header, header.encoder().iterationNextResponse(header, server, channel.alloc(), iterationResult)); } catch (Throwable t) { writeException(header, t); } }); }
void iterationEnd(HotRodHeader header, Subject subject, String iterationId) { AdvancedCache<byte[], byte[]> cache = server.cache(header, subject); executor.execute(() -> { try { boolean removed = server.getIterationManager().close(cache.getName(), iterationId); writeResponse(header, header.encoder().emptyResponse(header, server, channel.alloc(), removed ? OperationStatus.Success : OperationStatus.InvalidIteration)); } catch (Throwable t) { writeException(header, t); } }); }
public PrepareCoordinator(AdvancedCache<byte[], byte[]> cache, XidImpl xid, boolean recoverable, long transactionTimeout) { this.xid = xid; this.recoverable = recoverable; this.transactionTimeout = transactionTimeout; this.cache = cache; ComponentRegistry registry = cache.getComponentRegistry(); this.transactionTable = registry.getComponent(TransactionTable.class); this.perCacheTxTable = registry.getComponent(PerCacheTxTable.class); this.globalTxTable = registry.getGlobalComponentRegistry().getComponent(GlobalTxTable.class); this.cacheXid = new CacheXid(ByteString.fromString(cache.getName()), xid); }
/** * Broadcast an evict-all command with the given cache instance. * @param cache instance used to broadcast command * */ public static void broadcastEvictAll(AdvancedCache cache) { final RpcManager rpcManager = cache.getRpcManager(); if ( rpcManager != null ) { // Only broadcast evict all if it's clustered final CacheCommandInitializer factory = cache.getComponentRegistry() .getComponent( CacheCommandInitializer.class ); final boolean isSync = isSynchronousCache( cache ); final EvictAllCommand cmd = factory.buildEvictAllCommand(ByteString.fromString(cache.getName())); final RpcOptions options = rpcManager.getDefaultRpcOptions( isSync ); rpcManager.invokeRemotely( null, cmd, options ); } }
protected AdvancedCache getPendingPutsCache(Class<Item> entityClazz) { InfinispanBaseRegion region = TEST_SESSION_ACCESS.getRegion(sessionFactory(), entityClazz.getName()); AdvancedCache entityCache = region.getCache(); return entityCache.getCacheManager().getCache( entityCache.getName() + "-" + InfinispanProperties.DEF_PENDING_PUTS_RESOURCE).getAdvancedCache(); }
@Test public void testCacheWithRegionName() { InfinispanBaseRegion myregion = TEST_SESSION_ACCESS.getRegion(sessionFactory(), "myregion"); InfinispanBaseRegion otherregion = TEST_SESSION_ACCESS.getRegion(sessionFactory(), "otherregion"); assertEquals("myregion", myregion.getCache().getName()); assertEquals("otherregion", otherregion.getCache().getName()); }
@After public void tearDown() throws Exception { cleanup.forEach(Runnable::run); cleanup.clear(); try { DualNodeJtaTransactionManagerImpl.cleanupTransactions(); } finally { DualNodeJtaTransactionManagerImpl.cleanupTransactionManagers(); } cache.clear(); cm.getCache(cache.getName() + "-" + InfinispanProperties.DEF_PENDING_PUTS_RESOURCE).clear(); testee.removePendingPutsCache(); }
private CacheStatusResponse getCacheStatus(AdvancedCache cache) { LocalTopologyManager localTopologyManager = cache.getComponentRegistry().getComponent(LocalTopologyManager.class); int viewId = cache.getRpcManager().getTransport().getViewId(); ManagerStatusResponse statusResponse = localTopologyManager.handleStatusRequest(viewId); return statusResponse.getCaches().get(cache.getName()); }
private static void completeLocalTransaction(AdvancedCache<?, ?> cache, XidImpl xid, long timeout, boolean commit) throws HeuristicRollbackException, HeuristicMixedException, RollbackException { PerCacheTxTable perCacheTxTable = cache.getComponentRegistry().getComponent(PerCacheTxTable.class); GlobalTxTable globalTxTable = cache.getComponentRegistry().getGlobalComponentRegistry() .getComponent(GlobalTxTable.class); try { //local transaction EmbeddedTransaction tx = perCacheTxTable.getLocalTx(xid); tx.runCommit(!commit); CacheXid cacheXid = new CacheXid(ByteString.fromString(cache.getName()), xid); TxFunction function = new SetCompletedTransactionFunction(commit); globalTxTable.update(cacheXid, function, timeout); } finally { perCacheTxTable.removeLocalTx(xid); } }