From 1547393eb56828431fc0214e416d616722b9b5c1 Mon Sep 17 00:00:00 2001 From: Riya Saxena Date: Mon, 10 Jun 2024 14:10:46 -0700 Subject: [PATCH] address the design changes discussed Signed-off-by: Riya Saxena --- .../securityanalytics/correlation/JoinEngine.java | 1 - .../correlation/alert/CorrelationRuleScheduler.java | 10 +--------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/main/java/org/opensearch/securityanalytics/correlation/JoinEngine.java b/src/main/java/org/opensearch/securityanalytics/correlation/JoinEngine.java index 03d4a0b73..20cff273a 100644 --- a/src/main/java/org/opensearch/securityanalytics/correlation/JoinEngine.java +++ b/src/main/java/org/opensearch/securityanalytics/correlation/JoinEngine.java @@ -560,7 +560,6 @@ private void getCorrelatedFindings(String detectorType, Map if (!correlatedFindings.isEmpty()) { CorrelationRuleScheduler correlationRuleScheduler = new CorrelationRuleScheduler(client, correlationAlertService, notificationService); correlationRuleScheduler.schedule(correlationRules, correlatedFindings, request.getFinding().getId(), indexTimeout, user); - correlationRuleScheduler.shutdown(); } for (Map.Entry> autoCorrelation: autoCorrelations.entrySet()) { diff --git a/src/main/java/org/opensearch/securityanalytics/correlation/alert/CorrelationRuleScheduler.java b/src/main/java/org/opensearch/securityanalytics/correlation/alert/CorrelationRuleScheduler.java index 945407b15..ba42e252b 100644 --- a/src/main/java/org/opensearch/securityanalytics/correlation/alert/CorrelationRuleScheduler.java +++ b/src/main/java/org/opensearch/securityanalytics/correlation/alert/CorrelationRuleScheduler.java @@ -22,8 +22,6 @@ import java.util.List; import java.util.ArrayList; import java.util.Map; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; public class CorrelationRuleScheduler { @@ -31,13 +29,11 @@ public class CorrelationRuleScheduler { private final Client client; private final CorrelationAlertService correlationAlertService; private final NotificationService notificationService; - private final ExecutorService executorService; public CorrelationRuleScheduler(Client client, CorrelationAlertService correlationAlertService, NotificationService notificationService) { this.client = client; this.correlationAlertService = correlationAlertService; this.notificationService = notificationService; - this.executorService = Executors.newCachedThreadPool(); } public void schedule(List correlationRules, Map> correlatedFindings, String sourceFinding, TimeValue indexTimeout, User user) { @@ -56,15 +52,11 @@ public void schedule(List correlationRules, Map findingIds, TimeValue indexTimeout, String sourceFindingId, User user) { long startTime = Instant.now().toEpochMilli(); long endTime = startTime + correlationRule.getCorrTimeWindow(); RuleTask ruleTask = new RuleTask(correlationRule, findingIds, startTime, endTime, correlationAlertService, notificationService, indexTimeout, sourceFindingId, user); - executorService.submit(ruleTask); + ruleTask.run(); } private class RuleTask implements Runnable {