Example usage for io.netty.channel EventLoopGroup shutdown

List of usage examples for io.netty.channel EventLoopGroup shutdown

Introduction

In this page you can find the example usage for io.netty.channel EventLoopGroup shutdown.

Prototype

@Override
@Deprecated
void shutdown();

Source Link

Usage

From source file:com.google.cloud.bigtable.grpc.BigtableSession.java

License:Open Source License

/**
 * Use {@link BigtableSession#BigtableSession(BigtableOptions)} instead;
 *///from   w  w w .j  a  v  a2s  . co  m
@Deprecated
public BigtableSession(BigtableOptions options, @SuppressWarnings("unused") @Nullable ExecutorService batchPool,
        @Nullable EventLoopGroup elg, @Nullable ScheduledExecutorService scheduledRetries) throws IOException {
    this(options);
    if (elg != null) {
        // There used to be a default EventLoopGroup if the elg is not passed in.
        // AbstractBigtableConnection never sent one in, but some users may have. With the shared
        // threadpools, the user supplied EventLoopGroup is no longer used. Previously, the elg would
        // have been shut down in BigtableSession.close(), so shut it here.
        elg.shutdown();
    }
    if (scheduledRetries != null) {
        // Just like the EventLoopGroup, the schedule retries threadpool used to be a user feature
        // that wasn't often used. It was shutdown in the close() method. Since it's no longer used,
        // shut it down immediately.
        scheduledRetries.shutdown();
    }
}

From source file:de.ruedigermoeller.reallive.client.wsgate.WebSocketGate.java

License:Open Source License

public void run() {
    // param(1) just example to show the thread model with 2 connected clients while live coding
    //        EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    // param(1) just example to show the thread model with 2 connected clients while live coding
    EventLoopGroup workerGroup = new NioEventLoopGroup(8);
    try {//from  www.  j a  va2s.c om

        // additional thread pool for blocking handler
        //            final EventExecutorGroup executorGroup = new DefaultEventExecutorGroup(8);

        final ServerBootstrap bootstrap = new ServerBootstrap();
        bootstrap.group(workerGroup).channel(NioServerSocketChannel.class)
                .childHandler(new ChannelInitializer<SocketChannel>() {
                    @Override
                    protected void initChannel(SocketChannel ch) throws Exception {
                        ch.pipeline().addLast(new HttpRequestDecoder(), new HttpObjectAggregator(65536),
                                new HttpResponseEncoder(), new WebSocketServerProtocolHandler("/websocket"),
                                new WebSocketGateChannelHandler(WebSocketGate.this)); // normal example without another thread pool

                        // register blocking or long lasting handler to additional thread pool
                        //                            ch.pipeline().addLast(executorGroup, new JSUGWebSocketHandler(channels));
                    }
                });

        final Channel channel;
        channel = bootstrap.bind(port).sync().channel();

        System.out.println("server started on port: " + port);
        channel.closeFuture().sync();

    } catch (InterruptedException e) {
        e.printStackTrace();

    } finally {
        workerGroup.shutdown();
    }
}