Java Code Examples for org.jboss.netty.bootstrap.ServerBootstrap#releaseExternalResources()

The following examples show how to use org.jboss.netty.bootstrap.ServerBootstrap#releaseExternalResources() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TajoPullServerService.java    From tajo with Apache License 2.0 6 votes vote down vote up
@Override
public void serviceStop() throws Exception {
  // TODO: check this wait
  accepted.close().awaitUninterruptibly(10, TimeUnit.SECONDS);
  if (selector != null) {
    ServerBootstrap bootstrap = new ServerBootstrap(selector);
    bootstrap.releaseExternalResources();
  }

  if (channelInitializer != null) {
    channelInitializer.destroy();
  }

  localFS.close();
  indexReaderCache.invalidateAll();

  super.serviceStop();
}
 
Example 2
Source File: ShuffleHandler.java    From tez with Apache License 2.0 6 votes vote down vote up
@Override
protected void serviceStop() throws Exception {
  accepted.close().awaitUninterruptibly(10, TimeUnit.SECONDS);
  if (selector != null) {
    ServerBootstrap bootstrap = new ServerBootstrap(selector);
    bootstrap.releaseExternalResources();
  }
  if (pipelineFact != null) {
    pipelineFact.destroy();
  }
  if (timer != null) {
    // Release this shared timer resource
    timer.stop();
  }
  if (stateDb != null) {
    stateDb.close();
  }
  super.serviceStop();
}
 
Example 3
Source File: ShuffleHandler.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
protected void serviceStop() throws Exception {
  accepted.close().awaitUninterruptibly(10, TimeUnit.SECONDS);
  if (selector != null) {
    ServerBootstrap bootstrap = new ServerBootstrap(selector);
    bootstrap.releaseExternalResources();
  }
  if (pipelineFact != null) {
    pipelineFact.destroy();
  }
  if (stateDb != null) {
    stateDb.close();
  }
  super.serviceStop();
}
 
Example 4
Source File: ShuffleHandler.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
protected void serviceStop() throws Exception {
  accepted.close().awaitUninterruptibly(10, TimeUnit.SECONDS);
  if (selector != null) {
    ServerBootstrap bootstrap = new ServerBootstrap(selector);
    bootstrap.releaseExternalResources();
  }
  if (pipelineFact != null) {
    pipelineFact.destroy();
  }
  if (stateDb != null) {
    stateDb.close();
  }
  super.serviceStop();
}
 
Example 5
Source File: TajoPullServerService.java    From incubator-tajo with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void stop() {
  try {
    accepted.close().awaitUninterruptibly(10, TimeUnit.SECONDS);
    ServerBootstrap bootstrap = new ServerBootstrap(selector);
    bootstrap.releaseExternalResources();
    pipelineFact.destroy();

    localFS.close();
  } catch (Throwable t) {
    LOG.error(t);
  } finally {
    super.stop();
  }
}
 
Example 6
Source File: PullServerAuxService.java    From incubator-tajo with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void stop() {
  try {
    accepted.close().awaitUninterruptibly(10, TimeUnit.SECONDS);
    ServerBootstrap bootstrap = new ServerBootstrap(selector);
    bootstrap.releaseExternalResources();
    pipelineFact.destroy();

    localFS.close();
  } catch (Throwable t) {
    LOG.error(t);
  } finally {
    super.stop();
  }
}
 
Example 7
Source File: ShuffleHandler.java    From tez with Apache License 2.0 5 votes vote down vote up
public void stop() throws Exception {
  accepted.close().awaitUninterruptibly(10, TimeUnit.SECONDS);
  if (selector != null) {
    ServerBootstrap bootstrap = new ServerBootstrap(selector);
    bootstrap.releaseExternalResources();
  }
  if (pipelineFact != null) {
    pipelineFact.destroy();
  }
}
 
Example 8
Source File: RpcServerBootstrap.java    From voyage with Apache License 2.0 4 votes vote down vote up
private void initHttpBootstrap(int myport) {
	logger.info("initHttpBootstrap...........");
	final ServerConfig serverConfig = new ServerConfig(myport);
	final ChannelGroup channelGroup = new DefaultChannelGroup(getClass().getName());
	bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(
			//建议用ThreadPoolExecutor代替
			Executors.newCachedThreadPool(),
			Executors.newCachedThreadPool(), serverConfig.getThreadCnt()));
	//设置常见参数
	bootstrap.setOption("tcpNoDelay","true");//禁用nagle算法
	bootstrap.setOption("reuseAddress", "true");
	bootstrap.setOption("SO_RCVBUF",1024*128);
	bootstrap.setOption("SO_SNDBUF",1024*128);
	timer = new HashedWheelTimer();
	bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
		public ChannelPipeline getPipeline() throws Exception {
			ChannelPipeline pipeline = Channels.pipeline();
			int readTimeout = serverConfig.getReadTimeout();
			if (readTimeout > 0) {
				pipeline.addLast("timeout", new ReadTimeoutHandler(timer, readTimeout, TimeUnit.MILLISECONDS));
			}
			pipeline.addLast("decoder", new RpcRequestDecode());
			pipeline.addLast("encoder", new RpcResponseEncode());
			pipeline.addLast("handler", new NettyRpcServerHandler(channelGroup));
			return pipeline;
		}
	});
	
	int port = serverConfig.getPort();
	if (!checkPortConfig(port)) {
		throw new IllegalStateException("port: " + port + " already in use!");
	}

	Channel channel = bootstrap.bind(new InetSocketAddress(port));
	channelGroup.add(channel);
	logger.info("voyage server started");

	waitForShutdownCommand();
	ChannelGroupFuture future = channelGroup.close();
	future.awaitUninterruptibly();
	bootstrap.releaseExternalResources();
	timer.stop();
	timer = null;

	logger.info("voyage server stoped");

}
 
Example 9
Source File: NettyMapOutputHttpServer.java    From RDFS with Apache License 2.0 4 votes vote down vote up
public synchronized void stop() {
  accepted.close().awaitUninterruptibly(10, TimeUnit.SECONDS);
  ServerBootstrap bootstrap = new ServerBootstrap(channelFactory);
  bootstrap.releaseExternalResources();
}