Search in sources :

Example 1 with AsyncQueryPartitionExecutor

use of com.aerospike.client.async.AsyncQueryPartitionExecutor in project aerospike-client-java by aerospike.

the class AerospikeClient method queryPartitions.

/**
 * Asynchronously execute query for specified partitions.
 * 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.
 * <p>
 * Each record result is returned in separate onRecord() calls.
 *
 * @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				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 void queryPartitions(EventLoop eventLoop, RecordSequenceListener listener, QueryPolicy policy, Statement statement, PartitionFilter partitionFilter) throws AerospikeException {
    if (eventLoop == null) {
        eventLoop = cluster.eventLoops.next();
    }
    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);
        new AsyncQueryPartitionExecutor(eventLoop, listener, cluster, policy, statement, tracker);
    } else {
        throw new AerospikeException(ResultCode.PARAMETER_ERROR, "queryPartitions() not supported");
    }
}
Also used : PartitionTracker(com.aerospike.client.query.PartitionTracker) AsyncQueryPartitionExecutor(com.aerospike.client.async.AsyncQueryPartitionExecutor) Node(com.aerospike.client.cluster.Node) BatchNode(com.aerospike.client.command.BatchNode)

Example 2 with AsyncQueryPartitionExecutor

use of com.aerospike.client.async.AsyncQueryPartitionExecutor in project aerospike-client-java by aerospike.

the class AerospikeClient method query.

/**
 * Asynchronously execute query on all server nodes.
 * 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.
 * <p>
 * Each record result is returned in separate onRecord() calls.
 *
 * @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				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.
 * @throws AerospikeException	if event loop registration fails
 */
public final void query(EventLoop eventLoop, RecordSequenceListener listener, QueryPolicy policy, Statement statement) throws AerospikeException {
    if (eventLoop == null) {
        eventLoop = cluster.eventLoops.next();
    }
    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);
        new AsyncQueryPartitionExecutor(eventLoop, listener, cluster, policy, statement, tracker);
    } else {
        new AsyncQueryExecutor(eventLoop, listener, cluster, policy, statement, nodes);
    }
}
Also used : PartitionTracker(com.aerospike.client.query.PartitionTracker) AsyncQueryPartitionExecutor(com.aerospike.client.async.AsyncQueryPartitionExecutor) Node(com.aerospike.client.cluster.Node) BatchNode(com.aerospike.client.command.BatchNode) AsyncQueryExecutor(com.aerospike.client.async.AsyncQueryExecutor)

Aggregations

AsyncQueryPartitionExecutor (com.aerospike.client.async.AsyncQueryPartitionExecutor)2 Node (com.aerospike.client.cluster.Node)2 BatchNode (com.aerospike.client.command.BatchNode)2 PartitionTracker (com.aerospike.client.query.PartitionTracker)2 AsyncQueryExecutor (com.aerospike.client.async.AsyncQueryExecutor)1