You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lenya.apache.org by Antonio Gallardo <ag...@agssa.net> on 2007/04/01 00:00:10 UTC
Re: Problems with LRUMap
Hi Jann,
+1 See: http://svn.apache.org/viewvc?view=rev&revision=524487
Best Regards,
Antonio Gallardo.
Jann Forrer escribió:
> Hi
>
> We encounter problems with a LRUMap under heavy load in lenya-1.2. That
> might be due to unsynchronized access to the map.
>
> According to
> http://jakarta.apache.org/commons/collections/api-3.1/org/apache/commons/collections/map/LRUMap.html
> a LRUMap should be synchronized if it will be accessed by multiple threads:
>
> "A synchronized version can be obtained with:
> Collections.synchronizedMap( theMapToSynchronize ) If it will be
> accessed by multiple threads, you _must_ synchronize access to this Map.
> Even concurrent get(Object) operations produce indeterminate behaviour."
>
> Therefor I propose the following change in the URIParameterizerImpl.java:
>
> Index:
> org/apache/lenya/cms/cocoon/uriparameterizer/URIParameterizerImpl.java
> ===================================================================
> ---
> org/apache/lenya/cms/cocoon/uriparameterizer/URIParameterizerImpl.java
> (revision 515604)
> +++
> org/apache/lenya/cms/cocoon/uriparameterizer/URIParameterizerImpl.java
> (working copy)
> @@ -22,6 +22,7 @@
>
> import java.util.HashMap;
> import java.util.Map;
> +import java.util.Collections;
>
> import org.apache.avalon.framework.logger.AbstractLogEnabled;
> import org.apache.avalon.framework.logger.Logger;
> @@ -178,8 +179,9 @@
>
> protected static final int CACHE_CAPACITY = 1000;
>
> - private static Map cache = new LRUMap(CACHE_CAPACITY);
> -
> + private static Map cache = Collections.synchronizedMap (new
> LRUMap (CACHE_CAPACITY));
> +
> private ServiceManager manager;
>
> /**
>
> WDYT
>
> Jann
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
> For additional commands, e-mail: dev-help@lenya.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org
Re: Problems with LRUMap
Posted by Michael Wechner <mi...@wyona.com>.
Antonio Gallardo wrote:
> Hi Jann,
>
> +1 See: http://svn.apache.org/viewvc?view=rev&revision=524487
thanks
Michi
>
> Best Regards,
>
> Antonio Gallardo.
>
> Jann Forrer escribió:
>
>> Hi
>>
>> We encounter problems with a LRUMap under heavy load in lenya-1.2. That
>> might be due to unsynchronized access to the map.
>>
>> According to
>> http://jakarta.apache.org/commons/collections/api-3.1/org/apache/commons/collections/map/LRUMap.html
>>
>> a LRUMap should be synchronized if it will be accessed by multiple
>> threads:
>>
>> "A synchronized version can be obtained with:
>> Collections.synchronizedMap( theMapToSynchronize ) If it will be
>> accessed by multiple threads, you _must_ synchronize access to this Map.
>> Even concurrent get(Object) operations produce indeterminate behaviour."
>>
>> Therefor I propose the following change in the
>> URIParameterizerImpl.java:
>>
>> Index:
>> org/apache/lenya/cms/cocoon/uriparameterizer/URIParameterizerImpl.java
>> ===================================================================
>> ---
>> org/apache/lenya/cms/cocoon/uriparameterizer/URIParameterizerImpl.java
>> (revision 515604)
>> +++
>> org/apache/lenya/cms/cocoon/uriparameterizer/URIParameterizerImpl.java
>> (working copy)
>> @@ -22,6 +22,7 @@
>>
>> import java.util.HashMap;
>> import java.util.Map;
>> +import java.util.Collections;
>>
>> import org.apache.avalon.framework.logger.AbstractLogEnabled;
>> import org.apache.avalon.framework.logger.Logger;
>> @@ -178,8 +179,9 @@
>>
>> protected static final int CACHE_CAPACITY = 1000;
>>
>> - private static Map cache = new LRUMap(CACHE_CAPACITY);
>> -
>> + private static Map cache = Collections.synchronizedMap (new
>> LRUMap (CACHE_CAPACITY));
>> +
>> private ServiceManager manager;
>>
>> /**
>>
>> WDYT
>>
>> Jann
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
>> For additional commands, e-mail: dev-help@lenya.apache.org
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
> For additional commands, e-mail: dev-help@lenya.apache.org
>
>
--
Michael Wechner
Wyona - Open Source Content Management - Apache Lenya
http://www.wyona.com http://lenya.apache.org
michael.wechner@wyona.com michi@apache.org
+41 44 272 91 61
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org