【发布时间】:2014-09-06 08:04:39
【问题描述】:
我正在使用 TitanGraphDB + Cassandra。我正在按如下方式启动 Titan
cd titan-cassandra-0.3.1
bin/titan.sh config/titan-server-rexster.xml config/titan-server-cassandra.properties
我有一个 Rexster shell,可以用来与上面的 Titan+Cassandra 通信。
cd rexster-console-2.3.0
bin/rexster-console.sh
我正在尝试使用 Titan Graph DB 对网络拓扑进行建模。我想从我的 python 程序中对 Titan Graph DB 进行编程。我正在为此使用灯泡包。 我创建了三种类型的顶点
- switch
- port
- device
我在物理连接的端口之间创建带标签的边缘。我使用的标签是“链接”。
假设我有两个端口顶点portA 和portB。
我想使用灯泡包检查portA 是否从我的python program 连接到portB。
作为第一步。我写了一个脚本(保存在一个文件is_connected.sh)
def is_connected(portA, portB):
return portA.both("link").retain([portB]).hasNext()
如果我尝试从我的 rexster-console 执行上述脚本,如下所示,我会得到以下结果。
sudo ./start_rexter.sh
(l_(l
(_______( 0 0
( (-Y-) <woof>
l l-----l l
l l,, l l,,
opening session [127.0.0.1:8184]
?h for help
rexster[groovy]> ?e
specify the file to executerexster[groovy]> is_connected.sh
==>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: is_connected for class: Script2
这是我第一次尝试编写存储过程(又名 gremlin 脚本)。我不知道这是否是处理它的正确方法。我的最终目标是能够从我的使用灯泡的 python 程序。如果有人能指出我正确的方向,那就太好了!
【问题讨论】:
-
不清楚你想做什么。您的代码是 Python 语法,但使用了 Groovy 中定义的方法(retain、hasNext),并且您希望在理解 Groovy 而不是 Python 的 rexster 控制台中运行它。请注意,bulbs 在 Python 中本机实现了一小部分方法(inV、outV、...),但即使您使用灯泡,也必须在适当的 Groovy 中编写较大的脚本。
-
以上是@Tohotom 的好建议,但我仍然喜欢这个问题和方法。这是通往稍微复杂一点的道路上的一小步。让它工作,然后担心如何用灯泡做事。
标签: cassandra gremlin titan bulbs