Use something like this for node name

public class MyService extends AbstractLifeCycleComponent<MyService> {
@Inject
public MyService(Settings settings, Node node) {
   super(settings);
   String name = node.settings().get("name");
   ...
}

and for node IDs

public class MyService extends AbstractLifeCycleComponent<MyService> {
@Inject
public MyService(Settings settings, ClusterService clusterService) {
   super(settings);
   String nodeId = clusterService.localNode().getId();
   ...
}

Jörg

On Fri, Mar 6, 2015 at 5:10 AM, Kadaan <jbaran...@gmail.com> wrote:

> What do the proper way to get the localnode (and it's id) in a plugin? I
> have tried many ways and it always seems to be null.  The node just started
> and is loading the data from disk.  Because of my inability to get
> localNodeId, I have had to fall back to using node.name for my lookups,
> but this seems more error prone.
>
> --
> You received this message because you are subscribed to the Google Groups
> "elasticsearch" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elasticsearch+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/116cd053-a26e-480f-b7ca-367a6af4236f%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/CAKdsXoF49xdMZ5LpQCgWD69OxYXstFiyNVs-_da05hu2JFyikA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to