"; }
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 generateNodeData( JspWriter out, DatanodeDescriptor d,
String suffix, boolean alive,
int nnHttpPort )
throws IOException {
/* Say the datanode is dn1.hadoop.apache.org with ip 192.168.0.5
we use:
1) d.getHostName():d.getPort() to display.
Domain and port are stripped if they are common across the nodes.
i.e. "dn1"
2) d.getHost():d.Port() for "title".
i.e. "192.168.0.5:50010"
3) d.getHostName():d.getInfoPort() for url.
i.e. "http://dn1.hadoop.apache.org:50075/..."
Note that "d.getHost():d.getPort()" is what DFS clients use
to interact with datanodes.
*/
// from nn_browsedfscontent.jsp:
String url = "http://" + d.getHostName() + ":" + d.getInfoPort() +
"/browseDirectory.jsp?namenodeInfoPort=" +
nnHttpPort + "&dir=" +
URLEncoder.encode("/", "UTF-8");
String name = d.getHostName() + ":" + d.getPort();
if ( !name.matches( "\\d+\\.\\d+.\\d+\\.\\d+.*" ) )
name = name.replaceAll( "\\.[^.:]*", "" );
int idx = (suffix != null && name.endsWith( suffix )) ?
name.indexOf( suffix ) : -1;
out.print( rowTxt() + "
" +
(( idx > 0 ) ? name.substring(0, idx) : name) + "" +
(( alive ) ? "" : "\n") );
if ( !alive )
return;
long c = d.getCapacity();
long u = d.getDfsUsed();
long nu = d.getNonDfsUsed();
long r = d.getRemaining();
String percentUsed = StringUtils.limitDecimalTo2(d.getDfsUsedPercent());
String percentRemaining = StringUtils.limitDecimalTo2(d.getRemainingPercent());
String adminState = (d.isDecommissioned() ? "Decommissioned" :
(d.isDecommissionInProgress() ? "Decommission In Progress":
"In Service"));
long timestamp = d.getLastUpdate();
long currentTime = System.currentTimeMillis();
out.print("
");
StorageDirectory st =null;
for (Iterator it = fsImage.dirIterator(); it.hasNext();) {
st = it.next();
String dir = "" + st.getRoot();
String type = "" + st.getStorageDirType();
out.print("
"+dir+"
"+type+"
Active
");
}
long storageDirsSize = removedStorageDirs.size();
for(int i=0; i< storageDirsSize; i++){
st = removedStorageDirs.get(i);
String dir = "" + st.getRoot();
String type = "" + st.getStorageDirType();
out.print("
"+dir+"
"+type+"
Failed
");
}
out.print("
\n");
}
public void generateDFSHealthReport(JspWriter out,
NameNode nn,
HttpServletRequest request)
throws IOException {
FSNamesystem fsn = nn.getNamesystem();
ArrayList live = new ArrayList();
ArrayList dead = new ArrayList();
jspHelper.DFSNodesStatus(live, dead);
ArrayList decommissioning = fsn
.getDecommissioningNodes();
sorterField = request.getParameter("sorter/field");
sorterOrder = request.getParameter("sorter/order");
if ( sorterField == null )
sorterField = "name";
if ( sorterOrder == null )
sorterOrder = "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();
long total = fsn.getCapacityTotal();
long remaining = fsn.getCapacityRemaining();
long used = fsn.getCapacityUsed();
long nonDFS = fsn.getCapacityUsedNonDFS();
float percentUsed = fsn.getCapacityUsedPercent();
float percentRemaining = fsn.getCapacityRemainingPercent();
out.print( "