/** * 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(); }
/** * 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(); }
@Setup public void setup() { map = targetInstance.getMap(name); resultList = targetInstance.getList(name + "results"); transactionOptions = new TransactionOptions(); transactionOptions.setTransactionType(transactionType).setDurability(durability); }
@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(); }
@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(); }
TransactionOptions options = new TransactionOptions() .setTransactionType(transactionType) .setDurability(durability);
@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(); } }