@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()); }
private void shutdownSelectorIfIsSelector() { if (isSelector()) { this.hsTimer.cancel(); if (this.tmpSel != null) { try { this.tmpSel.close(); } catch (IOException ignore) { } } try { wakeupSelector(); this.selector.close(); } catch (IOException ignore) { } if (this.selectorThread != null) { this.selectorThread.interrupt(); } this.commBufferQueue.clear(); } }
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); }
@Override protected ServerToClientFunctionResultSender getResultSender() { ChunkedMessage msg = mock(ChunkedMessage.class); serverConnection = mock(ServerConnection.class); Function function = mock(Function.class); ExecuteFunctionOperationContext executeFunctionOperationContext = mock(ExecuteFunctionOperationContext.class); AcceptorImpl acceptor = mock(AcceptorImpl.class); when(serverConnection.getAcceptor()).thenReturn(acceptor); when(acceptor.isSelector()).thenReturn(true); when(acceptor.isRunning()).thenReturn(true); return new ServerToClientFunctionResultSender65(msg, 1, serverConnection, function, executeFunctionOperationContext); } }
public ServerToClientFunctionResultSender(ChunkedMessage msg, int messageType, ServerConnection sc, Function function, ExecuteFunctionOperationContext authzContext) { this.msg = msg; this.msg.setVersion(sc.getClientVersion()); this.messageType = messageType; this.sc = sc; this.fn = function; this.authContext = authzContext; this.isSelector = sc.getAcceptor().isSelector(); if (this.isSelector) { this.commBuffer = msg.getCommBuffer(); } }
thread.start(); if (isSelector()) { this.selectorThread = new LoggingThread("Cache Server Selector " + this.serverSock.getInetAddress() + ":"
if (isSelector()) { communicationMode = getCommunicationModeForSelector(socket); } else { incClientServerCnxCount(); if (isSelector()) { serverConn.registerWithSelector(); } else {
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; } }
HashSet tmp_hs = null; SystemTimer tmp_timer = null; if (isSelector()) { final long tilt = System.currentTimeMillis() + timeLimitMillis; if (isSelector()) { if (this.socketCreator.useSSL()) { throw new IllegalArgumentException(
void initStreams(Socket s, int socketBufferSize, MessageStats messageStats) { try { if (getAcceptor().isSelector()) { // set it on the message to null. This causes Message // to fetch it from a thread local. That way we only need // one per thread in our selector thread pool instead of // one per connection. commBuffer = null; } else { commBuffer = allocateCommBuffer(socketBufferSize, s); } requestMessage.setComms(this, theSocket, commBuffer, messageStats); replyMessage.setComms(this, theSocket, commBuffer, messageStats); responseMessage.setComms(this, theSocket, commBuffer, messageStats); errorMessage.setComms(this, theSocket, commBuffer, messageStats); chunkedResponseMessage.setComms(this, theSocket, commBuffer, messageStats); queryResponseMessage.setComms(this, theSocket, commBuffer, messageStats); executeFunctionResponseMessage.setComms(this, theSocket, commBuffer, messageStats); registerInterestResponseMessage.setComms(this, theSocket, commBuffer, messageStats); keySetResponseMessage.setComms(this, theSocket, commBuffer, messageStats); } catch (RuntimeException re) { throw re; } catch (Exception e) { logger.fatal(e.getMessage(), e); } }
setOwner(); if (getAcceptor().isSelector()) { boolean finishedMessage = false; try {