Search in sources :

Example 1 with PartitionTracker

use of com.aerospike.client.query.PartitionTracker in project aerospike-client-java by aerospike.

the class AerospikeClient method scanAll.

/**
 * Asynchronously read all records in specified namespace and set.  If the policy's
 * <code>concurrentNodes</code> is specified, each server node will be read in
 * parallel.  Otherwise, server nodes are read in series.
 * <p>
 * This method registers the command with an event loop and returns.
 * The event loop thread will process the command and send the results to the listener.
 *
 * @param eventLoop				event loop that will process the command. If NULL, the event
 * 								loop will be chosen by round-robin.
 * @param listener				where to send results
 * @param policy				scan configuration parameters, pass in null for defaults
 * @param namespace				namespace - equivalent to database name
 * @param setName				optional set name - equivalent to database table
 * @param binNames				optional bin to retrieve. All bins will be returned if not specified.
 * @throws AerospikeException	if event loop registration fails
 */
public final void scanAll(EventLoop eventLoop, RecordSequenceListener listener, ScanPolicy policy, String namespace, String setName, String... binNames) throws AerospikeException {
    if (eventLoop == null) {
        eventLoop = cluster.eventLoops.next();
    }
    if (policy == null) {
        policy = scanPolicyDefault;
    }
    Node[] nodes = cluster.validateNodes();
    PartitionTracker tracker = new PartitionTracker(policy, nodes);
    new AsyncScanPartitionExecutor(eventLoop, cluster, policy, listener, namespace, setName, binNames, tracker);
}
Also used : PartitionTracker(com.aerospike.client.query.PartitionTracker) Node(com.aerospike.client.cluster.Node) BatchNode(com.aerospike.client.command.BatchNode) AsyncScanPartitionExecutor(com.aerospike.client.async.AsyncScanPartitionExecutor)

Example 2 with PartitionTracker

use of com.aerospike.client.query.PartitionTracker in project aerospike-client-java by aerospike.

the class AerospikeClient method queryPartitions.

/**
 * Execute query for specified partitions and return record iterator.  The query executor puts
 * records on a queue in separate threads.  The calling thread concurrently pops records off
 * the queue through the record iterator.
 *
 * @param policy				query configuration parameters, pass in null for defaults
 * @param statement				query filter. Statement instance is not suitable for
 * 								reuse since it's modified in this method.
 * @param partitionFilter		filter on a subset of data partitions
 * @throws AerospikeException	if query fails
 */
public final RecordSet queryPartitions(QueryPolicy policy, Statement statement, PartitionFilter partitionFilter) throws AerospikeException {
    if (policy == null) {
        policy = queryPolicyDefault;
    }
    Node[] nodes = cluster.validateNodes();
    // A scan will be performed if the secondary index filter is null.
    if (statement.getFilter() == null) {
        PartitionTracker tracker = new PartitionTracker(policy, nodes, partitionFilter);
        QueryPartitionExecutor executor = new QueryPartitionExecutor(cluster, policy, statement, nodes.length, tracker);
        return executor.getRecordSet();
    } else {
        throw new AerospikeException(ResultCode.PARAMETER_ERROR, "queryPartitions() not supported");
    }
}
Also used : PartitionTracker(com.aerospike.client.query.PartitionTracker) Node(com.aerospike.client.cluster.Node) BatchNode(com.aerospike.client.command.BatchNode) AsyncQueryPartitionExecutor(com.aerospike.client.async.AsyncQueryPartitionExecutor) QueryPartitionExecutor(com.aerospike.client.query.QueryPartitionExecutor)

Example 3 with PartitionTracker

use of com.aerospike.client.query.PartitionTracker in project aerospike-client-java by aerospike.

the class AerospikeClient method scanPartitions.

/**
 * Asynchronously read records in specified namespace, set and partition filter.
 * <p>
 * This method registers the command with an event loop and returns.
 * The event loop thread will process the command and send the results to the listener.
 *
 * @param eventLoop				event loop that will process the command. If NULL, the event
 * 								loop will be chosen by round-robin.
 * @param listener				where to send results
 * @param policy				scan configuration parameters, pass in null for defaults
 * @param partitionFilter		filter on a subset of data partitions
 * @param namespace				namespace - equivalent to database name
 * @param setName				optional set name - equivalent to database table
 * @param binNames				optional bin to retrieve. All bins will be returned if not specified.
 * @throws AerospikeException	if event loop registration fails
 */
public final void scanPartitions(EventLoop eventLoop, RecordSequenceListener listener, ScanPolicy policy, PartitionFilter partitionFilter, String namespace, String setName, String... binNames) throws AerospikeException {
    if (eventLoop == null) {
        eventLoop = cluster.eventLoops.next();
    }
    if (policy == null) {
        policy = scanPolicyDefault;
    }
    Node[] nodes = cluster.validateNodes();
    PartitionTracker tracker = new PartitionTracker(policy, nodes, partitionFilter);
    new AsyncScanPartitionExecutor(eventLoop, cluster, policy, listener, namespace, setName, binNames, tracker);
}
Also used : PartitionTracker(com.aerospike.client.query.PartitionTracker) Node(com.aerospike.client.cluster.Node) BatchNode(com.aerospike.client.command.BatchNode) AsyncScanPartitionExecutor(com.aerospike.client.async.AsyncScanPartitionExecutor)

Example 4 with PartitionTracker

use of com.aerospike.client.query.PartitionTracker in project aerospike-client-java by aerospike.

the class AerospikeClient method queryNode.

/**
 * Execute query on a single server node and return record iterator.  The query executor puts
 * records on a queue in a separate thread.  The calling thread concurrently pops records off
 * the queue through the record iterator.
 *
 * @param policy				query configuration parameters, pass in null for defaults
 * @param statement				query filter. Statement instance is not suitable for
 * 								reuse since it's modified in this method.
 * @param node					server node to execute query
 * @return						record iterator
 * @throws AerospikeException	if query fails
 */
public final RecordSet queryNode(QueryPolicy policy, Statement statement, Node node) throws AerospikeException {
    if (policy == null) {
        policy = queryPolicyDefault;
    }
    // A scan will be performed if the secondary index filter is null.
    if (statement.getFilter() == null) {
        PartitionTracker tracker = new PartitionTracker(policy, node);
        QueryPartitionExecutor executor = new QueryPartitionExecutor(cluster, policy, statement, 1, tracker);
        return executor.getRecordSet();
    } else {
        QueryRecordExecutor executor = new QueryRecordExecutor(cluster, policy, statement, new Node[] { node });
        executor.execute();
        return executor.getRecordSet();
    }
}
Also used : QueryRecordExecutor(com.aerospike.client.query.QueryRecordExecutor) PartitionTracker(com.aerospike.client.query.PartitionTracker) AsyncQueryPartitionExecutor(com.aerospike.client.async.AsyncQueryPartitionExecutor) QueryPartitionExecutor(com.aerospike.client.query.QueryPartitionExecutor)

Example 5 with PartitionTracker

use of com.aerospike.client.query.PartitionTracker in project aerospike-client-java by aerospike.

the class AerospikeClient method scanPartitions.

/**
 * Read records in specified namespace, set and partition filter.
 * <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 partitionFilter		filter on a subset of data partitions
 * @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
 * @throws AerospikeException	if scan fails
 */
public final void scanPartitions(ScanPolicy policy, PartitionFilter partitionFilter, String namespace, String setName, ScanCallback callback, String... binNames) throws AerospikeException {
    if (policy == null) {
        policy = scanPolicyDefault;
    }
    Node[] nodes = cluster.validateNodes();
    PartitionTracker tracker = new PartitionTracker(policy, nodes, partitionFilter);
    ScanExecutor.scanPartitions(cluster, policy, namespace, setName, binNames, callback, tracker);
}
Also used : PartitionTracker(com.aerospike.client.query.PartitionTracker) Node(com.aerospike.client.cluster.Node) BatchNode(com.aerospike.client.command.BatchNode)

Aggregations

PartitionTracker (com.aerospike.client.query.PartitionTracker)10 Node (com.aerospike.client.cluster.Node)8 BatchNode (com.aerospike.client.command.BatchNode)8 AsyncQueryPartitionExecutor (com.aerospike.client.async.AsyncQueryPartitionExecutor)5 QueryPartitionExecutor (com.aerospike.client.query.QueryPartitionExecutor)3 AsyncScanPartitionExecutor (com.aerospike.client.async.AsyncScanPartitionExecutor)2 QueryRecordExecutor (com.aerospike.client.query.QueryRecordExecutor)2 AsyncQueryExecutor (com.aerospike.client.async.AsyncQueryExecutor)1