|
@@ -56,13 +56,14 @@ public class Count extends FsCommand {
|
|
//return the quota, namespace count and disk space usage.
|
|
//return the quota, namespace count and disk space usage.
|
|
private static final String OPTION_QUOTA_AND_USAGE = "u";
|
|
private static final String OPTION_QUOTA_AND_USAGE = "u";
|
|
private static final String OPTION_ECPOLICY = "e";
|
|
private static final String OPTION_ECPOLICY = "e";
|
|
|
|
+ private static final String OPTION_SNAPSHOT_COUNT = "s";
|
|
|
|
|
|
public static final String NAME = "count";
|
|
public static final String NAME = "count";
|
|
public static final String USAGE =
|
|
public static final String USAGE =
|
|
"[-" + OPTION_QUOTA + "] [-" + OPTION_HUMAN + "] [-" + OPTION_HEADER
|
|
"[-" + OPTION_QUOTA + "] [-" + OPTION_HUMAN + "] [-" + OPTION_HEADER
|
|
+ "] [-" + OPTION_TYPE + " [<storage type>]] [-" +
|
|
+ "] [-" + OPTION_TYPE + " [<storage type>]] [-" +
|
|
OPTION_QUOTA_AND_USAGE + "] [-" + OPTION_EXCLUDE_SNAPSHOT
|
|
OPTION_QUOTA_AND_USAGE + "] [-" + OPTION_EXCLUDE_SNAPSHOT
|
|
- + "] [-" + OPTION_ECPOLICY
|
|
|
|
|
|
+ + "] [-" + OPTION_ECPOLICY + "] [-" + OPTION_SNAPSHOT_COUNT
|
|
+ "] <path> ...";
|
|
+ "] <path> ...";
|
|
public static final String DESCRIPTION =
|
|
public static final String DESCRIPTION =
|
|
"Count the number of directories, files and bytes under the paths\n" +
|
|
"Count the number of directories, files and bytes under the paths\n" +
|
|
@@ -93,7 +94,8 @@ public class Count extends FsCommand {
|
|
"the storage types.\n" +
|
|
"the storage types.\n" +
|
|
"The -" + OPTION_QUOTA_AND_USAGE + " option shows the quota and \n" +
|
|
"The -" + OPTION_QUOTA_AND_USAGE + " option shows the quota and \n" +
|
|
"the usage against the quota without the detailed content summary."+
|
|
"the usage against the quota without the detailed content summary."+
|
|
- "The -"+ OPTION_ECPOLICY +" option shows the erasure coding policy.";
|
|
|
|
|
|
+ "The -" + OPTION_ECPOLICY + " option shows the erasure coding policy."
|
|
|
|
+ + "The -" + OPTION_SNAPSHOT_COUNT + " option shows snapshot counts.";
|
|
|
|
|
|
private boolean showQuotas;
|
|
private boolean showQuotas;
|
|
private boolean humanReadable;
|
|
private boolean humanReadable;
|
|
@@ -102,6 +104,7 @@ public class Count extends FsCommand {
|
|
private boolean showQuotasAndUsageOnly;
|
|
private boolean showQuotasAndUsageOnly;
|
|
private boolean excludeSnapshots;
|
|
private boolean excludeSnapshots;
|
|
private boolean displayECPolicy;
|
|
private boolean displayECPolicy;
|
|
|
|
+ private boolean showSnapshot;
|
|
|
|
|
|
/** Constructor */
|
|
/** Constructor */
|
|
public Count() {}
|
|
public Count() {}
|
|
@@ -123,7 +126,7 @@ public class Count extends FsCommand {
|
|
CommandFormat cf = new CommandFormat(1, Integer.MAX_VALUE,
|
|
CommandFormat cf = new CommandFormat(1, Integer.MAX_VALUE,
|
|
OPTION_QUOTA, OPTION_HUMAN, OPTION_HEADER, OPTION_QUOTA_AND_USAGE,
|
|
OPTION_QUOTA, OPTION_HUMAN, OPTION_HEADER, OPTION_QUOTA_AND_USAGE,
|
|
OPTION_EXCLUDE_SNAPSHOT,
|
|
OPTION_EXCLUDE_SNAPSHOT,
|
|
- OPTION_ECPOLICY);
|
|
|
|
|
|
+ OPTION_ECPOLICY, OPTION_SNAPSHOT_COUNT);
|
|
cf.addOptionWithValue(OPTION_TYPE);
|
|
cf.addOptionWithValue(OPTION_TYPE);
|
|
cf.parse(args);
|
|
cf.parse(args);
|
|
if (args.isEmpty()) { // default path is the current working directory
|
|
if (args.isEmpty()) { // default path is the current working directory
|
|
@@ -134,6 +137,7 @@ public class Count extends FsCommand {
|
|
showQuotasAndUsageOnly = cf.getOpt(OPTION_QUOTA_AND_USAGE);
|
|
showQuotasAndUsageOnly = cf.getOpt(OPTION_QUOTA_AND_USAGE);
|
|
excludeSnapshots = cf.getOpt(OPTION_EXCLUDE_SNAPSHOT);
|
|
excludeSnapshots = cf.getOpt(OPTION_EXCLUDE_SNAPSHOT);
|
|
displayECPolicy = cf.getOpt(OPTION_ECPOLICY);
|
|
displayECPolicy = cf.getOpt(OPTION_ECPOLICY);
|
|
|
|
+ showSnapshot = cf.getOpt(OPTION_SNAPSHOT_COUNT);
|
|
|
|
|
|
if (showQuotas || showQuotasAndUsageOnly) {
|
|
if (showQuotas || showQuotasAndUsageOnly) {
|
|
String types = cf.getOptValue(OPTION_TYPE);
|
|
String types = cf.getOptValue(OPTION_TYPE);
|
|
@@ -165,6 +169,9 @@ public class Count extends FsCommand {
|
|
if(displayECPolicy){
|
|
if(displayECPolicy){
|
|
headString.append("ERASURECODING_POLICY ");
|
|
headString.append("ERASURECODING_POLICY ");
|
|
}
|
|
}
|
|
|
|
+ if (showSnapshot) {
|
|
|
|
+ headString.append(ContentSummary.getSnapshotHeader());
|
|
|
|
+ }
|
|
headString.append("PATHNAME");
|
|
headString.append("PATHNAME");
|
|
out.println(headString.toString());
|
|
out.println(headString.toString());
|
|
}
|
|
}
|
|
@@ -205,6 +212,10 @@ public class Count extends FsCommand {
|
|
outputString.append(summary.getErasureCodingPolicy())
|
|
outputString.append(summary.getErasureCodingPolicy())
|
|
.append(" ");
|
|
.append(" ");
|
|
}
|
|
}
|
|
|
|
+ if (showSnapshot) {
|
|
|
|
+ ContentSummary summary = src.fs.getContentSummary(src.path);
|
|
|
|
+ outputString.append(summary.toSnapshot(isHumanReadable()));
|
|
|
|
+ }
|
|
outputString.append(src);
|
|
outputString.append(src);
|
|
out.println(outputString.toString());
|
|
out.println(outputString.toString());
|
|
}
|
|
}
|