I am not going to share any code, but will let you know how i achieved neo4j graph database replication using solr.
So, based on how a neo4j database index works is that it puts everything inside a folder, and creates a lock in the indexes if any one is accessing it.
Solr has it’s own replication hook which works like a charm, it also provides support for replication of config files specified the configuration. Please note you have to specify the file names. Now how do we use this feature to enable replication of neo4j database whose file names can vary after each update in your graph.
Now i hope you have your code written to update your graph database indexes and you have control over to lose the reference to the graph and close the graph instance and know when the state of database is stable.
At this stable point , what you do is lose the reference to the database and compress your graph database directory into a single file. Specify the same file path into solr replication configuration of config files.
The way solr replication works, is that the slaves is going to poll the master for any updates. If the slaves finds any updates, it asks for indexes and checksum of the config files, then if the slave finds any change in the configuration it’s going to replicate the file for you. At this point once it fetches the file, it’s going to rename the original file if previously present and place the new file with name.
Ok at this point you have master slave replication configuration setup with the new graph database in compressed form at the path specified in solr config. How do use it now ? Solr provides a hook to plugin your custom replication handler which is let’s you provide a hook to put in your code, at this point write some code which unzips the files and put it a particular position.
Now create a hook that in your neo4j code which when triggered reloads the reference of it’s graph with the directory that you just unzipped. Trigger this hook via something like a HTTP call or something.
That should work fine if implemented correctly. Nothing out of the box, you have sit down write some code to get this working.
If it works for you , buy me a beer if you can.