/// <summary>Helper function that generates the decommissioning report.</summary> /// <remarks> /// Helper function that generates the decommissioning report. Connect to each /// Namenode over http via JmxJsonServlet to collect the data nodes status. /// </remarks> internal virtual ClusterJspHelper.DecommissionStatus GenerateDecommissioningReport () { string clusterid = string.Empty; Configuration conf = new Configuration(); IList <DFSUtil.ConfiguredNNAddress> cnns = null; try { cnns = DFSUtil.FlattenAddressMap(DFSUtil.GetNNServiceRpcAddresses(conf)); } catch (Exception e) { // catch any exception encountered other than connecting to namenodes ClusterJspHelper.DecommissionStatus dInfo = new ClusterJspHelper.DecommissionStatus (clusterid, e); return(dInfo); } // Outer map key is datanode. Inner map key is namenode and the value is // decom status of the datanode for the corresponding namenode IDictionary <string, IDictionary <string, string> > statusMap = new Dictionary <string , IDictionary <string, string> >(); // Map of exceptions encountered when connecting to namenode // key is namenode and value is exception IDictionary <string, Exception> decommissionExceptions = new Dictionary <string, Exception >(); IList <string> unreportedNamenode = new AList <string>(); foreach (DFSUtil.ConfiguredNNAddress cnn in cnns) { IPEndPoint isa = cnn.GetAddress(); ClusterJspHelper.NamenodeMXBeanHelper nnHelper = null; try { nnHelper = new ClusterJspHelper.NamenodeMXBeanHelper(isa, conf); string mbeanProps = QueryMbean(nnHelper.httpAddress, conf); if (clusterid.Equals(string.Empty)) { clusterid = nnHelper.GetClusterId(mbeanProps); } nnHelper.GetDecomNodeInfoForReport(statusMap, mbeanProps); } catch (Exception e) { // catch exceptions encountered while connecting to namenodes string nnHost = isa.GetHostName(); decommissionExceptions[nnHost] = e; unreportedNamenode.AddItem(nnHost); continue; } } UpdateUnknownStatus(statusMap, unreportedNamenode); GetDecommissionNodeClusterState(statusMap); return(new ClusterJspHelper.DecommissionStatus(statusMap, clusterid, GetDatanodeHttpPort (conf), decommissionExceptions)); }
/// <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); }
internal virtual void PrintMap(IDictionary <string, IDictionary <string, IPEndPoint > > map) { StringBuilder buffer = new StringBuilder(); IList <DFSUtil.ConfiguredNNAddress> cnns = DFSUtil.FlattenAddressMap(map); foreach (DFSUtil.ConfiguredNNAddress cnn in cnns) { IPEndPoint address = cnn.GetAddress(); if (buffer.Length > 0) { buffer.Append(" "); } buffer.Append(address.GetHostName()); } PrintOut(buffer.ToString()); }
/// <exception cref="System.IO.IOException"/> internal override int DoWorkInternal(GetConf tool, string[] args) { Configuration config = tool.GetConf(); IList <DFSUtil.ConfiguredNNAddress> cnnlist = DFSUtil.FlattenAddressMap(DFSUtil.GetNNServiceRpcAddressesForCluster (config)); if (!cnnlist.IsEmpty()) { foreach (DFSUtil.ConfiguredNNAddress cnn in cnnlist) { IPEndPoint rpc = cnn.GetAddress(); tool.PrintOut(rpc.GetHostName() + ":" + rpc.Port); } return(0); } tool.PrintError("Did not get namenode service rpc addresses."); return(-1); }
/// <summary>JSP helper function that generates cluster health report.</summary> /// <remarks> /// JSP helper function that generates cluster health report. When /// encountering exception while getting Namenode status, the exception will /// be listed on the page with corresponding stack trace. /// </remarks> internal virtual ClusterJspHelper.ClusterStatus GenerateClusterHealthReport() { ClusterJspHelper.ClusterStatus cs = new ClusterJspHelper.ClusterStatus(); Configuration conf = new Configuration(); IList <DFSUtil.ConfiguredNNAddress> nns = null; try { nns = DFSUtil.FlattenAddressMap(DFSUtil.GetNNServiceRpcAddresses(conf)); } catch (Exception e) { // Could not build cluster status cs.SetError(e); return(cs); } // Process each namenode and add it to ClusterStatus foreach (DFSUtil.ConfiguredNNAddress cnn in nns) { IPEndPoint isa = cnn.GetAddress(); ClusterJspHelper.NamenodeMXBeanHelper nnHelper = null; try { nnHelper = new ClusterJspHelper.NamenodeMXBeanHelper(isa, conf); string mbeanProps = QueryMbean(nnHelper.httpAddress, conf); ClusterJspHelper.NamenodeStatus nn = nnHelper.GetNamenodeStatus(mbeanProps); if (cs.clusterid.IsEmpty() || cs.clusterid.Equals(string.Empty)) { // Set clusterid only once cs.clusterid = nnHelper.GetClusterId(mbeanProps); } cs.AddNamenodeStatus(nn); } catch (Exception e) { // track exceptions encountered when connecting to namenodes cs.AddException(isa.GetHostName(), e); continue; } } return(cs); }