Hi,

 I'm using the below code to get a singleton object for TransportClient 
object. I'm using the getInstance() to get the client object which is 
already alive in webapplication. 

public static Client getInstance()
{
if (instance == null)
  {
logger.debug("the client instance is null, creating a new instance");
ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder(); 
        settings.put("node.client", true); 
        settings.put("node.data", false); 
        settings.put("node.name", "node-client");
        settings.put("cluster.name", "elasticsearch");
        settings.build(); 
instance = new TransportClient(settings)
                .addTransportAddress(new 
InetSocketTransportAddress("10.203.238.139", 9300));
logger.debug("returning the new created client instance...");
return instance;
  }
return instance;
}

Calling the client as below from search api.
Client client = ESClientFactory.getInstance(); 

Now the issue is if I don't close client like client.close() I'm getting 
memory leak warning from webserver tomcat side. If I do close the 
connection using client.close() after search api call then I'm getting 
NoNodeAvailableException 
exception.

Please suggest what is the correct way to call the connection object.

Thanks,
Subhadip

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/e2aaf77f-cd18-4e52-98fc-c25ed03601fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to