protected final void initializeThreads() { // Detect cluster migrations when performing scan. long clusterKey = policy.failOnClusterChange ? QueryValidate.validateBegin(nodes[0], statement.namespace) : 0; boolean first = true; // Initialize threads. for (int i = 0; i < nodes.length; i++) { MultiCommand command = createCommand(clusterKey, first); threads[i] = new QueryThread(nodes[i], command); first = false; } }
public static void validate(Node node, String namespace, long expectedKey) { if (expectedKey == 0 || ! node.hasClusterStable()) { return; } // Fail when cluster is in migration. long clusterKey = validateBegin(node, namespace); if (clusterKey != expectedKey) { throw new AerospikeException(ResultCode.QUERY_ABORTED, "Cluster is in migration: " + expectedKey + ' ' + clusterKey); } } }
public static void validate(Node node, String namespace, long expectedKey) { if (expectedKey == 0 || ! node.hasClusterStable()) { return; } // Fail when cluster is in migration. long clusterKey = validateBegin(node, namespace); if (clusterKey != expectedKey) { throw new AerospikeException(ResultCode.QUERY_ABORTED, "Cluster is in migration: " + expectedKey + ' ' + clusterKey); } } }
protected final void initializeThreads() { // Detect cluster migrations when performing scan. long clusterKey = policy.failOnClusterChange ? QueryValidate.validateBegin(nodes[0], statement.namespace) : 0; boolean first = true; // Initialize threads. for (int i = 0; i < nodes.length; i++) { MultiCommand command = createCommand(clusterKey, first); threads[i] = new QueryThread(nodes[i], command); first = false; } }
/** * Read all records in specified namespace and set for one node only. * <p> * This call will block until the scan is complete - callbacks are made * within the scope of this call. * * @param policy scan configuration parameters, pass in null for defaults * @param node server node * @param namespace namespace - equivalent to database name * @param setName optional set name - equivalent to database table * @param callback read callback method - called with record data * @param binNames optional bin to retrieve. All bins will be returned if not specified. * Aerospike 2 servers ignore this parameter. * @throws AerospikeException if transaction fails */ public final void scanNode(ScanPolicy policy, Node node, String namespace, String setName, ScanCallback callback, String... binNames) throws AerospikeException { if (policy == null) { policy = scanPolicyDefault; } if (policy.scanPercent <= 0 || policy.scanPercent > 100) { throw new AerospikeException(ResultCode.PARAMETER_ERROR, "Invalid scan percent: " + policy.scanPercent); } // Detect cluster migrations when performing scan. long clusterKey = policy.failOnClusterChange ? QueryValidate.validateBegin(node, namespace) : 0; long taskId = RandomShift.instance().nextLong(); ScanCommand command = new ScanCommand(policy, namespace, setName, callback, binNames, taskId, clusterKey, true); command.execute(cluster, policy, node); }
/** * Read all records in specified namespace and set for one node only. * <p> * This call will block until the scan is complete - callbacks are made * within the scope of this call. * * @param policy scan configuration parameters, pass in null for defaults * @param node server node * @param namespace namespace - equivalent to database name * @param setName optional set name - equivalent to database table * @param callback read callback method - called with record data * @param binNames optional bin to retrieve. All bins will be returned if not specified. * Aerospike 2 servers ignore this parameter. * @throws AerospikeException if transaction fails */ public final void scanNode(ScanPolicy policy, Node node, String namespace, String setName, ScanCallback callback, String... binNames) throws AerospikeException { if (policy == null) { policy = scanPolicyDefault; } if (policy.scanPercent <= 0 || policy.scanPercent > 100) { throw new AerospikeException(ResultCode.PARAMETER_ERROR, "Invalid scan percent: " + policy.scanPercent); } // Detect cluster migrations when performing scan. long clusterKey = policy.failOnClusterChange ? QueryValidate.validateBegin(node, namespace) : 0; long taskId = RandomShift.instance().nextLong(); ScanCommand command = new ScanCommand(policy, namespace, setName, callback, binNames, taskId, clusterKey, true); command.execute(cluster, policy, node); }
long clusterKey = policy.failOnClusterChange ? QueryValidate.validateBegin(nodes[0], namespace) : 0; long taskId = RandomShift.instance().nextLong(); boolean first = true;
long clusterKey = policy.failOnClusterChange ? QueryValidate.validateBegin(nodes[0], namespace) : 0; long taskId = RandomShift.instance().nextLong(); boolean first = true;