Хорошая и надежная практика подключения клиента Node.js к серверу Gremlin (все работает на одном сервере) для операций CRUD.

[В Ubuntu 18.04] у меня есть (и я вынужден использовать) janusgraph для создания хранилища персон. Я буду использовать графическую базу данных, в основном потому, что отношения персонажей так же важны, как и атрибуты персонажей, а структура должна быть гибкой. Мне нужно создать приложение Node.js (+ мопс и стилус в конечном итоге), чтобы выполнять операции CRUD с данными в graphDB, но я не понимаю, как подключить клиент к серверу. (Исследования показали решения этой проблемы, но только с другими компонентами — Neo4j, OrientDB и т. д.)

Я могу успешно запустить gremlin-server, а затем попытался создать соединение gremlin-console, например следующее:

/opt/janusgraph-0.2.2-hadoop2/bin/gremlin.sh /opt/janusgraph-0.2.2-hadoop2/conf/gremlin-server/gremlin-server.yaml

где yaml выглядит так:

(Помимо localhost, я также попробовал конкретный IP-адрес хоста, и оба варианта с квадратными скобками и без них, но с аналогичными результатами)

host: [localhost]
port: 8182
scriptEvaluationTimeout: 30000
channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer
graphs: {
  graph: conf/gremlin-server/janusgraph-cql-es-server.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.JanusGraphIoRegistryV1d0] }}
  - { 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.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

Стандартный вывод выглядит следующим образом:

         (o o)
-----oOOo-(3)-oOOo-----
plugin activated: janusgraph.imports
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/janusgraph-0.2.2-hadoop2/lib/slf4j-log4j12-1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/janusgraph-0.2.2-hadoop2/lib/logback-classic-1.1.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
16:19:01 WARN  org.apache.hadoop.util.NativeCodeLoader  - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
plugin activated: tinkerpop.hadoop
plugin activated: tinkerpop.spark
plugin activated: tinkerpop.tinkergraph
Error in /opt/janusgraph-0.2.2-hadoop2/conf/gremlin-server/gremlin-server.yaml at [1: host: [localhost]] - No such property: localhost for class: groovysh_evaluate

Ясно, что я предположил или настроил что-то неправильно, даже в консоли для сервера yaml, и я не знаю, будет ли тот же файл yaml работать для подключения клиента Node.js.

Я думаю, что мне нужно подключение к консоли, чтобы я мог импортировать начальные данные из файла graphml, а затем создавать новые записи, запрашивать их, обновлять и удалять из внешнего приложения Node.js.

Что мне нужно сделать?


person Greg    schedule 07.05.2019    source источник


Ответы (1)


Следующее не создает никаких подключений из консоли Gremlin к серверу Gremlin:

/opt/janusgraph-0.2.2-hadoop2/bin/gremlin.sh /opt/janusgraph-0.2.2-hadoop2/conf/gremlin-server/gremlin-server.yaml

gremlin.sh не принимает yaml-файл Gremlin Server в качестве аргумента. Просто запустите bin/gremlin.sh, а затем напишите команды подключения:

gremlin> :remote connect tinkerpop.server conf/remote.yaml

где remote.yaml указывает на сервер Gremlin. Вы можете подробно прочитать об этом в разных местах, но я просто укажу вам на справочную документацию TinkerPop здесь.

person stephen mallette    schedule 09.05.2019
comment
Спасибо. Это помогло мне решить проблему. - person Greg; 07.06.2019