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 class ContentSummary extends QuotaUsage implements Writable{
|
|||
|
||||
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 class ContentSummary extends QuotaUsage implements Writable{
|
|||
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 @@ public class ContentSummary extends QuotaUsage implements Writable{
|
|||
: 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 class QuotaUsage {
|
|||
|
||||
/**
|
||||
* 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
|
||||
|
|
|
@ -166,8 +166,8 @@ public class Count extends FsCommand {
|
|||
headString.append(ContentSummary.getHeader(showQuotas));
|
||||
}
|
||||
}
|
||||
if(displayECPolicy){
|
||||
headString.append("ERASURECODING_POLICY ");
|
||||
if (displayECPolicy) {
|
||||
headString.append(ContentSummary.getErasureCodingPolicyHeader());
|
||||
}
|
||||
if (showSnapshot) {
|
||||
headString.append(ContentSummary.getSnapshotHeader());
|
||||
|
@ -204,13 +204,9 @@ public class Count extends FsCommand {
|
|||
outputString.append(summary.toString(
|
||||
showQuotas, isHumanReadable(), excludeSnapshots));
|
||||
}
|
||||
if(displayECPolicy){
|
||||
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,11 +282,10 @@ public class TestCount {
|
|||
options.add("dummy");
|
||||
count.processOptions(options);
|
||||
String withStorageTypeHeader =
|
||||
// <----13---> <-------17------> <----13-----> <------17------->
|
||||
" 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 " +
|
||||
// <----14----> <-------18-------> <-----14-----> <-------18------->
|
||||
" SSD_QUOTA REM_SSD_QUOTA DISK_QUOTA REM_DISK_QUOTA " +
|
||||
" ARCHIVE_QUOTA REM_ARCHIVE_QUOTA PROVIDED_QUOTA REM_PROVIDED_QUOTA " +
|
||||
" NVDIMM_QUOTA REM_NVDIMM_QUOTA " +
|
||||
"PATHNAME";
|
||||
verify(out).println(withStorageTypeHeader);
|
||||
verifyNoMoreInteractions(out);
|
||||
|
@ -311,8 +310,8 @@ public class TestCount {
|
|||
options.add("dummy");
|
||||
count.processOptions(options);
|
||||
String withStorageTypeHeader =
|
||||
// <----13---> <-------17------>
|
||||
" SSD_QUOTA REM_SSD_QUOTA " +
|
||||
// <----14----> <-------18------->
|
||||
" SSD_QUOTA REM_SSD_QUOTA " +
|
||||
"PATHNAME";
|
||||
verify(out).println(withStorageTypeHeader);
|
||||
verifyNoMoreInteractions(out);
|
||||
|
@ -337,12 +336,12 @@ public class TestCount {
|
|||
options.add("dummy");
|
||||
count.processOptions(options);
|
||||
String withStorageTypeHeader =
|
||||
// <----13---> <-------17------>
|
||||
" SSD_QUOTA REM_SSD_QUOTA " +
|
||||
" DISK_QUOTA REM_DISK_QUOTA " +
|
||||
"ARCHIVE_QUOTA REM_ARCHIVE_QUOTA " +
|
||||
// <----14----> <-------18------->
|
||||
" SSD_QUOTA REM_SSD_QUOTA " +
|
||||
" DISK_QUOTA REM_DISK_QUOTA " +
|
||||
" ARCHIVE_QUOTA REM_ARCHIVE_QUOTA " +
|
||||
"PROVIDED_QUOTA REM_PROVIDED_QUOTA " +
|
||||
" NVDIMM_QUOTA REM_NVDIMM_QUOTA " +
|
||||
" NVDIMM_QUOTA REM_NVDIMM_QUOTA " +
|
||||
"PATHNAME";
|
||||
verify(out).println(withStorageTypeHeader);
|
||||
verifyNoMoreInteractions(out);
|
||||
|
@ -405,9 +404,9 @@ public class TestCount {
|
|||
options.add("dummy");
|
||||
count.processOptions(options);
|
||||
String withStorageTypeHeader =
|
||||
// <----13---> <------17------->
|
||||
" SSD_QUOTA REM_SSD_QUOTA " +
|
||||
" DISK_QUOTA REM_DISK_QUOTA " +
|
||||
// <----14----> <------18-------->
|
||||
" SSD_QUOTA REM_SSD_QUOTA " +
|
||||
" DISK_QUOTA REM_DISK_QUOTA " +
|
||||
"PATHNAME";
|
||||
verify(out).println(withStorageTypeHeader);
|
||||
verifyNoMoreInteractions(out);
|
||||
|
|
Loading…
Reference in New Issue