use of org.apache.ignite.internal.processors.cache.distributed.near.IgniteTxMappings in project ignite by apache.
the class VisorTxTask method createVerboseInfo.
/**
* Constructs detailed transaction info for verbose mode.
*
* @param ignite Ignite.
* @param locTx Local tx.
*/
private static TxVerboseInfo createVerboseInfo(IgniteEx ignite, IgniteInternalTx locTx) {
TxVerboseInfo res = new TxVerboseInfo();
res.nearXidVersion(locTx.nearXidVersion());
Map<Integer, String> usedCaches = new HashMap<>();
Map<Integer, String> usedCacheGroups = new HashMap<>();
ClusterNode locNode = ignite.context().discovery().localNode();
res.localNodeId(locNode.id());
res.localNodeConsistentId(locNode.consistentId());
if (locTx instanceof GridNearTxLocal) {
IgniteTxMappings mappings = ((GridNearTxLocal) locTx).mappings();
List<IgniteTxEntry> nearOnlyEntries = new ArrayList<>();
List<IgniteTxEntry> locEntries = new ArrayList<>();
for (GridDistributedTxMapping mapping : mappings.mappings()) {
if (F.eqNodes(mapping.primary(), locNode))
locEntries.addAll(mapping.entries());
else
nearOnlyEntries.addAll(mapping.entries());
}
res.nearNodeId(locNode.id());
res.nearNodeConsistentId(locNode.consistentId());
res.txMappingType(TxMappingType.NEAR);
List<TxVerboseKey> nearOnlyTxKeys = fetchTxEntriesAndFillUsedCaches(ignite, locTx, usedCaches, usedCacheGroups, nearOnlyEntries, true);
List<TxVerboseKey> locTxKeys = fetchTxEntriesAndFillUsedCaches(ignite, locTx, usedCaches, usedCacheGroups, locEntries, false);
res.nearOnlyTxKeys(nearOnlyTxKeys);
res.localTxKeys(locTxKeys);
} else if (locTx instanceof GridDhtTxLocal) {
UUID nearNodeId = locTx.masterNodeIds().iterator().next();
DiscoCache discoCache = ignite.context().discovery().discoCache(locTx.topologyVersion());
if (discoCache == null)
discoCache = ignite.context().discovery().discoCache();
ClusterNode nearNode = discoCache.node(nearNodeId);
res.nearNodeId(nearNodeId);
res.nearNodeConsistentId(nearNode.consistentId());
res.txMappingType(TxMappingType.DHT);
res.localTxKeys(fetchTxEntriesAndFillUsedCaches(ignite, locTx, usedCaches, usedCacheGroups, locTx.allEntries(), false));
} else if (locTx instanceof GridDhtTxRemote) {
Iterator<UUID> masterNodesIter = locTx.masterNodeIds().iterator();
UUID nearNodeId = masterNodesIter.next();
UUID dhtNodeId = masterNodesIter.next();
DiscoCache discoCache = ignite.context().discovery().discoCache(locTx.topologyVersion());
if (discoCache == null)
discoCache = ignite.context().discovery().discoCache();
ClusterNode nearNode = discoCache.node(nearNodeId);
ClusterNode dhtNode = discoCache.node(dhtNodeId);
res.nearNodeId(nearNodeId);
res.nearNodeConsistentId(nearNode.consistentId());
res.txMappingType(TxMappingType.REMOTE);
res.dhtNodeId(dhtNodeId);
res.dhtNodeConsistentId(dhtNode.consistentId());
res.localTxKeys(fetchTxEntriesAndFillUsedCaches(ignite, locTx, usedCaches, usedCacheGroups, locTx.allEntries(), false));
}
res.usedCaches(usedCaches);
res.usedCacheGroups(usedCacheGroups);
return res;
}
Aggregations