[jboss-cvs] JBossCache/src/org/jboss/cache/interceptors ...
Elias Ross
genman at noderunner.net
Fri Dec 8 13:49:17 EST 2006
User: genman
Date: 06/12/08 13:49:17
Modified: src/org/jboss/cache/interceptors
CreateIfNotExistsInterceptor.java
PassivationInterceptor.java
CacheStoreInterceptor.java
DataGravitatorInterceptor.java
ActivationInterceptor.java
OptimisticReplicationInterceptor.java
CacheMgmtInterceptor.java TxInterceptor.java
Log:
JBCACHE-892 Use JDK1.5 concurrent classes
Revision Changes Path
1.20 +28 -28 JBossCache/src/org/jboss/cache/interceptors/CreateIfNotExistsInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CreateIfNotExistsInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/CreateIfNotExistsInterceptor.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- CreateIfNotExistsInterceptor.java 30 Aug 2006 17:08:18 -0000 1.19
+++ CreateIfNotExistsInterceptor.java 8 Dec 2006 18:49:17 -0000 1.20
@@ -1,6 +1,5 @@
package org.jboss.cache.interceptors;
-import EDU.oswego.cs.dl.util.concurrent.ReentrantLock;
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
@@ -10,6 +9,7 @@
import org.jboss.cache.marshall.MethodCallFactory;
import org.jboss.cache.marshall.MethodDeclarations;
+import java.util.concurrent.locks.ReentrantLock;
import java.util.ArrayList;
import java.util.Iterator;
@@ -18,8 +18,8 @@
* (depending on the create_if_not_exists argument)
*
* @author Bela Ban
- * @version $Id: CreateIfNotExistsInterceptor.java,v 1.19 2006/08/30 17:08:18 msurtani Exp $
- * @deprecated This code is not used anymore and will be removed in a future release
+ * @version $Id: CreateIfNotExistsInterceptor.java,v 1.20 2006/12/08 18:49:17 genman Exp $
+ * @deprecated This code is not used anymore and will be removed in a future unlock
*/
public class CreateIfNotExistsInterceptor extends Interceptor
{
@@ -79,7 +79,7 @@
// if(fqn == null)
// throw new CacheException("failed extracting FQN from method " + m);
//
-// lock.acquire();
+// lock.lockInterruptibly();
// if(isPut) { // lock needs to be held across puts()
// if(!cache.exists(fqn)) {
// GlobalTransaction gtx=cache.getCurrentTransaction();
@@ -89,13 +89,13 @@
// // lock(fqn, DataNode.LOCK_TYPE_WRITE, false);
// }
// else
-// lock.release();
+// lock.unlock();
// }
// return super.invoke(m);
// }
// finally {
// if(lock.holds() > 0)
-// lock.release(); // release lock for put()
+// lock.unlock(); // unlock lock for put()
// }
// }
// return super.invoke(m); // no locks held for non put()/remove()/evict() methods (e.g. for get() methods)
@@ -148,16 +148,16 @@
{ // remove() or evict(): wait until all puts() that work on the same subtree have completed
try
{
- findAndBlockOnPut(fqn, put_lock); // does NOT release put_lock !
+ findAndBlockOnPut(fqn, put_lock); // does NOT unlock put_lock !
addFqnToRemoveList(fqn, remove_lock);
- put_lock.release();
- // we only release now because waiting on the put-list and adding to remove-list need to be atomic !
+ put_lock.unlock();
+ // we only unlock now because waiting on the put-list and adding to remove-list need to be atomic !
return super.invoke(m);
}
finally
{
- if (put_lock.holds() > 0)
- put_lock.release();
+ if (put_lock.isHeldByCurrentThread())
+ put_lock.unlock();
removeFqnFromRemoveList(fqn, remove_lock);
}
}
@@ -169,7 +169,7 @@
/**
* Finds all FQNs in the put_list form which <code>fqn</code> is a parent (or equals), and waits on them.
* Loops until no more matching FQNs are found or the list is empty.<p/>
- * <em>Don't</em> release the lock, the caller will release it !
+ * <em>Don't</em> unlock the lock, the caller will unlock it !
*
* @param fqn
* @param lock
@@ -181,7 +181,7 @@
while (true)
{
//try {
- lock.acquire();
+ lock.lockInterruptibly();
tmp = findFqnInPutList(fqn);
if (tmp == null) // put_list is empty, or fqn has not been found
return;
@@ -189,7 +189,7 @@
log.trace("found " + tmp + " in put-list, waiting");
synchronized (tmp)
{
- lock.release();
+ lock.unlock();
tmp.wait();
}
if (log.isTraceEnabled())
@@ -197,7 +197,7 @@
//}
//finally {
// if(lock.holds() > 0)
- // lock.release();
+ // lock.unlock();
//}
}
}
@@ -215,7 +215,7 @@
Fqn tmp;
while (true)
{
- lock.acquire();
+ lock.lockInterruptibly();
try
{
tmp = findFqnInRemoveList(fqn);
@@ -225,7 +225,7 @@
log.trace("found " + tmp + " in remove-list, waiting");
synchronized (tmp)
{
- lock.release();
+ lock.unlock();
tmp.wait();
}
if (log.isTraceEnabled())
@@ -233,7 +233,7 @@
}
finally
{
- lock.release();
+ lock.unlock();
}
}
}
@@ -266,7 +266,7 @@
private void addFqnToPutList(Fqn fqn, ReentrantLock lock)
throws InterruptedException
{
- lock.acquire();
+ lock.lockInterruptibly();
try
{
if (!put_list.contains(fqn))
@@ -278,14 +278,14 @@
}
finally
{
- lock.release();
+ lock.unlock();
}
}
private void addFqnToRemoveList(Fqn fqn, ReentrantLock lock)
throws InterruptedException
{
- lock.acquire();
+ lock.lockInterruptibly();
try
{
if (!remove_list.contains(fqn))
@@ -297,7 +297,7 @@
}
finally
{
- lock.release();
+ lock.unlock();
}
}
@@ -305,13 +305,13 @@
private void removeFqnFromPutList(Fqn fqn, ReentrantLock lock)
throws InterruptedException
{
- lock.acquire();
+ lock.lockInterruptibly();
try
{
if (log.isTraceEnabled())
log.trace("removing " + fqn + " from put-list (size=" + put_list.size() + ")");
put_list.remove(fqn);
- lock.release();
+ lock.unlock();
synchronized (fqn)
{
fqn.notifyAll();
@@ -319,20 +319,20 @@
}
finally
{
- lock.release();
+ lock.unlock();
}
}
private void removeFqnFromRemoveList(Fqn fqn, ReentrantLock lock)
throws InterruptedException
{
- lock.acquire();
+ lock.lockInterruptibly();
try
{
if (log.isTraceEnabled())
log.trace("removing " + fqn + " from remove-list (size=" + remove_list.size() + ")");
remove_list.remove(fqn);
- lock.release();
+ lock.unlock();
synchronized (fqn)
{
fqn.notifyAll();
@@ -340,7 +340,7 @@
}
finally
{
- lock.release();
+ lock.unlock();
}
}
1.34 +4 -6 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.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- PassivationInterceptor.java 29 Nov 2006 22:10:22 -0000 1.33
+++ PassivationInterceptor.java 8 Dec 2006 18:49:17 -0000 1.34
@@ -1,11 +1,9 @@
package org.jboss.cache.interceptors;
-import EDU.oswego.cs.dl.util.concurrent.SynchronizedLong;
+import java.util.concurrent.atomic.AtomicLong;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
-import org.jboss.cache.TreeCache;
-import org.jboss.cache.TreeCacheProxyImpl;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.marshall.MethodDeclarations;
@@ -18,13 +16,13 @@
* 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.33 2006/11/29 22:10:22 genman Exp $
+ * @version $Id: PassivationInterceptor.java,v 1.34 2006/12/08 18:49:17 genman Exp $
*/
public class PassivationInterceptor extends Interceptor implements PassivationInterceptorMBean
{
protected CacheLoader loader = null;
- private SynchronizedLong m_passivations = new SynchronizedLong(0);
+ private AtomicLong m_passivations = new AtomicLong(0);
public synchronized void setCache(CacheSPI cache)
{
@@ -68,7 +66,7 @@
if (getStatisticsEnabled() && configuration.getExposeManagementStatistics())
{
- m_passivations.increment();
+ m_passivations.getAndIncrement();
}
}
catch (NodeNotLoadedException e)
1.39 +2 -2 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.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- CacheStoreInterceptor.java 16 Nov 2006 15:40:44 -0000 1.38
+++ CacheStoreInterceptor.java 8 Dec 2006 18:49:17 -0000 1.39
@@ -1,6 +1,5 @@
package org.jboss.cache.interceptors;
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
@@ -21,13 +20,14 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
/**
* 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.38 2006/11/16 15:40:44 msurtani Exp $
+ * @version $Id: CacheStoreInterceptor.java,v 1.39 2006/12/08 18:49:17 genman Exp $
*/
public class CacheStoreInterceptor extends BaseCacheLoaderInterceptor implements CacheStoreInterceptorMBean
{
1.30 +11 -9 JBossCache/src/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: DataGravitatorInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/DataGravitatorInterceptor.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- DataGravitatorInterceptor.java 20 Nov 2006 03:53:54 -0000 1.29
+++ DataGravitatorInterceptor.java 8 Dec 2006 18:49:17 -0000 1.30
@@ -6,7 +6,6 @@
*/
package org.jboss.cache.interceptors;
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheException;
@@ -17,7 +16,6 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
import org.jboss.cache.TransactionEntry;
-import org.jboss.cache.TreeCacheProxyImpl;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.config.Configuration;
@@ -35,16 +33,20 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
/**
- * The Data Gravitator interceptor intercepts cache misses and attempts t gravitate data from other parts of the cluster.
+ * The Data Gravitator interceptor intercepts cache misses and attempts t
+ * gravitate data from other parts of the cluster.
* <p/>
- * Only used if Buddy Replication is enabled. Also, the interceptor only kicks in if an {@link org.jboss.cache.config.Option} is passed in to
- * force Data Gravitation for a specific invocation or if <b>autoDataGravitation</b> is set to <b>true</b> when configuring
- * Buddy Replication.
+ * Only used if Buddy Replication is enabled. Also, the interceptor only kicks
+ * in if an {@link org.jboss.cache.config.Option} is passed in to force Data
+ * Gravitation for a specific invocation or if <b>autoDataGravitation</b> is
+ * set to <b>true</b> when configuring Buddy Replication.
* <p/>
- * See the JBoss Cache User Guide for more details on configuration options. There is a section dedicated to Buddy Replication
- * in the Replication chapter.
+ * See the JBoss Cache User Guide for more details on configuration options.
+ * There is a section dedicated to Buddy Replication in the Replication
+ * chapter.
*
* @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
*/
1.43 +2 -4 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.42
retrieving revision 1.43
diff -u -b -r1.42 -r1.43
--- ActivationInterceptor.java 29 Nov 2006 22:10:22 -0000 1.42
+++ ActivationInterceptor.java 8 Dec 2006 18:49:17 -0000 1.43
@@ -1,14 +1,11 @@
package org.jboss.cache.interceptors;
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
import org.jboss.cache.Fqn;
import org.jboss.cache.GlobalTransaction;
import org.jboss.cache.Modification;
import org.jboss.cache.Node;
import org.jboss.cache.TransactionEntry;
import org.jboss.cache.TransactionTable;
-import org.jboss.cache.TreeCache;
-import org.jboss.cache.TreeCacheProxyImpl;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.marshall.MethodDeclarations;
@@ -20,6 +17,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
/**
* Loads nodes that don't exist at the time of the call into memory from the CacheLoader.
@@ -27,7 +25,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.42 2006/11/29 22:10:22 genman Exp $
+ * @version $Id: ActivationInterceptor.java,v 1.43 2006/12/08 18:49:17 genman Exp $
*/
public class ActivationInterceptor extends CacheLoaderInterceptor implements ActivationInterceptorMBean
{
1.31 +1 -1 JBossCache/src/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: OptimisticReplicationInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- OptimisticReplicationInterceptor.java 6 Dec 2006 16:28:37 -0000 1.30
+++ OptimisticReplicationInterceptor.java 8 Dec 2006 18:49:17 -0000 1.31
@@ -6,7 +6,6 @@
*/
package org.jboss.cache.interceptors;
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
import org.jboss.cache.GlobalTransaction;
@@ -26,6 +25,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
/**
* Replication interceptor for the optimistically locked interceptor chain
1.24 +4 -4 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.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- CacheMgmtInterceptor.java 18 Oct 2006 11:07:55 -0000 1.23
+++ CacheMgmtInterceptor.java 8 Dec 2006 18:49:17 -0000 1.24
@@ -21,7 +21,6 @@
*/
package org.jboss.cache.interceptors;
-import EDU.oswego.cs.dl.util.concurrent.SynchronizedLong;
import org.jboss.cache.CacheListener;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
@@ -38,12 +37,13 @@
import javax.management.NotificationListener;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
/**
* Captures cache management statistics
*
* @author Jerry Gauthier
- * @version $Id: CacheMgmtInterceptor.java,v 1.23 2006/10/18 11:07:55 msurtani Exp $
+ * @version $Id: CacheMgmtInterceptor.java,v 1.24 2006/12/08 18:49:17 genman Exp $
*/
public class CacheMgmtInterceptor extends Interceptor implements CacheMgmtInterceptorMBean, NotificationBroadcaster
{
@@ -80,7 +80,7 @@
private static final String NOTIFICATION_NAME = Notification.class.getName();
private static final String NOTIFICATION_DESCR = "JBossCache event notifications";
- private SynchronizedLong m_seq = new SynchronizedLong(0);
+ private AtomicLong m_seq = new AtomicLong(0);
private int m_listeners = 0;
private long m_hit_times = 0;
private long m_miss_times = 0;
@@ -343,7 +343,7 @@
{
private long seq()
{
- return m_seq.increment();
+ return m_seq.getAndIncrement();
}
public void cacheStarted(CacheSPI cache)
1.67 +1 -2 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.66
retrieving revision 1.67
diff -u -b -r1.66 -r1.67
--- TxInterceptor.java 20 Nov 2006 03:53:54 -0000 1.66
+++ TxInterceptor.java 8 Dec 2006 18:49:17 -0000 1.67
@@ -6,7 +6,6 @@
*/
package org.jboss.cache.interceptors;
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.GlobalTransaction;
@@ -14,7 +13,6 @@
import org.jboss.cache.OptimisticTransactionEntry;
import org.jboss.cache.ReplicationException;
import org.jboss.cache.TransactionEntry;
-import org.jboss.cache.TreeCacheProxyImpl;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Option;
import org.jboss.cache.marshall.MethodCall;
@@ -30,6 +28,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
/**
* This interceptor is the new default at the head of all interceptor chains,
More information about the jboss-cvs-commits
mailing list