Search in sources :

Example 1 with IgniteTxMappings

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;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteTxEntry(org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry) GridDhtTxRemote(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxRemote) DiscoCache(org.apache.ignite.internal.managers.discovery.DiscoCache) GridDhtTxLocal(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxLocal) HashMap(java.util.HashMap) GridDistributedTxMapping(org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxMapping) ArrayList(java.util.ArrayList) GridNearTxLocal(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal) IgniteTxMappings(org.apache.ignite.internal.processors.cache.distributed.near.IgniteTxMappings) UUID(java.util.UUID)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 UUID (java.util.UUID)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 DiscoCache (org.apache.ignite.internal.managers.discovery.DiscoCache)1 GridDistributedTxMapping (org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxMapping)1 GridDhtTxLocal (org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxLocal)1 GridDhtTxRemote (org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxRemote)1 GridNearTxLocal (org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal)1 IgniteTxMappings (org.apache.ignite.internal.processors.cache.distributed.near.IgniteTxMappings)1 IgniteTxEntry (org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry)1