Database Reference
In-Depth Information
Neo4j is an AP database, which means it's eventually unavailable in the presence of par-
titions (it becomes read-only for safety reasons if the network is extremely fragmented).
Slaves will become eventually consistent by having updates either pushed to, or pulled by,
them over some period of time. These values are configurable, so the inconsistency win-
dow can be controlled as each application or setup dictates. We'll discuss this more in sec-
tion 11.2.3 .
Before we dive into more specifics around how certain HA features work within Neo4j,
we'll go through an exercise of setting up a three-machine cluster. This allows you to get
your hands dirty, so that you can then play and experiment with some of the setup options
as we discuss them in this chapter.
Switching from a single machine setup to a clustered setup
Forclients currently makinguseofanexisting single-machine (embedded orserver)setup,
switching to a clustered environment should be a relatively straightforward and pain-free
affair. This is possible because Neo4j HA was designed from the outset to make such a
transition as easy as possible. There will obviously be additional configuration involved in
order to ensure the server can establish itself as a member of a cluster (we'll be covering
thisshortly),butfromtheclient'sperspective,theoperationsavailableandthegeneralway
in which the interaction with the server is undertaken should remain largely unchanged.
Embedded mode
Forembeddedclients,theNeo4jJARdependencieswillneedtobechangedfromtheCom-
munity to the Enterprise edition, if this hasn't already been done. The only change re-
quiredthereafterisinthewaythe GraphDatabaseService instanceiscreated.Instead
of using the GraphDatabaseFactory to create the GraphDatabaseService ,
a HighlyAvailableGraphDatabaseFactory should be used. As both of these
factories generate implementations that make use of the same ( GraphDatabaseSer-
vice ) interface, there are no additional changes required for any clients using it.
The following code snippet shows this code in action, with the HA-specific changes high-
lighted:
graphDatabaseService = new HighlyAvailableGraphDatabaseFactory()
.newHighlyAvailableDatabaseBuilder ("/machineA")
Search WWH ::




Custom Search