/// <summary>Get the number of live datanodes.</summary> /// <param name="json">JSON string that contains live node status.</param> /// <param name="nn">namenode status to return information in</param> /// <exception cref="System.IO.IOException"/> private static void GetLiveNodeCount(string json, ClusterJspHelper.NamenodeStatus nn) { // Map of datanode host to (map of attribute name to value) IDictionary <string, IDictionary <string, object> > nodeMap = GetNodeMap(json); if (nodeMap == null || nodeMap.IsEmpty()) { return; } nn.liveDatanodeCount = nodeMap.Count; foreach (KeyValuePair <string, IDictionary <string, object> > entry in nodeMap) { // Inner map of attribute name to value IDictionary <string, object> innerMap = entry.Value; if (innerMap != null) { if (innerMap["adminState"].Equals(DatanodeInfo.AdminStates.Decommissioned.ToString ())) { nn.liveDecomCount++; } } } }
public virtual void AddNamenodeStatus(ClusterJspHelper.NamenodeStatus nn) { nnList.AddItem(nn); // Add namenode status to cluster status totalFilesAndDirectories += nn.filesAndDirectories; total_sum += nn.capacity; free_sum += nn.free; clusterDfsUsed += nn.bpUsed; nonDfsUsed_sum += nn.nonDfsUsed; }
/// <exception cref="System.IO.IOException"/> /// <exception cref="Javax.Management.MalformedObjectNameException"/> /// <exception cref="System.FormatException"/> public virtual ClusterJspHelper.NamenodeStatus GetNamenodeStatus(string props) { ClusterJspHelper.NamenodeStatus nn = new ClusterJspHelper.NamenodeStatus(); nn.host = host; nn.filesAndDirectories = GetProperty(props, "TotalFiles").GetLongValue(); nn.capacity = GetProperty(props, "Total").GetLongValue(); nn.free = GetProperty(props, "Free").GetLongValue(); nn.bpUsed = GetProperty(props, "BlockPoolUsedSpace").GetLongValue(); nn.nonDfsUsed = GetProperty(props, "NonDfsUsedSpace").GetLongValue(); nn.blocksCount = GetProperty(props, "TotalBlocks").GetLongValue(); nn.missingBlocksCount = GetProperty(props, "NumberOfMissingBlocks").GetLongValue( ); nn.httpAddress = httpAddress.ToURL(); GetLiveNodeCount(GetProperty(props, "LiveNodes").AsText(), nn); GetDeadNodeCount(GetProperty(props, "DeadNodes").AsText(), nn); nn.softwareVersion = GetProperty(props, "SoftwareVersion").GetTextValue(); return(nn); }
/// <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); }
/// <summary>Count the number of dead datanode.</summary> /// <param name="nn">namenode</param> /// <param name="json">JSON string</param> /// <exception cref="System.IO.IOException"/> private static void GetDeadNodeCount(string json, ClusterJspHelper.NamenodeStatus nn) { IDictionary <string, IDictionary <string, object> > nodeMap = GetNodeMap(json); if (nodeMap == null || nodeMap.IsEmpty()) { return; } nn.deadDatanodeCount = nodeMap.Count; foreach (KeyValuePair <string, IDictionary <string, object> > entry in nodeMap) { IDictionary <string, object> innerMap = entry.Value; if (innerMap != null && !innerMap.IsEmpty()) { if (((bool)innerMap["decommissioned"]) == true) { nn.deadDecomCount++; } } } }