Skip to content

Commit

Permalink
Adding max proc limits fix from this commit https://github.com/NASA-A…
Browse files Browse the repository at this point in the history
  • Loading branch information
zef committed Jan 28, 2025
1 parent 8b150aa commit 4f43ef0
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,20 @@ public List<Map<String,Object>> claimWithCounter(String limitToProcDefKey) {

int queryLimit = Math.min(MaxNumForProcsOnWorker, workerMaxProcQueryLimit);

// Adjust queryLimitForProcSet to ensure total claimed won't exceed workerMaxProcQueryLimit
int totalPossibleClaims = 0;
for (Integer limit : queryLimitForProcSet.values()) {
totalPossibleClaims += limit;
}
if (totalPossibleClaims > queryLimit) {
// Scale down individual limits proportionally
double scaleFactor = (double)queryLimit / totalPossibleClaims;
for (Map.Entry<String,Integer> entry : queryLimitForProcSet.entrySet()) {
int newLimit = Math.max(1, (int)(entry.getValue() * scaleFactor));
queryLimitForProcSet.put(entry.getKey(), Math.min(newLimit, queryLimit));
}
}

Map<String,List<String>> claimRowData =
schedulerDbService.claimHighestPriorityStartReq(
workerId, currentCounts, queryLimitForProcSet, queryLimit); // pass list of procDefkey and a map of queryLimit per procDefKey
Expand Down Expand Up @@ -1073,4 +1087,4 @@ public void bringWorkerDown() {
public String getWorkerId() {
return workerId;
}
}
}

0 comments on commit 4f43ef0

Please sign in to comment.