Peermi: RMI over JXTA
javadoc contact download

Peermi is an extension of the standard RMI classes to enable true p2p, bidi rmi. Peermi includes a universal (Internet wide) lookup system like the rmi Registry and classes to facilitate multicast method calls. Using Peermi you can easily create a distributed, peer net application. For example the following code illustrates an application that finds the average temperature around the world.


//define the remote interface
public interface TempMonitor extends PeerRemote{
    public int getLocalTemp() throws RemoteException;
}

//remote implementation
public class TempMonitorImpl extends PeerRemoteObject implements TempMonitor{

    public TempMonitorImpl() throws RemoteException{
       super(true);//true means to bind this object by Class name in the PeerRegistry
    }

    public int getLocalTemp() throws RemoteException{
       MagicalClass.getLocalTemperature();
    }

}

//client
public class AvgTempClient{

    public static void main(String[] args) throws Exception{
       PeerRegistry lookupReg = PeerRegistry.getLocalInstance();

       PeerManager<TempMonitor> managedListOfPeers =
            lookupReg.requestPerManager(TempMonitorImpl.class.getName(),TempMonitor.class);
                                        //this is the binding           //this is the interface type


       Thread.sleep(60*1000); //sleep so the PeerRegistry has time to find the peers.

       long totalTemp = 0;
       long peerCount = 0;
       for(TempMonitor peer : managedListOfPeers){
          peerCount++;
          totalTemp+=peer.getLocalTemp();
       }
       System.out.println("Average global temp is"+(totalTemp/peerCount));
    }
}


Peermi provides a Multicast class that would conduct the remote method invocations asynchronously. This would provide a large speed increase over a synchronized invocation like the example.


Download

The Peermi source code is maintained at sourceforge.net.

To build from source:

# cvs  -d:pserver:anonymous@cvs.sf.net/cvsroot/jxl checkout jxl
# cd   jxl/peermi/
# ant   jar

Once this is done, a directory called jxl/peermi/dist will contain all of the compiled jars and dependencies.

_______________________
For more information on the Peermi system, review the api, contact us, or try the forums.