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.
public class MyService extends AbstractLifeCycleComponent { @Inject
public MyService(Settings settings, Node node) {
super(settings);
String name = node.settings().get("name");
...
}
and for node IDs
public class MyService extends AbstractLifeCycleComponent { @Inject
public MyService(Settings settings, ClusterService clusterService) {
super(settings);
String nodeId = clusterService.localNode().getId();
...
}
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.
Interesting. I was trying
((ClusterStateResponse)state).getState().nodes().localNode(), but this
didn't work.
On Friday, March 6, 2015 at 1:37:10 AM UTC-8, Jörg Prante wrote:
Use something like this for node name
public class MyService extends AbstractLifeCycleComponent { @Inject
public MyService(Settings settings, Node node) {
super(settings);
String name = node.settings().get("name");
...
}
and for node IDs
public class MyService extends AbstractLifeCycleComponent { @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 <jbar...@gmail.com <javascript:>>
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.
Interesting. I was trying
((ClusterStateResponse)state).getState().nodes().localNode(), but this
didn't work.
On Friday, March 6, 2015 at 1:37:10 AM UTC-8, Jörg Prante wrote:
Use something like this for node name
public class MyService extends AbstractLifeCycleComponent { @Inject
public MyService(Settings settings, Node node) {
super(settings);
String name = node.settings().get("name");
...
}
and for node IDs
public class MyService extends AbstractLifeCycleComponent { @Inject
public MyService(Settings settings, ClusterService clusterService) {
super(settings);
String nodeId = clusterService.localNode().getId();
...
}
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.
Yes. I did that [ clusterStateRequest.clear().nodes(true).routingTable(true) ], but I still
wasn't able to get the localNodeId. It seems like the localNodeId is not
set while the node is recovering.
On Friday, March 6, 2015 at 9:40:59 AM UTC-8, Jörg Prante wrote:
In ClusterStateRequest, you have to set clusterStateRequest.nodes(true) to
get nodes returned.
Jörg
On Fri, Mar 6, 2015 at 5:44 PM, Kadaan <jbar...@gmail.com <javascript:>>
wrote:
Interesting. I was trying
((ClusterStateResponse)state).getState().nodes().localNode(), but this
didn't work.
On Friday, March 6, 2015 at 1:37:10 AM UTC-8, Jörg Prante wrote:
Use something like this for node name
public class MyService extends AbstractLifeCycleComponent { @Inject
public MyService(Settings settings, Node node) {
super(settings);
String name = node.settings().get("name");
...
}
and for node IDs
public class MyService extends AbstractLifeCycleComponent { @Inject
public MyService(Settings settings, ClusterService clusterService) {
super(settings);
String nodeId = clusterService.localNode().getId();
...
}
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.
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.