mohan3d commented on code in PR #4226:
URL: https://github.com/apache/ozone/pull/4226#discussion_r1094386714
##########
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneFileSystem.java:
##########
@@ -1010,6 +1013,24 @@ listingPageSize, uri, workingDir, getUsername())
return statusList;
}
+ @Override
+ public FsStatus getStatus(Path p) throws IOException {
+ BasicOzoneClientAdapterImpl adapterImpl =
+ (BasicOzoneClientAdapterImpl) adapter;
+ OzoneBucket bucket = adapterImpl.getBucket();
+ long usedBytes = bucket.getUsedBytes();
+ long quota = Long.MAX_VALUE;
+ if (bucket.getQuotaInBytes() > -1) {
+ quota = bucket.getQuotaInBytes();
+ } else {
+ OzoneVolume volume = adapterImpl.getVolume();
+ if (volume.getQuotaInBytes() > -1) {
+ quota = volume.getQuotaInBytes();
Review Comment:
Thanks @sadanand48 for responding.
> although I don't think that there is an api for this in OM ( to get
available size for a bucket.)
If you mean the given quota it can be obtained from OzoneBucket object
(bucket.getQuotaInBytes())
or usedBytes also can be obtained in the same way (bucket.getUsedBytes())
Regarding your comment on the way to calculate if there is no quota set. I
think this is true if there is no quota set in any bucket in the volume if I
understand well.
Let me summarize all cases we might have:
1. volume and buckets which all of them have quota set
2. volume and buckets (volume has quota, all buckets have no quota)
3. volume and buckets (volume has quota, mixed buckets some of them have
quota and the rest no quota)
> volume and buckets which all of them have quota set
This one is straightforward volume quota = sum (bucket.quota for each bucket
in the volume). hence the calculations are like this;
FsStatus={capacity=bucket.getQuotaInBytes, used=bucket.getUsedBytes(),
remaining=capacity-used}
> volume and buckets (volume has quota, all buckets have no quota)
Since there is no quota on any bucket the calculations can be like this;
FsStatus={capacity=volume.getQuotaInBytes, used=<calculate total bytes used in
all volume's buckets> remaining=capacity-used}
Not sure about the way to calculate it. Maybe there is a need to implement
an API in OM for it or simple solution like mentioned earlier.
```java
Iterator<? extends OzoneBucket> it = vol.listBuckets(null);
long volUsedBytes = 0L;
while (bucketIterator.hasNext()) {
volUsedBytes += bucketIterator.next().getUsedBytes();
}
```
> volume and buckets (volume has quota, mixed buckets some of them have
quota and the rest no quota)
Last one with mixed buckets is a little bit complicated, for example
/vol1 (quota=5GB)
/vol1/buck1 (quota=3GB, usedBytes=2GB)
/vol1/buck2 (quota=-1, usedBytes=1GB)
df /vol1/buck1 (should return 1GB as the quota given to the bucket is 3GB).
Another example:
/vol1 (quota=5GB)
/vol1/buck1 (quota=3GB, usedBytes=2GB)
/vol1/buck2 (quota=-1, usedBytes=2.5GB)
df /vol1/buck1 (should return 0.5GB which is the min of (available quota of
the volume and quota-used bytes of the bucket) = min(5GB - 2.5GB, 3GB-2GB) =
min(0.5GB, 1GB) = 0.5GB
df a bucket with no quota set should follow the earlier calculations (min of
(available quota of the volume and quota-used bytes of the bucket))
**Keep in mind these 2 and 3 cases will only happen in earlier version of
Ozone**. should we drop this and keep the calculations simplified? should we
care for earlier versions (where you can create a bucket without quota when
volume has quota)?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]