|
I noticed a problem with lateral caching when configuring two or more TCP servers. The problem has to do with lateral cache recovery process when losing connections. I have attached a fix.
Main Issue:
I have three lateral cache servers. I start one server first. Because the other lateral TCP servers are not yet running, the first server fails to connect to the others and begins recovery mode. In recovery mode, a LateralCacheMonitor thread runs every 20 seconds trying to create connections to the other servers. I noticed the thread was only trying to create a connection to one of the other cache servers. The result was that when I brought the other two servers up, the initial server only successfully connected to one out of the other two servers. This was always the last of the TCP servers in the comma separated list.
Cause:
The problem is caused by the reuse of the same LateralCacheAttributes object. For each of the TCP servers, a LateralCacheManager is created. Each LateralCacheManager is created with an instance of LateraCacheAttributes. Before instantiating the LateralCacheManager, the specific TCP server is set on the LateralCacheAttributes object. Since the same instance of LateralCacheAttributes is used each time, the call to set the TCP server overwrites the previous TCP server each time. In recovery mode, the TCP server property on the LateralCacheAttributes is used to reestablish the connections. Recovery mode will always attempt to reestablish a connection to the last of the TCP servers since this was the last server to be set in the LateralCacheAttributes object.
Fix:
To fix this issue, I modified the class LateralCacheFactory. Now LateralCacheFactory calls set TCP server on a clone of the LateralCacheAttributes object. As a result, the previous TCP server is not overwritten.
CVS diff:
$ cvs -d :pserver:[EMAIL PROTECTED]:/home/cvspublic diff -u LateralCacheFactory.java Index: LateralCacheFactory.java =================================================================== RCS file: /home/cvspublic/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheFactory.java,v retrieving revision 1.4 diff -u -r1.4 LateralCacheFactory.java --- LateralCacheFactory.java 7 Aug 2002 15:28:12 -0000 1.4 +++ LateralCacheFactory.java 16 Jun 2003 02:14:43 -0000 @@ -73,15 +73,16 @@ StringTokenizer it = new StringTokenizer( lac.tcpServers, "," ); while ( it.hasMoreElements() ) { + LateralCacheAttributes lacClone = (LateralCacheAttributes)lac.copy(); //String server = (String)it.next(); String server = ( String ) it.nextElement(); if ( log.isDebugEnabled() ) { log.debug( "tcp server = " + server ); } - lac.setTcpServer( server ); - LateralCacheManager lcm = LateralCacheManager.getInstance( lac ); - ICache ic = lcm.getCache( lac.getCacheName() ); + lacClone.setTcpServer( server ); + LateralCacheManager lcm = LateralCacheManager.getInstance( lacClone ); + ICache ic = lcm.getCache( lacClone.getCacheName() ); if ( ic != null ) { noWaits.add( ic ); |
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
