Search in sources :

Example 6 with BatchPolicy

use of com.aerospike.client.policy.BatchPolicy in project aerospike-client-java by aerospike.

the class AsyncClient method get.

/**
 * Asynchronously read multiple records for specified batch keys in one batch call.
 * This method allows different namespaces/bins to be requested for each key in the batch.
 * The returned records are located in the same list.
 * If the BatchRead key field is not found, the corresponding record field will be null.
 * <p>
 * This method schedules the get command with a channel selector and returns.
 * Another thread will process the command and send the results to the listener in a single call.
 * This method requires Aerospike Server version >= 3.6.0.
 *
 * @param policy				batch configuration parameters, pass in null for defaults
 * @param listener				where to send results
 * @param records				list of unique record identifiers and the bins to retrieve.
 * @throws AerospikeException	if read fails
 */
public final void get(final BatchPolicy policy, final BatchSequenceListener listener, final List<BatchRead> records) throws AerospikeException {
    final BatchPolicy bp = (policy != null) ? policy : asyncBatchPolicyDefault;
    if (useListener) {
        // Reserve one command for each node.
        final int commands = cluster.getNodes().length;
        commandBegin(commands, new Runnable() {

            public void run() {
                get(findEventLoop(), new ABatchSequenceListener(listener, commands), bp, records);
            }
        });
    } else {
        get(findEventLoop(), listener, bp, records);
    }
}
Also used : BatchPolicy(com.aerospike.client.policy.BatchPolicy)

Example 7 with BatchPolicy

use of com.aerospike.client.policy.BatchPolicy in project aerospike-client-java by aerospike.

the class AsyncClient method getHeader.

/**
 * Asynchronously read multiple record header data for specified keys in one batch call.
 * This method schedules the get command with a channel selector and returns.
 * Another thread will process the command and send the results to the listener in a single call.
 * <p>
 * If a key is not found, the record will be null.
 * The policy can be used to specify timeouts and maximum parallel commands.
 *
 * @param policy				batch configuration parameters, pass in null for defaults
 * @param listener				where to send results
 * @param keys					array of unique record identifiers
 * @throws AerospikeException	if queue is full
 */
public final void getHeader(final BatchPolicy policy, final RecordArrayListener listener, final Key[] keys) throws AerospikeException {
    final BatchPolicy bp = (policy != null) ? policy : asyncBatchPolicyDefault;
    if (useListener) {
        // Reserve one command for each node.
        final int commands = cluster.getNodes().length;
        commandBegin(commands, new Runnable() {

            public void run() {
                getHeader(findEventLoop(), new ARecordArrayListener(listener, commands), bp, keys);
            }
        });
    } else {
        getHeader(findEventLoop(), listener, bp, keys);
    }
}
Also used : BatchPolicy(com.aerospike.client.policy.BatchPolicy)

Example 8 with BatchPolicy

use of com.aerospike.client.policy.BatchPolicy in project aerospike-client-java by aerospike.

the class AsyncClient method get.

/**
 * Asynchronously read multiple records for specified keys in one batch call.
 * This method schedules the get command with a channel selector and returns.
 * Another thread will process the command and send the results to the listener in multiple unordered calls.
 * <p>
 * If a key is not found, the record will be null.
 * The policy can be used to specify timeouts and maximum parallel commands.
 *
 * @param policy				batch configuration parameters, pass in null for defaults
 * @param listener				where to send results
 * @param keys					array of unique record identifiers
 * @throws AerospikeException	if queue is full
 */
public final void get(final BatchPolicy policy, final RecordSequenceListener listener, final Key[] keys) throws AerospikeException {
    final BatchPolicy bp = (policy != null) ? policy : asyncBatchPolicyDefault;
    if (useListener) {
        // Reserve one command for each node.
        final int commands = cluster.getNodes().length;
        commandBegin(commands, new Runnable() {

            public void run() {
                get(findEventLoop(), new ARecordSequenceListener(listener, commands), bp, keys);
            }
        });
    } else {
        get(findEventLoop(), listener, bp, keys);
    }
}
Also used : BatchPolicy(com.aerospike.client.policy.BatchPolicy)

Example 9 with BatchPolicy

use of com.aerospike.client.policy.BatchPolicy in project aerospike-client-java by aerospike.

the class AsyncClient method exists.

/**
 * Asynchronously check if multiple record keys exist in one batch call.
 * This method schedules the exists command with a channel selector and returns.
 * Another thread will process the command and send the results to the listener in multiple unordered calls.
 * <p>
 * The policy can be used to specify timeouts and maximum parallel commands.
 *
 * @param policy				batch configuration parameters, pass in null for defaults
 * @param listener				where to send results
 * @param keys					array of unique record identifiers
 * @throws AerospikeException	if queue is full
 */
public final void exists(final BatchPolicy policy, final ExistsSequenceListener listener, final Key[] keys) throws AerospikeException {
    final BatchPolicy bp = (policy != null) ? policy : asyncBatchPolicyDefault;
    if (useListener) {
        // Reserve one command for each node.
        final int commands = cluster.getNodes().length;
        commandBegin(commands, new Runnable() {

            public void run() {
                exists(findEventLoop(), new AExistsSequenceListener(listener, commands), bp, keys);
            }
        });
    } else {
        exists(findEventLoop(), listener, bp, keys);
    }
}
Also used : BatchPolicy(com.aerospike.client.policy.BatchPolicy)

Example 10 with BatchPolicy

use of com.aerospike.client.policy.BatchPolicy in project aerospike-client-java by aerospike.

the class AsyncClient method get.

/**
 * Asynchronously read multiple records for specified keys in one batch call.
 * This method schedules the get command with a channel selector and returns.
 * Another thread will process the command and send the results to the listener in a single call.
 * <p>
 * If a key is not found, the record will be null.
 * The policy can be used to specify timeouts and maximum parallel commands.
 *
 * @param policy				batch configuration parameters, pass in null for defaults
 * @param listener				where to send results
 * @param keys					array of unique record identifiers
 * @throws AerospikeException	if queue is full
 */
public final void get(final BatchPolicy policy, final RecordArrayListener listener, final Key[] keys) throws AerospikeException {
    final BatchPolicy bp = (policy != null) ? policy : asyncBatchPolicyDefault;
    if (useListener) {
        // Reserve one command for each node.
        final int commands = cluster.getNodes().length;
        commandBegin(commands, new Runnable() {

            public void run() {
                get(findEventLoop(), new ARecordArrayListener(listener, commands), bp, keys);
            }
        });
    } else {
        get(findEventLoop(), listener, bp, keys);
    }
}
Also used : BatchPolicy(com.aerospike.client.policy.BatchPolicy)

Aggregations

BatchPolicy (com.aerospike.client.policy.BatchPolicy)11 Key (com.aerospike.client.Key)1 Record (com.aerospike.client.Record)1 Test (org.junit.Test)1