JanusGraph服务器模式之ConfiguredGraphFactory配置
程序员文章站
2024-01-19 13:25:58
...
ConfiguredGraphFactory配置模式使JanusGraph的服务器模式更为灵活,即可以在服务器运行中动态添加、修改、删除图配置。
实现方式是利用*管理方式,创建一个ConfigurationManagementGraph的图,管理所有业务的图。
一、配置properties
/path/to/janusgraph-0.5.2/conf/gremlin-server/gremlin-server-hbase-configurationgraph.properties
路径和名称根据实际情况修改
gremlin.graph=org.janusgraph.core.ConfiguredGraphFactory
storage.backend=hbase
graph.graphname=ConfigurationManagementGraph
storage.hostname=127.0.0.1
cache.db-cache = true
cache.db-cache-clean-wait = 20
cache.db-cache-time = 180000
cache.db-cache-size = 0.5
index.search.backend=elasticsearch
index.search.hostname=127.0.0.1:9200
index.search.elasticsearch.http.auth.type=basic
index.search.elasticsearch.http.auth.basic.username=admin
index.search.elasticsearch.http.auth.basic.password=admin
# 这个对建索引很关键,在我的环境中不配置会报错
graph.timestamps=MICRO
二、配置yaml
/path/to/janusgraph-0.5.2/conf/gremlin-server/gremlin-server-ws-configurationgraph.yaml
路径和名称根据实际情况修改
host: 127.0.0.1
port: 8182
scriptEvaluationTimeout: 30000
channelizer: org.janusgraph.channelizers.JanusGraphWsAndHttpChannelizer
graphManager: org.janusgraph.graphdb.management.JanusGraphManager
graphs: {
ConfigurationManagementGraph: conf/gremlin-server/gremlin-server-hbase-configurationgraph.properties
}
scriptEngines: {
gremlin-groovy: {
plugins: { org.janusgraph.graphdb.tinkerpop.plugin.JanusGraphGremlinPlugin: {},
org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {},
org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {},
org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]},
org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: []}}}}
serializers:
- { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
- { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0, config: { serializeResultToString: true }}
- { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
# Older serialization versions for backwards compatibility:
- { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
- { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: {ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
- { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}
- { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
- { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistryV1d0] }}
- { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistryV1d0] }}
processors:
- { className: org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor, config: { sessionTimeout: 28800000 }}
- { className: org.apache.tinkerpop.gremlin.server.op.traversal.TraversalOpProcessor, config: { cacheExpirationTime: 600000, cacheMaxSize: 1000 }}
metrics: {
consoleReporter: {enabled: true, interval: 180000},
csvReporter: {enabled: true, interval: 180000, fileName: /tmp/gremlin-server-metrics.csv},
jmxReporter: {enabled: true},
slf4jReporter: {enabled: true, interval: 180000},
gangliaReporter: {enabled: false, interval: 180000, addressingMode: MULTICAST},
graphiteReporter: {enabled: false, interval: 180000}}
maxInitialLineLength: 4096
maxHeaderSize: 8192
maxChunkSize: 8192
maxContentLength: 65536
maxAccumulationBufferComponents: 1024
resultIterationBatchSize: 64
writeBufferLowWaterMark: 32768
writeBufferHighWaterMark: 65536
三、启动
cd /path/to/janusgraph-0.5.2
bin/gremlin-server.sh conf/gremlin-server/gremlin-server-ws-configurationgraph.yaml
四、使用
bin/gremlin.sh
gremlin> :remote connect tinkerpop.server conf/remote.yaml session
gremlin> :remote console
gremlin> map = new HashMap<String, Object>();
gremlin> map.put("storage.backend", "hbase");
gremlin> map.put("storage.hostname", "127.0.0.1");
gremlin> map.put("storage.hbase.table", "graph1");
gremlin> map.put("graph.graphname", "graph1");
gremlin> map.put("graph.timestamps", "MICRO"); // 必须先配置,后期更新感觉无法用
gremlin> ConfiguredGraphFactory.createConfiguration(new MapConfiguration(map));
// 在这个阶段只是创建了配置,底层HBASE中并没有创建对应的graph1这个表
gremlin> graph1 = ConfiguredGraphFactory.open("graph1");
// 此时需要等待20秒左右,查看HBASE会出现graph1这个表
gremlin> graph1_traversal = graph1.traversal();
// 执行到此处后,下次需要使用graph1 和 graph1_traversal 不需要像以下进行复制,可直接
gremlin> graph1
gremlin> graph1_traversal
gremlin> graph1_traversal.V().size();
==>0
五、参考文献
https://github.com/JanusGraph/janusgraph/blob/master/docs/basics/configured-graph-factory.md
上一篇: vue+echarts+map绘制散点图
下一篇: tf读取数据
推荐阅读
-
JanusGraph服务器模式之ConfiguredGraphFactory配置
-
JanusGraph 服务器-配置ConfiguredGraphFactory
-
janusgraph使用ConfiguredGraphFactory配置动态创建图
-
Oracle 10备份与恢复之归档模式配置
-
Nginx之代理配置以及负载均衡 nginx 负载 负载均衡 服务器负载均衡软
-
C#设计模式之Builder生成器模式解决带老婆配置电脑问题实例
-
C#设计模式之Builder生成器模式解决带老婆配置电脑问题实例
-
服务器组装技术之LSI RAID配置硬盘热备图解
-
Nginx学习之静态文件服务器配置方法
-
Windows Server 2016 服务器配置指南之IIS10安装方法