HDFS-16018. Optimize the display of hdfs "count -e" or "count -t" com… (#2994)
This commit is contained in:
parent
3f5a66c158
commit
f7247922b7
@ -281,6 +281,20 @@ public int hashCode() {
|
||||
|
||||
private static final String ALL_HEADER = QUOTA_HEADER + SUMMARY_HEADER;
|
||||
|
||||
/**
|
||||
* Output format:
|
||||
* <--------20-------->
|
||||
* ERASURECODING_POLICY
|
||||
*/
|
||||
private static final String ERASURECODING_POLICY_FORMAT = "%20s ";
|
||||
|
||||
private static final String ERASURECODING_POLICY_HEADER_FIELD =
|
||||
"ERASURECODING_POLICY";
|
||||
|
||||
/** The header string. */
|
||||
private static final String ERASURECODING_POLICY_HEADER = String.format(
|
||||
ERASURECODING_POLICY_FORMAT, ERASURECODING_POLICY_HEADER_FIELD);
|
||||
|
||||
/**
|
||||
* Output format:<-------18-------> <----------24---------->
|
||||
* <----------24---------->. <-------------28------------> SNAPSHOT_LENGTH
|
||||
@ -308,6 +322,10 @@ public static String getHeader(boolean qOption) {
|
||||
return qOption ? ALL_HEADER : SUMMARY_HEADER;
|
||||
}
|
||||
|
||||
public static String getErasureCodingPolicyHeader() {
|
||||
return ERASURECODING_POLICY_HEADER;
|
||||
}
|
||||
|
||||
public static String getSnapshotHeader() {
|
||||
return SNAPSHOT_HEADER;
|
||||
}
|
||||
@ -444,6 +462,13 @@ private String formatSize(long size, boolean humanReadable) {
|
||||
: String.valueOf(size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Constant-width String representation of Erasure Coding Policy
|
||||
*/
|
||||
public String toErasureCodingPolicy() {
|
||||
return String.format(ERASURECODING_POLICY_FORMAT, erasureCodingPolicy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the string representation of the snapshot counts in the output
|
||||
* format.
|
||||
|
@ -242,12 +242,14 @@ public boolean equals(Object obj) {
|
||||
|
||||
/**
|
||||
* Output format:
|
||||
* |----12----| |------15-----| |------15-----| |------15-----|
|
||||
* QUOTA REM_QUOTA SPACE_QUOTA REM_SPACE_QUOTA
|
||||
* |----12----| |----12----| |-------18-------|
|
||||
* DIR_COUNT FILE_COUNT CONTENT_SIZE
|
||||
* |-----14-----| |-------18------| |-----14-----| |-------18------|
|
||||
* SSD_QUOTA REM_SSD_QUOTA DISK_QUOTA REM_DISK_QUOTA
|
||||
* |-----14-----| |-------18------| |-----14-----| |-------18------|
|
||||
* ARCHIVE_QUOTA REM_ARCHIVE_QUOTA PROVIDED_QUOTA REM_PROVIDED_QUOTA
|
||||
* |-----14-----| |-------18------| |-------18------|
|
||||
* NVDIMM_QUOTA REM_NVDIMM_QUOTA PATHNAME
|
||||
*/
|
||||
private static final String STORAGE_TYPE_SUMMARY_FORMAT = "%13s %17s ";
|
||||
private static final String STORAGE_TYPE_SUMMARY_FORMAT = "%14s %18s ";
|
||||
|
||||
/** Return the header of the output.
|
||||
* @return the header of the output
|
||||
|
@ -167,7 +167,7 @@ protected void processOptions(LinkedList<String> args) {
|
||||
}
|
||||
}
|
||||
if (displayECPolicy) {
|
||||
headString.append("ERASURECODING_POLICY ");
|
||||
headString.append(ContentSummary.getErasureCodingPolicyHeader());
|
||||
}
|
||||
if (showSnapshot) {
|
||||
headString.append(ContentSummary.getSnapshotHeader());
|
||||
@ -206,11 +206,7 @@ protected void processPath(PathData src) throws IOException {
|
||||
}
|
||||
if (displayECPolicy) {
|
||||
ContentSummary summary = src.fs.getContentSummary(src.path);
|
||||
if(!summary.getErasureCodingPolicy().equals("Replicated")){
|
||||
outputString.append("EC:");
|
||||
}
|
||||
outputString.append(summary.getErasureCodingPolicy())
|
||||
.append(" ");
|
||||
outputString.append(summary.toErasureCodingPolicy());
|
||||
}
|
||||
if (showSnapshot) {
|
||||
ContentSummary summary = src.fs.getContentSummary(src.path);
|
||||
|
@ -282,9 +282,8 @@ public void processPathWithQuotasByStorageTypesHeader() throws Exception {
|
||||
options.add("dummy");
|
||||
count.processOptions(options);
|
||||
String withStorageTypeHeader =
|
||||
// <----13---> <-------17------> <----13-----> <------17------->
|
||||
// <----14----> <-------18-------> <-----14-----> <-------18------->
|
||||
" SSD_QUOTA REM_SSD_QUOTA DISK_QUOTA REM_DISK_QUOTA " +
|
||||
// <----13---> <-------17------>
|
||||
" ARCHIVE_QUOTA REM_ARCHIVE_QUOTA PROVIDED_QUOTA REM_PROVIDED_QUOTA " +
|
||||
" NVDIMM_QUOTA REM_NVDIMM_QUOTA " +
|
||||
"PATHNAME";
|
||||
@ -311,7 +310,7 @@ public void processPathWithQuotasBySSDStorageTypesHeader() throws Exception {
|
||||
options.add("dummy");
|
||||
count.processOptions(options);
|
||||
String withStorageTypeHeader =
|
||||
// <----13---> <-------17------>
|
||||
// <----14----> <-------18------->
|
||||
" SSD_QUOTA REM_SSD_QUOTA " +
|
||||
"PATHNAME";
|
||||
verify(out).println(withStorageTypeHeader);
|
||||
@ -337,7 +336,7 @@ public void processPathWithQuotasByQTVH() throws Exception {
|
||||
options.add("dummy");
|
||||
count.processOptions(options);
|
||||
String withStorageTypeHeader =
|
||||
// <----13---> <-------17------>
|
||||
// <----14----> <-------18------->
|
||||
" SSD_QUOTA REM_SSD_QUOTA " +
|
||||
" DISK_QUOTA REM_DISK_QUOTA " +
|
||||
" ARCHIVE_QUOTA REM_ARCHIVE_QUOTA " +
|
||||
@ -405,7 +404,7 @@ public void processPathWithQuotasByMultipleStorageTypes() throws Exception {
|
||||
options.add("dummy");
|
||||
count.processOptions(options);
|
||||
String withStorageTypeHeader =
|
||||
// <----13---> <------17------->
|
||||
// <----14----> <------18-------->
|
||||
" SSD_QUOTA REM_SSD_QUOTA " +
|
||||
" DISK_QUOTA REM_DISK_QUOTA " +
|
||||
"PATHNAME";
|
||||
|
Loading…
Reference in New Issue
Block a user