2

我对 janusgraph gremlin-server 和 Cluster 客户端有问题。使用 Cluster (gremlin-driver 3.2.3/3.2.5) 检索的顶点仅包含 id 属性、标签和属性始终为空。

这是我的客户端配置。

val cluster = Cluster.open("/opt/janusgraph-0.1.1-hadoop2/conf/remote-objects.yaml")

远程对象.yaml

hosts: [localhost] 
   port: 8182
   serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}

gremlin 服务器配置:

host: localhost
port: 8182
scriptEvaluationTimeout: 30000
channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer
graphs: {
  graph: conf/gremlin-server/graph.properties}
plugins:
  - janusgraph.imports
scriptEngines: {
  gremlin-groovy: {
    imports: [java.lang.Math],
    staticImports: [java.lang.Math.PI],
    scripts: [scripts/empty-sample.groovy]}}
serializers:
  - { 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.GraphSONMessageSerializerGremlinV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
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
ssl: {enabled: false}

使用 gremlin-console 的远程查询工作正常(remote.yaml 和 remote-objects.yaml)

使用集群和远程遍历的查询不起作用:

val g = EmptyGraph.instance().traversal().withRemote(DriverRemoteConnection.using(cluster, "g"))

g.V().toList.foreach(v => println(v, "id", v.id(), "label", v.label(), v.properties("name").toList, v.getClass))

输出:

(v[8336],id,8336,label,,List(),class org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex)
(v[12288],id,12288,label,,List(),class org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex)
(v[12304],id,12304,label,,List(),class org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex)
(v[12328],id,12328,label,,List(),class org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex)
(v[12360],id,12360,label,,List(),class org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex)

我做错了什么?

4

1 回答 1

4

当您尝试使用远程图时,您将得到ReferenceElements其中包含的信息最少的信息。不幸的是,目前没有很多关于这方面的文档(我已经打开了一张票来解决这个问题),但你可以参考这个邮件列表线程

远程遍历工作正常,但您应该更明确地提出您的要求。例如,如果你想要id,label和 all properties,你可以使用:

g.V().valueMap(true).toList()
于 2017-08-20T20:40:53.727 回答