captainzmc commented on a change in pull request #1647:
URL: https://github.com/apache/ozone/pull/1647#discussion_r539921885
##########
File path:
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -228,23 +209,13 @@ public static OzoneQuota parseQuota(String quotaInBytes,
*/
public static OzoneQuota getOzoneQuota(long quotaInBytes,
long quotaInCounts) {
- long size;
- Units unit;
- if (quotaInBytes % TB == 0) {
- size = quotaInBytes / TB;
- unit = Units.TB;
- } else if (quotaInBytes % GB == 0) {
- size = quotaInBytes / GB;
- unit = Units.GB;
- } else if (quotaInBytes % MB == 0) {
- size = quotaInBytes / MB;
- unit = Units.MB;
- } else if (quotaInBytes % KB == 0) {
- size = quotaInBytes / KB;
- unit = Units.KB;
- } else {
- size = quotaInBytes;
- unit = Units.BYTES;
+ long size = 1L;
+ Units unit = Units.BYTES;
+ for (Long quota:quotaList.getSizeQuotaArray()){
+ if(quotaInBytes % quota == 0){
Review comment:
```suggestion
if (quotaInBytes % quota == 0) {
```
##########
File path:
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -72,24 +84,17 @@ public long getSize() {
}
/**
- * Returns size in Bytes or -1 if there is no Quota.
+ * Returns size in Bytes or negative num if there is no Quota.
*/
public long sizeInBytes() {
- switch (this.unit) {
- case BYTES:
- return this.getSize();
- case KB:
- return this.getSize() * KB;
- case MB:
- return this.getSize() * MB;
- case GB:
- return this.getSize() * GB;
- case TB:
- return this.getSize() * TB;
- case UNDEFINED:
- default:
- return -1;
+ long sQuota = -1L;
+ for(Units quota : quotaList.getUnitQuotaArray()){
+ if(quota == this.unit){
Review comment:
```suggestion
if (quota == this.unit) {
```
##########
File path:
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -164,45 +169,21 @@ public static OzoneQuota parseQuota(String quotaInBytes,
long quotaMultiplyExact = 0;
try {
- if (uppercase.endsWith(OZONE_QUOTA_KB)) {
- size = uppercase
- .substring(0, uppercase.length() - OZONE_QUOTA_KB.length());
- currUnit = Units.KB;
- quotaMultiplyExact = Math.multiplyExact(Long.parseLong(size), KB);
- }
-
- if (uppercase.endsWith(OZONE_QUOTA_MB)) {
- size = uppercase
- .substring(0, uppercase.length() - OZONE_QUOTA_MB.length());
- currUnit = Units.MB;
- quotaMultiplyExact = Math.multiplyExact(Long.parseLong(size), MB);
- }
-
- if (uppercase.endsWith(OZONE_QUOTA_GB)) {
- size = uppercase
- .substring(0, uppercase.length() - OZONE_QUOTA_GB.length());
- currUnit = Units.GB;
- quotaMultiplyExact = Math.multiplyExact(Long.parseLong(size), GB);
- }
-
- if (uppercase.endsWith(OZONE_QUOTA_TB)) {
- size = uppercase
- .substring(0, uppercase.length() - OZONE_QUOTA_TB.length());
- currUnit = Units.TB;
- quotaMultiplyExact = Math.multiplyExact(Long.parseLong(size), TB);
- }
-
- if (uppercase.endsWith(OZONE_QUOTA_BYTES)) {
- size = uppercase
- .substring(0, uppercase.length() - OZONE_QUOTA_BYTES.length());
- currUnit = Units.BYTES;
- quotaMultiplyExact = Math.multiplyExact(Long.parseLong(size), 1L);
+ for(String quota : quotaList.getOzoneQuotaArray()){
+ if (uppercase.endsWith((quota))){
Review comment:
```suggestion
if (uppercase.endsWith((quota))) {
```
##########
File path:
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -164,45 +169,21 @@ public static OzoneQuota parseQuota(String quotaInBytes,
long quotaMultiplyExact = 0;
try {
- if (uppercase.endsWith(OZONE_QUOTA_KB)) {
- size = uppercase
- .substring(0, uppercase.length() - OZONE_QUOTA_KB.length());
- currUnit = Units.KB;
- quotaMultiplyExact = Math.multiplyExact(Long.parseLong(size), KB);
- }
-
- if (uppercase.endsWith(OZONE_QUOTA_MB)) {
- size = uppercase
- .substring(0, uppercase.length() - OZONE_QUOTA_MB.length());
- currUnit = Units.MB;
- quotaMultiplyExact = Math.multiplyExact(Long.parseLong(size), MB);
- }
-
- if (uppercase.endsWith(OZONE_QUOTA_GB)) {
- size = uppercase
- .substring(0, uppercase.length() - OZONE_QUOTA_GB.length());
- currUnit = Units.GB;
- quotaMultiplyExact = Math.multiplyExact(Long.parseLong(size), GB);
- }
-
- if (uppercase.endsWith(OZONE_QUOTA_TB)) {
- size = uppercase
- .substring(0, uppercase.length() - OZONE_QUOTA_TB.length());
- currUnit = Units.TB;
- quotaMultiplyExact = Math.multiplyExact(Long.parseLong(size), TB);
- }
-
- if (uppercase.endsWith(OZONE_QUOTA_BYTES)) {
- size = uppercase
- .substring(0, uppercase.length() - OZONE_QUOTA_BYTES.length());
- currUnit = Units.BYTES;
- quotaMultiplyExact = Math.multiplyExact(Long.parseLong(size), 1L);
+ for(String quota : quotaList.getOzoneQuotaArray()){
Review comment:
```suggestion
for (String quota : quotaList.getOzoneQuotaArray()) {
```
##########
File path:
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -72,24 +84,17 @@ public long getSize() {
}
/**
- * Returns size in Bytes or -1 if there is no Quota.
+ * Returns size in Bytes or negative num if there is no Quota.
*/
public long sizeInBytes() {
- switch (this.unit) {
- case BYTES:
- return this.getSize();
- case KB:
- return this.getSize() * KB;
- case MB:
- return this.getSize() * MB;
- case GB:
- return this.getSize() * GB;
- case TB:
- return this.getSize() * TB;
- case UNDEFINED:
- default:
- return -1;
+ long sQuota = -1L;
+ for(Units quota : quotaList.getUnitQuotaArray()){
Review comment:
```suggestion
for (Units quota : quotaList.getUnitQuotaArray()) {
```
##########
File path:
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -227,24 +210,15 @@ public static OzoneQuota parseQuota(String quotaInBytes,
* @return OzoneQuota object
*/
public static OzoneQuota getOzoneQuota(long quotaInBytes,
- long quotaInCounts) {
- long size;
- Units unit;
- if (quotaInBytes % TB == 0) {
- size = quotaInBytes / TB;
- unit = Units.TB;
- } else if (quotaInBytes % GB == 0) {
- size = quotaInBytes / GB;
- unit = Units.GB;
- } else if (quotaInBytes % MB == 0) {
- size = quotaInBytes / MB;
- unit = Units.MB;
- } else if (quotaInBytes % KB == 0) {
- size = quotaInBytes / KB;
- unit = Units.KB;
- } else {
- size = quotaInBytes;
- unit = Units.BYTES;
+ long quotaInCounts) {
+ long size = 1L;
+ Units unit = Units.BYTES;
+ setQuotaList();
+ for (Long quota:quotaList.getSizeQuotaArray()){
Review comment:
```suggestion
for (Long quota : quotaList.getSizeQuotaArray()) {
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]