PrimaryNotStartedActionException using the Java APIs

Hi,
first of all, thanks for the "beauty" you put into ElasticSearch.
I am an absolute beginner with ElasticSearch, so forgive me if I
ask trivial questions (but I did not find the answer on this list
or on the documentation).

I am using ElasticSearch v0.5.1 with an empty configuration file.
I am running a single/local node and learning how to use the Java
API to interact with it.

Everything works fine with:

Server server = serverBuilder().settings(settingsBuilder()).server();

But, if I try to set build the server setting node.data to false:

Server server = serverBuilder().settings(settingsBuilder()
.put("node.data", false))
.server();

I have this exception when I try to add something to an index:


Exception in thread "main"
org.elasticsearch.action.PrimaryNotStartedActionException: [twitter][2]
Timeout waiting for [1m]
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$4.onTimeout(TransportShardReplicationOperationAction.java:301)
at
org.elasticsearch.cluster.service.InternalClusterService$1$1.run(InternalClusterService.java:96)
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:619)

IndexResponse response = client.index(indexRequest("twitter")
.operationThreaded(true)
.type("tweet")
.id("1")
.source(jsonBuilder()
.startObject()
.field("user", "kimchy")
.field("postDate", new Date())
.field("message", "trying out Elastic Search")
.endObject()
)).actionGet();

I am able to perform operations using the REST APIs.

Or, create an index with the Java APIs but when I try to add a document
to the index I see the exception above.

Am I doing something wrong?

Paolo

Not sure that I fully understand. Is the server you start the only one you
have in the cluster? If you set it with node.data set to false, then there
will be no node/server to allocated the indices to.

If it is not, and you started other instances of elasticsearch, then it
might be a discovery problem where the embedded server you started can't
discover the rest of the cluster. It should print in the console/logs if it
discovered or not. If it did not, try and pass the following system
property: -Djava.net.preferIPv4Stack=true (I really hope to get read of this
soon).

-shay.banon

On Tue, Mar 30, 2010 at 3:13 PM, Paolo Castagna <
castagna.lists@googlemail.com> wrote:

Hi,
first of all, thanks for the "beauty" you put into Elasticsearch.
I am an absolute beginner with Elasticsearch, so forgive me if I
ask trivial questions (but I did not find the answer on this list
or on the documentation).

I am using Elasticsearch v0.5.1 with an empty configuration file.
I am running a single/local node and learning how to use the Java
API to interact with it.

Everything works fine with:

Server server = serverBuilder().settings(settingsBuilder()).server();

But, if I try to set build the server setting node.data to false:

Server server = serverBuilder().settings(settingsBuilder()
.put("node.data", false))
.server();

I have this exception when I try to add something to an index:


Exception in thread "main"
org.elasticsearch.action.PrimaryNotStartedActionException: [twitter][2]
Timeout waiting for [1m]
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$4.onTimeout(TransportShardReplicationOperationAction.java:301)
at
org.elasticsearch.cluster.service.InternalClusterService$1$1.run(InternalClusterService.java:96)
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:619)

IndexResponse response = client.index(indexRequest("twitter")
.operationThreaded(true)
.type("tweet")
.id("1")
.source(jsonBuilder()
.startObject()
.field("user", "kimchy")
.field("postDate", new Date())
.field("message", "trying out Elastic Search")
.endObject()
)).actionGet();

I am able to perform operations using the REST APIs.

Or, create an index with the Java APIs but when I try to add a document
to the index I see the exception above.

Am I doing something wrong?

Paolo

Shay Banon wrote:

Not sure that I fully understand. Is the server you start the only one
you have in the cluster? If you set it with node.data set to false, then
there will be no node/server to allocated the indices to.

No, the server I start is not the only one I have in the cluster.
I start another one on the same machine using bin/elasticsearch.

If it is not, and you started other instances of elasticsearch, then it
might be a discovery problem where the embedded server you started can't
discover the rest of the cluster. It should print in the console/logs if
it discovered or not. If it did not, try and pass the following system
property: -Djava.net.preferIPv4Stack=true (I really hope to get read of
this soon).

Yes, this worked. I need to use -Djava.net.preferIPv4Stack=true when
I start bin/elasticsearch and when I execute the code which is using
the Java APIs.

Can you explain me this issue/problem?

Is it because of IPv6 and IPv4 are enabled on the same network
interface?

Thanks,
Paolo

On Tue, Mar 30, 2010 at 7:30 PM, Paolo Castagna <
castagna.lists@googlemail.com> wrote:

Shay Banon wrote:

Not sure that I fully understand. Is the server you start the only one you
have in the cluster? If you set it with node.data set to false, then there
will be no node/server to allocated the indices to.

No, the server I start is not the only one I have in the cluster.
I start another one on the same machine using bin/elasticsearch.

If it is not, and you started other instances of elasticsearch, then it

might be a discovery problem where the embedded server you started can't
discover the rest of the cluster. It should print in the console/logs if it
discovered or not. If it did not, try and pass the following system
property: -Djava.net.preferIPv4Stack=true (I really hope to get read of this
soon).

Yes, this worked. I need to use -Djava.net.preferIPv4Stack=true when
I start bin/elasticsearch and when I execute the code which is using
the Java APIs.

Can you explain me this issue/problem?

Is it because of IPv6 and IPv4 are enabled on the same network
interface?

Yes, there are problems with the jgroups discovery module when not
explicitly setting it. The bin/elasticsearch script sets it automatically,
so any client needs to set it as well. I hope to remove the need for this
once I upgrade to the next version of jgroups.

Thanks,
Paolo