1

我正在使用 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

我在物理连接的端口之间创建标记边缘。我使用的标签是“链接”。

假设我有两个端口顶点portAportB.

我想检查是否从我使用的灯泡包portA连接到。portBpython program

作为第一步。我写了一个脚本(保存在一个文件中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 程序中调用这个脚本使用灯泡。如果有人能指出我正确的方向,那就太好了!

4

1 回答 1

1

?e命令要求您指定要在同一行中执行的文件。我创建了sum.groovy

def sum(x,y) { x+y }

然后从控制台:

rexster[groovy]> ?e sum.groovy
==>null
rexster[groovy]> sum(1,2)
==>3

奇怪的是,没有文件的指定?e不会做正确的换行。我会试着去解决这个问题。

于 2014-07-16T10:33:00.160 回答