void sendResponseIfComplete() { if (size == counter.incrementAndGet()) { sendResponse(null); } } };
void sendResponseIfComplete() { if (size == counter.incrementAndGet()) { sendResponse(null); } } };
@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 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); } }