Хорошая и надежная практика подключения клиента Node.js к серверу gremlin (все работают на одном сервере) для операций CRUD. - PullRequest
0 голосов
/ 07 мая 2019

[в Ubuntu 18.04] У меня есть (и я вынужден использовать) janusgraph для создания репозитория персон. Я буду использовать graphDB, в основном потому, что личные отношения так же важны, как и личные атрибуты, а структура должна быть плавной. Мне нужно создать приложение Node.js (+ pug & stylus в конце концов) для выполнения CRUD операций с данными в графе DB, но я не понимаю, как подключить клиента к серверу. (Исследования показали решения этой проблемы, но только с различными компонентами - 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

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

(Как и 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.

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

1 Ответ

1 голос
/ 09 мая 2019

Следующее не создает никаких соединений из Gremlin Console с Gremlin Server:

/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 в качестве аргумента.Просто запустите bin/gremlin.sh и затем напишите команды подключения:

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

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

...