PrimaryNotStartedActionException with JAVA API


(HubertChang) #1

My elasticsearch.in.sh is:
JAVA_OPTS="
-Xms128M
-Xmx1G
-Djline.enabled=true
-Djava.net.preferIPv4Stack=true
-XX:+AggressiveOpts
-XX:+UseParNewGC
-XX:+UseConcMarkSweepGC
-XX:+CMSParallelRemarkEnabled
-XX:+HeapDumpOnOutOfMemoryError
-Dgateway.fs.location=/datastore/es/
-Dpath.logs=/datastore/es/logs/"
No extra config is added in elasticsearch.yml.

After elasticsearch started on the single node, I run:
curl -XPUT 'http://localhost:9200/twitter/tweet/1' -d '{name:"8888"}'
The response:
{"ok":true,"_index":"twitter","_type":"tweet","_id":"1"}

My code(in groovy):

import org.elasticsearch.client.Client
import org.elasticsearch.server.Server
import org.elasticsearch.server.ServerBuilder
import org.elasticsearch.util.settings.ImmutableSettings
import org.elasticsearch.action.index.IndexResponse
import org.elasticsearch.action.index.IndexRequest
Server server
try {
server = new ServerBuilder().
settings(ImmutableSettings.settingsBuilder().
put("node.data", false).
put("node.local", false)
).server()
} catch (Exception e) {
println(e.getMessage())
server.close()
}
Client client = server.client()
println "index one message."
IndexResponse response = client.index(new IndexRequest("twitter")
.type("tweet")
.id("88")
.source("{name:'HubertChang'}")).actionGet()
println "close the server."
server.close()

The output:
index one message.
Caught: org.elasticsearch.action.PrimaryNotStartedActionException: [twitter][3] Timeout waiting for [1m]

What's wrong with this?


(Shay Banon) #2

Can you try and add -Djava.net.preferIPv4Stack=true to your client side as
well? Check in the output (logs/console) if the client node you started in
groovy manages to connect to the cluster.

-shay.banon

On Wed, Mar 31, 2010 at 10:47 AM, HubertChang huixiu@gmail.com wrote:

My elasticsearch.in.sh is:
JAVA_OPTS="
-Xms128M
-Xmx1G
-Djline.enabled=true
-Djava.net.preferIPv4Stack=true
-XX:+AggressiveOpts
-XX:+UseParNewGC
-XX:+UseConcMarkSweepGC
-XX:+CMSParallelRemarkEnabled
-XX:+HeapDumpOnOutOfMemoryError
-Dgateway.fs.location=/datastore/es/
-Dpath.logs=/datastore/es/logs/"
No extra config is added in elasticsearch.yml.

After elasticsearch started on the single node, I run:
curl -XPUT 'http://localhost:9200/twitter/tweet/1' -d '{name:"8888"}'
The response:
{"ok":true,"_index":"twitter","_type":"tweet","_id":"1"}

My code(in groovy):

import org.elasticsearch.client.Client
import org.elasticsearch.server.Server
import org.elasticsearch.server.ServerBuilder
import org.elasticsearch.util.settings.ImmutableSettings
import org.elasticsearch.action.index.IndexResponse
import org.elasticsearch.action.index.IndexRequest
Server server
try {
server = new ServerBuilder().
settings(ImmutableSettings.settingsBuilder().
put("node.data", false).
put("node.local", false)
).server()
} catch (Exception e) {
println(e.getMessage())
server.close()
return
}
Client client = server.client()
println "index one message."
IndexResponse response = client.index(new IndexRequest("twitter")
.type("tweet")
.id("88")
.source("{name:'HubertChang'}")).actionGet()
println "close the server."
server.close()

The output:
index one message.
Caught: org.elasticsearch.action.PrimaryNotStartedActionException:
[twitter][3] Timeout waiting for [1m]

What's wrong with this?

--
View this message in context:
http://n3.nabble.com/PrimaryNotStartedActionException-with-JAVA-API-tp687867p687867.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.


(HubertChang) #3

After add "-Djava.net.preferIPv4Stack=true",
Output is:
index one message.
Caught: org.elasticsearch.transport.RemoteTransportException: [Jonas Harrow][inet[/192.168.56.1:9300]][indices/index/shard/index]

Replace "{name:'HubertChang'}" with '{name:"HubertChang"}', everyting is ok!

Thanks!


(system) #4