Search code examples
javasocketsrmiconnection-pooling

Java RMI connection-pooling details


I´m working on a Java RMI topic and need some information about the connection pooling on the client side. In the literature and the documentation there are no clear answers to these topics. I know that connection pooling is not a part of the RMI specification. But in some implementations (e.g. in SUN´s implementation) it is done. So my questions refer to this implementation.

I suppose that the socket (java.net.Socket) which is created by the RMI socket factory is cached in the pool. Is that correct?

How are these connections saved? I would except that a HashMap is used with the destination ip/port as key and the socket as value.

Sockets are closed by using a timeout. How is the information on the connection idle time gained? Possibly there is some kind of timestamp when the connection is used the last time.


Solution

  • Bearing in mind that I am talking about the Sun implementation only:

    I suppose that the socket (java.net.Socket) which is created by the RMI socket factory is cached in the pool. Is that correct?

    Yes, after it is released from the remote call, and of course the remote call looks in the pool first before it asks the socket factory to create a new Socket.

    How are these connections saved? I would except that a HashMap is used with the destination ip/port as key and the socket as value.

    Let's just say there must logically be a Map from ip:port to Socket. The implementation details aren't actually important.

    Sockets are closed by using a timeout. How is the information on the connection idle time gained?

    By noting the time when the connection was put into the pool.