/** {@inheritDoc} */ @Override protected IgniteCache<K, V> createAsyncInstance() { GridCacheContext<K, V> ctx = getContextSafe(); IgniteInternalCache<K, V> delegate = getDelegateSafe(); return new IgniteCacheProxyImpl<K, V>( ctx, delegate, true ); }
/** * @param name Cache name. * @return Cache instance for given name. */ @SuppressWarnings("unchecked") public <K, V> IgniteCacheProxy<K, V> jcache(String name) { assert name != null; IgniteCacheProxy<K, V> cache = (IgniteCacheProxy<K, V>)jcacheProxy(name, true); if (cache == null) { GridCacheAdapter<?, ?> cacheAdapter = caches.get(name); if (cacheAdapter != null) { cache = new IgniteCacheProxyImpl(cacheAdapter.context(), cacheAdapter, false); IgniteCacheProxyImpl<?, ?> prev = addjCacheProxy(name, (IgniteCacheProxyImpl<?, ?>)cache); if (prev != null) cache = (IgniteCacheProxy<K, V>)prev; completeProxyInitialize(cache.getName()); } } if (cache == null) throw new IllegalArgumentException("Cache is not configured: " + name); return cache; }
proxy = new IgniteCacheProxyImpl(cache.context(), cache, false);
/** * @param startTopVer Cache start version. * @param err Cache start error if any. */ void initCacheProxies(AffinityTopologyVersion startTopVer, @Nullable Throwable err) { for (GridCacheAdapter<?, ?> cache : caches.values()) { GridCacheContext<?, ?> cacheCtx = cache.context(); if (cacheCtx.startTopologyVersion().equals(startTopVer)) { if (!jCacheProxies.containsKey(cacheCtx.name())) { IgniteCacheProxyImpl<?, ?> newProxy = new IgniteCacheProxyImpl(cache.context(), cache, false); if (!cache.active()) newProxy.suspend(); addjCacheProxy(cacheCtx.name(), newProxy); } if (cacheCtx.preloader() != null) cacheCtx.preloader().onInitialExchangeComplete(err); } } }
/** * @param name Cache name. * @return Cache. */ private <K, V> IgniteInternalCache<K, V> internalCacheEx(String name) { if (ctx.discovery().localNode().isClient()) { IgniteCacheProxy<K, V> proxy = (IgniteCacheProxy<K, V>)jcacheProxy(name, true); if (proxy == null) { GridCacheAdapter<?, ?> cacheAdapter = caches.get(name); if (cacheAdapter != null) { proxy = new IgniteCacheProxyImpl(cacheAdapter.context(), cacheAdapter, false); IgniteCacheProxyImpl<?, ?> prev = addjCacheProxy(name, (IgniteCacheProxyImpl<?, ?>)proxy); if (prev != null) proxy = (IgniteCacheProxy<K, V>)prev; completeProxyInitialize(proxy.getName()); } } assert proxy != null : name; return proxy.internalProxy(); } return internalCache(name); }
/** * @param cctx Cache context. */ private void closeCache(GridCacheContext cctx) { if (cctx.affinityNode()) { GridCacheAdapter<?, ?> cache = caches.get(cctx.name()); assert cache != null : cctx.name(); jCacheProxies.put(cctx.name(), new IgniteCacheProxyImpl(cache.context(), cache, false)); completeProxyInitialize(cctx.name()); } else { cctx.gate().onStopped(); // Do not close client cache while requests processing is in progress. sharedCtx.io().writeLock(); try { if (!cctx.affinityNode() && cctx.transactional()) sharedCtx.tm().rollbackTransactionsForCache(cctx.cacheId()); completeProxyInitialize(cctx.name()); jCacheProxies.remove(cctx.name()); stopCacheSafely(cctx); } finally { sharedCtx.io().writeUnlock(); } } }
/** {@inheritDoc} */ @Override protected IgniteCache<K, V> createAsyncInstance() { return new IgniteCacheProxyImpl<K, V>( ctx, delegate, true ); }
/** * @param name Cache name. * @return Cache instance for given name. */ @SuppressWarnings("unchecked") public <K, V> IgniteCacheProxy<K, V> jcache(String name) { assert name != null; IgniteCacheProxy<K, V> cache = (IgniteCacheProxy<K, V>)jcacheProxy(name, true); if (cache == null) { GridCacheAdapter<?, ?> cacheAdapter = caches.get(name); if (cacheAdapter != null) { cache = new IgniteCacheProxyImpl(cacheAdapter.context(), cacheAdapter, false); IgniteCacheProxyImpl<?, ?> prev = addjCacheProxy(name, (IgniteCacheProxyImpl<?, ?>)cache); if (prev != null) cache = (IgniteCacheProxy<K, V>)prev; completeProxyInitialize(cache.getName()); } } if (cache == null) throw new IllegalArgumentException("Cache is not configured: " + name); return cache; }
/** * @param startTopVer Cache start version. * @param err Cache start error if any. */ void initCacheProxies(AffinityTopologyVersion startTopVer, @Nullable Throwable err) { for (GridCacheAdapter<?, ?> cache : caches.values()) { GridCacheContext<?, ?> cacheCtx = cache.context(); if (cacheCtx.startTopologyVersion().equals(startTopVer)) { if (!jCacheProxies.containsKey(cacheCtx.name())) { IgniteCacheProxyImpl<?, ?> newProxy = new IgniteCacheProxyImpl(cache.context(), cache, false); if (!cache.active()) newProxy.restart(); addjCacheProxy(cacheCtx.name(), newProxy); } if (cacheCtx.preloader() != null) cacheCtx.preloader().onInitialExchangeComplete(err); } } }
/** * @param name Cache name. * @return Cache. */ private <K, V> IgniteInternalCache<K, V> internalCacheEx(String name) { if (ctx.discovery().localNode().isClient()) { IgniteCacheProxy<K, V> proxy = (IgniteCacheProxy<K, V>)jcacheProxy(name, true); if (proxy == null) { GridCacheAdapter<?, ?> cacheAdapter = caches.get(name); if (cacheAdapter != null) { proxy = new IgniteCacheProxyImpl(cacheAdapter.context(), cacheAdapter, false); IgniteCacheProxyImpl<?, ?> prev = addjCacheProxy(name, (IgniteCacheProxyImpl<?, ?>)proxy); if (prev != null) proxy = (IgniteCacheProxy<K, V>)prev; completeProxyInitialize(proxy.getName()); } } assert proxy != null : name; return proxy.internalProxy(); } return internalCache(name); }
jCacheProxies.put(cctx.name(), new IgniteCacheProxyImpl(cache.context(), cache, false));