Connection Management/Cache in Grizzly 1.5

Recently Connection Management/Cache feature was added to Grizzly 1.5!
Actual implementation was provided by Ken Cavanaugh and originally was targeted to Corba, but Ken kindly proposed us to integrate it to SOAP/TCP and Grizzly even before he did it for Corba :)
Connection Management/Cache provides possibility to control active connections, reclaim least recently used (LRU) connections if limitation is reached. Specifically for client side it also serves as connection cache, which makes possible to reuse existing connections to a target host, instead of creating a new ones.
After integration of Connection Management/Cache to Grizzly, all its features become available in Grizzly framework.

For server part we need create an instance of CacheableSelectionKeyHandler and set it to Controller.
------------------------------------------------------------------
Controller controller = new Controller();
SelectionKeyHandler cacheableKeyHandler = new CacheableSelectionKeyHandler(highWaterMark, numberToReclaim);
controller.setSelectionKeyHandler(cacheableKeyHandler);
------------------------------------------------------------------
where:
highWaterMark: maximum number of active inbound connections Controller will handle
numberToReclaim: number of LRU connections, which will be reclaimed in case highWaterMark limit will be reached.

On the client side Connection Mangement/Cache is represented by several classes: CacheableConnectorHandlerPool, CacheableConnector:
------------------------------------------------------------------
Controller controller = new Controller();
ConnectorHandlerPool cacheableHandlerPool = new CacheableConnectorHandlerPool(controller, highWaterMark, numberToReclaim, maxParallel);
controller.setConnectorHandlerPool(cacheableHandlerPool);
................... complete controller initialization ...............................
ConnectorHandler clientConnector = controller.acquireConnectorHandler(Controller.Protocol.TCP);
clientConnector.connect(....);   // Initiates new connection or reuses one from cache
......................... execute client operations ....................................
clientConnector.close();          // If limit is not reached - connection will be put back to the cache
controller.releaseConnectorHandler(clientConnector);
------------------------------------------------------------------
where:
highWaterMark: maximum number of active outbound connections Controller will handle
numberToReclaim: number of LRU connections, which will be reclaimed in case highWaterMark limit will be reached.
maxParallel: maximum number of active outbound connections to single destination (usually <host>:<port>).

 

From simple example above we see, that Connection Management/Cache is very easy to use in Grizzly. It doesn't require significant changes comparing to default Grizzly configuration.

Comments:

[Trackback] A couple of blogs on Grizzly 1.5 written by the community are now starting to pop.

Posted by Jean-Francois Arcand's Blog on June 20, 2007 at 07:10 PM CEST #

[Trackback] A couple of blogs on Grizzly 1.5 written by the community are now starting to pop.

Posted by Jean-Francois Arcand's Blog on June 20, 2007 at 07:11 PM CEST #

Can you please give me few details on the SOAP/TCP project.

Posted by Nagesh on December 19, 2007 at 07:17 AM CET #

SOAP/TCP is part of project Metro [1]. It implements optimized transport for Web Services.
Using links [2]-[4] you can read more about it. What is SOAP/TCP, how to use it with Netbeans, which performance advantages you're getting.

WBR.

[1] https://metro.dev.java.net
[2] http://blogs.sun.com/oleksiys/entry/tcp_transport_for_web_services
[3] http://blogs.sun.com/oleksiys/entry/soap_tcp_support_in_netbeans
[4] http://blogs.sun.com/oleksiys/entry/soap_tcp_makes_web_services

Posted by oleksiys on January 15, 2008 at 06:43 AM CET #

Post a Comment:
  • HTML Syntax: NOT allowed
About

oleksiys

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today