本文整理匯總了Java中org.jboss.netty.handler.timeout.IdleStateHandler類的典型用法代碼示例。如果您正苦於以下問題:Java IdleStateHandler類的具體用法?Java IdleStateHandler怎麽用?Java IdleStateHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IdleStateHandler類屬於org.jboss.netty.handler.timeout包,在下文中一共展示了IdleStateHandler類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getPipeline
import org.jboss.netty.handler.timeout.IdleStateHandler; //導入依賴的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: getPipeline
import org.jboss.netty.handler.timeout.IdleStateHandler; //導入依賴的package包/類
@Override
public ChannelPipeline getPipeline() throws Exception {
HttpRequestHandler httpRequestHandler = new HttpRequestHandler();
httpRequestHandler.setSettings(settings);
httpRequestHandler.setApplicationContext(applicationContext);
ChannelPipeline pipeline = Channels.pipeline();
if (settings.getKeepAliveTimeout() > 0) {
pipeline.addLast("idle", new IdleStateHandler(timer, 0, 0, settings.getKeepAliveTimeout()));
pipeline.addLast("timeout", httpTimeoutHandler);
}
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("handler", httpRequestHandler);
return pipeline;
}
示例3: getPipeline
import org.jboss.netty.handler.timeout.IdleStateHandler; //導入依賴的package包/類
@Override
public ChannelPipeline getPipeline() throws Exception {
RemoteRequestHandler remoteRequestHandler = new RemoteRequestHandler();
remoteRequestHandler.setSettings(settings);
remoteRequestHandler.setApplicationContext(applicationContext);
ChannelPipeline pipeline = Channels.pipeline();
if (settings.getKeepAliveTimeout() > 0) {
pipeline.addLast("idle", new IdleStateHandler(timer, 0, 0, settings.getKeepAliveTimeout()));
pipeline.addLast("timeout", httpTimeoutHandler);
}
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("handler", remoteRequestHandler);
return pipeline;
}
示例4: getPipelineFactory
import org.jboss.netty.handler.timeout.IdleStateHandler; //導入依賴的package包/類
@Override
public ChannelPipelineFactory getPipelineFactory() {
executionHandler = new NaviExecutionHandler();
return new ChannelPipelineFactory() {
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addLast("httpCodec", new NaviHttpServerCodec());
pipeline.addLast("inflater", new HttpContentDecompressor());
pipeline.addLast("GLOBAL_TRAFFIC_SHAPING", globalTcHandler);
String chunkSize = ServerConfigure.get(NaviDefine.CHUNK_AGGR_SIZE);
if (StringUtils.isNumeric(chunkSize)) {
pipeline.addLast("aggregator", new HttpChunkAggregator(Integer.valueOf(chunkSize)));
}
// pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("deflater", new HttpContentCompressor());
pipeline.addLast("execution", executionHandler);
pipeline.addLast("idleState", new IdleStateHandler(timer, getChildChannelIdleTime(), getChildChannelIdleTime(), getChildChannelIdleTime()));
pipeline.addLast("handler", getNaviHttpHandler());
return pipeline;
}
};
}
示例5: getPipelineFactory
import org.jboss.netty.handler.timeout.IdleStateHandler; //導入依賴的package包/類
public ChannelPipelineFactory getPipelineFactory() {
executionHandler = new NaviExecutionHandler();
// execution = new ExecutionHandler(Executors.newCachedThreadPool());
return new ChannelPipelineFactory() {
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addLast("idleState", new IdleStateHandler(timer,
getChildChannelIdleTime(), getChildChannelIdleTime(),
getChildChannelIdleTime()));
//StateCheckChannelHandler加入心跳機製 讀空閑 斷開連接 寫空閑發送心跳數據
// pipeline.addLast("idleHandler", new StateCheckChannelHandler());
pipeline.addLast("decoder", new DelimiterBasedFrameDecoder(getMaxPacketSize(), getDelimiter()));
pipeline.addLast("execution", executionHandler);
// pipeline.addLast("execution", execution);
pipeline.addLast("handler", getNaviTCPHandler());
return pipeline;
}
};
}
示例6: init
import org.jboss.netty.handler.timeout.IdleStateHandler; //導入依賴的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);
}
示例7: getPipeline
import org.jboss.netty.handler.timeout.IdleStateHandler; //導入依賴的package包/類
@Override
public ChannelPipeline getPipeline() {
ChannelPipeline pipeline = Channels.pipeline();
if (resetDelay != null) {
pipeline.addLast("idleHandler", new IdleStateHandler(GlobalTimer.getTimer(), resetDelay, 0, 0));
}
pipeline.addLast("openHandler", new OpenChannelHandler(server));
if (loggerEnabled) {
pipeline.addLast("logger", new StandardLoggingHandler());
}
addSpecificHandlers(pipeline);
if (reverseGeocoder != null) {
pipeline.addLast("geocoder", new ReverseGeocoderHandler(reverseGeocoder));
}
pipeline.addLast("handler", new TrackerEventHandler(dataManager));
return pipeline;
}
示例8: getPipeline
import org.jboss.netty.handler.timeout.IdleStateHandler; //導入依賴的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;
}
示例9: getPipeline
import org.jboss.netty.handler.timeout.IdleStateHandler; //導入依賴的package包/類
@Override
public ChannelPipeline getPipeline() {
ChannelPipeline pipeline = Channels.pipeline();
// decoders
pipeline.addLast("framer", new DelimiterBasedFrameDecoder(MAX_REQUEST_LENGTH, DOUBLE_LINE_FEED_DELIMITER));
pipeline.addLast("string-decoder", new StringDecoder(JAGGRAB_CHARSET));
pipeline.addLast("jaggrab-decoder", new JagGrabRequestDecoder());
// encoders
pipeline.addLast("jaggrab-encoder", new JagGrabResponseEncoder());
// handler
pipeline.addLast("timeout", new IdleStateHandler(timer, NetworkConstants.IDLE_TIME, 0, 0));
pipeline.addLast("handler", handler);
return pipeline;
}
示例10: getPipeline
import org.jboss.netty.handler.timeout.IdleStateHandler; //導入依賴的package包/類
@Override
public ChannelPipeline getPipeline() {
ChannelPipeline pipeline = Channels.pipeline();
// decoders
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("chunker", new HttpChunkAggregator(MAX_REQUEST_LENGTH));
// encoders
pipeline.addLast("encoder", new HttpResponseEncoder());
// handler
pipeline.addLast("timeout", new IdleStateHandler(timer, NetworkConstants.IDLE_TIME, 0, 0));
pipeline.addLast("handler", handler);
return pipeline;
}
示例11: getPipeline
import org.jboss.netty.handler.timeout.IdleStateHandler; //導入依賴的package包/類
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline p = Channels.pipeline();
if (extraHandlers != null) {
for (final ChannelHandler handler : this.extraHandlers.getClientHandlers()) {
p.addLast("" + handler.hashCode(), handler);
}
}
// Do not use FixedLengthFrameDecoder provided by netty to avoid
// copy and an extra handler to parse the messages
// p.addLast("pnpDecoder", new PNPClientFrameDecoder());
p.addLast("pnpDecoder", new PNPClientFrameDecoder());
p.addLast("frameEncoder", new LengthFieldPrepender(4));
p.addLast("pnpEncoder", new PNPEncoder());
long idle_timeout = PNPConfig.PA_PNP_IDLE_TIMEOUT.getValue();
if (idle_timeout != 0) {
p.addLast("timer", new IdleStateHandler(timer, 0, idle_timeout, 0, TimeUnit.MILLISECONDS));
}
p.addLast(PNPClientHandler.NAME, new PNPClientHandler());
return p;
}
示例12: start
import org.jboss.netty.handler.timeout.IdleStateHandler; //導入依賴的package包/類
void start(final int idleTimeMilliSeconds, final SocketAddress tcpAddress,
final SocketAddress udpAddress) {
tcpServer = new ServerBootstrap(new NioServerSocketChannelFactory(
Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
tcpServer.setPipelineFactory(new ChannelPipelineFactory() {
private final HashedWheelTimer timer = new HashedWheelTimer();
private final IdleStateHandler idleStateHandler = new IdleStateHandler(
timer, 0, 0, idleTimeMilliSeconds, TimeUnit.MILLISECONDS);
@Override
public ChannelPipeline getPipeline() throws Exception {
return Channels.pipeline(RpcUtil.constructRpcFrameDecoder(),
RpcUtil.STAGE_RPC_MESSAGE_PARSER, idleStateHandler, handler,
RpcUtil.STAGE_RPC_TCP_RESPONSE);
}
});
udpServer = new ConnectionlessBootstrap(new NioDatagramChannelFactory(
Executors.newCachedThreadPool()));
udpServer.setPipeline(Channels.pipeline(RpcUtil.STAGE_RPC_MESSAGE_PARSER,
handler, RpcUtil.STAGE_RPC_UDP_RESPONSE));
tcpChannel = tcpServer.bind(tcpAddress);
udpChannel = udpServer.bind(udpAddress);
allChannels.add(tcpChannel);
allChannels.add(udpChannel);
LOG.info("Portmap server started at tcp://" + tcpChannel.getLocalAddress()
+ ", udp://" + udpChannel.getLocalAddress());
}
示例13: OpenflowPipelineFactory
import org.jboss.netty.handler.timeout.IdleStateHandler; //導入依賴的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;
}
示例14: init
import org.jboss.netty.handler.timeout.IdleStateHandler; //導入依賴的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);
}
示例15: setAuxChannelIdle
import org.jboss.netty.handler.timeout.IdleStateHandler; //導入依賴的package包/類
/**
* Sets the channel pipeline's idle (Echo) timeouts to a longer interval.
* This is specifically for aux channels.
*/
private void setAuxChannelIdle() {
IdleStateHandler idleHandler = new IdleStateHandler(
this.timer,
PipelineIdleReadTimeout.AUX,
PipelineIdleWriteTimeout.AUX,
0);
pipeline.replace(PipelineHandler.MAIN_IDLE,
PipelineHandler.AUX_IDLE,
idleHandler);
}