Tabnine Logo
IdleStateHandler
Code IndexAdd Tabnine to your IDE (free)

How to use
IdleStateHandler
in
org.jboss.netty.handler.timeout

Best Java code snippets using org.jboss.netty.handler.timeout.IdleStateHandler (Showing top 20 results out of 315)

origin: apache/hive

  public HttpPipelineFactory(Configuration conf, Timer timer) throws Exception {
   SHUFFLE = getShuffle(conf);
   // TODO Setup SSL Shuffle
//      if (conf.getBoolean(MRConfig.SHUFFLE_SSL_ENABLED_KEY,
//                          MRConfig.SHUFFLE_SSL_ENABLED_DEFAULT)) {
//        LOG.info("Encrypted shuffle is enabled.");
//        sslFactory = new SSLFactory(SSLFactory.Mode.SERVER, conf);
//        sslFactory.init();
//      }
   this.idleStateHandler = new IdleStateHandler(timer, 0, connectionKeepAliveTimeOut, 0);
  }

origin: io.netty/netty

  public void run() {
    try {
      channelIdle(ctx, state, lastActivityTimeMillis);
    } catch (Throwable t) {
      fireExceptionCaught(ctx, t);
    }
  }
});
origin: io.netty/netty

public void beforeRemove(ChannelHandlerContext ctx) throws Exception {
  destroy(ctx);
}
origin: io.netty/netty

@Override
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
    throws Exception {
  // This method will be invoked only if this handler was added
  // before channelOpen event is fired.  If a user adds this handler
  // after the channelOpen event, initialize() will be called by beforeAdd().
  initialize(ctx);
  ctx.sendUpstream(e);
}
origin: io.netty/netty

public void beforeAdd(ChannelHandlerContext ctx) throws Exception {
  if (ctx.getPipeline().isAttached()) {
    // channelOpen event has been fired already, which means
    // this.channelOpen() will not be invoked.
    // We have to initialize here instead.
    initialize(ctx);
  } else {
    // channelOpen event has not been fired yet.
    // this.channelOpen() will be invoked and initialization will occur there.
  }
}
origin: alibaba/canal

IdleStateHandler idleStateHandler = new IdleStateHandler(NettyUtils.hashedWheelTimer,
  readTimeout,
  writeTimeout,
origin: io.netty/netty

@Override
public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e)
    throws Exception {
  destroy(ctx);
  ctx.sendUpstream(e);
}
origin: menacher/java-game-server

@Override
public ChannelPipeline getPipeline() throws Exception
{
  // Create a default pipeline implementation.
  ChannelPipeline pipeline = pipeline();
  pipeline.addLast("idleStateCheck", new IdleStateHandler(timer, 0, 0,
      MAX_IDLE_SECONDS));
  pipeline.addLast("idleCheckHandler", idleCheckHandler);
  pipeline.addLast("multiplexer", createProtcolMultiplexerDecoder());
  return pipeline;
}

origin: menacher/java-game-server

public ChannelPipeline addHandlers(ChannelPipeline pipeline)
{
  if (null == pipeline)
    return null;
  pipeline.addLast("framer",createLengthBasedFrameDecoder());
  pipeline.addLast("idleStateCheck", new IdleStateHandler(timer, 0, 0,
      MAX_IDLE_SECONDS));
  pipeline.addLast("idleCheckHandler", idleCheckHandler);
  pipeline.addLast("eventDecoder", eventDecoder);
  pipeline.addLast("loginHandler", loginHandler);
  pipeline.addLast("lengthFieldPrepender",lengthFieldPrepender);
  return pipeline;
}
 
origin: eBay/parallec

/**
 * Instantiates a new my pipeline factory.
 *
 * @param timer the timer
 * @param tcpWorker the tcp worker
 * @param idleTimeoutSec the idle timeout sec
 */
public MyPipelineFactory(Timer timer, TcpWorker tcpWorker, int idleTimeoutSec) {
  this.tcpWorker = tcpWorker;
  this.idleStateHandler = new IdleStateHandler(timer, 0, 0, idleTimeoutSec); 
  this.myIdleHandler = new MyIdleHandler(tcpWorker);
}
origin: eBay/parallec

/**
 * Instantiates a new my pipeline factory.
 *
 * @param timer
 *            the timer
 * @param udpWorker
 *            the udp worker
 */
public UdpPipelineFactory(Timer timer, UdpWorker udpWorker) {
  this.udpWorker = udpWorker;
  this.idleStateHandler = new IdleStateHandler(timer, 0, 0,
      udpWorker.udpMeta.getUdpIdleTimeoutSec());
  this.myIdleHandler = new MyIdleHandler(udpWorker);
}
origin: neilbeveridge/zuul-netty

public HttpOutboundPipeline (Timer timer) {
  IDLE_STATE_HANDLER = new IdleStateHandler(timer, IDLE_TIMEOUT_READER, IDLE_TIMEOUT_WRITER, IDLE_TIMEOUT_BOTH);
}
origin: neilbeveridge/zuul-netty

public MockEndpoint() {
  IDLE_STATE_HANDLER = new IdleStateHandler(TIMER, IDLE_TIMEOUT_READER, IDLE_TIMEOUT_WRITER, IDLE_TIMEOUT_BOTH);
}
origin: org.onosproject/onos-pcep-controller-impl

public PcepPipelineFactory(Controller controller) {
  super();
  this.controller = controller;
  this.idleHandler = new IdleStateHandler(TIMER, DEFAULT_DEAD_TIME, DEFAULT_KEEP_ALIVE_TIME, 0);
  this.readTimeoutHandler = new ReadTimeoutHandler(TIMER, DEFAULT_WAIT_TIME);
}
origin: org.apache.hive/hive-llap-server

  public HttpPipelineFactory(Configuration conf, Timer timer) throws Exception {
   SHUFFLE = getShuffle(conf);
   // TODO Setup SSL Shuffle
//      if (conf.getBoolean(MRConfig.SHUFFLE_SSL_ENABLED_KEY,
//                          MRConfig.SHUFFLE_SSL_ENABLED_DEFAULT)) {
//        LOG.info("Encrypted shuffle is enabled.");
//        sslFactory = new SSLFactory(SSLFactory.Mode.SERVER, conf);
//        sslFactory.init();
//      }
   this.idleStateHandler = new IdleStateHandler(timer, 0, connectionKeepAliveTimeOut, 0);
  }

origin: io.parallec/parallec-core

/**
 * Instantiates a new my pipeline factory.
 *
 * @param timer the timer
 * @param tcpWorker the tcp worker
 * @param idleTimeoutSec the idle timeout sec
 */
public MyPipelineFactory(Timer timer, TcpWorker tcpWorker, int idleTimeoutSec) {
  this.tcpWorker = tcpWorker;
  this.idleStateHandler = new IdleStateHandler(timer, 0, 0, idleTimeoutSec); 
  this.myIdleHandler = new MyIdleHandler(tcpWorker);
}
origin: org.onosproject/onos-protocols-pcep-ctl

public PcepPipelineFactory(Controller controller) {
  super();
  this.controller = controller;
  this.idleHandler = new IdleStateHandler(TIMER, DEFAULT_DEAD_TIME, DEFAULT_KEEP_ALIVE_TIME, 0);
  this.readTimeoutHandler = new ReadTimeoutHandler(TIMER, DEFAULT_WAIT_TIME);
}
origin: org.hbase/asynchbase

RegionClientPipeline() {
 timeout_handler = new IdleStateHandler(timer, 0, 0, 
   config.getInt("hbase.hbase.ipc.client.connection.idle_timeout"));
}
origin: neilbeveridge/zuul-netty

public CommonHttpPipeline(Timer timer) {
  this.idleStateHandler = new IdleStateHandler(timer, IDLE_TIMEOUT_READER, IDLE_TIMEOUT_WRITER, IDLE_TIMEOUT_BOTH);
  this.outboundConnectionPool = new CommonsConnectionPool(timer, OUTBOUND_CHANNEL_FACTORY);
}
origin: org.onosproject/onos-of-ctl

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;
}
org.jboss.netty.handler.timeoutIdleStateHandler

Javadoc

Triggers an IdleStateEvent when a Channel has not performed read, write, or both operation for a while.

Supported idle states

PropertyMeaning
readerIdleTime an IdleStateEvent whose state is IdleState#READER_IDLEwill be triggered when no read was performed for the specified period of time. Specify 0 to disable.
writerIdleTime an IdleStateEvent whose state is IdleState#WRITER_IDLEwill be triggered when no write was performed for the specified period of time. Specify 0 to disable.
allIdleTime an IdleStateEvent whose state is IdleState#ALL_IDLEwill be triggered when neither read nor write was performed for the specified period of time. Specify 0 to disable.
 
// An example that sends a ping message when there is no outbound traffic 
// for 30 seconds.  The connection is closed when there is no inbound traffic 
// for 60 seconds. 
public class MyPipelineFactory implements  
ChannelPipelineFactory { 
private final  
Timer timer; 
private final  
ChannelHandler idleStateHandler; 
public MyPipelineFactory( 
Timer timer) { 
this.timer = timer; 
this.idleStateHandler = new  
IdleStateHandler(timer, 60, 30, 0), // timer must be shared. 
} 
public  
ChannelPipeline getPipeline() { 
return  
Channels.pipeline( 
idleStateHandler, 
new MyHandler()); 
} 
} 
// Handler should handle the  
IdleStateEvent triggered by  
IdleStateHandler. 
public class MyHandler extends  
IdleStateAwareChannelHandler { 
 @Overridepublic void channelIdle( 
ChannelHandlerContext ctx,  
IdleStateEvent e) { 
if (e.getState() ==  
IdleState.READER_IDLE) { 
e.getChannel().close(); 
} else if (e.getState() ==  
IdleState.WRITER_IDLE) { 
e.getChannel().write(new PingMessage()); 
} 
} 
} 
ServerBootstrap bootstrap = ...; 
Timer timer = new  
HashedWheelTimer(); 
... 
bootstrap.setPipelineFactory(new MyPipelineFactory(timer)); 
... 
The Timer which was specified when the IdleStateHandler is created should be stopped manually by calling #releaseExternalResources()or Timer#stop() when your application shuts down.

Most used methods

  • <init>
    Creates a new instance.
  • channelIdle
  • destroy
  • initialize
  • state

Popular in Java

  • Reading from database using SQL prepared statement
  • getApplicationContext (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • BoxLayout (javax.swing)
  • IsNull (org.hamcrest.core)
    Is the value null?
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now