Manage the directory quota feature
If you want to limit the directory capacity of OSS-HDFS and the number of objects or subdirectories in the directory, you can use the directory quota feature to avoid excessive charges due to the large capacity of a directory or a large number of subdirectories and objects in the directory.
Description
-
Capacity quota: the maximum storage capacity of a directory, including subdirectories and objects in the directory. If the capacity quota is exceeded, you cannot create objects or subdirectories in the directory.
-
Quantity quota: the maximum number of subdirectories and objects in a directory. If the quantity quota is exceeded, you cannot create objects or subdirectories in the directory.
Limits
You can specify only capacity quota and quantity quota for objects and subdirectories in a directory. You cannot specify quotas for a directory based on different object storage classes.
Usage notes
Capacity and quantity statistics for directory quotas are not updated in real time and may be delayed. When quotas are configured for a large number of directories or a directory has a large storage capacity, the statistics may lag behind actual usage by hours, and actual usage may exceed the quota limit.
Procedure
-
Download the Jindofs SDK installation package.
-
Configure the AccessKey pair and environment variables.
-
Go to the bin directory of the installed JindoFS SDK JAR package.
The following sample code provides an example on how to go to the bin directory of the
jindofs-sdk-x.x.x-linuxJAR package. If you use a different version of JindoFS SDK, replace the package name with the name of the corresponding JindoFS SDK JAR package.cd jindofs-sdk-x.x.x-linux/bin/ -
Create a configuration file named jindofs.cfg in the bin directory and configure the AccessKey pair of your Alibaba Cloud account or the a RAM user that has the required permissions.
[client] fs.oss.accessKeyId = yourAccessKeyID fs.oss.accessKeySecret = yourAccessKeySecret -
Configure environment variables.
NoteSet <JINDOSDK_CONF_DIR> to the absolute path of the
jindofs.cfgconfiguration file.export JINDOSDK_CONF_DIR=<JINDOSDK_CONF_DIR>
-
-
Enable the directory quota feature.
./jindofs admin -putConfig -dlsUri oss://<bucket>.<oss-hdfs-endpoint>/ -conf namespace.directory.quota.enable=trueNoteSet <bucket> to the name of the bucket for which OSS-HDFS is enabled. Set <oss-hdfs-endpoint> to the endpoint of OSS-HDFS. Example: cn-shanghai.oss-dls.aliyuncs.com.
Check whether the directory quota feature is enabled.
./jindofs admin -getConfig -dlsUri oss://<bucket>.<oss-hdfs-endpoint>/ -name namespace.directory.quota.enable -
Specify capacity quota and quantity quota for a directory.
-
Set the quantity quota of the directory to 1,000, which means that the number of subdirectories and objects in the directory cannot exceed 1,000.
./jindofs admin -setQuota -dlsUri oss://<bucket>.<oss-hdfs-endpoint>/<path> -q 1000 -
Set the capacity quota of the directory to 1,000. Unit: bytes.
./jindofs admin -setSpaceQuota -dlsUri oss://<bucket>.<oss-hdfs-endpoint>/<path> -q 1000After you specified the capacity quota and quantity quota, you can view the specified quotas.
./jindofs fs -count -q -v -dlsUri oss://<bucket>.<oss-hdfs-endpoint>/<path>
-
-
(Optional) Delete the capacity quota and quantity quota of a directory
If your business requirements change or the storage capacity of a directory exceeds your initial plan, you can delete the capacity quota and quantity quota of a directory.
-
Delete the quantity quota of a directory.
./jindofs admin -clearQuota -dlsUri oss://<bucket>.<oss-hdfs-endpoint>/<path> -
Delete the capacity quota of a directory.
./jindofs admin -clearSpaceQuota -dlsUri oss://<bucket>.<oss-hdfs-endpoint>/<path>
-