/** * @return true if current PartitionLossPolicy corresponds to *_SAFE values. */ private boolean isSafeLossPolicy() { PartitionLossPolicy lossPlc = cctx.cache().configuration().getPartitionLossPolicy(); return lossPlc == PartitionLossPolicy.READ_ONLY_SAFE || lossPlc == PartitionLossPolicy.READ_WRITE_SAFE; }
/** * @param cache Cache. * @return {@code True} if near cache is enabled. */ private static <K, V> boolean nearEnabled(GridCacheAdapter<K, V> cache) { return isNearEnabled(cache.configuration()); }
/** * @param cacheName Cache name. * @return If replicated cache with given name is locally available. */ private boolean replicatedCacheAvailable(String cacheName) { GridCacheAdapter<Object, Object> cache = ctx.cache().internalCache(cacheName); return cache != null && cache.configuration().getCacheMode() == REPLICATED; }
/** * @param cache Cache. */ public void cache(GridCacheAdapter<K, V> cache) { this.cache = cache; deferredDel = cache.isDht() || cache.isDhtAtomic() || cache.isColocated() || (cache.isNear() && cache.configuration().getAtomicityMode() == ATOMIC); }
/** * @param queue Ignite queue. * @return Cache configuration. */ protected CacheConfiguration getQueueCache(IgniteQueue queue) { GridCacheQueueAdapter delegate = GridTestUtils.getFieldValue(queue, "delegate"); GridCacheAdapter cache = GridTestUtils.getFieldValue(delegate, GridCacheQueueAdapter.class, "cache"); return cache.configuration(); }
/** {@inheritDoc} */ @Nullable @Override public IndexingQueryCacheFilter forCache(String cacheName) { final GridCacheAdapter<Object, Object> cache = ctx.cache().internalCache(cacheName); // REPLICATED -> nothing to filter (explicit partitions are not supported). if (cache.context().isReplicated()) return null; // No backups and explicit partitions -> nothing to filter. if (cache.configuration().getBackups() == 0 && parts == null) return null; return new IndexingQueryCacheFilter(cache.context().affinity(), parts, topVer, ctx.discovery().localNode()); } }
/** * @return Affinity. */ private AffinityFunction affinity() { return ((IgniteKernal)grid(0)).internalCache(DEFAULT_CACHE_NAME).configuration().getAffinity(); }
/** * @return Affinity mapper. */ private AffinityKeyMapper affinityMapper() { return ((IgniteKernal)grid(0)).internalCache(DEFAULT_CACHE_NAME).configuration().getAffinityMapper(); }
continue; CacheConfiguration ccfg = e.getValue().configuration();
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override protected void onKernalStart0() throws IgniteCheckedException { dataCachePrj = igfsCtx.kernalContext().cache().getOrStartCache(dataCacheName); assert dataCachePrj != null; dataCache = (IgniteInternalCache)dataCachePrj; AffinityKeyMapper mapper = igfsCtx.kernalContext().cache() .internalCache(dataCacheName).configuration().getAffinityMapper(); grpSize = mapper instanceof IgfsGroupDataBlocksKeyMapper ? ((IgfsGroupDataBlocksKeyMapper)mapper).getGroupSize() : 1; grpBlockSize = igfsCtx.configuration().getBlockSize() * (long)grpSize; assert grpBlockSize != 0; igfsCtx.kernalContext().cache().internalCache(dataCacheName).preloader() .startFuture().listen(new CI1<IgniteInternalFuture<Object>>() { @Override public void apply(IgniteInternalFuture<Object> f) { dataCacheStartLatch.countDown(); } }); new Thread(delWorker).start(); }
/** * Create data transfer object for given cache. * * @param ca Internal cache. * @param collectMetrics Collect cache metrics flag. * @throws IgniteCheckedException If failed to create data transfer object. */ public VisorCache(IgniteEx ignite, GridCacheAdapter ca, boolean collectMetrics) throws IgniteCheckedException { assert ca != null; GridCacheContext cctx = ca.context(); CacheConfiguration cfg = ca.configuration(); name = ca.name(); dynamicDeploymentId = cctx.dynamicDeploymentId(); mode = cfg.getCacheMode(); primarySize = ca.localSizeLong(PEEK_ONHEAP_PRIMARY); backupSize = ca.localSizeLong(PEEK_ONHEAP_BACKUP); nearSize = ca.nearSize(); size = primarySize + backupSize + nearSize; partitions = ca.affinity().partitions(); near = cctx.isNear(); if (collectMetrics) metrics = new VisorCacheMetrics(ignite, name); sys = ignite.context().cache().systemCache(name); statisticsEnabled = ca.clusterMetrics().isStatisticsEnabled(); }
if (addToRes && (all || cacheGrps.contains(ca.configuration().getGroupName()))) resCaches.add(new VisorCache(ignite, ca, arg.isCollectCacheMetrics()));
U.stopLifecycleAware(log, lifecycleAwares(ctx.group(), cache.configuration(), ctx.store().configuredStore()));
/** * @param cache Cache. * @throws IgniteCheckedException If failed. */ private void onKernalStart(GridCacheAdapter<?, ?> cache) throws IgniteCheckedException { GridCacheContext<?, ?> ctx = cache.context(); // Start DHT cache as well. if (isNearEnabled(ctx)) { GridDhtCacheAdapter dht = ctx.near().dht(); GridCacheContext<?, ?> dhtCtx = dht.context(); for (GridCacheManager mgr : dhtManagers(dhtCtx)) mgr.onKernalStart(); dht.onKernalStart(); if (log.isDebugEnabled()) log.debug("Executed onKernalStart() callback for DHT cache: " + dht.name()); } for (GridCacheManager mgr : F.view(ctx.managers(), F0.notContains(dhtExcludes(ctx)))) mgr.onKernalStart(); cache.onKernalStart(); if (ctx.events().isRecordable(EventType.EVT_CACHE_STARTED)) ctx.events().addEvent(EventType.EVT_CACHE_STARTED); if (log.isDebugEnabled()) log.debug("Executed onKernalStart() callback for cache [name=" + cache.name() + ", mode=" + cache.configuration().getCacheMode() + ']'); }
return parts; CacheConfiguration cfg = ca.configuration();
/** * @param cacheName Cache name. * @return If replicated cache with given name is locally available. */ private boolean replicatedCacheAvailable(String cacheName) { GridCacheAdapter<Object, Object> cache = ctx.cache().internalCache(cacheName); return cache != null && cache.configuration().getCacheMode() == REPLICATED; }
/** * @param cache Cache. */ public void cache(GridCacheAdapter<K, V> cache) { this.cache = cache; deferredDel = cache.isDht() || cache.isDhtAtomic() || cache.isColocated() || (cache.isNear() && cache.configuration().getAtomicityMode() == ATOMIC); }
/** {@inheritDoc} */ @Nullable @Override public IndexingQueryCacheFilter forCache(String cacheName) { final GridCacheAdapter<Object, Object> cache = ctx.cache().internalCache(cacheName); // REPLICATED -> nothing to filter (explicit partitions are not supported). if (cache.context().isReplicated()) return null; // No backups and explicit partitions -> nothing to filter. if (cache.configuration().getBackups() == 0 && parts == null) return null; return new IndexingQueryCacheFilter(cache.context().affinity(), parts, topVer, ctx.discovery().localNode()); } }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override protected void onKernalStart0() throws IgniteCheckedException { dataCachePrj = igfsCtx.kernalContext().cache().getOrStartCache(dataCacheName); assert dataCachePrj != null; dataCache = (IgniteInternalCache)dataCachePrj; AffinityKeyMapper mapper = igfsCtx.kernalContext().cache() .internalCache(dataCacheName).configuration().getAffinityMapper(); grpSize = mapper instanceof IgfsGroupDataBlocksKeyMapper ? ((IgfsGroupDataBlocksKeyMapper)mapper).getGroupSize() : 1; grpBlockSize = igfsCtx.configuration().getBlockSize() * (long)grpSize; assert grpBlockSize != 0; igfsCtx.kernalContext().cache().internalCache(dataCacheName).preloader() .startFuture().listen(new CI1<IgniteInternalFuture<Object>>() { @Override public void apply(IgniteInternalFuture<Object> f) { dataCacheStartLatch.countDown(); } }); new Thread(delWorker).start(); }
/** * Create data transfer object for given cache. * * @param ca Internal cache. * @param collectMetrics Collect cache metrics flag. * @throws IgniteCheckedException If failed to create data transfer object. */ public VisorCache(IgniteEx ignite, GridCacheAdapter ca, boolean collectMetrics) throws IgniteCheckedException { assert ca != null; GridCacheContext cctx = ca.context(); CacheConfiguration cfg = ca.configuration(); name = ca.name(); dynamicDeploymentId = cctx.dynamicDeploymentId(); mode = cfg.getCacheMode(); primarySize = ca.localSizeLong(PEEK_ONHEAP_PRIMARY); backupSize = ca.localSizeLong(PEEK_ONHEAP_BACKUP); nearSize = ca.nearSize(); size = primarySize + backupSize + nearSize; partitions = ca.affinity().partitions(); near = cctx.isNear(); if (collectMetrics) metrics = new VisorCacheMetrics(ignite, name); sys = ignite.context().cache().systemCache(name); }