/** * @return All configured public cache instances. */ public Collection<IgniteCacheProxy<?, ?>> publicCaches() { Collection<IgniteCacheProxy<?, ?>> res = new ArrayList<>(jCacheProxies.size()); for (IgniteCacheProxyImpl<?, ?> proxy : jCacheProxies.values()) { if (proxy.context().userCache()) res.add(proxy.gatewayWrapper()); } return res; }
/** {@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 ); }
/** {@inheritDoc} */ @Override public void put(K key, V val) { IgniteInternalCache<K, V> delegate = getDelegateSafe(); try { if (isAsync()) setFuture(putAsync0(key, val)); else delegate.put(key, val); } catch (IgniteCheckedException | IgniteException e) { throw cacheException(e); } }
/** {@inheritDoc} */ @Override public <T> IgniteFuture<T> invokeAsync(K key, EntryProcessor<K, V, T> entryProcessor, Object... args) { return createFuture(invokeAsync0(key, entryProcessor, args)); }
/** {@inheritDoc} */ @Override public IgniteFuture<Long> sizeLongAsync(int part, CachePeekMode... peekModes) throws CacheException { IgniteInternalCache<K, V> delegate = getDelegateSafe(); return createFuture(delegate.sizeLongAsync(part, peekModes)); }
/** {@inheritDoc} */ @Override public <R> QueryCursor<R> query(Query<R> qry) { GridCacheContext<K, V> ctx = getContextSafe(); A.notNull(qry, "qry"); try { ctx.checkSecurity(SecurityPermission.CACHE_READ); validate(qry); convertToBinary(qry); CacheOperationContext opCtxCall = ctx.operationContextPerCall(); boolean keepBinary = opCtxCall != null && opCtxCall.isKeepBinary(); if (qry instanceof ContinuousQuery || qry instanceof ContinuousQueryWithTransformer) return (QueryCursor<R>)queryContinuous((AbstractContinuousQuery)qry, qry.isLocal(), keepBinary); if (qry instanceof SqlQuery) return (QueryCursor<R>)ctx.kernalContext().query().querySql(ctx, (SqlQuery)qry, keepBinary); if (qry instanceof SqlFieldsQuery) return (FieldsQueryCursor<R>)ctx.kernalContext().query().querySqlFields(ctx, (SqlFieldsQuery)qry, null, keepBinary, true).get(0); if (qry instanceof ScanQuery) return query((ScanQuery)qry, null, projection(qry.isLocal())); return (QueryCursor<R>)query(qry, projection(qry.isLocal())); } catch (Exception e) { if (e instanceof CacheException) throw (CacheException)e; throw new CacheException(e.getMessage(), e); } }
/** {@inheritDoc} */ @Override public void preloadPartition(int part) { IgniteInternalCache<K, V> delegate = getDelegateSafe(); try { delegate.preloadPartition(part); } catch (IgniteCheckedException e) { throw cacheException(e); } }
proxy = new IgniteCacheProxyImpl(cache.context(), cache, false); proxy.suspend(); proxy.context0().gate().stopped(); proxy.closeProxy();
/** {@inheritDoc} */ @Override public void enableStatistics(boolean enabled) { GridCacheContext<K, V> ctx = getContextSafe(); try { ctx.kernalContext().cache().enableStatistics(Collections.singleton(getName()), enabled); } catch (IgniteCheckedException e) { throw cacheException(e); } }
GridCacheContext<K, V> ctx = getContextSafe(); throw new IgniteException("Mandatory RemoteTransformerFactory is not set for the query: " + qry); Collection<ClusterNode> nodes = context().grid().cluster().nodes(); qry.getInitialQuery() != null ? query(qry.getInitialQuery()) : null;
/** * @param cacheName Cache name. * @param stop {@code True} for stop cache, {@code false} for close cache. * @param restart Restart flag. */ void blockGateway(String cacheName, boolean stop, boolean restart) { // Break the proxy before exchange future is done. IgniteCacheProxyImpl<?, ?> proxy = jcacheProxy(cacheName, false); if (restart) { GridCacheAdapter<?, ?> cache = caches.get(cacheName); if (cache != null) cache.active(false); } if (proxy != null) { if (stop) { if (restart) proxy.restart(); proxy.context().gate().stopped(); } else proxy.closeProxy(); } }
/** {@inheritDoc} */ @Override public IgniteFuture<Void> preloadPartitionAsync(int part) { IgniteInternalCache<K, V> delegate = getDelegateSafe(); try { return (IgniteFuture<Void>)createFuture(delegate.preloadPartitionAsync(part)); } catch (IgniteCheckedException e) { throw cacheException(e); } }
/** {@inheritDoc} */ @Override public IgniteFuture<Void> loadCacheAsync(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws CacheException { GridCacheContext<K, V> ctx = getContextSafe(); try { if (ctx.cache().isLocal()) return (IgniteFuture<Void>)createFuture(ctx.cache().localLoadCacheAsync(p, args)); return (IgniteFuture<Void>)createFuture(ctx.cache().globalLoadCacheAsync(p, args)); } catch (IgniteCheckedException | IgniteException e) { throw cacheException(e); } }
/** {@inheritDoc} */ @Override public void deregisterCacheEntryListener(CacheEntryListenerConfiguration<K, V> lsnrCfg) { GridCacheContext<K, V> ctx = getContextSafe(); try { ctx.continuousQueries().cancelJCacheQuery(lsnrCfg); } catch (IgniteCheckedException | IgniteException e) { throw cacheException(e); } }
/** {@inheritDoc} */ @Override public List<FieldsQueryCursor<List<?>>> queryMultipleStatements(SqlFieldsQuery qry) { GridCacheContext<K, V> ctx = getContextSafe(); A.notNull(qry, "qry"); try { ctx.checkSecurity(SecurityPermission.CACHE_READ); validate(qry); convertToBinary(qry); CacheOperationContext opCtxCall = ctx.operationContextPerCall(); boolean keepBinary = opCtxCall != null && opCtxCall.isKeepBinary(); return ctx.kernalContext().query().querySqlFields(ctx, qry, null, keepBinary, false); } catch (Exception e) { if (e instanceof CacheException) throw (CacheException)e; throw new CacheException(e); } }
/** * @param req Request. */ private void stopGateway(DynamicCacheChangeRequest req) { assert req.stop() : req; IgniteCacheProxyImpl<?, ?> proxy; // Break the proxy before exchange future is done. if (req.restart()) { if (DataStructuresProcessor.isDataStructureCache(req.cacheName())) ctx.dataStructures().suspend(req.cacheName()); GridCacheAdapter<?, ?> cache = caches.get(req.cacheName()); if (cache != null) cache.active(false); proxy = jCacheProxies.get(req.cacheName()); if (proxy != null) proxy.restart(); } else { completeProxyInitialize(req.cacheName()); proxy = jCacheProxies.remove(req.cacheName()); } if (proxy != null) proxy.context().gate().onStopped(); }
((IgniteCacheProxyImpl) delegate).checkRestart(); IgniteInternalCache<K, V> cache = context().kernalContext().cache().<K, V>publicJCache(context().name()).internalProxy(); GridFutureAdapter<Void> fut = proxyImpl.opportunisticRestart(); proxyImpl.onRestarted(cache.context(), cache.context().cache()); else new IgniteFutureImpl<>(fut).get();
/** * @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; }
/** * Convert query arguments to BinaryObjects if binary marshaller used. * * @param qry Query. */ private void convertToBinary(final Query qry) { GridCacheContext<K, V> ctx = getContextSafe(); if (ctx.binaryMarshaller()) { if (qry instanceof SqlQuery) { final SqlQuery sqlQry = (SqlQuery) qry; convertToBinary(sqlQry.getArgs()); } else if (qry instanceof SpiQuery) { final SpiQuery spiQry = (SpiQuery) qry; convertToBinary(spiQry.getArgs()); } else if (qry instanceof SqlFieldsQuery) { final SqlFieldsQuery fieldsQry = (SqlFieldsQuery) qry; convertToBinary(fieldsQry.getArgs()); } } }