Hello,
We noticed an abnormal number of connections from the gremlin driver.
Here is a sample code able to leverage the issue :
public class App {
private static final int RECONNECT_INITIAL_DELAY = 50;
private static final String GREMLIN_HOST = "localhost";
private static final int GREMLIN_PORT = 8182;
private static final int MIN_POOL_SIZE = 2;
private static final int MAX_POOL_SIZE = 8;
public static void main(String[] args) {
/* Client initialization */
final Builder builder = Cluster.build().serializer(new GryoMessageSerializerV1d0(GryoMapper.build().create())).addContactPoint(GREMLIN_HOST).port(GREMLIN_PORT);
builder.reconnectIntialDelay(RECONNECT_INITIAL_DELAY);
builder.minConnectionPoolSize(MIN_POOL_SIZE);
builder.maxConnectionPoolSize(MAX_POOL_SIZE);
final Cluster cluster = builder.create();
final Client client = cluster.connect();
client.init();
final String request = "g.V()";
final ExecutorService executorService = Executors.newFixedThreadPool(100);
for (int i = 0; i < 1000; ++i) {
executorService.submit(new Runnable() {
@Override
public void run() {
try {
client.submit(request, null).all().get(500, TimeUnit.MILLISECONDS);
} catch (final TimeoutException | InterruptedException | ExecutionException | RuntimeException exception) {
System.err.println("Execution failed, an error occured: " + exception.getMessage());
}
}
});
}
}
}
By running this code and opening another terminal using a netstat -p | grep 8182 we can see the number of connections going above 8. (we saw around 150 sockets opened in our application)
So my question are :
* Is the gremlin driver thread safe ?
* If it is supposed to be thread safe, then this is an issue, otherwise, a misuse from me (Also maybe some documentation was missing ?).
Thank you for your time.
Regards,
Anthony PERINOT