Distributed Systems with the Active Object pattern
It's been a while since my last post. I have been quite busy those last weeks, but hey, at least I'm back :-pThis is a rather long weblog entry but really interesting (well I hope so!).Anyway, a co-worker of mine pointed me to a cool project from the ObjectWeb consortium called ProActive. Quoting the main page of the website associated to this project:
ProActive is a Java library for parallel, distributed, and concurrent computing, also featuring mobility and security in a uniform framework. With a reduced set of simple primitives, ProActive provides a comprehensive API allowing to simplify the programming of applications that are distributed on Local Area Network (LAN), on cluster of workstations, or on Internet Grids.The library is based on an Active Object pattern.
If you are interested in distributed systems, this project is worth a look, believe me. Here are some of its features:
Asynchronous calls: Typed Messages (Request and Reply)
Automatic future-based synchronizations: wait-by-necessity
Migration, Mobile Agents (compatible with Swing and AWT)
Remote creation of remote objects
Reuse: polymorphism between standard objects and remote objects
Group Communications with dynamic group management
Libraries for sophisticated synchronizations, collaborative applications
Interfaced with Globus, Jini, LSF, rsh, ssh, etc.
On the fly stub generation with ASM or BCEL
Transparent, dynamic code loading (up and down)
Seamless management of the RMIRegistry and Jini
So what kind of real things can you do with it? Let's take some few examples: first of all, ProActive is able to start some JVMs on remote computers using rlogin, rsh, ssh, lsf, or Globus. Next when all those JVMs have started, they are linked in ProActive so that you can start moving your active objects from any JVM to any other JVM.But what I consider being the most interesting feature is what they call the future-based synchronization. Let me explain what it is. Suppose you have an object A that is turned into an active object (easy to do -- very few constraints placed on objects in order to make them active). Now let's say you have some client code calling a method m on A. Suppose this method requires 5 seconds for completion and returns an Object O. On the callee side the call to m will not block and we will end up with a proxy to O. If the client code is written in such a way that we are able to do some other work for 5 seconds before we need O (meaning calling a method on O -- giving O to another method does not mean using it yet), we will definitely fasten the client code. So you might wonder now what happens if you use O before the real value (from A) has been computed? Simple: the client code will block!This scheme can lead to really powerful system if you client code uses many active objects and if A returns active objects instead of POJO (Plain Old Java Objects).