public ReadHeaderCommand(Cluster cluster, Policy policy, Key key) { this.cluster = cluster; this.policy = policy; this.key = key; this.partition = new Partition(key); }
public AsyncReadHeader(AsyncCluster cluster, Policy policy, RecordListener listener, Key key) : base(cluster) { this.policy = policy; this.listener = listener; this.key = key; this.partition = new Partition(key); }
public ReadCommand(Cluster cluster, Policy policy, Key key, string[] binNames) { this.cluster = cluster; this.policy = policy; this.key = key; this.partition = new Partition(key); this.binNames = binNames; }
public AsyncRead(AsyncCluster cluster, Policy policy, RecordListener listener, Key key, string[] binNames) : base(cluster) { this.policy = policy; this.listener = listener; this.key = key; this.partition = new Partition(key); this.binNames = binNames; }
public Node GetReadNode(Partition partition, Replica replica) { switch (replica) { case Replica.MASTER: return GetMasterNode(partition); case Replica.MASTER_PROLES: return GetMasterProlesNode(partition); default: case Replica.RANDOM: return GetRandomNode(); } }
public Node GetMasterProlesNode(Partition partition) { // Must copy hashmap reference for copy on write semantics to work. Dictionary<string, Node[][]> map = partitionMap; Node[][] replicaArray; if (map.TryGetValue(partition.ns, out replicaArray)) { for (int i = 0; i < replicaArray.Length; i++) { int index = Math.Abs(replicaIndex % replicaArray.Length); Interlocked.Increment(ref replicaIndex); Node node = replicaArray[index][partition.partitionId]; if (node != null && node.Active) { return node; } } } /* if (Log.debugEnabled()) { Log.debug("Choose random node for " + partition); } */ return GetRandomNode(); }
public Node GetMasterNode(Partition partition) { // Must copy hashmap reference for copy on write semantics to work. Dictionary<string, Node[][]> map = partitionMap; Node[][] replicaArray; if (map.TryGetValue(partition.ns, out replicaArray)) { Node node = replicaArray[0][partition.partitionId]; if (node != null && node.Active) { return node; } } /* if (Log.debugEnabled()) { Log.debug("Choose random node for " + partition); } */ return GetRandomNode(); }
public static List<BatchNode> GenerateList(Cluster cluster, BatchPolicy policy, Key[] keys) { Node[] nodes = cluster.Nodes; if (nodes.Length == 0) { throw new AerospikeException(ResultCode.SERVER_NOT_AVAILABLE, "Command failed because cluster is empty."); } // Create initial key capacity for each node as average + 25%. int keysPerNode = keys.Length / nodes.Length; keysPerNode += (int)((uint)keysPerNode >> 2); // The minimum key capacity is 10. if (keysPerNode < 10) { keysPerNode = 10; } // Split keys by server node. List<BatchNode> batchNodes = new List<BatchNode>(nodes.Length); for (int i = 0; i < keys.Length; i++) { Partition partition = new Partition(keys[i]); Node node = cluster.GetReadNode(partition, policy.replica); BatchNode batchNode = FindBatchNode(batchNodes, node); if (batchNode == null) { batchNodes.Add(new BatchNode(node, keysPerNode, i)); } else { batchNode.AddKey(i); } } return batchNodes; }
public override bool Equals(object obj) { Partition other = (Partition)obj; return(this.ns.Equals(other.ns) && this.partitionId == other.partitionId); }