You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by "moayad86 (GitHub)" <gi...@apache.org> on 2019/04/09 14:57:58 UTC

[GitHub] [tinkerpop] moayad86 opened pull request #1094: TINKERPOP-2195: Add finally block in HttpGremlinEndpointHandler to commit transaction

https://issues.apache.org/jira/browse/TINKERPOP-2195

An improvement is to do the serialisation first, and add a finally block to the try...catch statement, where transaction commit can take place. More information in the ticket.

[ Full content available at: https://github.com/apache/tinkerpop/pull/1094 ]
This message was relayed via gitbox.apache.org for dev@tinkerpop.apache.org

[GitHub] [tinkerpop] moayad86 commented on issue #1094: TINKERPOP-2195: Add finally block in HttpGremlinEndpointHandler to commit transaction

Posted by "moayad86 (GitHub)" <gi...@apache.org>.
We're using a custom Channelizer currently for that purpose, but it seems detaching the objects and including the additional data in the strategy is a reasonable solution.

[ Full content available at: https://github.com/apache/tinkerpop/pull/1094 ]
This message was relayed via gitbox.apache.org for dev@tinkerpop.apache.org

[GitHub] [tinkerpop] spmallette commented on issue #1094: TINKERPOP-2195: Add finally block in HttpGremlinEndpointHandler to commit transaction

Posted by "spmallette (GitHub)" <gi...@apache.org>.
I think that your implementation should configure `ReferenceElementStrategy` (which for 3.4.0 is enabled by default):

https://github.com/apache/tinkerpop/blob/7062595b72108e9545eaceb62e45b4ea7d946ed6/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/ReferenceElementStrategy.java

and which will detach your elements at iteration time when building the `ResponseMessage`. No new transaction will be opened on serialization. If you don't like the "references" that `ReferenceElementStrategy` produces then you could write your own strategy to produce "detached" objects just as easily to same effect - just used `DetachedFactory` rather than `ReferenceFactory`:

https://github.com/apache/tinkerpop/blob/7062595b72108e9545eaceb62e45b4ea7d946ed6/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedFactory.java

That should solve your problem without this change - right?

[ Full content available at: https://github.com/apache/tinkerpop/pull/1094 ]
This message was relayed via gitbox.apache.org for dev@tinkerpop.apache.org

[GitHub] [tinkerpop] moayad86 commented on issue #1094: TINKERPOP-2195: Add finally block in HttpGremlinEndpointHandler to commit transaction

Posted by "moayad86 (GitHub)" <gi...@apache.org>.
We're using a custom Channelizer currently for that purpose, but it seems detaching the objects and including the additional data in the strategy is a reasonable solution.
Thanks for the information.

[ Full content available at: https://github.com/apache/tinkerpop/pull/1094 ]
This message was relayed via gitbox.apache.org for dev@tinkerpop.apache.org

[GitHub] [tinkerpop] spmallette commented on issue #1094: TINKERPOP-2195: Add finally block in HttpGremlinEndpointHandler to commit transaction

Posted by "spmallette (GitHub)" <gi...@apache.org>.
I assume that the additional information you are adding in the custom serializer is something where you do more traversing on returned objects or gather data from other sources? I'm not sure a serializer is the best place for that. A serializer should only be about transforming the data to its network payload form and probably shouldn't contain other logic. 

A custom strategy on the other hand, seems like a better place to keep that sort of logic. You could "detach" and then add your additional data (nothing says you are restricted to detaching only in the strategy) Or, if that seems unsuitable for some reason then you should probably create a custom `Channelizer` and your own implementation of that REST endpoint.

[ Full content available at: https://github.com/apache/tinkerpop/pull/1094 ]
This message was relayed via gitbox.apache.org for dev@tinkerpop.apache.org

[GitHub] [tinkerpop] spmallette commented on issue #1094: TINKERPOP-2195: Add finally block in HttpGremlinEndpointHandler to commit transaction

Posted by "spmallette (GitHub)" <gi...@apache.org>.
I think that your implementation should configure `ReferenceElementStrategy` (which for 3.4.0 is enabled by default in Gremlin Server sample init files):

https://github.com/apache/tinkerpop/blob/7062595b72108e9545eaceb62e45b4ea7d946ed6/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/ReferenceElementStrategy.java

and which will detach your elements at iteration time when building the `ResponseMessage`. No new transaction will be opened on serialization. If you don't like the "references" that `ReferenceElementStrategy` produces then you could write your own strategy to produce "detached" objects just as easily to same effect - just used `DetachedFactory` rather than `ReferenceFactory`:

https://github.com/apache/tinkerpop/blob/7062595b72108e9545eaceb62e45b4ea7d946ed6/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedFactory.java

That should solve your problem without this change - right?

[ Full content available at: https://github.com/apache/tinkerpop/pull/1094 ]
This message was relayed via gitbox.apache.org for dev@tinkerpop.apache.org

[GitHub] [tinkerpop] moayad86 commented on issue #1094: TINKERPOP-2195: Add finally block in HttpGremlinEndpointHandler to commit transaction

Posted by "moayad86 (GitHub)" <gi...@apache.org>.
ReferenceElementStrategy or a strategy which uses DetachedFactory will solve the problem of detaching the objects, but we're using a custom JSON serializer to include additional information. I guess it's not going to be possible to include those information in that case.

[ Full content available at: https://github.com/apache/tinkerpop/pull/1094 ]
This message was relayed via gitbox.apache.org for dev@tinkerpop.apache.org