/** * @param key Key. * @param cacheName Cache name. * @return {@code True} if matches. */ private static boolean missedCacheTypeKeyMatches(long key, String cacheName) { int cacheId = CU.cacheId(cacheName); long cacheIdShifted = ((long)cacheId << 32); return (key & cacheIdShifted) == cacheIdShifted; }
/** * Create missed cache type key. * * @param cacheName Cache name. * @param typeId Type ID. * @return Key. */ private static long missedCacheTypeKey(String cacheName, int typeId) { return ((long)CU.cacheId(cacheName) << 32) | typeId; }
/** * Gets all nodes that have cache with given name. * * @param cacheName Cache name. * @return Collection of nodes. */ public List<ClusterNode> cacheNodes(@Nullable String cacheName) { return cacheNodes(CU.cacheId(cacheName)); }
/** * Gets cache nodes for cache with given name. * * @param cacheName Cache name. * @param topVer Topology version. * @return Collection of cache nodes. */ public List<ClusterNode> cacheNodes(@Nullable String cacheName, AffinityTopologyVersion topVer) { return resolveDiscoCache(CU.cacheId(cacheName), topVer).cacheNodes(cacheName); }
/** * @param topVer Topology version (maximum allowed node order). * @return Oldest alive server nodes with at least one cache configured. */ @Nullable public ClusterNode oldestAliveServerNode(AffinityTopologyVersion topVer) { return resolveDiscoCache(CU.cacheId(null), topVer).oldestAliveServerNode(); }
/** * @param topVer Topology version. * @return All baseline nodes for given topology version or {@code null} if baseline was not set for the * given topology version. */ @Nullable public List<? extends BaselineNode> baselineNodes(AffinityTopologyVersion topVer) { return resolveDiscoCache(CU.cacheId(null), topVer).baselineNodes(); }
/** * Gets cache remote nodes for cache with given name. * * @param topVer Topology version. * @return Collection of cache nodes. */ public Collection<ClusterNode> remoteAliveNodesWithCaches(AffinityTopologyVersion topVer) { return resolveDiscoCache(CU.cacheId(null), topVer).remoteAliveNodesWithCaches(); }
/** * Gets consistentId from history for given topology version. * * @param topVer Topology version. * @return Compacted consistent id map. */ public Map<Short, UUID> nodeIdMap(AffinityTopologyVersion topVer) { return resolveDiscoCache(CU.cacheId(null), topVer).nodeIdMap(); }
/** * Gets node from history for given topology version. * * @param topVer Topology version. * @param id Node ID. * @return Node. */ public ClusterNode node(AffinityTopologyVersion topVer, UUID id) { return resolveDiscoCache(CU.cacheId(null), topVer).node(id); }
/** * @param cacheId Cache ID. * @return Cache descriptor. */ @Nullable public DynamicCacheDescriptor cacheDescriptor(int cacheId) { for (DynamicCacheDescriptor cacheDesc : cacheDescriptors().values()) { CacheConfiguration ccfg = cacheDesc.cacheConfiguration(); assert ccfg != null : cacheDesc; if (CU.cacheId(ccfg.getName()) == cacheId) return cacheDesc; } return null; }
/** * Gets consistentId from history for given topology version. * * @param topVer Topology version. * @return Compacted consistent id. */ public Map<UUID, Short> consistentId(AffinityTopologyVersion topVer) { return resolveDiscoCache(CU.cacheId(null), topVer).consistentIdMap(); }
/** */ RebalanceBlockingSPI() { resumeRebalanceFutures.put(CU.cacheId(GROUP_1), new GridFutureAdapter()); resumeRebalanceFutures.put(CU.cacheId(GROUP_2), new GridFutureAdapter()); suspendRebalanceInMiddleLatch.put(CU.cacheId(GROUP_1), new CountDownLatch(3)); suspendRebalanceInMiddleLatch.put(CU.cacheId(GROUP_2), new CountDownLatch(3)); }
@Override public boolean apply(ClusterNode node, Message msg) { return msg instanceof GridDhtPartitionSupplyMessage && ((GridDhtPartitionSupplyMessage) msg).groupId() == CU.cacheId("c1"); } });
/** * @param spi SPI. * @param cacheName Cache name. */ private void blockSupplySend(TestRecordingCommunicationSpi spi, final String cacheName) { final int grpId = CU.cacheId(cacheName); spi.blockMessages(new IgniteBiPredicate<ClusterNode, Message>() { @Override public boolean apply(ClusterNode node, Message msg) { return msg.getClass().equals(GridDhtPartitionSupplyMessage.class) && ((GridDhtPartitionSupplyMessage)msg).groupId() == grpId; } }); }
/** {@inheritDoc} */ @Override public List<List<ClusterNode>> cacheAffinity(String cacheName) { if (cacheName == null) throw new NullPointerException("Null cache name."); DynamicCacheDescriptor cacheDesc = ctx.affinity().caches().get(CU.cacheId(cacheName)); if (cacheDesc == null) throw new IllegalArgumentException("Invalid cache name: " + cacheName); GridAffinityAssignmentCache aff = ctx.affinity().groupAffinity(cacheDesc.groupId()); assert aff != null : cacheName; return aff.readyAssignments(aff.lastVersion()); }
/** * Constructor of not started cache context. * * @param cacheDesc Cache descriptor. */ public GridCacheContextInfo(DynamicCacheDescriptor cacheDesc) { config = cacheDesc.cacheConfiguration(); dynamicDeploymentId = cacheDesc.deploymentId(); groupId = cacheDesc.groupId(); cacheId = CU.cacheId(config.getName()); clientCache = true; }
/** * @param gridNumber Grid number. * @param cacheName Cache name. * @return Partitions states for given cache name. */ private List<GridDhtPartitionState> getPartitionsStates(int gridNumber, String cacheName) { CacheGroupContext cgCtx = grid(gridNumber).context().cache().cacheGroup(CU.cacheId(cacheName)); GridDhtPartitionTopologyImpl top = (GridDhtPartitionTopologyImpl)cgCtx.topology(); return top.localPartitions().stream() .map(GridDhtLocalPartition::state) .collect(Collectors.toList()); }
/** * @throws Exception If fail. */ @Test public void testPageReplacement() throws Exception { final IgniteEx ig = startGrid(0); ig.active(true); final PageMemory memory = getMemory(ig); writeData(ig, memory, CU.cacheId(cacheName)); }
@Override public boolean apply() { try { GridCacheContext cctx = node.context().cache().context().cacheContext(CU.cacheId(DEFAULT_CACHE_NAME)); KeyCacheObject key = cctx.toCacheKeyObject(1); return cctx.offheap().read(cctx, key) == null; } catch (Exception e) { fail(); return false; } } }, 5000));