/** * Getter for manager to allow pausing and resuming transactions * */ public CacheTransactionManager getCacheTransactionManager() { return this.cache.getCacheTransactionManager(); }
throw e; CacheTransactionManager txMgr = cache.getCacheTransactionManager(); Boolean result = false; final boolean isDebugEnabled = logger.isDebugEnabled();
/** Close the cache */ private synchronized void closeCache() { if (cache != null) { try { if (!cache.isClosed()) { CacheTransactionManager txMgr = cache.getCacheTransactionManager(); if (txMgr != null) { if (txMgr.exists()) { // make sure we cleanup this threads txid stored in a thread local txMgr.rollback(); } } cache.close(); } } finally { cache = null; } } }
@Override public void save(File snapshot, SnapshotFormat format, SnapshotOptions<K, V> options) throws IOException { // we can't be in a transaction since that will inline the function execution if (region.getCache().getCacheTransactionManager().exists()) { throw new IllegalStateException("Unable to save snapshot during a transaction"); } if (shouldRunInParallel(options)) { snapshotInParallel(new ParallelArgs<>(snapshot, format, options), new ParallelExportFunction<K, V>()); } else { exportOnMember(snapshot, format, options); } }
@Before public void createMocks() { region = mock(Region.class); execution = mock(Execution.class); collector = mock(ResultCollector.class); provider = mock(LuceneQueryProvider.class); cache = mock(Cache.class); cacheTransactionManager = mock(CacheTransactionManager.class); when(region.getCache()).thenReturn(cache); when(region.getCache().getCacheTransactionManager()).thenReturn(cacheTransactionManager); when(region.getCache().getCacheTransactionManager().exists()).thenReturn(false); when(execution.setArguments(any())).thenReturn(execution); when(execution.withCollector(any())).thenReturn(execution); when(execution.execute(anyString())).thenReturn((ResultCollector) collector); results = mock(PageableLuceneQueryResults.class); query = new LuceneQueryImpl<Object, Object>("index", region, provider, LIMIT, 20) { @Override protected Execution onRegion() { return execution; } @Override protected PageableLuceneQueryResults<Object, Object> newPageableResults(final int pageSize, final TopEntries<Object> entries) { return results; } }; }
logger.debug("RollbackFunction: for transaction: {} rolling back locally", txId); CacheTransactionManager txMgr = cache.getCacheTransactionManager(); if (txMgr.tryResume(txId)) { if (isDebugEnabled) {
logger.debug("CommitFunction: for transaction: {} committing locally", txId); CacheTransactionManager txMgr = cache.getCacheTransactionManager(); if (txMgr.tryResume(txId)) { if (isDebugEnabled) {
try { if (hasTransaction) { txm = cache.getCacheTransactionManager(); transactionId = txm.suspend();
Arrays.asList(other.getCacheTransactionManager().getListeners()); List<TransactionListener> thisTxListeners = Arrays.asList(getCacheTransactionManager().getListeners());
final TransactionListener[] tls = cache.getCacheTransactionManager().getListeners(); if (tls.length > 0) { txEvent = new TXRmtEvent(this.txIdent, cache);
private void executeWithTransaction(ChannelHandlerContext ctx, final Executor exec, Command command) throws Exception { CacheTransactionManager txm = cache.getCacheTransactionManager(); TransactionId transactionId = getTransactionID(); txm.resume(transactionId); try { exec.executeCommand(command, this); } catch (UnsupportedOperationInTransactionException e) { command.setResponse(Coder.getErrorResponse(this.byteBufAllocator, RedisConstants.ERROR_UNSUPPORTED_OPERATION_IN_TRANSACTION)); } catch (TransactionException e) { command.setResponse(Coder.getErrorResponse(this.byteBufAllocator, RedisConstants.ERROR_TRANSACTION_EXCEPTION)); } catch (Exception e) { ByteBuf response = getExceptionResponse(ctx, e); command.setResponse(response); } getTransactionQueue().add(command); transactionId = txm.suspend(); setTransactionID(transactionId); }
generate(this.cache.getCacheTransactionManager()); } else if (this.version.compareTo(CacheXmlVersion.GEMFIRE_6_6) >= 0) { generate(this.cache.getCacheTransactionManager());
getCache().getCacheTransactionManager().begin(); getCache().getCacheTransactionManager().commit();
private TopEntries<K> findTopEntries() throws LuceneQueryException { TopEntriesCollectorManager manager = new TopEntriesCollectorManager(null, limit); LuceneFunctionContext<TopEntriesCollector> context = new LuceneFunctionContext<>(query, indexName, manager, limit); if (region.getCache().getCacheTransactionManager().exists()) { throw new LuceneQueryException(LUCENE_QUERY_CANNOT_BE_EXECUTED_WITHIN_A_TRANSACTION); } // TODO provide a timeout to the user? TopEntries<K> entries = null; try { TopEntriesFunctionCollector collector = new TopEntriesFunctionCollector(context); ResultCollector<TopEntriesCollector, TopEntries<K>> rc = onRegion().setArguments(context).withCollector(collector).execute(LuceneQueryFunction.ID); entries = rc.getResult(); } catch (FunctionException e) { if (e.getCause() instanceof LuceneQueryException) { throw (LuceneQueryException) e.getCause(); } else if (e.getCause() instanceof TransactionException) { // When run from client with single hop disabled throw new LuceneQueryException(LUCENE_QUERY_CANNOT_BE_EXECUTED_WITHIN_A_TRANSACTION); } else if (e.getCause() instanceof RuntimeException) { throw (RuntimeException) e.getCause(); } throw e; } catch (TransactionException e) { // When function execution is run from server throw new LuceneQueryException(LUCENE_QUERY_CANNOT_BE_EXECUTED_WITHIN_A_TRANSACTION); } return entries; }
getCache().getCacheTransactionManager().begin(); Entry e = region.getEntry(key); region.getAll(a); getCache().getCacheTransactionManager().commit(); value = e.getValue();
boolean isTransactionPresent(Region<?, ?> region) { return region.getRegionService() instanceof Cache && isTransactionPresent(((Cache) region.getRegionService()).getCacheTransactionManager()); }
boolean isTransactionPresent(Region<?, ?> region) { return region.getRegionService() instanceof Cache && isTransactionPresent(((Cache) region.getRegionService()).getCacheTransactionManager()); }