我正在尝试使用 Titan Graph DB 对网络拓扑进行建模。我想从 Python 应用程序中指定拓扑。
我有一个使用 tinkertop 框架注释的 java 接口(interface)文件。下面给出了一个示例结构。
public interface IDeviceObject extends IBaseObject {
@JsonProperty("mac")
@Property("dl_addr")
public String getMACAddress();
@Property("dl_addr")
public void setMACAddress(String macaddr);
@JsonProperty("ipv4")
@Property("nw_addr")
public String getIPAddress();
@Property("nw_addr")
public void setIPAddress(String ipaddr);
@JsonIgnore
@Adjacency(label="host",direction = Direction.IN)
public Iterable<IPortObject> getAttachedPorts();
@JsonIgnore
@Adjacency(label="host",direction=Direction.IN)
public void setHostPort(final IPortObject port);
@JsonIgnore
@Adjacency(label="host",direction=Direction.IN)
public void removeHostPort(final IPortObject port);
@JsonIgnore
@GremlinGroovy("it.in('host').in('on')")
public Iterable<ISwitchObject> getSwitch();
}
PYTHON OBJECTS ----> BULBS ----> REXTER ---> Titan Graph DB ---> Cassandra DB
(1) BULBS将python对象转为Graphs (2) Rexter将Graphs转JSON (3) Titan将JSON转回Graphs?? (4) 并且也写入cassandra store
看起来我做事的方式很绕,我错过了什么?如果有人能指出上述内容有什么问题,那就太好了?
最佳答案
你的图表:
PYTHON OBJECTS ----> BULBS ----> Rexster ---> Titan Graph DB ---> Cassandra DB
看起来或多或少是正确的,这取决于你想如何看待所涉及的抽象。您也可以将其定义为:
PYTHON OBJECTS ----> BULBS ----> Rexster/Titan ---> Cassandra DB
由于 Rexster 基本上嵌入了一个 Titan 实例,它通过 REST 公开供 Bulbs 使用。这部分不太正确:
- BULBS 将 python 对象转换为图形
- Rexter 将图形转换为 JSON
- Titan 将 JSON 转换回图形??
- 也写信给cassandra store
我会说:
- Titan 是一个 Blueprints写入 Cassandra 的实现
- Rexster 使用 JSON 通过 REST 托管蓝图实现并公开该 API 的元素(和 Gremlin)
- Bulbs 是基于 Rexster 的 Python 对象映射层。
归根结底,Python 与 Titan 没有直接联系。 Titan 具有基于 JVM 的蓝图接口(interface),并使用 Rexster 作为非 JVM 语言与其对话的方式。
关于python - 从 Python 使用 Titan Graph 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23190344/