public Node GetNode(Cluster cluster, Policy policy, Partition partition, bool isRead) { // Must copy hashmap reference for copy on write semantics to work. Dictionary <string, Partitions> map = cluster.partitionMap; Partitions partitions; if (!map.TryGetValue(partition.ns, out partitions)) { throw new AerospikeException.InvalidNamespace(partition.ns, map.Count); } if (partitions.cpMode && isRead && !policy.linearizeRead) { // Strong Consistency namespaces always use master node when read policy is sequential. return(cluster.GetMasterNode(partitions, partition)); } // Handle default case first. if (policy.replica == Replica.SEQUENCE) { // Sequence always starts at master, so writes can go through the same algorithm. return(GetSequenceNode(cluster, partitions, partition)); } if (!isRead) { // Writes will always proxy to master node. return(cluster.GetMasterNode(partitions, partition)); } switch (policy.replica) { default: case Replica.MASTER: return(cluster.GetMasterNode(partitions, partition)); case Replica.PREFER_RACK: return(GetRackNode(cluster, partitions, partition)); case Replica.MASTER_PROLES: return(cluster.GetMasterProlesNode(partitions, partition)); case Replica.RANDOM: return(cluster.GetRandomNode()); } }
public Node GetReadNode(Cluster cluster, Partition partition, Replica replica) { switch (replica) { case Replica.MASTER: return(cluster.GetMasterNode(partition)); case Replica.MASTER_PROLES: return(cluster.GetMasterProlesNode(partition)); case Replica.SEQUENCE: return(GetSequenceNode(cluster, partition)); default: case Replica.RANDOM: return(cluster.GetRandomNode()); } }
public Node GetNode(Cluster cluster, Partition partition, Replica replica, bool isRead) { // Handle default case first. if (replica == Replica.SEQUENCE) { return(GetSequenceNode(cluster, partition)); } if (replica == Replica.MASTER || !isRead) { return(cluster.GetMasterNode(partition)); } if (replica == Replica.MASTER_PROLES) { return(cluster.GetMasterProlesNode(partition)); } return(cluster.GetRandomNode()); }
private static Node GetNode(Cluster cluster, Policy policy, Partition partition, uint sequence) { // Must copy hashmap reference for copy on write semantics to work. Dictionary <string, Partitions> map = cluster.partitionMap; Partitions partitions; if (!map.TryGetValue(partition.ns, out partitions)) { throw new AerospikeException.InvalidNamespace(partition.ns, map.Count); } if (partitions.cpMode && !policy.linearizeRead) { // Strong Consistency namespaces always use master node when read policy is sequential. return(cluster.GetMasterNode(partitions, partition)); } switch (policy.replica) { case Replica.SEQUENCE: return(GetSequenceNode(cluster, partitions, partition, sequence)); case Replica.PREFER_RACK: return(GetRackNode(cluster, partitions, partition, sequence)); default: case Replica.MASTER: return(cluster.GetMasterNode(partitions, partition)); case Replica.MASTER_PROLES: return(cluster.GetMasterProlesNode(partitions, partition)); case Replica.RANDOM: return(cluster.GetRandomNode()); } }