Examples of SocketChannel


Examples of com.facebook.presto.jdbc.internal.netty.channel.socket.SocketChannel

            }
        });
    }

    void connectReal(final SocketAddress remoteAddress, final ChannelFuture future) {
        final SocketChannel virtualChannel = this;
        realChannel.connect(remoteAddress).addListener(new ChannelFutureListener() {
            public void operationComplete(ChannelFuture f) {
                final String serverName = config.getServerName();
                final int serverPort = ((InetSocketAddress) remoteAddress).getPort();
                final String serverPath = config.getServerPath();
View Full Code Here

Examples of com.maverick.multiplex.SocketChannel

    class SocketChannelFactory implements ChannelFactory {

            public Channel createChannel(MultiplexedConnection connection, String type) {
             
              if(type.equals(SocketChannel.CHANNEL_TYPE))
                    return new SocketChannel();
              else
                return null;
            }
View Full Code Here

Examples of io.netty.channel.socket.SocketChannel

    private static ChannelListener<StreamConnection> switchToHornetQProtocol(final HornetQServer hornetqServer, final String acceptorName) {
        return new ChannelListener<StreamConnection>() {
            @Override
            public void handleEvent(final StreamConnection connection) {
                MESSAGING_LOGGER.debugf("Switching to %s protocol for %s http-acceptor", HORNETQ_REMOTING, acceptorName);
                SocketChannel channel = new WrappingXnioSocketChannel(connection);
                RemotingService remotingService = hornetqServer.getRemotingService();

                NettyAcceptor acceptor = (NettyAcceptor)remotingService.getAcceptor(acceptorName);
                acceptor.transfer(channel);
                connection.getSourceChannel().resumeReads();
View Full Code Here

Examples of java.nio.channels.SocketChannel

      String initial = createInitalLineAndHeaders();     
      responseData.prepend(initial);
      headersCreated = true;
    }

    SocketChannel channel = (SocketChannel) key.channel();
    responseData.flip()// prepare for write
    try {
      channel.write(responseData.getByteBuffer());
    } catch (IOException e) {
      logger.error("ClosedChannelException during channel.write(): {}", e.getMessage());
      Closeables.closeQuietly(key.channel());
    }
    long bytesFlushed = responseData.position();
View Full Code Here

Examples of java.nio.channels.SocketChannel

   * inserted to the HTTP response.
   *
   */
  public long finish() {
    long bytesWritten = 0;
    SocketChannel clientChannel = (SocketChannel) key.channel();
    if (clientChannel.isOpen()) {
      if (!headersCreated) {
        setEtagAndContentLength();
      }
      bytesWritten = flush();
    }
View Full Code Here

Examples of java.nio.channels.SocketChannel

  }
 
  @Override
  public void handleAccept(SelectionKey key) throws IOException {
    logger.debug("handle accept...");
    SocketChannel clientChannel = ((ServerSocketChannel) key.channel()).accept();
    clientChannel.configureBlocking(false);
    IOLoop.INSTANCE.addHandler(clientChannel, this, SelectionKey.OP_READ, ByteBuffer.allocate(READ_BUFFER_SIZE));
  }
View Full Code Here

Examples of java.nio.channels.SocketChannel

  }

  @Override
  public void handleRead(SelectionKey key) throws IOException {
    logger.debug("handle read...");
    SocketChannel clientChannel = (SocketChannel) key.channel();
    HttpRequest request = getHttpRequest(key, clientChannel);
   
    if (request.isKeepAlive()) {
      IOLoop.INSTANCE.addKeepAliveTimeout(
          clientChannel,
View Full Code Here

Examples of java.nio.channels.SocketChannel

  public void handleWrite(SelectionKey key) {
    logger.debug("handle write...");
    DynamicByteBuffer dbb = (DynamicByteBuffer) key.attachment();
    logger.debug("pending data about to be written");
    ByteBuffer toSend = dbb.getByteBuffer();
    SocketChannel channel = ((SocketChannel) key.channel());
    try {
      toSend.flip()// prepare for write
      long bytesWritten = channel.write(toSend);
      if (IOLoop.INSTANCE.hasKeepAliveTimeout(channel)) {
        prolongKeepAliveTimeout(channel);
      }
      logger.debug("sent {} bytes to wire", bytesWritten);
      if (!toSend.hasRemaining()) {
View Full Code Here

Examples of java.nio.channels.SocketChannel

   * Should only be invoked by the IOLoop
   */
  @Override
  public void handleConnect(SelectionKey key) throws IOException {
    logger.debug("handle connect...");
    SocketChannel sc = (SocketChannel) channel;
    if (sc.isConnectionPending()) {
      try {
        sc.finishConnect();
        invokeConnectSuccessfulCallback();
        interestOps &= ~SelectionKey.OP_CONNECT;
        IOLoop.INSTANCE.updateHandler(channel, interestOps |= SelectionKey.OP_READ);
      } catch (ConnectException e) {
        logger.warn("Connect failed: {}", e.getMessage());
View Full Code Here

Examples of java.nio.channels.SocketChannel

        public void handle(SelectionKey key) throws ClosedChannelException, IOException {
            if(!key.isValid()) {
                return;
            }
            ServerSocketChannel serverChannel = (ServerSocketChannel) key.channel();
            SocketChannel socketChannel = serverChannel.accept();
            if(LOG.isDebugEnabled()) {
                LOG.debug("accepted a connection from " + socketChannel.socket().getInetAddress());
            }
            socketChannel.configureBlocking(false);
            socketChannel.register(key.selector(), SelectionKey.OP_READ, nextHandler);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.