Examples of NioSocketChannel


Examples of io.netty.channel.socket.nio.NioSocketChannel

    }

    public TCPWrap(NodeProcess process, int fd) throws Exception {
        super(process, false);
        SocketChannel socketChannel = UnsafeTcp.attach(fd);
        NioSocketChannel channel = new NioSocketChannel(socketChannel);
        this.channelFuture = channel.newSucceededFuture();
        channel.pipeline().addLast("emit.afterConnect", new AfterConnectEventHandler(this.process, TCPWrap.this));
        channel.pipeline().addLast("emit.eof", new EOFEventHandler(this.process, TCPWrap.this));
        channel.pipeline().addLast("handle", new UnrefHandler(this));
        process.getEventLoop().getEventLoopGroup().register(channel);
    }
View Full Code Here

Examples of io.netty.channel.socket.nio.NioSocketChannel

    i++;
    ch.write(new Command(set, numToBytes(i, false), VALUE));
  }

  public static void main(String[] args) throws Exception {
    final SocketChannel ch = new NioSocketChannel();
    new NioEventLoopGroup().register(ch);
    final long start = System.currentTimeMillis();
    ch.pipeline().addLast(new RedisCommandEncoder(), new RedisReplyDecoder());
    ch.connect(new InetSocketAddress("localhost", 6379)).addListener(new ChannelFutureListener() {
      @Override
      public void operationComplete(ChannelFuture channelFuture) throws Exception {
        write(ch);
      }
    });
View Full Code Here

Examples of io.netty.channel.socket.nio.NioSocketChannel

    group.register(socketChannel);
  }

  public static Promise<RedisClientBase> connect(String host, int port) {
    final Queue<Promise<Reply>> queue = new LinkedList<>();
    SocketChannel socketChannel = new NioSocketChannel();
    final RedisClientBase client = new RedisClientBase(socketChannel, queue);
    socketChannel.pipeline().addLast(new RedisCommandEncoder(), new RedisReplyDecoder(),
            new SimpleChannelInboundHandler<Reply<?>>() {
              @Override
              protected void channelRead0(ChannelHandlerContext channelHandlerContext, Reply<?> reply) throws Exception {
                Promise<Reply> poll;
                synchronized (client) {
                  poll = queue.poll();
                  if (poll == null) {
                    throw new IllegalStateException("Promise queue is empty, received reply");
                  }
                }
                poll.set(reply);
              }
            });
    final Promise<RedisClientBase> promise = new Promise<>();
    socketChannel.connect(new InetSocketAddress(host, port)).addListener(new ChannelFutureListenerPromiseAdapter<>(promise, client));
    return promise;
  }
View Full Code Here

Examples of io.netty.channel.socket.nio.NioSocketChannel

public class RegisterSocket {

    public void register(java.nio.channels.SocketChannel socket, EventLoopGroup egroup) {
        java.nio.channels.SocketChannel mySocket = socket;

        SocketChannel ch = new NioSocketChannel(mySocket);
        EventLoopGroup group = egroup;
        group.register(ch);

    }
View Full Code Here

Examples of io.netty.channel.socket.nio.NioSocketChannel

    private static final class NioChannelFactory implements ChannelFactory {

        public Channel newChannel() {
            try {
                return new NioSocketChannel(SocketChannel.open());
            } catch (IOException ioe) {
                return Exceptions.chuck(ioe);
            }
        }
View Full Code Here

Examples of org.jboss.netty.channel.socket.nio.NioSocketChannel

    }

    @Override
    public void executeInIoThread(Runnable runnable)
    {
        NioSocketChannel nioSocketChannel = (NioSocketChannel) getNettyChannel();
        nioSocketChannel.getWorker().executeInIoThread(runnable, true);
    }
View Full Code Here

Examples of org.jboss.netty.channel.socket.nio.NioSocketChannel

    }

    @Override
    public void executeInIoThread(Runnable runnable)
    {
        NioSocketChannel nioSocketChannel = (NioSocketChannel) getNettyChannel();
        nioSocketChannel.getWorker().executeInIoThread(runnable, true);
    }
View Full Code Here

Examples of org.jboss.netty.channel.socket.nio.NioSocketChannel

    }

    @Override
    public void executeInIoThread(Runnable runnable)
    {
        NioSocketChannel nioSocketChannel = (NioSocketChannel) getNettyChannel();
        nioSocketChannel.getWorker().executeInIoThread(runnable, true);
    }
View Full Code Here

Examples of org.jboss.netty.channel.socket.nio.NioSocketChannel

    }

    @Override
    public void executeInIoThread(Runnable runnable)
    {
        NioSocketChannel nioSocketChannel = (NioSocketChannel) getNettyChannel();
        nioSocketChannel.getWorker().executeInIoThread(runnable, true);
    }
View Full Code Here

Examples of org.jboss.netty.channel.socket.nio.NioSocketChannel

    }

    @Override
    public void executeInIoThread(Runnable runnable)
    {
        NioSocketChannel nioSocketChannel = (NioSocketChannel) getNettyChannel();
        nioSocketChannel.getWorker().executeInIoThread(runnable, true);
    }
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.