Package com.aerospike.client.cluster

Examples of com.aerospike.client.cluster.Node


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


        int failedConns = 0;
        int iterations = 0;

        // Execute command until successful, timed out or maximum iterations have been reached.
    while (true) {
      Node node = null;
      try {   
        node = getNode();
        Connection conn = node.getConnection(remainingMillis);
       
        try {
          // Reset timeout in send buffer (destined for server) and socket.
          Buffer.intToBytes(remainingMillis, sendBuffer, 22);
         
          // Send command.
          send(conn);
         
          // Parse results.
          parseResult(conn.getInputStream());
         
          // Reflect healthy status.
          conn.updateLastUsed();
          node.restoreHealth();
         
          // Put connection back in pool.
          node.putConnection(conn);
         
          // Command has completed successfully.  Exit method.
          return;
        }
        catch (AerospikeException ae) {
          // Close socket to flush out possible garbage.  Do not put back in pool.
          conn.close();
          throw ae;
        }
        catch (RuntimeException re) {
          // All runtime exceptions are considered fatal.  Do not retry.
          // Close socket to flush out possible garbage.  Do not put back in pool.
          conn.close();
          throw re;
        }
        catch (IOException ioe) {
          // IO errors are considered temporary anomalies.  Retry.
          // Close socket to flush out possible garbage.  Do not put back in pool.
          conn.close();
         
          if (Log.debugEnabled()) {
            Log.debug("Node " + node + ": " + Util.getErrorMessage(ioe));
          }
          // IO error means connection to server node is unhealthy.
          // Reflect this status.
          node.decreaseHealth();
        }
      }
      catch (AerospikeException.InvalidNode ine) {
        // Node is currently inactive.  Retry.
        failedNodes++;
      }
      catch (AerospikeException.Connection ce) {
        // Socket connection error has occurred. Decrease health and retry.
        node.decreaseHealth();
       
        if (Log.debugEnabled()) {
          Log.debug("Node " + node + ": " + Util.getErrorMessage(ce));
        }
        failedConns++; 
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();
     
      while (parser.next()) {
        String name = parser.getName();

        if (name.equals("error")) {
          throw new AerospikeException(serverPath + " registration failed: " + parser.getValue());
        }
      }
      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

        int failedConns = 0;
        int iterations = 0;

        // Execute command until successful, timed out or maximum iterations have been reached.
    while (true) {
      Node node = null;
      try {   
        node = getNode();
        Connection conn = node.getConnection(remainingMillis);
       
        try {
          // Set command buffer.
          writeBuffer();

          // Reset timeout in send buffer (destined for server) and socket.
          Buffer.intToBytes(remainingMillis, dataBuffer, 22);
         
          // Send command.
          conn.write(dataBuffer, dataOffset);
         
          // Parse results.
          parseResult(conn);
         
          // Reflect healthy status.
          conn.updateLastUsed();
          node.restoreHealth();
         
          // Put connection back in pool.
          node.putConnection(conn);
         
          // Command has completed successfully.  Exit method.
          return;
        }
        catch (AerospikeException ae) {
          // Close socket to flush out possible garbage.  Do not put back in pool.
          conn.close();
          throw ae;
        }
        catch (RuntimeException re) {
          // All runtime exceptions are considered fatal.  Do not retry.
          // Close socket to flush out possible garbage.  Do not put back in pool.
          conn.close();
          throw re;
        }
        catch (IOException ioe) {
          // IO errors are considered temporary anomalies.  Retry.
          // Close socket to flush out possible garbage.  Do not put back in pool.
          conn.close();
         
          if (Log.debugEnabled()) {
            Log.debug("Node " + node + ": " + Util.getErrorMessage(ioe));
          }
          // IO error means connection to server node is unhealthy.
          // Reflect this status.
          node.decreaseHealth();
        }
      }
      catch (AerospikeException.InvalidNode ine) {
        // Node is currently inactive.  Retry.
        failedNodes++;
      }
      catch (AerospikeException.Connection ce) {
        // Socket connection error has occurred. Decrease health and retry.
        node.decreaseHealth();
       
        if (Log.debugEnabled()) {
          Log.debug("Node " + node + ": " + Util.getErrorMessage(ce));
        }
        failedConns++; 
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 (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

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.