Examples of EventLoopGroup


Examples of io.netty.channel.EventLoopGroup

    }

    protected EventLoopGroup getWorkerGroup() {

        // prefer using explicit configured thread pools
        EventLoopGroup wg = configuration.getWorkerGroup();
       
        if (wg == null) {
            // create new pool which we should shutdown when stopping as its not
            // shared
            workerGroup = new NettyWorkerPoolBuilder().withWorkerCount(configuration.getWorkerCount())
View Full Code Here

Examples of io.netty.channel.EventLoopGroup

            out = System.err;
        } else {
            return null;
        }

        EventLoopGroup eventLoopGroup = process.getEventLoop().getEventLoopGroup();
        Channel channel = NioOutputStreamChannel.create(process, out);
        channel.config().setAutoRead(false);
        channel.pipeline().addLast( new DataEventHandler( process, handle ));
        eventLoopGroup.register(channel);

        return channel.newSucceededFuture();
    }
View Full Code Here

Examples of io.netty.channel.EventLoopGroup

public class ReadStream {

    public static ChannelFuture create(NodeProcess process, int fd, StreamWrap handle) throws IOException {
        if (fd == 0) {
            InputStream in = System.in;
            EventLoopGroup eventLoopGroup = process.getEventLoop().getEventLoopGroup();

            Channel channel = NioInputStreamChannel.create(process, in);
            channel.config().setAutoRead(false);
            channel.pipeline().addLast( new DataEventHandler( process, handle ) );
            eventLoopGroup.register(channel);

            return channel.newSucceededFuture();
        }

        return null;
View Full Code Here

Examples of io.netty.channel.EventLoopGroup

    abstract public boolean isContext(Object global);


    protected Nodyn(NodynConfig config, Vertx vertx, boolean controlLifeCycle) {
        EventLoopGroup elg = ((VertxInternal) vertx).getEventLoopGroup();
        this.eventLoop = new EventLoop(elg, controlLifeCycle);
        this.vertx = vertx;
        this.config = config;
        this.completionHandler = new CompletionHandler();
    }
View Full Code Here

Examples of io.netty.channel.EventLoopGroup

    /**
     * Start server
     */
    public void start() {
        EventLoopGroup bossGroup = new NioEventLoopGroup();
        EventLoopGroup workerGroup = new NioEventLoopGroup();

        pipelineFactory.start(configCopy, namespacesHub);
        ServerBootstrap b = new ServerBootstrap();
        b.group(bossGroup, workerGroup)
            .option(ChannelOption.TCP_NODELAY, true)
View Full Code Here

Examples of io.netty.channel.EventLoopGroup

        if (!file.canRead()) {
            throw new FileNotFoundException(FILE);
        }

        // Configure the client.
        EventLoopGroup group = new NioEventLoopGroup();

        // setup the factory: here using a mixed memory/disk based on size threshold
        HttpDataFactory factory = new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE); // Disk if MINSIZE exceed

        DiskFileUpload.deleteOnExitTemporaryFile = true; // should delete file on exit (in normal exit)
        DiskFileUpload.baseDirectory = null; // system temp directory
        DiskAttribute.deleteOnExitTemporaryFile = true; // should delete file on exit (in normal exit)
        DiskAttribute.baseDirectory = null; // system temp directory

        try {
            Bootstrap b = new Bootstrap();
            b.group(group).channel(NioSocketChannel.class).handler(new HttpUploadClientIntializer(sslCtx));

            // Simple Get form: no factory used (not usable)
            List<Entry<String, String>> headers = formget(b, host, port, get, uriSimple);
            if (headers == null) {
                factory.cleanAllHttpData();
                return;
            }

            // Simple Post form: factory used for big attributes
            List<InterfaceHttpData> bodylist = formpost(b, host, port, uriSimple, file, factory, headers);
            if (bodylist == null) {
                factory.cleanAllHttpData();
                return;
            }

            // Multipart Post form: factory used
            formpostmultipart(b, host, port, uriFile, factory, headers, bodylist);
        } finally {
            // Shut down executor threads to exit.
            group.shutdownGracefully();

            // Really clean all temporary files if they still exist
            factory.cleanAllHttpData();
        }
    }
View Full Code Here

Examples of io.netty.channel.EventLoopGroup

            sslCtx = SslContext.newClientContext(InsecureTrustManagerFactory.INSTANCE);
        } else {
            sslCtx = null;
        }

        EventLoopGroup group = new NioEventLoopGroup();
        try {
            // Connect with V13 (RFC 6455 aka HyBi-17). You can change it to V08 or V00.
            // If you change it to V00, ping is not supported and remember to change
            // HttpResponseDecoder to WebSocketHttpResponseDecoder in the pipeline.
            final WebSocketClientHandler handler =
                    new WebSocketClientHandler(
                            WebSocketClientHandshakerFactory.newHandshaker(
                                    uri, WebSocketVersion.V13, null, false, new DefaultHttpHeaders()));

            Bootstrap b = new Bootstrap();
            b.group(group)
             .channel(NioSocketChannel.class)
             .handler(new ChannelInitializer<SocketChannel>() {
                 @Override
                 protected void initChannel(SocketChannel ch) {
                     ChannelPipeline p = ch.pipeline();
                     if (sslCtx != null) {
                         p.addLast(sslCtx.newHandler(ch.alloc(), host, port));
                     }
                     p.addLast(
                             new HttpClientCodec(),
                             new HttpObjectAggregator(8192),
                             handler);
                 }
             });

            Channel ch = b.connect(uri.getHost(), port).sync().channel();
            handler.handshakeFuture().sync();

            BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
            while (true) {
                String msg = console.readLine();
                if (msg == null) {
                    break;
                } else if ("bye".equals(msg.toLowerCase())) {
                    ch.writeAndFlush(new CloseWebSocketFrame());
                    ch.closeFuture().sync();
                    break;
                } else if ("ping".equals(msg.toLowerCase())) {
                    WebSocketFrame frame = new PingWebSocketFrame(Unpooled.wrappedBuffer(new byte[] { 8, 1, 8, 1 }));
                    ch.writeAndFlush(frame);
                } else {
                    WebSocketFrame frame = new TextWebSocketFrame(msg);
                    ch.writeAndFlush(frame);
                }
            }
        } finally {
            group.shutdownGracefully();
        }
    }
View Full Code Here

Examples of io.netty.channel.EventLoopGroup

    /**
     * Start Gremlin Server with {@link Settings} provided to the constructor.
     */
    public void run() throws Exception {
        final EventLoopGroup bossGroup = new NioEventLoopGroup(settings.threadPoolBoss);
        final EventLoopGroup workerGroup = new NioEventLoopGroup(settings.threadPoolWorker);

        final BasicThreadFactory threadFactory = new BasicThreadFactory.Builder().namingPattern("gremlin-%d").build();
        final EventExecutorGroup gremlinGroup = new DefaultEventExecutorGroup(settings.gremlinPool, threadFactory);

        try {
            final ServerBootstrap b = new ServerBootstrap();

            // when high value is reached then the channel becomes non-writeable and stays like that until the
            // low value is so that there is time to recover
            b.childOption(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, settings.writeBufferLowWaterMark);
            b.childOption(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, settings.writeBufferHighWaterMark);
            b.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);

            final GremlinExecutor gremlinExecutor = initializeGremlinExecutor(gremlinGroup, workerGroup);
            final Channelizer channelizer = createChannelizer(settings);
            channelizer.init(settings, gremlinExecutor, gremlinGroup, graphs.get(), workerGroup);
            b.group(bossGroup, workerGroup)
                    .channel(NioServerSocketChannel.class)
                    .childHandler(channelizer);

            ch = b.bind(settings.host, settings.port).sync().channel();
            logger.info("Gremlin Server configured with worker thread pool of {} and boss thread pool of {}",
                    settings.threadPoolWorker, settings.threadPoolBoss);
            logger.info("Channel started at port {}.", settings.port);

            serverReady.ifPresent(future -> future.complete(null));

            ch.closeFuture().sync();
        } finally {
            logger.info("Shutting down thread pools");

            gremlinGroup.shutdownGracefully();
            bossGroup.shutdownGracefully();
            workerGroup.shutdownGracefully();

            logger.info("Gremlin Server - shutdown complete");
        }
    }
View Full Code Here

Examples of io.netty.channel.EventLoopGroup

        }
    }

    protected void startServerBootstrap() {
        // prefer using explicit configured thread pools
        EventLoopGroup bg = configuration.getBossGroup();
        EventLoopGroup wg = configuration.getWorkerGroup();

        if (bg == null) {
            // create new pool which we should shutdown when stopping as its not shared
            bossGroup = new NettyServerBossPoolBuilder()
                    .withBossCount(configuration.getBossCount())
View Full Code Here

Examples of io.netty.channel.EventLoopGroup

        // noop
    }

    protected void startServerBootstrap() throws Exception {
        // create non-shared worker pool
        EventLoopGroup wg = configuration.getWorkerGroup();
        if (wg == null) {
            // create new pool which we should shutdown when stopping as its not shared
            workerGroup = new NettyWorkerPoolBuilder()
                    .withWorkerCount(configuration.getWorkerCount())
                    .withName("NettyServerTCPWorker")
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.