neo4j-core 2.2.2-java → 2.2.3-java

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,8 +2,8 @@ source :gemcutter
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'neo4j-advanced', '>= 1.8.M05', '< 1.9', :require => false
6
- gem 'neo4j-enterprise', '>= 1.8.M05', '< 1.9', :require => false
5
+ gem 'neo4j-advanced', '>= 1.8.1', '< 2.0', :require => false
6
+ gem 'neo4j-enterprise', '>= 1.8.1', '< 2.0', :require => false
7
7
 
8
8
  group 'development' do
9
9
  gem 'pry'
@@ -32,71 +32,65 @@ migration_thread: false
32
32
  # Notice it must be either 'true' or 'false' as string
33
33
  enable_online_backup: 'false'
34
34
 
35
- #use the clustered Neo4j GraphDatabase (org.neo4j.kernel.HighlyAvailableGraphDatabase)
36
- ha.db: false
37
-
38
- # Example of HA Configuration, see http://wiki.neo4j.org/content/High_Availability_Cluster
39
- # This is only used when ha.db is set to true
40
- ha.server_id: 2
41
- ha.server: 'localhost:6002'
42
- ha.coordinators: 'localhost:2181,localhost:2182,localhost:2183'
35
+ #use the clustered Neo4j GraphDatabase (org.neo4j.kernel.ha.HighlyAvailableGraphDatabase)
36
+ #enable_ha: true
43
37
 
44
38
  # if enabled you can use the bin/neo4j-shell command to access the database
45
- enable_remote_shell: "port=9332"
46
-
47
- #===Memory mapped I/O settings===
48
-
49
- #Each file in the Neo store can use memory mapped I/O for reading/writing.
50
- #Best performance is achived if the full file can be memory mapped but if
51
- #there isn't enough memory for that Neo will try and make the best use of
52
- #the memory it gets (regions of the file that get accessed often will more
53
- #likley be memory mapped).
54
-
55
- #For high traversal speed it is important to have the nodestore.db and
56
- #relationshipstore.db files.
57
-
58
- neostore.nodestore.db.mapped_memory: 25M
59
- neostore.relationshipstore.db.mapped_memory: 50M
60
- neostore.propertystore.db.mapped_memory: 90M
61
- neostore.propertystore.db.index.mapped_memory: 1M
62
- neostore.propertystore.db.index.keys.mapped_memory: 1M
63
- neostore.propertystore.db.strings.mapped_memory: 130M
64
- neostore.propertystore.db.arrays.mapped_memory: 130M
65
-
66
-
67
- #: ": ": "Cache settings: ": ": "
68
-
69
- #use adaptive caches YES|NO. Let Neo try make best use of available heap.
70
- use_adaptive_cache: YES
71
-
72
- #heap usage/max heap size ratio. Neo will increase caches while ratio
73
- #is less and decrease if greater. Default 0.77 seems to be a good over
74
- #all ratio of heap usage to avoid GC trashing. Larger heaps may allow for
75
- #a higher ratio while tiny heaps may need even less.
76
- adaptive_cache_heap_ratio: 0.77
77
-
78
- #how aggressive Neo will decrease caches once heap ratio reached
79
- adaptive_cache_manager_decrease_ratio: 1.15
80
-
81
- #how aggresive Neo will increase caches if ratio isn't yet reached
82
- adaptive_cache_manager_increase_ratio: 1.1
83
-
84
- #if no requests are made to Neo this is the amount of time in ms Neo will wait
85
- #before it checks the heap usage and adapts the caches if needed
86
- adaptive_cache_worker_sleep_time: 3000
87
-
88
- #minimum size (number of nodes) of node cache. If adaptive cache is in use
89
- #node cache will not be decreased under this value
90
- min_node_cache_size: 0
91
-
92
- #minimum size (number of relationships) of relationship cache. If adaptive
93
- #cache is in use relationship cache will not be decreased under this value
94
- min_relationship_cache_size: 0
95
-
96
- #maximum size (number of nodes) of node cache. If adaptive cache is not in
97
- #use the node cache will not be increased above this value
98
- max_node_cache_size: 1500
99
-
100
- #maximum size (number of relationship) of node cache. If adaptive cache is
101
- #not in use the relationship cache will not be increased above this value
102
- max_relationship_cache_size: 3500
39
+ # enable_remote_shell: "port=9332"
40
+
41
+ ##===Memory mapped I/O settings===
42
+ #
43
+ ##Each file in the Neo store can use memory mapped I/O for reading/writing.
44
+ ##Best performance is achived if the full file can be memory mapped but if
45
+ ##there isn't enough memory for that Neo will try and make the best use of
46
+ ##the memory it gets (regions of the file that get accessed often will more
47
+ ##likley be memory mapped).
48
+ #
49
+ ##For high traversal speed it is important to have the nodestore.db and
50
+ ##relationshipstore.db files.
51
+ #
52
+ #neostore.nodestore.db.mapped_memory: 25M
53
+ #neostore.relationshipstore.db.mapped_memory: 50M
54
+ #neostore.propertystore.db.mapped_memory: 90M
55
+ #neostore.propertystore.db.index.mapped_memory: 1M
56
+ #neostore.propertystore.db.index.keys.mapped_memory: 1M
57
+ #neostore.propertystore.db.strings.mapped_memory: 130M
58
+ #neostore.propertystore.db.arrays.mapped_memory: 130M
59
+ #
60
+ #
61
+ ##: ": ": "Cache settings: ": ": "
62
+ #
63
+ ##use adaptive caches YES|NO. Let Neo try make best use of available heap.
64
+ #use_adaptive_cache: YES
65
+ #
66
+ ##heap usage/max heap size ratio. Neo will increase caches while ratio
67
+ ##is less and decrease if greater. Default 0.77 seems to be a good over
68
+ ##all ratio of heap usage to avoid GC trashing. Larger heaps may allow for
69
+ ##a higher ratio while tiny heaps may need even less.
70
+ #adaptive_cache_heap_ratio: 0.77
71
+ #
72
+ ##how aggressive Neo will decrease caches once heap ratio reached
73
+ #adaptive_cache_manager_decrease_ratio: 1.15
74
+ #
75
+ ##how aggresive Neo will increase caches if ratio isn't yet reached
76
+ #adaptive_cache_manager_increase_ratio: 1.1
77
+ #
78
+ ##if no requests are made to Neo this is the amount of time in ms Neo will wait
79
+ ##before it checks the heap usage and adapts the caches if needed
80
+ #adaptive_cache_worker_sleep_time: 3000
81
+ #
82
+ ##minimum size (number of nodes) of node cache. If adaptive cache is in use
83
+ ##node cache will not be decreased under this value
84
+ #min_node_cache_size: 0
85
+ #
86
+ ##minimum size (number of relationships) of relationship cache. If adaptive
87
+ ##cache is in use relationship cache will not be decreased under this value
88
+ #min_relationship_cache_size: 0
89
+ #
90
+ ##maximum size (number of nodes) of node cache. If adaptive cache is not in
91
+ ##use the node cache will not be increased above this value
92
+ #max_node_cache_size: 1500
93
+ #
94
+ ##maximum size (number of relationship) of node cache. If adaptive cache is
95
+ ##not in use the relationship cache will not be increased above this value
96
+ #max_relationship_cache_size: 3500
@@ -43,7 +43,7 @@ module Neo4j
43
43
  end
44
44
 
45
45
  def self.ha_enabled?
46
- Neo4j::Config['ha.db']
46
+ !!Neo4j::Config[:enable_ha]
47
47
  end
48
48
 
49
49
 
@@ -182,7 +182,11 @@ module Neo4j
182
182
  Neo4j.logger.info "starting Neo4j in HA mode, machine id: #{Neo4j.config['ha.server_id']} at #{Neo4j.config['ha.server']} db #{@storage_path}"
183
183
  # Modify the public base classes for the HA Node and Relationships
184
184
  # (instead of private Java::OrgNeo4jKernel::HighlyAvailableGraphDatabase::LookupNode)
185
- @graph = Java::OrgNeo4jKernel::HighlyAvailableGraphDatabase.new(@storage_path, Neo4j.config.to_java_map)
185
+ builder = Java::OrgNeo4jGraphdbFactory::HighlyAvailableGraphDatabaseFactory.new()
186
+ builder = builder.newHighlyAvailableDatabaseBuilder(@storage_path)
187
+ builder = builder.setConfig(Neo4j.config.to_java_map)
188
+ @graph = builder.newGraphDatabase()
189
+ #@graph = Java::OrgNeo4jKernelHa::HighlyAvailableGraphDatabase.new(@storage_path, Neo4j.config.to_java_map)
186
190
  @graph.register_transaction_event_handler(@event_handler)
187
191
  @lucene = @graph.index
188
192
  @event_handler.neo4j_started(self)
@@ -22,12 +22,16 @@ module Neo4j
22
22
  end
23
23
 
24
24
  # Get the indexed entity, creating it (exactly once) if no indexed entity exists.
25
- # There must be an index on the key
25
+ # There must be an index on the key.
26
+ # Must *not* be called inside a transaction.
26
27
  # @param [Symbol] key the key to find the entity under in the index.
27
28
  # @param [String, Fixnum, Float] value the value the key is mapped to for the entity in the index.
28
29
  # @param [Hash] props optional properties that the entity will have if created
29
30
  # @yield optional, make it possible to initialize the created node in a block
31
+ # @raise an exception if a transaction is running
30
32
  def get_or_create(key, value, props=nil, &init_block)
33
+ raise "Transaction already running, can't use get_or_create" if Neo4j.db.graph.respond_to?(:transactionRunning) && Neo4j.db.graph.transactionRunning
34
+
31
35
  tx = Neo4j::Transaction.new
32
36
  result = @index.get(key.to_s, value).get_single
33
37
  return result if result
@@ -44,7 +48,7 @@ module Neo4j
44
48
  tx.success
45
49
  result
46
50
  ensure
47
- tx.finish
51
+ tx && tx.finish
48
52
  end
49
53
 
50
54
  end
@@ -15,7 +15,7 @@ module Neo4j
15
15
  # evaluate(Path path, BranchState<STATE> state)
16
16
  # Evaluates a Path and returns an Evaluation containing information about whether or not to include it in the traversal result, i.e return it from the Traverser.
17
17
  def evaluate(path, state)
18
- ret = @eval_block.call(path, state)
18
+ ret = @eval_block.call(path)
19
19
  case ret
20
20
  when :exclude_and_continue then
21
21
  Java::OrgNeo4jGraphdbTraversal::Evaluation::EXCLUDE_AND_CONTINUE
@@ -21,7 +21,7 @@ module Neo4j
21
21
  end
22
22
  # find the first filter which returns false
23
23
  # if not found then we will accept this path
24
- if @procs.find { |p| !p.call(path, state) }.nil?
24
+ if @procs.find { |p| !p.call(path) }.nil?
25
25
  Java::OrgNeo4jGraphdbTraversal::Evaluation::INCLUDE_AND_CONTINUE
26
26
  else
27
27
  Java::OrgNeo4jGraphdbTraversal::Evaluation::EXCLUDE_AND_CONTINUE
@@ -14,7 +14,7 @@ module Neo4j
14
14
  # for the state parameter see - http://api.neo4j.org/1.8.1/org/neo4j/graphdb/traversal/BranchState.html
15
15
  def evaluate(path, state)
16
16
  return Java::OrgNeo4jGraphdbTraversal::Evaluation::EXCLUDE_AND_CONTINUE if path.length == 0
17
- if @proc.call(path, state)
17
+ if @proc.call(path)
18
18
  Java::OrgNeo4jGraphdbTraversal::Evaluation::INCLUDE_AND_PRUNE
19
19
  else
20
20
  Java::OrgNeo4jGraphdbTraversal::Evaluation::INCLUDE_AND_CONTINUE
@@ -1,5 +1,5 @@
1
1
  module Neo4j
2
2
  module Core
3
- VERSION = "2.2.2"
3
+ VERSION = "2.2.3"
4
4
  end
5
5
  end
data/lib/neo4j/config.rb CHANGED
@@ -11,6 +11,7 @@ module Neo4j
11
11
  # == Configurations keys
12
12
  #
13
13
  # storage_path where the database is stored
14
+ # enable_ha if ha cluster should be enabled (requires neo4j-enterprise gem)
14
15
  # timestamps if timestamps should be used when saving the model (Neo4j::Rails::Model)
15
16
  # lucene lucene configuration for fulltext and exact indices
16
17
  # enable_rules if false the _all relationship to all instances will not be created and custom rules will not be available. (Neo4j::NodeMixin and Neo4j::Rails::Model)
data/lib/neo4j/neo4j.rb CHANGED
@@ -239,7 +239,7 @@ module Neo4j
239
239
  # Only available using the neo4j-enterprise gem.
240
240
  # @return [Boolean] true if the Neo4j database is the HA master
241
241
  def ha_master?
242
- Neo4j.management(Java::OrgNeo4jManagement::HighAvailability).isMaster
242
+ db.graph && db.graph.isMaster()
243
243
  end
244
244
 
245
245
  # @return [Enumerable] all nodes in the database
data/neo4j-core.gemspec CHANGED
@@ -27,6 +27,6 @@ It comes included with the Apache Lucene document database.
27
27
  s.extra_rdoc_files = %w( README.rdoc )
28
28
  s.rdoc_options = ["--quiet", "--title", "Neo4j::Core", "--line-numbers", "--main", "README.rdoc", "--inline-source"]
29
29
 
30
- s.add_dependency("neo4j-community", '>= 1.8.M05', '< 1.9')
30
+ s.add_dependency("neo4j-community", '>= 1.8.1', '< 1.9')
31
31
  s.add_dependency("neo4j-cypher", '~> 1.0.0')
32
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neo4j-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.2.3
5
5
  prerelease:
6
6
  platform: java
7
7
  authors:
@@ -17,7 +17,7 @@ dependencies:
17
17
  requirements:
18
18
  - - ! '>='
19
19
  - !ruby/object:Gem::Version
20
- version: 1.8.M05
20
+ version: 1.8.1
21
21
  - - !binary |-
22
22
  PA==
23
23
  - !ruby/object:Gem::Version
@@ -27,7 +27,7 @@ dependencies:
27
27
  requirements:
28
28
  - - ! '>='
29
29
  - !ruby/object:Gem::Version
30
- version: 1.8.M05
30
+ version: 1.8.1
31
31
  - - !binary |-
32
32
  PA==
33
33
  - !ruby/object:Gem::Version