protected CacheClientNotifier getCacheClientNotifier() { return getAcceptor().getCacheClientNotifier(); }
String[] getConnectedGatewaySenders() { Set<String> uniqueIds; AcceptorImpl acceptor = ((CacheServerImpl) rcv.getServer()).getAcceptor(); Set<ServerConnection> serverConnections = acceptor.getAllServerConnections(); if (serverConnections != null && serverConnections.size() > 0) { uniqueIds = new HashSet<>(); for (ServerConnection conn : serverConnections) { uniqueIds.add(conn.getMembershipID()); } String[] allConnectedClientStr = new String[uniqueIds.size()]; return uniqueIds.toArray(allConnectedClientStr); } return new String[0]; }
private boolean isFiringMembershipEvents() { return this.acceptor.isRunning() && !(this.acceptor.getCachedRegionHelper().getCache()).isClosed() && !acceptor.getCachedRegionHelper().getCache().getCancelCriterion().isCancelInProgress(); }
public void registerSC(ServerConnection sc) { synchronized (this.syncLock) { if (!isRunning()) { finishCon(sc); return; } } getSelectorQueue().offer(sc); wakeupSelector(); }
@Override public void releaseTLCommBuffer() { if (!isSelector()) { return; } releaseCommBuffer(Message.setTLCommBuffer(null)); }
@Override public void setTLCommBuffer() { // The thread local will only be set if maxThreads has been set. if (!isSelector()) { return; } Message.setTLCommBuffer(takeCommBuffer()); }
if (isSelector()) { communicationMode = getCommunicationModeForSelector(socket); } else { communicationMode = getCommunicationModeForNonSelector(socket); if (handOffQueueInitialization(socket, communicationMode)) { return; boolean notForQueue = (communicationMode != ClientToServerForQueue); if (notForQueue) { int curCnt = this.getClientServerCnxCount(); if (curCnt >= this.maxConnections) { logger.warn( if (communicationMode.expectsConnectionRefusalMessage()) { try { refuseHandshake(socket.getOutputStream(), String.format("exceeded max-connections %s", Integer.valueOf(this.maxConnections)), closeSocket(socket); return; incClientServerCnxCount(); if (isSelector()) { serverConn.registerWithSelector(); } else {
ServerConnectionFactory serverConnectionFactory, long timeLimitMillis) throws IOException { this.securityService = internalCache.getSecurityService(); this.bindHostName = calcBindHostName(internalCache, bindHostName); this.connectionListener = listener == null ? new ConnectionListenerAdapter() : listener; this.notifyBySubscription = notifyBySubscription; if (getBindAddress() instanceof Inet6Address) { logger.warn( "Ignoring max-threads setting and using zero instead due to JRockit NIO bugs. See GemFire bug #40198"); HashSet tmp_hs = null; SystemTimer tmp_timer = null; if (isSelector()) { if (getCachedRegionHelper() != null) { gc = getCachedRegionHelper().getCache(); } else { gc = null; if (isSelector()) { if (this.socketCreator.useSSL()) { throw new IllegalArgumentException( this.serverSock.bind(new InetSocketAddress(getBindAddress(), port), backLog); break; } catch (SocketException b) { if (!treatAsBindException(b) || System.currentTimeMillis() > tilt) { throw b;
@Override public void run() { logger.info(":Cache server: Initializing {} server-to-client communication socket: {}", isPrimaryServerToClient ? "primary" : "secondary", socket); try { acceptor.getCacheClientNotifier().registerClient(socket, isPrimaryServerToClient, acceptor.getAcceptorId(), acceptor.isNotifyBySubscription()); } catch (IOException ex) { closeSocket(socket); if (acceptor.isRunning()) { if (!acceptor.loggedAcceptError) { acceptor.loggedAcceptError = true; if (ex instanceof SocketTimeoutException) { logger .warn("Cache server: failed accepting client connection due to socket timeout."); } else { logger.warn("Cache server: failed accepting client connection " + ex, ex); } } } } } }
long delta = System.nanoTime() - lastCheckedTime; if (checkRegisteredKeysInterval == 0 || delta >= checkRegisteredKeysInterval) { registeredKeys = checkRegisteredKeys(registeredKeys); lastCheckedTime = System.nanoTime(); finishCon(sc); } catch (IOException ex) { finishCon(sc); logger.warn("ignoring", ex); } catch (RuntimeException ex) { finishCon(sc); logger.warn("ignoring", ex); checkForStuckKeys(); finishCon(sc); continue; } catch (IOException ex) { finishCon(sc); if (isRunning()) { logger.warn("unexpected", ex); AcceptorImpl.this.pool.execute(sc); } catch (RejectedExecutionException rejected) { finishCon(sc); AcceptorImpl.this.stats.decThreadQueueSize(); if (!isRunning()) { break;
getAcceptor().getCacheClientNotifier().getClientProxy(this.proxyId); if (proxy != null && proxy.waitRemoval()) { proxy = getAcceptor().getCacheClientNotifier().getClientProxy(this.proxyId); ClientHealthMonitor chm = this.acceptor.getClientHealthMonitor(); synchronized (this.chmLock) { this.chmRegistered = true; this.acceptor.getConnectionListener().connectionOpened(registerClient, communicationMode);
private Map<String, ClientConnInfo> getUniqueClientIds() { Map<String, ClientConnInfo> uniqueIds = null; ServerConnection[] serverConnections = acceptor.getAllServerConnectionList(); Collection<CacheClientProxy> clientProxies = acceptor.getCacheClientNotifier().getClientProxies();
try { synchronized (syncLock) { if (!isRunning()) { return; shutdownSelectorIfIsSelector(); ClientHealthMonitor.shutdownInstance(); shutdownSCs(); this.clientNotifier.shutdown(this.acceptorId); shutdownPools(); this.stats.close(); if (!cache.isClosed()) { notifyCacheMembersOfClose();
private ExecutorService initializeServerConnectionThreadPool() throws IOException { String threadName = "ServerConnection on port " + this.localPort + " Thread "; ThreadInitializer threadInitializer = thread -> getStats().incConnectionThreadsCreated(); CommandWrapper commandWrapper = command -> { try { command.run(); } catch (CancelException e) { // bug 39463 // ignore } finally { ConnectionTable.releaseThreadsSockets(); } }; try { if (isSelector()) { return LoggingExecutors.newThreadPoolWithUnlimitedFeed(threadName, threadInitializer, commandWrapper, this.maxThreads, getStats().getCnxPoolHelper(), Integer.MAX_VALUE, getThreadMonitorObj()); } else { return LoggingExecutors.newThreadPoolWithSynchronousFeed(threadName, threadInitializer, commandWrapper, MINIMUM_MAX_CONNECTIONS, this.maxConnections, 0L); } } catch (IllegalArgumentException poolInitException) { this.stats.close(); this.serverSock.close(); throw poolInitException; } }
protected ServerToClientFunctionResultSender getResultSender() { ChunkedMessage msg = mock(ChunkedMessage.class); serverConnection = mock(ServerConnection.class); Function function = mock(Function.class); ExecuteFunctionOperationContext executeFunctionOperationContext = mock(ExecuteFunctionOperationContext.class); // sc.getAcceptor().isSelector(); AcceptorImpl acceptor = mock(AcceptorImpl.class); when(serverConnection.getAcceptor()).thenReturn(acceptor); when(acceptor.isSelector()).thenReturn(true); when(acceptor.isRunning()).thenReturn(true); return new ServerToClientFunctionResultSender(msg, 1, serverConnection, function, executeFunctionOperationContext); }
private Map<ClientProxyMembershipID, MutableInt> getCleanupProxyIdTable() { return acceptor.getClientHealthMonitor().getCleanupProxyIdTable(); }
if (getAcceptor().isRunning()) { this.acceptor.getClientHealthMonitor().removeConnection(this.proxyId, this); if (unregisterClient) { this.acceptor.getClientHealthMonitor().unregisterClient(this.proxyId, getAcceptor(), this.clientDisconnectedCleanly, this.clientDisconnectedException); this.acceptor.getConnectionListener().connectionClosed(clientDeparted, communicationMode);
boolean finished = false; try { handleNewClientConnection(socket, serverConnectionFactory); finished = true; } catch (RegionDestroyedException rde) { if (isRunning()) { if (!AcceptorImpl.this.loggedAcceptError) { AcceptorImpl.this.loggedAcceptError = true; closeSocket(socket); if (isRunning()) { AcceptorImpl.this.stats.decAcceptsInProgress();
while (isRunning()) { if (SystemFailure.getFailure() != null) { if (!isRunning()) { closeSocket(socket); break; handOffNewClientConnection(socket, serverConnectionFactory); } catch (InterruptedIOException e) { // Solaris only closeSocket(socket); if (isRunning()) { if (logger.isDebugEnabled()) { logger.debug("Aborted due to interrupt: {}", e); closeSocket(socket); if (isRunning()) { if (!this.loggedAcceptError) { this.loggedAcceptError = true; closeSocket(socket); throw e; } catch (Exception e) { closeSocket(socket); if (isRunning()) { logger.fatal("Cache server: Unexpected Exception", e);
this.acceptor = new AcceptorImpl(getPort(), getBindAddress(), getNotifyBySubscription(), getSocketBufferSize(), getMaximumTimeBetweenPings(), this.cache, getMaxConnections(), getMaxThreads(), getMaximumMessageCount(), getMessageTimeToLive(), this.loadMonitor, this.tcpNoDelay, serverConnectionFactory, 120000); this.acceptor.start(); this.advisor.handshake(); this.loadMonitor.start(new ServerLocation(getExternalAddress(), getPort()), acceptor.getStats());