Skip to content

Commit

Permalink
Enable OnlineBackup [#149 state:resolved]
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasronge committed Feb 16, 2011
1 parent 62288ac commit d417e0d
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 3 deletions.
3 changes: 3 additions & 0 deletions config/neo4j/config.yml
Expand Up @@ -19,6 +19,9 @@ lucene: { fulltext: { provider: lucene,
# If set to true it you can use the database while it is migrating.
migration_thread: false

# If online backup should be available, if it is the Online JAR file will be loaded.
online_backup_enabled: false

#use the clustered Neo4j GraphDatabase (org.neo4j.kernel.HighlyAvailableGraphDatabase)
ha.db: false

Expand Down
3 changes: 3 additions & 0 deletions example/ha-cluster/config.yml
Expand Up @@ -22,6 +22,9 @@ migration_thread: false
#use the clustered Neo4j GraphDatabase (org.neo4j.kernel.HighlyAvailableGraphDatabase)
ha.db: true

# If online backup should be available, if it is the Online JAR file will be loaded.
online_backup_enabled: false

# Example of HA Configuration, see http://wiki.neo4j.org/content/High_Availability_Cluster
# This is only used when ha.db is set to true
ha.machine_id: 1
Expand Down
5 changes: 5 additions & 0 deletions example/ha-cluster/myapp.rb
Expand Up @@ -11,6 +11,11 @@ def start(machine_id)
Neo4j.config['ha.machine_id'] = machine_id
Neo4j.config['ha.server'] = "localhost:600#{machine_id}"
Neo4j.config['enable_remote_shell'] = "port=933#{machine_id}"

# since we are all running on localhost we can only enable one online back up server
# since they all use the port 6362
Neo4j.config[:online_backup_enabled] = true if machine_id == 1

Neo4j.config[:storage_path] = "db/neo#{machine_id}"
Neo4j.start
end
19 changes: 16 additions & 3 deletions lib/neo4j.rb
Expand Up @@ -19,19 +19,32 @@

module Neo4j

def self.load_local_jars
def self.load_local_jars
# This is a temporary fix since the HA does not yet work with this JAR
# It will be solved in a future version of the Java Neo4j library.
require 'neo4j/jars/core/neo4j-index-1.3-1.3.M01.jar'
if Neo4j.config[:online_backup_enabled]
Neo4j.load_online_backup
else
# backup and HA does not work with this JAR FILE
require 'neo4j/jars/core/neo4j-index-1.3-1.3.M01.jar'
end
end

def self.load_shell_jars
require 'neo4j/jars/ha/neo4j-shell-1.3.M02.jar'
end


def self.load_online_backup
require 'neo4j/jars/ha/neo4j-com-1.3.M02.jar'
require 'neo4j/jars/core/neo4j-backup-1.3-SNAPSHOT.jar'
require 'neo4j/jars/ha/netty-3.2.1.Final.jar'
Neo4j.send(:const_set, :OnlineBackup, org.neo4j.backup.OnlineBackup)
end

def self.load_ha_jars
require 'neo4j/jars/ha/log4j-1.2.16.jar'
require 'neo4j/jars/ha/neo4j-ha-1.3.M02.jar'
require 'neo4j/jars/ha/neo4j-com-1.3.M02.jar'
require 'neo4j/jars/ha/netty-3.2.1.Final.jar'
require 'neo4j/jars/ha/org.apache.servicemix.bundles.jline-0.9.94_1.jar'
require 'neo4j/jars/ha/org.apache.servicemix.bundles.lucene-3.0.1_2.jar'
Expand Down
1 change: 1 addition & 0 deletions lib/neo4j/database.rb
Expand Up @@ -64,6 +64,7 @@ def start_local_graph_db #:nodoc:
def start_ha_graph_db
Neo4j.logger.info "starting Neo4j in HA mode, machine id: #{Neo4j.config['ha.machine_id']} at #{Neo4j.config['ha.server']} db #{@storage_path}"
Neo4j.load_ha_jars # those jars are only needed for the HighlyAvailableGraphDatabase
Neo4j.load_online_backup if Neo4j.config[:online_backup_enabled]
@graph = org.neo4j.kernel.HighlyAvailableGraphDatabase.new(@storage_path, Neo4j.config.to_java_map)
@graph.register_transaction_event_handler(@event_handler)
@lucene = @graph.index #org.neo4j.index.impl.lucene.LuceneIndexProvider.new
Expand Down
Binary file added lib/neo4j/jars/core/neo4j-backup-1.3-SNAPSHOT.jar
Binary file not shown.
Binary file added lib/neo4j/jars/ha/neo4j-com-1.3.M02.jar
Binary file not shown.

0 comments on commit d417e0d

Please sign in to comment.