Skip to content

Commit 75c8e27

Browse files
committed
[backend] fix: changed lock system for inject status update from implants
1 parent 307c035 commit 75c8e27

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

openbas-api/src/main/java/io/openbas/rest/inject/service/InjectStatusService.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private int getCompleteTrace(Inject inject) {
8383
public boolean isAllInjectAgentsExecuted(Inject inject) {
8484
int totalCompleteTrace = getCompleteTrace(inject);
8585
List<Agent> agents = this.injectService.getAgentsByInject(inject);
86-
log.info(
86+
log.debug(
8787
"[issue/2797] Inputs for inject ID: "
8888
+ inject.getId()
8989
+ "::agents.size="
@@ -94,13 +94,13 @@ public boolean isAllInjectAgentsExecuted(Inject inject) {
9494
}
9595

9696
public void updateFinalInjectStatus(InjectStatus injectStatus) {
97-
log.info("[issue/2797] updateFinalInjectStatus 1: " + injectStatus.getId());
97+
log.debug("[issue/2797] updateFinalInjectStatus 1: " + injectStatus.getId());
9898
ExecutionStatus finalStatus =
9999
computeStatus(
100100
injectStatus.getTraces().stream()
101101
.filter(t -> ExecutionTraceAction.COMPLETE.equals(t.getAction()))
102102
.toList());
103-
log.info("[issue/2797] updateFinalInjectStatus 2: " + injectStatus.getId());
103+
log.debug("[issue/2797] updateFinalInjectStatus 2: " + injectStatus.getId());
104104
injectStatus.setTrackingEndDate(Instant.now());
105105
injectStatus.setName(finalStatus);
106106
injectStatus.getInject().setUpdatedAt(Instant.now());
@@ -165,7 +165,7 @@ private void computeExecutionTraceStatusIfNeeded(
165165

166166
@Scheduled(fixedDelay = 60000) // Run every 1 minutes
167167
public void cleanupOldLocks() {
168-
log.info("[issue/2797] Clean up of old locks started");
168+
log.debug("[issue/2797] Clean up of old locks started");
169169
long currentTime = System.currentTimeMillis();
170170
int removedCount = 0;
171171

@@ -180,9 +180,7 @@ public void cleanupOldLocks() {
180180
}
181181
}
182182

183-
if (removedCount > 0) {
184-
log.info("[issue/2797] Cleaned up {} old locks", removedCount);
185-
}
183+
log.debug("[issue/2797] Cleaned up {} old locks", removedCount);
186184
}
187185

188186
// [issue/2797] region end: Added an alternative locking mechanism
@@ -201,11 +199,11 @@ public void updateInjectStatus(
201199
// Update last access time
202200
lastAccessTime.put(inject.getId(), System.currentTimeMillis());
203201

204-
log.info("[issue/2797] Waiting for lock for inject ID: " + inject.getId());
202+
log.debug("[issue/2797] Waiting for lock for inject ID: " + inject.getId());
205203
synchronized (lock) {
206204
boolean isAllInjectAgentsExecuted = isAllInjectAgentsExecuted(inject);
207-
log.info("[issue/2797] Acquired lock for inject ID: " + inject.getId());
208-
log.info(
205+
log.debug("[issue/2797] Acquired lock for inject ID: " + inject.getId());
206+
log.debug(
209207
"[issue/2797] Inputs for inject ID: "
210208
+ inject.getId()
211209
+ "::action="
@@ -218,7 +216,7 @@ public void updateInjectStatus(
218216
}
219217

220218
injectRepository.save(inject);
221-
log.info("Successfully updated inject: " + inject.getId());
219+
log.debug("Successfully updated inject: " + inject.getId());
222220
}
223221
}
224222

0 commit comments

Comments
 (0)