/** * Gets default partitioned cache mode. * * @param cfg Configuration. * @return Partitioned cache mode. */ public static GridCacheDistributionMode distributionMode(GridCacheConfiguration cfg) { return cfg.getDistributionMode() != null ? cfg.getDistributionMode() : GridCacheDistributionMode.PARTITIONED_ONLY; }
/** * Checks if near cache is enabled for cache configuration. * * @param cfg Cache configuration to check. * @return {@code True} if near cache is enabled, {@code false} otherwise. */ @SuppressWarnings("SimplifiableIfStatement") public static boolean isNearEnabled(GridCacheConfiguration cfg) { if (cfg.getCacheMode() == LOCAL) return false; return cfg.getDistributionMode() == NEAR_PARTITIONED || cfg.getDistributionMode() == GridCacheDistributionMode.NEAR_ONLY; }
/** {@inheritDoc} */ @Override public List<GridCacheClearAllRunnable<K, V>> splitClearAll() { GridCacheDistributionMode mode = configuration().getDistributionMode(); return (mode == PARTITIONED_ONLY || mode == NEAR_PARTITIONED) ? super.splitClearAll() : Collections.<GridCacheClearAllRunnable<K, V>>emptyList(); }
/** * Checks if node is affinity node for given cache configuration. * * @param cfg Configuration to check. * @return {@code True} if local node is affinity node (i.e. will store partitions). */ public static boolean isAffinityNode(GridCacheConfiguration cfg) { if (cfg.getCacheMode() == LOCAL) return true; GridCacheDistributionMode partTax = cfg.getDistributionMode(); if (partTax == null) partTax = distributionMode(cfg); return partTax == GridCacheDistributionMode.PARTITIONED_ONLY || partTax == GridCacheDistributionMode.NEAR_PARTITIONED; }
/** {@inheritDoc} */ @Override public List<GridCacheClearAllRunnable<K, V>> splitClearAll() { switch (configuration().getDistributionMode()) { case NEAR_PARTITIONED: GridCacheVersion obsoleteVer = ctx.versions().next(); List<GridCacheClearAllRunnable<K, V>> dhtJobs = dht().splitClearAll(); List<GridCacheClearAllRunnable<K, V>> res = new ArrayList<>(dhtJobs.size()); for (GridCacheClearAllRunnable<K, V> dhtJob : dhtJobs) res.add(new GridNearCacheClearAllRunnable<>(this, obsoleteVer, dhtJob)); return res; case NEAR_ONLY: return super.splitClearAll(); default: assert false : "Invalid partition distribution mode."; return null; } }
/** * @return Nodes to execute on. */ private Collection<GridNode> nodes() { GridCacheMode cacheMode = cctx.config().getCacheMode(); switch (cacheMode) { case LOCAL: if (prj != null) U.warn(log, "Ignoring query projection because it's executed over LOCAL cache " + "(only local node will be queried): " + this); return Collections.singletonList(cctx.localNode()); case REPLICATED: if (prj != null) return nodes(cctx, prj); GridCacheDistributionMode mode = cctx.config().getDistributionMode(); return mode == PARTITIONED_ONLY || mode == NEAR_PARTITIONED ? Collections.singletonList(cctx.localNode()) : Collections.singletonList(F.rand(nodes(cctx, null))); case PARTITIONED: return nodes(cctx, prj); default: throw new IllegalStateException("Unknown cache distribution mode: " + cacheMode); } }
GridCacheConfiguration ccfgCp = new GridCacheConfiguration(ccfg); if (ccfgCp.getDistributionMode() == GridCacheDistributionMode.CLIENT_ONLY) ccfgCp.setDistributionMode(GridCacheDistributionMode.PARTITIONED_ONLY); else if (ccfgCp.getDistributionMode() == GridCacheDistributionMode.NEAR_ONLY) ccfgCp.setDistributionMode(GridCacheDistributionMode.NEAR_PARTITIONED);
/** * Checks if cache configurations are alike for warmup. * * @param ccfg0 First configuration. * @param ccfg1 Second configuration. * @return {@code True} if configurations match. */ private boolean matches(GridCacheConfiguration ccfg0, GridCacheConfiguration ccfg1) { return F.eq(ccfg0.getCacheMode(), ccfg1.getCacheMode()) && F.eq(ccfg0.getBackups(), ccfg1.getBackups()) && F.eq(ccfg0.getAtomicityMode(), ccfg1.getAtomicityMode()) && F.eq(ccfg0.getAtomicWriteOrderMode(), ccfg1.getAtomicWriteOrderMode()) && F.eq(ccfg0.getMemoryMode(), ccfg1.getMemoryMode()) && F.eq(ccfg0.getDistributionMode(), ccfg1.getDistributionMode()); }
GridCacheDistributionMode distributionMode = ctx.config().getDistributionMode();
&& cfg.getDistributionMode() != GridCacheDistributionMode.CLIENT_ONLY;
cfg.getDistributionMode() != NEAR_PARTITIONED && cfg.getDistributionMode() != NEAR_ONLY);
if (cfg.getDistributionMode() == null) cfg.setDistributionMode(PARTITIONED_ONLY); if (cfg.getDistributionMode() == PARTITIONED_ONLY || cfg.getDistributionMode() == CLIENT_ONLY) { if (cfg.getNearEvictionPolicy() != null) U.quietAndWarn(log, "Ignoring near eviction policy since near cache is disabled."); assert cfg.getDistributionMode() != null;
&& (cfg.getDistributionMode() == CLIENT_ONLY || cfg.getDistributionMode() == NEAR_ONLY)) nearOrClientCaches.add(cfg.getName());
cfg.distributionMode(ccfg.getDistributionMode()); cfg.atomicityMode(ccfg.getAtomicityMode()); cfg.atomicSequenceReserveSize(ccfg.getAtomicSequenceReserveSize());
if (cc.getDistributionMode() == NEAR_PARTITIONED) { U.warn(log, "NEAR_PARTITIONED distribution mode cannot be used with REPLICATED cache, " + "will be changed to PARTITIONED_ONLY [cacheName=" + cc.getName() + ']');
dgcRmvLocks = cc.isDgcRemoveLocks(); dgcSuspectLockTimeout = cc.getDgcSuspectLockTimeout(); distro = cc.getDistributionMode(); drSndCacheCfg = cc.getDrSenderConfiguration() != null ? new GridDrSenderCacheConfiguration(cc.getDrSenderConfiguration()) : null;