我有Titan(在我的系统上运行嵌入式cassandra)。
cd titan-cassandra-0.3.1
bin/titan.sh config/titan-server-rexster.xml config/titan-server-cassandra.properties
我运行了rexster服务器
cd rexster-console-2.3.0
bin/rexster-console.sh
我可以使用Gremlin查询从rexter shell创建一个图形。
g = rexster.getGraph("graph")
v1 = g.addVertex([name:"s1"])
v2 = g.addVertex([name:"s2"])
e1 = g.addEdge(v1, v2, "likes")
我在我的系统上安装了灯泡,如下所示。
sudo apt-get install python2.7-dev
sudo apt-get install libyaml-dev
sudo pip install https://github.com/espeed/bulbs/tarball/master
如果我在我的机器上从ipython尝试以下内容
In [1]: from bulbs.rexster import Graph
In [2]: g = Graph()
我收到以下错误。
---------------------------------------------------------------------------
LookupError Traceback (most recent call last)
/home/karthik/Projects/ryu_extras/<ipython-input-2-eb1ac0314e67> in <module>()
----> 1 g = Graph()
/usr/local/lib/python2.7/dist-packages/bulbs/rexster/graph.pyc in __init__(self, config)
54
55 def __init__(self, config=None):
---> 56 super(Graph, self).__init__(config)
57
58 # Rexster supports Gremlin
/usr/local/lib/python2.7/dist-packages/bulbs/base/graph.pyc in __init__(self, config)
56 self.factory = Factory(self.client)
57
---> 58 self.vertices = self.build_proxy(Vertex)
59 self.edges = self.build_proxy(Edge)
60
/usr/local/lib/python2.7/dist-packages/bulbs/base/graph.pyc in build_proxy(self, element_class, index_class)
122 if not index_class:
123 index_class = self.default_index
--> 124 return self.factory.build_element_proxy(element_class, index_class)
125
126 def load_graphml(self, uri):
/usr/local/lib/python2.7/dist-packages/bulbs/factory.pyc in build_element_proxy(self, element_class, index_class, index_name)
17 proxy_class = element_class.get_proxy_class()
18 element_proxy = proxy_class(element_class, self.client)
---> 19 primary_index = self.get_index(element_class,index_class,index_name)
20 element_proxy.index = primary_index
21 return element_proxy
/usr/local/lib/python2.7/dist-packages/bulbs/factory.pyc in get_index(self, element_class, index_class, index_name)
25 index_name = element_class.get_index_name(self.client.config)
26 index_proxy = self.build_index_proxy(element_class, index_class)
---> 27 index = index_proxy.get_or_create(index_name)
28 return index
29
/usr/local/lib/python2.7/dist-packages/bulbs/rexster/index.pyc in get_or_create(self, index_name, index_params)
78
79 """
---> 80 resp = self.client.get_or_create_vertex_index(index_name, index_params)
81 index = self.index_class(self.client,resp.results)
82 self.client.registry.add_index(index_name, index)
/usr/local/lib/python2.7/dist-packages/bulbs/rexster/client.pyc in get_or_create_vertex_index(self, index_name, index_params)
666 script = self.scripts.get('get_or_create_vertex_index')
667 params = dict(index_name=index_name, index_params=index_params)
--> 668 resp = self.gremlin(script, params)
669 #assert "MANUAL" in resp.content['results'][0]
670 result = {'name': index_name, 'type': 'manual', 'class': 'vertex'}
/usr/local/lib/python2.7/dist-packages/bulbs/rexster/client.pyc in gremlin(self, script, params, load)
354 if self.config.server_scripts is True:
355 params["load"] = load or [self.scripts.default_namespace]
--> 356 return self.request.post(gremlin_path, params)
357
358
/usr/local/lib/python2.7/dist-packages/bulbs/rest.pyc in post(self, path, params)
129
130 """
--> 131 return self.request(POST, path, params)
132
133 def delete(self, path, params=None):
/usr/local/lib/python2.7/dist-packages/bulbs/rest.pyc in request(self, method, path, params)
184 http_resp = self.http.request(uri, method, body, headers)
185
--> 186 return self.response_class(http_resp, self.config)
187
188
/usr/local/lib/python2.7/dist-packages/bulbs/rexster/client.pyc in __init__(self, response, config)
196 def __init__(self, response, config):
197 self.config = config
--> 198 self.handle_response(response)
199 self.headers = self.get_headers(response)
200 self.content = self.get_content(response)
/usr/local/lib/python2.7/dist-packages/bulbs/rexster/client.pyc in handle_response(self, http_resp)
220 headers, content = http_resp
221 response_handler = RESPONSE_HANDLERS.get(headers.status)
--> 222 response_handler(http_resp)
223
224 def get_headers(self,response):
/usr/local/lib/python2.7/dist-packages/bulbs/rest.pyc in not_found(http_resp)
37
38 def not_found(http_resp):
---> 39 raise LookupError(http_resp)
40 #return None
41
LookupError: ({'status': '404', 'transfer-encoding': 'chunked', 'server': 'grizzly/2.2.16', 'date': 'Sat, 10 May 2014 06:22:49 GMT', 'access-control-allow-origin': '*', 'content-type': 'application/json'}, '{"message":"Graph [emptygraph] could not be found"}')
这是什么意思?
答案 0 :(得分:4)
Titan有自己的模块......
>>> from bulbs.titan import Graph
>>> g = Graph()