Package com.aerospike.client.cluster

Examples of com.aerospike.client.cluster.Node


    sb.append(language);
    sb.append(";");
   
    // 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;
View Full Code Here


    }
    return names;
  }
 
  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;
    }
View Full Code Here

   *                 Aerospike 2 servers ignore this parameter.
   * @throws AerospikeException  if scan fails
   */
  public final void scanNode(ScanPolicy policy, String nodeName, String namespace, String setName, ScanCallback callback, String... binNames)
    throws AerospikeException {   
    Node node = cluster.getNode(nodeName);
    scanNode(policy, node, namespace, setName, callback, binNames);
  }
View Full Code Here

    sb.append(language);
    sb.append(";");
   
    // 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

    }
    return names;
  }
 
  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;
    }
View Full Code Here

    dataBuffer[dataOffset++] = id;
  }

  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();
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);
View Full Code Here

    for (int i = 0; i < keys.length; i++) {
      Key key = keys[i];
      Partition partition = new Partition(key);     
      BatchNode batchNode;
     
      Node node = cluster.getNode(partition);
      batchNode = findBatchNode(batchNodes, node);
     
      if (batchNode == null) {
        batchNodes.add(new BatchNode(node, keysPerNode, key.namespace, i));
      }
View Full Code Here

TOP

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

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.