Codota Logo
Channel.isActive
Code IndexAdd Codota to your IDE (free)

How to use
isActive
method
in
io.netty.channel.Channel

Best Java code snippets using io.netty.channel.Channel.isActive (Showing top 20 results out of 2,637)

Refine searchRefine arrow

  • ChannelHandlerContext.channel
  • Common ways to obtain Channel
private void myMethod () {
Channel c =
  • Codota IconChannelFuture future;future.channel()
  • Codota IconChannelHandlerContext ctx;ctx.channel()
  • Codota IconChannelHandlerContext ctx;ctx.channel().read()
  • Smart code suggestions by Codota
}
origin: qunarcorp/qmq

boolean isInValid() {
  Channel channel = ctx.channel();
  return channel == null || !channel.isActive();
}
origin: yu199195/Raincat

/**
 * async Send message to tx Manager.
 *
 * @param heartBeat {@linkplain HeartBeat }
 */
public void asyncSendTxManagerMessage(final HeartBeat heartBeat) {
  if (ctx != null && ctx.channel() != null && ctx.channel().isActive()) {
    ctx.writeAndFlush(heartBeat);
  }
}
origin: weibocom/motan

private ChannelFuture sendResponse(ChannelHandlerContext ctx, Response response) {
  byte[] msg = CodecUtil.encodeObjectToBytes(channel, codec, response);
  if (ctx.channel().isActive()) {
    return ctx.channel().writeAndFlush(msg);
  }
  return null;
}
origin: redisson/redisson

@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
  if (ctx.channel().isActive() && ctx.channel().isRegistered()) {
    // channelActive() event has been fired already, which means this.channelActive() will
    // not be invoked. We have to initialize here instead.
    initialize(ctx);
  } else {
    // channelActive() event has not been fired yet.  this.channelActive() will be invoked
    // and initialization will occur there.
  }
}
origin: redisson/redisson

@Override
public void handlerAdded(final ChannelHandlerContext ctx) throws Exception {
  this.ctx = ctx;
  pendingUnencryptedWrites = new SslHandlerCoalescingBufferQueue(ctx.channel(), 16);
  if (ctx.channel().isActive()) {
    startHandshakeProcessing();
  }
}
origin: micronaut-projects/micronaut-core

  private void maybeStart() {
    if (ctx.channel().isActive()) {
      state = RUNNING;
      maybeRequestMore();
    } else {
      state = INACTIVE;
    }
  }
}
origin: wildfly/wildfly

private void protocolViolation(ChannelHandlerContext ctx, CorruptedFrameException ex) {
  state = State.CORRUPT;
  if (ctx.channel().isActive()) {
    Object closeMessage;
    if (receivedClosingHandshake) {
      closeMessage = Unpooled.EMPTY_BUFFER;
    } else {
      closeMessage = new CloseWebSocketFrame(1002, null);
    }
    ctx.writeAndFlush(closeMessage).addListener(ChannelFutureListener.CLOSE);
  }
  throw ex;
}
origin: line/armeria

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
  Exceptions.logIfUnexpected(logger, ctx.channel(), protocol, cause);
  if (ctx.channel().isActive()) {
    ctx.close();
  }
}
origin: redisson/redisson

@Override
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
  // Initialize early if channel is active already.
  if (ctx.channel().isActive()) {
    initialize(ctx);
  }
  super.channelRegistered(ctx);
}
origin: neo4j/neo4j

@Override
public void handlerAdded( ChannelHandlerContext ctx ) throws Exception
{
  // Sometimes the connect event will have happened before adding, the channel will be active then
  if ( ctx.channel().isActive() )
  {
    SslHandler sslHandler = createSslHandler( ctx, (InetSocketAddress) ctx.channel().remoteAddress() );
    replaceSelfWith( sslHandler );
    sslHandler.handlerAdded( ctx );
  }
}
origin: jamesdbloom/mockserver

private void failure(String message, Throwable cause, ChannelHandlerContext ctx, Object response) {
  if (shouldNotIgnoreException(cause)) {
    mockServerLogger.error(message, cause);
  }
  Channel channel = ctx.channel();
  channel.writeAndFlush(response);
  if (channel.isActive()) {
    channel.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
  }
}
origin: wildfly/wildfly

private void checkUTF8String(ChannelHandlerContext ctx, ByteBuf buffer) {
  try {
    if (utf8Validator == null) {
      utf8Validator = new Utf8Validator();
    }
    utf8Validator.check(buffer);
  } catch (CorruptedFrameException ex) {
    if (ctx.channel().isActive()) {
      ctx.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
    }
  }
}
origin: wildfly/wildfly

@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
  if (ctx.channel().isActive() && ctx.channel().isRegistered()) {
    // channelActive() event has been fired already, which means this.channelActive() will
    // not be invoked. We have to initialize here instead.
    initialize(ctx);
  } else {
    // channelActive() event has not been fired yet.  this.channelActive() will be invoked
    // and initialization will occur there.
  }
}
origin: wildfly/wildfly

@Override
public void handlerAdded(final ChannelHandlerContext ctx) throws Exception {
  this.ctx = ctx;
  pendingUnencryptedWrites = new SslHandlerCoalescingBufferQueue(ctx.channel(), 16);
  if (ctx.channel().isActive()) {
    startHandshakeProcessing();
  }
}
origin: Netflix/zuul

protected void immediately(ChannelHandlerContext ctx, ChannelPromise promise)
{
  if (isAlreadyClosing(ctx)) {
    promise.setSuccess();
    return;
  }
  if (ctx.channel().isActive()) {
    ctx.close(promise);
  }
  else {
    promise.setSuccess();
  }
}
origin: alipay/sofa-rpc

  @Override
  public void exceptionCaught(ChannelHandlerContext ctx, Throwable e)
    throws Exception {
    // handle the case of to big requests.
    if (e.getCause() instanceof TooLongFrameException) {
      DefaultHttpResponse response = new DefaultHttpResponse(HTTP_1_1, REQUEST_ENTITY_TOO_LARGE);
      ctx.write(response).addListener(ChannelFutureListener.CLOSE);
    } else {
      if (ctx.channel().isActive()) { // 连接已断开就不打印了
        logger.warn("Exception caught by request handler", e);
      }
      ctx.close();
    }
  }
}
origin: alipay/sofa-rpc

  @Override
  public void exceptionCaught(ChannelHandlerContext ctx, Throwable e)
    throws Exception {
    // handle the case of to big requests.
    if (e.getCause() instanceof TooLongFrameException) {
      DefaultHttpResponse response = new DefaultHttpResponse(HTTP_1_1, REQUEST_ENTITY_TOO_LARGE);
      ctx.write(response).addListener(ChannelFutureListener.CLOSE);
    } else {
      if (ctx.channel().isActive()) { // 连接已断开就不打印了
        logger.warn("Exception caught by request handler", e);
      }
      ctx.close();
    }
  }
}
origin: Netflix/zuul

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
  int status = 500;
  final String errorMsg = "ClientResponseWriter caught exception in client connection pipeline: " +
      ChannelUtils.channelInfoForLogging(ctx.channel());
  if (cause instanceof ZuulException) {
    final ZuulException ze = (ZuulException) cause;
    status = ze.getStatusCode();
    LOG.error(errorMsg, cause);
  }
  else if (cause instanceof ReadTimeoutException) {
    LOG.error(errorMsg + ", Read timeout fired");
    status = 504;
  }
  else {
    LOG.error(errorMsg, cause);
  }
  if (isHandlingRequest && !startedSendingResponseToClient && ctx.channel().isActive()) {
    final HttpResponse httpResponse = new DefaultFullHttpResponse(HTTP_1_1, HttpResponseStatus.valueOf(status));
    ctx.writeAndFlush(httpResponse).addListener(ChannelFutureListener.CLOSE);
    startedSendingResponseToClient = true;
  }
  else {
    ctx.close();
  }
}
origin: wildfly/wildfly

@Override
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
  // Initialize early if channel is active already.
  if (ctx.channel().isActive()) {
    initialize(ctx);
  }
  super.channelRegistered(ctx);
}
origin: apache/rocketmq-externals

@Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
  if (ctx.channel().isActive() && ctx.channel().isRegistered()) {
    initialize(ctx);
  }
}
io.netty.channelChannelisActive

Javadoc

Return true if the Channel is active and so connected.

Popular methods of Channel

  • writeAndFlush
  • close
  • remoteAddress
    Returns the remote address where this channel is connected to. The returned SocketAddress is suppose
  • pipeline
    Return the assigned ChannelPipeline.
  • closeFuture
    Returns the ChannelFuture which will be notified when this channel is closed. This method always ret
  • localAddress
    Returns the local address where this channel is bound to. The returned SocketAddress is supposed to
  • eventLoop
    Return the EventLoop this Channel was registered to.
  • isOpen
    Returns true if the Channel is open and may get active later
  • attr
  • write
  • alloc
    Return the assigned ByteBufAllocator which will be used to allocate ByteBufs.
  • isWritable
    Returns true if and only if the I/O thread will perform the requested write operation immediately. A
  • alloc,
  • isWritable,
  • config,
  • flush,
  • newPromise,
  • id,
  • read,
  • voidPromise,
  • isRegistered

Popular in Java

  • Updating database using SQL prepared statement
  • getSystemService (Context)
  • requestLocationUpdates (LocationManager)
  • startActivity (Activity)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • MessageFormat (java.text)
    MessageFormat provides a means to produce concatenated messages in language-neutral way. Use this to
  • SortedSet (java.util)
    A Set that further provides a total ordering on its elements. The elements are ordered using their C
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • JCheckBox (javax.swing)
  • Logger (org.slf4j)
    The main user interface to logging. It is expected that logging takes place through concrete impleme
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now