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);
                }
            }
        }
Beispiel #2
0
        protected internal override void OnSuccess()
        {
            try
            {
                if (tracker.IsComplete(policy))
                {
                    listener.OnSuccess();
                    return;
                }

                // Prepare for retry.
                Reset();
                ScanPartitions();
            }
            catch (AerospikeException ae)
            {
                OnFailure(ae);
            }
            catch (Exception e)
            {
                OnFailure(new AerospikeException(e));
            }
        }