Example #1
0
            /// <summary>Generate decommissioning datanode report in XML format</summary>
            /// <param name="doc">, xmloutputter</param>
            /// <exception cref="System.IO.IOException"/>
            public virtual void ToXML(XMLOutputter doc)
            {
                if (error != null)
                {
                    CreateGeneralException(doc, clusterid, StringUtils.StringifyException(error));
                    doc.GetWriter().Flush();
                    return;
                }
                if (statusMap == null || statusMap.IsEmpty())
                {
                    // none of the namenodes has reported, print exceptions from each nn.
                    doc.StartTag("cluster");
                    CreateNamenodeExceptionMsg(doc, exceptions);
                    doc.EndTag();
                    doc.GetWriter().Flush();
                    return;
                }
                doc.StartTag("cluster");
                doc.Attribute("clusterId", clusterid);
                doc.StartTag("decommissioningReport");
                CountDecommissionDatanodes();
                ToXmlItemBlock(doc, ClusterJspHelper.DecommissionStates.Decommissioned.ToString()
                               , Sharpen.Extensions.ToString(decommissioned));
                ToXmlItemBlock(doc, ClusterJspHelper.DecommissionStates.DecommissionInprogress.ToString
                                   (), Sharpen.Extensions.ToString(decommissioning));
                ToXmlItemBlock(doc, ClusterJspHelper.DecommissionStates.PartiallyDecommissioned.ToString
                                   (), Sharpen.Extensions.ToString(partial));
                doc.EndTag();
                // decommissioningReport
                doc.StartTag("datanodes");
                ICollection <string> dnSet = statusMap.Keys;

                foreach (string dnhost in dnSet)
                {
                    IDictionary <string, string> nnStatus = statusMap[dnhost];
                    if (nnStatus == null || nnStatus.IsEmpty())
                    {
                        continue;
                    }
                    string overallStatus = nnStatus[OverallStatus];
                    // check if datanode is in decommission states
                    if (overallStatus != null && (overallStatus.Equals(DatanodeInfo.AdminStates.DecommissionInprogress
                                                                       .ToString()) || overallStatus.Equals(DatanodeInfo.AdminStates.Decommissioned.ToString
                                                                                                                ()) || overallStatus.Equals(ClusterJspHelper.DecommissionStates.PartiallyDecommissioned
                                                                                                                                            .ToString()) || overallStatus.Equals(ClusterJspHelper.DecommissionStates.Unknown
                                                                                                                                                                                 .ToString())))
                    {
                        doc.StartTag("node");
                        // dn
                        ToXmlItemBlockWithLink(doc, dnhost, new Uri("http", dnhost, httpPort, string.Empty
                                                                    ), "DataNode");
                        // overall status first
                        ToXmlItemBlock(doc, OverallStatus, overallStatus);
                        foreach (KeyValuePair <string, string> m in nnStatus)
                        {
                            string nn = m.Key;
                            if (nn.Equals(OverallStatus))
                            {
                                continue;
                            }
                            // xml
                            ToXmlItemBlock(doc, nn, nnStatus[nn]);
                        }
                        doc.EndTag();
                    }
                }
                // node
                doc.EndTag();
                // datanodes
                CreateNamenodeExceptionMsg(doc, exceptions);
                doc.EndTag();
            }
Example #2
0
            /// <exception cref="System.IO.IOException"/>
            public virtual void ToXML(XMLOutputter doc)
            {
                if (error != null)
                {
                    // general exception, only print exception message onto web page.
                    CreateGeneralException(doc, clusterid, StringUtils.StringifyException(error));
                    doc.GetWriter().Flush();
                    return;
                }
                int   size                = nnList.Count;
                long  total               = 0L;
                long  free                = 0L;
                long  nonDfsUsed          = 0l;
                float dfsUsedPercent      = 0.0f;
                float dfsRemainingPercent = 0.0f;

                if (size > 0)
                {
                    total               = total_sum / size;
                    free                = free_sum / size;
                    nonDfsUsed          = nonDfsUsed_sum / size;
                    dfsUsedPercent      = DFSUtil.GetPercentUsed(clusterDfsUsed, total);
                    dfsRemainingPercent = DFSUtil.GetPercentRemaining(free, total);
                }
                doc.StartTag("cluster");
                doc.Attribute("clusterId", clusterid);
                doc.StartTag("storage");
                ToXmlItemBlock(doc, "Total Files And Directories", System.Convert.ToString(totalFilesAndDirectories
                                                                                           ));
                ToXmlItemBlock(doc, "Configured Capacity", StringUtils.ByteDesc(total));
                ToXmlItemBlock(doc, "DFS Used", StringUtils.ByteDesc(clusterDfsUsed));
                ToXmlItemBlock(doc, "Non DFS Used", StringUtils.ByteDesc(nonDfsUsed));
                ToXmlItemBlock(doc, "DFS Remaining", StringUtils.ByteDesc(free));
                // dfsUsedPercent
                ToXmlItemBlock(doc, "DFS Used%", DFSUtil.Percent2String(dfsUsedPercent));
                // dfsRemainingPercent
                ToXmlItemBlock(doc, "DFS Remaining%", DFSUtil.Percent2String(dfsRemainingPercent)
                               );
                doc.EndTag();
                // storage
                doc.StartTag("namenodes");
                // number of namenodes
                ToXmlItemBlock(doc, "NamenodesCount", Sharpen.Extensions.ToString(size));
                foreach (ClusterJspHelper.NamenodeStatus nn in nnList)
                {
                    doc.StartTag("node");
                    ToXmlItemBlockWithLink(doc, nn.host, nn.httpAddress, "NameNode");
                    ToXmlItemBlock(doc, "Blockpool Used", StringUtils.ByteDesc(nn.bpUsed));
                    ToXmlItemBlock(doc, "Blockpool Used%", DFSUtil.Percent2String(DFSUtil.GetPercentUsed
                                                                                      (nn.bpUsed, total)));
                    ToXmlItemBlock(doc, "Files And Directories", System.Convert.ToString(nn.filesAndDirectories
                                                                                         ));
                    ToXmlItemBlock(doc, "Blocks", System.Convert.ToString(nn.blocksCount));
                    ToXmlItemBlock(doc, "Missing Blocks", System.Convert.ToString(nn.missingBlocksCount
                                                                                  ));
                    ToXmlItemBlockWithLink(doc, nn.liveDatanodeCount + " (" + nn.liveDecomCount + ")"
                                           , new Uri(nn.httpAddress, "/dfsnodelist.jsp?whatNodes=LIVE"), "Live Datanode (Decommissioned)"
                                           );
                    ToXmlItemBlockWithLink(doc, nn.deadDatanodeCount + " (" + nn.deadDecomCount + ")"
                                           , new Uri(nn.httpAddress, "/dfsnodelist.jsp?whatNodes=DEAD"), "Dead Datanode (Decommissioned)"
                                           );
                    ToXmlItemBlock(doc, "Software Version", nn.softwareVersion);
                    doc.EndTag();
                }
                // node
                doc.EndTag();
                // namenodes
                CreateNamenodeExceptionMsg(doc, nnExceptions);
                doc.EndTag();
                // cluster
                doc.GetWriter().Flush();
            }