/** * @return {@code True} if cache is replicated cache. */ public boolean isReplicated() { return cacheCfg.getCacheMode() == GridCacheMode.REPLICATED; }
/** * @param cfg Cache configuration. * @return Query manager. */ private GridCacheQueryManager queryManager(GridCacheConfiguration cfg) { return cfg.getCacheMode() == LOCAL ? new GridCacheLocalQueryManager() : new GridCacheDistributedQueryManager(); }
/** {@inheritDoc} */ @Override public void start0() throws GridException { super.start0(); assert cctx.config().getCacheMode() == LOCAL; }
/** * 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; }
/** * @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() == GridCacheMode.REPLICATED; }
/** {@inheritDoc} */ @Override public GridCacheQueryFuture<?> queryDistributed(GridCacheQueryBean qry, Collection<GridNode> nodes) { assert cctx.config().getCacheMode() == LOCAL; throw new GridRuntimeException("Distributed queries are not available for local cache " + "(use 'GridCacheQuery.execute(grid.forLocal())' instead) [cacheName=" + cctx.name() + ']'); }
/** {@inheritDoc} */ @Override public GridCacheQueryFuture<?> queryFieldsDistributed(GridCacheQueryBean qry, Collection<GridNode> nodes) { assert cctx.config().getCacheMode() == LOCAL; throw new GridRuntimeException("Distributed queries are not available for local cache " + "(use 'GridCacheQuery.execute(grid.forLocal())' instead) [cacheName=" + cctx.name() + ']'); } }
/** * @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() == GridCacheMode.REPLICATED; }
/** {@inheritDoc} */ @Override protected void start0() throws GridException { if (cctx.config().getCacheMode() != LOCAL) { pessimisticRecoveryBuf = new GridCachePerThreadTxCommitBuffer<>(cctx); txFinishSync = new GridCacheTxFinishSync<>(cctx); } }
/** {@inheritDoc} */ @Override public int nearSize() { return cctx.config().getCacheMode() == PARTITIONED && isNearEnabled(cctx) ? cctx.near().nearKeySet(entryFilter(true)).size() : 0; }
/** {@inheritDoc} */ @Override public boolean backup() { return ctx.config().getCacheMode() != LOCAL && ctx.affinity().backups(key, ctx.affinity().affinityTopologyVersion()).contains(ctx.localNode()); }
/** * @param ctx Context. * @return Managers present in both, DHT and Near caches. */ @SuppressWarnings("IfMayBeConditional") private Collection<GridCacheManager> dhtExcludes(GridCacheContext ctx) { if (ctx.config().getCacheMode() == LOCAL || !isNearEnabled(ctx)) return Collections.emptyList(); else return F.asList((GridCacheManager)ctx.dgc(), ctx.queries(), ctx.continuousQueries()); }
/** {@inheritDoc} */ @Override public boolean backup() { GridCacheContext<K, V> ctx = impl.context(); return ctx.config().getCacheMode() != LOCAL && ctx.affinity().backups(key, ctx.affinity().affinityTopologyVersion()).contains(ctx.localNode()); }
/** {@inheritDoc} */ @Override public boolean backup() { GridCacheContext<K, V> ctx = cached.context(); return ctx.config().getCacheMode() != LOCAL && ctx.affinity().backups(cached.key(), ctx.affinity().affinityTopologyVersion()).contains(ctx.localNode()); }
/** {@inheritDoc} */ @Override public boolean primary() { return ctx.config().getCacheMode() == LOCAL || ctx.affinity().primary(ctx.localNode(), key, ctx.affinity().affinityTopologyVersion()); }
/** {@inheritDoc} */ @Override public boolean primary() { GridCacheContext<K, V> ctx = cached.context(); if (ctx.config().getCacheMode() == LOCAL) return true; GridNode primary = ctx.affinity().primary(cached.key(), ctx.affinity().affinityTopologyVersion()); return primary != null && ctx.nodeId().equals(primary.id()); }
/** {@inheritDoc} */ @Override public boolean primary() { GridCacheContext<K, V> ctx = impl.context(); return ctx.config().getCacheMode() == LOCAL || ctx.affinity().primary(ctx.localNode(), key, ctx.affinity().affinityTopologyVersion()); }
/** {@inheritDoc} */ @Override public GridCacheQueryFuture<?> queryLocal(GridCacheQueryBean qry) { assert cctx.config().getCacheMode() != LOCAL; if (log.isDebugEnabled()) log.debug("Executing query on local node: " + qry); GridCacheLocalQueryFuture<K, V, ?> fut = new GridCacheLocalQueryFuture<>(cctx, qry); try { qry.query().validate(); fut.execute(); } catch (GridException e) { fut.onDone(e); } return fut; }
/** {@inheritDoc} */ @Override public GridCacheQueryFuture<?> queryFieldsLocal(GridCacheQueryBean qry) { assert cctx.config().getCacheMode() == LOCAL; if (log.isDebugEnabled()) log.debug("Executing query on local node: " + qry); GridCacheLocalFieldsQueryFuture fut = new GridCacheLocalFieldsQueryFuture(cctx, qry); try { qry.query().validate(); fut.execute(); } catch (GridException e) { fut.onDone(e); } return fut; }
/** {@inheritDoc} */ @Override public GridCacheQueryFuture<?> queryFieldsLocal(GridCacheQueryBean qry) { assert cctx.config().getCacheMode() != LOCAL; if (log.isDebugEnabled()) log.debug("Executing query on local node: " + qry); GridCacheLocalFieldsQueryFuture fut = new GridCacheLocalFieldsQueryFuture(cctx, qry); try { qry.query().validate(); fut.execute(); } catch (GridException e) { fut.onDone(e); } return fut; }