public virtual void TestRemove() { DatanodeDescriptor nodeNotInMap = DFSTestUtil.GetDatanodeDescriptor("3.3.3.3", "/d1/r4" ); NUnit.Framework.Assert.IsFalse(map.Remove(nodeNotInMap)); NUnit.Framework.Assert.IsTrue(map.Remove(dataNodes[0])); NUnit.Framework.Assert.IsTrue(map.GetDatanodeByHost("1.1.1.1.") == null); NUnit.Framework.Assert.IsTrue(map.GetDatanodeByHost("2.2.2.2") == dataNodes[1]); DatanodeDescriptor node = map.GetDatanodeByHost("3.3.3.3"); NUnit.Framework.Assert.IsTrue(node == dataNodes[2] || node == dataNodes[3]); NUnit.Framework.Assert.IsNull(map.GetDatanodeByHost("4.4.4.4")); NUnit.Framework.Assert.IsTrue(map.Remove(dataNodes[2])); NUnit.Framework.Assert.IsNull(map.GetDatanodeByHost("1.1.1.1")); NUnit.Framework.Assert.AreEqual(map.GetDatanodeByHost("2.2.2.2"), dataNodes[1]); NUnit.Framework.Assert.AreEqual(map.GetDatanodeByHost("3.3.3.3"), dataNodes[3]); NUnit.Framework.Assert.IsTrue(map.Remove(dataNodes[3])); NUnit.Framework.Assert.IsNull(map.GetDatanodeByHost("1.1.1.1")); NUnit.Framework.Assert.AreEqual(map.GetDatanodeByHost("2.2.2.2"), dataNodes[1]); NUnit.Framework.Assert.IsNull(map.GetDatanodeByHost("3.3.3.3")); NUnit.Framework.Assert.IsFalse(map.Remove(null)); NUnit.Framework.Assert.IsTrue(map.Remove(dataNodes[1])); NUnit.Framework.Assert.IsFalse(map.Remove(dataNodes[1])); }
public virtual void TestContains() { DatanodeDescriptor nodeNotInMap = DFSTestUtil.GetDatanodeDescriptor("8.8.8.8", "/d2/r4" ); for (int i = 0; i < dataNodes.Length; i++) { NUnit.Framework.Assert.IsTrue(cluster.Contains(dataNodes[i])); } NUnit.Framework.Assert.IsFalse(cluster.Contains(nodeNotInMap)); }
public virtual void Setup() { dataNodes = new DatanodeDescriptor[] { DFSTestUtil.GetDatanodeDescriptor("1.1.1.1" , "/d1/r1"), DFSTestUtil.GetDatanodeDescriptor("2.2.2.2", "/d1/r1"), DFSTestUtil .GetDatanodeDescriptor("3.3.3.3", "/d1/r2"), DFSTestUtil.GetDatanodeDescriptor("3.3.3.3" , 5021, "/d1/r2") }; foreach (DatanodeDescriptor node in dataNodes) { map.Add(node); } map.Add(null); }
public static DatanodeDescriptor GetDatanodeDescriptor(string ipAddr, string rackLocation , DatanodeStorage storage, string hostname) { DatanodeDescriptor dn = DFSTestUtil.GetDatanodeDescriptor(ipAddr, DFSConfigKeys.DfsDatanodeDefaultPort , rackLocation, hostname); if (storage != null) { dn.UpdateStorage(storage); } return(dn); }
/// <exception cref="System.Exception"/> private void DoTestOneOfTwoRacksDecommissioned(int testIndex) { // Block originally on A1, A2, B1 IList <DatanodeStorageInfo> origStorages = GetStorages(0, 1, 3); IList <DatanodeDescriptor> origNodes = GetNodes(origStorages); BlockInfoContiguous blockInfo = AddBlockOnNodes(testIndex, origNodes); // Decommission all of the nodes in rack A IList <DatanodeDescriptor> decomNodes = StartDecommission(0, 1, 2); DatanodeStorageInfo[] pipeline = ScheduleSingleReplication(blockInfo); NUnit.Framework.Assert.IsTrue("Source of replication should be one of the nodes the block " + "was on. Was: " + pipeline[0], origStorages.Contains(pipeline[0])); // Only up to two nodes can be picked per rack when there are two racks. NUnit.Framework.Assert.AreEqual("Should have two targets", 2, pipeline.Length); bool foundOneOnRackB = false; for (int i = 1; i < pipeline.Length; i++) { DatanodeDescriptor target = pipeline[i].GetDatanodeDescriptor(); if (rackB.Contains(target)) { foundOneOnRackB = true; } NUnit.Framework.Assert.IsFalse(decomNodes.Contains(target)); NUnit.Framework.Assert.IsFalse(origNodes.Contains(target)); } NUnit.Framework.Assert.IsTrue("Should have at least one target on rack B. Pipeline: " + Joiner.On(",").Join(pipeline), foundOneOnRackB); // Mark the block as received on the target nodes in the pipeline FulfillPipeline(blockInfo, pipeline); // the block is still under-replicated. Add a new node. This should allow // the third off-rack replica. DatanodeDescriptor rackCNode = DFSTestUtil.GetDatanodeDescriptor("7.7.7.7", "/rackC" ); rackCNode.UpdateStorage(new DatanodeStorage(DatanodeStorage.GenerateUuid())); AddNodes(ImmutableList.Of(rackCNode)); try { DatanodeStorageInfo[] pipeline2 = ScheduleSingleReplication(blockInfo); NUnit.Framework.Assert.AreEqual(2, pipeline2.Length); NUnit.Framework.Assert.AreEqual(rackCNode, pipeline2[1].GetDatanodeDescriptor()); } finally { RemoveNode(rackCNode); } }
public virtual void TestCreateInvalidTopology() { NetworkTopology invalCluster = new NetworkTopology(); DatanodeDescriptor[] invalDataNodes = new DatanodeDescriptor[] { DFSTestUtil.GetDatanodeDescriptor ("1.1.1.1", "/d1/r1"), DFSTestUtil.GetDatanodeDescriptor("2.2.2.2", "/d1/r1"), DFSTestUtil .GetDatanodeDescriptor("3.3.3.3", "/d1") }; invalCluster.Add(invalDataNodes[0]); invalCluster.Add(invalDataNodes[1]); try { invalCluster.Add(invalDataNodes[2]); NUnit.Framework.Assert.Fail("expected InvalidTopologyException"); } catch (NetworkTopology.InvalidTopologyException e) { NUnit.Framework.Assert.IsTrue(e.Message.StartsWith("Failed to add ")); NUnit.Framework.Assert.IsTrue(e.Message.Contains("You cannot have a rack and a non-rack node at the same " + "level of the network topology.")); } }
public virtual void SetupDatanodes() { dataNodes = new DatanodeDescriptor[] { DFSTestUtil.GetDatanodeDescriptor("1.1.1.1" , "/d1/r1"), DFSTestUtil.GetDatanodeDescriptor("2.2.2.2", "/d1/r1"), DFSTestUtil .GetDatanodeDescriptor("3.3.3.3", "/d1/r2"), DFSTestUtil.GetDatanodeDescriptor("4.4.4.4" , "/d1/r2"), DFSTestUtil.GetDatanodeDescriptor("5.5.5.5", "/d1/r2"), DFSTestUtil .GetDatanodeDescriptor("6.6.6.6", "/d2/r3"), DFSTestUtil.GetDatanodeDescriptor("7.7.7.7" , "/d2/r3"), DFSTestUtil.GetDatanodeDescriptor("8.8.8.8", "/d2/r3"), DFSTestUtil .GetDatanodeDescriptor("9.9.9.9", "/d3/r1"), DFSTestUtil.GetDatanodeDescriptor("10.10.10.10" , "/d3/r1"), DFSTestUtil.GetDatanodeDescriptor("11.11.11.11", "/d3/r1"), DFSTestUtil .GetDatanodeDescriptor("12.12.12.12", "/d3/r2"), DFSTestUtil.GetDatanodeDescriptor ("13.13.13.13", "/d3/r2"), DFSTestUtil.GetDatanodeDescriptor("14.14.14.14", "/d4/r1" ), DFSTestUtil.GetDatanodeDescriptor("15.15.15.15", "/d4/r1"), DFSTestUtil.GetDatanodeDescriptor ("16.16.16.16", "/d4/r1"), DFSTestUtil.GetDatanodeDescriptor("17.17.17.17", "/d4/r1" ), DFSTestUtil.GetDatanodeDescriptor("18.18.18.18", "/d4/r1"), DFSTestUtil.GetDatanodeDescriptor ("19.19.19.19", "/d4/r1"), DFSTestUtil.GetDatanodeDescriptor("20.20.20.20", "/d4/r1" ) }; for (int i = 0; i < dataNodes.Length; i++) { cluster.Add(dataNodes[i]); } dataNodes[9].SetDecommissioned(); dataNodes[10].SetDecommissioned(); }