I am currently working on developing a schedule plugin for Elasticsearch. The objective is to display only the index number every 5 minutes. However, I am encountering an issue where the NodeClient is consistently null.
I would greatly appreciate any suggestions or guidance from the community on how to address this NodeClient null issue and any insights on improving the schedule plugin.
When Elasticsearch loads the plugin, the createComponents method is not being invoked, resulting in a null client. The objective is to ensure that the createComponents method is executed during plugin initialization, allowing access to a non-null client.
public class ConnectorPlugin extends Plugin implements ActionPlugin {
private static final Properties properties = new Properties();
private boolean componentsCreated = false;
private Client client;
public ConnectorPlugin() throws IOException {
Properties connectorProperties = new Properties();
Properties pluginDescriptorProperties = new Properties();
InputStream connectorStream = this.getClass().getResourceAsStream("/connector.properties");
InputStream pluginDescriptorStream = this.getClass().getResourceAsStream("/plugin-descriptor.properties");
connectorProperties.load(connectorStream);
pluginDescriptorProperties.load(pluginDescriptorStream);
properties.putAll(connectorProperties);
properties.putAll(pluginDescriptorProperties);
}
@Override
public Collection<Object> createComponents(
Client client,
ClusterService clusterService,
ThreadPool threadPool,
ResourceWatcherService resourceWatcherService,
ScriptService scriptService,
NamedXContentRegistry xContentRegistry,
Environment environment,
NodeEnvironment nodeEnvironment,
NamedWriteableRegistry namedWriteableRegistry,
IndexNameExpressionResolver indexNameExpressionResolver,
Supplier<RepositoriesService> repositoriesServiceSupplier
){
this.client=client;
System.out.println("Client is properly initialized");
List<Object> components = new ArrayList<>();
return components;
}
}
Looks ok to me. I don't think it's possible for Elasticsearch to create a plugin and not call createComponents later on, so I think it must be that Elasticsearch isn't creating the instance of ConnectorPlugin either.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.