/** * @return Cache processor. */ private GridCacheProcessor cacheProcessor() { return cctx.cache(); }
/** * @param rebalanceEnabled rebalance enabled flag. */ public void rebalanceEnabled(boolean rebalanceEnabled) { this.rebalanceEnabled = rebalanceEnabled; if (rebalanceEnabled) cache().enableRebalance(); }
/** * @param msg Message. * @return Cache or group descriptor. */ private Object descriptorForMessage(GridCacheMessage msg) { if (msg instanceof GridCacheIdMessage) return cctx.cache().cacheDescriptor(((GridCacheIdMessage)msg).cacheId()); else if (msg instanceof GridCacheGroupIdMessage) return cctx.cache().cacheGroupDescriptors().get(((GridCacheGroupIdMessage)msg).groupId()); return null; }
/** * @param f Consumer. * @return Accumulated result for all page stores. */ public long forAllPageStores(ToLongFunction<PageStore> f) { long res = 0; for (CacheGroupContext gctx : cctx.cache().cacheGroups()) res += forGroupPageStores(gctx, f); return res; }
/** * Checks WAL disabled for cache group. * * @param grpId Group id. * @return {@code True} if WAL disable for group. {@code False} If not. */ public boolean isDisabled(int grpId) { CacheGroupContext ctx = cctx.cache().cacheGroup(grpId); return ctx != null && !ctx.walEnabled(); }
/** * Collects non local cache groups. * * @return Collection of non local cache groups. */ private List<CacheGroupContext> nonLocalCacheGroups() { return cctx.cache().cacheGroups().stream() .filter(grp -> !grp.isLocal() && !cacheGroupStopping(grp.groupId())) .collect(Collectors.toList()); }
/** * Partition refresh callback. * For coordinator causes {@link GridDhtPartitionsFullMessage FullMessages} send, * for non coordinator - {@link GridDhtPartitionsSingleMessage SingleMessages} send */ public void refreshPartitions() { refreshPartitions(cctx.cache().cacheGroups()); }
/** {@inheritDoc} */ @Override public void clear() { try { cache.context().shared().cache().clearStatistics(Collections.singleton(cache.name())); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } }
/** {@inheritDoc} */ @Override public void enableStatistics() { try { cache.context().shared().cache().enableStatistics(Collections.singleton(cache.name()), true); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } }
/** {@inheritDoc} */ @Override public void disableStatistics() { try { cache.context().shared().cache().enableStatistics(Collections.singleton(cache.name()), false); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } } }
/** * Returns cache object context if created or creates new and caches it until cache started. * * @param cacheId Cache id. */ @Nullable public CacheObjectContext cacheObjectContext(int cacheId) throws IgniteCheckedException { GridCacheContext<K, V> ctx = ctxMap.get(cacheId); if (ctx != null) return ctx.cacheObjectContext(); DynamicCacheDescriptor desc = cache().cacheDescriptor(cacheId); return desc != null ? desc.cacheObjectContext(kernalContext().cacheObjects()) : null; }
/** {@inheritDoc} */ @Override public void disableStatistics() { try { cache.context().shared().cache().enableStatistics(Collections.singleton(cache.name()), false); } catch (IgniteCheckedException e) { throw new RuntimeException(e.getMessage()); } } }
/** {@inheritDoc} */ @SuppressWarnings("ForLoopReplaceableByForEach") @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); CacheGroupContext grp = ctx.cache().cacheGroup(grpId); if (grp == null) return; for (CacheEntryInfoCollection col : infos().values()) { List<GridCacheEntryInfo> entries = col.infos(); for (int i = 0; i < entries.size(); i++) entries.get(i).unmarshal(grp.cacheObjectContext(), ldr); } }
/** {@inheritDoc} */ @Override public void enableStatistics() { try { cache.context().shared().cache().enableStatistics(Collections.singleton(cache.name()), true); } catch (IgniteCheckedException e) { throw new RuntimeException(e.getMessage()); } }
/** * @param evt Event. * @param cache Discovery data cache. */ private void processEventInactive(DiscoveryEvent evt, DiscoCache cache) { // Clear local join caches context. cctx.cache().localJoinCachesContext(); if (log.isDebugEnabled()) log.debug("Ignore event, cluster is inactive: " + evt); }
@Override public Long apply() { long freeSpace = 0L; for (CacheGroupContext grpCtx : cctx.cache().cacheGroups()) { if (!grpCtx.dataRegion().config().getName().equals(dataRegName)) continue; assert grpCtx.offheap() instanceof GridCacheOffheapManager; freeSpace += ((GridCacheOffheapManager)grpCtx.offheap()).freeSpace(); } return freeSpace; } };
/** * */ private void onLeft() { for (CacheGroupContext grp : cctx.cache().cacheGroups()) { if (grp.isLocal()) continue; grp.preloader().unwindUndeploys(); cctx.exchange().exchangerUpdateHeartbeat(); } }
@Override public void applyx(IgniteInternalFuture future) { for (Integer grpId0 : session0.disabledGrps) { CacheGroupContext grp = cctx.cache().cacheGroup(grpId0); if (grp != null) grp.topology().ownMoving(topVer); else if (log.isDebugEnabled()) log.debug("Cache group was destroyed before checkpoint finished, [grpId=" + grpId0 + ']'); } if (log.isDebugEnabled()) log.debug("Refresh partitions due to rebalance finished"); cctx.exchange().refreshPartitions(); } });
/** {@inheritDoc} */ @Override protected void start0() throws IgniteCheckedException { if (srv) cctx.kernalContext().io().addMessageListener(TOPIC_WAL, ioLsnr); walDisableContext = new WALDisableContext( cctx.cache().context().database(), cctx.pageStore(), log ); cctx.kernalContext().internalSubscriptionProcessor().registerMetastorageListener(walDisableContext); }
/** {@inheritDoc} */ @Override public GridDhtTopologyFuture topologyReadLock(GridCacheSharedContext cctx, GridFutureAdapter<?> fut) { if (cacheCtx == null || cacheCtx.isLocal()) return cctx.exchange().lastTopologyFuture(); cacheCtx.topology().readLock(); if (cacheCtx.topology().stopping()) { fut.onDone( cctx.cache().isCacheRestarting(cacheCtx.name())? new IgniteCacheRestartingException(cacheCtx.name()): new CacheStoppedException(cacheCtx.name())); return null; } return cacheCtx.topology().topologyVersionFuture(); }