Cannot start Node using Java API

Hi,

I'm a newbie in ES.
I was trying to start a Java client using Java API.
I used the following code:

    ImmutableSettings.Builder settings =

ImmutableSettings.settingsBuilder();
settings.put("node.client", true);
settings.put("node.data", false);
settings.put("node.name", "temp");
settings.build();
Node node =
NodeBuilder.nodeBuilder().settings(settings).node();
Client client = node.client();

But I always get the following message:

12/01/15 22:46:46 INFO elasticsearch.node: [Hussar] {0.18.6}[1081]:
initializing ...
12/01/15 22:46:46 INFO elasticsearch.plugins: [Hussar] loaded [],
sites []
12/01/15 22:46:47 INFO elasticsearch.node: [Hussar] {0.18.6}[1081]:
initialized
12/01/15 22:46:47 INFO elasticsearch.node: [Hussar] {0.18.6}[1081]:
starting ...
12/01/15 22:46:47 INFO elasticsearch.transport: [Hussar] bound_address
{inet[/0.0.0.0:9301]}, publish_address {inet[/192.168.0.15:9301]}
12/01/15 22:47:17 WARN elasticsearch.discovery: [Hussar] waited for
30s and no initial state was set by the discovery
12/01/15 22:47:17 INFO elasticsearch.discovery: [Hussar] elasticsearch/
nJrZ15f7Tk-xu7VfKPjdFQ
12/01/15 22:47:17 INFO elasticsearch.http: [Hussar] bound_address
{inet[/0.0.0.0:9201]}, publish_address {inet[/192.168.0.15:9201]}
12/01/15 22:47:17 INFO elasticsearch.node: [Hussar] {0.18.6}[1081]:
started

Then I when try to index a document, I get the following error
message:

Exception in thread "main"
org.elasticsearch.discovery.MasterNotDiscoveredException:
at
org.elasticsearch.action.support.master.TransportMasterNodeOperationAction
$3.onTimeout(TransportMasterNodeOperationAction.java:162)
at org.elasticsearch.cluster.service.InternalClusterService
$NotifyTimeout.run(InternalClusterService.java:332)
at java.util.concurrent.ThreadPoolExecutor
$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

But if use TransportClient API and try to index a document(using the
following code), everything goes smoothly.

    ImmutableSettings.Builder settings =

ImmutableSettings.settingsBuilder();
settings.put("cluster.name", "anthread");
settings.put("client.transport.sniff", true);
settings.build();
client = new TransportClient(settings);
client.addTransportAddress(new
InetSocketTransportAddress("192.168.0.15", 9300));
client.addTransportAddress(new
InetSocketTransportAddress("192.168.0.7", 9300));

And if I try to run an additional node using the following command:
"./elasticsearch -f -Des.node.data=false -Des.node.client=true"
I get the next message, which suggests that the master was found
successfully, unlike the situation above.

[2012-01-15 23:33:43,936][INFO ][node ]
[anthread01] {0.18.6}[2130]: initializing ...
[2012-01-15 23:33:43,944][INFO ][plugins ]
[anthread01] loaded [], sites []
[2012-01-15 23:33:45,370][INFO ][node ]
[anthread01] {0.18.6}[2130]: initialized
[2012-01-15 23:33:45,371][INFO ][node ]
[anthread01] {0.18.6}[2130]: starting ...
[2012-01-15 23:33:45,418][INFO ][transport ]
[anthread01] bound_address {inet[/192.168.0.15:9301]}, publish_address
{inet[/192.168.0.15:9301]}
[2012-01-15 23:33:48,527][INFO ][cluster.service ]
[anthread01] detected_master [anthread01][fegUJtU0QG60HaSDMe3wgg]
[inet[/192.168.0.15:9300]], added {[anthread01][fegUJtU0QG60HaSDMe3wgg]
[inet[/192.168.0.15:9300]],[anthread04][79-cnh1mTVu3HY_3N6mv8w][inet[/
192.168.0.4:9300]],[anthread03][uPw2gr6lRD2JHsxbvIurqw][inet[/
192.168.0.8:9300]],[anthread02][gz-aUT28QbSL6ZGlMF9J3A][inet[/
192.168.0.7:9300]],[anthread05][CH3NDGGCSzmrI-PVXtEXyg][inet[/
192.168.0.5:9300]],}, reason: zen-disco-receive(from master
[[anthread01][fegUJtU0QG60HaSDMe3wgg][inet[/192.168.0.15:9300]]])
[2012-01-15 23:33:48,540][INFO ][discovery ]
[anthread01] anthread/__eWuXJyT4iyitu186ISag
[2012-01-15 23:33:48,543][INFO ][http ]
[anthread01] bound_address {inet[/192.168.0.15:9201]}, publish_address
{inet[/192.168.0.15:9201]}
[2012-01-15 23:33:48,544][INFO ][node ]
[anthread01] {0.18.6}[2130]: started
[2012-01-15 23:33:52,709][INFO ][node ]
[anthread01] {0.18.6}[2130]: stopping ...
[2012-01-15 23:33:52,723][INFO ][node ]
[anthread01] {0.18.6}[2130]: stopped
[2012-01-15 23:33:52,723][INFO ][node ]
[anthread01] {0.18.6}[2130]: closing ...
[2012-01-15 23:33:52,732][INFO ][node ]
[anthread01] {0.18.6}[2130]: closed

Could anyone tell me what I am doing wrong?
I am assuming that when I start a node using Java API, the newly
created node cannot find the existing cluster.
But when I use TransportClient or "/bin/elasticsearch", everything
goes fine. So I must be missing something here.
My firewalls are all turned off, of course.
I am really out of clue here.

Ed

You don't seem to set the cluster name when you construct the node client?

On Sun, Jan 15, 2012 at 4:56 PM, mp2893 mp2893@gmail.com wrote:

Hi,

I'm a newbie in ES.
I was trying to start a Java client using Java API.
I used the following code:


   ImmutableSettings.Builder settings =

ImmutableSettings.settingsBuilder();
settings.put("node.client", true);
settings.put("node.data", false);
settings.put("node.name", "temp");
settings.build();
Node node =
NodeBuilder.nodeBuilder().settings(settings).node();
Client client = node.client();


But I always get the following message:


12/01/15 22:46:46 INFO elasticsearch.node: [Hussar] {0.18.6}[1081]:
initializing ...
12/01/15 22:46:46 INFO elasticsearch.plugins: [Hussar] loaded ,
sites
12/01/15 22:46:47 INFO elasticsearch.node: [Hussar] {0.18.6}[1081]:
initialized
12/01/15 22:46:47 INFO elasticsearch.node: [Hussar] {0.18.6}[1081]:
starting ...
12/01/15 22:46:47 INFO elasticsearch.transport: [Hussar] bound_address
{inet[/0.0.0.0:9301]}, publish_address {inet[/192.168.0.15:9301]}
12/01/15 22:47:17 WARN elasticsearch.discovery: [Hussar] waited for
30s and no initial state was set by the discovery
12/01/15 22:47:17 INFO elasticsearch.discovery: [Hussar] elasticsearch/
nJrZ15f7Tk-xu7VfKPjdFQ
12/01/15 22:47:17 INFO elasticsearch.http: [Hussar] bound_address
{inet[/0.0.0.0:9201]}, publish_address {inet[/192.168.0.15:9201]}
12/01/15 22:47:17 INFO elasticsearch.node: [Hussar] {0.18.6}[1081]:
started


Then I when try to index a document, I get the following error
message:


Exception in thread "main"
org.elasticsearch.discovery.MasterNotDiscoveredException:
at
org.elasticsearch.action.support.master.TransportMasterNodeOperationAction
$3.onTimeout(TransportMasterNodeOperationAction.java:162)
at org.elasticsearch.cluster.service.InternalClusterService
$NotifyTimeout.run(InternalClusterService.java:332)
at java.util.concurrent.ThreadPoolExecutor
$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)


But if use TransportClient API and try to index a document(using the
following code), everything goes smoothly.


   ImmutableSettings.Builder settings =

ImmutableSettings.settingsBuilder();
settings.put("cluster.name", "anthread");
settings.put("client.transport.sniff", true);
settings.build();
client = new TransportClient(settings);
client.addTransportAddress(new
InetSocketTransportAddress("192.168.0.15", 9300));
client.addTransportAddress(new
InetSocketTransportAddress("192.168.0.7", 9300));


And if I try to run an additional node using the following command:
"./elasticsearch -f -Des.node.data=false -Des.node.client=true"
I get the next message, which suggests that the master was found
successfully, unlike the situation above.


[2012-01-15 23:33:43,936][INFO ][node ]
[anthread01] {0.18.6}[2130]: initializing ...
[2012-01-15 23:33:43,944][INFO ][plugins ]
[anthread01] loaded , sites
[2012-01-15 23:33:45,370][INFO ][node ]
[anthread01] {0.18.6}[2130]: initialized
[2012-01-15 23:33:45,371][INFO ][node ]
[anthread01] {0.18.6}[2130]: starting ...
[2012-01-15 23:33:45,418][INFO ][transport ]
[anthread01] bound_address {inet[/192.168.0.15:9301]}, publish_address
{inet[/192.168.0.15:9301]}
[2012-01-15 23:33:48,527][INFO ][cluster.service ]
[anthread01] detected_master [anthread01][fegUJtU0QG60HaSDMe3wgg]
[inet[/192.168.0.15:9300]], added {[anthread01][fegUJtU0QG60HaSDMe3wgg]
[inet[/192.168.0.15:9300]],[anthread04][79-cnh1mTVu3HY_3N6mv8w][inet[/
192.168.0.4:9300]],[anthread03][uPw2gr6lRD2JHsxbvIurqw][inet[/
192.168.0.8:9300]],[anthread02][gz-aUT28QbSL6ZGlMF9J3A][inet[/
192.168.0.7:9300]],[anthread05][CH3NDGGCSzmrI-PVXtEXyg][inet[/
192.168.0.5:9300]],}, reason: zen-disco-receive(from master
[[anthread01][fegUJtU0QG60HaSDMe3wgg][inet[/192.168.0.15:9300]]])
[2012-01-15 23:33:48,540][INFO ][discovery ]
[anthread01] anthread/__eWuXJyT4iyitu186ISag
[2012-01-15 23:33:48,543][INFO ][http ]
[anthread01] bound_address {inet[/192.168.0.15:9201]}, publish_address
{inet[/192.168.0.15:9201]}
[2012-01-15 23:33:48,544][INFO ][node ]
[anthread01] {0.18.6}[2130]: started
[2012-01-15 23:33:52,709][INFO ][node ]
[anthread01] {0.18.6}[2130]: stopping ...
[2012-01-15 23:33:52,723][INFO ][node ]
[anthread01] {0.18.6}[2130]: stopped
[2012-01-15 23:33:52,723][INFO ][node ]
[anthread01] {0.18.6}[2130]: closing ...
[2012-01-15 23:33:52,732][INFO ][node ]
[anthread01] {0.18.6}[2130]: closed


Could anyone tell me what I am doing wrong?
I am assuming that when I start a node using Java API, the newly
created node cannot find the existing cluster.
But when I use TransportClient or "/bin/elasticsearch", everything
goes fine. So I must be missing something here.
My firewalls are all turned off, of course.
I am really out of clue here.

Ed

Yes, you were right.
I added the following code:
"settings.put("cluster.name", "myCluster");"
and it worked like a charm.
Thanks!!!

Ed

2012/1/16 Shay Banon kimchy@gmail.com

You don't seem to set the cluster name when you construct the node client?

On Sun, Jan 15, 2012 at 4:56 PM, mp2893 mp2893@gmail.com wrote:

Hi,

I'm a newbie in ES.
I was trying to start a Java client using Java API.
I used the following code:


   ImmutableSettings.Builder settings =

ImmutableSettings.settingsBuilder();
settings.put("node.client", true);
settings.put("node.data", false);
settings.put("node.name", "temp");
settings.build();
Node node =
NodeBuilder.nodeBuilder().settings(settings).node();
Client client = node.client();


But I always get the following message:


12/01/15 22:46:46 INFO elasticsearch.node: [Hussar] {0.18.6}[1081]:
initializing ...
12/01/15 22:46:46 INFO elasticsearch.plugins: [Hussar] loaded ,
sites
12/01/15 22:46:47 INFO elasticsearch.node: [Hussar] {0.18.6}[1081]:
initialized
12/01/15 22:46:47 INFO elasticsearch.node: [Hussar] {0.18.6}[1081]:
starting ...
12/01/15 22:46:47 INFO elasticsearch.transport: [Hussar] bound_address
{inet[/0.0.0.0:9301]}, publish_address {inet[/192.168.0.15:9301]}
12/01/15 22:47:17 WARN elasticsearch.discovery: [Hussar] waited for
30s and no initial state was set by the discovery
12/01/15 22:47:17 INFO elasticsearch.discovery: [Hussar] elasticsearch/
nJrZ15f7Tk-xu7VfKPjdFQ
12/01/15 22:47:17 INFO elasticsearch.http: [Hussar] bound_address
{inet[/0.0.0.0:9201]}, publish_address {inet[/192.168.0.15:9201]}
12/01/15 22:47:17 INFO elasticsearch.node: [Hussar] {0.18.6}[1081]:
started


Then I when try to index a document, I get the following error
message:


Exception in thread "main"
org.elasticsearch.discovery.MasterNotDiscoveredException:
at
org.elasticsearch.action.support.master.TransportMasterNodeOperationAction
$3.onTimeout(TransportMasterNodeOperationAction.java:162)
at org.elasticsearch.cluster.service.InternalClusterService
$NotifyTimeout.run(InternalClusterService.java:332)
at java.util.concurrent.ThreadPoolExecutor
$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)


But if use TransportClient API and try to index a document(using the
following code), everything goes smoothly.


   ImmutableSettings.Builder settings =

ImmutableSettings.settingsBuilder();
settings.put("cluster.name", "anthread");
settings.put("client.transport.sniff", true);
settings.build();
client = new TransportClient(settings);
client.addTransportAddress(new
InetSocketTransportAddress("192.168.0.15", 9300));
client.addTransportAddress(new
InetSocketTransportAddress("192.168.0.7", 9300));


And if I try to run an additional node using the following command:
"./elasticsearch -f -Des.node.data=false -Des.node.client=true"
I get the next message, which suggests that the master was found
successfully, unlike the situation above.


[2012-01-15 23:33:43,936][INFO ][node ]
[anthread01] {0.18.6}[2130]: initializing ...
[2012-01-15 23:33:43,944][INFO ][plugins ]
[anthread01] loaded , sites
[2012-01-15 23:33:45,370][INFO ][node ]
[anthread01] {0.18.6}[2130]: initialized
[2012-01-15 23:33:45,371][INFO ][node ]
[anthread01] {0.18.6}[2130]: starting ...
[2012-01-15 23:33:45,418][INFO ][transport ]
[anthread01] bound_address {inet[/192.168.0.15:9301]}, publish_address
{inet[/192.168.0.15:9301]}
[2012-01-15 23:33:48,527][INFO ][cluster.service ]
[anthread01] detected_master [anthread01][fegUJtU0QG60HaSDMe3wgg]
[inet[/192.168.0.15:9300]], added {[anthread01][fegUJtU0QG60HaSDMe3wgg]
[inet[/192.168.0.15:9300]],[anthread04][79-cnh1mTVu3HY_3N6mv8w][inet[/
192.168.0.4:9300]],[anthread03][uPw2gr6lRD2JHsxbvIurqw][inet[/
192.168.0.8:9300]],[anthread02][gz-aUT28QbSL6ZGlMF9J3A][inet[/
192.168.0.7:9300]],[anthread05][CH3NDGGCSzmrI-PVXtEXyg][inet[/
192.168.0.5:9300]],}, reason: zen-disco-receive(from master
[[anthread01][fegUJtU0QG60HaSDMe3wgg][inet[/192.168.0.15:9300]]])
[2012-01-15 23:33:48,540][INFO ][discovery ]
[anthread01] anthread/__eWuXJyT4iyitu186ISag
[2012-01-15 23:33:48,543][INFO ][http ]
[anthread01] bound_address {inet[/192.168.0.15:9201]}, publish_address
{inet[/192.168.0.15:9201]}
[2012-01-15 23:33:48,544][INFO ][node ]
[anthread01] {0.18.6}[2130]: started
[2012-01-15 23:33:52,709][INFO ][node ]
[anthread01] {0.18.6}[2130]: stopping ...
[2012-01-15 23:33:52,723][INFO ][node ]
[anthread01] {0.18.6}[2130]: stopped
[2012-01-15 23:33:52,723][INFO ][node ]
[anthread01] {0.18.6}[2130]: closing ...
[2012-01-15 23:33:52,732][INFO ][node ]
[anthread01] {0.18.6}[2130]: closed


Could anyone tell me what I am doing wrong?
I am assuming that when I start a node using Java API, the newly
created node cannot find the existing cluster.
But when I use TransportClient or "/bin/elasticsearch", everything
goes fine. So I must be missing something here.
My firewalls are all turned off, of course.
I am really out of clue here.

Ed