Skip to content

Commit

Permalink
Add more getters
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Widdis <[email protected]>
  • Loading branch information
dbwiddis committed Feb 21, 2023
1 parent b1f03c0 commit afefeae
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/main/java/org/opensearch/sdk/ExtensionsRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ public class ExtensionsRunner {
private final TaskManager taskManager;

private final SDKNamedXContentRegistry sdkNamedXContentRegistry;
private final SDKClient sdkClient = new SDKClient();
private final SDKClusterService sdkClusterService = new SDKClusterService(this);

private ExtensionsInitRequestHandler extensionsInitRequestHandler = new ExtensionsInitRequestHandler(this);
private ExtensionsIndicesModuleRequestHandler extensionsIndicesModuleRequestHandler = new ExtensionsIndicesModuleRequestHandler();
private ExtensionsIndicesModuleNameRequestHandler extensionsIndicesModuleNameRequestHandler =
Expand Down Expand Up @@ -174,10 +177,10 @@ protected ExtensionsRunner(Extension extension) throws IOException {

b.bind(SDKNamedXContentRegistry.class).toInstance(getNamedXContentRegistry());
b.bind(ThreadPool.class).toInstance(getThreadPool());
b.bind(TaskManager.class).toInstance(taskManager);
b.bind(TaskManager.class).toInstance(getTaskManager());

b.bind(SDKClient.class);
b.bind(SDKClusterService.class).toInstance(new SDKClusterService(this));
b.bind(SDKClient.class).toInstance(getSdkClient());
b.bind(SDKClusterService.class).toInstance(getSdkClusterService());
});
// Bind the return values from create components
modules.add(this::injectComponents);
Expand Down Expand Up @@ -568,6 +571,18 @@ public ThreadPool getThreadPool() {
return threadPool;
}

public TaskManager getTaskManager() {
return taskManager;
}

public SDKClient getSdkClient() {
return sdkClient;
}

public SDKClusterService getSdkClusterService() {
return sdkClusterService;
}

public TransportService getExtensionTransportService() {
return extensionTransportService;
}
Expand Down
4 changes: 4 additions & 0 deletions src/test/java/org/opensearch/sdk/TestExtensionsRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.opensearch.sdk.handlers.EnvironmentSettingsResponseHandler;
import org.opensearch.sdk.handlers.ExtensionsInitRequestHandler;
import org.opensearch.sdk.handlers.ExtensionsRestRequestHandler;
import org.opensearch.tasks.TaskManager;
import org.opensearch.sdk.handlers.AcknowledgedResponseHandler;
import org.opensearch.test.OpenSearchTestCase;
import org.opensearch.threadpool.ThreadPool;
Expand Down Expand Up @@ -225,6 +226,9 @@ public void testGettersAndSetters() throws IOException {
assertTrue(extensionsRunner.getExtension() instanceof BaseExtension);
assertEquals(extensionsRunner, ((BaseExtension) extensionsRunner.getExtension()).extensionsRunner());
assertTrue(extensionsRunner.getThreadPool() instanceof ThreadPool);
assertTrue(extensionsRunner.getTaskManager() instanceof TaskManager);
assertTrue(extensionsRunner.getSdkClient() instanceof SDKClient);
assertTrue(extensionsRunner.getSdkClusterService() instanceof SDKClusterService);

settings = extensionsRunner.getSettings();
assertEquals(ExtensionsRunnerForTest.NODE_NAME, settings.get(ExtensionsRunner.NODE_NAME_SETTING));
Expand Down

0 comments on commit afefeae

Please sign in to comment.