Пример #1
0
 public QueryPartitionCommand
 (
     Cluster cluster,
     Node node,
     Policy policy,
     Statement statement,
     RecordSet recordSet,
     PartitionTracker tracker,
     NodePartitions nodePartitions
 ) : base(cluster, policy, nodePartitions.node, statement.ns, tracker.socketTimeout, tracker.totalTimeout)
 {
     this.statement      = statement;
     this.recordSet      = recordSet;
     this.tracker        = tracker;
     this.nodePartitions = nodePartitions;
 }
Пример #2
0
        public AsyncQueryPartitionExecutor
        (
            AsyncCluster cluster,
            QueryPolicy policy,
            RecordSequenceListener listener,
            Statement statement,
            PartitionTracker tracker
        ) : base(cluster)
        {
            this.policy    = policy;
            this.listener  = listener;
            this.statement = statement;
            this.tracker   = tracker;

            statement.returnData        = true;
            tracker.SleepBetweenRetries = 0;
            QueryPartitions();
        }
 public QueryPartitionExecutor
 (
     Cluster cluster,
     QueryPolicy policy,
     Statement statement,
     int nodeCapacity,
     PartitionTracker tracker
 )
 {
     this.cluster         = cluster;
     this.policy          = policy;
     statement.returnData = true;
     this.statement       = statement;
     this.threads         = new List <QueryThread>(nodeCapacity);
     this.cancel          = new CancellationTokenSource();
     this.tracker         = tracker;
     this.recordSet       = new RecordSet(this, policy.recordQueueSize, cancel.Token);
     ThreadPool.QueueUserWorkItem(this.Run);
 }
 public ScanPartitionCommand
 (
     Cluster cluster,
     ScanPolicy scanPolicy,
     string ns,
     string setName,
     string[] binNames,
     ScanCallback callback,
     ulong taskId,
     PartitionTracker tracker,
     NodePartitions nodePartitions
 ) : base(cluster, scanPolicy, nodePartitions.node, ns, tracker.socketTimeout, tracker.totalTimeout)
 {
     this.scanPolicy     = scanPolicy;
     this.setName        = setName;
     this.binNames       = binNames;
     this.callback       = callback;
     this.taskId         = taskId;
     this.tracker        = tracker;
     this.nodePartitions = nodePartitions;
 }
Пример #5
0
        public AsyncScanPartitionExecutor
        (
            AsyncCluster cluster,
            ScanPolicy policy,
            RecordSequenceListener listener,
            string ns,
            string setName,
            string[] binNames,
            PartitionTracker tracker
        ) : base(cluster)
        {
            this.policy   = policy;
            this.listener = listener;
            this.ns       = ns;
            this.setName  = setName;
            this.binNames = binNames;
            this.tracker  = tracker;

            policy.Validate();
            tracker.SleepBetweenRetries = 0;
            ScanPartitions();
        }
        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);
                }
            }
        }