Java - Neo4j 3.0.0-M01嵌入式螺栓配置

时间:2016-11-22 19:40:29

标签: java apache-spark neo4j connector

我正在使用我的java项目的neo4j 3.0.0-M01的EMBEDDED版本和neo4j-spark连接器,我无法正确配置bolt。

关于连接器(https://github.com/neo4j-contrib/neo4j-spark-connector)的官方github项目的说明仅指运行独立服务器的情况(例如在localhost上),这不是我的情况。

以下是我的项目中涉及bolt配置的代码片段:

SparkConf conf = new SparkConf().setAppName("TestApp").setMaster("local[8]");
    conf.set("spark.neo4j.bolt.url","bolt://C/neo4j_test/neo4j-community-3/data/graph-repo.db");

如果我对包含conf.set()方法的行进行注释,则在端口7474上的localhost上启动独立(不是嵌入式)neo4j服务器,然后执行我的代码,连接成功。否则我得到这个例外:

java.lang.IllegalArgumentException: hostname can't be null
at java.net.InetSocketAddress.checkHost(Unknown Source)
at java.net.InetSocketAddress.<init>(Unknown Source)
at org.neo4j.driver.internal.connector.socket.SocketClient$ChannelFactory.create(SocketClient.java:243)
at org.neo4j.driver.internal.connector.socket.SocketClient.start(SocketClient.java:75)
at org.neo4j.driver.internal.connector.socket.SocketConnection.<init>(SocketConnection.java:63)
at org.neo4j.driver.internal.connector.socket.SocketConnector.connect(SocketConnector.java:52)
at org.neo4j.driver.internal.pool.InternalConnectionPool.acquire(InternalConnectionPool.java:113)
at org.neo4j.driver.internal.InternalDriver.session(InternalDriver.java:53)
at org.neo4j.spark.Executor$.execute(Neo4j.scala:360)
at org.neo4j.spark.Neo4jRDD.compute(Neo4j.scala:408)
at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:319)
at org.apache.spark.rdd.RDD.iterator(RDD.scala:283)
at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:70)
at org.apache.spark.scheduler.Task.run(Task.scala:86)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:274)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

即使是Neo4j手册也没有解释如何引用嵌入式实例,正如您在第4章的以下摘录中所看到的那样:(https://neo4j.com/docs/developer-manual/current/drivers/):

4.3.1.1。 Bolt URI格式

Bolt URI遵循scheme:// host:port的标准URI模式。例如,bolt://203.0.113.1:1234将使用Bolt协议连接到端口1234上的203.0.113.1。可以使用主机名而不是IP地址:bolt:// server:1234。默认的Bolt端口是7687。

0 个答案:

没有答案