public AsyncBatchReadListExecutor ( AsyncCluster cluster, BatchPolicy policy, BatchListListener listener, List <BatchRead> records ) { this.listener = listener; this.records = records; // Create commands. List <BatchNode> batchNodes = BatchNode.GenerateList(cluster, policy, records); AsyncMultiCommand[] tasks = new AsyncMultiCommand[batchNodes.Count]; int count = 0; foreach (BatchNode batchNode in batchNodes) { if (!batchNode.node.hasBatchIndex) { throw new AerospikeException(ResultCode.PARAMETER_ERROR, "Requested command requires a server that supports new batch index protocol."); } tasks[count++] = new AsyncBatchReadListCommand(this, cluster, batchNode, policy, records); } // Dispatch commands to nodes. Execute(tasks, policy.maxConcurrentThreads); }
public AsyncBatchReadListExecutor ( AsyncCluster cluster, BatchPolicy policy, BatchListListener listener, List <BatchRead> records ) : base(cluster) { this.listener = listener; this.records = records; // Create commands. List <BatchNode> batchNodes = BatchNode.GenerateList(cluster, policy, records); AsyncMultiCommand[] tasks = new AsyncMultiCommand[batchNodes.Count]; int count = 0; foreach (BatchNode batchNode in batchNodes) { tasks[count++] = new AsyncBatchReadListCommand(this, cluster, batchNode, policy, records); } // Dispatch commands to nodes. Execute(tasks, 0); }
public AsyncBatchReadListExecutor( AsyncCluster cluster, BatchPolicy policy, BatchListListener listener, List<BatchRead> records ) { this.listener = listener; this.records = records; // Create commands. List<BatchNode> batchNodes = BatchNode.GenerateList(cluster, policy, records); AsyncMultiCommand[] tasks = new AsyncMultiCommand[batchNodes.Count]; int count = 0; foreach (BatchNode batchNode in batchNodes) { if (!batchNode.node.hasBatchIndex) { throw new AerospikeException(ResultCode.PARAMETER_ERROR, "Requested command requires a server that supports new batch index protocol."); } tasks[count++] = new AsyncBatchReadListCommand(this, cluster, batchNode, policy, records); } // Dispatch commands to nodes. Execute(tasks, policy.maxConcurrentThreads); }
/// <summary> /// 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 BatchRecord key field is not found, the corresponding record field will be null. /// <para> /// 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. /// </para> /// </summary> /// <param name="policy">batch configuration parameters, pass in null for defaults</param> /// <param name="listener">where to send results</param> /// <param name="records">list of unique record identifiers and the bins to retrieve.</param> /// <exception cref="AerospikeException">if read fails</exception> public void Get(BatchPolicy policy, BatchListListener listener, List<BatchRead> records) { if (records.Count == 0) { listener.OnSuccess(records); return; } if (policy == null) { policy = batchPolicyDefault; } new AsyncBatchReadListExecutor(cluster, policy, listener, records); }