/** * test hook */ public void endpointsNetDownForDUnitTest() { logger.debug("PoolImpl - endpointsNetDownForDUnitTest"); setTEST_DURABLE_IS_NET_DOWN(true); try { Thread.sleep(this.pingInterval * 2); } catch (java.lang.InterruptedException ignore) { // do nothing. } Map endpoints = endpointManager.getEndpointMap(); for (Iterator itr = endpoints.values().iterator(); itr.hasNext();) { Endpoint endpoint = (Endpoint) itr.next(); logger.debug("PoolImpl Simulating crash of endpoint {}", endpoint); endpointManager.serverCrashed(endpoint); } }
@Override public void start(ScheduledExecutorService backgroundProcessor) { this.backgroundProcessor = backgroundProcessor; String name = "poolLoadConditioningMonitor-" + getPoolName(); this.loadConditioningProcessor = LoggingExecutors.newScheduledThreadPool(name, 1/* why not 0? */, false); endpointManager.addListener(endpointListener); lock.lock(); try { startBackgroundPrefill(); } finally { lock.unlock(); } }
/** * Test hook that returns the number of servers we currently have connections to. */ public int getConnectedServerCount() { return this.endpointManager.getConnectedServerCount(); }
@Override public void run2() { if (endpoint.timeToPing(pingIntervalNanos)) { try { PingOp.execute(pool, endpoint.getLocation()); } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug("Error occurred while pinging server: {} - {}", endpoint.getLocation(), e.getMessage()); } InternalCache cache = GemFireCacheImpl.getInstance(); if (cache != null) { ClientMetadataService cms = cache.getClientMetadataService(); cms.removeBucketServerLocation(endpoint.getLocation()); } // any failure to ping the server should be considered a crash (eg. // socket timeout exception, security exception, failure to connect). pool.getEndpointManager().serverCrashed(endpoint); } } } }
public ServerQueueStatus connect(EndpointManager endpointManager, ServerLocation location, ClientSideHandshake handshake, int socketBufferSize, int handshakeTimeout, int readTimeout, CommunicationMode communicationMode, GatewaySender sender, SocketCreator sc) throws IOException { theSocket = sc.connectForClient(location.getHostName(), location.getPort(), handshakeTimeout, socketBufferSize); theSocket.setTcpNoDelay(true); theSocket.setSendBufferSize(socketBufferSize); // Verify buffer sizes verifySocketBufferSize(socketBufferSize, theSocket.getReceiveBufferSize(), "receive"); verifySocketBufferSize(socketBufferSize, theSocket.getSendBufferSize(), "send"); theSocket.setSoTimeout(handshakeTimeout); out = theSocket.getOutputStream(); in = theSocket.getInputStream(); this.status = handshake.handshakeWithServer(this, location, communicationMode); commBuffer = ServerConnection.allocateCommBuffer(socketBufferSize, theSocket); if (sender != null) { commBufferForAsyncRead = ServerConnection.allocateCommBuffer(socketBufferSize, theSocket); } theSocket.setSoTimeout(readTimeout); endpoint = endpointManager.referenceEndpoint(location, this.status.getMemberId()); this.connectFinished = true; this.endpoint.getStats().incConnections(1); return status; }
@Override public Map<ServerLocation, Endpoint> getEndpointMap() { return endpointManager.getEndpointMap(); }
endpointManager.removeListener(endpointListener);
private Object executeWithPossibleReAuthentication(Connection conn, Op op) throws Exception { try { return conn.execute(op); } catch (ServerConnectivityException sce) { Throwable cause = sce.getCause(); if ((cause instanceof AuthenticationRequiredException && "User authorization attributes not found.".equals(cause.getMessage())) || sce.getMessage().contains("Connection error while authenticating user")) { // (ashetkar) Need a cleaner way of doing above check. // 2nd exception-message above is from AbstractOp.sendMessage() PoolImpl pool = (PoolImpl) PoolManagerImpl.getPMI().find(this.endpointManager.getPoolName()); if (!pool.getMultiuserAuthentication()) { Connection connImpl = this.connectionManager.getConnection(conn); conn.getServer().setUserId((Long) AuthenticateUserOp.executeOn(connImpl, this)); return conn.execute(op); } else { UserAttributes ua = UserAttributes.userAttributes.get(); if (ua != null) { authenticateMultiuser(pool, conn, ua); } return conn.execute(op); } } else { throw sce; } } }
endpointManager.close(); } catch (RuntimeException e) { logger.error("Error encountered while stopping endpoint manager", e);
conn.destroy(); if (invalidateServer) { endpointManager.serverCrashed(conn.getEndpoint());
endpointManager.referenceEndpoint(serverLocation, mock(InternalDistributedMember.class));
/** * Returns a list of ServerLocation instances; one for each server we are currently connected to. */ public List<ServerLocation> getCurrentServers() { ArrayList result = new ArrayList(); Map endpointMap = endpointManager.getEndpointMap(); result.addAll(endpointMap.keySet()); return result; }
@Override public void close(boolean keepAlive) { endpointManager.removeListener(endpointListener); synchronized (lock) { shuttingDown = true;
(PoolImpl) PoolManagerImpl.getPMI().find(this.endpointManager.getPoolName()); if (poolImpl == null) { return;
logger.isDebugEnabled() ? e : null); eManager.serverCrashed(this.endpoint); } catch (ClassNotFoundException e) { if (!quitting()) {
Endpoint ep = (Endpoint) this.endpointManager.getEndpointMap().get(server); if (ep != null) { QueueConnections qcs = this.queueManager.getAllConnectionsNoWait();
source.start(this); connectionFactory.start(backgroundProcessor); endpointManager.addListener(new InstantiatorRecoveryListener(backgroundProcessor, this)); endpointManager.addListener(new DataSerializerRecoveryListener(backgroundProcessor, this)); if (Boolean.getBoolean(ON_DISCONNECT_CLEAR_PDXTYPEIDS)) { endpointManager.addListener(new PdxRegistryRecoveryListener(this)); endpointManager.addListener(new LiveServerPinger(this));
verify(endpointManager).serverCrashed(endpoint);
@Override public void start(ScheduledExecutorService background) { try { denyList.start(background); endpointManager.addListener(endpointListener); // Use a separate timer for queue management tasks // We don't want primary recovery (and therefore user threads) to wait for // things like pinging connections for health checks. final String name = "queueTimer-" + this.pool.getName(); this.recoveryThread = LoggingExecutors.newScheduledThreadPool(name, 1, false); getState().start(background, getPool().getSubscriptionAckInterval()); // initialize connections initializeConnections(); scheduleRedundancySatisfierIfNeeded(redundancyRetryInterval); // When a server is removed from the denylist, try again // to establish redundancy (if we need to) DenyListListener denyListListener = new DenyListListenerAdapter() { @Override public void serverRemoved(ServerLocation location) { QueueManagerImpl.this.scheduleRedundancySatisfierIfNeeded(0); } }; denyList.addListener(denyListListener); factory.getDenyList().addListener(denyListListener); } finally { initializedLatch.countDown(); } }
this.eManager.serverCrashed(this.endpoint); if (isDebugEnabled) { logger.debug("Caught the following exception and will exit", e); ClientServerObserver clientServerObserver = ClientServerObserverHolder.getInstance(); clientServerObserver.beforeFailoverByCacheClientUpdater(this.location); this.eManager.serverCrashed(this.endpoint); String message = ": Caught the following exception and will exit: "; handleException(message, e);