CompressionAndRMI

From Protege Wiki
Revision as of 18:31, November 25, 2008 by Tredmond (talk | contribs) (New page: I am writing this page in case there are others who try to implement compression over rmi and find that it is more difficult than expected. Perhaps a google search will take you here and...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

I am writing this page in case there are others who try to implement compression over rmi and find that it is more difficult than expected. Perhaps a google search will take you here and maybe this page will be useful.

There are several other pages that tell you how to set up a compressing socket but I had problems making these implementations work. In particular, it is very easy to customize the socket factory used by rmi. This can be done on a per remote object level by using the appropriate constructor for the server side implementation of the remote objects. This is the approach that we took:

public class ServerFrameStore extends UnicastRemoteObject implements RemoteServerFrameStore {

   ...

    public ServerFrameStore(KnowledgeBase kb) throws RemoteException {
        super(SSLFactory.getServerPort(SSLFactory.Context.ALWAYS),
              new RmiSocketFactory(SSLFactory.Context.ALWAYS),
              new RmiSocketFactory(SSLFactory.Context.ALWAYS));

The constructor

        super(SSLFactory.getServerPort(SSLFactory.Context.ALWAYS),
              new RmiSocketFactory(SSLFactory.Context.ALWAYS),
              new RmiSocketFactory(SSLFactory.Context.ALWAYS));

specifies the port over which the rmi connection is made and the client and server rmi socket factories. One can also set the rmi socket factory for all remote objects with a single set rmi socket factory call. All of this is standard and is describe in more detail elsewhere.

Now some of the other pages describe how to then construct a rmi socket factory that will compress and decompress data going over the wire. The critical step in this work is the construction of a compressing input and output stream that will compress the data over the wire.