Elastic search transport client singleton


(cyrilforce) #1

Hi All,

I had created a transport client singleton that's being used in a web
application. I would like to know that if i didn't close the transport
client will it create memory leaks as we do re-deploy the web application
constantly. In addition, what is the best practices on handling the
elastic search transport client ? As i wanted the transport client shared
and reuse by multiple code in the same web application.
Should i just let the connection timeout itself or explicit close the
connection for each web deploy.

Thanks.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/f93d9e26-d02c-4320-8887-ad9ae1c4fd20%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Jörg Prante) #2

The TransportClient uses a thread pool for managing connections to remote
nodes.

For each web deploy, it is important to close all resources with
client.close() and to release the threadpool with
client.threadPool().shutdown()

Example:
https://github.com/jprante/elasticsearch-support/blob/master/src/main/java/org/xbib/elasticsearch/support/client/TransportClientBase.java#L90

You can share a client instance between many concurrent threads. There is
no need to close transport client connections after actionGet().

Jörg

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAKdsXoH7jYjX7%3D15P%2BaRTgzOAeigwiJsSVRFwbzY1xB5OwOLiw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(cyrilforce) #3

Hi Jörg,

Thanks for you advices.I have implemented the close conn mechanism through
the servletcontextlistener as it is a webapp.

Thanks.
Cyril

On Mon, Dec 9, 2013 at 4:52 PM, joergprante@gmail.com <joergprante@gmail.com

wrote:

The TransportClient uses a thread pool for managing connections to remote
nodes.

For each web deploy, it is important to close all resources with
client.close() and to release the threadpool with
client.threadPool().shutdown()

Example:
https://github.com/jprante/elasticsearch-support/blob/master/src/main/java/org/xbib/elasticsearch/support/client/TransportClientBase.java#L90

You can share a client instance between many concurrent threads. There is
no need to close transport client connections after actionGet().

Jörg

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/Iz1omfHq0Yc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAKdsXoH7jYjX7%3D15P%2BaRTgzOAeigwiJsSVRFwbzY1xB5OwOLiw%40mail.gmail.com
.

For more options, visit https://groups.google.com/groups/opt_out.

--
Regards,

Chee Hoo

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAGS0%2Bg9aaFHPtPt3XBuYuwj_MKLnLNdOX%2BL0iGm1EGRvnQ1XTQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #4