本文整理汇总了Java中org.jboss.netty.handler.timeout.ReadTimeoutHandler类的典型用法代码示例。如果您正苦于以下问题:Java ReadTimeoutHandler类的具体用法?Java ReadTimeoutHandler怎么用?Java ReadTimeoutHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ReadTimeoutHandler类属于org.jboss.netty.handler.timeout包,在下文中一共展示了ReadTimeoutHandler类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPipeline
import org.jboss.netty.handler.timeout.ReadTimeoutHandler; //导入依赖的package包/类
@Override
public ChannelPipeline getPipeline() throws Exception {
RPCChannelHandler channelHandler =
new RPCChannelHandler(syncManager, rpcService);
IdleStateHandler idleHandler =
new IdleStateHandler(timer, 5, 10, 0);
ReadTimeoutHandler readTimeoutHandler =
new ReadTimeoutHandler(timer, 30);
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addLast("idle", idleHandler);
pipeline.addLast("timeout", readTimeoutHandler);
pipeline.addLast("handshaketimeout",
new HandshakeTimeoutHandler(channelHandler, timer, 10));
pipeline.addLast("frameDecoder",
new ThriftFrameDecoder(maxFrameSize));
pipeline.addLast("frameEncoder",
new ThriftFrameEncoder());
pipeline.addLast("handler", channelHandler);
return pipeline;
}
示例2: connect
import org.jboss.netty.handler.timeout.ReadTimeoutHandler; //导入依赖的package包/类
@Override
public void connect() {
workerService = createWorkerService(getThreadPoolType(CollectorProperties.WRITER.COLLECTOR_WORKER_THREAD_POOL));
workerbossService = createWorkderBossService(getThreadPoolType(CollectorProperties.WRITER.COLLECTOR_WORKERBOSS_THREAD_POOL));
channelFactory = new NioServerSocketChannelFactory(workerbossService,
workerService);
bootstrap = new ServerBootstrap(channelFactory);
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
return Channels.pipeline(ipFilterHandler,
new MessageFrameDecoder(), new ReadTimeoutHandler(
HashedWheelTimerFactory.getInstance(),
readTimeout, TimeUnit.MILLISECONDS),
metricsHandler, channelHandler);
}
});
bootstrap.bind(new InetSocketAddress(port));
}
示例3: init
import org.jboss.netty.handler.timeout.ReadTimeoutHandler; //导入依赖的package包/类
private void init(IOFSwitchManager switchManager, Timer timer,
INewOFConnectionListener connectionListener,
IDebugCounterService debugCounters,
@Nonnull List<U32> ofBitmaps,
@Nonnull OFFactory defaultFactory) {
this.switchManager = switchManager;
this.connectionListener = connectionListener;
this.timer = timer;
this.debugCounters = debugCounters;
this.defaultFactory = defaultFactory;
this.ofBitmaps = ofBitmaps;
this.idleHandler = new IdleStateHandler(
timer,
PipelineIdleReadTimeout.MAIN,
PipelineIdleWriteTimeout.MAIN,
0);
this.readTimeoutHandler = new ReadTimeoutHandler(timer, 30);
}
示例4: getPipeline
import org.jboss.netty.handler.timeout.ReadTimeoutHandler; //导入依赖的package包/类
/**
* creates a new pipeline for interacting with the
* controller. This is where the controllerHandler and
* the timeouthandler come into play
* @return the pipeline (ChannelPipeline) for a new Socket.
*/
private ChannelPipeline getPipeline(){
ChannelPipeline pipe = Channels.pipeline();
ChannelHandler idleHandler = new IdleStateHandler(timer, 20, 25, 0);
ChannelHandler readTimeoutHandler = new ReadTimeoutHandler(timer, 30);
OFControllerChannelHandler controllerHandler = new OFControllerChannelHandler();
pipe.addLast("ofmessagedecoder", new OFMessageDecoder());
pipe.addLast("ofmessageencoder", new OFMessageEncoder());
pipe.addLast("idle", idleHandler);
pipe.addLast("timeout", readTimeoutHandler);
pipe.addLast("handshaketimeout",
new ControllerHandshakeTimeoutHandler(controllerHandler, timer, 15));
pipe.addLast("handler", controllerHandler);
return pipe;
}
示例5: OpenflowPipelineFactory
import org.jboss.netty.handler.timeout.ReadTimeoutHandler; //导入依赖的package包/类
public OpenflowPipelineFactory(Controller controller,
ThreadPoolExecutor pipelineExecutor,
SSLContext sslContext) {
super();
this.controller = controller;
this.pipelineExecutor = pipelineExecutor;
this.timer = new HashedWheelTimer();
this.idleHandler = new IdleStateHandler(timer, 20, 25, 0);
this.readTimeoutHandler = new ReadTimeoutHandler(timer, 30);
this.sslContext = sslContext;
}
示例6: BgpPipelineFactory
import org.jboss.netty.handler.timeout.ReadTimeoutHandler; //导入依赖的package包/类
/**
* Constructor to initialize the values.
*
* @param bgpController parent controller
* @param isBgpServ if it is a server or remote peer
*/
public BgpPipelineFactory(BgpController bgpController, boolean isBgpServ) {
super();
this.isBgpServ = isBgpServ;
this.bgpController = bgpController;
/* hold time */
this.readTimeoutHandler = new ReadTimeoutHandler(TIMER, bgpController.getConfig().getHoldTime());
}
示例7: init
import org.jboss.netty.handler.timeout.ReadTimeoutHandler; //导入依赖的package包/类
private void init(IOFSwitchManager switchManager, Timer timer,
INewOFConnectionListener connectionListener,
IDebugCounterService debugCounters) {
this.switchManager = switchManager;
this.connectionListener = connectionListener;
this.timer = timer;
this.debugCounters = debugCounters;
this.idleHandler = new IdleStateHandler(
timer,
PipelineIdleReadTimeout.MAIN,
PipelineIdleWriteTimeout.MAIN,
0);
this.readTimeoutHandler = new ReadTimeoutHandler(timer, 30);
}
示例8: OpenflowPipelineFactory
import org.jboss.netty.handler.timeout.ReadTimeoutHandler; //导入依赖的package包/类
public OpenflowPipelineFactory(Controller controller,
ThreadPoolExecutor pipelineExecutor) {
super();
this.controller = controller;
this.pipelineExecutor = pipelineExecutor;
this.timer = new HashedWheelTimer();
this.idleHandler = new IdleStateHandler(timer, 20, 25, 0);
this.readTimeoutHandler = new ReadTimeoutHandler(timer, 30);
}
示例9: getPipeline
import org.jboss.netty.handler.timeout.ReadTimeoutHandler; //导入依赖的package包/类
@Override
public ChannelPipeline getPipeline() throws Exception {
final ChannelPipeline pipeline = new DefaultChannelPipeline();
pipeline.addLast("timeout", new ReadTimeoutHandler(timer, 10));
pipeline.addLast("encoder", new RS2Encoder());
pipeline.addLast("decoder", new RS2LoginProtocol());
pipeline.addLast("handler", new ChannelHandler());
return pipeline;
}
示例10: OpenflowPipelineFactory
import org.jboss.netty.handler.timeout.ReadTimeoutHandler; //导入依赖的package包/类
public OpenflowPipelineFactory(IOFSwitchManager switchManager, Timer timer,
INewOFConnectionListener connectionListener,
IDebugCounterService debugCounters) {
super();
this.switchManager = switchManager;
this.connectionListener = connectionListener;
this.timer = timer;
this.debugCounters = debugCounters;
this.idleHandler = new IdleStateHandler(
timer,
PipelineIdleReadTimeout.MAIN,
PipelineIdleWriteTimeout.MAIN,
0);
this.readTimeoutHandler = new ReadTimeoutHandler(timer, 30);
}
示例11: ClientChannelPipeline
import org.jboss.netty.handler.timeout.ReadTimeoutHandler; //导入依赖的package包/类
public ClientChannelPipeline(
final OpenVirteXController openVirteXController,
final ChannelGroup cg, final ThreadPoolExecutor pipelineExecutor,
final ClientBootstrap bootstrap, final OVXSwitch sw) {
super();
this.ctrl = openVirteXController;
this.pipelineExecutor = pipelineExecutor;
this.timer = PhysicalNetwork.getTimer();
this.idleHandler = new IdleStateHandler(this.timer, 20, 25, 0);
this.readTimeoutHandler = new ReadTimeoutHandler(this.timer, 30);
this.bootstrap = bootstrap;
this.sw = sw;
this.cg = cg;
}
示例12: SwitchChannelPipeline
import org.jboss.netty.handler.timeout.ReadTimeoutHandler; //导入依赖的package包/类
public SwitchChannelPipeline(
final OpenVirteXController openVirteXController,
final ThreadPoolExecutor pipelineExecutor) {
super();
this.ctrl = openVirteXController;
this.pipelineExecutor = pipelineExecutor;
this.timer = PhysicalNetwork.getTimer();
this.idleHandler = new IdleStateHandler(this.timer, 20, 25, 0);
this.readTimeoutHandler = new ReadTimeoutHandler(this.timer, 30);
this.eh = new ExecutionHandler(this.pipelineExecutor);
}
示例13: initHttpBootstrap
import org.jboss.netty.handler.timeout.ReadTimeoutHandler; //导入依赖的package包/类
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");
}