public static void ScanPartitions(Cluster cluster, ScanPolicy policy, string ns, string setName, string[] binNames, ScanCallback callback, PartitionTracker tracker)
        {
            policy.Validate();

            while (true)
            {
                ulong taskId = RandomShift.ThreadLocalInstance.NextLong();

                try
                {
                    List <NodePartitions> list = tracker.AssignPartitionsToNodes(cluster, ns);

                    if (policy.concurrentNodes && list.Count > 1)
                    {
                        Executor executor = new Executor(list.Count);

                        foreach (NodePartitions nodePartitions in list)
                        {
                            ScanPartitionCommand command = new ScanPartitionCommand(cluster, policy, ns, setName, binNames, callback, taskId, tracker, nodePartitions);
                            executor.AddCommand(command);
                        }

                        executor.Execute(policy.maxConcurrentNodes);
                    }
                    else
                    {
                        foreach (NodePartitions nodePartitions in list)
                        {
                            ScanPartitionCommand command = new ScanPartitionCommand(cluster, policy, ns, setName, binNames, callback, taskId, tracker, nodePartitions);
                            command.Execute();
                        }
                    }
                }
                catch (AerospikeException ae)
                {
                    ae.Iteration = tracker.iteration;
                    throw ae;
                }

                if (tracker.IsComplete(policy))
                {
                    // Scan is complete.
                    return;
                }

                if (policy.sleepBetweenRetries > 0)
                {
                    // Sleep before trying again.
                    Util.Sleep(policy.sleepBetweenRetries);
                }
            }
        }
Example #2
0
        private void ScanPartitions()
        {
            ulong taskId = RandomShift.ThreadLocalInstance.NextLong();
            List <NodePartitions> nodePartitionsList = tracker.AssignPartitionsToNodes(cluster, ns);

            AsyncScanPartition[] tasks = new AsyncScanPartition[nodePartitionsList.Count];
            int count = 0;

            foreach (NodePartitions nodePartitions in nodePartitionsList)
            {
                tasks[count++] = new AsyncScanPartition(this, cluster, policy, listener, ns, setName, binNames, taskId, tracker, nodePartitions);
            }
            Execute(tasks, policy.maxConcurrentNodes);
        }