Play with JMaglev yourself

JMaglev is finally public available!

I’m releasing my experiments with JRuby and Terracotta, so you can play with JMaglev and contribute some code. The project is in Github.

I had to patch JRuby to make RubyObjects a little less dependent from the JRuby Runtime. It isn’t perfect yet, but is working. The patch against the current jruby trunk (rev. 8091) and the patched jruby-complete are included in the project.

The code in Github is just a TIM (Terracotta Integration Module) with a sample maven project and the JMaglev use-case included. Unfortunately, I haven’t any time yet to upload the TIM to Terracotta Forge. BTW, does anyone know how to do this?

For those who want to reproduce my JMaglev demo, here is a step-by-step. You must have GIT, Maven 2 and the JDK properly installed. It only works on Linux and OS X. Is anyone wanting to contribute support for Windows users?

  1. git clone git://github.com/fabiokung/clustered-jruby.git
  2. long time waiting, because terracotta-2.7.1 (vanilla) and jruby-complete (patched) are bundled.
  3. cd clustered-jruby
  4. mvn install (although mvn package is enough)
  5. cd jmaglev
  6. start the terracotta server:
    lib/terracotta-2.7.1/bin/start-tc-server.sh
  7. open another two terminals
  8. run the simplified jirb inside them:
  9. cd clustered-jruby/jmaglev
    ./bin/jmaglev jmaglev.rb

  10. Follow the demo. You will be able to share global variables among all jmaglevs:
    require 'hat'
    $hat
    require 'rabbit'
    $hat.put(Rabbit.new)
    
  11. in the other terminal, try to see the magic hat contents:
    $hat
    

I haven’t tested it with rails applications, but right now, it isn’t able to run IRB. I never thought that running IRB could be so hard. 🙂

More drawbacks and limitations are being discussed in the JRuby Users Mailing List.

I hope to see many contributions. Happy hacking!

11 thoughts on “Play with JMaglev yourself

  1. I can help you get this published on the Terracotta Forge, but it would require you hosting your project in the Forge Subversion repository. If you’re willing to do this, shoot a message to forge-dev@terracotta.org and we can get it set up for you.

  2. Just a heads up that this won’t work on the mac because it is shipping with a bootjar. need to add a step to replace the boot jar in the ./clustered-jruby/jmaglev/lib/ with one built for your platform.

  3. @Steve
    You are right. Thanks.

    I’ve built the jar in a mac, then it should work only for intel macs.

    I’m going to build the bootjar on demand ASAP. Contributions are welcome. 😉

  4. Any instructions on how to build the jar for PPC/20.4 folks? I’m no Java guru but I can follow instructions.

    Thanks in advance.

  5. I have no idea if this problem is because of the bootjar but this is what I get when trying to run a simplified jirb:

    aemtower:~ aem$ cd ~/Sites/other/clustered-jruby/jmaglev/
    aemtower:~/Sites/other/clustered-jruby/jmaglev aem$ ./bin/jmaglev jmaglev.rb
    Error occurred during initialization of VM
    java.lang.NoClassDefFoundError: java/lang/ClassLoader$5
    ./bin/jmaglev: line 44: 3752 Trace/BPT trap $JAVA_CMD -Dcom.tc.l1.modules.repositories=$JMAGLEV_HOME/../target -Dtc.install-root=$JMAGLEV_HOME/lib/terracotta-2.7.1 -Dtc.config=$JMAGLEV_HOME/lib/tc-config.xml -Xbootclasspath/p:$JMAGLEV_HOME/lib/dso-boot.jar -cp .:$JMAGLEV_HOME/lib/jruby-complete-1.1.5.jar: org.jruby.Main “$@”

    BTW, the terracotta server seems to have started fine:

    5272 [main] INFO com.terracottatech.console – Terracotta Server has started up as ACTIVE node on 0.0.0.0:9510 successfully, and is now ready for work.

    Any ideas? I’m really looking forward to playing with this.

    Thanks in advance.

  6. Hi Adrian,

    You could try running the bundled example and then maven should assemble the BootJar for you.

    cd examples
    mvn tc:run
    # wait wait wait…

    The Terracotta Maven Plugin task will package a dso-boot.jar in the target directory. Just replace the other, in the lib dir:

    cd ..
    cp examples/target/dsl-boot.jar jmaglev/lib

    It should work.

  7. Hi Fabio,

    Thanks! That did it. Now I’ll see if I can figure out how to setup Terracota persistant/replicated in two boxes and I’ll be on my way. This is one tasty treat 😉

  8. This looks awesome.

    It’s a little worrying that you use the name JMaglev though, as Gemstone has probably trademarked the term Maglev. It’s quite likely that they’d order you to cease and desist. I’d suggest coming up with a distinct name.

  9. @Phil You’re probably right. That’s why I haven’t released anything called ‘JMagLev’. I don’t have a domain, I don’t have a product and the github project is called ‘clustered-jruby’.

    Thanks!

  10. This is really awesome!

    BTW. All you people having problems similar to Adrian when booting jruby client, just run the script that generates a new boot-jar:

    lib/terracotta-2.7.1/bin/make-boot-jar.sh

    and replace the old one with it:

    mv -f lib/terracotta-2.7.1/lib/dso-boot/dso-boot-*.jar lib/dso-boot.jar

Leave a reply to Fabio Kung Cancel reply