Skip to content

Commit

Permalink
DAR-CORE-CWS: Observed multiple jobs running on worker configured to …
Browse files Browse the repository at this point in the history
…run at most 1.
  • Loading branch information
jdrodjpl committed Jan 14, 2025
1 parent b17d422 commit 01c20de
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cws-engine-service/src/main/java/jpl/cws/engine/WorkerService.java
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

0 comments on commit 01c20de

Please sign in to comment.