Skip to content

Commit

Permalink
HDFS-7775. Use consistent naming for NN-internal quota related types …
Browse files Browse the repository at this point in the history
…and functions. (Contributed bu Xiaoyu Yao)
  • Loading branch information
arp7 committed Feb 14, 2015
1 parent 2efb234 commit f2231ce
Show file tree
Hide file tree
Showing 31 changed files with 285 additions and 267 deletions.
7 changes: 5 additions & 2 deletions hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
Expand Up @@ -951,6 +951,9 @@ Release 2.7.0 - UNRELEASED
HDFS-7778. Rename FsVolumeListTest to TestFsVolumeList and commit it to HDFS-7778. Rename FsVolumeListTest to TestFsVolumeList and commit it to
branch-2. (Lei (Eddy) Xu via cnauroth) branch-2. (Lei (Eddy) Xu via cnauroth)


HDFS-4625. BKJM doesn't take advantage of speculative reads. (Rakesh R
via aajisaka)

BREAKDOWN OF HDFS-7584 SUBTASKS AND RELATED JIRAS BREAKDOWN OF HDFS-7584 SUBTASKS AND RELATED JIRAS


HDFS-7720. Quota by Storage Type API, tools and ClientNameNode HDFS-7720. Quota by Storage Type API, tools and ClientNameNode
Expand All @@ -965,8 +968,8 @@ Release 2.7.0 - UNRELEASED
HDFS-7776. Adding additional unit tests for Quota By Storage Type. HDFS-7776. Adding additional unit tests for Quota By Storage Type.
(Xiaoyu Yao via Arpit Agarwal) (Xiaoyu Yao via Arpit Agarwal)


HDFS-4625. BKJM doesn't take advantage of speculative reads. (Rakesh R HDFS-7775. Use consistent naming for NN-internal quota related types
via aajisaka) and functions. (Xiaoyu Yao via Arpit Agarwal)


Release 2.6.1 - UNRELEASED Release 2.6.1 - UNRELEASED


Expand Down
Expand Up @@ -3049,22 +3049,22 @@ ContentSummary getContentSummary(String src) throws IOException {
* Sets or resets quotas for a directory. * Sets or resets quotas for a directory.
* @see ClientProtocol#setQuota(String, long, long, StorageType) * @see ClientProtocol#setQuota(String, long, long, StorageType)
*/ */
void setQuota(String src, long namespaceQuota, long diskspaceQuota) void setQuota(String src, long namespaceQuota, long storagespaceQuota)
throws IOException { throws IOException {
// sanity check // sanity check
if ((namespaceQuota <= 0 && namespaceQuota != HdfsConstants.QUOTA_DONT_SET && if ((namespaceQuota <= 0 && namespaceQuota != HdfsConstants.QUOTA_DONT_SET &&
namespaceQuota != HdfsConstants.QUOTA_RESET) || namespaceQuota != HdfsConstants.QUOTA_RESET) ||
(diskspaceQuota <= 0 && diskspaceQuota != HdfsConstants.QUOTA_DONT_SET && (storagespaceQuota <= 0 && storagespaceQuota != HdfsConstants.QUOTA_DONT_SET &&
diskspaceQuota != HdfsConstants.QUOTA_RESET)) { storagespaceQuota != HdfsConstants.QUOTA_RESET)) {
throw new IllegalArgumentException("Invalid values for quota : " + throw new IllegalArgumentException("Invalid values for quota : " +
namespaceQuota + " and " + namespaceQuota + " and " +
diskspaceQuota); storagespaceQuota);


} }
TraceScope scope = getPathTraceScope("setQuota", src); TraceScope scope = getPathTraceScope("setQuota", src);
try { try {
// Pass null as storage type for traditional space/namespace quota. // Pass null as storage type for traditional namespace/storagespace quota.
namenode.setQuota(src, namespaceQuota, diskspaceQuota, null); namenode.setQuota(src, namespaceQuota, storagespaceQuota, null);
} catch(RemoteException re) { } catch(RemoteException re) {
throw re.unwrapRemoteException(AccessControlException.class, throw re.unwrapRemoteException(AccessControlException.class,
FileNotFoundException.class, FileNotFoundException.class,
Expand All @@ -3081,12 +3081,12 @@ void setQuota(String src, long namespaceQuota, long diskspaceQuota)
* Sets or resets quotas by storage type for a directory. * Sets or resets quotas by storage type for a directory.
* @see ClientProtocol#setQuota(String, long, long, StorageType) * @see ClientProtocol#setQuota(String, long, long, StorageType)
*/ */
void setQuotaByStorageType(String src, StorageType type, long spaceQuota) void setQuotaByStorageType(String src, StorageType type, long quota)
throws IOException { throws IOException {
if (spaceQuota <= 0 && spaceQuota != HdfsConstants.QUOTA_DONT_SET && if (quota <= 0 && quota != HdfsConstants.QUOTA_DONT_SET &&
spaceQuota != HdfsConstants.QUOTA_RESET) { quota != HdfsConstants.QUOTA_RESET) {
throw new IllegalArgumentException("Invalid values for quota :" + throw new IllegalArgumentException("Invalid values for quota :" +
spaceQuota); quota);
} }
if (type == null) { if (type == null) {
throw new IllegalArgumentException("Invalid storage type(null)"); throw new IllegalArgumentException("Invalid storage type(null)");
Expand All @@ -3096,7 +3096,7 @@ void setQuotaByStorageType(String src, StorageType type, long spaceQuota)
+ type.toString()); + type.toString());
} }
try { try {
namenode.setQuota(src, HdfsConstants.QUOTA_DONT_SET, spaceQuota, type); namenode.setQuota(src, HdfsConstants.QUOTA_DONT_SET, quota, type);
} catch (RemoteException re) { } catch (RemoteException re) {
throw re.unwrapRemoteException(AccessControlException.class, throw re.unwrapRemoteException(AccessControlException.class,
FileNotFoundException.class, FileNotFoundException.class,
Expand Down
Expand Up @@ -735,13 +735,13 @@ public ContentSummary next(final FileSystem fs, final Path p)
* @see org.apache.hadoop.hdfs.protocol.ClientProtocol#setQuota(String, long, long, StorageType) * @see org.apache.hadoop.hdfs.protocol.ClientProtocol#setQuota(String, long, long, StorageType)
*/ */
public void setQuota(Path src, final long namespaceQuota, public void setQuota(Path src, final long namespaceQuota,
final long diskspaceQuota) throws IOException { final long storagespaceQuota) throws IOException {
Path absF = fixRelativePart(src); Path absF = fixRelativePart(src);
new FileSystemLinkResolver<Void>() { new FileSystemLinkResolver<Void>() {
@Override @Override
public Void doCall(final Path p) public Void doCall(final Path p)
throws IOException, UnresolvedLinkException { throws IOException, UnresolvedLinkException {
dfs.setQuota(getPathName(p), namespaceQuota, diskspaceQuota); dfs.setQuota(getPathName(p), namespaceQuota, storagespaceQuota);
return null; return null;
} }
@Override @Override
Expand All @@ -759,18 +759,18 @@ public Void next(final FileSystem fs, final Path p)
* *
* @param src target directory whose quota is to be modified. * @param src target directory whose quota is to be modified.
* @param type storage type of the specific storage type quota to be modified. * @param type storage type of the specific storage type quota to be modified.
* @param spaceQuota value of the specific storage type quota to be modified. * @param quota value of the specific storage type quota to be modified.
* Maybe {@link HdfsConstants#QUOTA_RESET} to clear quota by storage type. * Maybe {@link HdfsConstants#QUOTA_RESET} to clear quota by storage type.
*/ */
public void setQuotaByStorageType( public void setQuotaByStorageType(
Path src, final StorageType type, final long spaceQuota) Path src, final StorageType type, final long quota)
throws IOException { throws IOException {
Path absF = fixRelativePart(src); Path absF = fixRelativePart(src);
new FileSystemLinkResolver<Void>() { new FileSystemLinkResolver<Void>() {
@Override @Override
public Void doCall(final Path p) public Void doCall(final Path p)
throws IOException, UnresolvedLinkException { throws IOException, UnresolvedLinkException {
dfs.setQuotaByStorageType(getPathName(p), type, spaceQuota); dfs.setQuotaByStorageType(getPathName(p), type, quota);
return null; return null;
} }
@Override @Override
Expand Down
Expand Up @@ -96,8 +96,8 @@ public void clearQuota(Path src) throws IOException {
} }


/** /**
* Set the disk space quota (size of files) for a directory. Note that * Set the storage space quota (size of files) for a directory. Note that
* directories and sym links do not occupy disk space. * directories and sym links do not occupy storage space.
* *
* @param src the path to set the space quota of * @param src the path to set the space quota of
* @param spaceQuota the value to set for the space quota * @param spaceQuota the value to set for the space quota
Expand All @@ -108,8 +108,8 @@ public void setSpaceQuota(Path src, long spaceQuota) throws IOException {
} }


/** /**
* Clear the disk space quota (size of files) for a directory. Note that * Clear the storage space quota (size of files) for a directory. Note that
* directories and sym links do not occupy disk space. * directories and sym links do not occupy storage space.
* *
* @param src the path to clear the space quota of * @param src the path to clear the space quota of
* @throws IOException in the event of error * @throws IOException in the event of error
Expand All @@ -120,21 +120,21 @@ public void clearSpaceQuota(Path src) throws IOException {


/** /**
* Set the quota by storage type for a directory. Note that * Set the quota by storage type for a directory. Note that
* directories and sym links do not occupy disk space. * directories and sym links do not occupy storage type quota.
* *
* @param src the target directory to set the quota by storage type * @param src the target directory to set the quota by storage type
* @param type the storage type to set for quota by storage type * @param type the storage type to set for quota by storage type
* @param spaceQuota the value to set for quota by storage type * @param quota the value to set for quota by storage type
* @throws IOException in the event of error * @throws IOException in the event of error
*/ */
public void setQuotaByStorageType(Path src, StorageType type, long spaceQuota) public void setQuotaByStorageType(Path src, StorageType type, long quota)
throws IOException { throws IOException {
dfs.setQuotaByStorageType(src, type, spaceQuota); dfs.setQuotaByStorageType(src, type, quota);
} }


/** /**
* Clear the space quota by storage type for a directory. Note that * Clear the space quota by storage type for a directory. Note that
* directories and sym links do not occupy disk space. * directories and sym links do not occupy storage type quota.
* *
* @param src the target directory to clear the quota by storage type * @param src the target directory to clear the quota by storage type
* @param type the storage type to clear for quota by storage type * @param type the storage type to clear for quota by storage type
Expand Down
Expand Up @@ -951,10 +951,14 @@ public ContentSummary getContentSummary(String path)
* @param path The string representation of the path to the directory * @param path The string representation of the path to the directory
* @param namespaceQuota Limit on the number of names in the tree rooted * @param namespaceQuota Limit on the number of names in the tree rooted
* at the directory * at the directory
* @param diskspaceQuota Limit on disk space occupied all the files under * @param storagespaceQuota Limit on storage space occupied all the files under
* this directory. * this directory.
* @param type StorageType that the space quota is intended to be set on. * @param type StorageType that the space quota is intended to be set on.
* It may be null when called by traditional space/namespace quota. * It may be null when called by traditional space/namespace quota.
* When type is is not null, the storagespaceQuota parameter is for
* type specified and namespaceQuota must be
* {@link HdfsConstants#QUOTA_DONT_SET}.
*
* <br><br> * <br><br>
* *
* The quota can have three types of values : (1) 0 or more will set * The quota can have three types of values : (1) 0 or more will set
Expand All @@ -971,7 +975,7 @@ public ContentSummary getContentSummary(String path)
* @throws IOException If an I/O error occurred * @throws IOException If an I/O error occurred
*/ */
@Idempotent @Idempotent
public void setQuota(String path, long namespaceQuota, long diskspaceQuota, public void setQuota(String path, long namespaceQuota, long storagespaceQuota,
StorageType type) throws AccessControlException, FileNotFoundException, StorageType type) throws AccessControlException, FileNotFoundException,
UnresolvedLinkException, SnapshotAccessControlException, IOException; UnresolvedLinkException, SnapshotAccessControlException, IOException;


Expand Down
Expand Up @@ -887,7 +887,7 @@ public SetQuotaResponseProto setQuota(RpcController controller,
SetQuotaRequestProto req) throws ServiceException { SetQuotaRequestProto req) throws ServiceException {
try { try {
server.setQuota(req.getPath(), req.getNamespaceQuota(), server.setQuota(req.getPath(), req.getNamespaceQuota(),
req.getDiskspaceQuota(), req.getStoragespaceQuota(),
req.hasStorageType() ? req.hasStorageType() ?
PBHelper.convertStorageType(req.getStorageType()): null); PBHelper.convertStorageType(req.getStorageType()): null);
return VOID_SETQUOTA_RESPONSE; return VOID_SETQUOTA_RESPONSE;
Expand Down
Expand Up @@ -806,15 +806,15 @@ public ContentSummary getContentSummary(String path)
} }


@Override @Override
public void setQuota(String path, long namespaceQuota, long diskspaceQuota, public void setQuota(String path, long namespaceQuota, long storagespaceQuota,
StorageType type) StorageType type)
throws AccessControlException, FileNotFoundException, throws AccessControlException, FileNotFoundException,
UnresolvedLinkException, IOException { UnresolvedLinkException, IOException {
final SetQuotaRequestProto.Builder builder final SetQuotaRequestProto.Builder builder
= SetQuotaRequestProto.newBuilder() = SetQuotaRequestProto.newBuilder()
.setPath(path) .setPath(path)
.setNamespaceQuota(namespaceQuota) .setNamespaceQuota(namespaceQuota)
.setDiskspaceQuota(diskspaceQuota); .setStoragespaceQuota(storagespaceQuota);
if (type != null) { if (type != null) {
builder.setStorageType(PBHelper.convertStorageType(type)); builder.setStorageType(PBHelper.convertStorageType(type));
} }
Expand Down

0 comments on commit f2231ce

Please sign in to comment.