Skip to content

Commit

Permalink
Add lifecycle component back to jobscheduler placeholder class
Browse files Browse the repository at this point in the history
  • Loading branch information
f-galland committed Oct 9, 2024
1 parent a38277d commit b92006e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand All @@ -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;
Expand All @@ -27,8 +30,8 @@ private void start(ThreadPool threadPool) {
ExecutorService executorService = threadPool.executor(ThreadPool.Names.GENERIC);
Future<SimpleHttpResponse> future = AccessController.doPrivileged(
(PrivilegedAction<Future<SimpleHttpResponse>>) () -> {
try {
return new AsyncRequestRepository(configReader).performAsyncRequest();
try (AsyncRequestRepository asyncRequestRepository = new AsyncRequestRepository(configReader)){
return asyncRequestRepository.performAsyncRequest();
} catch (Exception e) {
throw new RuntimeException(e);
}
Expand All @@ -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() {

}
}

0 comments on commit b92006e

Please sign in to comment.