Skip to content

Commit

Permalink
[MINOR][0.7] Avoid returning null in defaultUserApps when quota file …
Browse files Browse the repository at this point in the history
…does't config user (apache#822)

### What changes were proposed in this pull request?
`map.getOrDefault()` => `map.computeIfAbsent()`


### Why are the changes needed?
If do not define the user and app num  in the quota configuration file, it will appear that the `defaultUserApps` does not have the corresponding app number for this user, because we did not include the `quotaAppNum` in the `defaultUserApps`. 

**before** :
The log from coordinator is `[ERROR] 2023-03-28 19:24:11,18 Grpc-260 AccessAppQuotaChecker check - Denied by AccessAppQuotaChecker => User: xxxx, current app num is: 3, default app num is: null.`

**after** :
The log from coordinator is `[ERROR] 2023-03-31 14:32:21,228 Grpc-240 AccessAppQuotaChecker check - Denied by AccessAppQuotaChecker => User: xxxx, current app num is: 3, default app num is: 3.`


### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
Origin uts.
  • Loading branch information
smallzhongfeng authored Apr 14, 2023
1 parent bcb591e commit 71a9c7a
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void parseQuotaFile(DataInputStream fsDataInputStream) {

public boolean checkQuota(String user, String uuid) {
Map<String, Long> appAndTimes = currentUserAndApp.computeIfAbsent(user, x -> Maps.newConcurrentMap());
Integer defaultAppNum = defaultUserApps.getOrDefault(user, quotaAppNum);
Integer defaultAppNum = defaultUserApps.computeIfAbsent(user, x -> quotaAppNum);
synchronized (this) {
int currentAppNum = appAndTimes.size();
if (currentAppNum >= defaultAppNum) {
Expand Down

0 comments on commit 71a9c7a

Please sign in to comment.