@Override public Xid[] recover(int flag) throws XAException { NodeEngine nodeEngine = getNodeEngine(); XAService xaService = getService(); OperationService operationService = nodeEngine.getOperationService(); ClusterService clusterService = nodeEngine.getClusterService(); Collection<Member> memberList = clusterService.getMembers(); List<InternalCompletableFuture<SerializableList>> futureList = new ArrayList<InternalCompletableFuture<SerializableList>>(); for (Member member : memberList) { if (member.localMember()) { continue; } CollectRemoteTransactionsOperation op = new CollectRemoteTransactionsOperation(); Address address = member.getAddress(); InternalCompletableFuture<SerializableList> future = operationService.invokeOnTarget(SERVICE_NAME, op, address); futureList.add(future); } HashSet<SerializableXID> xids = new HashSet<SerializableXID>(); xids.addAll(xaService.getPreparedXids()); for (InternalCompletableFuture<SerializableList> future : futureList) { SerializableList xidSet = future.getSafely(); for (Data xidData : xidSet) { SerializableXID xid = nodeEngine.toObject(xidData); xids.add(xid); } } return xids.toArray(new SerializableXID[xids.size()]); }
@Override protected ClientMessage call() throws Exception { ClientEndpoint endpoint = getEndpoint(); XAService xaService = getService(getServiceName()); TransactionContext context = xaService.newXATransactionContext(parameters.xid, (int) parameters.timeout); TransactionAccessor.getTransaction(context).begin(); endpoint.setTransactionContext(context); return TransactionCreateResultParameters.encode(context.getTxnId()); }
private TransactionContext createTransactionContext(Xid xid) { XAService xaService = getService(); TransactionContext context = xaService.newXATransactionContext(xid, timeoutInSeconds.get()); getTransaction(context).begin(); return context; }