0

When running a Neo4J database server standalone (on Ubuntu 14.04), configuration options are set for the global installation in etc/neo4j/neo4j.conf or possibly $NEO4J_HOME/conf/neo4j.conf.

However, when instantiating a Neo4j database from Java or Scala using Apache's Neo4jGraph class (org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph), there is no global installation, and the constructor does not (as far as I can tell) look for any configuration files.

In particular, when running the test suite for my application, I end up with many simultaneous instances of Neo4jGraph, which ends up throwing a java.net.BindException: Address already in use because all of these instances are trying to communicate over a small range of ports for online backup, which I don't actually need. These channels are set with config options dbms.backup.address (default value: 127.0.0.1:6362-6372) and dbms.backup.enabled (default value: true).

My problem would be solved by setting dbms.backup.enabled to false, or expanding the port range.

Things that have not worked:

  • Creating /etc/neo4j/neo4j.conf containing the line dbms.backup.enabled=false.

  • Creating the same file in my project's src/main/resources directory.

  • Creating the same file in src/main/resources/neo4j.

  • Manually setting the configuration property inside the Scala code:

val db = new Neo4jGraph(dataDirectory) db.configuration.addProperty("dbms.backup.enabled",false)

  • or

db.configuration.addProperty("neo4j.conf.dbms.backup.enabled",false)

  • or

db.configuration.addProperty("gremlin.neo4j.conf.dbms.backup.enabled",false)

How should I go about setting this property?

MSmedberg
  • 381
  • 3
  • 13

3 Answers3

0

Neo4jGraph configuration through TinkerPop is accomplished by a pass-through of configuration keys. In TinkerPop 3.x, that would mean that all Neo4j keys prefixed with gremlin.neo4j.conf that are provided via Configuration object to Neo4jGraph.open() or GraphFactory.open() will be passed down directly to the Neo4j instance. You can see examples of this here in the TinkerPop documentation on high availability configuration.

In TinkerPop 2.x, the same approach was taken however the key prefix was instead blueprints.neo4j.conf.* as discussed here.

stephen mallette
  • 45,298
  • 5
  • 67
  • 135
  • Does setting Configuration key `gremlin.neo4j.conf.dbms.backup.address` to, say, `0.0.0.0:6350-6359` produce an instance listening on that port range? For me it does not. – MSmedberg Aug 02 '16 at 04:01
0

Manipulating db.configuration after the database connection had already been opened was definitely futile.

stephen mallette's answer was on the right track, but this particular configuration doesn't appear to pass through in the way his linked example does. There is a naming mismatch between the configuration keys expected in neo4j.conf and those expected in org.neo4j.backup.OnlineBackupKernelExtension. Instead of dbms.backup.address and dbms.backup.enabled, that class looks for config keys online_backup_server and online_backup_enabled.

I was not able to get these keys passed down to the underlying Neo4jGraphAPI instance correctly. What I had to do, instead, was the following:

import org.neo4j.tinkerpop.api.impl.Neo4jFactoryImpl
import scala.collection.JavaConverters._

val factory = new Neo4jFactoryImpl()
val config = Map(
    "online_backup_enabled" -> "true",
    "online_backup_server" -> "0.0.0.0:6350-6359"
).asJava
val db = Neo4jGraph.open(factory.newGraphDatabase(dataDirectory,config))

With this initialization, the instance correctly listened for backups on port 6350; changing "true" to "false" disabled backup listening.

Community
  • 1
  • 1
MSmedberg
  • 381
  • 3
  • 13
0

Using Neo4j 3.0.0 the following disables port listening for me (Java code)

import org.apache.commons.configuration.BaseConfiguration;
import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph;

BaseConfiguration conf = new BaseConfiguration();
conf.setProperty(Neo4jGraph.CONFIG_DIRECTORY, "/path/to/db");
conf.setProperty(Neo4jGraph.CONFIG_CONF + "." + "dbms.backup.enabled", "false");
graph = Neo4jGraph.open(config);
cheshire
  • 190
  • 2
  • 4