use of org.apache.hadoop.fs.QuotaUsage in project hadoop by apache.
the class TestViewFsDefaultValue method testGetQuotaUsageWithStorageTypes.
/**
* Test that getQuotaUsage can be retrieved on the client side if
* storage types are defined.
*/
@Test
public void testGetQuotaUsageWithStorageTypes() throws IOException {
FileSystem hFs = cluster.getFileSystem(0);
final DistributedFileSystem dfs = (DistributedFileSystem) hFs;
dfs.setQuotaByStorageType(testFileDirPath, StorageType.SSD, 500);
dfs.setQuotaByStorageType(testFileDirPath, StorageType.DISK, 600);
QuotaUsage qu = vfs.getQuotaUsage(testFileDirPath);
assertEquals(500, qu.getTypeQuota(StorageType.SSD));
assertEquals(600, qu.getTypeQuota(StorageType.DISK));
}
use of org.apache.hadoop.fs.QuotaUsage in project hadoop by apache.
the class DistributedFileSystem method getQuotaUsage.
@Override
public QuotaUsage getQuotaUsage(Path f) throws IOException {
statistics.incrementReadOps(1);
storageStatistics.incrementOpCounter(OpType.GET_QUOTA_USAGE);
Path absF = fixRelativePart(f);
return new FileSystemLinkResolver<QuotaUsage>() {
@Override
public QuotaUsage doCall(final Path p) throws IOException, UnresolvedLinkException {
return dfs.getQuotaUsage(getPathName(p));
}
@Override
public QuotaUsage next(final FileSystem fs, final Path p) throws IOException {
return fs.getQuotaUsage(p);
}
}.resolve(this, absF);
}
use of org.apache.hadoop.fs.QuotaUsage in project hadoop by apache.
the class FSNamesystem method getQuotaUsage.
/**
* Get the quota usage for a specific file/dir.
*
* @param src The string representation of the path to the file
*
* @throws AccessControlException if access is denied
* @throws UnresolvedLinkException if a symlink is encountered.
* @throws FileNotFoundException if no file exists
* @throws StandbyException
* @throws IOException for issues with writing to the audit log
*
* @return object containing information regarding the file
* or null if file not found
*/
QuotaUsage getQuotaUsage(final String src) throws IOException {
checkOperation(OperationCategory.READ);
final String operationName = "quotaUsage";
QuotaUsage quotaUsage;
readLock();
boolean success = true;
try {
checkOperation(OperationCategory.READ);
quotaUsage = FSDirStatAndListingOp.getQuotaUsage(dir, src);
} catch (AccessControlException ace) {
success = false;
logAuditEvent(success, operationName, src);
throw ace;
} finally {
readUnlock(operationName);
}
logAuditEvent(success, operationName, src);
return quotaUsage;
}
use of org.apache.hadoop.fs.QuotaUsage in project hadoop by apache.
the class TestQuota method testSetAndClearSpaceQuotaRegularInternal.
private void testSetAndClearSpaceQuotaRegularInternal(final String[] args, final Path dir, final int cmdRet, final int spaceQuota) throws Exception {
resetStream();
final DFSAdmin dfsAdmin = new DFSAdmin(conf);
final List<String> outs = Lists.newArrayList();
final int ret = ToolRunner.run(dfsAdmin, args);
assertEquals(cmdRet, ret);
final QuotaUsage quotaUsage = dfs.getQuotaUsage(dir);
assertEquals(spaceQuota, quotaUsage.getSpaceQuota());
scanIntoList(OUT_STREAM, outs);
assertTrue("There should be no output if it runs successfully.", outs.isEmpty());
}
use of org.apache.hadoop.fs.QuotaUsage in project hadoop by apache.
the class TestQuota method testSetAndClearSpaceQuotaByStorageTypeInternal.
private void testSetAndClearSpaceQuotaByStorageTypeInternal(final String[] args, final Path dir, final int cmdRet, final int spaceQuota, final int spaceQuotaByStorageType) throws Exception {
resetStream();
final DFSAdmin dfsAdmin = new DFSAdmin(conf);
final List<String> outs = Lists.newArrayList();
final int ret = ToolRunner.run(dfsAdmin, args);
assertEquals(cmdRet, ret);
final QuotaUsage quotaUsage = dfs.getQuotaUsage(dir);
assertEquals(spaceQuota, quotaUsage.getSpaceQuota());
assertEquals(spaceQuotaByStorageType, quotaUsage.getTypeQuota(StorageType.DISK));
scanIntoList(OUT_STREAM, outs);
assertTrue("There should be no output if it runs successfully.", outs.isEmpty());
}
Aggregations