Tabnine Logo
Channels.setDiscard
Code IndexAdd Tabnine to your IDE (free)

How to use
setDiscard
method
in
com.ning.http.client.providers.netty.channel.Channels

Best Java code snippets using com.ning.http.client.providers.netty.channel.Channels.setDiscard (Showing top 12 results out of 315)

origin: com.ning/async-http-client

public void closeChannel(Channel channel) {
  // The channel may have already been removed from the future if a timeout occurred, and this method may be called just after.
  LOGGER.debug("Closing Channel {} ", channel);
  try {
    removeAll(channel);
    Channels.setDiscard(channel);
    Channels.silentlyCloseChannel(channel);
  } catch (Throwable t) {
    LOGGER.debug("Error closing a connection", t);
  }
  openChannels.remove(channel);
}
origin: com.ning/async-http-client

@Override
public boolean cancel(boolean force) {
  cancelTimeouts();
  if (isCancelled.getAndSet(true))
    return false;
  // cancel could happen before channel was attached
  if (channel != null) {
    Channels.setDiscard(channel);
    Channels.silentlyCloseChannel(channel);
  }
  if (!onThrowableCalled.getAndSet(true)) {
    try {
      asyncHandler.onThrowable(new CancellationException());
    } catch (Throwable t) {
      LOGGER.warn("cancel", t);
    }
  }
  latch.countDown();
  runListeners();
  return true;
}
origin: com.ning/async-http-client

private void close(Channel channel) {
  // FIXME pity to have to do this here
  Channels.setDiscard(channel);
  channelId2Creation.remove(channel.getId());
  Channels.silentlyCloseChannel(channel);
}
origin: com.ning/async-http-client

@Override
public void messageReceived(final ChannelHandlerContext ctx, MessageEvent e) throws Exception {
  // call super to reset the read timeout
  super.messageReceived(ctx, e);
  Channel channel = ctx.getChannel();
  Object attribute = Channels.getAttribute(channel);
  if (attribute instanceof Callback) {
    Object message = e.getMessage();
    Callback ac = (Callback) attribute;
    if (message instanceof HttpChunk) {
      // the AsyncCallable is to be processed on the last chunk
      if (HttpChunk.class.cast(message).isLast())
        // process the AsyncCallable before passing the message to the protocol
        ac.call();
        // FIXME remove attribute?
    } else {
      LOGGER.info("Received unexpected message while expecting a chunk: " + message);
      ac.call();
      Channels.setDiscard(channel);
    }
  } else if (attribute instanceof NettyResponseFuture<?>) {
    NettyResponseFuture<?> future = (NettyResponseFuture<?>) attribute;
    protocol.handle(channel, future, e.getMessage());
  } else if (attribute != DiscardEvent.INSTANCE) {
    // unhandled message
    LOGGER.debug("Orphan channel {} with attribute {} received message {}, closing", channel, attribute, e.getMessage());
    Channels.silentlyCloseChannel(channel);
  }
}
origin: com.ning/async-http-client

public final void tryToOfferChannelToPool(Channel channel, boolean keepAlive, Object partitionKey) {
  if (channel.isConnected() && keepAlive && channel.isReadable()) {
    LOGGER.debug("Adding key: {} for channel {}", partitionKey, channel);
    Channels.setDiscard(channel);
    if (channelPool.offer(channel, partitionKey)) {
      if (maxConnectionsPerHostEnabled)
        channelId2PartitionKey.putIfAbsent(channel.getId(), partitionKey);
    } else {
      // rejected by pool
      closeChannel(channel);
    }
  } else {
    // not offered
    closeChannel(channel);
  }
}
origin: com.ning/async-http-client

Channels.setDiscard(channel);
CloseWebSocketFrame closeFrame = CloseWebSocketFrame.class.cast(frame);
webSocket.onClose(closeFrame.getStatusCode(), closeFrame.getReasonText());
origin: io.gatling/async-http-client

  private void close(Channel channel) {
    try {
      // FIXME pity to have to do this here
      Channels.setDiscard(channel);
      channelId2Creation.remove(channel.getId());
      channel.close();
    } catch (Throwable t) {
      // noop
    }
  }
}
origin: io.gatling/async-http-client

public void closeChannel(Channel channel) {
  removeAll(channel);
  Channels.setDiscard(channel);
  // The channel may have already been removed if a timeout occurred, and this method may be called just after.
  if (channel != null) {
    LOGGER.debug("Closing Channel {} ", channel);
    try {
      channel.close();
    } catch (Throwable t) {
      LOGGER.debug("Error closing a connection", t);
    }
    openChannels.remove(channel);
  }
}
origin: io.gatling/async-http-client

public final void tryToOfferChannelToPool(Channel channel, boolean keepAlive, String poolKey) {
  if (keepAlive && channel.isReadable()) {
    LOGGER.debug("Adding key: {} for channel {}", poolKey, channel);
    channelPool.offer(channel, poolKey);
    if (maxConnectionsPerHostEnabled)
      channelId2KeyPool.putIfAbsent(channel.getId(), poolKey);
    Channels.setDiscard(channel);
  } else {
    // not offered
    closeChannel(channel);
  }
}
origin: io.gatling/async-http-client

@Override
public boolean cancel(boolean force) {
  cancelTimeouts();
  if (isCancelled.getAndSet(true))
    return false;
  try {
    Channels.setDiscard(channel);
    channel.close();
  } catch (Throwable t) {
    // Ignore
  }
  if (!onThrowableCalled.getAndSet(true)) {
    try {
      asyncHandler.onThrowable(new CancellationException());
    } catch (Throwable t) {
      LOGGER.warn("cancel", t);
    }
  }
  latch.countDown();
  runListeners();
  return true;
}
origin: io.gatling/async-http-client

LOGGER.info("Received unexpected message while expecting a chunk: " + message);
ac.call();
Channels.setDiscard(channel);
origin: io.gatling/async-http-client

Channels.setDiscard(channel);
CloseWebSocketFrame closeFrame = CloseWebSocketFrame.class.cast(frame);
webSocket.onClose(closeFrame.getStatusCode(), closeFrame.getReasonText());
com.ning.http.client.providers.netty.channelChannelssetDiscard

Popular methods of Channels

  • getAttribute
  • isChannelValid
  • setAttribute
  • silentlyCloseChannel

Popular in Java

  • Start an intent from android
  • getApplicationContext (Context)
  • getSharedPreferences (Context)
  • getExternalFilesDir (Context)
  • Kernel (java.awt.image)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Collectors (java.util.stream)
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • 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