asmuts 2004/06/11 19:33:41
Modified: src/java/org/apache/jcs/auxiliary/remote RemoteCache.java
src/java/org/apache/jcs/utils/data PropertyGroups.java
src/java/org/apache/jcs/config OptionConverter.java
src/java/org/apache/jcs/engine/memory/mru
MRUMemoryCache.java
src/java/org/apache/jcs/engine/memory/lru
LRUMemoryCache.java
src/java/org/apache/jcs/auxiliary/lateral/socket/tcp
LateralTCPService.java LateralTCPSender.java
Log:
Antonio Gallardo's formatting and import cleanup patch.
I may have missed a few things in the patch. Also, I could not update to the new
version of util concurrent in the project.xml, since maven couldn't find the 1.3.4
specified in the patch.
Revision Changes Path
1.11 +2 -2
jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/RemoteCache.java
Index: RemoteCache.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/RemoteCache.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- RemoteCache.java 15 Apr 2004 19:22:47 -0000 1.10
+++ RemoteCache.java 12 Jun 2004 02:33:41 -0000 1.11
@@ -245,7 +245,7 @@
// Do not communicate with cluster except via server.
// separates the remote from the local. Must run a server to
// cluster, else it can be run inside a local.
- if ( this.irca.getRemoteType() != irca.CLUSTER )
+ if ( this.irca.getRemoteType() != IRemoteCacheAttributes.CLUSTER )
{
if ( !this.irca.getGetOnly() )
@@ -367,7 +367,7 @@
// initiate failover if local
RemoteCacheNoWaitFacade rcnwf = ( RemoteCacheNoWaitFacade )
RemoteCacheFactory.facades.get( irca.getCacheName() );
log.debug( "Initiating failover, rcnf = " + rcnwf );
- if ( rcnwf != null && rcnwf.rca.getRemoteType() == rcnwf.rca.LOCAL )
+ if ( rcnwf != null && rcnwf.rca.getRemoteType() ==
RemoteCacheAttributes.LOCAL )
{
log.debug( "found facade calling failover" );
// may need to remove the noWait index here. It will be 0 if it is local
1.4 +0 -2
jakarta-turbine-jcs/src/java/org/apache/jcs/utils/data/PropertyGroups.java
Index: PropertyGroups.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/utils/data/PropertyGroups.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PropertyGroups.java 15 Apr 2004 19:22:52 -0000 1.3
+++ PropertyGroups.java 12 Jun 2004 02:33:41 -0000 1.4
@@ -248,7 +248,6 @@
/** Description of the Method */
public Object nextElement()
{
- Object ob;
while ( baseEnum.hasMoreElements() )
{
Object k = baseEnum.nextElement();
@@ -294,7 +293,6 @@
/** Description of the Method */
public Object nextElement()
{
- Object ob;
while ( baseEnum.hasMoreElements() )
{
Object k = baseEnum.nextElement();
1.4 +22 -31
jakarta-turbine-jcs/src/java/org/apache/jcs/config/OptionConverter.java
Index: OptionConverter.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/config/OptionConverter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- OptionConverter.java 15 Apr 2004 19:22:52 -0000 1.3
+++ OptionConverter.java 12 Jun 2004 02:33:41 -0000 1.4
@@ -358,41 +358,32 @@
{
return val;
}
- else
- {
- sbuf.append( val.substring( i, val.length() ) );
- return sbuf.toString();
- }
+ sbuf.append( val.substring( i, val.length() ) );
+ return sbuf.toString();
}
- else
+ sbuf.append( val.substring( i, j ) );
+ k = val.indexOf( DELIM_STOP, j );
+ if ( k == -1 )
{
- sbuf.append( val.substring( i, j ) );
- k = val.indexOf( DELIM_STOP, j );
- if ( k == -1 )
- {
- throw new IllegalArgumentException( '"' + val +
- "\" has no closing brace. Opening brace at position " + j
- + '.' );
- }
- else
- {
- j += DELIM_START_LEN;
- String key = val.substring( j, k );
- // first try in System properties
- String replacement = getSystemProperty( key, null );
- // then try props parameter
- if ( replacement == null && props != null )
- {
- replacement = props.getProperty( key );
- }
+ throw new IllegalArgumentException( '"' + val +
+ "\" has no closing brace. Opening brace at position " + j
+ + '.' );
+ }
+ j += DELIM_START_LEN;
+ String key = val.substring( j, k );
+ // first try in System properties
+ String replacement = getSystemProperty( key, null );
+ // then try props parameter
+ if ( replacement == null && props != null )
+ {
+ replacement = props.getProperty( key );
+ }
- if ( replacement != null )
- {
- sbuf.append( replacement );
- }
- i = k + DELIM_STOP_LEN;
- }
+ if ( replacement != null )
+ {
+ sbuf.append( replacement );
}
+ i = k + DELIM_STOP_LEN;
}
}
1.14 +38 -41
jakarta-turbine-jcs/src/java/org/apache/jcs/engine/memory/mru/MRUMemoryCache.java
Index: MRUMemoryCache.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/memory/mru/MRUMemoryCache.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- MRUMemoryCache.java 15 Apr 2004 19:22:52 -0000 1.13
+++ MRUMemoryCache.java 12 Jun 2004 02:33:41 -0000 1.14
@@ -93,9 +93,9 @@
if ( replace )
{
// the slowest method I've ever seen
- mrulist.remove( ( String ) key );
+ mrulist.remove( key );
}
- mrulist.addFirst( ( String ) key );
+ mrulist.addFirst( key );
}
// save a microsecond on the second call.
@@ -105,55 +105,52 @@
{
return;
}
- else
- {
- // SPOOL LAST -- need to make this a grouping in a queue
+ // SPOOL LAST -- need to make this a grouping in a queue
- log.debug( "In RAM overflow" );
+ log.debug( "In RAM overflow" );
- // write the last item to disk.
- try
- {
+ // write the last item to disk.
+ try
+ {
- // PUSH 5 TO DISK TO MINIMIZE THE TYPICAL
- int chunkSizeCorrected = Math.min( size, chunkSize );
+ // PUSH 5 TO DISK TO MINIMIZE THE TYPICAL
+ int chunkSizeCorrected = Math.min( size, chunkSize );
- if ( log.isDebugEnabled() )
- {
- log.debug( "update: About to spool to disk cache, map.size() =
" + size + ", this.cattr.getMaxObjects() = " + this.cattr.getMaxObjects() + ",
chunkSizeCorrected = " + chunkSizeCorrected );
- }
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( "update: About to spool to disk cache, map.size() = " +
size + ", this.cattr.getMaxObjects() = " + this.cattr.getMaxObjects() + ",
chunkSizeCorrected = " + chunkSizeCorrected );
+ }
- // The spool will put them in a disk event queue, so there is no
- // need to pre-queue the queuing. This would be a bit wasteful
- // and wouldn't save much time in this synchronous call.
- for ( int i = 0; i < chunkSizeCorrected; i++ )
- {
- // Might want to rename this "overflow" incase the hub
- // wants to do something else.
- Serializable last = ( Serializable ) mrulist.getLast();
- ICacheElement ceL = ( ICacheElement ) map.get( last );
- cache.spoolToDisk( ceL );
-
- // need a more fine grained locking here
- synchronized ( map )
- {
- map.remove( last );
- mrulist.remove( last );
- }
- }
+ // The spool will put them in a disk event queue, so there is no
+ // need to pre-queue the queuing. This would be a bit wasteful
+ // and wouldn't save much time in this synchronous call.
+ for ( int i = 0; i < chunkSizeCorrected; i++ )
+ {
+ // Might want to rename this "overflow" incase the hub
+ // wants to do something else.
+ Serializable last = ( Serializable ) mrulist.getLast();
+ ICacheElement ceL = ( ICacheElement ) map.get( last );
+ cache.spoolToDisk( ceL );
- if ( log.isDebugEnabled() )
+ // need a more fine grained locking here
+ synchronized ( map )
{
- log.debug( "update: After spool, map.size() = " + size + ",
this.cattr.getMaxObjects() = " + this.cattr.getMaxObjects() + ", chunkSizeCorrected =
" + chunkSizeCorrected );
+ map.remove( last );
+ mrulist.remove( last );
}
-
}
- catch ( Exception ex )
+
+ if ( log.isDebugEnabled() )
{
- // impossible case.
- ex.printStackTrace();
- throw new IllegalStateException( ex.getMessage() );
+ log.debug( "update: After spool, map.size() = " + size + ",
this.cattr.getMaxObjects() = " + this.cattr.getMaxObjects() + ", chunkSizeCorrected =
" + chunkSizeCorrected );
}
+
+ }
+ catch ( Exception ex )
+ {
+ // impossible case.
+ ex.printStackTrace();
+ throw new IllegalStateException( ex.getMessage() );
}
}
1.23 +44 -47
jakarta-turbine-jcs/src/java/org/apache/jcs/engine/memory/lru/LRUMemoryCache.java
Index: LRUMemoryCache.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/memory/lru/LRUMemoryCache.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- LRUMemoryCache.java 15 Apr 2004 19:22:53 -0000 1.22
+++ LRUMemoryCache.java 12 Jun 2004 02:33:41 -0000 1.23
@@ -98,69 +98,66 @@
{
return;
}
- else
- {
- log.debug( "In memory limit reached, spooling" );
-
- // Write the last 'chunkSize' items to disk.
+ log.debug( "In memory limit reached, spooling" );
- int chunkSizeCorrected = Math.min( size, chunkSize );
+ // Write the last 'chunkSize' items to disk.
- if ( log.isDebugEnabled() )
- {
- log.debug( "About to spool to disk cache, map size: " + size
- + ", max objects: " + this.cattr.getMaxObjects()
- + ", items to spool: " + chunkSizeCorrected );
- }
+ int chunkSizeCorrected = Math.min( size, chunkSize );
- // The spool will put them in a disk event queue, so there is no
- // need to pre-queue the queuing. This would be a bit wasteful
- // and wouldn't save much time in this synchronous call.
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( "About to spool to disk cache, map size: " + size
+ + ", max objects: " + this.cattr.getMaxObjects()
+ + ", items to spool: " + chunkSizeCorrected );
+ }
+
+ // The spool will put them in a disk event queue, so there is no
+ // need to pre-queue the queuing. This would be a bit wasteful
+ // and wouldn't save much time in this synchronous call.
- for ( int i = 0; i < chunkSizeCorrected; i++ )
+ for ( int i = 0; i < chunkSizeCorrected; i++ )
+ {
+ synchronized ( this )
{
- synchronized ( this )
+ if ( last != null )
{
- if ( last != null )
+ if ( last.ce != null )
{
- if ( last.ce != null )
+ cache.spoolToDisk( last.ce );
+ if ( !map.containsKey(last.ce.getKey()) )
{
- cache.spoolToDisk( last.ce );
- if ( !map.containsKey(last.ce.getKey()) )
- {
- log.error("update: map does not contain key: " +
last.ce.getKey());
- verifyCache();
- }
- if ( map.remove(last.ce.getKey()) == null )
- {
- log.warn("update: remove failed for key: " +
last.ce.getKey() );
- verifyCache();
- }
+ log.error("update: map does not contain key: " +
last.ce.getKey());
+ verifyCache();
}
- else
+ if ( map.remove(last.ce.getKey()) == null )
{
- throw new Error("update: last.ce is null!");
+ log.warn("update: remove failed for key: " +
last.ce.getKey() );
+ verifyCache();
}
- removeNode( last );
- }
- else
+ }
+ else
{
- verifyCache();
- throw new Error("update: last is null!");
+ throw new Error("update: last.ce is null!");
}
+ removeNode( last );
+ }
+ else
+ {
+ verifyCache();
+ throw new Error("update: last is null!");
}
}
+ }
- if ( log.isDebugEnabled() )
- {
- log.debug("update: After spool map size: " + map.size());
- }
- if ( map.size() != dumpCacheSize() )
- {
- log.error("update: After spool, size mismatch: map.size() = "
- + map.size() + ", linked list size = " +
- dumpCacheSize());
- }
+ if ( log.isDebugEnabled() )
+ {
+ log.debug("update: After spool map size: " + map.size());
+ }
+ if ( map.size() != dumpCacheSize() )
+ {
+ log.error("update: After spool, size mismatch: map.size() = "
+ + map.size() + ", linked list size = " +
+ dumpCacheSize());
}
}
1.8 +5 -5
jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java
Index: LateralTCPService.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- LateralTCPService.java 25 May 2004 05:27:42 -0000 1.7
+++ LateralTCPService.java 12 Jun 2004 02:33:41 -0000 1.8
@@ -99,7 +99,7 @@
{
LateralElementDescriptor led = new LateralElementDescriptor( item );
led.requesterId = requesterId;
- led.command = led.UPDATE;
+ led.command = LateralElementDescriptor.UPDATE;
sender.send( led );
}
@@ -117,7 +117,7 @@
CacheElement ce = new CacheElement( cacheName, key, null );
LateralElementDescriptor led = new LateralElementDescriptor( ce );
led.requesterId = requesterId;
- led.command = led.REMOVE;
+ led.command = LateralElementDescriptor.REMOVE;
sender.send( led );
}
@@ -152,7 +152,7 @@
CacheElement ce = new CacheElement( cacheName, key, null );
LateralElementDescriptor led = new LateralElementDescriptor( ce );
//led.requesterId = requesterId; // later
- led.command = led.GET;
+ led.command = LateralElementDescriptor.GET;
return sender.sendAndReceive( led );
//return null;
// nothing needs to be done
@@ -185,7 +185,7 @@
CacheElement ce = new CacheElement( cacheName, "ALL", null );
LateralElementDescriptor led = new LateralElementDescriptor( ce );
led.requesterId = requesterId;
- led.command = led.REMOVEALL;
+ led.command = LateralElementDescriptor.REMOVEALL;
sender.send( led );
}
1.11 +5 -5
jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPSender.java
Index: LateralTCPSender.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPSender.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- LateralTCPSender.java 25 May 2004 05:27:42 -0000 1.10
+++ LateralTCPSender.java 12 Jun 2004 02:33:41 -0000 1.11
@@ -127,7 +127,7 @@
throw new IOException( "Socket is null" );
}
- socket.setSoTimeout( this.timeOut );
+ socket.setSoTimeout( LateralTCPSender.timeOut );
synchronized ( this )
{
oos = new ObjectOutputStream( socket.getOutputStream() );
@@ -317,7 +317,7 @@
{
LateralElementDescriptor led = new LateralElementDescriptor( item );
led.requesterId = requesterId;
- led.command = led.UPDATE;
+ led.command = LateralElementDescriptor.UPDATE;
send( led );
}
@@ -337,7 +337,7 @@
CacheElement ce = new CacheElement( cacheName, key, null );
LateralElementDescriptor led = new LateralElementDescriptor( ce );
led.requesterId = requesterId;
- led.command = led.REMOVE;
+ led.command = LateralElementDescriptor.REMOVE;
send( led );
}
@@ -379,7 +379,7 @@
CacheElement ce = new CacheElement( cacheName, "ALL", null );
LateralElementDescriptor led = new LateralElementDescriptor( ce );
led.requesterId = requesterId;
- led.command = led.REMOVEALL;
+ led.command = LateralElementDescriptor.REMOVEALL;
send( led );
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]