Example usage for org.apache.hadoop.fs StorageType supportTypeQuota

List of usage examples for org.apache.hadoop.fs StorageType supportTypeQuota

Introduction

In this page you can find the example usage for org.apache.hadoop.fs StorageType supportTypeQuota.

Prototype

public boolean supportTypeQuota() 

Source Link

Usage

From source file:com.mellanox.r4h.DFSClient.java

License:Apache License

/**
 * Sets or resets quotas by storage type for a directory.
 * // w  w w . j  a  v a 2s.c  o  m
 * @see ClientProtocol#setQuota(String, long, long, StorageType)
 */
void setQuotaByStorageType(String src, StorageType type, long quota) throws IOException {
    if (quota <= 0 && quota != HdfsConstants.QUOTA_DONT_SET && quota != HdfsConstants.QUOTA_RESET) {
        throw new IllegalArgumentException("Invalid values for quota :" + quota);
    }
    if (type == null) {
        throw new IllegalArgumentException("Invalid storage type(null)");
    }
    if (!type.supportTypeQuota()) {
        throw new IllegalArgumentException("Don't support Quota for storage type : " + type.toString());
    }
    TraceScope scope = getPathTraceScope("setQuotaByStorageType", src);
    try {
        namenode.setQuota(src, HdfsConstants.QUOTA_DONT_SET, quota, type);
    } catch (RemoteException re) {
        throw re.unwrapRemoteException(AccessControlException.class, FileNotFoundException.class,
                QuotaByStorageTypeExceededException.class, UnresolvedPathException.class,
                SnapshotAccessControlException.class);
    } finally {
        scope.close();
    }
}