private PoolFactory getPoolFactory() { if (this.pf == null) { this.pf = PoolManager.createFactory(); } return this.pf; }
/** * @since GemFire 6.5 */ @Override public QueryService getQueryService(String poolName) { Pool pool = PoolManager.find(poolName); if (pool == null) { throw new IllegalStateException("Could not find a pool named " + poolName); } else { return pool.getQueryService(); } }
/** * @param xmlPoolsOnly if true then only call readyForEvents on pools declared in XML. */ public static void readyForEvents(InternalDistributedSystem system, boolean xmlPoolsOnly) { boolean foundDurablePool = false; Map<String, Pool> pools = PoolManager.getAll(); for (Iterator<Pool> itr = pools.values().iterator(); itr.hasNext();) { PoolImpl p = (PoolImpl) itr.next(); if (p.isDurableClient()) { // TODO - handle an exception and attempt on all pools? foundDurablePool = true; if (!xmlPoolsOnly || p.getDeclaredInXML()) { p.readyForEvents(system); } } } if (pools.size() > 0 && !foundDurablePool) { throw new IllegalStateException( "Only durable clients should call readyForEvents()"); } }
/** * Unconditionally destroys all created pools that are in this manager. */ public static void close() { close(false); } }
PoolManager.close(false);
@Override public RegionService createAuthenticatedView(Properties userSecurityProperties, String poolName) { Pool pool = PoolManager.find(poolName); if (pool == null) { throw new IllegalStateException("Pool " + poolName + " does not exist"); } return createAuthenticatedCacheView(pool, userSecurityProperties); }
public static Pool configureConnectionPoolWithName(AttributesFactory factory, String host, int[] ports, boolean establish, int redundancy, int connectionsPerServer, String serverGroup, String poolName, int pingInterval, int idleTimeout, boolean threadLocalCnxs, int lifetimeTimeout, int statisticInterval) { return configureConnectionPoolWithNameAndFactory(factory, host, ports, establish, redundancy, connectionsPerServer, serverGroup, poolName, PoolManager.createFactory(), pingInterval, idleTimeout, threadLocalCnxs, lifetimeTimeout, statisticInterval); }
@Override public Set<InetSocketAddress> getCurrentServers() { Map<String, Pool> pools = PoolManager.getAll(); Set<InetSocketAddress> result = null; for (Pool pool : pools.values()) { PoolImpl poolImpl = (PoolImpl) pool; for (ServerLocation serverLocation : poolImpl.getCurrentServers()) { if (result == null) { result = new HashSet<>(); } result.add(new InetSocketAddress(serverLocation.getHostName(), serverLocation.getPort())); } } if (result == null) { return Collections.emptySet(); } else { return result; } }
PoolManager.close(keepAlive);
private static InternalPool calcPool(Region r) { String poolName = r.getAttributes().getPoolName(); if (poolName == null || "".equals(poolName)) { throw new IllegalStateException( "The region " + r.getFullPath() + " did not have a client pool configured."); } else { InternalPool pool = (InternalPool) PoolManager.find(poolName); if (pool == null) { throw new IllegalStateException("The pool " + poolName + " does not exist."); } return pool; } }
public static Pool configureConnectionPoolWithName(AttributesFactory factory, String host, int[] ports, boolean establish, int redundancy, int connectionsPerServer, String serverGroup, String poolName) { return configureConnectionPoolWithNameAndFactory(factory, host, ports, establish, redundancy, connectionsPerServer, serverGroup, poolName, PoolManager.createFactory(), -1, -1, false, -2, -1); }
final Map map = new HashMap(); // KEY:server (String), VALUE:List of active endpoints Map/* <String,Pool> */ poolMap = PoolManager.getAll(); Iterator pools = poolMap.values().iterator(); while (pools.hasNext()) {
/** * Returns the pool this region is using or null if it does not have one or the pool does not * exist. * * @since GemFire 5.7 */ private PoolImpl getPool() { PoolImpl result = null; if (getPoolName() != null) { result = (PoolImpl) PoolManager.find(getPoolName()); } return result; }
private PoolFactory createDefaultPF() { PoolFactory defaultPoolFactory = PoolManager.createFactory(); try { String localHostName = SocketCreator.getHostName(SocketCreator.getLocalHost()); defaultPoolFactory.addServer(localHostName, CacheServer.DEFAULT_PORT); } catch (UnknownHostException ex) { throw new IllegalStateException("Could not determine local host name", ex); } return defaultPoolFactory; }
public static void allPoolsRegisterInstantiator(InstantiatorAttributesHolder holder) { InstantiatorAttributesHolder[] holders = new InstantiatorAttributesHolder[1]; holders[0] = holder; for (Iterator<Pool> itr = PoolManager.getAll().values().iterator(); itr.hasNext();) { PoolImpl next = (PoolImpl) itr.next(); try { EventID eventId = InternalInstantiator.generateEventId(); if (eventId == null) { // cache must not exist, do nothing } else { RegisterInstantiatorsOp.execute(next, holders, InternalInstantiator.generateEventId()); } } catch (RuntimeException e) { logger.warn("Error registering instantiator on pool:", e); } finally { next.releaseThreadLocalConnection(); } } }
public static void dumpPoolIdentifiers() throws Exception { // duplicate events were received, so let's look at the thread identifiers we have PoolImpl pool = (PoolImpl) PoolManager.find("ClientServerMiscDUnitTestPool"); Map seqMap = pool.getThreadIdToSequenceIdMap(); for (Object o : seqMap.keySet()) { ThreadIdentifier tid = (ThreadIdentifier) o; byte[] memberBytes = tid.getMembershipID(); dumpMemberId(tid, memberBytes); } }
public static void createPool(PoolAttributes poolAttr) throws Exception { Properties props = new Properties(); props.setProperty(MCAST_PORT, "0"); props.setProperty(LOCATORS, ""); DistributedSystem ds = new CacheServerTestUtil().getSystem(props);; PoolFactoryImpl pf = (PoolFactoryImpl) PoolManager.createFactory(); pf.init(poolAttr); PoolImpl p = (PoolImpl) pf.create("CacheServerTestUtil"); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.LOCAL); factory.setPoolName(p.getName()); RegionAttributes attrs = factory.create(); pool = p; }
public static void allPoolsRegisterInstantiator(Instantiator instantiator) { Instantiator[] instantiators = new Instantiator[1]; instantiators[0] = instantiator; for (Iterator<Pool> itr = PoolManager.getAll().values().iterator(); itr.hasNext();) { PoolImpl next = (PoolImpl) itr.next(); try { EventID eventId = InternalInstantiator.generateEventId(); if (eventId == null) { // cache must not exist, do nothing } else { RegisterInstantiatorsOp.execute(next, instantiators, InternalInstantiator.generateEventId()); } } catch (RuntimeException e) { logger.warn("Error registering instantiator on pool:", e); } finally { next.releaseThreadLocalConnection(); } } }
public static void createCacheClientFromXml(URL url, String poolName, String durableClientId, int timeout, Boolean addControlListener) { ClientCacheFactory ccf = new ClientCacheFactory(); try { File cacheXmlFile = new File(url.toURI().getPath()); ccf.set(CACHE_XML_FILE, cacheXmlFile.toURI().getPath()); } catch (URISyntaxException e) { throw new ExceptionInInitializerError(e); } ccf.set(MCAST_PORT, "0"); ccf.set(DURABLE_CLIENT_ID, durableClientId); ccf.set(DURABLE_CLIENT_TIMEOUT, String.valueOf(timeout)); cache = (Cache) ccf.create(); expected = IgnoredException .addIgnoredException("java.net.ConnectionException||java.net.SocketException"); pool = (PoolImpl) PoolManager.find(poolName); }
protected void startBridgeClient(final Pool pool, final String[] regions) throws Exception { Properties props = new Properties(); props.setProperty(MCAST_PORT, String.valueOf(0)); props.setProperty(LOCATORS, ""); DistributedSystem ds = getSystem(props); Cache cache = CacheFactory.create(ds); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.LOCAL); factory.setPoolName(POOL_NAME); PoolFactoryImpl pf = (PoolFactoryImpl) PoolManager.createFactory(); pf.init(pool); LocatorDiscoveryCallback locatorCallback = new MyLocatorCallback(); remoteObjects.put(CALLBACK_KEY, locatorCallback); pf.setLocatorDiscoveryCallback(locatorCallback); pf.create(POOL_NAME); RegionAttributes attrs = factory.create(); for (int i = 0; i < regions.length; i++) { cache.createRegion(regions[i], attrs); } remoteObjects.put(CACHE_KEY, cache); }