Tabnine Logo
Channel.isConnected
Code IndexAdd Tabnine to your IDE (free)

How to use
isConnected
method
in
org.jboss.netty.channel.Channel

Best Java code snippets using org.jboss.netty.channel.Channel.isConnected (Showing top 20 results out of 819)

origin: apache/incubator-dubbo

@Override
public boolean isConnected() {
  return channel.isConnected();
}
origin: apache/incubator-dubbo

@Override
public boolean isConnected() {
  return channel.isConnected();
}
origin: apache/incubator-dubbo

static void removeChannelIfDisconnected(org.jboss.netty.channel.Channel ch) {
  if (ch != null && !ch.isConnected()) {
    channelMap.remove(ch);
  }
}
origin: apache/incubator-dubbo

static void removeChannelIfDisconnected(org.jboss.netty.channel.Channel ch) {
  if (ch != null && !ch.isConnected()) {
    channelMap.remove(ch);
  }
}
origin: apache/incubator-dubbo

static NettyChannel getOrAddChannel(org.jboss.netty.channel.Channel ch, URL url, ChannelHandler handler) {
  if (ch == null) {
    return null;
  }
  NettyChannel ret = channelMap.get(ch);
  if (ret == null) {
    NettyChannel nc = new NettyChannel(ch, url, handler);
    if (ch.isConnected()) {
      ret = channelMap.putIfAbsent(ch, nc);
    }
    if (ret == null) {
      ret = nc;
    }
  }
  return ret;
}
origin: apache/incubator-dubbo

static NettyChannel getOrAddChannel(org.jboss.netty.channel.Channel ch, URL url, ChannelHandler handler) {
  if (ch == null) {
    return null;
  }
  NettyChannel ret = channelMap.get(ch);
  if (ret == null) {
    NettyChannel nc = new NettyChannel(ch, url, handler);
    if (ch.isConnected()) {
      ret = channelMap.putIfAbsent(ch, nc);
    }
    if (ret == null) {
      ret = nc;
    }
  }
  return ret;
}
origin: apache/incubator-dubbo

@Override
protected org.apache.dubbo.remoting.Channel getChannel() {
  Channel c = channel;
  if (c == null || !c.isConnected()) {
    return null;
  }
  return NettyChannel.getOrAddChannel(c, getUrl(), this);
}
origin: apache/incubator-dubbo

@Override
protected org.apache.dubbo.remoting.Channel getChannel() {
  Channel c = channel;
  if (c == null || !c.isConnected()) {
    return null;
  }
  return NettyChannel.getOrAddChannel(c, getUrl(), this);
}
origin: kairosdb/kairosdb

@Override
public void execute(Channel chan, List<String> command) throws DatastoreException
{
  m_counter.incrementAndGet();
  if (chan.isConnected())
  {
    Package thisPackage = getClass().getPackage();
    String versionString = thisPackage.getImplementationTitle()+" "+thisPackage.getImplementationVersion();
    chan.write(versionString+"\n");
  }
}
origin: menacher/java-game-server

/**
 * This method will write an event to the channel and then add a close
 * listener which will close it after the write has completed.
 * 
 * @param channel
 * @param event
 */
public void closeAfterFlushingPendingWrites(Channel channel, Event event)
{
  if (channel.isConnected())
  {
    channel.write(event).addListener(ChannelFutureListener.CLOSE);
  }
  else
  {
    System.err.println("Unable to write the Event :" + event
        + " to socket as channel is ot connected");
  }
}
origin: io.netty/netty

private void protocolViolation(Channel channel, CorruptedFrameException ex) throws CorruptedFrameException {
  checkpoint(State.CORRUPT);
  if (channel.isConnected()) {
    channel.write(ChannelBuffers.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
  }
  throw ex;
}
origin: apache/avro

/**
 * Tests whether the given channel is ready for writing.
 * @return true if the channel is open and ready; false otherwise.
 */
private static boolean isChannelReady(Channel channel) {
 return (channel != null) &&
  channel.isOpen() && channel.isBound() && channel.isConnected();
}
origin: io.netty/netty

void setWritable(ChannelHandlerContext ctx, boolean writable) {
  Channel channel = ctx.getChannel();
  if (channel.isConnected()) {
    channel.setUserDefinedWritability(index, writable);
  }
}
origin: apache/hive

 @Override
 public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
   throws Exception {
  Channel ch = e.getChannel();
  Throwable cause = e.getCause();
  if (cause instanceof TooLongFrameException) {
   sendError(ctx, BAD_REQUEST);
   return;
  } else if (cause instanceof IOException) {
   if (cause instanceof ClosedChannelException) {
    LOG.debug("Ignoring closed channel error", cause);
    return;
   }
   String message = String.valueOf(cause.getMessage());
   if (IGNORABLE_ERROR_MESSAGE.matcher(message).matches()) {
    LOG.debug("Ignoring client socket close", cause);
    return;
   }
  }
  LOG.error("Shuffle error: ", cause);
  if (ch.isConnected()) {
   LOG.error("Shuffle error " + e);
   sendError(ctx, INTERNAL_SERVER_ERROR);
  }
 }
}
origin: menacher/java-game-server

/**
 * Writes an the {@link Events#DISCONNECT} to the client, flushes
 * all the pending writes and closes the channel.
 * 
 */
@Override
public void close()
{
  LOG.debug("Going to close tcp connection in class: {}", this
      .getClass().getName());
  Event event = Events.event(null, Events.DISCONNECT);
  if (channel.isConnected())
  {
    channel.write(event).addListener(ChannelFutureListener.CLOSE);
  }
  else
  {
    channel.close();
    LOG.trace("Unable to write the Event {} with type {} to socket",
        event, event.getType());
  }
}
origin: io.netty/netty

@Override
public void releaseExternalResources() {
  Channel channel = ctx.getChannel();
  synchronized (this) {
    if (ctx != null && ctx.getChannel().isConnected()) {
      for (ToSend toSend : messagesQueue) {
        if (! channel.isConnected()) {
          // ignore
          break;
        }
        ctx.sendDownstream(toSend.toSend);
      }
    }
    messagesQueue.clear();
  }
  if (writeTimeout != null) {
    writeTimeout.cancel();
  }
  super.releaseExternalResources();
}
origin: io.netty/netty

public void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e)
    throws Exception {
  if (!(e instanceof MessageEvent)) {
    ctx.sendDownstream(e);
    return;
  }
  boolean offered = queue.offer((MessageEvent) e);
  assert offered;
  final Channel channel = ctx.getChannel();
  // call flush if the channel is writable or not connected. flush(..) will take care of the rest
  if (channel.isWritable() || !channel.isConnected()) {
    this.ctx = ctx;
    flush(ctx, false);
  }
}
origin: apache/incubator-druid

@Override
public boolean isGood(ChannelFuture resource)
{
 Channel channel = resource.awaitUninterruptibly().getChannel();
 boolean isSuccess = resource.isSuccess();
 boolean isConnected = channel.isConnected();
 boolean isOpen = channel.isOpen();
 if (log.isTraceEnabled()) {
  log.trace("isGood = isSucess[%s] && isConnected[%s] && isOpen[%s]", isSuccess, isConnected, isOpen);
 }
 return isSuccess && isConnected && isOpen;
}
origin: weibocom/motan

private void processRequest(final ChannelHandlerContext ctx, final Request request, long processStartTime) {
  Object result;
  try {
    result = messageHandler.handle(serverChannel, request);
  } catch (Exception e) {
    LoggerUtil.error("NettyChannelHandler processRequest fail!request:" + MotanFrameworkUtil.toString(request), e);
    result = MotanFrameworkUtil.buildErrorResponse(request.getRequestId(), new MotanServiceException("process request fail. errmsg:" + e.getMessage()));
  }
  MotanFrameworkUtil.logRequestEvent(request.getRequestId(), "after invoke biz method: " + MotanFrameworkUtil.getFullMethodString(request), System.currentTimeMillis());
  DefaultResponse response = null;
  if (!(result instanceof DefaultResponse)) {
    response = new DefaultResponse(result);
  } else {
    response = (DefaultResponse) result;
  }
  response.setRequestId(request.getRequestId());
  response.setProcessTime(System.currentTimeMillis() - processStartTime);
  if (ctx.getChannel().isConnected()) {
    ChannelFuture channelFuture = ctx.getChannel().write(response);
    if (channelFuture != null && request instanceof TraceableRequest) {
      channelFuture.addListener(new ChannelFutureListener() {
        @Override
        public void operationComplete(ChannelFuture future) throws Exception {
          MotanFrameworkUtil.logRequestEvent(request.getRequestId(), "after send rpc response: " + MotanFrameworkUtil.getFullMethodString(request), System.currentTimeMillis());
          ((TraceableRequest) request).onFinish();
        }
      });
    }
  }
}
origin: io.netty/netty

private void sendGoAwayFrame(ChannelHandlerContext ctx, ChannelStateEvent e) {
  // Avoid NotYetConnectedException
  if (!e.getChannel().isConnected()) {
    ctx.sendDownstream(e);
    return;
  }
  ChannelFuture future = sendGoAwayFrame(ctx, e.getChannel(), null, SpdySessionStatus.OK);
  if (spdySession.noActiveStreams()) {
    future.addListener(new ClosingChannelFutureListener(ctx, e));
  } else {
    closeSessionFutureListener = new ClosingChannelFutureListener(ctx, e);
  }
}
org.jboss.netty.channelChannelisConnected

Javadoc

Returns true if and only if this channel is connected to a #getRemoteAddress().

Popular methods of Channel

  • write
    Sends a message to this channel asynchronously. It has an additional parameter that allows a user to
  • close
    Closes this channel asynchronously. If this channel is bound or connected, it will be disconnected a
  • getRemoteAddress
    Returns the remote address where this channel is connected to. The returned SocketAddress is suppose
  • getPipeline
    Returns the ChannelPipeline which handles ChannelEvents associated with this channel.
  • getLocalAddress
    Returns the local address where this channel is bound to. The returned SocketAddress is supposed to
  • isOpen
    Returns true if and only if this channel is open.
  • getId
    Returns the unique integer ID of this channel.
  • getCloseFuture
    Returns the ChannelFuture which will be notified when this channel is closed. This method always ret
  • isBound
    Returns true if and only if this channel is bound to a #getLocalAddress().
  • setReadable
    Suspends or resumes the read operation of the I/O thread asynchronously. This method is a shortcut t
  • getConfig
    Returns the configuration of this channel.
  • disconnect
    Disconnects this channel from the current remote address asynchronously.
  • getConfig,
  • disconnect,
  • isWritable,
  • isReadable,
  • setAttachment,
  • setInterestOps,
  • getAttachment,
  • unbind,
  • connect

Popular in Java

  • Creating JSON documents from java classes using gson
  • runOnUiThread (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • putExtra (Intent)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • Kernel (java.awt.image)
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Best IntelliJ plugins
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