/// <summary> /// Using DFSUtil methods get the list of given /// <paramref name="type"/> /// of address /// </summary> /// <exception cref="System.IO.IOException"/> private IDictionary <string, IDictionary <string, IPEndPoint> > GetAddressListFromConf (TestGetConf.TestType type, HdfsConfiguration conf) { switch (type) { case TestGetConf.TestType.Namenode: { return(DFSUtil.GetNNServiceRpcAddressesForCluster(conf)); } case TestGetConf.TestType.Backup: { return(DFSUtil.GetBackupNodeAddresses(conf)); } case TestGetConf.TestType.Secondary: { return(DFSUtil.GetSecondaryNameNodeAddresses(conf)); } case TestGetConf.TestType.Nnrpcaddresses: { return(DFSUtil.GetNNServiceRpcAddressesForCluster(conf)); } } return(null); }
/// <summary> /// Using /// <see cref="GetConf"/> /// methods get the list of given /// <paramref name="type"/> /// of /// addresses /// </summary> /// <?/> /// <?/> /// <?/> /// <?/> /// <exception cref="System.Exception"/> private void GetAddressListFromTool(TestGetConf.TestType type, HdfsConfiguration conf, bool checkPort, IList <DFSUtil.ConfiguredNNAddress> expected) { string @out = GetAddressListFromTool(type, conf, expected.Count != 0); IList <string> values = new AList <string>(); // Convert list of addresses returned to an array of string StringTokenizer tokenizer = new StringTokenizer(@out); while (tokenizer.HasMoreTokens()) { string s = tokenizer.NextToken().Trim(); values.AddItem(s); } string[] actual = Sharpen.Collections.ToArray(values, new string[values.Count]); // Convert expected list to String[] of hosts int i = 0; string[] expectedHosts = new string[expected.Count]; foreach (DFSUtil.ConfiguredNNAddress cnn in expected) { IPEndPoint addr = cnn.GetAddress(); if (!checkPort) { expectedHosts[i++] = addr.GetHostName(); } else { expectedHosts[i++] = addr.GetHostName() + ":" + addr.Port; } } // Compare two arrays NUnit.Framework.Assert.IsTrue(Arrays.Equals(expectedHosts, actual)); }
/// <summary>Get address list for a given type of address.</summary> /// <remarks> /// Get address list for a given type of address. Command expected to /// fail if /// <paramref name="success"/> /// is false. /// </remarks> /// <returns>returns the success or error output from the tool.</returns> /// <exception cref="System.Exception"/> private string GetAddressListFromTool(TestGetConf.TestType type, HdfsConfiguration conf, bool success) { string[] args = new string[1]; switch (type) { case TestGetConf.TestType.Namenode: { args[0] = GetConf.Command.Namenode.GetName(); break; } case TestGetConf.TestType.Backup: { args[0] = GetConf.Command.Backup.GetName(); break; } case TestGetConf.TestType.Secondary: { args[0] = GetConf.Command.Secondary.GetName(); break; } case TestGetConf.TestType.Nnrpcaddresses: { args[0] = GetConf.Command.Nnrpcaddresses.GetName(); break; } } return(RunTool(conf, args, success)); }
/// <exception cref="System.Exception"/> private void VerifyAddresses(HdfsConfiguration conf, TestGetConf.TestType type, bool checkPort, params string[] expected) { // Ensure DFSUtil returned the right set of addresses IDictionary <string, IDictionary <string, IPEndPoint> > map = GetAddressListFromConf (type, conf); IList <DFSUtil.ConfiguredNNAddress> list = DFSUtil.FlattenAddressMap(map); string[] actual = ToStringArray(list); Arrays.Sort(actual); Arrays.Sort(expected); Assert.AssertArrayEquals(expected, actual); // Test GetConf returned addresses GetAddressListFromTool(type, conf, checkPort, list); }