How to confirm successful completion of Client commands

16 views
Skip to first unread message

Patrick Aupperle

unread,
Jun 14, 2018, 3:09:13 PM6/14/18
to Gremlin-users
I am implementing an application which makes heavy use of the Client class to submit commands to a gremlin server, but it seems there is no good way to confirm they're successful completion without retrieving the result. In some cases, the result appears not to be serializable, so simply retrieving it is not an option in some cases. Even in the cases, though, I would like to confirm that the command completed without error. Is there any way to check this?

Stephen Mallette

unread,
Jun 14, 2018, 3:19:33 PM6/14/18
to Gremlin-users
I'm not sure what you're looking to have as a confirmation. If you send g.addV() to the server and no exception is raised on the client, you should take that as a success. Are you seeing a situation where that is not the case? 

In some cases, the result appears not to be serializable, so simply retrieving it is not an option in some cases.

Under what scenario does that happen? Can you provide more details please?

On Thu, Jun 14, 2018 at 3:09 PM Patrick Aupperle <patrick...@gmail.com> wrote:
I am implementing an application which makes heavy use of the Client class to submit commands to a gremlin server, but it seems there is no good way to confirm they're successful completion without retrieving the result. In some cases, the result appears not to be serializable, so simply retrieving it is not an option in some cases. Even in the cases, though, I would like to confirm that the command completed without error. Is there any way to check this?

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/7fedc719-ffc4-48ef-b519-287524916b64%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Patrick Aupperle

unread,
Jun 14, 2018, 3:33:37 PM6/14/18
to Gremlin-users
At the point where the call returns, the command has been successfully submitted, but not necessarily completed (hence submit returning a future instead of and actual value). At the point of return, a failure should still be possible. I have observed failures like this. The easiest example is this:
System.out.println("setting test");
client.submit("test = 'value'");
System.out.println("getting test");
System.out.println(client.submit("test").one().getString());
System.out.println("setting test2");
client.submit("test2 = value2'");
System.out.println("getting test2");
System.out.println(client.submit("test2").one().getString());


The output I get from this is:
setting test
getting test
value
setting test2
getting test2
java
.util.concurrent.CompletionException: org.apache.tinkerpop.gremlin.driver.exception.ResponseException: No such property: test2 for class: Script3027


As you can see, no error from setting test 2, but the value is not set, because there was an error in the line that set it.

Stephen Mallette

unread,
Jun 14, 2018, 3:47:34 PM6/14/18
to Gremlin-users
oh...then do:

client.submit(...).all().get()

then it will block until all the message frames have been accounted for (or an exception is raised). as an aside to your example, note that:

client.submit("test2 = value2'");
client.submit("test2").all().get()

will till result in an error unless for some reason you are using sessions.


We typically recommend that you try to avoid using those, but sometimes the use case is such that you're stuck with them I suppose.

Patrick Aupperle

unread,
Jun 14, 2018, 4:01:41 PM6/14/18
to Gremlin-users
The problem is that there are some objects that are not serializable (ex, JanusGraphManagement), and attempting to do ".all().get()" produces an exception, despite the command running successfully. 

There are parts of my application where the session appears unavoidable. 

Stephen Mallette

unread,
Jun 14, 2018, 4:18:39 PM6/14/18
to Gremlin-users
Well, you shouldn't be returning a JanusGraphManagement object. Any reason why the return of that object would indicate a success? I mean, you're usually calling some method of JanusGraphManagement. Are you saying that return objects from those methods return things that aren't serializable? If so, then just don't return that object and return something else. Send something like this to fix your serialization problem:

JanusGraphManagement.methodThatReturnsSomethingNonserializable();[]

In the above script,  methodThatReturnsSomethingNonserializable() will complete (or throw an exception) and then the result is tacked on at the end - an empty list which will serialize just fine. 

Reply all
Reply to author
Forward
0 new messages