Reputation: 703
I am setting up a Neo4j based system in jRuby running on glassfish. Glassfish as with most rails systems allows for some mechanism to run multiple instances. In glassfish case there is an internal setting for the thread pool size.
My issue is that I am having problems with the Neo4j database being opened more than once and this is causing an error. I am in the process of upgrading to Rails3 to pull in the latest Neo4j.rb but in the mean time wanted to assure I had the right server setup.
Below is my setup:
# # GlassFish configuration. # # Please read the comments for each configuration settings before modifying. # # application environment. Default value development environment: staging # HTTP configuration http: # port port: 3000 #address address: 0.0.0.0 # context root. The default value is '/' contextroot: / # Grizzly is NIO based HTTP libraries used by GlassFish gem grizzly: chunking-enabled: true request-timeout: 30 send-buffer-size: 8192 max-keepalive-connextions: 256 keepalive-timeout: 30 thread-pool: idle-thread-timeout-seconds: 900 max-queue-size: 4096 max-thread-pool-size: 5 min-thread-pool-size: 2 #Logging configuration log: log-level: all jruby-runtime-pool: initial: 1 min: 1 max: 5 daemon: enable: true jvm-options: -server -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:NewRatio=2 -XX:+DisableExplicitGC -Dhk2.file.directory.changeIntervalTimer=6000
Upvotes: 0
Views: 1163
Reputation: 321
You can try setting the jruby-runtime-pool max value to 1 instead (have not tested this). If you are running a multithreaded application (like rails 3 and Neo4j) I think there is no need to use more then one jruby-runtime, right ?
Upvotes: 2
Reputation: 3315
The method Neo4j.start
takes an optional Neo database instance. I haven't tried it but if you can experiment with ensuring that only one Neo instance gets created and make sure that each runtime looks for that shared instance first, your multiple runtime approach might work.
Where to put the shared instance? If you were running in a servlet context you could put it in a servlet context attribute. Since you're not, the best way would probably be to write a small Java wrapper class for starting and storing the single instance, and importing that Java class into each runtime.
Upvotes: 1