users@grizzly.java.net

Questions on Client Grizzly Connection Caching

From: John ROM <snake-john_at_gmx.de>
Date: Tue, 20 May 2008 17:23:37 +0200

Hello,

I have a client talking to the server.


I setup pooling like this:

Controller controller = new Controller();

ConnectorHandlerPool cacheableHandlerPool = new

CacheableConnectorHandlerPool(controller, 5,2, 1);
    controller.setConnectorHandlerPool(cacheableHandlerPool);



And on every "client write" I do something like:

------------------------------------------------------------------

public void send(Object params[]) throws Exception {
 connector_handler = controller.acquireConnectorHandler(Controller.Protocol.TCP);
while (true) {
            try {
                connector_handler
                 .connect(
              new InetSocketAddress(host, port),
              getConnectCallbackHandle());
              
              break;
            
             } catch (Exception ex) {
                System.out.println("just try again ");
            }
        }
        writeRequest(params); // has same connector_handler
      
        try {
            connector_handler.close();
        } finally {
            controller.releaseConnectorHandler(connector_handler);
        }

    }
----------------------------------------------------------------------
My questions are :

1) Does the code look ok?

2) When I reuse an existing connection
   the connect call always fires the Callbackhandler.
   Since the connection is already connected this irritates me ?

3) if a connection is broken I obviously just don't
  hand it back to the pool. But I guess this broken connection
  would still hold on to resources. Is this an issue?

4) Is the set up of the Connection Pool with CacheableConnectorHandlerPool(controller, 5,2, 1);
   alright for my usecase?
    
Many Greetings
John

-- 
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger