1

I'm using TitanGraphDB + Cassandra. I'm starting Titan as follows

cd titan-cassandra-0.3.1
bin/titan.sh config/titan-server-rexster.xml config/titan-server-cassandra.properties

I have a Rexster shell that I can use to communicate to Titan + Cassandra above.

cd rexster-console-2.3.0
bin/rexster-console.sh

I'm attempting to model a network topology using Titan Graph DB. I want to program the Titan Graph DB from my python program. I'm using bulbs package for that. I create five types of vertices

 - switch
 - port 
 - device
 - flow
 - flow_entry

I create edges between vertices that are connected logically. The edges are not labelled.

Let us say I want to test the connectivity between Vertex A and Vertex B

I have a groovy script is_connected.groovy

def isConnected (portA, portB) {
    return portA.both().retain([portB]).hasNext()
}

Now from my rexster console

g = rexster.getGraph("graph")
==>titangraph[embeddedcassandra:null]
rexster[groovy]> g.V('type', 'flow')    
==>v[116]
==>v[100]
rexster[groovy]> g.V('type', 'flow_entry')
==>v[120]
==>v[104]

As you can see above I have two vertices of type flow v[116] and v[100]

I have two vertices of type flow_entry v[120] and v[104]

I want to check for the connectivity between v[120] and v[116] for e.g

rexster[groovy]> ?e is_connected.groovy       
==>null
rexster[groovy]> is_connected(g.v[116],g.v[120])
==>An error occurred while processing the script for language [groovy]. All transactions across all graphs in the session have been concluded with failure: java.util.concurrent.ExecutionException: javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: v for class: com.thinkaurelius.titan.graphdb.database.StandardTitanGraph

Either I am doing something very wrong,or I am missing something obvious.It would be great if you could point me in the right direction.

2 Answers 2

2

This syntax is not valid groovy:

is_connected(g.v[116],g.v[120])

should be:

is_connected(g.v(116),g.v(120))
1
  • 1
    Note his Gremlin-Groovy script's function definition is Groovy-style camelCase isConnected(), but in the Rexster console he's using Python-style snake_case is_connected() -- that won't work.
    – espeed
    Jul 20, 2014 at 22:23
1

You're mixing up Python syntax with Gremlin-Groovy syntax:

You defined the Groovy script as:

def isConnected (portA, portB) {
    return portA.both().retain([portB]).hasNext()
}

...so...

rexster[groovy]> is_connected(g.v[116], g.v[120])

...should be...

rexster[groovy]> isConnected(g.v(116), g.v(120))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.