use of org.infinispan.commons.tx.XidImpl in project infinispan by infinispan.
the class RecoveryManagerImpl method removeRecoveryInformation.
@Override
public RecoveryAwareTransaction removeRecoveryInformation(Long internalId) {
XidImpl remoteTransactionXid = recoveryAwareTxTable().getRemoteTransactionXid(internalId);
if (remoteTransactionXid != null) {
return removeRecoveryInformation(remoteTransactionXid);
} else {
for (RecoveryAwareRemoteTransaction raRemoteTx : inDoubtTransactions.values()) {
GlobalTransaction globalTransaction = raRemoteTx.getGlobalTransaction();
if (internalId.equals(globalTransaction.getInternalId())) {
XidImpl xid = globalTransaction.getXid();
log.tracef("Found transaction xid %s that maps internal id %s", xid, internalId);
removeRecoveryInformation(xid);
return raRemoteTx;
}
}
}
log.tracef("Could not find tx to map to internal id %s", internalId);
return null;
}
use of org.infinispan.commons.tx.XidImpl in project infinispan by infinispan.
the class RecoveryManagerImpl method isTransactionPrepared.
@Override
public boolean isTransactionPrepared(GlobalTransaction globalTx) {
XidImpl xid = globalTx.getXid();
RecoveryAwareRemoteTransaction remoteTransaction = (RecoveryAwareRemoteTransaction) recoveryAwareTxTable().getRemoteTransaction(globalTx);
boolean remotePrepared = remoteTransaction != null && remoteTransaction.isPrepared();
boolean result = // if it is in doubt must be prepared
inDoubtTransactions.get(new RecoveryInfoKey(xid, cacheName)) != null || recoveryAwareTxTable().getLocalPreparedXids().contains(xid) || remotePrepared;
if (log.isTraceEnabled())
log.tracef("Is tx %s prepared? %s", xid, result);
return result;
}
use of org.infinispan.commons.tx.XidImpl 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;
}
use of org.infinispan.commons.tx.XidImpl in project infinispan by infinispan.
the class RecoveryAdminOperations method lookupRecoveryInfo.
private InDoubtTxInfo lookupRecoveryInfo(int formatId, byte[] globalTxId, byte[] branchQualifier) {
Set<InDoubtTxInfo> info = getRecoveryInfoFromCluster();
XidImpl xid = XidImpl.create(formatId, globalTxId, branchQualifier);
for (InDoubtTxInfo i : info) {
if (i.getXid().equals(xid)) {
log.tracef("Found matching recovery info: %s", i);
return i;
}
}
return null;
}
use of org.infinispan.commons.tx.XidImpl in project infinispan by infinispan.
the class ForgetTest method forgetWithXid.
private void forgetWithXid(int nodeIndex) {
XidImpl xid = tx.getXid();
recoveryOps(nodeIndex).forget(xid.getFormatId(), xid.getGlobalTransactionId(), xid.getBranchQualifier());
// make sure tx has been removed
assertEquals(tt(1).getRemoteTxCount(), 0);
}
Aggregations