use of org.infinispan.commands.remote.recovery.GetInDoubtTxInfoCommand in project infinispan by infinispan.
the class RecoveryManagerImpl method getInDoubtTransactionInfoFromCluster.
@Override
public Set<InDoubtTxInfo> getInDoubtTransactionInfoFromCluster() {
Map<XidImpl, InDoubtTxInfo> result = new HashMap<>();
if (rpcManager != null) {
GetInDoubtTxInfoCommand inDoubtTxInfoCommand = commandFactory.buildGetInDoubtTxInfoCommand();
CompletionStage<Map<Address, Response>> completionStage = rpcManager.invokeCommandOnAll(inDoubtTxInfoCommand, MapResponseCollector.ignoreLeavers(), rpcManager.getSyncRpcOptions());
Map<Address, Response> addressResponseMap = rpcManager.blocking(completionStage);
for (Map.Entry<Address, Response> re : addressResponseMap.entrySet()) {
Response r = re.getValue();
if (!isSuccessful(r)) {
throw new CacheException("Could not fetch in doubt transactions: " + r);
}
// noinspection unchecked
Set<InDoubtTxInfo> infoInDoubtSet = ((SuccessfulResponse<Set<InDoubtTxInfo>>) r).getResponseValue();
for (InDoubtTxInfo infoInDoubt : infoInDoubtSet) {
InDoubtTxInfo inDoubtTxInfo = result.get(infoInDoubt.getXid());
if (inDoubtTxInfo == null) {
inDoubtTxInfo = infoInDoubt;
result.put(infoInDoubt.getXid(), inDoubtTxInfo);
} else {
inDoubtTxInfo.setStatus(infoInDoubt.getStatus());
}
inDoubtTxInfo.addOwner(re.getKey());
}
}
}
Set<InDoubtTxInfo> onThisNode = getInDoubtTransactionInfo();
Iterator<InDoubtTxInfo> iterator = onThisNode.iterator();
while (iterator.hasNext()) {
InDoubtTxInfo info = iterator.next();
InDoubtTxInfo inDoubtTxInfo = result.get(info.getXid());
if (inDoubtTxInfo != null) {
inDoubtTxInfo.setLocal(true);
iterator.remove();
} else {
info.setLocal(true);
}
}
HashSet<InDoubtTxInfo> value = new HashSet<>(result.values());
value.addAll(onThisNode);
return value;
}
Aggregations