Package com.couchbase.client.http

Examples of com.couchbase.client.http.RequestHandle


          op.cancel();
          connRequest.cancel();
        }
      }
      HttpContext context = conn.getContext();
      RequestHandle handle = new RequestHandle(connMgr, conn);
      context.setAttribute("request-handle", handle);
      context.setAttribute("operation", op);
      conn.requestOutput();
    }
View Full Code Here


    public void initalizeContext(final HttpContext context,
        final Object attachment) {
    }

    public void finalizeContext(final HttpContext context) {
      RequestHandle handle =
          (RequestHandle) context.removeAttribute("request-handle");
      if (handle != null) {
        handle.cancel();
      }
    }
View Full Code Here

      return op.getRequest();
    }

    public void handleResponse(final HttpResponse response,
        final HttpContext context) {
      RequestHandle handle =
          (RequestHandle) context.removeAttribute("request-handle");
      HttpOperation op = (HttpOperation) context.removeAttribute("operation");

      try {
        response.setEntity(new BufferedHttpEntity(response.getEntity()));
      } catch(IOException ex) {
        throw new RuntimeException("Could not convert HttpEntity content.");
      }

      int statusCode = response.getStatusLine().getStatusCode();
      if (handle != null) {
        boolean shouldRetry = shouldRetry(statusCode, response);
        if(shouldRetry) {
          if(!op.isTimedOut() && !op.isCancelled()) {
            getLogger().info("Retrying HTTP operation Request: "
              + op.getRequest().getRequestLine() + ", Response: "
              + response.getStatusLine());
            vconn.addOp(op);
          }
        } else {
          op.handleResponse(response);
        }
        handle.completed();
      }
    }
View Full Code Here

          op.cancel();
          connRequest.cancel();
        }
      }
      HttpContext context = conn.getContext();
      RequestHandle handle = new RequestHandle(connMgr, conn);
      context.setAttribute("request-handle", handle);
      context.setAttribute("operation", op);
      conn.requestOutput();
    }
View Full Code Here

    public void initalizeContext(final HttpContext context,
        final Object attachment) {
    }

    public void finalizeContext(final HttpContext context) {
      RequestHandle handle =
          (RequestHandle) context.removeAttribute("request-handle");
      if (handle != null) {
        handle.cancel();
      }
    }
View Full Code Here

      return op.getRequest();
    }

    public void handleResponse(final HttpResponse response,
        final HttpContext context) {
      RequestHandle handle =
          (RequestHandle) context.removeAttribute("request-handle");
      HttpOperation op = (HttpOperation) context.removeAttribute("operation");

      try {
        response.setEntity(new BufferedHttpEntity(response.getEntity()));
      } catch(IOException ex) {
        throw new RuntimeException("Could not convert HttpEntity content.");
      }

      int statusCode = response.getStatusLine().getStatusCode();
      if (handle != null) {
        boolean shouldRetry = shouldRetry(statusCode, response);
        if(shouldRetry) {
          if(!op.isTimedOut() && !op.isCancelled()) {
            getLogger().info("Retrying HTTP operation Request: "
              + op.getRequest().getRequestLine() + ", Response: "
              + response.getStatusLine());
            vconn.addOp(op);
          }
        } else {
          op.handleResponse(response);
        }
        handle.completed();
      }
    }
View Full Code Here

TOP

Related Classes of com.couchbase.client.http.RequestHandle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.