Traversal clone anomolies

42 views
Skip to first unread message

JPT

unread,
Mar 26, 2018, 7:00:49 PM3/26/18
to DataStax Java Driver for Apache Cassandra User Mailing List
Upon migrating from JanusGraph I have encountered some situations where traversal cloning does not function as expected. In most cases the solution of beginning the traversal anew is straightforward enough. But in others, where partially complete traversals are passed to methods that expect to be able to clone them, a solution is not as easy (although, as a stopgap, I have resorted to passing anonymous traversals to the methods and having them instead pass them to V().inject(1).flatMap, which seems clumsy). Given the two exceptions fielded in the code below, might someone provide insight as to whether I am doing something wrong or have uncovered a bug? I should note that I have tried, unsuccessfully, redundantly cloning the traversals just prior to calling range in the first scenario and property in the second.

Thanks!

JP

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Vertex;

import com.datastax.driver.dse.DseCluster;
import com.datastax.driver.dse.DseSession;
import com.datastax.driver.dse.graph.GraphOptions;
import com.datastax.driver.dse.graph.SimpleGraphStatement;
import com.datastax.dse.graph.api.DseGraph;

public class DseTest {
    public static void main(String args[]) {
        DseSession session = DseCluster
            .builder()
            .addContactPoint("127.0.0.1")
            .withGraphOptions(new GraphOptions().setGraphName("test"))
            .build()
            .connect();

        session.executeGraph(new SimpleGraphStatement("system.graph('test').ifNotExists().create()").setSystemQuery());
        session.executeGraph("schema.config().option('graph.schema_mode').set('Production')");
        session.executeGraph("schema.propertyKey('id').Int().single().ifNotExists().create()");
        session.executeGraph("schema.vertexLabel('label').properties('id').ifNotExists().create()");
        session.executeGraph("schema.vertexLabel('label').index('label_by_id').materialized().by('id').ifNotExists().add()");

        GraphTraversalSource source = DseGraph.traversal(session);

        if (source.V().has("label", "id", 1).count().next() == 0) {
            source.addV("label").property("id", 1).iterate();
        }

        try {
            GraphTraversal<Vertex, Vertex> traversal = source.V().has("label", "id", 1);
            Object unused = traversal.asAdmin().clone().count().next();
            Vertex vertex = traversal.range(0, 1).next(); // returns same Long value as above
        }
        catch (Exception e) {
            // java.lang.ClassCastException: java.lang.Long cannot be cast to org.apache.tinkerpop.gremlin.structure.Vertex
            System.out.println(e.toString());
        }

        try {
            GraphTraversal<Vertex, Vertex> traversal = source.V().has("label", "id", 1);
            Object unused = traversal.asAdmin().clone().valueMap().next();
            traversal.property("id", 2).iterate(); // fails with no detail in exception
        }
        catch (Exception e) {
           // com.datastax.driver.core.exceptions.InvalidQueryException:
           System.out.println(e.toString());
        }
    }
}


Kevin Gallardo

unread,
Mar 27, 2018, 4:14:29 PM3/27/18
to java-dri...@lists.datastax.com
Hi, 

I tested your example and was able to reproduce indeed this strange behavior. It seems to be a TinkerPop issue that has been apparently fixed in TinkerPop 3.3.0, putting a dependency to TinkerPop 3.3.0+ should resolve the issue, not sure what the exact issue is yet but for now I'd recommend updating to a newer TinkerPop version. Our next DSE driver minor version will ship with TinkerPop 3.3.0+.

Hope that helps.

--
You received this message because you are subscribed to the Google Groups "DataStax Java Driver for Apache Cassandra User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-user+unsubscribe@lists.datastax.com.



--
Kévin Gallardo.
Software Developer in Drivers and Tools Team,
DataStax.

Kevin Gallardo

unread,
Mar 27, 2018, 4:27:54 PM3/27/18
to java-dri...@lists.datastax.com
Ok, I think the fix for your issue was https://github.com/apache/tinkerpop/commit/e59124e7e82352cca60a5dd8ef2ab7c9c75198ee. Can you tell us which tinkerpop/DSE Driver version you are using?

Without this fix, when cloning a traversal you would clone everything except the bytecode, which contains the steps composing the traversal, so sounds like a legitimate bug that has been fixed in TinkerPop 3.2.6 / 3.3.1.

Our latest minor version of the DSE driver 1.5.1 currently depends on TinkerPop 3.2.5 which doesn't have the fix. We'll update this dependency to at least 3.2.6 in our next release, in the meantime you can add yourself a dependency to TinkerPop 3.2.6 and it should hopefully resolve the issue (3.2.7 is the current latest TP).

Cheers.
Message has been deleted

Kevin Gallardo

unread,
Mar 28, 2018, 11:04:56 AM3/28/18
to java-dri...@lists.datastax.com

Pavani T

unread,
Mar 29, 2018, 3:27:18 AM3/29/18
to java-dri...@lists.datastax.com
Hi,

I am connecting remote cassandra cluster through jconsole. I set the below properties in cassandra-env.sh

JMX_PORT="7199"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.rmi.port=$JMX_PORT"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=true"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=false"
JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=x.x.x.x"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote"

I am getting this error when i debug the jconsole through jconsole -debug x.x.x.x:7199 

java.lang.SecurityException: Expecting a javax.rmi.ssl.SslRMIClientSocketFactory RMI client socket factory in stub!
at javax.management.remote.rmi.RMIConnector.checkStub(RMIConnector.java:1901)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:295)
at sun.tools.jconsole.ProxyClient.tryConnect(ProxyClient.java:355)
at sun.tools.jconsole.ProxyClient.connect(ProxyClient.java:313)
at sun.tools.jconsole.VMPanel$2.run(VMPanel.java:294)

please somebody help me out from this issue.

Thanks && Regards
pavs

Reply all
Reply to author
Forward
0 new messages