public virtual void TestNamenodeRpcBindAny() { Configuration conf = new HdfsConfiguration(); // The name node in MiniDFSCluster only binds to 127.0.0.1. // We can set the bind address to 0.0.0.0 to make it listen // to all interfaces. conf.Set(DFSConfigKeys.DfsNamenodeRpcBindHostKey, "0.0.0.0"); MiniDFSCluster cluster = null; try { cluster = new MiniDFSCluster.Builder(conf).Build(); cluster.WaitActive(); NUnit.Framework.Assert.AreEqual("0.0.0.0", ((NameNodeRpcServer)cluster.GetNameNodeRpc ()).GetClientRpcServer().GetListenerAddress().GetHostName()); } finally { if (cluster != null) { cluster.Shutdown(); } // Reset the config conf.Unset(DFSConfigKeys.DfsNamenodeRpcBindHostKey); } }
public virtual void TestFencingConfigPerNameNode() { Org.Mockito.Mockito.DoReturn(StandbyReadyResult).When(mockProtocol).GetServiceStatus (); string nsSpecificKey = DFSConfigKeys.DfsHaFenceMethodsKey + "." + Nsid; string nnSpecificKey = nsSpecificKey + ".nn1"; HdfsConfiguration conf = GetHAConf(); // Set the default fencer to succeed conf.Set(DFSConfigKeys.DfsHaFenceMethodsKey, GetFencerTrueCommand()); tool.SetConf(conf); NUnit.Framework.Assert.AreEqual(0, RunTool("-failover", "nn1", "nn2", "--forcefence" )); // Set the NN-specific fencer to fail. Should fail to fence. conf.Set(nnSpecificKey, GetFencerFalseCommand()); tool.SetConf(conf); NUnit.Framework.Assert.AreEqual(-1, RunTool("-failover", "nn1", "nn2", "--forcefence" )); conf.Unset(nnSpecificKey); // Set an NS-specific fencer to fail. Should fail. conf.Set(nsSpecificKey, GetFencerFalseCommand()); tool.SetConf(conf); NUnit.Framework.Assert.AreEqual(-1, RunTool("-failover", "nn1", "nn2", "--forcefence" )); // Set the NS-specific fencer to succeed. Should succeed conf.Set(nsSpecificKey, GetFencerTrueCommand()); tool.SetConf(conf); NUnit.Framework.Assert.AreEqual(0, RunTool("-failover", "nn1", "nn2", "--forcefence" )); }
public virtual void TestAllReplicasOnSameRack() { Configuration conf = new HdfsConfiguration(); conf.Unset(DFSConfigKeys.NetTopologyScriptFileNameKey); fsn = Org.Mockito.Mockito.Mock <FSNamesystem>(); Org.Mockito.Mockito.DoReturn(true).When(fsn).HasWriteLock(); Org.Mockito.Mockito.DoReturn(true).When(fsn).HasReadLock(); bm = new BlockManager(fsn, conf); // Add nodes on two racks AddNodes(nodes); // Added a new block in blocksMap and all the replicas are on the same rack BlockInfoContiguous blockInfo = AddBlockOnNodes(1, rackA); // Since the network toppolgy is multi-rack, the blockHasEnoughRacks // should return false. NUnit.Framework.Assert.IsFalse("Replicas for block is not stored on enough racks" , bm.BlockHasEnoughRacks(blockInfo)); }