Hello,
I make intent to reuse class ElasticsearchNodeFactoryBean from article 'Elasticsearch with Spring'
(http://techo-ecco.com/blog/elasticsearch-with-spring/).
I have a problem with client node creation on localhost.
Can you help me please.
I start elasticsearch.bat from elastic folder, to create server node to store in it the indexes.
Then i start a client node from my java main class with spring configuration and want recover indexes from server node.
I was changed a little ElasticSearchNodeFactoryBean because node was not recognized with master server node
(that created with elasticsearch.bat and named like MasterNode).
Both nodes works on localhost and with same jdk1.6 and elasticsearch-0.18.2
My snippets code and logs with my comments:
Spring applicationContext.xml
<bean id="searchNode" class="com.web.project.elasticsearch.ElasticSearchNodeFactoryBean">
<property name="configLocation" value="classpath:/spring/elasticsearch.properties"/>
</bean>
<bean id="searchClient" factory-bean="searchNode" factory-method="client" />
<bean id="adminClient" factory-bean="searchClient" factory-method="admin" />
elasticsearch.properties
node.name=MyNode
node.client=true
node.local=true
node.data=false
index.number_of_shards=3
index.store.fs.memory.enabled=false
index.analysis.analyzer.projectx_standard.type=standard
index.analysis.analyzer.projectx_standard.filter=[lowercase]
And code to get index:
ClassPathXmlApplicationContext ctx =
new ClassPathXmlApplicationContext("classpath:/spring/applicationContext.xml");
Client client = (Client) ctx.getBean("searchClient");
GetResponse response = client.prepareGet("twitter", "tweet", "1")
.execute()
.actionGet();
System.out.println("End get ..."+response.sourceAsString());
When I run test on server node (MasterNode) i have a lot of exeptions:
java.io.IOException: Se ha forzado la interrupci¾n de una conexi¾n existente por
el host remoto
at sun.nio.ch.SocketDispatcher.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:25)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:233)
at sun.nio.ch.IOUtil.read(IOUtil.java:200)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:236)
at org.elasticsearch.common.netty.channel.socket.nio.NioWorker.read(NioW
orker.java:321)
at org.elasticsearch.common.netty.channel.socket.nio.NioWorker.processSe
lectedKeys(NioWorker.java:280)
at org.elasticsearch.common.netty.channel.socket.nio.NioWorker.run(NioWo
rker.java:200)
at org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(Thread
RenamingRunnable.java:108)
at org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.ru
n(DeadLockProofWorker.java:44)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:908)
at java.lang.Thread.run(Thread.java:619)
[2011-11-08 13:01:45,311][WARN ][transport.netty ] [MasterNode] Excepti
on caught on netty layer [[id: 0x01c8f59c, /192.168.4.161:4421 => /192.168.4.161
:9300]]
java.io.IOException: Se ha forzado la interrupci¾n de una conexi¾n existente por
el host remoto
at sun.nio.ch.SocketDispatcher.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:25)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:233)
at sun.nio.ch.IOUtil.read(IOUtil.java:200)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:236)
at org.elasticsearch.common.netty.channel.socket.nio.NioWorker.read(NioW
orker.java:321)
at org.elasticsearch.common.netty.channel.socket.nio.NioWorker.processSe
lectedKeys(NioWorker.java:280)
at org.elasticsearch.common.netty.channel.socket.nio.NioWorker.run(NioWo
rker.java:200)
at org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(Thread
RenamingRunnable.java:108)
at org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.ru
n(DeadLockProofWorker.java:44)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:908)
at java.lang.Thread.run(Thread.java:619)
[2011-11-08 13:01:46,108][INFO ][cluster.service ] [MasterNode] removed
{[Aguja][RHkrUAcLQfWygl90Z04D9Q][inet[/192.168.4.161:9301]],}, reason: zen-disc
o-node_failed([Aguja][RHkrUAcLQfWygl90Z04D9Q][inet[/192.168.4.161:9301]]), reaso
n transport disconnected (with verified connect)
And finally i have a index information...
End get ...{"user":"kimchy","postDate":"2011-11-06T14:12:13.416Z","message":"trying out Elastic Search"}
Only if i create client node like an api:
Node node = nodeBuilder().client(true).node();
Client client = node.client();
GetResponse response = client.prepareGet("twitter", "tweet", "1")
.execute()
.actionGet();
System.out.println("End get ..."+response.sourceAsString());
all works fine, without errors...
Another thing, spring implementation create node with name (Aguja on log.txt) but on elasticsearch.properties was declared like (MyNode)...
I don't understand what i'm doing wrong.
Do you known why i have this exceptions? And what i must do to avoid it?
I added logs and ElasticSearchNodeFactoryBean class.
<nabble_a href="ElasticSearchNodeFactoryBean.java">ElasticSearchNodeFactoryBean.java</nabble_a>
<nabble_a href="logs.txt">logs.txt</nabble_a>
Please help me. Advance thank you very much.