congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
HttpConnectionPool.tryRelease
Code IndexAdd Tabnine to your IDE (free)

How to use
tryRelease
method
in
com.mpush.netty.http.HttpConnectionPool

Best Java code snippets using com.mpush.netty.http.HttpConnectionPool.tryRelease (Showing top 3 results out of 315)

origin: mpusher/mpush

private void writeRequest(Channel channel, RequestContext context) {
  channel.attr(requestKey).set(context);
  pool.attachHost(context.host, channel);
  channel.writeAndFlush(context.request).addListener((ChannelFutureListener) future -> {
    if (!future.isSuccess()) {
      RequestContext info = future.channel().attr(requestKey).getAndSet(null);
      info.tryDone();
      info.onFailure(503, "Service Unavailable");
      LOGGER.debug("request failure request={}", info);
      pool.tryRelease(future.channel());
    }
  });
}
origin: mpusher/mpush

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
  RequestContext context = ctx.channel().attr(client.requestKey).getAndSet(null);
  try {
    if (context != null && context.tryDone()) {
      context.onException(cause);
    }
  } finally {
    client.pool.tryRelease(ctx.channel());
  }
  LOGGER.error("http client caught an ex, info={}", context, cause);
}
origin: mpusher/mpush

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
  RequestContext context = ctx.channel().attr(client.requestKey).getAndSet(null);
  try {
    if (context != null && context.tryDone()) {
      LOGGER.debug("receive server response, request={}, response={}", context, msg);
      HttpResponse response = (HttpResponse) msg;
      if (isRedirect(response)) {
        if (context.onRedirect(response)) {
          String location = getRedirectLocation(context.request, response);
          if (location != null && location.length() > 0) {
            context.cancelled.set(false);
            context.request.setUri(location);
            client.request(context);
            return;
          }
        }
      }
      context.onResponse(response);
    } else {
      LOGGER.warn("receive server response but timeout, request={}, response={}", context, msg);
    }
  } finally {
    client.pool.tryRelease(ctx.channel());
    ReferenceCountUtil.release(msg);
  }
}
com.mpush.netty.httpHttpConnectionPooltryRelease

Popular methods of HttpConnectionPool

  • attachHost
  • close
  • tryAcquire

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setContentView (Activity)
  • getResourceAsStream (ClassLoader)
  • getExternalFilesDir (Context)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Notification (javax.management)
  • Top Sublime Text 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