/** * Checks if cache context is closed. * * @param ctx Cache context to check. * @return {@code True} if cache context is closed. */ public boolean closed(GridCacheContext ctx) { return !ctxMap.containsKey(ctx.cacheId()); }
/** * @param cctx Cache context. * @param factory Entry factory. * @param initCap Initial capacity. */ public GridCacheLocalConcurrentMap(GridCacheContext cctx, GridCacheMapEntryFactory factory, int initCap) { super(factory); this.cacheId = cctx.cacheId(); this.entryMap = new CacheMapHolder(cctx, new ConcurrentHashMap<KeyCacheObject, GridCacheMapEntry>(initCap, 0.75f, Runtime.getRuntime().availableProcessors() * 2)); }
/** * @return IDs of caches in this group. */ public Set<Integer> cacheIds() { List<GridCacheContext> caches = this.caches; Set<Integer> ids = U.newHashSet(caches.size()); for (GridCacheContext cctx : caches) ids.add(cctx.cacheId()); return ids; }
/** * @param cctx Stopped cache context. */ public void stopCacheOnReconnect(GridCacheContext cctx) { cachesRegistry.unregisterCache(cctx.cacheId()); }
/** * @return Set of internal cached entry representations. */ public final Iterable<? extends GridCacheEntryEx> allEntries() { return map.entries(ctx.cacheId()); }
/** {@inheritDoc} */ @Override public void decrementPublicSize(CacheMapHolder hld, GridCacheEntryEx e) { assert cacheId == e.context().cacheId(); entryMap.size.decrementAndGet(); } }
/** * @param cctx Cache context. * @param threadId Id of thread for transaction. * @return Transaction for thread with given ID. */ private <T> T tx(GridCacheContext cctx, long threadId) { if (cctx == null || !cctx.systemTx()) return (T)threadMap.get(threadId); TxThreadKey key = new TxThreadKey(threadId, cctx.cacheId()); return (T)sysThreadMap.get(key); }
/** {@inheritDoc} */ @Override protected IgniteCacheExpiryPolicy accessPolicy(GridCacheContext cacheCtx, Collection<KeyCacheObject> keys) { assert optimistic(); if (accessMap != null) { for (Map.Entry<IgniteTxKey, IgniteCacheExpiryPolicy> e : accessMap.entrySet()) { if (e.getKey().cacheId() == cacheCtx.cacheId() && keys.contains(e.getKey().key())) return e.getValue(); } } return null; }
/** * @param segIdx Segment index. * @return RootPage for meta page. * @throws IgniteCheckedException If failed. */ private RootPage getMetaPage(int segIdx) throws IgniteCheckedException { return cctx.offheap().rootPageForIndex(cctx.cacheId(), treeName, segIdx); }
/** * @param filter Filters to evaluate. * @return Entry set. */ public Set<Cache.Entry<K, V>> entrySet(@Nullable CacheEntryPredicate... filter) { boolean keepBinary = ctx.keepBinary(); return new EntrySet(map.entrySet(ctx.cacheId(), filter), keepBinary); }
/** {@inheritDoc} */ @Override public void start() throws IgniteCheckedException { super.start(); ctx.io().addCacheHandler(ctx.cacheId(), GridNearGetResponse.class, new CI2<UUID, GridNearGetResponse>() { @Override public void apply(UUID nodeId, GridNearGetResponse res) { processGetResponse(nodeId, res); } }); }
/** {@inheritDoc} */ @Override public GridCursor<CacheDataRow> mvccAllVersionsCursor(GridCacheContext cctx, KeyCacheObject key, Object x) throws IgniteCheckedException { int cacheId = cctx.cacheId(); GridCursor<CacheDataRow> cursor = dataTree.find( new MvccMaxSearchRow(cacheId, key), new MvccMinSearchRow(cacheId, key), x); return cursor; }
/** {@inheritDoc} */ @Override public void addActiveCache(GridCacheContext cctx, boolean recovery, IgniteTxAdapter tx) throws IgniteCheckedException { assert !tx.local(); int cacheId = cctx.cacheId(); // Check if we can enlist new cache to transaction. if (!activeCacheIds.contains(cacheId)) activeCacheIds.add(cacheId); }
/** {@inheritDoc} */ @Override public void invoke(GridCacheContext cctx, KeyCacheObject key, OffheapInvokeClosure c) throws IgniteCheckedException { int cacheId = grp.sharedGroup() ? cctx.cacheId() : CU.UNDEFINED_CACHE_ID; invoke0(cctx, new SearchRow(cacheId, key), c); }
/** {@inheritDoc} */ @Override public void start() throws IgniteCheckedException { ctx.io().addCacheHandler(ctx.cacheId(), GridCacheTtlUpdateRequest.class, new CI2<UUID, GridCacheTtlUpdateRequest>() { @Override public void apply(UUID nodeId, GridCacheTtlUpdateRequest req) { processTtlUpdateRequest(req); } }); ctx.gridEvents().addLocalEventListener(discoLsnr, EVT_NODE_LEFT, EVT_NODE_FAILED); }
/** {@inheritDoc} */ @Override public long localSizeLong(CachePeekMode[] peekModes) throws IgniteCheckedException { PeekModes modes = parsePeekModes(peekModes, true); modes.primary = true; modes.backup = true; if (modes.offheap) return ctx.offheap().cacheEntriesCount(ctx.cacheId()); else if (modes.heap) return size(); else return 0; }
/** {@inheritDoc} */ @Override public void onActivate(GridKernalContext kctx) throws IgniteCheckedException { this.ctx = kctx.cache().<GridCacheInternalKey, V>context().cacheContext(ctx.cacheId()); this.cacheView = ctx.cache(); }
/** {@inheritDoc} */ @Override public long sizeLong() { long sum = 0; for (GridDhtLocalPartition p : topology().currentLocalPartitions()) sum += p.dataStore().cacheSize(ctx.cacheId()); return sum; }
/** {@inheritDoc} */ @Override public long primarySizeLong() { long sum = 0; AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion(); for (GridDhtLocalPartition p : topology().currentLocalPartitions()) { if (p.primary(topVer)) sum += p.dataStore().cacheSize(ctx.cacheId()); } return sum; }
/** {@inheritDoc} */ @Override public void onDeferredDelete(GridCacheEntryEx entry, GridCacheVersion ver) { assert entry.isDht(); GridDhtLocalPartition part = topology().localPartition(entry.partition(), AffinityTopologyVersion.NONE, false); if (part != null) part.onDeferredDelete(entry.context().cacheId(), entry.key(), ver); }