如果对您有有用,麻烦右边点个赞哦~~
资料查阅
- 先查https://docs.janusgraph.org
- https://docs.janusgraph.org查不到查http://s3.thinkaurelius.com/docs/titan/1.0.0/
- 之后试试StackOverflow
远程连接JanusGraph Server(即gremlin-server)
JanusGraph数据库配置(官网中文翻译).https://blog.csdn.net/wzwdcld/article/details/82082760
JanusGraph·server端配置启动和远程remote连接·多实例问题 https://blog.csdn.net/wzwdcld/article/details/81460193
远程连接方法一
- Java 操作JanusGraph. http://www.k6k4.com/chapter/show/aafiizxav1531746415578
- 上文配置改in-memory,即可在应用程序内使用嵌入式Janus写入数据和查询数据
- 有人说把文中 127.0.01,改远程地址,即可远程写入数据和查询数据,我还没有试验过
- 不需要写序列化数据的代码
远程连接方法二
- 官方github的examples,下载这个文件夹,用IDEA下载,其中有多个Maven模块,找到remote模块,其依赖于commons模块
- <<janusgraph-examples.zip>>
- 具体的:下图中的RemoteGraphAPP继承自JanusGraphApp,JanusGraphApp继承自GraghApp.java
-
RemoteGraphApp中只有 远程连接 和 打开Graph的逻辑, 创建Schema和其他元素的逻辑由 JanusGraphApp完成
<<janusgraph-examples.zip>>
上面压缩包里的项目从 RemoteGraphApp出运行,可以直接跑通, 服务器端可以查询到数据。
-
程序运行逻辑:
-
RemoteGraphApp的main函数
-
RemoteGraphApp的构造函数
-
JanusGraphApp的构造函数
-
GraphApp的构造函数
-
RemoteGraphApp实例调用runApp(),进入GraphApp的runApp();
-
RemoteGraphApp的openGraph()
-
client = cluster.connect(); 连接远端服务器
-
graph = Empt g = graph.tr return g;
-
- RemoteGraphApp的createSchema()
-
final String req = JanusGraphApp.createSchemaRequest();
-
final ResultSet resultSet = client.submit(req); //客户端提交gremlin的Schema的请求语句,并获得返回结果
-
- RemoteGraphApp.createElements()
- 远程测试结果:
- GraphApp.readElements()//测试读数据
- GraphApp.updateElements() //测试更新数据
- GraphApp.deleteElements() //测试删除一个顶点
- RemoteApp.closeGraph();
- GraphApp.closeGraph();
-
- 远程服务器,通过bin下面的脚本 janus.sh启动
- 更改remote模块中的配置文件remote-objects.yaml为
-
hosts: [10.158.69.75] port: 8182 serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { bufferSize: 8192, useMapperFromGraph: graph, ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry], serializeResultToString: false, custom: [org.janusgraph.graphdb.relations.RelationIdentifier] }
- 更改commons模块中的的 createSchemaRequest() 里的序列化(字符串)逻辑
- 该字符串将创建schema、创建具体元素的代码序列化到一句请求字符串中
- 所以需要写序列化请求内容的代码,此处有些繁琐
- 验证可用
JanusGraph数据库操作
JanusGraph实战笔记·数据写入·查询. https://blog.csdn.net/wzwdcld/article/details/81275923
Java in-memory嵌入式创建schema,解析ttl文件,写入Janus并批量查询的代码:
- 见我的微云同步盘:https://share.weiyun.com/54qS919
- 可视化插件
- Graphexp
- Gremlin官网上的介绍:Graphexp - Interactive visualization of the Gremlin graph database with D3.js.
- Cytoscape
- Apache TinkerPop的Gephi插件
- KeyLines by Cambridge Intelligence
- Linkurious
- Graphexp
图解JanusGraph内部数据存储结构. https://cloud.tencent.com/developer/news/206999
我的博客即将同步至腾讯云+社区,邀请大家一同入驻:https://cloud.tencent.com/developer/support-plan?invite_code=3l3al4ql8ou8o