@Setup public void setup() { map = targetInstance.getMap(name); resultList = targetInstance.getList(name + "results"); transactionOptions = new TransactionOptions(); transactionOptions.setTransactionType(transactionType).setDurability(durability); }
@Override public StoreTransaction beginTransaction(StoreTxConfig txConfig) throws StorageException { if (transactional) { TransactionOptions txo = new TransactionOptions(); txo.setTimeout(lockExpireMS, TimeUnit.MILLISECONDS); return new HazelCastTransaction(manager.newTransactionContext(txo), txConfig); } else { return new NoOpStoreTransaction(txConfig); } }
@Override public <T> T executeTransaction(TransactionalTask<T> task) throws TransactionException { return executeTransaction(TransactionOptions.getDefault(), task); }
/** * Creates a new default configured TransactionsOptions. * <p/> * It will be configured with a timeout of 2 minutes, durability of 1 and a TransactionType.TWO_PHASE. */ public TransactionOptions() { setDurability(1).setTransactionType(TransactionType.TWO_PHASE).setDefaultTimeout(); }
@Override protected Object innerCall() throws Exception { TransactionOptions options = new TransactionOptions(); options.setDurability(parameters.durability); options.setTimeout(parameters.timeout, TimeUnit.MILLISECONDS); options.setTransactionType(TransactionOptions.TransactionType.getByValue(parameters.transactionType)); TransactionManagerServiceImpl transactionManager = (TransactionManagerServiceImpl) clientEngine.getTransactionManagerService(); TransactionContext context = transactionManager.newClientTransactionContext(options, endpoint.getUuid()); context.beginTransaction(); endpoint.setTransactionContext(context); return context.getTxnId(); }
getHazelcastMQContextHolder().isSynchronizedWithTransaction()) { TransactionOptions txOps = new TransactionOptions(); txOps.setTransactionType(TransactionOptions.TransactionType.LOCAL); if (definition.getTimeout() > 0) { txOps.setTimeout(definition.getTimeout(), TimeUnit.SECONDS);
@Override public void begin() { // start a transaction if (this.transaction != null) { // the transaction context this.transaction = this.hazelcastInstance.newTransactionContext(new TransactionOptions().setTransactionType(TransactionType.ONE_PHASE)); this.transaction.beginTransaction(); // get the map this.transactionCache = this.transaction.getMap(HazelcastCacheProvider.MAP_PREFIX + this.name); } }
public TransactionImpl(TransactionManagerServiceImpl transactionManagerService, NodeEngine nodeEngine, TransactionOptions options, String txOwnerUuid, boolean originatedFromClient) { this.transactionLog = new TransactionLog(); this.transactionManagerService = transactionManagerService; this.nodeEngine = nodeEngine; this.txnId = newUnsecureUuidString(); this.timeoutMillis = options.getTimeoutMillis(); this.transactionType = options.getTransactionType() == LOCAL ? ONE_PHASE : options.getTransactionType(); this.durability = transactionType == ONE_PHASE ? 0 : options.getDurability(); this.txOwnerUuid = txOwnerUuid == null ? nodeEngine.getLocalMember().getUuid() : txOwnerUuid; this.checkThreadAccess = txOwnerUuid == null; this.logger = nodeEngine.getLogger(getClass()); this.rollbackExceptionHandler = logAllExceptions(logger, "Error during rollback!", Level.FINEST); this.rollbackTxExceptionHandler = logAllExceptions(logger, "Error during tx rollback backup!", Level.FINEST); this.replicationTxExceptionHandler = createReplicationTxExceptionHandler(logger); this.originatedFromClient = originatedFromClient; }
/** * Creates a new TransactionOptions configured with default settings. * * @return the created default TransactionOptions. * @see #TransactionOptions() */ public static TransactionOptions getDefault() { return new TransactionOptions(); }
long timeoutMillis = TransactionOptions.getDefault().getTimeoutMillis(); waitWithDeadline(futures, timeoutMillis, TimeUnit.MILLISECONDS, finalizeExceptionHandler); } else {
private void checkTimeout() { if (startTime + options.getTimeoutMillis() < Clock.currentTimeMillis()) { throw new TransactionException("Transaction is timed-out!"); } }
@Override protected Object innerCall() throws Exception { TransactionOptions options = new TransactionOptions(); options.setDurability(parameters.durability); options.setTimeout(parameters.timeout, TimeUnit.MILLISECONDS); options.setTransactionType(TransactionOptions.TransactionType.getByValue(parameters.transactionType)); TransactionManagerServiceImpl transactionManager = (TransactionManagerServiceImpl) clientEngine.getTransactionManagerService(); TransactionContext context = transactionManager.newClientTransactionContext(options, endpoint.getUuid()); context.beginTransaction(); endpoint.setTransactionContext(context); return context.getTxnId(); }
getTransactionContextHolder().isSynchronizedWithTransaction()) { TransactionOptions txOps = new TransactionOptions(); txOps.setTransactionType(TransactionOptions.TransactionType.LOCAL); if (definition.getTimeout() > 0) { txOps.setTimeout(definition.getTimeout(), TimeUnit.SECONDS);
TransactionOptions tOpts = new TransactionOptions(); tOpts.setTransactionType(TransactionOptions.TransactionType.ONE_PHASE); TransactionContext tCtx = hzInstance.newTransactionContext(tOpts);
/** * Creates a new default configured TransactionsOptions. * <p/> * It will be configured with a timeout of 2 minutes, durability of 1 and a TransactionType.TWO_PHASE. */ public TransactionOptions() { setDurability(1).setTransactionType(TransactionType.TWO_PHASE).setDefaultTimeout(); }
public TransactionImpl(TransactionManagerServiceImpl transactionManagerService, NodeEngine nodeEngine, TransactionOptions options, String txOwnerUuid, boolean originatedFromClient) { this.transactionLog = new TransactionLog(); this.transactionManagerService = transactionManagerService; this.nodeEngine = nodeEngine; this.txnId = newUnsecureUuidString(); this.timeoutMillis = options.getTimeoutMillis(); this.transactionType = options.getTransactionType() == LOCAL ? ONE_PHASE : options.getTransactionType(); this.durability = transactionType == ONE_PHASE ? 0 : options.getDurability(); this.txOwnerUuid = txOwnerUuid == null ? nodeEngine.getLocalMember().getUuid() : txOwnerUuid; this.checkThreadAccess = txOwnerUuid == null; this.logger = nodeEngine.getLogger(getClass()); this.rollbackExceptionHandler = logAllExceptions(logger, "Error during rollback!", Level.FINEST); this.rollbackTxExceptionHandler = logAllExceptions(logger, "Error during tx rollback backup!", Level.FINEST); this.replicationTxExceptionHandler = createReplicationTxExceptionHandler(logger); this.originatedFromClient = originatedFromClient; }
/** * Creates a new TransactionOptions configured with default settings. * * @return the created default TransactionOptions. * @see #TransactionOptions() */ public static TransactionOptions getDefault() { return new TransactionOptions(); }
long timeoutMillis = TransactionOptions.getDefault().getTimeoutMillis(); waitWithDeadline(futures, timeoutMillis, TimeUnit.MILLISECONDS, finalizeExceptionHandler); } else {
private void checkTimeout() { if (startTime + options.getTimeoutMillis() < Clock.currentTimeMillis()) { throw new TransactionException("Transaction is timed-out!"); } }
@TimeStep public void timestep(ThreadState state) { int key = state.nextRandom(0, range / 2); TransactionOptions transactionOptions = new TransactionOptions() .setTransactionType(transactionType) .setDurability(durability); TransactionContext transactionContext = targetInstance.newTransactionContext(transactionOptions); transactionContext.beginTransaction(); TransactionalMap<Object, Object> txMap = transactionContext.getMap("map"); try { Object val = txMap.getForUpdate(key); if (val != null) { key = state.nextRandom(range / 2, range); } txMap.put(key, (long) key); transactionContext.commitTransaction(); } catch (Exception e) { logger.severe("----------------------tx exception -------------------------", e); if (failOnException) { throw rethrow(e); } transactionContext.rollbackTransaction(); } }