diff --git a/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/engine/quota/limit/RunningJobResourceQuotaManager.java b/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/engine/quota/limit/RunningJobResourceQuotaManager.java index cb4d8e67ef..da751d0d58 100644 --- a/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/engine/quota/limit/RunningJobResourceQuotaManager.java +++ b/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/engine/quota/limit/RunningJobResourceQuotaManager.java @@ -81,6 +81,7 @@ public RunningJobResourceQuotaManager(StringRedisTemplate redisTemplate, } public void addJob(String appCode, ResourceScope resourceScope, long jobInstanceId) { + long startTime = System.currentTimeMillis(); String resourceScopeZSetKey = buildResourceScopeRunningJobZSetKey(resourceScope); long currentTimestamp = System.currentTimeMillis(); redisTemplate.opsForZSet().add(resourceScopeZSetKey, String.valueOf(jobInstanceId), currentTimestamp); @@ -88,15 +89,24 @@ public void addJob(String appCode, ResourceScope resourceScope, long jobInstance String appZSetKey = buildAppRunningJobZSetKey(appCode); redisTemplate.opsForZSet().add(appZSetKey, String.valueOf(jobInstanceId), currentTimestamp); } + long cost = System.currentTimeMillis() - startTime; + if (log.isDebugEnabled()) { + log.debug("Add job to RunningJobResourceQuotaCache cost : {} ms", cost); + } } public void removeJob(String appCode, ResourceScope resourceScope, long jobInstanceId) { + long startTime = System.currentTimeMillis(); String resourceScopeZSetKey = buildResourceScopeRunningJobZSetKey(resourceScope); redisTemplate.opsForZSet().remove(resourceScopeZSetKey, String.valueOf(jobInstanceId)); if (StringUtils.isNotEmpty(appCode)) { String appZSetKey = buildAppRunningJobZSetKey(appCode); redisTemplate.opsForZSet().remove(appZSetKey, String.valueOf(jobInstanceId)); } + long cost = System.currentTimeMillis() - startTime; + if (log.isDebugEnabled()) { + log.debug("Remove job from RunningJobResourceQuotaCache cost : {} ms", cost); + } } /** @@ -113,8 +123,8 @@ public ResourceQuotaCheckResultEnum checkResourceQuotaLimit(String appCode, Reso boolean isJobFrom3rdApp = StringUtils.isNotEmpty(appCode); List keyList = new ArrayList<>(); - keyList.add("job:execute:running:job:resource:scope:" + resourceScope.getResourceScopeUniqueId()); - keyList.add(isJobFrom3rdApp ? "job:execute:running:job:app:" + appCode : "None"); + keyList.add(buildResourceScopeRunningJobZSetKey(resourceScope)); + keyList.add(isJobFrom3rdApp ? buildAppRunningJobZSetKey(appCode) : "None"); long resourceScopeLimit = runningJobResourceQuotaStore.getQuotaLimitByResourceScope(resourceScope);