I have a web service, where every time a button is pressed from UI, it
connects to elastic search and fires a query. This is the code which is
executed every time. The issue is that after a while, intermittently, the
UI hangs.
private static final String CONFIG_CLUSTER_NAME = "cluster.name";
private static final String CLUSTER_NAME = "sample_es";
private static final String[] transportAddress = {
//Machine details
};
private static final int transportPort = 9300;
public static Client initClient(){
settings = ImmutableSettings.settingsBuilder().put(CONFIG_CLUSTER_NAME, CLUSTER_NAME).build();
Client client = new TransportClient(settings);
for (int i=0 ; i < transportAddress.length-1 ; i++){
((TransportClient)client).addTransportAddress(new InetSocketTransportAddress(transportAddress[i], transportPort));
}
logger.info("TransportClient Created");
return client;
}
public static int query( String query) throws Exception
{
Client client = null;
try{
Whenever we restart the tomcat server, this is the error message we are
seeing in logs. How should we fix this?
[org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom$1] (value
[org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom$1@5838ce3e]) and a value of type
[org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom] (value
[org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom@796c75b1]) but failed to remove it
when the web application was stopped. This is very likely to create a memory leak.
I have a web service, where every time a button is pressed from UI, it
connects to Elasticsearch and fires a query. This is the code which is
executed every time. The issue is that after a while, intermittently, the
UI hangs.
private static final String CONFIG_CLUSTER_NAME = "cluster.name";
private static final String CLUSTER_NAME = "sample_es";
private static final String transportAddress = {
//Machine details
};
private static final int transportPort = 9300;
public static Client initClient(){
settings = ImmutableSettings.settingsBuilder().put(CONFIG_CLUSTER_NAME, CLUSTER_NAME).build();
Client client = new TransportClient(settings);
for (int i=0 ; i < transportAddress.length-1 ; i++){
((TransportClient)client).addTransportAddress(new InetSocketTransportAddress(transportAddress[i], transportPort));
}
logger.info("TransportClient Created");
return client;
}
public static int query( String query) throws Exception
{
Client client = null;
try{
Whenever we restart the tomcat server, this is the error message we are
seeing in logs. How should we fix this?
[org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom$1] (value
[org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom$1@5838ce3e]) and a value of type
[org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom] (value
[org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom@796c75b1]) but failed to remove it
when the web application was stopped. This is very likely to create a memory leak.
is it happening because we are creating and closing a new client for every
query??
Will having only one connection forever solve this? Does ES connection stay
live even if no one uses it for a couple hours? Or it becomes stale?
That is why I am creating and closing a connection everytime.
On Sunday, November 23, 2014 9:48:49 PM UTC+5:30, Jörg Prante wrote:
You do not correctly instantiate TransportClient as a singleton.
From the code snippet it is not clear, but it seems that you
recreate TransportClient at each query, which is not correct.
Jörg
On Sun, Nov 23, 2014 at 4:36 PM, <prac...@gmail.com <javascript:>> wrote:
I have a web service, where every time a button is pressed from UI, it
connects to Elasticsearch and fires a query. This is the code which is
executed every time. The issue is that after a while, intermittently, the
UI hangs.
private static final String CONFIG_CLUSTER_NAME = "cluster.name";
private static final String CLUSTER_NAME = "sample_es";
private static final String transportAddress = {
//Machine details
};
private static final int transportPort = 9300;
public static Client initClient(){
settings = ImmutableSettings.settingsBuilder().put(CONFIG_CLUSTER_NAME, CLUSTER_NAME).build();
Client client = new TransportClient(settings);
for (int i=0 ; i < transportAddress.length-1 ; i++){
((TransportClient)client).addTransportAddress(new InetSocketTransportAddress(transportAddress[i], transportPort));
}
logger.info("TransportClient Created");
return client;
}
public static int query( String query) throws Exception
{
Client client = null;
try{
Whenever we restart the tomcat server, this is the error message we are
seeing in logs. How should we fix this?
[org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom$1] (value
[org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom$1@5838ce3e]) and a value of type
[org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom] (value
[org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom@796c75b1]) but failed to remove it
when the web application was stopped. This is very likely to create a memory leak.
I have a web service, where every time a button is pressed from UI, it
connects to Elasticsearch and fires a query. This is the code which is
executed every time. The issue is that after a while, intermittently, the
UI hangs.
private static final String CONFIG_CLUSTER_NAME = "cluster.name";
private static final String CLUSTER_NAME = "sample_es";
private static final String transportAddress = {
//Machine details
};
private static final int transportPort = 9300;
public static Client initClient(){
settings = ImmutableSettings.settingsBuilder().put(CONFIG_CLUSTER_NAME, CLUSTER_NAME).build();
Client client = new TransportClient(settings);
for (int i=0 ; i < transportAddress.length-1 ; i++){
((TransportClient)client).addTransportAddress(new InetSocketTransportAddress(transportAddress[i], transportPort));
}
logger.info("TransportClient Created");
return client;
}
public static int query( String query) throws Exception
{
Client client = null;
try{
Whenever we restart the tomcat server, this is the error message we are
seeing in logs. How should we fix this?
[org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom$1] (value
[org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom$1@5838ce3e]) and a value of type
[org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom] (value
[org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom@796c75b1]) but failed to remove it
when the web application was stopped. This is very likely to create a memory leak.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.