Skip to main content

I claim King of the Mountain! ;-)

Posted by cajo on July 26, 2009 at 4:22 PM PDT

Expanding on the fun from my previous blog entry:

I hereby publicly claim that there exists no Java distributed computing framework that is equally flexible, and as fast, as cajo.

I challenge all wizards: Dare thee make me eat mine own words?

Welcome everyone, even teams, pick thee thine favourite magick: EJB, Spring, Jini, CORBA, JXTA, Terracotta, GridGain, etc... or even craft thine own! Let's have some fun, as in that way, everybody wins.

The cajo implementation of the simple, three method, framework agnostic, public domain grail interface (i.e. the gauntlet) uses elemental Java RMI. (so matching the 20kB grail.jar library size need not be part of the contest ;)

Additional dispensations: Whilst cajo doth also run over HTTP/HTTPS, traverse HTTP proxies, with NAT on both sides, invoke asynchronous server callbacks through closed client firewalls, use fully custom arguments and return types, work with JREs 1.3+ including 64-bit, run in Applets and WebStart unsigned, and is free: this will not be part of the tourney either.

Come join in the fun! With the economy in doldrums we have a little time to joust, and sharpen our skills. Implement the grail interface with thine most emulous framework, then let's compare numbers.

Who's implementation of the grail can make the challenge code run fastest across two JVMs?

The grail challenge server: (feel free to cut & paste)

import gnu.cajo.Grail; // the grail interface definition is public domain

public class Server {

   public static class Test { // remotely invokable POJO
      private final boolean result;
      Test(boolean result) { this.result = result; }
      public Boolean bar(int count) {
         System.out.println("bar called w/ " + count + " count");
         return Boolean.TRUE;
      public static java.awt.Color foo(Object bar, int count) {
         System.out.println("foo called w/ " + bar + ' ' + count + " count");
      public boolean baz() {
         System.out.println("baz called");
         return result;
      public void extra() { System.out.println("extra stuff"); }

   public static void main(String args[]) throws Exception {
      Grail grail =
         new gnu.cajo.Cajo(1198, null, null); // swap with your constructor
      grail.export(new Test(true));
      System.out.println("Server running");

The grail challenge client:

import gnu.cajo.Grail; // the grail interface definition is public domain

interface ClientMethodSet { // methods of interest to this client
   void baz();
   boolean bar(Integer quantum);
   Object foo(String barbaz, int foobar);

public class Client {
   public static void main(String args[]) throws Exception {
      Grail grail =
         new gnu.cajo.Cajo(0, null, null); // swap with your constructor
      Thread.currentThread().sleep(99); // allow some server discovery time
      Object refs[] = grail.lookup(ClientMethodSet.class);
      if (refs.length > 0) {
         ClientMethodSet cs = // use the first server in the list
            (ClientMethodSet)grail.proxy(refs[0], ClientMethodSet.class);
         final Integer tf = new Integer(25);
         long time = System.currentTimeMillis();
         for (int i = 0; i < 5000; i++) { // 5k runs to average over
            cs.baz(); // 3 calls per run
            System.out.println(, 42));
         time = (System.currentTimeMillis() - time) / 1000;
         System.out.println("run time " + time + " seconds");
      } else System.out.println("No server objects found");

To compile this challenger:

   javac -cp grail.jar
   javac -cp grail.jar

To run it:

   java -cp grail.jar;. Server
   java -cp grail.jar;. Client

The rules:

Swap in thine own grail implementation constructor, but the rest of the code is immutable for the purposes of this contest. Thou canst use any, or as many libraries as thou wish to implement thine framework. Yet to be it clear; we are speaking of a general-purpose solution, not an arrow aimed specifically at this example. Be sure to run the two solutions in similar environments.

Now, if thine framework cannot successfully implement the grail; it is worthy to ascertain why. The key point of this tourney is that the code is plain, clean, pure, Java. Note the complete absence of framework specific clutter in the code, nor the insipid configuration files, nor those preposterous annotations, nor the need for an IDE plugin to manage pointless complexity.

Swapping distributed frameworks should be as easy as changing constructors.

The grail interface concept has three main goals: Efficiency, Productivity, and Portability.

So, who shall become the new reigning Master of the Java distributed computing domain?

Consider taking up this gauntlet, and to those daring contestants; I genuinely wish thee: godspeed!


PS If a tourney is not your particular flagon of ale; please try out and expand upon the given cajo example. The grail concept is remarkably powerful, and easy to use. Thine comments and feedback wouldst also be most most heartily appreciated! (Use of Antediluvian English is not required) :-)

Related Topics >>


Hi Kirill, the use of ancient literary prose was just to add a little fun, but you may be right; it could be off putting to non-native speakers. In which case I sincerely apologise; and would be happy to clarify any confusion.

You might want to cut down on the odd language in favor of a simple, clean and concise description of the challenge.