コード例 #1
0
        /// <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));
        }
コード例 #2
0
        /// <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);
        }