protected static void createProxyCache(final int[] userIndices, final Properties[] props) { int j = 0; for (int i : userIndices) { proxyCaches[i] = (ProxyCache) ((PoolImpl) pool).createAuthenticatedCacheView(props[j]); j++; } }
@Override public Object call() throws Exception { op.initMessagePart(); Object result = null; boolean onlyUseExistingCnx = ((pool.getMaxConnections() != -1 && pool.getConnectionCount() >= pool.getMaxConnections()) ? true : false); op.setAllowDuplicateMetadataRefresh(!onlyUseExistingCnx); try { UserAttributes.userAttributes.set(securityAttributes); result = this.pool.executeOn(server, op, true, onlyUseExistingCnx); } catch (AllConnectionsInUseException ex) { // if we reached connection limit and don't have available connection to // that server,then execute function on one of the connections available // from other servers instead of creating new connection to the original // server if (op instanceof ExecuteRegionFunctionSingleHopOpImpl) { ExecuteRegionFunctionSingleHopOpImpl newop = (ExecuteRegionFunctionSingleHopOpImpl) op; result = this.pool.execute(new ExecuteRegionFunctionOpImpl(newop)); } else { result = this.pool.execute(this.op); } } finally { UserAttributes.userAttributes.set(null); } return result; }
private ConnectionSource getSourceImpl(LocatorDiscoveryCallback locatorDiscoveryCallback) { List<InetSocketAddress> locators = getLocators(); if (locators.isEmpty()) { return new ExplicitConnectionSourceImpl(getServers()); } else { AutoConnectionSourceImpl source = new AutoConnectionSourceImpl(locators, locatorAddresses, getServerGroup(), socketConnectTimeout); if (locatorDiscoveryCallback != null) { source.setLocatorDiscoveryCallback(locatorDiscoveryCallback); } return source; } }
if (!getName().equals(other.getName())) { throw new RuntimeException( String.format("Pool %s are different", "names")); if (getSocketConnectTimeout() != other.getSocketConnectTimeout()) { throw new RuntimeException( String.format("Pool %s is different", "socketConnectimeout")); if (getFreeConnectionTimeout() != other.getFreeConnectionTimeout()) { throw new RuntimeException( String.format("Pool %s is different", "connectionTimeout")); if (getLoadConditioningInterval() != other.getLoadConditioningInterval()) { throw new RuntimeException( String.format("Pool %s is different", "connectionLifetime")); if (getSocketBufferSize() != other.getSocketBufferSize()) { throw new RuntimeException( String.format("Pool %s is different", "socketBufferSize")); if (getThreadLocalConnections() != other.getThreadLocalConnections()) { throw new RuntimeException( String.format("Pool %s is different", "threadLocalConnections")); if (getReadTimeout() != other.getReadTimeout()) { throw new RuntimeException( String.format("Pool %s is different", "readTimeout")); if (getMinConnections() != other.getMinConnections()) {
Connection conn = pool.acquireConnection(); assertNotNull(conn); assertEquals(1, pool.getConnectedServerCount()); assertFalse(pool.isDestroyed()); destroyRegion2(); assertFalse(pool.isDestroyed()); destroyPRRegion(); assertFalse(pool.isDestroyed()); pool.destroy(); assertTrue(pool.isDestroyed());
@SuppressWarnings("all") private void verifyClientCacheSubscriptionQueueConnectionsEstablished() { resolvePools().stream() .filter(pool -> pool.getSubscriptionEnabled()) .filter(pool -> pool instanceof PoolImpl) .map(pool -> (PoolImpl) pool) .forEach(pool -> { long timeout = System.currentTimeMillis() + resolveTimeout(); while (System.currentTimeMillis() < timeout && !pool.isPrimaryUpdaterAlive()) { synchronized (pool) { ObjectUtils.doOperationSafely(() -> { TimeUnit.MILLISECONDS.timedWait(pool, 500L); return null; }); } } String errorMessage = String.format("ClientCache subscription queue connection not established;" + " Pool [%s] has configuration [locators = %s, servers = %s]", pool, pool.getLocators(), pool.getServers()); if (isThrowExceptionOnSubscriptionQueueConnectionFailure()) { Assert.state(pool.isPrimaryUpdaterAlive(), errorMessage); } else if (getLogger().isWarnEnabled()){ getLogger().warn(errorMessage); } }); }
List locators = getLocators(); if (!locators.isEmpty()) { logger.debug("PoolImpl - starting pool with locators: {}", locators); } else { logger.debug("PoolImpl -starting pool with servers: {}", getServers()); final String timerName = "poolTimer-" + getName() + "-"; backgroundProcessor = LoggingExecutors.newScheduledThreadPool(timerName, BACKGROUND_TASK_POOL_SIZE, BACKGROUND_TASK_POOL_KEEP_ALIVE, threadMonitoring);
stats.setCpus(cpus); String poolName = pool.getName(); try { Map<String, String> newPoolStats = stats.getPoolStats(); String poolStatsStr = "MinConnections=" + pool.getMinConnections() + ";MaxConnections=" + pool.getMaxConnections() + ";Redundancy=" + pool.getSubscriptionRedundancy() + ";CQS=" + pool.getQueryService().getCqs().length; logger.debug("ClientHealthStats for poolName " + poolName + " poolStatsStr=" + poolStatsStr);
if (!isDestroyed()) { this.destroyed = true; this.keepAlive = keepAlive;
/** * Test two regions: notify by subscription is true. Both the regions have registered interest in * all the keys. Close both the regions. When the last region is closed , it should close the * ConnectionProxy on the client , close all the server connection threads on the server & remove * the CacheClientProxy from the CacheClient notifier */ @Test public void testRegionClose() throws Exception { // start server first PORT1 = initServerCache(true); pool = (PoolImpl) createClientCache(NetworkUtils.getServerHostName(), PORT1); populateCache(); registerInterestInBothTheRegions(); closeBothRegions(); assertFalse(pool.isDestroyed()); pool.destroy(); assertTrue(pool.isDestroyed()); server1.invoke(() -> ClientServerMiscDUnitTestBase.verifyNoCacheClientProxyOnServer()); }
+ op.getMessage() + " to all servers using pool: " + pool); servers = pool.getConnectionSource().getAllServers(); Iterator i = servers.iterator(); while (i.hasNext()) { pool.executeOn((ServerLocation) i.next(), op); + Arrays.toString(groups) + " all members:" + allServers); pool.execute(op, 0);
try { if (this.sender.getProxy() == null || this.sender.getProxy().isDestroyed()) { this.sender.initProxy(); } else { con = this.sender.getProxy().acquireConnection(); logger.debug("ServerLocation is: {}. Connecting to this serverLocation...", server); con = this.sender.getProxy().acquireConnection(server); } else { if (logger.isDebugEnabled()) { logger.debug("ServerLocation is null. Creating new connection. "); con = this.sender.getProxy().acquireConnection();
: new PoolStats(statFactory, getName() + "->" + (isEmpty(serverGroup) ? "[any servers]" : "[" + getServerGroup() + "]")); source = getSourceImpl(((PoolFactoryImpl.PoolAttributes) attributes).locatorCallback); endpointManager = new EndpointManagerImpl(name, this.dsys, this.cancelCriterion, this.stats); connectionFactory = new ConnectionFactoryImpl(source, endpointManager, this.dsys, cancelCriterion, getStats());
if (((PoolImpl) cp).isUsedByGateway()) { m1Size--; if (((PoolImpl) cp).isUsedByGateway()) { m2Size--; PoolImpl poolImpl = (PoolImpl) pool; if (!poolImpl.isUsedByGateway()) { poolImpl.sameAs(m2.get(poolImpl.getName()));
factory.setDataPolicy(DataPolicy.EMPTY); factory.setPoolName(p.getName()); conn = pool.acquireConnection(); return conn != null; } catch (NoAvailableServersException e) {
@Override public boolean isBackingCacheAvailable() { if (getSessionManager().isCommitValveFailfastEnabled()) { PoolImpl pool = (PoolImpl) PoolManager.find(getOperatingRegionName()); return pool.isPrimaryUpdaterAlive(); } return true; }
int maxRetryAttempts = 0; if (isHA) { maxRetryAttempts = pool.getRetryAttempts(); isFnSerializationReqd, isHA, optimizeForWrite, (byte) 1, groups, allServers, executor.isIgnoreDepartedMembers()); pool.execute(reexecOp, 0); } else { if (isDebugEnabled) { executor.isIgnoreDepartedMembers()); pool.execute(op, 0);
@Override public String toString() { StringBuilder sb = new StringBuilder(100); sb.append(this.getClass().getSimpleName()).append('@').append(System.identityHashCode(this)) .append(" name=").append(getName()); return sb.toString(); }
/** * Test hook that returns a list of server names (host+port); one for each server we are currently * connected to. */ public List<String> getCurrentServerNames() { List<ServerLocation> servers = getCurrentServers(); ArrayList<String> result = new ArrayList(servers.size()); Iterator it = servers.iterator(); while (it.hasNext()) { ServerLocation sl = (ServerLocation) it.next(); String name = sl.getHostName() + sl.getPort(); result.add(name); } return result; }