From ef31f08698f509e05d61529e8620ce31cb324b5e Mon Sep 17 00:00:00 2001 From: Bin Fan Date: Tue, 19 Sep 2017 22:59:00 -0700 Subject: [PATCH] [SMALLFIX] Address comments --- .../src/main/java/alluxio/Constants.java | 14 -------------- .../java/alluxio/cli/fs/command/LsCommand.java | 18 +++++++++++++++--- .../fs/command/LsCommandIntegrationTest.java | 5 ++--- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/core/common/src/main/java/alluxio/Constants.java b/core/common/src/main/java/alluxio/Constants.java index 98c31968daf7..d3dc340eca65 100644 --- a/core/common/src/main/java/alluxio/Constants.java +++ b/core/common/src/main/java/alluxio/Constants.java @@ -41,20 +41,6 @@ public final class Constants { public static final String EXTENSION_JAR = ".jar"; - public static final String LS_FORMAT_PERMISSION = "%-11s"; - public static final String LS_FORMAT_FILE_SIZE = "%15s"; - public static final String LS_FORMAT_CREATE_TIME = "%24s"; - public static final String LS_FORMAT_ALLUXIO_STATE = "%5s"; - public static final String LS_FORMAT_PERSISTENCE_STATE = "%16s"; - public static final String LS_FORMAT_USER_NAME = "%-15s"; - public static final String LS_FORMAT_GROUP_NAME = "%-15s"; - public static final String LS_FORMAT_FILE_PATH = "%-5s"; - public static final String LS_FORMAT = LS_FORMAT_PERMISSION + LS_FORMAT_USER_NAME - + LS_FORMAT_GROUP_NAME + LS_FORMAT_FILE_SIZE + LS_FORMAT_PERSISTENCE_STATE - + LS_FORMAT_CREATE_TIME + LS_FORMAT_ALLUXIO_STATE + " " + LS_FORMAT_FILE_PATH + "%n"; - public static final String LS_FORMAT_NO_ACL = LS_FORMAT_FILE_SIZE + LS_FORMAT_PERSISTENCE_STATE - + LS_FORMAT_CREATE_TIME + LS_FORMAT_ALLUXIO_STATE + " " + LS_FORMAT_FILE_PATH + "%n"; - public static final String MESOS_RESOURCE_CPUS = "cpus"; public static final String MESOS_RESOURCE_MEM = "mem"; public static final String MESOS_RESOURCE_DISK = "disk"; diff --git a/shell/src/main/java/alluxio/cli/fs/command/LsCommand.java b/shell/src/main/java/alluxio/cli/fs/command/LsCommand.java index 6d047226e850..fac2b8446444 100644 --- a/shell/src/main/java/alluxio/cli/fs/command/LsCommand.java +++ b/shell/src/main/java/alluxio/cli/fs/command/LsCommand.java @@ -12,7 +12,6 @@ package alluxio.cli.fs.command; import alluxio.AlluxioURI; -import alluxio.Constants; import alluxio.client.file.FileSystem; import alluxio.client.file.URIStatus; import alluxio.client.file.options.ListStatusOptions; @@ -43,6 +42,19 @@ public final class LsCommand extends WithWildCardPathCommand { public static final String IN_ALLUXIO_STATE_DIR = "DIR"; public static final String IN_ALLUXIO_STATE_FILE_FORMAT = "%d%%"; + public static final String LS_FORMAT_PERMISSION = "%-11s"; + public static final String LS_FORMAT_FILE_SIZE = "%15s"; + public static final String LS_FORMAT_CREATE_TIME = "%24s"; + public static final String LS_FORMAT_ALLUXIO_STATE = "%5s"; + public static final String LS_FORMAT_PERSISTENCE_STATE = "%16s"; + public static final String LS_FORMAT_USER_NAME = "%-15s"; + public static final String LS_FORMAT_GROUP_NAME = "%-15s"; + public static final String LS_FORMAT_FILE_PATH = "%-5s"; + public static final String LS_FORMAT_NO_ACL = LS_FORMAT_FILE_SIZE + LS_FORMAT_PERSISTENCE_STATE + + LS_FORMAT_CREATE_TIME + LS_FORMAT_ALLUXIO_STATE + " " + LS_FORMAT_FILE_PATH + "%n"; + public static final String LS_FORMAT = LS_FORMAT_PERMISSION + LS_FORMAT_USER_NAME + + LS_FORMAT_GROUP_NAME + LS_FORMAT_FILE_SIZE + LS_FORMAT_PERSISTENCE_STATE + + LS_FORMAT_CREATE_TIME + LS_FORMAT_ALLUXIO_STATE + " " + LS_FORMAT_FILE_PATH + "%n"; private static final Option FORCE_OPTION = Option.builder("f") @@ -110,11 +122,11 @@ public static String formatLsString(boolean hSize, boolean acl, boolean isFolder } if (acl) { - return String.format(Constants.LS_FORMAT, permission, userName, groupName, + return String.format(LS_FORMAT, permission, userName, groupName, sizeStr, persistenceState, CommonUtils.convertMsToDate(createTimeMs), inAlluxioState, path); } else { - return String.format(Constants.LS_FORMAT_NO_ACL, sizeStr, + return String.format(LS_FORMAT_NO_ACL, sizeStr, persistenceState, CommonUtils.convertMsToDate(createTimeMs), inAlluxioState, path); } } diff --git a/tests/src/test/java/alluxio/cli/fs/command/LsCommandIntegrationTest.java b/tests/src/test/java/alluxio/cli/fs/command/LsCommandIntegrationTest.java index 079ea94630e1..19e13a92d158 100644 --- a/tests/src/test/java/alluxio/cli/fs/command/LsCommandIntegrationTest.java +++ b/tests/src/test/java/alluxio/cli/fs/command/LsCommandIntegrationTest.java @@ -12,7 +12,6 @@ package alluxio.cli.fs.command; import alluxio.AlluxioURI; -import alluxio.Constants; import alluxio.LocalAlluxioClusterResource; import alluxio.PropertyKey; import alluxio.client.WriteType; @@ -53,7 +52,7 @@ private String getLsResultStr(String path, long createTime, int size, String inA String persistenceState) throws IOException, AlluxioException { return String - .format(Constants.LS_FORMAT, FormatUtils.formatMode((short) permission, isDir), + .format(LsCommand.LS_FORMAT, FormatUtils.formatMode((short) permission, isDir), testUser, testGroup, String.valueOf(size), persistenceState, CommonUtils.convertMsToDate(createTime), inAlluxioState, path); } @@ -82,7 +81,7 @@ private String getLsNoAclResultStr(String path, long createTime, boolean hSize, } else { sizeStr = hSize ? FormatUtils.getSizeFromBytes(size) : String.valueOf(size); } - return String.format(Constants.LS_FORMAT_NO_ACL, sizeStr, persistenceState, + return String.format(LsCommand.LS_FORMAT_NO_ACL, sizeStr, persistenceState, CommonUtils.convertMsToDate(createTime), inAlluxioState, path); }