|
@@ -30,6 +30,7 @@ import java.net.URLEncoder;
|
|
import java.security.PrivilegedExceptionAction;
|
|
import java.security.PrivilegedExceptionAction;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
|
|
+import java.util.Collections;
|
|
import java.util.Iterator;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -640,7 +641,8 @@ class NamenodeJspHelper {
|
|
.getAttribute(JspHelper.CURRENT_CONF);
|
|
.getAttribute(JspHelper.CURRENT_CONF);
|
|
// We can't redirect if there isn't a DN to redirect to.
|
|
// We can't redirect if there isn't a DN to redirect to.
|
|
// Lets instead show a proper error message.
|
|
// Lets instead show a proper error message.
|
|
- if (nn.getNamesystem().getNumLiveDataNodes() < 1) {
|
|
|
|
|
|
+ FSNamesystem fsn = nn.getNamesystem();
|
|
|
|
+ if (fsn == null || fsn.getNumLiveDataNodes() < 1) {
|
|
throw new IOException("Can't browse the DFS since there are no " +
|
|
throw new IOException("Can't browse the DFS since there are no " +
|
|
"live nodes available to redirect to.");
|
|
"live nodes available to redirect to.");
|
|
}
|
|
}
|
|
@@ -676,6 +678,20 @@ class NamenodeJspHelper {
|
|
resp.sendRedirect(redirectLocation);
|
|
resp.sendRedirect(redirectLocation);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Returns a descriptive label for the running NameNode. If the NameNode has
|
|
|
|
+ * initialized to the point of running its RPC server, then this label consists
|
|
|
|
+ * of the host and port of the RPC server. Otherwise, the label is a message
|
|
|
|
+ * stating that the NameNode is still initializing.
|
|
|
|
+ *
|
|
|
|
+ * @param nn NameNode to describe
|
|
|
|
+ * @return String NameNode label
|
|
|
|
+ */
|
|
|
|
+ static String getNameNodeLabel(NameNode nn) {
|
|
|
|
+ return nn.getRpcServer() != null ? nn.getNameNodeAddressHostPortString() :
|
|
|
|
+ "initializing";
|
|
|
|
+ }
|
|
|
|
+
|
|
static class NodeListJsp {
|
|
static class NodeListJsp {
|
|
private int rowNum = 0;
|
|
private int rowNum = 0;
|
|
|
|
|
|
@@ -830,6 +846,9 @@ class NamenodeJspHelper {
|
|
HttpServletRequest request) throws IOException {
|
|
HttpServletRequest request) throws IOException {
|
|
final NameNode nn = NameNodeHttpServer.getNameNodeFromContext(context);
|
|
final NameNode nn = NameNodeHttpServer.getNameNodeFromContext(context);
|
|
final FSNamesystem ns = nn.getNamesystem();
|
|
final FSNamesystem ns = nn.getNamesystem();
|
|
|
|
+ if (ns == null) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
final DatanodeManager dm = ns.getBlockManager().getDatanodeManager();
|
|
final DatanodeManager dm = ns.getBlockManager().getDatanodeManager();
|
|
|
|
|
|
final List<DatanodeDescriptor> live = new ArrayList<DatanodeDescriptor>();
|
|
final List<DatanodeDescriptor> live = new ArrayList<DatanodeDescriptor>();
|
|
@@ -1007,14 +1026,16 @@ class NamenodeJspHelper {
|
|
final BlockManager blockManager;
|
|
final BlockManager blockManager;
|
|
|
|
|
|
XMLBlockInfo(FSNamesystem fsn, Long blockId) {
|
|
XMLBlockInfo(FSNamesystem fsn, Long blockId) {
|
|
- this.blockManager = fsn.getBlockManager();
|
|
|
|
|
|
+ this.blockManager = fsn != null ? fsn.getBlockManager() : null;
|
|
|
|
|
|
if (blockId == null) {
|
|
if (blockId == null) {
|
|
this.block = null;
|
|
this.block = null;
|
|
this.inode = null;
|
|
this.inode = null;
|
|
} else {
|
|
} else {
|
|
this.block = new Block(blockId);
|
|
this.block = new Block(blockId);
|
|
- this.inode = ((INode)blockManager.getBlockCollection(block)).asFile();
|
|
|
|
|
|
+ this.inode = blockManager != null ?
|
|
|
|
+ ((INode)blockManager.getBlockCollection(block)).asFile() :
|
|
|
|
+ null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1088,8 +1109,10 @@ class NamenodeJspHelper {
|
|
}
|
|
}
|
|
|
|
|
|
doc.startTag("replicas");
|
|
doc.startTag("replicas");
|
|
- for(final Iterator<DatanodeDescriptor> it = blockManager.datanodeIterator(block);
|
|
|
|
- it.hasNext(); ) {
|
|
|
|
|
|
+ for (final Iterator<DatanodeDescriptor> it = blockManager != null ?
|
|
|
|
+ blockManager.datanodeIterator(block) :
|
|
|
|
+ Collections.<DatanodeDescriptor>emptyList().iterator();
|
|
|
|
+ it.hasNext();) {
|
|
doc.startTag("replica");
|
|
doc.startTag("replica");
|
|
|
|
|
|
DatanodeDescriptor dd = it.next();
|
|
DatanodeDescriptor dd = it.next();
|
|
@@ -1125,7 +1148,7 @@ class NamenodeJspHelper {
|
|
|
|
|
|
XMLCorruptBlockInfo(FSNamesystem fsn, Configuration conf,
|
|
XMLCorruptBlockInfo(FSNamesystem fsn, Configuration conf,
|
|
int numCorruptBlocks, Long startingBlockId) {
|
|
int numCorruptBlocks, Long startingBlockId) {
|
|
- this.blockManager = fsn.getBlockManager();
|
|
|
|
|
|
+ this.blockManager = fsn != null ? fsn.getBlockManager() : null;
|
|
this.conf = conf;
|
|
this.conf = conf;
|
|
this.numCorruptBlocks = numCorruptBlocks;
|
|
this.numCorruptBlocks = numCorruptBlocks;
|
|
this.startingBlockId = startingBlockId;
|
|
this.startingBlockId = startingBlockId;
|
|
@@ -1148,16 +1171,19 @@ class NamenodeJspHelper {
|
|
doc.endTag();
|
|
doc.endTag();
|
|
|
|
|
|
doc.startTag("num_missing_blocks");
|
|
doc.startTag("num_missing_blocks");
|
|
- doc.pcdata(""+blockManager.getMissingBlocksCount());
|
|
|
|
|
|
+ doc.pcdata("" + (blockManager != null ?
|
|
|
|
+ blockManager.getMissingBlocksCount() : 0));
|
|
doc.endTag();
|
|
doc.endTag();
|
|
|
|
|
|
doc.startTag("num_corrupt_replica_blocks");
|
|
doc.startTag("num_corrupt_replica_blocks");
|
|
- doc.pcdata(""+blockManager.getCorruptReplicaBlocksCount());
|
|
|
|
|
|
+ doc.pcdata("" + (blockManager != null ?
|
|
|
|
+ blockManager.getCorruptReplicaBlocksCount() : 0));
|
|
doc.endTag();
|
|
doc.endTag();
|
|
|
|
|
|
doc.startTag("corrupt_replica_block_ids");
|
|
doc.startTag("corrupt_replica_block_ids");
|
|
- final long[] corruptBlockIds = blockManager.getCorruptReplicaBlockIds(
|
|
|
|
- numCorruptBlocks, startingBlockId);
|
|
|
|
|
|
+ final long[] corruptBlockIds = blockManager != null ?
|
|
|
|
+ blockManager.getCorruptReplicaBlockIds(numCorruptBlocks,
|
|
|
|
+ startingBlockId) : null;
|
|
if (corruptBlockIds != null) {
|
|
if (corruptBlockIds != null) {
|
|
for (Long blockId: corruptBlockIds) {
|
|
for (Long blockId: corruptBlockIds) {
|
|
doc.startTag("block_id");
|
|
doc.startTag("block_id");
|