|
@@ -15,8 +15,52 @@
|
|
long currentTime;
|
|
long currentTime;
|
|
JspHelper jspHelper = new JspHelper();
|
|
JspHelper jspHelper = new JspHelper();
|
|
|
|
|
|
- public void generateLiveNodeData(JspWriter out, DatanodeInfo d)
|
|
|
|
|
|
+ int rowNum = 0;
|
|
|
|
+ int colNum = 0;
|
|
|
|
+
|
|
|
|
+ String rowTxt() { colNum = 0;
|
|
|
|
+ return "<tr class=\"" + (((rowNum++)%2 == 0)? "rowNormal" : "rowAlt")
|
|
|
|
+ + "\"> "; }
|
|
|
|
+ String colTxt() { return "<td id=\"col" + ++colNum + "\"> "; }
|
|
|
|
+ void counterReset () { colNum = 0; rowNum = 0 ; }
|
|
|
|
+
|
|
|
|
+ long diskBytes = 1024 * 1024 * 1024;
|
|
|
|
+ String diskByteStr = "GB";
|
|
|
|
+
|
|
|
|
+ String sorterField = null;
|
|
|
|
+ String sorterOrder = null;
|
|
|
|
+
|
|
|
|
+ String NodeHeaderStr(String name) {
|
|
|
|
+ String ret = "class=header";
|
|
|
|
+ String order = "ASC";
|
|
|
|
+ if ( name.equals( sorterField ) ) {
|
|
|
|
+ ret += sorterOrder;
|
|
|
|
+ if ( sorterOrder.equals("ASC") )
|
|
|
|
+ order = "DSC";
|
|
|
|
+ }
|
|
|
|
+ ret += " onClick=\"window.document.location=" +
|
|
|
|
+ "'/dfshealth.jsp?sorter/field=" + name + "&sorter/order=" +
|
|
|
|
+ order + "'\" title=\"sort on this column\"";
|
|
|
|
+
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void generateLiveNodeData( JspWriter out, DatanodeDescriptor d,
|
|
|
|
+ String suffix, boolean alive )
|
|
throws IOException {
|
|
throws IOException {
|
|
|
|
+
|
|
|
|
+ String name = d.getName();
|
|
|
|
+ if ( !name.matches( "\\d+\\.\\d+.\\d+\\.\\d+.*" ) )
|
|
|
|
+ name = name.replaceAll( "\\.[^.:]*", "" );
|
|
|
|
+
|
|
|
|
+ int idx = (suffix != null && name.endsWith( suffix )) ?
|
|
|
|
+ name.indexOf( suffix ) : -1;
|
|
|
|
+ out.print( rowTxt() + "<td class=\"name\"><a title=\"" + d.getName() +
|
|
|
|
+ "\">" + (( idx > 0 ) ? name.substring(0, idx) : name) +
|
|
|
|
+ (( alive ) ? "" : "\n") );
|
|
|
|
+ if ( !alive )
|
|
|
|
+ return;
|
|
|
|
+
|
|
long c = d.getCapacity();
|
|
long c = d.getCapacity();
|
|
long r = d.getRemaining();
|
|
long r = d.getRemaining();
|
|
long u = c - r;
|
|
long u = c - r;
|
|
@@ -27,66 +71,112 @@
|
|
else
|
|
else
|
|
percentUsed = "100";
|
|
percentUsed = "100";
|
|
|
|
|
|
- out.print("<tr> <td id=\"col1\">" + d.getName() +
|
|
|
|
- "<td>" + ((currentTime - d.getLastUpdate())/1000) +
|
|
|
|
- "<td>" + DFSShell.byteDesc(c) +
|
|
|
|
- "<td>" + percentUsed + "\n");
|
|
|
|
|
|
+ out.print("<td class=\"lastcontact\"> " +
|
|
|
|
+ ((currentTime - d.getLastUpdate())/1000) +
|
|
|
|
+ "<td class=\"size\">" +
|
|
|
|
+ DFSShell.limitDecimal(c*1.0/diskBytes, 2) +
|
|
|
|
+ "<td class=\"pcused\">" + percentUsed +
|
|
|
|
+ "<td class=\"blocks\">" + d.numBlocks() + "\n");
|
|
}
|
|
}
|
|
|
|
|
|
public void generateDFSHealthReport(JspWriter out,
|
|
public void generateDFSHealthReport(JspWriter out,
|
|
HttpServletRequest request)
|
|
HttpServletRequest request)
|
|
throws IOException {
|
|
throws IOException {
|
|
- Vector live = new Vector();
|
|
|
|
- Vector dead = new Vector();
|
|
|
|
|
|
+ ArrayList<DatanodeDescriptor> live = new ArrayList<DatanodeDescriptor>();
|
|
|
|
+ ArrayList<DatanodeDescriptor> dead = new ArrayList<DatanodeDescriptor>();
|
|
jspHelper.DFSNodesStatus(live, dead);
|
|
jspHelper.DFSNodesStatus(live, dead);
|
|
|
|
+
|
|
|
|
+ sorterField = request.getParameter("sorter/field");
|
|
|
|
+ sorterOrder = request.getParameter("sorter/order");
|
|
|
|
+ if ( sorterField == null )
|
|
|
|
+ sorterField = "name";
|
|
|
|
+ if ( sorterOrder == null )
|
|
|
|
+ sorterOrder = "ASC";
|
|
|
|
+
|
|
|
|
+ jspHelper.sortNodeList(live, sorterField, sorterOrder);
|
|
|
|
+ jspHelper.sortNodeList(dead, "name", "ASC");
|
|
|
|
+
|
|
|
|
+ // Find out common suffix. Should this be before or after the sort?
|
|
|
|
+ String port_suffix = null;
|
|
|
|
+ if ( live.size() > 0 ) {
|
|
|
|
+ String name = live.get(0).getName();
|
|
|
|
+ int idx = name.indexOf(':');
|
|
|
|
+ if ( idx > 0 ) {
|
|
|
|
+ port_suffix = name.substring( idx );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for ( int i=1; port_suffix != null && i < live.size(); i++ ) {
|
|
|
|
+ if ( live.get(i).getName().endsWith( port_suffix ) == false ) {
|
|
|
|
+ port_suffix = null;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ counterReset();
|
|
|
|
|
|
out.print( "<div id=\"dfstable\"> <table>\n" +
|
|
out.print( "<div id=\"dfstable\"> <table>\n" +
|
|
- "<tr> <td id=\"col1\"> Capacity <td> : <td>" +
|
|
|
|
|
|
+ rowTxt() + colTxt() + "Capacity" + colTxt() + ":" + colTxt() +
|
|
DFSShell.byteDesc( fsn.totalCapacity() ) +
|
|
DFSShell.byteDesc( fsn.totalCapacity() ) +
|
|
- "<tr> <td id=\"col1\"> Remaining <td> : <td>" +
|
|
|
|
|
|
+ rowTxt() + colTxt() + "Remaining" + colTxt() + ":" + colTxt() +
|
|
DFSShell.byteDesc( fsn.totalRemaining() ) +
|
|
DFSShell.byteDesc( fsn.totalRemaining() ) +
|
|
- "<tr> <td id=\"col1\"> Used <td> : <td>" +
|
|
|
|
|
|
+ rowTxt() + colTxt() + "Used" + colTxt() + ":" + colTxt() +
|
|
DFSShell.limitDecimal((fsn.totalCapacity() -
|
|
DFSShell.limitDecimal((fsn.totalCapacity() -
|
|
fsn.totalRemaining())*100.0/
|
|
fsn.totalRemaining())*100.0/
|
|
- (fsn.totalCapacity() + 1e-10), 2) +
|
|
|
|
- "%<tr> <td id=\"col1\"> Live Nodes <td> : <td>" + live.size() +
|
|
|
|
- "<tr> <td id=\"col1\"> Dead Nodes <td> : <td>" + dead.size() +
|
|
|
|
|
|
+ (fsn.totalCapacity() + 1e-10), 2) + " %" +
|
|
|
|
+ rowTxt() + colTxt() +
|
|
|
|
+ "<a href=\"#LiveNodes\">Live Nodes</a> " +
|
|
|
|
+ colTxt() + ":" + colTxt() + live.size() +
|
|
|
|
+ rowTxt() + colTxt() +
|
|
|
|
+ "<a href=\"#DeadNodes\">Dead Nodes</a> " +
|
|
|
|
+ colTxt() + ":" + colTxt() + dead.size() +
|
|
"</table></div><br><hr>\n" );
|
|
"</table></div><br><hr>\n" );
|
|
|
|
|
|
if (live.isEmpty() && dead.isEmpty()) {
|
|
if (live.isEmpty() && dead.isEmpty()) {
|
|
out.print("There are no datanodes in the cluster");
|
|
out.print("There are no datanodes in the cluster");
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
-
|
|
|
|
|
|
+
|
|
currentTime = System.currentTimeMillis();
|
|
currentTime = System.currentTimeMillis();
|
|
out.print( "<div id=\"dfsnodetable\"> "+
|
|
out.print( "<div id=\"dfsnodetable\"> "+
|
|
- "<a id=\"title\">" +
|
|
|
|
|
|
+ "<a name=\"LiveNodes\" id=\"title\">" +
|
|
"Live Datanodes: " + live.size() + "</a>" +
|
|
"Live Datanodes: " + live.size() + "</a>" +
|
|
- "<br><br>\n<table border=\"1\">\n" );
|
|
|
|
|
|
+ "<br><br>\n<table border=1 cellspacing=0>\n" );
|
|
|
|
|
|
|
|
+ counterReset();
|
|
|
|
+
|
|
if ( live.size() > 0 ) {
|
|
if ( live.size() > 0 ) {
|
|
|
|
+
|
|
|
|
+ if ( live.get(0).getCapacity() > 1024 * diskBytes ) {
|
|
|
|
+ diskBytes *= 1024;
|
|
|
|
+ diskByteStr = "TB";
|
|
|
|
+ }
|
|
|
|
|
|
- out.print( "<tr id=\"row1\">" +
|
|
|
|
- "<td> Node <td> Last Contact <td> Size " +
|
|
|
|
- "<td> Used (%)\n" );
|
|
|
|
|
|
+ out.print( "<tr class=\"headerRow\"> <th " +
|
|
|
|
+ NodeHeaderStr("name") + "> Node <th " +
|
|
|
|
+ NodeHeaderStr("lastcontact") + "> Last Contact <th " +
|
|
|
|
+ NodeHeaderStr("size") + "> Size (" + diskByteStr +
|
|
|
|
+ ") <th " + NodeHeaderStr("pcused") +
|
|
|
|
+ "> Used (%) <th " + NodeHeaderStr("blocks") +
|
|
|
|
+ "> Blocks\n" );
|
|
|
|
|
|
for ( int i=0; i < live.size(); i++ ) {
|
|
for ( int i=0; i < live.size(); i++ ) {
|
|
- DatanodeInfo d = ( DatanodeInfo ) live.elementAt(i);
|
|
|
|
- generateLiveNodeData( out, d );
|
|
|
|
|
|
+ generateLiveNodeData( out, live.get(i), port_suffix, true );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
out.print("</table>\n");
|
|
out.print("</table>\n");
|
|
|
|
+
|
|
|
|
+ counterReset();
|
|
|
|
|
|
- out.print("<br> <a id=\"title\"> " +
|
|
|
|
|
|
+ out.print("<br> <a name=\"DeadNodes\" id=\"title\"> " +
|
|
" Dead Datanodes : " +dead.size() + "</a><br><br>\n");
|
|
" Dead Datanodes : " +dead.size() + "</a><br><br>\n");
|
|
|
|
|
|
if ( dead.size() > 0 ) {
|
|
if ( dead.size() > 0 ) {
|
|
- out.print( "<table border=\"1\"> <tr id=\"row1\"> " +
|
|
|
|
|
|
+ out.print( "<table border=1 cellspacing=0> <tr id=\"row1\"> " +
|
|
"<td> Node \n" );
|
|
"<td> Node \n" );
|
|
|
|
|
|
for ( int i=0; i < dead.size() ; i++ ) {
|
|
for ( int i=0; i < dead.size() ; i++ ) {
|
|
- DatanodeInfo d = ( DatanodeInfo ) dead.elementAt(i);
|
|
|
|
- out.print( "<tr> <td> " + d.getName() + "\n" );
|
|
|
|
|
|
+ generateLiveNodeData( out, dead.get(i), port_suffix, false );
|
|
}
|
|
}
|
|
|
|
|
|
out.print("</table>\n");
|
|
out.print("</table>\n");
|