Don't know how to return count-value in Java

Basic question, why does next() not seem to give me the results back about the count of Entities?
2023-05-24 09:21:44,641 [INFO] [j.Test35_2_1.main] :: [GraphStep(vertex,[]), HasStep([~label.eq(Entity)]), CountGlobalStep]
...
Exception in thread "main" java.lang.IllegalStateException: org.apache.tinkerpop.gremlin.process.remote.RemoteConnectionException: org.apache.tinkerpop.gremlin.driver.exception.NoHostAvailableException: java.util.concurrent.CompletionException: Could not initialize 2 (minPoolSize) connections in pool. Successful connections=0. Closing the connection pool.
at org.apache.tinkerpop.gremlin.process.remote.traversal.step.map.RemoteStep.promise(RemoteStep.java:97)
...
Caused by: org.apache.tinkerpop.gremlin.process.remote.RemoteConnectionException: org.apache.tinkerpop.gremlin.driver.exception.NoHostAvailableException: java.util.concurrent.CompletionException: Could not initialize 2 (minPoolSize) connections in pool. Successful connections=0. Closing the connection pool.
at org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection.submitAsync(DriverRemoteConnection.java:231)
2023-05-24 09:21:44,641 [INFO] [j.Test35_2_1.main] :: [GraphStep(vertex,[]), HasStep([~label.eq(Entity)]), CountGlobalStep]
...
Exception in thread "main" java.lang.IllegalStateException: org.apache.tinkerpop.gremlin.process.remote.RemoteConnectionException: org.apache.tinkerpop.gremlin.driver.exception.NoHostAvailableException: java.util.concurrent.CompletionException: Could not initialize 2 (minPoolSize) connections in pool. Successful connections=0. Closing the connection pool.
at org.apache.tinkerpop.gremlin.process.remote.traversal.step.map.RemoteStep.promise(RemoteStep.java:97)
...
Caused by: org.apache.tinkerpop.gremlin.process.remote.RemoteConnectionException: org.apache.tinkerpop.gremlin.driver.exception.NoHostAvailableException: java.util.concurrent.CompletionException: Could not initialize 2 (minPoolSize) connections in pool. Successful connections=0. Closing the connection pool.
at org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection.submitAsync(DriverRemoteConnection.java:231)
logger.info(g.V().hasLabel("Entity").count());
logger.info(g.V().hasLabel("Entity").count().next().toString());
logger.info(g.V().hasLabel("Entity").count());
logger.info(g.V().hasLabel("Entity").count().next().toString());
31 Replies
spmallette
spmallette2y ago
That error has less to do with your Gremlin and more to do with your connection to Gremlin Server. If you're using 3.5.5/3.6.2 or better on either release line, the Client object you've initialized can't initialize the connection pool because it can't even get to the host for some reason. older versions prior to those will have a more nuanced reason for NoHostAvailableException but it would again have something to do with the connection and less to do with the Gremlin being sent. you can read a bit more about this here: https://tinkerpop.apache.org/docs/current/upgrade/#_gremlin_driver_host_availability with some additional reading here about timeout troubleshooting which may have some relevance: https://tinkerpop.apache.org/docs/current/reference/#gremlin-java-troubleshooting
ZEE
ZEEOP2y ago
I don't know how to tell, I'm just using the latest ArcadeDB arcadedb-23.4.1
spmallette
spmallette2y ago
You don't know how to tell what?
ZEE
ZEEOP2y ago
Which version of Gremlin was added to the bundle
spmallette
spmallette2y ago
either way, i'm pretty sure that you have a connection problem and not a Gremlin problem there. that said, i'm not sure why you don't know what version of TinkerPop you are using though. you have have had to choose a version when you setup your java project or downloaded Gremlin Console or whatever, right?
ZEE
ZEEOP2y ago
The Gremlin Console and Server came pre-bundled with it
spmallette
spmallette2y ago
so what is that log from? those are ArcadeDB server logs?
ZEE
ZEEOP2y ago
They're from the response back to Java
spmallette
spmallette2y ago
so from your application written in Java, right?
ZEE
ZEEOP2y ago
public static void main(String[] args) throws IOException, CsvValidationException {
long startTime = System.nanoTime();
GraphTraversalSource g = traversal().withRemote(DriverRemoteConnection.using("localhost",8182,"g"));
logger.info(g.V().hasLabel("Entity").count());
logger.info(g.V().hasLabel("Entity").next().toString());
}
public static void main(String[] args) throws IOException, CsvValidationException {
long startTime = System.nanoTime();
GraphTraversalSource g = traversal().withRemote(DriverRemoteConnection.using("localhost",8182,"g"));
logger.info(g.V().hasLabel("Entity").count());
logger.info(g.V().hasLabel("Entity").next().toString());
}
spmallette
spmallette2y ago
so what version of TinkerPop did you choose to write your application? that's the driver version i'm referring to in my original reply
ZEE
ZEEOP2y ago
I don't know, I'm already way past wit's end here. https://github.com/ArcadeData/arcadedb/releases/tag/23.4.1
GitHub
Release 23.4.1 · ArcadeData/arcadedb
What's New SQL Add bool_and and bool_or functions by @gramian in #1017 Add base64url format to encode and decode functions by @gramian in #1019 Add ifnull method by @gramian in #1030 Add ILI...
ZEE
ZEEOP2y ago
I don't see the TinkerPop version listed in the release notes
spmallette
spmallette2y ago
your java application wouldnt run to even get an error (wouldn't even compile for that matter) if you didn't have a TinkerPop gremlin-driver jar file somehow referenced to the application itself. how are you referencing that jar?
ZEE
ZEEOP2y ago
<dependency>
<groupId>com.arcadedb</groupId>
<artifactId>arcadedb-gremlin</artifactId>
<version>23.4.1</version>
</dependency>
<dependency>
<groupId>com.arcadedb</groupId>
<artifactId>arcadedb-gremlin</artifactId>
<version>23.4.1</version>
</dependency>
spmallette
spmallette2y ago
ok, so you are transitively getting the gremlin-driver dependency through arcade db.
ZEE
ZEEOP2y ago
Yeah
spmallette
spmallette2y ago
when you have this situation you can either dig around in the project's pom.xml which is easy when it's an open source project:
spmallette
spmallette2y ago
GitHub
arcadedb/pom.xml at 23.4.1 · ArcadeData/arcadedb
ArcadeDB Multi-Model Database, one DBMS that supports SQL, Cypher, Gremlin, HTTP/JSON, MongoDB and Redis. ArcadeDB is a conceptual fork of OrientDB, the first Multi-Model DBMS. - arcadedb/pom.xml a...
spmallette
spmallette2y ago
or you can do a mvn dependency:tree in your project and it should tell you or you can go in your build directory for your application, presumably, target/ and find the jars in any event, ti's 3.6.2
ZEE
ZEEOP2y ago
So it's new enough
ZEE
ZEEOP2y ago
Is there a known fix for this? Did I make a mistake on some gremlin configuration I need to perform? Is there an additional adjustments I should be looking out for? (In the documents or in the code)
spmallette
spmallette2y ago
you're on one of the newer versions i mentioned so the problem is:
Client object you've initialized can't initialize the connection pool because it can't even get to the host for some reason
you need to figure out the reason for the connection pool initialization failure. i sort of would expect other error messages in the logs but you didn't present any. what have you tried? you said console was bundled with ArcadeDB...did you try to connect with that? does it work? or maybe try sending scripts to ArcadeDB as that gets you a bit closer to the metal to see the initialization failure for the Client?
ZEE
ZEEOP2y ago
They're suggesting to use https://docs.arcadedb.com/#_create-a-graph instead
spmallette
spmallette2y ago
"Connection refused: no further information" is almost like the server isn't even running
ZEE
ZEEOP2y ago
Do you know what the graph value is supposed to be set to with ArcadeDB?
graph = JanusGraphFactory.build().
set("storage.backend", "cql").
set("storage.hostname", "127.0.0.1").
open()
g = graph.traversal()
g.V().limit(1)
graph = JanusGraphFactory.build().
set("storage.backend", "cql").
set("storage.hostname", "127.0.0.1").
open()
g = graph.traversal()
g.V().limit(1)
I have been asking ArcadeDB as well, and I'm getting silence right now I haven't even been able to get their document example to work Expected 1 arguments but found 5.
MutableVertex elon = database.newVertex("User", "name", "Elon", "lastName", "Musk");
MutableVertex steve = database.newVertex("User", "name", "Steve", "lastName", "Jobs");
elon.newEdge("IsFriendOf", steve, true, "since", 2010);
MutableVertex elon = database.newVertex("User", "name", "Elon", "lastName", "Musk");
MutableVertex steve = database.newVertex("User", "name", "Steve", "lastName", "Jobs");
elon.newEdge("IsFriendOf", steve, true, "since", 2010);
spmallette
spmallette2y ago
not sure. i don't know anything about ArcadeDB. i still think there is some basic networking issue at play here. "connection refused" is fairly direct way of the driver saying, "i can't reach the server at that host and port" how did you start arcadedb?
ZEE
ZEEOP2y ago
Ran server.bat It seems to be working fine for creating vertices and their "Types" / Classes.
ZEE
ZEEOP2y ago
And g seems to exist for localhost:8182
spmallette
spmallette2y ago
the connection pool doesn't initialize until you send a request iirc, so while "g" i setup with localhost:8182 it really doesn't mean much until you send a request and you don't do that until you hit the line your debugger is at what's in config/gremlin-server.yaml ? basically this file? https://github.com/ArcadeData/arcadedb/blob/main/package/src/main/config/gremlin-server.yaml host is 0.0.0.0 in that and not localhost. i wonder if something is not binding right there with your driver trying to connect with the latter maybe play with that for a bit?
ZEE
ZEEOP2y ago
Yeah, I'll try that Same issue regardless of localhost 8182 added and server.bat restarted
Want results from more Discord servers?
Add your server