/** * @param e Transaction entry. * @param primaryOnly Flag to include backups into check or not. * @return {@code True} if entry is locally mapped as a primary or back up node. */ protected boolean isNearLocallyMapped(IgniteTxEntry e, boolean primaryOnly) { GridCacheContext cacheCtx = e.context(); if (!cacheCtx.isNear()) return false; // Try to take either entry-recorded primary node ID, // or transaction node ID from near-local transactions. UUID nodeId = e.nodeId() == null ? local() ? this.nodeId : null : e.nodeId(); if (nodeId != null && nodeId.equals(cctx.localNodeId())) return true; GridCacheEntryEx cached = e.cached(); int part = cached != null ? cached.partition() : cacheCtx.affinity().partition(e.key()); List<ClusterNode> affNodes = cacheCtx.affinity().nodesByPartition(part, topologyVersion()); e.locallyMapped(F.contains(affNodes, cctx.localNode())); if (primaryOnly) { ClusterNode primary = F.first(affNodes); if (primary == null && !cacheCtx.affinityNode()) return false; assert primary != null : "Primary node is null for affinity nodes: " + affNodes; return primary.isLocal(); } else return e.locallyMapped(); }
/** * Adds key mapping to dht mapping. * * @param key Key to add. * @param node Node this key mapped to. */ public void addKeyMapping(IgniteTxKey key, ClusterNode node) { GridDistributedTxMapping m = mappings.get(node.id()); if (m == null) mappings.put(m = new GridDistributedTxMapping(node)); IgniteTxEntry txEntry = entry(key); assert txEntry != null; txEntry.nodeId(node.id()); m.add(txEntry); if (log.isDebugEnabled()) log.debug("Added mappings to transaction [locId=" + cctx.localNodeId() + ", key=" + key + ", node=" + node + ", tx=" + this + ']'); }
mappings.put(primary.id(), nodeMapping = new GridDistributedTxMapping(primary)); txEntry.nodeId(primary.id());
entry.nodeId(primary.id());
entry.nodeId(primary.id());
/** * @param e Transaction entry. * @param primaryOnly Flag to include backups into check or not. * @return {@code True} if entry is locally mapped as a primary or back up node. */ protected boolean isNearLocallyMapped(IgniteTxEntry e, boolean primaryOnly) { GridCacheContext cacheCtx = e.context(); if (!cacheCtx.isNear()) return false; // Try to take either entry-recorded primary node ID, // or transaction node ID from near-local transactions. UUID nodeId = e.nodeId() == null ? local() ? this.nodeId : null : e.nodeId(); if (nodeId != null && nodeId.equals(cctx.localNodeId())) return true; GridCacheEntryEx cached = e.cached(); int part = cached != null ? cached.partition() : cacheCtx.affinity().partition(e.key()); List<ClusterNode> affNodes = cacheCtx.affinity().nodesByPartition(part, topologyVersion()); e.locallyMapped(F.contains(affNodes, cctx.localNode())); if (primaryOnly) { ClusterNode primary = F.first(affNodes); if (primary == null && !cacheCtx.affinityNode()) return false; assert primary != null : "Primary node is null for affinity nodes: " + affNodes; return primary.isLocal(); } else return e.locallyMapped(); }
/** * Adds key mapping to dht mapping. * * @param key Key to add. * @param node Node this key mapped to. */ public void addKeyMapping(IgniteTxKey key, ClusterNode node) { GridDistributedTxMapping m = mappings.get(node.id()); if (m == null) mappings.put(m = new GridDistributedTxMapping(node)); IgniteTxEntry txEntry = entry(key); assert txEntry != null; txEntry.nodeId(node.id()); m.add(txEntry); if (log.isDebugEnabled()) log.debug("Added mappings to transaction [locId=" + cctx.localNodeId() + ", key=" + key + ", node=" + node + ", tx=" + this + ']'); }
mappings.put(primary.id(), nodeMapping = new GridDistributedTxMapping(primary)); txEntry.nodeId(primary.id());
entry.nodeId(primary.id());
entry.nodeId(primary.id());