Author: thomas.heute(a)jboss.com
Date: 2010-05-10 12:57:51 -0400 (Mon, 10 May 2010)
New Revision: 3031
Modified:
portal/branches/EPP_5_0_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java
portal/branches/EPP_5_0_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java
portal/branches/EPP_5_0_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataCache.java
portal/branches/EPP_5_0_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/NullObject.java
Log:
JBEPP-352: Provide mop cache operation trace logging
Modified:
portal/branches/EPP_5_0_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java
===================================================================
---
portal/branches/EPP_5_0_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java 2010-05-10
15:09:15 UTC (rev 3030)
+++
portal/branches/EPP_5_0_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java 2010-05-10
16:57:51 UTC (rev 3031)
@@ -364,6 +364,10 @@
{
if (status == SynchronizationStatus.SAVED && staleKeys != null)
{
+ if (log.isTraceEnabled())
+ {
+ log.trace("Session commit about to evict entries " +
staleKeys);
+ }
for (Serializable key : staleKeys)
{
mgr.cacheRemove(key);
Modified:
portal/branches/EPP_5_0_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java
===================================================================
---
portal/branches/EPP_5_0_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java 2010-05-10
15:09:15 UTC (rev 3030)
+++
portal/branches/EPP_5_0_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java 2010-05-10
16:57:51 UTC (rev 3031)
@@ -26,6 +26,8 @@
import org.exoplatform.services.cache.CacheService;
import org.exoplatform.services.cache.ExoCache;
import org.exoplatform.services.jcr.RepositoryService;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
import org.gatein.mop.core.api.MOPService;
import org.picocontainer.Startable;
@@ -40,6 +42,9 @@
{
/** . */
+ private final Logger log = LoggerFactory.getLogger(POMSessionManager.class);
+
+ /** . */
private MOPService pomService;
/** . */
@@ -69,17 +74,47 @@
public void cachePut(Serializable key, Object value)
{
- cache.put(GlobalKey.wrap(repositoryService, key), value);
+ GlobalKey globalKey = GlobalKey.wrap(repositoryService, key);
+
+ //
+ if (log.isTraceEnabled())
+ {
+ log.trace("Updating cache key=" + globalKey + " with value="
+ value);
+ }
+
+ //
+ cache.put(globalKey, value);
}
public Object cacheGet(Serializable key)
{
- return cache.get(GlobalKey.wrap(repositoryService, key));
+ GlobalKey globalKey = GlobalKey.wrap(repositoryService, key);
+
+ //
+ Object value = cache.get(globalKey);
+
+ //
+ if (log.isTraceEnabled())
+ {
+ log.trace("Obtained for cache key=" + globalKey + " value="
+ value);
+ }
+
+ //
+ return value;
}
public void cacheRemove(Serializable key)
{
- cache.remove(GlobalKey.wrap(repositoryService, key));
+ GlobalKey globalKey = GlobalKey.wrap(repositoryService, key);
+
+ //
+ if (log.isTraceEnabled())
+ {
+ log.trace("Removing cache key=" + globalKey);
+ }
+
+ //
+ cache.remove(globalKey);
}
public void start()
@@ -109,6 +144,12 @@
public void clearCache()
{
+ if (log.isTraceEnabled())
+ {
+ log.trace("Clearing cache");
+ }
+
+ //
cache.clearCache();
}
Modified:
portal/branches/EPP_5_0_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataCache.java
===================================================================
---
portal/branches/EPP_5_0_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataCache.java 2010-05-10
15:09:15 UTC (rev 3030)
+++
portal/branches/EPP_5_0_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/DataCache.java 2010-05-10
16:57:51 UTC (rev 3031)
@@ -23,6 +23,8 @@
import org.exoplatform.portal.pom.config.POMTask;
import org.exoplatform.portal.pom.config.TaskExecutor;
import org.exoplatform.portal.pom.config.TaskExecutionDecorator;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
import java.io.Serializable;
import java.util.concurrent.atomic.AtomicLong;
@@ -35,6 +37,9 @@
{
/** . */
+ private final Logger log = LoggerFactory.getLogger(DataCache.class);
+
+ /** . */
private final AtomicLong readCount = new AtomicLong();
/** . */
@@ -73,6 +78,10 @@
private <K extends Serializable, V> V remove(POMSession session,
CacheableDataTask<K, V> task) throws Exception
{
K key = task.getKey();
+ if (log.isTraceEnabled())
+ {
+ log.trace("Schedule " + key + " for eviction");
+ }
session.scheduleForEviction(key);
return super.execute(session, task);
}
@@ -80,6 +89,10 @@
private <K extends Serializable, V> V write(POMSession session,
CacheableDataTask<K, V> task) throws Exception
{
K key = task.getKey();
+ if (log.isTraceEnabled())
+ {
+ log.trace("Schedule " + key + " for eviction");
+ }
session.scheduleForEviction(key);
return super.execute(session, task);
}
@@ -87,21 +100,36 @@
private <K extends Serializable, V> V create(POMSession session,
CacheableDataTask<K, V> task) throws Exception
{
K key = task.getKey();
+ if (log.isTraceEnabled())
+ {
+ log.trace("Schedule " + key + " for eviction");
+ }
session.scheduleForEviction(key);
return super.execute(session, task);
}
private <K extends Serializable, V> V read(POMSession session,
CacheableDataTask<K, V> task) throws Exception
{
+ K key = task.getKey();
+
+ //
if (!session.isModified())
{
- K key = task.getKey();
Object o = session.getFromCache(key);
+ if (log.isTraceEnabled())
+ {
+ log.trace("Retrieved " + o + " for key " + key);
+ }
+
V v = null;
if (o != null)
{
if (o == NullObject.get())
{
+ if (log.isTraceEnabled())
+ {
+ log.trace("Returning null as found null object marker");
+ }
return null;
}
else
@@ -111,12 +139,20 @@
{
v = type.cast(o);
}
+ else
+ {
+ log.error("Object " + o + " was not of the expected type
" + type);
+ }
}
}
//
if (v != null)
{
+ if (log.isTraceEnabled())
+ {
+ log.trace("Returning object " + v + " for key " +
key);
+ }
return v;
}
else
@@ -124,17 +160,35 @@
readCount.incrementAndGet();
//
+ if (log.isTraceEnabled())
+ {
+ log.trace("Object not found in cache for key " + key + "
about to retrieve it");
+ }
+
+ //
v = super.execute(session, task);
+ if (log.isTraceEnabled())
+ {
+ log.trace("Retrieved object " + v + " key " + key +
" that will be returned");
+ }
//
if (!session.isModified())
{
if (v == null)
{
+ if (log.isTraceEnabled())
+ {
+ log.trace("Updating cache with null object for key " +
key);
+ }
session.putInCache(key, NullObject.get());
}
else
{
+ if (log.isTraceEnabled())
+ {
+ log.trace("Updating cache with object " + v + " for
key " + key);
+ }
session.putInCache(key, v);
}
}
@@ -145,6 +199,12 @@
}
else
{
+ if (log.isTraceEnabled())
+ {
+ log.trace("Session was modified, object for key " + key + " is
directly retrieved");
+ }
+
+ //
return super.execute(session, task);
}
}
Modified:
portal/branches/EPP_5_0_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/NullObject.java
===================================================================
---
portal/branches/EPP_5_0_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/NullObject.java 2010-05-10
15:09:15 UTC (rev 3030)
+++
portal/branches/EPP_5_0_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/config/cache/NullObject.java 2010-05-10
16:57:51 UTC (rev 3031)
@@ -52,4 +52,10 @@
{
// Nothing to do
}
+
+ @Override
+ public String toString()
+ {
+ return "NullObject[]";
+ }
}