Package com.aerospike.client.cluster

Examples of com.aerospike.client.cluster.Connection


   *
   * @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 (RuntimeException re) {
      conn.close();
      throw re;
    }
  }
View Full Code Here


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

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

   * @param node    server node
   * @param names    names of variables to retrieve
   */
  public static Map<String,String> request(InfoPolicy policy, Node node, String... names) throws AerospikeException {
    int timeout = (policy == null) ? DEFAULT_TIMEOUT : policy.timeout;
    Connection conn = node.getConnection(timeout);

    try {
      Map<String,String> result = request(conn, names);
      node.putConnection(conn);
      return result;
    }
    catch (RuntimeException re) {
      conn.close();
      throw re;
    }
  }
View Full Code Here

   * @param policy  info command configuration parameters, pass in null for defaults
   * @param node    server node
   */
  public static Map<String,String> request(InfoPolicy policy, Node node) throws AerospikeException {
    int timeout = (policy == null) ? DEFAULT_TIMEOUT : policy.timeout;
    Connection conn = node.getConnection(timeout);

    try {
      Map<String,String> result = request(conn);
      node.putConnection(conn);
      return result;
    }
    catch (RuntimeException re) {
      conn.close();
      throw re;
    }
  }
View Full Code Here

   * @param name          name of value to retrieve
   * @return            info value
   */
  public static String request(InetSocketAddress socketAddress, String name)
    throws AerospikeException
    Connection conn = new Connection(socketAddress, DEFAULT_TIMEOUT);
   
    try {
      return request(conn, name);
    }
    finally {
      conn.close();
    }
  }
View Full Code Here

   * @param names          names of values to retrieve
   * @return            info name/value pairs
   */
  public static HashMap<String,String> request(InetSocketAddress socketAddress, String... names)
    throws AerospikeException {
    Connection conn = new Connection(socketAddress, DEFAULT_TIMEOUT);
   
    try {
      return request(conn, names);
    }
    finally {
      conn.close();
    }   
  }
View Full Code Here

   * @param socketAddress      <code>InetSocketAddress</code> of server node
   * @return            info name/value pairs
   */
  public static HashMap<String,String> request(InetSocketAddress socketAddress)
    throws AerospikeException {
    Connection conn = new Connection(socketAddress, DEFAULT_TIMEOUT);

    try {
      return request(conn);
    }
    finally {
      conn.close();
    }   
  }
View Full Code Here

   
    // Send UDF to one node. That node will distribute the UDF to other nodes.
    String command = sb.toString();
    Node node = cluster.getRandomNode();
    int timeout = (policy == null)? 0 : policy.timeout;
    Connection conn = node.getConnection(timeout);
   
    try {     
      Info info = new Info(conn, command);
      NameValueParser parser = info.getNameValueParser();
      String error = null;
      String file = null;
      String line = null;
      String message = null;
     
      while (parser.next()) {
        String name = parser.getName();

        if (name.equals("error")) {
          error = parser.getValue();
        }
        else if (name.equals("file")) {
          file = parser.getValue();       
        }
        else if (name.equals("line")) {
          line = parser.getValue();       
        }
        else if (name.equals("message")) {
          message = parser.getStringBase64();         
        }
      }
     
      if (error != null) {     
        throw new AerospikeException("Registration failed: " + error + Environment.Newline +
          "File: " + file + Environment.Newline +
          "Line: " + line + Environment.Newline +
          "Message: " + message
          );
      }
     
      node.putConnection(conn);
      return new RegisterTask(cluster, serverPath);
    }
    catch (AerospikeException ae) {
      conn.close();
      throw ae;
    }
    catch (RuntimeException re) {
      conn.close();
      throw new AerospikeException(re);
    }
  }
View Full Code Here

  }
 
  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 (AerospikeException ae) {
      conn.close();
      throw ae;
    }
    catch (RuntimeException re) {
      conn.close();
      throw new AerospikeException(re);
    }
    return info.getValue();
  }
View Full Code Here

   
    // Send UDF to one node. That node will distribute the UDF to other nodes.
    String command = sb.toString();
    Node node = cluster.getRandomNode();
    int timeout = (policy == null)? 0 : policy.timeout;
    Connection conn = node.getConnection(timeout);
   
    try {     
      Info info = new Info(conn, command);
      NameValueParser parser = info.getNameValueParser();
      String error = null;
      String file = null;
      String line = null;
      String message = null;
     
      while (parser.next()) {
        String name = parser.getName();

        if (name.equals("error")) {
          error = parser.getValue();
        }
        else if (name.equals("file")) {
          file = parser.getValue();       
        }
        else if (name.equals("line")) {
          line = parser.getValue();       
        }
        else if (name.equals("message")) {
          message = parser.getStringBase64();         
        }
      }
     
      if (error != null) {     
        throw new AerospikeException("Registration failed: " + error + Environment.Newline +
          "File: " + file + Environment.Newline +
          "Line: " + line + Environment.Newline +
          "Message: " + message
          );
      }
     
      node.putConnection(conn);
      return new RegisterTask(cluster, serverPath);
    }
    catch (RuntimeException re) {
      conn.close();
      throw re;
    }
  }
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.