|
@@ -155,6 +155,7 @@ public class NamenodeFsck implements DataEncryptionKeyFactory {
|
|
private boolean showMaintenanceState = false;
|
|
private boolean showMaintenanceState = false;
|
|
private long staleInterval;
|
|
private long staleInterval;
|
|
private Tracer tracer;
|
|
private Tracer tracer;
|
|
|
|
+ private String auditSource;
|
|
|
|
|
|
/**
|
|
/**
|
|
* True if we encountered an internal error during FSCK, such as not being
|
|
* True if we encountered an internal error during FSCK, such as not being
|
|
@@ -186,7 +187,7 @@ public class NamenodeFsck implements DataEncryptionKeyFactory {
|
|
|
|
|
|
String path = "/";
|
|
String path = "/";
|
|
|
|
|
|
- private String blockIds = null;
|
|
|
|
|
|
+ private String[] blockIds = null;
|
|
|
|
|
|
// We return back N files that are corrupt; the list of files returned is
|
|
// We return back N files that are corrupt; the list of files returned is
|
|
// ordered by block id; to allow continuation support, pass in the last block
|
|
// ordered by block id; to allow continuation support, pass in the last block
|
|
@@ -262,11 +263,17 @@ public class NamenodeFsck implements DataEncryptionKeyFactory {
|
|
} else if (key.equals("includeSnapshots")) {
|
|
} else if (key.equals("includeSnapshots")) {
|
|
this.snapshottableDirs = new ArrayList<String>();
|
|
this.snapshottableDirs = new ArrayList<String>();
|
|
} else if (key.equals("blockId")) {
|
|
} else if (key.equals("blockId")) {
|
|
- this.blockIds = pmap.get("blockId")[0];
|
|
|
|
|
|
+ this.blockIds = pmap.get("blockId")[0].split(" ");
|
|
} else if (key.equals("replicate")) {
|
|
} else if (key.equals("replicate")) {
|
|
this.doReplicate = true;
|
|
this.doReplicate = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ this.auditSource = (blockIds != null)
|
|
|
|
+ ? "blocksIds=" + Arrays.asList(blockIds) : path;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getAuditSource() {
|
|
|
|
+ return auditSource;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -368,18 +375,18 @@ public class NamenodeFsck implements DataEncryptionKeyFactory {
|
|
/**
|
|
/**
|
|
* Check files on DFS, starting from the indicated path.
|
|
* Check files on DFS, starting from the indicated path.
|
|
*/
|
|
*/
|
|
- public void fsck() {
|
|
|
|
|
|
+ public void fsck() throws AccessControlException {
|
|
final long startTime = Time.monotonicNow();
|
|
final long startTime = Time.monotonicNow();
|
|
try {
|
|
try {
|
|
if(blockIds != null) {
|
|
if(blockIds != null) {
|
|
- String[] blocks = blockIds.split(" ");
|
|
|
|
|
|
+ namenode.getNamesystem().checkSuperuserPrivilege();
|
|
StringBuilder sb = new StringBuilder();
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("FSCK started by " +
|
|
sb.append("FSCK started by " +
|
|
UserGroupInformation.getCurrentUser() + " from " +
|
|
UserGroupInformation.getCurrentUser() + " from " +
|
|
remoteAddress + " at " + new Date());
|
|
remoteAddress + " at " + new Date());
|
|
out.println(sb);
|
|
out.println(sb);
|
|
sb.append(" for blockIds: \n");
|
|
sb.append(" for blockIds: \n");
|
|
- for (String blk: blocks) {
|
|
|
|
|
|
+ for (String blk: blockIds) {
|
|
if(blk == null || !blk.contains(Block.BLOCK_FILE_PREFIX)) {
|
|
if(blk == null || !blk.contains(Block.BLOCK_FILE_PREFIX)) {
|
|
out.println("Incorrect blockId format: " + blk);
|
|
out.println("Incorrect blockId format: " + blk);
|
|
continue;
|
|
continue;
|
|
@@ -389,7 +396,6 @@ public class NamenodeFsck implements DataEncryptionKeyFactory {
|
|
sb.append(blk + "\n");
|
|
sb.append(blk + "\n");
|
|
}
|
|
}
|
|
LOG.info("{}", sb.toString());
|
|
LOG.info("{}", sb.toString());
|
|
- namenode.getNamesystem().logFsckEvent("/", remoteAddress);
|
|
|
|
out.flush();
|
|
out.flush();
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -398,7 +404,6 @@ public class NamenodeFsck implements DataEncryptionKeyFactory {
|
|
+ " from " + remoteAddress + " for path " + path + " at " + new Date();
|
|
+ " from " + remoteAddress + " for path " + path + " at " + new Date();
|
|
LOG.info(msg);
|
|
LOG.info(msg);
|
|
out.println(msg);
|
|
out.println(msg);
|
|
- namenode.getNamesystem().logFsckEvent(path, remoteAddress);
|
|
|
|
|
|
|
|
if (snapshottableDirs != null) {
|
|
if (snapshottableDirs != null) {
|
|
SnapshottableDirectoryStatus[] snapshotDirs =
|
|
SnapshottableDirectoryStatus[] snapshotDirs =
|