Package com.couchbase.client.http

Examples of com.couchbase.client.http.AsyncConnectionRequest


    }, "Couchbase View Thread for node " + addr);
    ioThread.start();
  }

  public boolean writeOp(HttpOperation op) {
    AsyncConnectionRequest connRequest = connMgr.requestConnection();
    try {
      connRequest.waitFor();
    } catch (InterruptedException e) {
      getLogger().warn(
          "Interrupted while trying to get a connection.");
      connRequest.cancel();
      return false;
    }

    NHttpClientConnection conn = connRequest.getConnection();
    if (conn == null) {
      getLogger().debug("Failed to obtain connection on node " + this.addr);
      connRequest.cancel();
      return false;
    } else {
      if (!user.equals("default")) {
        try {
          op.addAuthHeader(HttpUtil.buildAuthHeader(user, pass));
        } catch (UnsupportedEncodingException ex) {
          getLogger().error("Could not create auth header for request, "
            + "could not encode credentials into base64. Canceling op."
            + op, ex);
          op.cancel();
          connRequest.cancel();
        }
      }
      HttpContext context = conn.getContext();
      RequestHandle handle = new RequestHandle(connMgr, conn);
      context.setAttribute("request-handle", handle);
View Full Code Here


    }, "Couchbase View Thread for node " + addr);
    ioThread.start();
  }

  public boolean writeOp(HttpOperation op) {
    AsyncConnectionRequest connRequest = connMgr.requestConnection();
    try {
      connRequest.waitFor();
    } catch (InterruptedException e) {
      getLogger().warn(
          "Interrupted while trying to get a connection.");
      connRequest.cancel();
      return false;
    }

    NHttpClientConnection conn = connRequest.getConnection();
    if (conn == null) {
      getLogger().debug("Failed to obtain connection on node " + this.addr);
      connRequest.cancel();
      return false;
    } else {
      if (!user.equals("default")) {
        try {
          op.addAuthHeader(HttpUtil.buildAuthHeader(user, pass));
        } catch (UnsupportedEncodingException ex) {
          getLogger().error("Could not create auth header for request, "
            + "could not encode credentials into base64. Canceling op."
            + op, ex);
          op.cancel();
          connRequest.cancel();
        }
      }
      HttpContext context = conn.getContext();
      RequestHandle handle = new RequestHandle(connMgr, conn);
      context.setAttribute("request-handle", handle);
View Full Code Here

TOP

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

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.