API calls from within Plugin

Hi all,

we want to write a Plugin that needs to be able to perform certain operations, that wouldn't be a problem over the API. But I have the feeling, that it is not a good idea, to do a REST call from within a Plugin, and that there should be a better way to access certain functionality?

  • check, if the local node is the current Master
  • close an index
    Ideally also:
  • check, how long an Index is open
  • get the Index that is open for the longest time

Are there components that I could inject into the Plugin to perform these operations and get this information ?

Thanks !


the ClusterService and the Client handed over in Plugin.createComponents will help you.

ClusterService.localNode().isMasterNode(). The cluster service also allows you to access the cluster state to get all the index metadata. Not sure if open is something you can check for, but the creation date might help.

Cool! Thanks a lot! I will look into this !

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.