Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

run in J2SE, when shutdownClient, the jvm still hang. #54

Closed
zykaka opened this issue Jul 1, 2013 · 7 comments
Closed

run in J2SE, when shutdownClient, the jvm still hang. #54

zykaka opened this issue Jul 1, 2013 · 7 comments

Comments

@zykaka
Copy link

zykaka commented Jul 1, 2013

test the code like:

    client.shutdownClient();

    System.out.println("terminated!");

The main thread exists but the whole JVM still hold by the execution service.

Fix could be in the NodeChecker:

protected void shutDown() throws Exception{
    super.shutDown();
    client = null;
    clientConfig = null;

    executorService.shutdown();
}

protected ScheduledExecutorService executor() {
    executorService =
            Executors.newSingleThreadScheduledExecutor();
    return executorService;
}
@ferhatsb
Copy link
Member

ferhatsb commented Jul 2, 2013

Which version are you running , snapshot ?

@zykaka
Copy link
Author

zykaka commented Jul 3, 2013

snapshot of master

@zykaka zykaka closed this as completed Aug 29, 2013
@zykaka
Copy link
Author

zykaka commented Aug 29, 2013

Sample test code:

package abc.test;

import io.searchbox.client.JestClient;
import io.searchbox.client.JestClientFactory;
import io.searchbox.client.JestResult;
import io.searchbox.client.config.ClientConfig;
import io.searchbox.core.Search;

import java.util.concurrent.TimeUnit;

public class JestTest {

/**
 * @param args
 * @throws Exception 
 */
public static void main(String[] args) throws Exception {

    // Configuration
    ClientConfig clientConfig = 
            new ClientConfig.Builder("http://localhost:9200")
    .multiThreaded(true).discoveryEnabled(true)
    .discoveryFrequency(1l, TimeUnit.SECONDS).maxTotalConnection(100).build();

    // Construct a new Jest client according to configuration via factory
    JestClientFactory factory = new JestClientFactory();
    factory.setClientConfig(clientConfig);
    JestClient client = factory.getObject();


    String query = "{\n" +
            "    \"query\": {\n" +
            "        \"filtered\" : {\n" +
            "            \"query\" : {\n" +
            "                \"query_string\" : {\n" +
            "                    \"query\" : \"search\"\n" +
            "                }\n" +
            "            },\n" +
            "            \"filter\" : {\n" +
            "                \"term\" : { \"user\" : \"kimchy\" }\n" +
            "            }\n" +
            "        }\n" +
            "    }\n" +
            "}"; 


    Thread.sleep(2000);

    Search search = new Search.Builder(query)
    // multiple index or types can be added.
    .addIndex("twitter").addType("tweet")
    .build();

    for(int i=0; i<10; i++){
        JestResult result = client.execute(search); 

        System.out.println(result.getJsonString());
    }

    client.shutdownClient();

    System.out.println("terminated!");
}

}

This new process will never stops.

@zykaka zykaka reopened this Aug 29, 2013
@kramer
Copy link
Member

kramer commented Aug 31, 2013

I still cannot reproduce the issue even with the sample code you provided... When I run your sample code, both main thread and the JVM properly terminates. Are you customizing/overwriting any of the Jest classes, maybe that's the issue?

@ferhatsb
Copy link
Member

ferhatsb commented Sep 1, 2013

@zykaka which jdk/jvm version you are using?

@zykaka
Copy link
Author

zykaka commented Sep 3, 2013

IBM jdk 6.0

@ferhatsb
Copy link
Member

ferhatsb commented Feb 9, 2014

Closing this, guess this bug is only happens with IBM JDK.

@ferhatsb ferhatsb closed this as completed Feb 9, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants