void begin() { try { if (client.getConnectionManager().getOwnerConnection() == null) { throw new TransactionException("Owner connection needs to be present to begin a transaction"); } if (state == ACTIVE) { throw new IllegalStateException("Transaction is already active"); } checkThread(); if (TRANSACTION_EXISTS.get() != null) { throw new IllegalStateException("Nested transactions are not allowed!"); } TRANSACTION_EXISTS.set(Boolean.TRUE); startTime = Clock.currentTimeMillis(); ClientMessage request = TransactionCreateCodec.encodeRequest(options.getTimeoutMillis(), options.getDurability(), options.getTransactionType().id(), threadId); ClientMessage response = ClientTransactionUtil.invoke(request, getTxnId(), client, connection); TransactionCreateCodec.ResponseParameters result = TransactionCreateCodec.decodeResponse(response); txnId = result.response; state = ACTIVE; } catch (Exception e) { TRANSACTION_EXISTS.set(null); throw rethrow(e); } }
void begin() { try { if (client.getConnectionManager().getOwnerConnection() == null) { throw new TransactionException("Owner connection needs to be present to begin a transaction"); } if (state == ACTIVE) { throw new IllegalStateException("Transaction is already active"); } checkThread(); if (TRANSACTION_EXISTS.get() != null) { throw new IllegalStateException("Nested transactions are not allowed!"); } TRANSACTION_EXISTS.set(Boolean.TRUE); startTime = Clock.currentTimeMillis(); ClientMessage request = TransactionCreateCodec.encodeRequest(options.getTimeoutMillis(), options.getDurability(), options.getTransactionType().id(), threadId); ClientMessage response = ClientTransactionUtil.invoke(request, getTxnId(), client, connection); TransactionCreateCodec.ResponseParameters result = TransactionCreateCodec.decodeResponse(response); txnId = result.response; state = ACTIVE; } catch (Exception e) { TRANSACTION_EXISTS.set(null); throw rethrow(e); } }
@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(); }
@Override public void readData(ObjectDataInput in) throws IOException { timeoutMillis = in.readLong(); durability = in.readInt(); transactionType = TransactionType.getByValue(in.readInt()); }
@Override public void readData(ObjectDataInput in) throws IOException { timeoutMillis = in.readLong(); durability = in.readInt(); transactionType = TransactionType.getByValue(in.readInt()); }