@Override protected Operation prepareOperation() { Data xid = serializationService.toData(parameters.xid); return new FinalizeRemoteTransactionOperation(xid, parameters.isCommit); }
@Override public void run() throws Exception { XAService xaService = getService(); final List<XATransaction> list = xaService.removeTransactions(xid); if (list == null) { sendResponse(getNodeEngine().toData(XAException.XAER_NOTA)); return; } final int size = list.size(); final ExecutionCallback callback = new ExecutionCallback() { AtomicInteger counter = new AtomicInteger(); @Override public void onResponse(Object response) { sendResponseIfComplete(); } @Override public void onFailure(Throwable t) { // TODO log the error sendResponseIfComplete(); } void sendResponseIfComplete() { if (size == counter.incrementAndGet()) { sendResponse(null); } } }; for (XATransaction xaTransaction : list) { finalizeTransaction(xaTransaction, callback); } }
void sendResponseIfComplete() { if (size == counter.incrementAndGet()) { sendResponse(null); } } };
@Override public void beforeRun() throws Exception { returnsResponse = false; xid = getNodeEngine().toObject(xidData); }
void sendResponseIfComplete() { if (size == counter.incrementAndGet()) { sendResponse(null); } } };
@Override public void beforeRun() throws Exception { returnsResponse = false; xid = getNodeEngine().toObject(xidData); }
@Override public void run() throws Exception { XAService xaService = getService(); final List<XATransaction> list = xaService.removeTransactions(xid); if (list == null) { sendResponse(getNodeEngine().toData(XAException.XAER_NOTA)); return; } final int size = list.size(); final ExecutionCallback callback = new ExecutionCallback() { AtomicInteger counter = new AtomicInteger(); @Override public void onResponse(Object response) { sendResponseIfComplete(); } @Override public void onFailure(Throwable t) { // TODO log the error sendResponseIfComplete(); } void sendResponseIfComplete() { if (size == counter.incrementAndGet()) { sendResponse(null); } } }; for (XATransaction xaTransaction : list) { finalizeTransaction(xaTransaction, callback); } }
@Override protected Operation prepareOperation() { Data xid = serializationService.toData(parameters.xid); return new FinalizeRemoteTransactionOperation(xid, parameters.isCommit); }
private void finalizeTransactionRemotely(Xid xid, boolean isCommit) throws XAException { NodeEngine nodeEngine = getNodeEngine(); IPartitionService partitionService = nodeEngine.getPartitionService(); OperationService operationService = nodeEngine.getOperationService(); SerializableXID serializableXID = new SerializableXID(xid.getFormatId(), xid.getGlobalTransactionId(), xid.getBranchQualifier()); Data xidData = nodeEngine.toData(serializableXID); int partitionId = partitionService.getPartitionId(xidData); FinalizeRemoteTransactionOperation operation = new FinalizeRemoteTransactionOperation(xidData, isCommit); InternalCompletableFuture<Integer> future = operationService.invokeOnPartition(SERVICE_NAME, operation, partitionId); Integer errorCode; try { errorCode = future.get(); } catch (Exception e) { throw ExceptionUtil.rethrow(e); } if (errorCode != null) { throw new XAException(errorCode); } }
private void finalizeTransactionRemotely(Xid xid, boolean isCommit) throws XAException { NodeEngine nodeEngine = getNodeEngine(); IPartitionService partitionService = nodeEngine.getPartitionService(); OperationService operationService = nodeEngine.getOperationService(); SerializableXID serializableXID = new SerializableXID(xid.getFormatId(), xid.getGlobalTransactionId(), xid.getBranchQualifier()); Data xidData = nodeEngine.toData(serializableXID); int partitionId = partitionService.getPartitionId(xidData); FinalizeRemoteTransactionOperation operation = new FinalizeRemoteTransactionOperation(xidData, isCommit); InternalCompletableFuture<Integer> future = operationService.invokeOnPartition(SERVICE_NAME, operation, partitionId); Integer errorCode; try { errorCode = future.get(); } catch (Exception e) { throw ExceptionUtil.rethrow(e); } if (errorCode != null) { throw new XAException(errorCode); } }
return new FinalizeRemoteTransactionBackupOperation(); case FINALIZE_REMOTE_TX: return new FinalizeRemoteTransactionOperation(); case PUT_REMOTE_TX_BACKUP: return new PutRemoteTransactionBackupOperation();
return new FinalizeRemoteTransactionBackupOperation(); case FINALIZE_REMOTE_TX: return new FinalizeRemoteTransactionOperation(); case PUT_REMOTE_TX_BACKUP: return new PutRemoteTransactionBackupOperation();