/** * Creates a new TransactionOptions configured with default settings. * * @return the created default TransactionOptions. * @see #TransactionOptions() */ public static TransactionOptions getDefault() { return new TransactionOptions(); }
/** * Creates a new TransactionOptions configured with default settings. * * @return the created default TransactionOptions. * @see #TransactionOptions() */ public static TransactionOptions getDefault() { return new TransactionOptions(); }
@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 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 static void main(String[] args) throws Exception { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); TransactionOptions txOptions = new TransactionOptions().setTimeout(10, TimeUnit.SECONDS); TransactionContext txCxt = hz.newTransactionContext(txOptions); txCxt.beginTransaction(); TransactionalMap<String, String> map = txCxt.getMap("map"); try { map.put("1", "1"); map.put("2", "2"); txCxt.commitTransaction(); } catch (RuntimeException t) { txCxt.rollbackTransaction(); throw t; } System.out.println("Finished"); Hazelcast.shutdownAll(); } }
@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 tOpts = new TransactionOptions();
@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 @SuppressWarnings("PMD.PreserveStackTrace") public void run() { 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(); } }
getHazelcastMQContextHolder().isSynchronizedWithTransaction()) { TransactionOptions txOps = new TransactionOptions(); txOps.setTransactionType(TransactionOptions.TransactionType.LOCAL); if (definition.getTimeout() > 0) {
getTransactionContextHolder().isSynchronizedWithTransaction()) { TransactionOptions txOps = new TransactionOptions(); txOps.setTransactionType(TransactionOptions.TransactionType.LOCAL); if (definition.getTimeout() > 0) {