if (!instance.isClient()) { throw new IllegalStateException( "A client cache can not be created because a non-client cache already exists.");
/** * Gets an arbitrary open instance of {@link ClientCache} produced by an earlier call to * {@link #create}. * * @throws CacheClosedException if a cache has not been created or the only created one is * {@link ClientCache#isClosed closed} * @throws IllegalStateException if the cache was created by CacheFactory instead of * ClientCacheFactory */ public static synchronized ClientCache getAnyInstance() { InternalClientCache instance = GemFireCacheImpl.getInstance(); if (instance == null) { throw new CacheClosedException( "A cache has not yet been created."); } else { if (!instance.isClient()) { throw new IllegalStateException( "The singleton cache was created by CacheFactory not ClientCacheFactory."); } instance.getCancelCriterion().checkCancelInProgress(null); return instance; } }
@Override public Execution onServers(RegionService regionService, String... groups) { if (regionService == null) { throw new FunctionException(String.format("%s passed is null", "RegionService instance ")); } if (regionService instanceof GemFireCacheImpl) { InternalClientCache internalCache = (InternalClientCache) regionService; if (!internalCache.isClient()) { throw new FunctionException("The cache was not a client cache"); } else if (internalCache.getDefaultPool() != null) { return onServers(internalCache.getDefaultPool(), groups); } else { throw new FunctionException("The client cache does not have a default pool"); } } else { ProxyCache proxyCache = (ProxyCache) regionService; return new ServerFunctionExecutor(proxyCache.getUserAttributes().getPool(), true, proxyCache, groups); } }
@Override public Execution onServer(RegionService regionService, String... groups) { if (regionService == null) { throw new FunctionException(String.format("%s passed is null", "RegionService instance ")); } if (regionService instanceof GemFireCacheImpl) { InternalClientCache internalCache = (InternalClientCache) regionService; if (!internalCache.isClient()) { throw new FunctionException("The cache was not a client cache"); } else if (internalCache.getDefaultPool() != null) { return onServer(internalCache.getDefaultPool(), groups); } else { throw new FunctionException("The client cache does not have a default pool"); } } else { ProxyCache proxyCache = (ProxyCache) regionService; return new ServerFunctionExecutor(proxyCache.getUserAttributes().getPool(), false, proxyCache, groups); } }