/** * @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(); }
if (!updateNearCache && cacheCtx.isNear() && txEntry.locallyMapped()) metrics = false;
/** * @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(); }
if (!updateNearCache && cacheCtx.isNear() && txEntry.locallyMapped()) metrics = false;