Exemplo n.º 1
0
        public void PartitionLookupTest(string[] nodes, int partitionsPerNode, int elements, int key, int expectedNode, int expectedPartition)
        {
            var nodeList = new List <string>();

            nodeList.AddRange(nodes);
            var map = HtmSparseIntDictionary <Column> .CreatePartitionMap(nodeList, elements, partitionsPerNode);

            var part = HtmSparseIntDictionary <Column> .GetPlacementSlotForElement(map, key);

            Assert.IsTrue(part.NodeIndx == expectedNode && part.PartitionIndx == expectedPartition);
        }
Exemplo n.º 2
0
        public void TestGroupingByNode(string[] nodes)
        {
            var nodeList = new List <string>(nodes);

            List <IActorRef> list = new List <IActorRef>();

            for (int k = 0; k < nodes.Length; k++)
            {
                list.Add(new MockedActor(nodes[k]));
            }

            var map = HtmSparseIntDictionary <Column> .CreatePartitionMap(nodeList, 4096, 10);

            int i = 0;

            foreach (var item in map)
            {
                item.ActorRef = list[i++ % nodes.Length];
            }

            var groupedNodes = HtmSparseIntDictionary <object> .GetPartitionsByNode(map);
        }
Exemplo n.º 3
0
        public void PartitionMapTest(string[] nodes, int partitionsPerNode, int elements)
        {
            var nodeList = new List <string>();

            nodeList.AddRange(nodes);
            var map = HtmSparseIntDictionary <Column> .CreatePartitionMap(nodeList, elements, partitionsPerNode);

            // System can allocate less partitions than requested.
            Assert.IsTrue(map.Count <= nodes.Length * partitionsPerNode);

            Assert.IsTrue((map[7].MinKey == 14 && map[7].MaxKey == 15) ||
                          (map[7].MinKey == 21 && map[7].MaxKey == 23) ||
                          (map[9].MinKey == 3690 && map[9].MaxKey == 4095) ||
                          (map[170].MinKey == 1020 && map[170].MaxKey == 1023));

            Assert.IsTrue((int)(object)map.Last().MaxKey >= (elements - 1));

            foreach (var item in map)
            {
                // Partition can hold a single element.
                Assert.IsTrue((int)(object)item.MaxKey >= (int)(object)item.MinKey);
            }
        }