protected void init() { this.inputBuffer = new InputBufferImpl(); this.readTimeout = (endpoint.getSoTimeout() > 0 ? endpoint.getSoTimeout() : Integer.MAX_VALUE); // Initialize the completion handler this.completionHandler = new CompletionHandler<Integer, NioChannel>() { @Override public void completed(Integer nBytes, NioChannel attachment) { if (nBytes < 0) { failed(new ClosedChannelException(), attachment); return; } if (nBytes > 0) { bbuf.flip(); bbuf.get(buf, pos, nBytes); lastValid = pos + nBytes; endpoint.processChannel(attachment, SocketStatus.OPEN_READ); } } @Override public void failed(Throwable exc, NioChannel attachment) { endpoint.removeEventChannel(attachment); endpoint.processChannel(attachment, SocketStatus.ERROR); } }; }
public AjpNioProtocol() { endpoint = new NioEndpoint(); cHandler = new AjpConnectionHandler(this); ((NioEndpoint) endpoint).setHandler(cHandler); setSoLinger(Constants.DEFAULT_CONNECTION_LINGER); setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT); setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY); // AJP does not use Send File ((NioEndpoint) endpoint).setUseSendfile(false); }
public AjpNioProcessor(int packetSize, NioEndpoint endpoint) { super(packetSize, endpoint); response.setOutputBuffer(new SocketOutputBuffer()); pool = endpoint.getSelectorPool(); }
public Http11NioProtocol() { endpoint = new NioEndpoint(); cHandler = new Http11ConnectionHandler(this); ((NioEndpoint) endpoint).setHandler(cHandler); setSoLinger(Constants.DEFAULT_CONNECTION_LINGER); setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT); setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY); }
/** * Send an action to the connector. * * @param actionCode Type of the action * @param param Action parameter */ @Override protected void actionInternal(ActionCode actionCode, Object param) { if (actionCode == ActionCode.ASYNC_COMPLETE) { if (asyncStateMachine.asyncComplete()) { ((NioEndpoint) endpoint) .processSocket(this.socketWrapper.getSocket(), SocketStatus.OPEN_READ, false); } } else if (actionCode == ActionCode.ASYNC_SETTIMEOUT) { if (param == null) return; long timeout = ((Long) param).longValue(); final KeyAttachment ka = (KeyAttachment) socketWrapper.getSocket().getAttachment(false); ka.setTimeout(timeout); } else if (actionCode == ActionCode.ASYNC_DISPATCH) { if (asyncStateMachine.asyncDispatch()) { ((NioEndpoint) endpoint) .processSocket(this.socketWrapper.getSocket(), SocketStatus.OPEN_READ, true); } } }
public NioSocketWrapper(NioChannel channel, NioEndpoint endpoint) { super(channel, endpoint); pool = endpoint.getSelectorPool(); socketBufferHandler = channel.getBufHandler(); }
public void setPollerThreadPriority(int threadPriority) { ((NioEndpoint) endpoint).setPollerThreadPriority(threadPriority); }
public void setAcceptorThreadPriority(int threadPriority) { ((NioEndpoint) endpoint).setAcceptorThreadPriority(threadPriority); }
public void setSelectorTimeout(long timeout) { ((NioEndpoint) endpoint).setSelectorTimeout(timeout); }
public void setPollerThreadCount(int count) { ((NioEndpoint) endpoint).setPollerThreadCount(count); }
// -------------------- Tcp setup -------------------- public void setOomParachute(int oomParachute) { ((NioEndpoint) endpoint).setOomParachute(oomParachute); }
public void setUseSendfile(boolean useSendfile) { ((NioEndpoint) endpoint).setUseSendfile(useSendfile); }
/** Close the channel */ private void close(NioChannel channel) { endpoint.closeChannel(channel); }