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);
 }
Esempio n. 3
0
  public AjpNioProcessor(int packetSize, NioEndpoint endpoint) {

    super(packetSize, endpoint);

    response.setOutputBuffer(new SocketOutputBuffer());

    pool = endpoint.getSelectorPool();
  }
Esempio n. 4
0
 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);
 }
Esempio n. 5
0
  /**
   * 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);
      }
    }
  }
Esempio n. 6
0
 public NioSocketWrapper(NioChannel channel, NioEndpoint endpoint) {
   super(channel, endpoint);
   pool = endpoint.getSelectorPool();
   socketBufferHandler = channel.getBufHandler();
 }
Esempio n. 7
0
 public void setPollerThreadPriority(int threadPriority) {
   ((NioEndpoint) endpoint).setPollerThreadPriority(threadPriority);
 }
Esempio n. 8
0
 public void setAcceptorThreadPriority(int threadPriority) {
   ((NioEndpoint) endpoint).setAcceptorThreadPriority(threadPriority);
 }
Esempio n. 9
0
 public void setSelectorTimeout(long timeout) {
   ((NioEndpoint) endpoint).setSelectorTimeout(timeout);
 }
Esempio n. 10
0
 public void setPollerThreadCount(int count) {
   ((NioEndpoint) endpoint).setPollerThreadCount(count);
 }
Esempio n. 11
0
 // -------------------- Tcp setup --------------------
 public void setOomParachute(int oomParachute) {
   ((NioEndpoint) endpoint).setOomParachute(oomParachute);
 }
Esempio n. 12
0
 public void setUseSendfile(boolean useSendfile) {
   ((NioEndpoint) endpoint).setUseSendfile(useSendfile);
 }
 /** Close the channel */
 private void close(NioChannel channel) {
   endpoint.closeChannel(channel);
 }