private static void Statistics(IList <Node> nodes, ConsistentHash <Node> cluster) { var statDict = new Dictionary <String, int>(); foreach (var n in nodes) { statDict.Add(n.IP, 0); } for (int i = 0; i < ItemCount; i++) { var node = cluster.GetNode($"key_{i}"); statDict[node.IP] += 1; } var mean = statDict.Values.Average(); var std = statDict.Values.StdDev(); Console.WriteLine(@$ " Algorithm Statistics: {cluster.ToString()} -------------------- Total: {ItemCount:N0} Mean: {mean:N0} StdDev: {std:F2} "); foreach (var(k, v) in statDict) { Console.WriteLine("Node [{0}]: {1}", k, v); } }
public static void FindNode(this ConsistentHash <Node> cluster, String key) { var found = cluster.GetNode(key); Console.WriteLine($"Key [{key}] - Hash [{cluster.GetHashKey(key)}], route to Node [{found.IP}]"); }