[jboss-cvs] JBossCache/src/org/jboss/cache/interceptors ...
Manik Surtani
msurtani at jboss.com
Tue Sep 5 14:09:56 EDT 2006
User: msurtani
Date: 06/09/05 14:09:56
Modified: src/org/jboss/cache/interceptors
ActivationInterceptor.java
CacheLoaderInterceptor.java
CacheMgmtInterceptor.java
CacheStoreInterceptor.java Interceptor.java
InterceptorMBean.java InvalidationInterceptor.java
InvocationContextInterceptor.java
PassivationInterceptor.java TxInterceptor.java
Added: src/org/jboss/cache/interceptors
InvocationContextInterceptorMBean.java
Log:
InterceptorMBean signature change
Revision Changes Path
1.35 +5 -5 JBossCache/src/org/jboss/cache/interceptors/ActivationInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ActivationInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/ActivationInterceptor.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- ActivationInterceptor.java 4 Sep 2006 21:06:18 -0000 1.34
+++ ActivationInterceptor.java 5 Sep 2006 18:09:56 -0000 1.35
@@ -27,7 +27,7 @@
* their attributes have been initialized and their children have been loaded in memory.
*
* @author <a href="mailto:{hmesha at novell.com}">{Hany Mesha}</a>
- * @version $Id: ActivationInterceptor.java,v 1.34 2006/09/04 21:06:18 msurtani Exp $
+ * @version $Id: ActivationInterceptor.java,v 1.35 2006/09/05 18:09:56 msurtani Exp $
*/
public class ActivationInterceptor extends CacheLoaderInterceptor implements ActivationInterceptorMBean
{
@@ -236,14 +236,14 @@
m_activations = 0;
}
- public Map dumpStatistics()
+ public Map<String, Object> dumpStatistics()
{
- Map retval = super.dumpStatistics();
+ Map<String, Object> retval = super.dumpStatistics();
if (retval == null)
{
- retval = new HashMap();
+ retval = new HashMap<String, Object>();
}
- retval.put("Activations", new Long(m_activations));
+ retval.put("Activations", m_activations);
return retval;
}
1.52 +4 -4 JBossCache/src/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheLoaderInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/CacheLoaderInterceptor.java,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -b -r1.51 -r1.52
--- CacheLoaderInterceptor.java 4 Sep 2006 21:06:18 -0000 1.51
+++ CacheLoaderInterceptor.java 5 Sep 2006 18:09:56 -0000 1.52
@@ -32,7 +32,7 @@
* Loads nodes that don't exist at the time of the call into memory from the CacheLoader
*
* @author Bela Ban
- * @version $Id: CacheLoaderInterceptor.java,v 1.51 2006/09/04 21:06:18 msurtani Exp $
+ * @version $Id: CacheLoaderInterceptor.java,v 1.52 2006/09/05 18:09:56 msurtani Exp $
*/
public class CacheLoaderInterceptor extends BaseCacheLoaderInterceptor implements CacheLoaderInterceptorMBean
{
@@ -304,9 +304,9 @@
m_cacheMisses = 0;
}
- public Map dumpStatistics()
+ public Map<String, Object> dumpStatistics()
{
- Map<String, Long> retval = new HashMap<String, Long>();
+ Map<String, Object> retval = new HashMap<String, Object>();
retval.put("CacheLoaderLoads", m_cacheLoads);
retval.put("CacheLoaderMisses", m_cacheMisses);
return retval;
1.20 +138 -136 JBossCache/src/org/jboss/cache/interceptors/CacheMgmtInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheMgmtInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/CacheMgmtInterceptor.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- CacheMgmtInterceptor.java 25 Aug 2006 14:10:07 -0000 1.19
+++ CacheMgmtInterceptor.java 5 Sep 2006 18:09:56 -0000 1.20
@@ -41,8 +41,9 @@
/**
* Captures cache management statistics
+ *
* @author Jerry Gauthier
- * @version $Id: CacheMgmtInterceptor.java,v 1.19 2006/08/25 14:10:07 msurtani Exp $
+ * @version $Id: CacheMgmtInterceptor.java,v 1.20 2006/09/05 18:09:56 msurtani Exp $
*/
public class CacheMgmtInterceptor extends Interceptor implements CacheMgmtInterceptorMBean, NotificationBroadcaster
{
@@ -107,6 +108,7 @@
/**
* Pass the method on and capture cache statistics
+ *
* @return
* @throws Throwable
*/
@@ -116,7 +118,6 @@
Object[]args = m.getArgs();
Object retval;
-
// if statistics not enabled, execute the method and return
if (!getStatisticsEnabled())
return super.invoke(m);
@@ -128,7 +129,7 @@
//fqn = (Fqn) args[0];
//key = args[1];
t1 = System.currentTimeMillis();
- retval=super.invoke(m);
+ retval = super.invoke(m);
t2 = System.currentTimeMillis();
if (retval == null)
{
@@ -143,7 +144,7 @@
break;
case MethodDeclarations.putKeyValMethodLocal_id:
t1 = System.currentTimeMillis();
- retval=super.invoke(m);
+ retval = super.invoke(m);
t2 = System.currentTimeMillis();
m_store_times = m_store_times + (t2 - t1);
m_stores++;
@@ -151,9 +152,9 @@
case MethodDeclarations.putDataMethodLocal_id:
case MethodDeclarations.putDataEraseMethodLocal_id:
//fqn = (Fqn) args[1];
- attributes = (Map)args[2];
+ attributes = (Map) args[2];
t1 = System.currentTimeMillis();
- retval=super.invoke(m);
+ retval = super.invoke(m);
t2 = System.currentTimeMillis();
if (attributes != null && attributes.size() > 0)
@@ -165,11 +166,11 @@
case MethodDeclarations.evictNodeMethodLocal_id:
case MethodDeclarations.evictVersionedNodeMethodLocal_id:
//fqn = (Fqn) args[0];
- retval=super.invoke(m);
+ retval = super.invoke(m);
m_evictions++;
break;
default :
- retval=super.invoke(m);
+ retval = super.invoke(m);
break;
}
@@ -201,14 +202,14 @@
double total = m_hits + m_misses;
if (total == 0)
return 0;
- return (m_hits/total);
+ return (m_hits / total);
}
public double getReadWriteRatio()
{
if (m_stores == 0)
return 0;
- return (((double)(m_hits + m_misses)/(double)m_stores));
+ return (((double) (m_hits + m_misses) / (double) m_stores));
}
public long getAverageReadTime()
@@ -216,14 +217,14 @@
long total = m_hits + m_misses;
if (total == 0)
return 0;
- return (m_hit_times + m_miss_times)/total;
+ return (m_hit_times + m_miss_times) / total;
}
public long getAverageWriteTime()
{
if (m_stores == 0)
return 0;
- return (m_store_times)/m_stores;
+ return (m_store_times) / m_stores;
}
public int getNumberOfAttributes()
@@ -246,21 +247,21 @@
return (System.currentTimeMillis() - m_reset) / 1000;
}
- public Map dumpStatistics()
+ public Map<String, Object> dumpStatistics()
{
- Map retval=new HashMap();
- retval.put("Hits", new Long(m_hits));
- retval.put("Misses", new Long(m_misses));
- retval.put("Stores", new Long(m_stores));
- retval.put("Evictions", new Long(m_evictions));
- retval.put("NumberOfAttributes", new Integer(cache.getNumberOfAttributes()));
- retval.put("NumberOfNodes", new Integer(cache.getNumberOfNodes()));
- retval.put("ElapsedTime", new Long(getElapsedTime()));
- retval.put("TimeSinceReset", new Long(getTimeSinceReset()));
- retval.put("AverageReadTime", new Long(getAverageReadTime()));
- retval.put("AverageWriteTime", new Long(getAverageWriteTime()));
- retval.put("HitMissRatio", new Double(getHitMissRatio()));
- retval.put("ReadWriteRatio", new Double(getReadWriteRatio()));
+ Map<String, Object> retval = new HashMap<String, Object>();
+ retval.put("Hits", m_hits);
+ retval.put("Misses", m_misses);
+ retval.put("Stores", m_stores);
+ retval.put("Evictions", m_evictions);
+ retval.put("NumberOfAttributes", cache.getNumberOfAttributes());
+ retval.put("NumberOfNodes", cache.getNumberOfNodes());
+ retval.put("ElapsedTime", getElapsedTime());
+ retval.put("TimeSinceReset", getTimeSinceReset());
+ retval.put("AverageReadTime", getAverageReadTime());
+ retval.put("AverageWriteTime", getAverageWriteTime());
+ retval.put("HitMissRatio", getHitMissRatio());
+ retval.put("ReadWriteRatio", getReadWriteRatio());
return retval;
}
@@ -310,13 +311,13 @@
public MBeanNotificationInfo[] getNotificationInfo()
{
- String[] types = new String[] {NOTIF_CACHE_STARTED, NOTIF_CACHE_STOPPED, NOTIF_NODE_CREATED,
+ String[] types = new String[]{NOTIF_CACHE_STARTED, NOTIF_CACHE_STOPPED, NOTIF_NODE_CREATED,
NOTIF_NODE_EVICTED, NOTIF_NODE_LOADED, NOTIF_NODE_MODIFIED,
NOTIF_NODE_REMOVED, NOTIF_NODE_VISITED, NOTIF_VIEW_CHANGE,
NOTIF_NODE_ACTIVATE, NOTIF_NODE_EVICT, NOTIF_NODE_MODIFY,
NOTIF_NODE_PASSIVATE, NOTIF_NODE_REMOVE};
MBeanNotificationInfo info = new MBeanNotificationInfo(types, NOTIFICATION_NAME, NOTIFICATION_DESCR);
- return new MBeanNotificationInfo[] {info};
+ return new MBeanNotificationInfo[]{info};
}
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
@@ -340,7 +341,8 @@
{
}
- private long seq() {
+ private long seq()
+ {
return m_seq.increment();
}
1.30 +217 -196 JBossCache/src/org/jboss/cache/interceptors/CacheStoreInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheStoreInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/CacheStoreInterceptor.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- CacheStoreInterceptor.java 25 Aug 2006 14:10:07 -0000 1.29
+++ CacheStoreInterceptor.java 5 Sep 2006 18:09:56 -0000 1.30
@@ -8,8 +8,8 @@
import org.jboss.cache.TransactionEntry;
import org.jboss.cache.TransactionTable;
import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.marshall.MethodDeclarations;
import org.jboss.cache.marshall.MethodCall;
+import org.jboss.cache.marshall.MethodDeclarations;
import javax.transaction.TransactionManager;
import java.lang.reflect.Method;
@@ -23,62 +23,70 @@
/**
* Writes modifications back to the store on the way out: stores modifications back
* through the CacheLoader, either after each method call (no TXs), or at TX commit.
+ *
* @author Bela Ban
- * @version $Id: CacheStoreInterceptor.java,v 1.29 2006/08/25 14:10:07 msurtani Exp $
+ * @version $Id: CacheStoreInterceptor.java,v 1.30 2006/09/05 18:09:56 msurtani Exp $
*/
public class CacheStoreInterceptor extends BaseCacheLoaderInterceptor implements CacheStoreInterceptorMBean
{
protected CacheLoaderConfig loaderConfig = null;
- protected TransactionManager tx_mgr=null;
- protected TransactionTable tx_table=null;
+ protected TransactionManager tx_mgr = null;
+ protected TransactionTable tx_table = null;
private HashMap m_txStores = new HashMap();
private Map preparingTxs = new ConcurrentHashMap();
private long m_cacheStores = 0;
- public void setCache(CacheSPI cache) {
+ public void setCache(CacheSPI cache)
+ {
super.setCache(cache);
this.loaderConfig = cache.getCacheLoaderManager().getCacheLoaderConfig();
- tx_mgr=cache.getTransactionManager();
- tx_table=cache.getTransactionTable();
+ tx_mgr = cache.getTransactionManager();
+ tx_table = cache.getTransactionTable();
}
/**
* Pass the method on. When it returns, store the modification back to the store using the CacheLoader.
* In case of a transaction, register for TX completion (2PC) and at TX commit, write modifications made
* under the given TX to the CacheLoader
+ *
* @return
* @throws Throwable
*/
- public Object invoke(MethodCall m) throws Throwable {
+ public Object invoke(MethodCall m) throws Throwable
+ {
// if this is a shared cache loader and the call is of remote origin, pass up the chain. - Manik
// see http://www.jboss.com/index.html?module=bb&op=viewtopic&t=76090
- if (!cache.getInvocationContext().isOriginLocal() && loaderConfig.isShared()) {
+ if (!cache.getInvocationContext().isOriginLocal() && loaderConfig.isShared())
+ {
log.trace("Passing up method call and bypassing this interceptor since the cache loader is shared and this call originated remotely.");
return super.invoke(m);
}
Fqn fqn;
Object key, value;
- Object[] args=m.getArgs();
- Object retval, tmp_retval=null;
- boolean use_tmp_retval=false;
+ Object[] args = m.getArgs();
+ Object retval, tmp_retval = null;
+ boolean use_tmp_retval = false;
- if (log.isTraceEnabled()) {
+ if (log.isTraceEnabled())
+ {
log.trace("CacheStoreInterceptor called with meth " + m);
}
- if (tx_mgr != null && tx_mgr.getTransaction() != null) {
+ if (tx_mgr != null && tx_mgr.getTransaction() != null)
+ {
// we have a tx running.
log.trace("transactional so don't put stuff in the cloader yet.");
GlobalTransaction gtx = cache.getInvocationContext().getGlobalTransaction();
switch (m.getMethodId())
{
case MethodDeclarations.commitMethod_id:
- if (cache.getInvocationContext().isTxHasMods()) {
+ if (cache.getInvocationContext().isTxHasMods())
+ {
// this is a commit call.
if (log.isTraceEnabled()) log.trace("Calling loader.commit() for gtx " + gtx);
// sync call (a write) on the loader
@@ -93,19 +101,22 @@
releaseLoaderLocks(fqnsModified);
preparingTxs.remove(gtx);
}
- if (configuration.isUseInterceptorMbeans() && getStatisticsEnabled()) {
- Integer puts = (Integer)m_txStores.get(gtx);
+ if (configuration.isUseInterceptorMbeans() && getStatisticsEnabled())
+ {
+ Integer puts = (Integer) m_txStores.get(gtx);
if (puts != null)
m_cacheStores = m_cacheStores + puts.intValue();
m_txStores.remove(gtx);
}
}
- else {
+ else
+ {
log.trace("Commit called with no modifications; ignoring.");
}
break;
case MethodDeclarations.rollbackMethod_id:
- if (cache.getInvocationContext().isTxHasMods()) {
+ if (cache.getInvocationContext().isTxHasMods())
+ {
// this is a rollback method
if (preparingTxs.containsKey(gtx))
{
@@ -115,7 +126,8 @@
if (configuration.isUseInterceptorMbeans() && getStatisticsEnabled())
m_txStores.remove(gtx);
}
- else {
+ else
+ {
log.trace("Rollback called with no modifications; ignoring.");
}
break;
@@ -137,7 +149,7 @@
switch (m.getMethodId())
{
case MethodDeclarations.removeNodeMethodLocal_id:
- fqn=(Fqn)args[1];
+ fqn = (Fqn) args[1];
obtainLoaderLock(fqn);
try
{
@@ -149,13 +161,13 @@
}
break;
case MethodDeclarations.removeKeyMethodLocal_id:
- fqn=(Fqn)args[1];
- key=args[2];
+ fqn = (Fqn) args[1];
+ key = args[2];
obtainLoaderLock(fqn);
try
{
- tmp_retval=loader.remove(fqn, key);
- use_tmp_retval=true;
+ tmp_retval = loader.remove(fqn, key);
+ use_tmp_retval = true;
}
finally
{
@@ -163,7 +175,7 @@
}
break;
case MethodDeclarations.removeDataMethodLocal_id:
- fqn=(Fqn)args[1];
+ fqn = (Fqn) args[1];
obtainLoaderLock(fqn);
try
{
@@ -177,7 +189,7 @@
}
// }
- retval=super.invoke(m);
+ retval = super.invoke(m);
// put() methods need to be applied *after* the call
// synchronized(this) {
@@ -201,9 +213,9 @@
m_cacheStores++;
break;
case MethodDeclarations.putKeyValMethodLocal_id:
- fqn=(Fqn)args[1];
- key=args[2];
- value=args[3];
+ fqn = (Fqn) args[1];
+ key = args[2];
+ value = args[3];
obtainLoaderLock(fqn);
try
{
@@ -220,7 +232,7 @@
}
// }
- if(use_tmp_retval)
+ if (use_tmp_retval)
return tmp_retval;
else
return retval;
@@ -240,52 +252,60 @@
private Fqn findFqn(Object[] o)
{
- for (int i=0; i<o.length; i++)
+ for (int i = 0; i < o.length; i++)
{
if (o[i] instanceof Fqn) return (Fqn) o[i];
}
return null;
}
- public long getCacheLoaderStores() {
+ public long getCacheLoaderStores()
+ {
return m_cacheStores;
}
- public void resetStatistics() {
+ public void resetStatistics()
+ {
m_cacheStores = 0;
}
- public Map dumpStatistics() {
- Map<String, Long> retval=new HashMap<String, Long>();
+ public Map<String, Object> dumpStatistics()
+ {
+ Map<String, Object> retval = new HashMap<String, Object>();
retval.put("CacheLoaderStores", m_cacheStores);
return retval;
}
- private void prepareCacheLoader(GlobalTransaction gtx, boolean onePhase) throws Exception {
+ private void prepareCacheLoader(GlobalTransaction gtx, boolean onePhase) throws Exception
+ {
List modifications;
TransactionEntry entry;
int txPuts = 0;
- entry=tx_table.get(gtx);
- if(entry == null)
+ entry = tx_table.get(gtx);
+ if (entry == null)
throw new Exception("entry for transaction " + gtx + " not found in transaction table");
- modifications=entry.getCacheLoaderModifications();
- if(modifications.size() == 0)
+ modifications = entry.getCacheLoaderModifications();
+ if (modifications.size() == 0)
return;
- List cache_loader_modifications=new ArrayList();
- for(Iterator it=modifications.iterator(); it.hasNext();) {
- MethodCall methodCall=(MethodCall) it.next();
- Modification mod=convertMethodCallToModification(methodCall);
+ List cache_loader_modifications = new ArrayList();
+ for (Iterator it = modifications.iterator(); it.hasNext();)
+ {
+ MethodCall methodCall = (MethodCall) it.next();
+ Modification mod = convertMethodCallToModification(methodCall);
cache_loader_modifications.add(mod);
- if (configuration.isUseInterceptorMbeans() && getStatisticsEnabled()) {
- if ( (mod.getType() == Modification.PUT_DATA) ||
+ if (configuration.isUseInterceptorMbeans() && getStatisticsEnabled())
+ {
+ if ((mod.getType() == Modification.PUT_DATA) ||
(mod.getType() == Modification.PUT_DATA_ERASE) ||
- (mod.getType() == Modification.PUT_KEY_VALUE) )
+ (mod.getType() == Modification.PUT_KEY_VALUE))
txPuts++;
}
}
- if (log.isTraceEnabled()) log.trace("Converted method calls to cache loader modifications. List size: " + cache_loader_modifications.size());
- if(cache_loader_modifications.size() > 0) {
+ if (log.isTraceEnabled())
+ log.trace("Converted method calls to cache loader modifications. List size: " + cache_loader_modifications.size());
+ if (cache_loader_modifications.size() > 0)
+ {
loader.prepare(gtx, cache_loader_modifications, onePhase);
preparingTxs.put(gtx, gtx);
if (configuration.isUseInterceptorMbeans() && getStatisticsEnabled() && txPuts > 0)
@@ -293,38 +313,39 @@
}
}
- protected Modification convertMethodCallToModification(MethodCall methodCall) throws Exception {
- Method method=methodCall.getMethod();
+ protected Modification convertMethodCallToModification(MethodCall methodCall) throws Exception
+ {
+ Method method = methodCall.getMethod();
Object[] args;
- if(method == null)
+ if (method == null)
throw new Exception("method call has no method: " + methodCall);
- args=methodCall.getArgs();
+ args = methodCall.getArgs();
switch (methodCall.getMethodId())
{
case MethodDeclarations.putDataMethodLocal_id:
return new Modification(Modification.PUT_DATA,
- (Fqn)args[1], // fqn
- (Map)args[2]); // data
+ (Fqn) args[1], // fqn
+ (Map) args[2]); // data
case MethodDeclarations.putDataEraseMethodLocal_id:
return new Modification(Modification.PUT_DATA_ERASE,
- (Fqn)args[1], // fqn
- (Map)args[2]); // data
+ (Fqn) args[1], // fqn
+ (Map) args[2]); // data
case MethodDeclarations.putKeyValMethodLocal_id:
return new Modification(Modification.PUT_KEY_VALUE,
- (Fqn)args[1], // fqn
+ (Fqn) args[1], // fqn
args[2], // key
args[3]); // value
case MethodDeclarations.removeNodeMethodLocal_id:
return new Modification(Modification.REMOVE_NODE,
- (Fqn)args[1]); // fqn
+ (Fqn) args[1]); // fqn
case MethodDeclarations.removeKeyMethodLocal_id:
return new Modification(Modification.REMOVE_KEY_VALUE,
- (Fqn)args[1], // fqn
+ (Fqn) args[1], // fqn
args[2]); // key
case MethodDeclarations.removeDataMethodLocal_id:
return new Modification(Modification.REMOVE_DATA,
- (Fqn)args[1]); // fqn
+ (Fqn) args[1]); // fqn
default :
throw new Exception("method call " + method.getName() + " cannot be converted to a modification");
}
1.24 +12 -6 JBossCache/src/org/jboss/cache/interceptors/Interceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Interceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/Interceptor.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- Interceptor.java 5 Sep 2006 11:03:26 -0000 1.23
+++ Interceptor.java 5 Sep 2006 18:09:56 -0000 1.24
@@ -31,7 +31,7 @@
import javax.transaction.Status;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
-import java.util.HashMap;
+import java.util.Collections;
import java.util.Map;
/**
@@ -39,7 +39,7 @@
* <em>Note that this will be replaced by {@link org.jboss.aop.advice.Interceptor} in one of the next releases</em>
*
* @author Bela Ban
- * @version $Id: Interceptor.java,v 1.23 2006/09/05 11:03:26 msurtani Exp $
+ * @version $Id: Interceptor.java,v 1.24 2006/09/05 18:09:56 msurtani Exp $
*/
public abstract class Interceptor implements InterceptorMBean
{
@@ -95,15 +95,21 @@
this.last = last;
}
- public Map dumpStatistics()
+ /**
+ * This implementation returns an empty Map. If individual Interceptors wish to expose statistics, they can override this
+ * method.
+ */
+ public Map<String, Object> dumpStatistics()
{
- // should be implemented by individual interceptors
- return new HashMap();
+ return Collections.emptyMap();
}
+ /**
+ * This implementation is a no-op. If individual Interceptors wish to expose statistics, they can override this
+ * method.
+ */
public void resetStatistics()
{
- // should be implemented by individual interceptors
}
/**
1.2 +10 -9 JBossCache/src/org/jboss/cache/interceptors/InterceptorMBean.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: InterceptorMBean.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/InterceptorMBean.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- InterceptorMBean.java 23 Dec 2005 21:01:40 -0000 1.1
+++ InterceptorMBean.java 5 Sep 2006 18:09:56 -0000 1.2
@@ -25,8 +25,9 @@
/**
* Interface containing common cache management operations
+ *
* @author Jerry Gauthier
- * @version $Id: InterceptorMBean.java,v 1.1 2005/12/23 21:01:40 jerrygauth Exp $
+ * @version $Id: InterceptorMBean.java,v 1.2 2006/09/05 18:09:56 msurtani Exp $
*/
public interface InterceptorMBean
{
@@ -49,11 +50,11 @@
/**
* Returns a map of the cache interceptor's statistics
- * Map elements consist of {String name, Object value} entries
+ * Map is keyed on statistic names (which are Strings) and values are Objects.
*
* @return a map containing statistics
*/
- Map dumpStatistics();
+ Map<String, Object> dumpStatistics();
/**
* Resets an interceptor's cache statistics
1.26 +2 -2 JBossCache/src/org/jboss/cache/interceptors/InvalidationInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: InvalidationInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/InvalidationInterceptor.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- InvalidationInterceptor.java 30 Aug 2006 17:08:18 -0000 1.25
+++ InvalidationInterceptor.java 5 Sep 2006 18:09:56 -0000 1.26
@@ -139,9 +139,9 @@
m_invalidations = 0;
}
- public Map dumpStatistics()
+ public Map<String, Object> dumpStatistics()
{
- Map<String, Long> retval = new HashMap<String, Long>();
+ Map<String, Object> retval = new HashMap<String, Object>();
retval.put("Invalidations", m_invalidations);
return retval;
}
1.2 +1 -1 JBossCache/src/org/jboss/cache/interceptors/InvocationContextInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: InvocationContextInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/InvocationContextInterceptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- InvocationContextInterceptor.java 5 Sep 2006 11:03:26 -0000 1.1
+++ InvocationContextInterceptor.java 5 Sep 2006 18:09:56 -0000 1.2
@@ -13,7 +13,7 @@
*
* @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
*/
-public class InvocationContextInterceptor extends Interceptor
+public class InvocationContextInterceptor extends Interceptor implements InvocationContextInterceptorMBean
{
public Object invoke(MethodCall call) throws Throwable
{
1.27 +32 -24 JBossCache/src/org/jboss/cache/interceptors/PassivationInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PassivationInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/PassivationInterceptor.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- PassivationInterceptor.java 25 Aug 2006 14:10:07 -0000 1.26
+++ PassivationInterceptor.java 5 Sep 2006 18:09:56 -0000 1.27
@@ -17,9 +17,10 @@
* CacheLoader, either before each method call (no TXs), or at TX commit.
*
* @author <a href="mailto:{hmesha at novell.com}">{Hany Mesha}</a>
- * @version $Id: PassivationInterceptor.java,v 1.26 2006/08/25 14:10:07 msurtani Exp $
+ * @version $Id: PassivationInterceptor.java,v 1.27 2006/09/05 18:09:56 msurtani Exp $
*/
-public class PassivationInterceptor extends Interceptor implements PassivationInterceptorMBean {
+public class PassivationInterceptor extends Interceptor implements PassivationInterceptorMBean
+{
protected CacheLoader loader = null;
private SynchronizedLong m_passivations = new SynchronizedLong(0);
@@ -38,20 +39,22 @@
* @return
* @throws Throwable
*/
- public Object invoke(MethodCall m) throws Throwable {
+ public Object invoke(MethodCall m) throws Throwable
+ {
Fqn fqn;
- Object[] args=m.getArgs();
-
+ Object[] args = m.getArgs();
// could be potentially TRANSACTIONAL. If so, we register for TX completion (if we haven't done so yet)
// hmesha- We don't need to handle transaction during passivation since
// passivation happens local to a node and never replicated
// evict() method need to be applied to the CacheLoader before passing up the call
- if (m.getMethodId() == MethodDeclarations.evictNodeMethodLocal_id) {
- fqn = (Fqn)args[0];
+ if (m.getMethodId() == MethodDeclarations.evictNodeMethodLocal_id)
+ {
+ fqn = (Fqn) args[0];
// evict method local doesn't hold attributes therefore we have to get them manually
- synchronized (this) {
+ synchronized (this)
+ {
Map attributes = getNodeAttributes(fqn);
// remove internal flag if node was never fully loaded
if (attributes != null)
@@ -68,16 +71,19 @@
return super.invoke(m);
}
- public long getPassivations() {
+ public long getPassivations()
+ {
return m_passivations.get();
}
- public void resetStatistics() {
+ public void resetStatistics()
+ {
m_passivations.set(0);
}
- public Map dumpStatistics() {
- Map<String, Long> retval=new HashMap<String, Long>();
+ public Map<String, Object> dumpStatistics()
+ {
+ Map<String, Object> retval = new HashMap<String, Object>();
retval.put("Passivations", m_passivations.get());
return retval;
}
@@ -85,12 +91,14 @@
/**
* Returns attributes for a node.
*/
- private Map getNodeAttributes(Fqn fqn) {
+ private Map getNodeAttributes(Fqn fqn)
+ {
if (fqn == null)
return null;
Node n = cache;
int size = fqn.size();
- for(int i=0; i < size && n != null; i++) {
+ for (int i = 0; i < size && n != null; i++)
+ {
cache.getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
n = n.getChild(new Fqn(fqn.get(i)));
}
1.59 +7 -8 JBossCache/src/org/jboss/cache/interceptors/TxInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TxInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/TxInterceptor.java,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -b -r1.58 -r1.59
--- TxInterceptor.java 30 Aug 2006 17:08:18 -0000 1.58
+++ TxInterceptor.java 5 Sep 2006 18:09:56 -0000 1.59
@@ -208,12 +208,12 @@
m_rollbacks = 0;
}
- public Map dumpStatistics()
+ public Map<String, Object> dumpStatistics()
{
- Map retval = new HashMap(3);
- retval.put("Prepares", new Long(m_prepares));
- retval.put("Commits", new Long(m_commits));
- retval.put("Rollbacks", new Long(m_rollbacks));
+ Map<String, Object> retval = new HashMap<String, Object>(3);
+ retval.put("Prepares", m_prepares);
+ retval.put("Commits", m_commits);
+ retval.put("Rollbacks", m_rollbacks);
return retval;
}
@@ -224,8 +224,7 @@
if (params[clue] instanceof GlobalTransaction)
return (GlobalTransaction) params[clue];
else
- for (int i = 0; i < params.length; i++)
- if (params[i] instanceof GlobalTransaction) return (GlobalTransaction) params[i];
+ for (Object param : params) if (param instanceof GlobalTransaction) return (GlobalTransaction) param;
return null;
}
@@ -245,7 +244,7 @@
private Object handleRemotePrepare(MethodCall m, GlobalTransaction gtx) throws Throwable
{
List modifications = (List) m.getArgs()[1];
- boolean onePhase = ((Boolean) m.getArgs()[configuration.isNodeLockingOptimistic() ? 4 : 3]).booleanValue();
+ boolean onePhase = (Boolean) m.getArgs()[configuration.isNodeLockingOptimistic() ? 4 : 3];
// Is there a local transaction associated with GTX ?
Transaction ltx = txTable.getLocalTransaction(gtx);
1.1 date: 2006/09/05 18:09:56; author: msurtani; state: Exp;JBossCache/src/org/jboss/cache/interceptors/InvocationContextInterceptorMBean.java
Index: InvocationContextInterceptorMBean.java
===================================================================
package org.jboss.cache.interceptors;
/**
* MBean to the {@link InvocationContextInterceptor}
*
* @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
*/
public interface InvocationContextInterceptorMBean extends InterceptorMBean
{
}
More information about the jboss-cvs-commits
mailing list