Esempio n. 1
0
        public void SetDigest(NodePartitions nodePartitions, Key key)
        {
            uint partitionId = Partition.GetPartitionId(key.digest);

            partitionsAll[partitionId - partitionBegin].digest = key.digest;
            nodePartitions.recordCount++;
        }
Esempio n. 2
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;
 }
 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;
 }
Esempio n. 4
0
 public void PartitionDone(NodePartitions nodePartitions, int partitionId)
 {
     partitionsAll[partitionId - partitionBegin].done = true;
     nodePartitions.partsReceived++;
 }
Esempio n. 5
0
        public List <NodePartitions> AssignPartitionsToNodes(Cluster cluster, string ns)
        {
            //Log.Info("Round " + iteration);
            List <NodePartitions> list = new List <NodePartitions>(nodeCapacity);

            Dictionary <string, Partitions> map = cluster.partitionMap;
            Partitions partitions;

            if (!map.TryGetValue(ns, out partitions))
            {
                throw new AerospikeException.InvalidNamespace(ns, map.Count);
            }

            Node[] master = partitions.replicas[0];

            foreach (PartitionStatus part in partitionsAll)
            {
                if (!part.done)
                {
                    Node node = Volatile.Read(ref master[part.id]);

                    if (node == null)
                    {
                        throw new AerospikeException.InvalidNode(part.id);
                    }

                    // Use node name to check for single node equality because
                    // partition map may be in transitional state between
                    // the old and new node with the same name.
                    if (nodeFilter != null && !nodeFilter.Name.Equals(node.Name))
                    {
                        continue;
                    }

                    NodePartitions np = FindNode(list, node);

                    if (np == null)
                    {
                        // If the partition map is in a transitional state, multiple
                        // NodePartitions instances (each with different partitions)
                        // may be created for a single node.
                        np = new NodePartitions(node, partitionsCapacity);
                        list.Add(np);
                    }
                    np.AddPartition(part);
                }
            }

            if (maxRecords > 0)
            {
                // Distribute maxRecords across nodes.
                int nodeSize = list.Count;

                if (maxRecords < nodeSize)
                {
                    // Only include nodes that have at least 1 record requested.
                    nodeSize = (int)maxRecords;
                    list     = list.GetRange(0, nodeSize);
                }

                long max = maxRecords / nodeSize;
                int  rem = (int)(maxRecords - (max * nodeSize));

                for (int i = 0; i < nodeSize; i++)
                {
                    NodePartitions np = list[i];
                    np.recordMax = i < rem ? max + 1 : max;
                }
            }
            nodePartitionsList = list;
            return(list);
        }