Package com.aerospike.client.cluster

Examples of com.aerospike.client.cluster.Connection


  }
 
  private String sendInfoCommand(Policy policy, String command) throws AerospikeException {   
    Node node = cluster.getRandomNode();
    int timeout = (policy == null)? 0 : policy.timeout;
    Connection conn = node.getConnection(timeout);
    Info info;
   
    try {
      info = new Info(conn, command);
      node.putConnection(conn);
    }
    catch (RuntimeException re) {
      conn.close();
      throw re;
    }
    return info.getValue();
  }
View Full Code Here


   *
   * @param node    server node
   * @param name    name of variable to retrieve
   */
  public static String request(Node node, String name) throws AerospikeException {
    Connection conn = node.getConnection(DEFAULT_TIMEOUT);

    try  {
      String response = Info.request(conn, name);
      node.putConnection(conn);
      return response;
    }
    catch (AerospikeException ae) {
      conn.close();
      throw ae;
    }
    catch (RuntimeException re) {
      conn.close();
      throw re;
    }
  }
View Full Code Here

  private void executeCommand(Cluster cluster, AdminPolicy policy) throws AerospikeException {
    writeSize();
    Node node = cluster.getRandomNode();
    int timeout = (policy == null) ? 1000 : policy.timeout;
    Connection conn = node.getConnection(timeout);

    try {
      conn.write(dataBuffer, dataOffset);
      conn.readFully(dataBuffer, HEADER_SIZE);
      node.putConnection(conn);
    }
    catch (Exception e) {
      // All IO exceptions are considered fatal.  Do not retry.
      // Close socket to flush out possible garbage.  Do not put back in pool.
      conn.close();
      throw new AerospikeException(e);
    }

    int result = dataBuffer[RESULT_CODE];
View Full Code Here

  public void readUsers(Cluster cluster, AdminPolicy policy, List<UserRoles> list) throws AerospikeException {
    writeSize();
    Node node = cluster.getRandomNode();
    int timeout = (policy == null) ? 1000 : policy.timeout;
    int status = 0;
    Connection conn = node.getConnection(timeout);

    try {
      conn.write(dataBuffer, dataOffset);
      status = readUserBlocks(conn, list);
      node.putConnection(conn);
    }
    catch (Exception e) {
      // Garbage may be in socket.  Do not put back into pool.
      conn.close();
      throw new AerospikeException(e);
    }

    if (status > 0) {
      throw new AerospikeException(status, "Query users failed.");
View Full Code Here

TOP

Related Classes of com.aerospike.client.cluster.Connection

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.