Exemplo n.º 1
0
        public static void Test()
        {
            HashAlgorithmTest test = new HashAlgorithmTest();

            /** Records the times of locating node*/
            Dictionary <string, int> nodeRecord = new Dictionary <string, int>();

            List <string>     allNodes = test.getNodes(NODE_COUNT);
            KetamaNodeLocator locator  = new KetamaNodeLocator(allNodes, VIRTUAL_NODE_COUNT);

            List <String> allKeys = test.getAllStrings();

            foreach (string key in allKeys)
            {
                string node = locator.GetPrimary(key);
                if (!nodeRecord.ContainsKey(node))
                {
                    nodeRecord[node] = 1;
                }
                else
                {
                    nodeRecord[node] = nodeRecord[node] + 1;
                }
            }

            Console.WriteLine("Nodes count : " + NODE_COUNT + ", Keys count : " + EXE_TIMES + ", Normal percent : " + (float)100 / NODE_COUNT + "%");
            Console.WriteLine("-------------------- boundary  ----------------------");
            foreach (string key in nodeRecord.Keys)
            {
                Console.WriteLine("Node name :" + key + " - Times : " + nodeRecord[key] + " - Percent : " + (float)nodeRecord[key] / EXE_TIMES * 100 + "%");
            }
            Console.ReadLine();
        }
Exemplo n.º 2
0
        private static void call(List <string> nodes, Dictionary <string, List <string> > map)
        {
            KetamaNodeLocator locator = new KetamaNodeLocator(nodes, VIRTUAL_NODE_COUNT);

            foreach (string key in map.Keys)
            {
                string node = locator.GetPrimary(key);

                if (node != null)
                {
                    List <string> list = map[key];
                    list.Add(node);
                }
            }
        }
Exemplo n.º 3
0
        public static void TestDb()
        {
            HashAlgorithmTest test = new HashAlgorithmTest();

            /** Records the times of locating node*/
            Dictionary <string, int> nodeRecord = new Dictionary <string, int>();

            List <string>     allNodes = test.getNodes(NODE_COUNT);
            KetamaNodeLocator locator  = new KetamaNodeLocator(allNodes, VIRTUAL_NODE_COUNT);

            List <string> allKeys = new List <string> {
                "10", "11", "12", "13", "14"
            };

            foreach (string key in allKeys)
            {
                string node = locator.GetPrimary(key);
                Console.WriteLine("Node name :" + node + " - key : " + key);
            }
            Console.ReadLine();
        }