Is NodeClient thread safe?

Hi,

I am using the NodeClient in a servlet where I create one instance of
the node. Then in every web request coming in I create a client from
that node and start searching etc with it. I.e the node (and client) is
shared among several sessions. For this to work the client need to be
thread safe. The question is - is it?

/Kristian

I wouldn't recommend creating a client on each and every request, as the
client is sort of a expensive resource. You should create it once for your
application and probably leave it in the servlet context available for all
the requests.

On Wed, Apr 13, 2011 at 4:23 PM, Kristian Jörg krjg@devo.se wrote:

Hi,

I am using the NodeClient in a servlet where I create one instance of the
node. Then in every web request coming in I create a client from that node
and start searching etc with it. I.e the node (and client) is shared among
several sessions. For this to work the client need to be thread safe. The
question is - is it?

/Kristian

Yes, the NodeClient is thread safe (any Client is thread safe, also the TransportClient) and its lifecycle should be similar to the application lifecycle.
On Wednesday, April 13, 2011 at 5:25 PM, Enrique Medina Montenegro wrote:

I wouldn't recommend creating a client on each and every request, as the client is sort of a expensive resource. You should create it once for your application and probably leave it in the servlet context available for all the requests.

On Wed, Apr 13, 2011 at 4:23 PM, Kristian Jörg krjg@devo.se wrote:

Hi,

I am using the NodeClient in a servlet where I create one instance of the node. Then in every web request coming in I create a client from that node and start searching etc with it. I.e the node (and client) is shared among several sessions. For this to work the client need to be thread safe. The question is - is it?

/Kristian

Hi Enrique,




yes I do create only one instance of the client in exactly the way
you describe.




/Kristian




Enrique Medina Montenegro skrev 2011-04-13 16:25:
<blockquote cite="mid:BANLkTim06=c8wPn88vsLyB5KrZH-wUukMA@mail.gmail.com" type="cite">
I wouldn't recommend creating a client on each and every request, as the client is sort of a expensive resource. You should create it once for your application and probably leave it in the servlet context available for all the requests.

On Wed, Apr 13, 2011 at 4:23 PM, Kristian Jörg <krjg@devo.se>
wrote:

Hi,
      I am using the NodeClient in a servlet where I create one
      instance of the node. Then in every web request coming in I
      create a client from that node and start searching etc with
      it. I.e the node (and client) is shared among several
      sessions. For this to work the client need to be thread safe.
      The question is - is it?




      /Kristian
Ok!




Thanks!




/Kristian




Shay Banon skrev 2011-04-13 20:45:
<blockquote cite="mid:70D42DC561514FE68C4EB6B67D622648@elasticsearch.com" type="cite">
Yes, the NodeClient is thread safe (any Client is thread safe, also the TransportClient) and its lifecycle should be similar to the application lifecycle.

On Wednesday, April 13, 2011 at 5:25 PM, Enrique Medina Montenegro wrote:

I wouldn't recommend creating a client on each and every request, as the client is sort of a expensive resource. You should create it once for your application and probably leave it in the servlet context available for all the requests.

On Wed, Apr 13, 2011 at 4:23 PM, Kristian Jörg <krjg@devo.se>
wrote:

Hi,
                    I am using the NodeClient in a servlet where I
                    create one instance of the node. Then in every
                    web request coming in I create a client from
                    that node and start searching etc with it. I.e
                    the node (and client) is shared among several
                    sessions. For this to work the client need to be
                    thread safe. The question is - is it?




                    /Kristian

My question is how client can handle multiple requests at same time? Will requests queue up? Or does it have a connection pool implemented?