Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Allow specifying custom client implementation during bootstrap #16748

Open
5 tasks
arjunkumargiri opened this issue Nov 29, 2024 · 3 comments
Open
5 tasks
Labels
enhancement Enhancement or improvement to existing feature or request Other untriaged

Comments

@arjunkumargiri
Copy link

Is your feature request related to a problem? Please describe

Currently, the Node.java class in OpenSearch hard-codes the use of NodeClient.

client = new NodeClient(settings, threadPool);

This limits the flexibility for OpenSearch users who may want to use custom client implementations during the bootstrap process. Though NodeClient is an implementation of Client there is no mechanism available to dynamically specify Client implementation during bootstrap. We should create a mechanism that allows users to specify their own client implementation during bootstrap.

Describe the solution you'd like

Implement a mechanism that allows users to specify a custom client implementation during the OpenSearch node bootstrap process. This could be achieved through:

  1. A new configuration option in opensearch.yml
  2. A programmatic way to set the client implementation when initializing a node.
  3. New client implementations can be provided as part of a plugin.

Related component

Other

Describe alternatives you've considered

Experimented with extending Node.java to specify client implementation. However, this approach requires changes to bootstrap logic to make use of custom node class.

Additional context

Benefits

  • Increased flexibility for OpenSearch users.
  • Ability to use custom client implementations for specific use cases.
  • Better extensibility of the OpenSearch core.

Potential Implementation

  1. Create a new interface, e.g., BootstrapClientProvider
  2. Modify Node.java to use this interface instead of directly instantiating NodeClient
  3. Provide a default implementation that uses NodeClient
  4. Add configuration options to specify a custom implementation
  5. Update relevant documentation

Acceptance Criteria

  • A mechanism to specify custom client implementation is available
  • The default behavior (using NodeClient) remains unchanged if no custom client is specified
  • Documentation is updated to reflect the new capability
  • Unit tests are added to verify the new functionality
  • Integration tests demonstrate the use of a custom client during bootstrap
@arjunkumargiri arjunkumargiri added enhancement Enhancement or improvement to existing feature or request untriaged labels Nov 29, 2024
@github-actions github-actions bot added the Other label Nov 29, 2024
@andrross
Copy link
Member

I think the Java Service Provider Interface (SPI) would be the appropriate mechanism for injecting a custom NodeClient provider. We use SPI for several other things in the codebase: https://github.com/opensearch-project/OpenSearch/tree/b5917c5c349c4c931fd278f59f5fadfbcf7f0379/server/src/main/resources/META-INF/services

@arjunkumargiri Have you looked at whether SPI would work here?

@arjunkumargiri
Copy link
Author

Agreed, SPI will provide a clean interface for plugins to implement custom Client.

To override default Client implementation used by Node.java, can the client be set as part of cluster settings?

@shwetathareja
Copy link
Member

To override default Client implementation used by Node.java, can the client be set as part of cluster settings?

When a node is bootstrapped, it is not part of the cluster yet. It has access to node level static settings which are specified in yml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement or improvement to existing feature or request Other untriaged
Projects
None yet
Development

No branches or pull requests

3 participants