use of org.apache.hadoop.fs.QuotaUsage in project hadoop by apache.
the class Count method processPath.
@Override
protected void processPath(PathData src) throws IOException {
if (showQuotasAndUsageOnly || showQuotabyType) {
QuotaUsage usage = src.fs.getQuotaUsage(src.path);
out.println(usage.toString(isHumanReadable(), showQuotabyType, storageTypes) + src);
} else {
ContentSummary summary = src.fs.getContentSummary(src.path);
out.println(summary.toString(showQuotas, isHumanReadable(), excludeSnapshots) + src);
}
}
use of org.apache.hadoop.fs.QuotaUsage in project hadoop by apache.
the class FSDirStatAndListingOp method getQuotaUsageInt.
private static QuotaUsage getQuotaUsageInt(FSDirectory fsd, INodesInPath iip) throws IOException {
fsd.readLock();
try {
INode targetNode = iip.getLastINode();
QuotaUsage usage = null;
if (targetNode.isDirectory()) {
DirectoryWithQuotaFeature feature = targetNode.asDirectory().getDirectoryWithQuotaFeature();
if (feature != null) {
QuotaCounts counts = feature.getSpaceConsumed();
QuotaCounts quotas = feature.getQuota();
usage = new QuotaUsage.Builder().fileAndDirectoryCount(counts.getNameSpace()).quota(quotas.getNameSpace()).spaceConsumed(counts.getStorageSpace()).spaceQuota(quotas.getStorageSpace()).typeConsumed(counts.getTypeSpaces().asArray()).typeQuota(quotas.getTypeSpaces().asArray()).build();
}
}
return usage;
} finally {
fsd.readUnlock();
}
}
use of org.apache.hadoop.fs.QuotaUsage in project hadoop by apache.
the class FSDirStatAndListingOp method getQuotaUsage.
static QuotaUsage getQuotaUsage(FSDirectory fsd, String src) throws IOException {
FSPermissionChecker pc = fsd.getPermissionChecker();
final INodesInPath iip;
fsd.readLock();
try {
iip = fsd.resolvePath(pc, src, DirOp.READ_LINK);
if (fsd.isPermissionEnabled()) {
fsd.checkPermission(pc, iip, false, null, null, null, FsAction.READ_EXECUTE);
}
} finally {
fsd.readUnlock();
}
QuotaUsage usage = getQuotaUsageInt(fsd, iip);
if (usage != null) {
return usage;
} else {
//If quota isn't set, fall back to getContentSummary.
return getContentSummaryInt(fsd, iip);
}
}
use of org.apache.hadoop.fs.QuotaUsage in project hadoop by apache.
the class TestViewFsDefaultValue method testGetQuotaUsage.
/**
* Test that getQuotaUsage can be retrieved on the client side.
*/
@Test
public void testGetQuotaUsage() throws IOException {
FileSystem hFs = cluster.getFileSystem(0);
final DistributedFileSystem dfs = (DistributedFileSystem) hFs;
dfs.setQuota(testFileDirPath, 100, 500);
QuotaUsage qu = vfs.getQuotaUsage(testFileDirPath);
assertEquals(100, qu.getQuota());
assertEquals(500, qu.getSpaceQuota());
}
use of org.apache.hadoop.fs.QuotaUsage in project hadoop by apache.
the class TestViewFsDefaultValue method testGetQuotaUsageWithQuotaDefined.
/**
* Test that getQuotaUsage can be retrieved on the client side if
* quota isn't defined.
*/
@Test
public void testGetQuotaUsageWithQuotaDefined() throws IOException {
FileSystem hFs = cluster.getFileSystem(0);
final DistributedFileSystem dfs = (DistributedFileSystem) hFs;
dfs.setQuota(testFileDirPath, -1, -1);
dfs.setQuotaByStorageType(testFileDirPath, StorageType.SSD, -1);
dfs.setQuotaByStorageType(testFileDirPath, StorageType.DISK, -1);
QuotaUsage qu = vfs.getQuotaUsage(testFileDirPath);
assertEquals(-1, qu.getTypeQuota(StorageType.SSD));
assertEquals(-1, qu.getQuota());
assertEquals(-1, qu.getSpaceQuota());
assertEquals(2, qu.getFileAndDirectoryCount());
assertEquals(0, qu.getTypeConsumed(StorageType.SSD));
assertTrue(qu.getSpaceConsumed() > 0);
}
Aggregations