public virtual void TestChooseMoreTargetsThanNodeGroups() { for (int i = 0; i < NumOfDatanodes; i++) { cluster.Remove(dataNodes[i]); } for (int i_1 = 0; i_1 < NumOfDatanodesBoundary; i_1++) { DatanodeDescriptor node = dataNodesInBoundaryCase[i_1]; if (cluster.Contains(node)) { cluster.Remove(node); } } for (int i_2 = 0; i_2 < NumOfDatanodesMoreTargets; i_2++) { cluster.Add(dataNodesInMoreTargetsCase[i_2]); } for (int i_3 = 0; i_3 < NumOfDatanodesMoreTargets; i_3++) { UpdateHeartbeatWithUsage(dataNodesInMoreTargetsCase[i_3], 2 * HdfsConstants.MinBlocksForWrite * BlockSize, 0L, 2 * HdfsConstants.MinBlocksForWrite * BlockSize, 0L, 0L, 0L, 0 , 0); } DatanodeStorageInfo[] targets; // Test normal case -- 3 replicas targets = ChooseTarget(3, dataNodesInMoreTargetsCase[0]); NUnit.Framework.Assert.AreEqual(targets.Length, 3); NUnit.Framework.Assert.IsTrue(CheckTargetsOnDifferentNodeGroup(targets)); // Test special case -- replica number over node groups. targets = ChooseTarget(10, dataNodesInMoreTargetsCase[0]); NUnit.Framework.Assert.IsTrue(CheckTargetsOnDifferentNodeGroup(targets)); // Verify it only can find 6 targets for placing replicas. NUnit.Framework.Assert.AreEqual(targets.Length, 6); }