Skip to content

Commit

Permalink
display detailed file number in slow fs ls command (#8364)
Browse files Browse the repository at this point in the history
  • Loading branch information
LuQQiu authored and calvinjia committed Feb 8, 2019
1 parent 06d86b4 commit 34d1dad
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions shell/src/main/java/alluxio/cli/fs/command/LsCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,12 @@ public Options getOptions() {
private void ls(AlluxioURI path, boolean recursive, boolean forceLoadMetadata, boolean dirAsFile,
boolean hSize, boolean pinnedOnly, String sortField, boolean reverse)
throws AlluxioException, IOException {
URIStatus pathStatus = mFileSystem.getStatus(path);
if (dirAsFile) {
URIStatus status = mFileSystem.getStatus(path);
if (pinnedOnly && !status.isPinned()) {
if (pinnedOnly && !pathStatus.isPinned()) {
return;
}
printLsString(status, hSize);
printLsString(pathStatus, hSize);
return;
}

Expand All @@ -243,13 +243,15 @@ private void ls(AlluxioURI path, boolean recursive, boolean forceLoadMetadata, b

// If list status takes too long, print the message
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
System.out.println("Getting directory status may take a while "
+ "if it has millions of files or sub-directories.");
}
}, 10000);
if (pathStatus.isFolder()) {
timer.schedule(new TimerTask() {
@Override
public void run() {
System.out.printf("Getting directory status of %s files or sub-directories "
+ "may taike a while.", pathStatus.getLength());
}
}, 10000);
}
List<URIStatus> statuses = mFileSystem.listStatus(path, optionsBuilder.build());
timer.cancel();

Expand Down

0 comments on commit 34d1dad

Please sign in to comment.