diff --git a/plugins/command-manager/src/main/java/com/wazuh/commandmanager/http/client/AsyncRequestRepository.java b/plugins/command-manager/src/main/java/com/wazuh/commandmanager/http/client/AsyncRequestRepository.java index 61430ff..4aa5256 100644 --- a/plugins/command-manager/src/main/java/com/wazuh/commandmanager/http/client/AsyncRequestRepository.java +++ b/plugins/command-manager/src/main/java/com/wazuh/commandmanager/http/client/AsyncRequestRepository.java @@ -40,7 +40,6 @@ import org.apache.logging.log4j.Logger; import java.io.Closeable; -import java.io.IOException; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; diff --git a/plugins/command-manager/src/main/java/com/wazuh/commandmanager/scheduler/JobScheduler.java b/plugins/command-manager/src/main/java/com/wazuh/commandmanager/scheduler/JobScheduler.java index 28860af..6e81c4b 100644 --- a/plugins/command-manager/src/main/java/com/wazuh/commandmanager/scheduler/JobScheduler.java +++ b/plugins/command-manager/src/main/java/com/wazuh/commandmanager/scheduler/JobScheduler.java @@ -5,6 +5,9 @@ import org.apache.hc.client5.http.async.methods.SimpleHttpResponse; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.opensearch.common.lifecycle.Lifecycle; +import org.opensearch.common.lifecycle.LifecycleComponent; +import org.opensearch.common.lifecycle.LifecycleListener; import org.opensearch.threadpool.ThreadPool; @@ -13,7 +16,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; -public class JobScheduler { +public class JobScheduler implements LifecycleComponent { private static final Logger logger = LogManager.getLogger(JobScheduler.class); private final ConfigReader configReader; @@ -27,8 +30,8 @@ private void start(ThreadPool threadPool) { ExecutorService executorService = threadPool.executor(ThreadPool.Names.GENERIC); Future future = AccessController.doPrivileged( (PrivilegedAction>) () -> { - try { - return new AsyncRequestRepository(configReader).performAsyncRequest(); + try (AsyncRequestRepository asyncRequestRepository = new AsyncRequestRepository(configReader)){ + return asyncRequestRepository.performAsyncRequest(); } catch (Exception e) { throw new RuntimeException(e); } @@ -53,4 +56,34 @@ private void start(ThreadPool threadPool) { } ); } + + @Override + public Lifecycle.State lifecycleState() { + return null; + } + + @Override + public void addLifecycleListener(LifecycleListener lifecycleListener) { + + } + + @Override + public void removeLifecycleListener(LifecycleListener lifecycleListener) { + + } + + @Override + public void start() { + + } + + @Override + public void stop() { + + } + + @Override + public void close() { + + } }