From jbosscache-commits at lists.jboss.org Fri Aug 1 04:39:16 2008 Content-Type: multipart/mixed; boundary="===============4702771323880925918==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6477 - core/trunk/src/main/java/org/jboss/cache/commands. Date: Fri, 01 Aug 2008 04:39:16 -0400 Message-ID: --===============4702771323880925918== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-01 04:39:15 -0400 (Fri, 01 Aug 2008) New Revision: 6477 Modified: core/trunk/src/main/java/org/jboss/cache/commands/OptimisticCommandsFact= oryImpl.java core/trunk/src/main/java/org/jboss/cache/commands/PessimisticCommandsFac= toryImpl.java Log: added createNodeCommand for opt locking deprecated opt commands factory Modified: core/trunk/src/main/java/org/jboss/cache/commands/OptimisticComma= ndsFactoryImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/OptimisticCommandsFac= toryImpl.java 2008-07-31 18:08:14 UTC (rev 6476) +++ core/trunk/src/main/java/org/jboss/cache/commands/OptimisticCommandsFac= toryImpl.java 2008-08-01 08:39:15 UTC (rev 6477) @@ -2,6 +2,7 @@ = import org.jboss.cache.Fqn; import org.jboss.cache.commands.legacy.read.LegacyGravitateDataCommand; +import org.jboss.cache.commands.legacy.write.CreateNodeCommand; import org.jboss.cache.commands.legacy.write.LegacyEvictCommand; import org.jboss.cache.commands.legacy.write.VersionedInvalidateCommand; import org.jboss.cache.commands.read.GravitateDataCommand; @@ -13,7 +14,10 @@ * * @author Manik Surtani (manik(a)jbo= ss.org) * @since 3.0 + * @deprecated will be removed with opt locking */ +(a)Deprecated +(a)SuppressWarnings("deprecation") public class OptimisticCommandsFactoryImpl extends CommandsFactoryImpl { @Override @@ -42,12 +46,28 @@ } = @Override + public CreateNodeCommand buildCreateNodeCommand(Fqn fqn) + { + CreateNodeCommand command =3D new CreateNodeCommand(fqn); + command.initialize(dataContainer); + return command; + } + + + @Override public ReplicableCommand fromStream(int id, Object[] parameters) { ReplicableCommand command; boolean skipSetParams =3D false; switch (id) { + case CreateNodeCommand.METHOD_ID: + { + CreateNodeCommand returnValue =3D new CreateNodeCommand(null); + returnValue.initialize(dataContainer); + command =3D returnValue; + break; + } case GravitateDataCommand.METHOD_ID: { LegacyGravitateDataCommand returnValue =3D new LegacyGravitate= DataCommand(rpcManager.getLocalAddress()); Modified: core/trunk/src/main/java/org/jboss/cache/commands/PessimisticComm= andsFactoryImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/PessimisticCommandsFa= ctoryImpl.java 2008-07-31 18:08:14 UTC (rev 6476) +++ core/trunk/src/main/java/org/jboss/cache/commands/PessimisticCommandsFa= ctoryImpl.java 2008-08-01 08:39:15 UTC (rev 6477) @@ -2,7 +2,6 @@ = import org.jboss.cache.Fqn; import org.jboss.cache.commands.legacy.read.PessGetChildrenNamesCommand; -import org.jboss.cache.commands.legacy.write.CreateNodeCommand; import org.jboss.cache.commands.legacy.write.PessClearDataCommand; import org.jboss.cache.commands.legacy.write.PessMoveCommand; import org.jboss.cache.commands.legacy.write.PessPutDataMapCommand; @@ -30,7 +29,10 @@ * @author Manik Surtani (manik(a)jbo= ss.org) * @see org.jboss.cache.commands.legacy.ReversibleCommand * @since 3.0 + * @deprecated will be removed with possimistic locking */ +(a)Deprecated +(a)SuppressWarnings("deprecation") public class PessimisticCommandsFactoryImpl extends OptimisticCommandsFact= oryImpl { @Override @@ -98,14 +100,6 @@ } = @Override - public CreateNodeCommand buildCreateNodeCommand(Fqn fqn) - { - CreateNodeCommand command =3D new CreateNodeCommand(fqn); - command.initialize(dataContainer); - return command; - } - - @Override public InvalidateCommand buildInvalidateCommand(Fqn fqn) { InvalidateCommand command =3D new InvalidateCommand(fqn); @@ -185,13 +179,6 @@ command =3D returnValue; break; } - case CreateNodeCommand.METHOD_ID: - { - CreateNodeCommand returnValue =3D new CreateNodeCommand(null); - returnValue.initialize(dataContainer); - command =3D returnValue; - break; - } case InvalidateCommand.METHOD_ID: { InvalidateCommand returnValue =3D new InvalidateCommand(null); --===============4702771323880925918==-- From jbosscache-commits at lists.jboss.org Fri Aug 1 05:04:42 2008 Content-Type: multipart/mixed; boundary="===============7949973549912777162==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6478 - core/trunk/src/test/java/org/jboss/cache/profiling. Date: Fri, 01 Aug 2008 05:04:40 -0400 Message-ID: --===============7949973549912777162== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-01 05:04:40 -0400 (Fri, 01 Aug 2008) New Revision: 6478 Added: core/trunk/src/test/java/org/jboss/cache/profiling/ProfileMapViewTest.ja= va Log: added test Copied: core/trunk/src/test/java/org/jboss/cache/profiling/ProfileMapViewTe= st.java (from rev 6476, core/trunk/src/test/java/org/jboss/cache/profiling/= ProfileTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/profiling/ProfileMapViewTest.j= ava (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/profiling/ProfileMapViewTest.j= ava 2008-08-01 09:04:40 UTC (rev 6478) @@ -0,0 +1,305 @@ +package org.jboss.cache.profiling; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.cache.Cache; +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.Configuration.NodeLockingScheme; +import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; +import org.jboss.cache.lock.IsolationLevel; +import org.jboss.cache.util.Caches; +import org.jboss.cache.util.Caches.HashKeySelector; +import org.jboss.cache.util.TestingUtil; +import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +(a)Test(groups =3D "profiling") +public class ProfileMapViewTest +{ + /* + Test configuration options + */ + protected static final long DURATION =3D 60 * 1000; // 1 min of GENERAT= ION =3D a lot of processing. :-) + protected static final int NUM_THREADS =3D 15; + protected static final int MAX_RANDOM_SLEEP_MILLIS =3D 1; + protected static final int MAX_ENTRIES =3D 200; + protected static final int WARMUP_LOOPS =3D 20000; + protected static final boolean USE_SLEEP =3D false; // throttle generat= ion a bit + + private List keys =3D new ArrayList(MAX_ENTRIES); + private Random r =3D new Random(); + private Cache cache; + private Map map; + + + private Log log =3D LogFactory.getLog(ProfileTest.class); + + @BeforeTest + public void setUp() + { + Configuration cfg =3D UnitTestCacheConfigurationFactory.createConfig= uration(Configuration.CacheMode.LOCAL); + cfg.setNodeLockingScheme(NodeLockingScheme.MVCC); + cfg.setConcurrencyLevel(500); + cache =3D new DefaultCacheFactory().createCache(cfg,= false); + } + + @AfterTest + public void tearDown() + { + cache.stop(); + } + + + public void testLocalModeMVCC_RC() throws Exception + { + cache.getConfiguration().setIsolationLevel(IsolationLevel.READ_COMMI= TTED); + runCompleteTest(); + } + + public void testLocalModeMVCC_RR() throws Exception + { + cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE= _READ); + runCompleteTest(); + } + + + private void runCompleteTest() throws Exception + { + init(); + startup(); + warmup(); + doTest(); + + // wait for user exit + System.in.read(); + } + + /** + * Thr following test phases can be profiled individually using trigger= s in JProfiler. + */ + + protected void init() + { + long startTime =3D System.currentTimeMillis(); + log.warn("Starting init() phase"); + keys.clear(); + for (int i =3D 0; i < MAX_ENTRIES; i++) + { + String key =3D createRandomKey(r); + while (keys.contains(key)) key =3D createRandomKey(r); + if (i % 10 =3D=3D 0) + { + log.warn("Generated " + i + " fqns"); + } + keys.add(key); + } + System.gc(); + long duration =3D System.currentTimeMillis() - startTime; + log.warn("Finished init() phase. " + printDuration(duration)); + } + + private String createRandomKey(Random r) + { + StringBuilder s =3D new StringBuilder("/"); + int depth =3D r.nextInt(3); + for (int i =3D 0; i < depth; i++) + { + s.append(r.nextInt(Integer.MAX_VALUE)).append("/"); + } + + return s.toString(); + } + + private Map createMap(Cache cache) + { + return Caches.asPartitionedMap(cache.getRoot(), new HashKeySelector(= 128)); + } + + private void startup() + { + long startTime =3D System.currentTimeMillis(); + log.warn("Starting cache"); + cache.start(); + map =3D createMap(cache); + long duration =3D System.currentTimeMillis() - startTime; + log.warn("Started cache. " + printDuration(duration)); + } + + private void warmup() throws InterruptedException + { + long startTime =3D System.currentTimeMillis(); + ExecutorService exec =3D Executors.newFixedThreadPool(NUM_THREADS); + log.warn("Starting warmup"); + // creates all the Fqns since this can be expensive and we don't rea= lly want to measure this (for now) + for (final String key : keys) + { + exec.execute(new Runnable() + { + public void run() + { + // this will create the necessary nodes. +// cache.put(f, Collections.emptyMap()); + map.put(key, "value"); + } + }); + } + + // loop through WARMUP_LOOPS gets and puts for JVM optimisation + for (int i =3D 0; i < WARMUP_LOOPS; i++) + { + exec.execute(new Runnable() + { + public void run() + { +// Fqn f =3D fqns.get(r.nextInt(MAX_ENTRIES)); + String key =3D keys.get(r.nextInt(MAX_ENTRIES)); +// cache.get(f, ""); +// cache.put(f, "k", "v"); +// cache.remove(f, "k"); + map.get(key); + map.put(key, "value"); + map.remove(key); + } + }); + } + + exec.shutdown(); + exec.awaitTermination(360, TimeUnit.SECONDS); + + long duration =3D System.currentTimeMillis() - startTime; + log.warn("Finished warmup. " + printDuration(duration)); + //cache.removeNode(Fqn.ROOT); + cache.stop(); + cache.start(); + map =3D createMap(cache); + } + + private void doTest() throws Exception + { + ExecutorService exec =3D Executors.newFixedThreadPool(NUM_THREADS); + long end =3D System.currentTimeMillis() + DURATION; + long startTime =3D System.currentTimeMillis(); + log.warn("Starting test"); + int i =3D 0; + while (System.currentTimeMillis() < end) + { + MyRunnable r =3D null; + switch (i % 3) + { + case 0: + r =3D new Putter(i++); + break; + case 1: + r =3D new Getter(i++); + break; + case 2: + r =3D new Remover(i++); + break; + } + exec.execute(r); +// if (USE_SLEEP) TestingUtil.sleepRandom(MAX_RANDOM_SLEEP_MILLIS); + if (USE_SLEEP) TestingUtil.sleepThread(MAX_RANDOM_SLEEP_MILLIS); + } + log.warn("Finished generating runnables; awaiting executor completio= n"); + // wait for executors to complete! + exec.shutdown(); + exec.awaitTermination(((long) i), TimeUnit.SECONDS); // wait up to = 1 sec for each call? + long duration =3D System.currentTimeMillis() - startTime; + log.warn("Finished test. " + printDuration(duration)); + } + + enum Mode + { + PUT, GET, REMOVE + } + + private abstract class MyRunnable implements Runnable + { + int id; + Mode mode; + + public void run() + { + if (id % 100 =3D=3D 0) log.warn("Processing iteration " + id); + String k =3D getRandomString(); + String key =3D keys.get(r.nextInt(MAX_ENTRIES)); + switch (mode) + { + case PUT: +// cache.put(f, k, getRandomString()); + map.put(key, getRandomString()); + break; + case GET: +// cache.get(f, k); + map.get(key); + break; + case REMOVE: +// cache.remove(f, k); + map.remove(key); + break; + } + } + } + + private class Putter extends MyRunnable + { + private Putter(int id) + { + this.id =3D id; + mode =3D Mode.PUT; + } + } + + private class Getter extends MyRunnable + { + private Getter(int id) + { + this.id =3D id; + mode =3D Mode.GET; + } + } + + private class Remover extends MyRunnable + { + private Remover(int id) + { + this.id =3D id; + mode =3D Mode.REMOVE; + } + } + + private String getRandomString() + { + StringBuilder sb =3D new StringBuilder(); + int len =3D r.nextInt(10); + + for (int i =3D 0; i < len; i++) + { + sb.append((char) (63 + r.nextInt(26))); + } + return sb.toString(); + } + + private String printDuration(long duration) + { + if (duration > 2000) + { + double dSecs =3D ((double) duration / (double) 1000); + return "Duration: " + dSecs + " seconds"; + } + else + { + return "Duration: " + duration + " millis"; + } + } +} \ No newline at end of file --===============7949973549912777162==-- From jboss-qa-internal at redhat.com Fri Aug 1 06:47:34 2008 Content-Type: multipart/mixed; boundary="===============4888004006134275167==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23527?= Date: Fri, 01 Aug 2008 06:47:31 -0400 Message-ID: <587808797.7211217587651700.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 269443537.6241217541983146.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============4888004006134275167== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/527/changes --===============4888004006134275167==-- From jbosscache-commits at lists.jboss.org Fri Aug 1 07:03:23 2008 Content-Type: multipart/mixed; boundary="===============4958440061213256072==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6479 - in core/trunk/src: main/java/org/jboss/cache/commands/write and 4 other directories. Date: Fri, 01 Aug 2008 07:03:23 -0400 Message-ID: --===============4958440061213256072== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-01 07:03:23 -0400 (Fri, 01 Aug 2008) New Revision: 6479 Added: core/trunk/src/main/java/org/jboss/cache/notifications/annotation/NodeIn= validated.java core/trunk/src/main/java/org/jboss/cache/notifications/event/NodeInvalid= atedEvent.java core/trunk/src/test/java/org/jboss/cache/notifications/NotifyNodeInvalid= atedTest.java Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/Versioned= InvalidateCommand.java core/trunk/src/main/java/org/jboss/cache/commands/write/InvalidateComman= d.java core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java core/trunk/src/main/java/org/jboss/cache/notifications/annotation/CacheL= istener.java core/trunk/src/main/java/org/jboss/cache/notifications/event/Event.java core/trunk/src/main/java/org/jboss/cache/notifications/event/EventImpl.j= ava core/trunk/src/test/java/org/jboss/cache/notifications/EventLog.java core/trunk/src/test/java/org/jboss/cache/notifications/NotifierAnnotatio= nsTest.java core/trunk/src/test/java/org/jboss/cache/notifications/NotifierTest.java core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListen= erTest.java Log: JBCACHE-86 - a NodeInvalidated callback to listeners Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/Ve= rsionedInvalidateCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/Versione= dInvalidateCommand.java 2008-08-01 09:04:40 UTC (rev 6478) +++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/Versione= dInvalidateCommand.java 2008-08-01 11:03:23 UTC (rev 6479) @@ -129,10 +129,10 @@ = protected void removeData(NodeSPI n, InvocationContext ctx) throws Cach= eException { - notifier.notifyNodeEvicted(fqn, true, ctx); + notifier.notifyNodeInvalidated(fqn, true, ctx); n.clearDataDirect(); n.setDataLoaded(false); - notifier.notifyNodeEvicted(fqn, false, ctx); + notifier.notifyNodeInvalidated(fqn, false, ctx); } = public DataVersion getDataVersion() Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/Invalidat= eCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/write/InvalidateComma= nd.java 2008-08-01 09:04:40 UTC (rev 6478) +++ core/trunk/src/main/java/org/jboss/cache/commands/write/InvalidateComma= nd.java 2008-08-01 11:03:23 UTC (rev 6479) @@ -65,14 +65,14 @@ = boolean evictNode(Fqn fqn, InvocationContext ctx) { - notifier.notifyNodeEvicted(fqn, true, ctx); + notifier.notifyNodeInvalidated(fqn, true, ctx); try { return dataContainer.evict(fqn); } finally { - notifier.notifyNodeEvicted(fqn, false, ctx); + notifier.notifyNodeInvalidated(fqn, false, ctx); } } = Modified: core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java 20= 08-08-01 09:04:40 UTC (rev 6478) +++ core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java 20= 08-08-01 11:03:23 UTC (rev 6479) @@ -56,6 +56,11 @@ void notifyNodeEvicted(Fqn fqn, boolean pre, InvocationContext ctx); = /** + * Notifies all registered listeners of a nodeInvalidated event. + */ + void notifyNodeInvalidated(Fqn fqn, boolean pre, InvocationContext ctx); + + /** * Notifies all registered listeners of a nodeLoaded event. */ void notifyNodeLoaded(Fqn fqn, boolean pre, Map data, InvocationContext= ctx); Modified: core/trunk/src/main/java/org/jboss/cache/notifications/NotifierIm= pl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.jav= a 2008-08-01 09:04:40 UTC (rev 6478) +++ core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.jav= a 2008-08-01 11:03:23 UTC (rev 6479) @@ -28,11 +28,12 @@ import org.jgroups.View; = import javax.transaction.Transaction; +import java.lang.annotation.Annotation; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -55,31 +56,35 @@ private static final Class[] allowedMethodAnnotations =3D { CacheStarted.class, CacheStopped.class, CacheBlocked.class,= CacheUnblocked.class, NodeCreated.class, NodeRemoved.class, NodeVisited.cl= ass, NodeModified.class, NodeMoved.class, - NodeActivated.class, NodePassivated.class, NodeLoaded.class= , NodeEvicted.class, TransactionRegistered.class, TransactionCompleted.clas= s, ViewChanged.class, BuddyGroupChanged.class + NodeActivated.class, NodePassivated.class, NodeLoaded.class= , NodeEvicted.class, TransactionRegistered.class, TransactionCompleted.clas= s, ViewChanged.class, BuddyGroupChanged.class, + NodeInvalidated.class }; private static final Class[] parameterTypes =3D { CacheStartedEvent.class, CacheStoppedEvent.class, CacheBloc= kedEvent.class, CacheUnblockedEvent.class, NodeCreatedEvent.class, NodeRemo= vedEvent.class, NodeVisitedEvent.class, NodeModifiedEvent.class, NodeMovedE= vent.class, - NodeActivatedEvent.class, NodePassivatedEvent.class, NodeLo= adedEvent.class, NodeEvictedEvent.class, TransactionRegisteredEvent.class, = TransactionCompletedEvent.class, ViewChangedEvent.class, BuddyGroupChangedE= vent.class + NodeActivatedEvent.class, NodePassivatedEvent.class, NodeLo= adedEvent.class, NodeEvictedEvent.class, TransactionRegisteredEvent.class, = TransactionCompletedEvent.class, ViewChangedEvent.class, BuddyGroupChangedE= vent.class, + NodeInvalidatedEvent.class }; = - private final List cacheStartedListeners =3D new Co= pyOnWriteArrayList(); - private final List cacheStoppedListeners =3D new Co= pyOnWriteArrayList(); - private final List cacheBlockedListeners =3D new Co= pyOnWriteArrayList(); - private final List cacheUnblockedListeners =3D new = CopyOnWriteArrayList(); - private final List nodeCreatedListeners =3D new Cop= yOnWriteArrayList(); - private final List nodeRemovedListeners =3D new Cop= yOnWriteArrayList(); - private final List nodeVisitedListeners =3D new Cop= yOnWriteArrayList(); - private final List nodeModifiedListeners =3D new Co= pyOnWriteArrayList(); - private final List nodeMovedListeners =3D new CopyO= nWriteArrayList(); - private final List nodeActivatedListeners =3D new C= opyOnWriteArrayList(); - private final List nodePassivatedListeners =3D new = CopyOnWriteArrayList(); - private final List nodeLoadedListeners =3D new Copy= OnWriteArrayList(); - private final List nodeEvictedListeners =3D new Cop= yOnWriteArrayList(); - private final List transactionRegisteredListeners = =3D new CopyOnWriteArrayList(); - private final List transactionCompletedListeners = =3D new CopyOnWriteArrayList(); - private final List viewChangedListeners =3D new Cop= yOnWriteArrayList(); - private final List buddyGroupChangedListeners =3D n= ew CopyOnWriteArrayList(); + final Map, List> listen= ersMap =3D new HashMap, List>(32); + final List cacheStartedListeners =3D new CopyOnWrit= eArrayList(); + final List cacheStoppedListeners =3D new CopyOnWrit= eArrayList(); + final List cacheBlockedListeners =3D new CopyOnWrit= eArrayList(); + final List cacheUnblockedListeners =3D new CopyOnWr= iteArrayList(); + final List nodeCreatedListeners =3D new CopyOnWrite= ArrayList(); + final List nodeRemovedListeners =3D new CopyOnWrite= ArrayList(); + final List nodeVisitedListeners =3D new CopyOnWrite= ArrayList(); + final List nodeModifiedListeners =3D new CopyOnWrit= eArrayList(); + final List nodeMovedListeners =3D new CopyOnWriteAr= rayList(); + final List nodeActivatedListeners =3D new CopyOnWri= teArrayList(); + final List nodePassivatedListeners =3D new CopyOnWr= iteArrayList(); + final List nodeLoadedListeners =3D new CopyOnWriteA= rrayList(); + final List nodeInvalidatedListeners =3D new CopyOnW= riteArrayList(); + final List nodeEvictedListeners =3D new CopyOnWrite= ArrayList(); + final List transactionRegisteredListeners =3D new C= opyOnWriteArrayList(); + final List transactionCompletedListeners =3D new Co= pyOnWriteArrayList(); + final List viewChangedListeners =3D new CopyOnWrite= ArrayList(); + final List buddyGroupChangedListeners =3D new CopyO= nWriteArrayList(); = // final Map> listenerInvocations =3D= new ConcurrentHashMap>(); private Cache cache; @@ -88,10 +93,29 @@ = public NotifierImpl() { + listenersMap.put(CacheStarted.class, cacheStartedListeners); + listenersMap.put(CacheStopped.class, cacheStoppedListeners); + listenersMap.put(CacheBlocked.class, cacheBlockedListeners); + listenersMap.put(CacheUnblocked.class, cacheUnblockedListeners); + listenersMap.put(NodeCreated.class, nodeCreatedListeners); + listenersMap.put(NodeRemoved.class, nodeRemovedListeners); + listenersMap.put(NodeVisited.class, nodeVisitedListeners); + listenersMap.put(NodeModified.class, nodeModifiedListeners); + listenersMap.put(NodeMoved.class, nodeMovedListeners); + listenersMap.put(NodeActivated.class, nodeActivatedListeners); + listenersMap.put(NodePassivated.class, nodePassivatedListeners); + listenersMap.put(NodeLoaded.class, nodeLoadedListeners); + listenersMap.put(NodeEvicted.class, nodeEvictedListeners); + listenersMap.put(TransactionRegistered.class, transactionRegisteredL= isteners); + listenersMap.put(TransactionCompleted.class, transactionCompletedLis= teners); + listenersMap.put(ViewChanged.class, viewChangedListeners); + listenersMap.put(BuddyGroupChanged.class, buddyGroupChangedListeners= ); + listenersMap.put(NodeInvalidated.class, nodeInvalidatedListeners); } = public NotifierImpl(Cache cache) { + this(); this.cache =3D cache; } = @@ -120,6 +144,7 @@ * * @param listener object to be considered as a listener. */ + @SuppressWarnings("unchecked") private void validateAndAddListenerInvocation(Object listener) { testListenerClassValidity(listener.getClass()); @@ -162,7 +187,7 @@ = private void addListenerInvocation(Class annotation, ListenerInvocation= li) { - List result =3D getListenersForAnnotation(annota= tion); + List result =3D getListenerCollectionForAnnotati= on(annotation); result.add(li); } = @@ -179,7 +204,7 @@ private void removeListenerInvocation(Class annotation, Object listener) { if (listener =3D=3D null) return; - List l =3D getListenersForAnnotation(annotation); + List l =3D getListenerCollectionForAnnotation(an= notation); Set markedForRemoval =3D new HashSet(); for (ListenerInvocation li : l) { @@ -216,23 +241,10 @@ public Set getCacheListeners() { Set result =3D new HashSet(); - result.addAll(getListeningObjects(cacheStartedListeners)); - result.addAll(getListeningObjects(cacheStoppedListeners)); - result.addAll(getListeningObjects(cacheBlockedListeners)); - result.addAll(getListeningObjects(cacheUnblockedListeners)); - result.addAll(getListeningObjects(nodeCreatedListeners)); - result.addAll(getListeningObjects(nodeRemovedListeners)); - result.addAll(getListeningObjects(nodeVisitedListeners)); - result.addAll(getListeningObjects(nodeModifiedListeners)); - result.addAll(getListeningObjects(nodeMovedListeners)); - result.addAll(getListeningObjects(nodeActivatedListeners)); - result.addAll(getListeningObjects(nodePassivatedListeners)); - result.addAll(getListeningObjects(nodeLoadedListeners)); - result.addAll(getListeningObjects(nodeEvictedListeners)); - result.addAll(getListeningObjects(transactionRegisteredListeners)); - result.addAll(getListeningObjects(transactionCompletedListeners)); - result.addAll(getListeningObjects(viewChangedListeners)); - result.addAll(getListeningObjects(buddyGroupChangedListeners)); + for (List list : listenersMap.values()) + { + for (ListenerInvocation li : list) result.add(li.target); + } return Collections.unmodifiableSet(result); } = @@ -359,6 +371,25 @@ } } = + public void notifyNodeInvalidated(final Fqn fqn, final boolean pre, Inv= ocationContext ctx) + { + if (!nodeInvalidatedListeners.isEmpty()) + { + final boolean originLocal =3D ctx.isOriginLocal(); + Transaction tx =3D ctx.getTransaction(); + InvocationContext backup =3D resetInvocationContext(ctx); + EventImpl e =3D new EventImpl(); + e.setCache(cache); + e.setOriginLocal(originLocal); + e.setPre(pre); + e.setFqn(fqn); + e.setTransaction(tx); + e.setType(NODE_INVALIDATED); + for (ListenerInvocation listener : nodeInvalidatedListeners) list= ener.invoke(e); + restoreInvocationContext(backup); + } + } + public void notifyNodeLoaded(Fqn fqn, boolean pre, Map data, Invocation= Context ctx) { if (!nodeLoadedListeners.isEmpty()) @@ -619,174 +650,10 @@ = } = - private List getListenersForAnnotation(Class annota= tion) + private List getListenerCollectionForAnnotation(Cla= ss annotation) { - if (annotation =3D=3D CacheStarted.class) - { - return cacheStartedListeners; - } - else if (annotation =3D=3D CacheStopped.class) - { - return cacheStoppedListeners; - } - else if (annotation =3D=3D CacheBlocked.class) - { - return cacheBlockedListeners; - } - else if (annotation =3D=3D CacheUnblocked.class) - { - return cacheUnblockedListeners; - } - else if (annotation =3D=3D NodeCreated.class) - { - return nodeCreatedListeners; - } - else if (annotation =3D=3D NodeRemoved.class) - { - return nodeRemovedListeners; - } - else if (annotation =3D=3D NodeVisited.class) - { - return nodeVisitedListeners; - } - else if (annotation =3D=3D NodeModified.class) - { - return nodeModifiedListeners; - } - else if (annotation =3D=3D NodeMoved.class) - { - return nodeMovedListeners; - } - else if (annotation =3D=3D NodeActivated.class) - { - return nodeActivatedListeners; - } - else if (annotation =3D=3D NodePassivated.class) - { - return nodePassivatedListeners; - } - else if (annotation =3D=3D NodeLoaded.class) - { - return nodeLoadedListeners; - } - else if (annotation =3D=3D NodeEvicted.class) - { - return nodeEvictedListeners; - } - else if (annotation =3D=3D TransactionRegistered.class) - { - return transactionRegisteredListeners; - } - else if (annotation =3D=3D TransactionCompleted.class) - { - return transactionCompletedListeners; - } - else if (annotation =3D=3D ViewChanged.class) - { - return viewChangedListeners; - } - else if (annotation =3D=3D BuddyGroupChanged.class) - { - return buddyGroupChangedListeners; - } - else - { - throw new RuntimeException("Unknown listener class: " + annotatio= n); - } + List list =3D listenersMap.get(annotation); + if (list =3D=3D null) throw new CacheException("Unknown listener ann= otation: " + annotation); + return list; } - - private Collection getListeningObjects(List cacheSt= artedListeners) - { - Set result =3D new HashSet(); - for (ListenerInvocation li : cacheStartedListeners) - { - result.add(li.target); - } - return result; - } - - public List getCacheStartedListeners() - { - return cacheStartedListeners; - } - - public List getCacheStoppedListeners() - { - return cacheStoppedListeners; - } - - public List getCacheBlockedListeners() - { - return cacheBlockedListeners; - } - - public List getCacheUnblockedListeners() - { - return cacheUnblockedListeners; - } - - public List getNodeCreatedListeners() - { - return nodeCreatedListeners; - } - - public List getNodeRemovedListeners() - { - return nodeRemovedListeners; - } - - public List getNodeVisitedListeners() - { - return nodeVisitedListeners; - } - - public List getNodeModifiedListeners() - { - return nodeModifiedListeners; - } - - public List getNodeMovedListeners() - { - return nodeMovedListeners; - } - - public List getNodeActivatedListeners() - { - return nodeActivatedListeners; - } - - public List getNodePassivatedListeners() - { - return nodePassivatedListeners; - } - - public List getNodeLoadedListeners() - { - return nodeLoadedListeners; - } - - public List getNodeEvictedListeners() - { - return nodeEvictedListeners; - } - - public List getTransactionRegisteredListeners() - { - return transactionRegisteredListeners; - } - - public List getTransactionCompletedListeners() - { - return transactionCompletedListeners; - } - - public List getViewChangedListeners() - { - return viewChangedListeners; - } - - public List getBuddyGroupChangedListeners() - { - return buddyGroupChangedListeners; - } } Modified: core/trunk/src/main/java/org/jboss/cache/notifications/annotation= /CacheListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/notifications/annotation/Cache= Listener.java 2008-08-01 09:04:40 UTC (rev 6478) +++ core/trunk/src/main/java/org/jboss/cache/notifications/annotation/Cache= Listener.java 2008-08-01 11:03:23 UTC (rev 6479) @@ -152,6 +152,11 @@ * {@link org.jboss.cache.notifications.event.BuddyGro= upChangedEvent} * Buddy replication is enabled and one of the buddy gr= oups that the instance is a member of has changed it's membership. * + * + * {@link NodeInvalidated} + * {@link org.jboss.cache.notifications.event.NodeInva= lidatedEvent} + * A node was invalidated by a remote cache. Only if c= ache mode is INVALIDATION_SYNC or INVALIDATION_ASYNC. + * *

* *

@@ -283,12 +288,10 @@ * @see TransactionCompleted * @see TransactionRegistered * @see BuddyGroupChanged + * @see NodeInvalidated * @see org.jboss.cache.Cache#addCacheListener(Object) - * @see org.jboss.cache.Cache#addCacheListener(org.jboss.cache.Fqn,Object) * @see org.jboss.cache.Cache#removeCacheListener(Object) - * @see org.jboss.cache.Cache#removeCacheListener(org.jboss.cache.Fqn,Obje= ct) * @see org.jboss.cache.Cache#getCacheListeners() - * @see org.jboss.cache.Cache#getCacheListeners(org.jboss.cache.Fqn) * @since 2.0.0 */ @Retention(RetentionPolicy.RUNTIME) Copied: core/trunk/src/main/java/org/jboss/cache/notifications/annotation/N= odeInvalidated.java (from rev 6476, core/trunk/src/main/java/org/jboss/cach= e/notifications/annotation/NodeEvicted.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/notifications/annotation/NodeI= nvalidated.java (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/notifications/annotation/NodeI= nvalidated.java 2008-08-01 11:03:23 UTC (rev 6479) @@ -0,0 +1,23 @@ +package org.jboss.cache.notifications.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * This annotation should be used on methods that need to be notified when= a node is invalidated. + *

+ * Methods annotated with this annotation should be public and take in a s= ingle parameter, a {@link org.jboss.cache.notifications.event.NodeInvalidat= edEvent} + * otherwise an {@link org.jboss.cache.notifications.IncorrectCacheListene= rException} will be thrown when registering + * your cache listener. + * + * @author Manik Surtani + * @see org.jboss.cache.notifications.annotation.CacheListener + * @since 3.0 + */ +(a)Retention(RetentionPolicy.RUNTIME) +(a)Target(ElementType.METHOD) +public @interface NodeInvalidated +{ +} \ No newline at end of file Modified: core/trunk/src/main/java/org/jboss/cache/notifications/event/Even= t.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/notifications/event/Event.java= 2008-08-01 09:04:40 UTC (rev 6478) +++ core/trunk/src/main/java/org/jboss/cache/notifications/event/Event.java= 2008-08-01 11:03:23 UTC (rev 6479) @@ -14,7 +14,7 @@ { CACHE_STARTED, CACHE_STOPPED, CACHE_BLOCKED, CACHE_UNBLOCKED, NODE_A= CTIVATED, NODE_PASSIVATED, NODE_LOADED, NODE_EVICTED, NODE_CREATED, NODE_REMOVED, NODE_MODIFIED= , NODE_MOVED, NODE_VISITED, - TRANSACTION_COMPLETED, TRANSACTION_REGISTERED, VIEW_CHANGED, BUDDY_G= ROUP_CHANGED + TRANSACTION_COMPLETED, TRANSACTION_REGISTERED, VIEW_CHANGED, BUDDY_G= ROUP_CHANGED, NODE_INVALIDATED } = /** Modified: core/trunk/src/main/java/org/jboss/cache/notifications/event/Even= tImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/notifications/event/EventImpl.= java 2008-08-01 09:04:40 UTC (rev 6478) +++ core/trunk/src/main/java/org/jboss/cache/notifications/event/EventImpl.= java 2008-08-01 11:03:23 UTC (rev 6479) @@ -17,7 +17,7 @@ public class EventImpl implements CacheBlockedEvent, CacheUnblockedEvent, = CacheStartedEvent, CacheStoppedEvent, NodeActivatedEvent, NodeCreatedEvent, NodeEvictedEvent, NodeLoadedEv= ent, NodeModifiedEvent, NodeMovedEvent, NodePassivatedEvent, NodeRemovedEvent, NodeVisitedEvent, Transaction= CompletedEvent, TransactionRegisteredEvent, - ViewChangedEvent, BuddyGroupChangedEvent + ViewChangedEvent, BuddyGroupChangedEvent, NodeInvalidatedEvent { private boolean pre =3D false; // by default events are after the fact private Cache cache; Added: core/trunk/src/main/java/org/jboss/cache/notifications/event/NodeInv= alidatedEvent.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/notifications/event/NodeInvali= datedEvent.java (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/notifications/event/NodeInvali= datedEvent.java 2008-08-01 11:03:23 UTC (rev 6479) @@ -0,0 +1,11 @@ +package org.jboss.cache.notifications.event; + +/** + * Notifies a listener of an invalidation event + * + * @author Manik Surtani (manik(a)jbo= ss.org) + * @since 3.0 + */ +public interface NodeInvalidatedEvent extends NodeEvent +{ +} Modified: core/trunk/src/test/java/org/jboss/cache/notifications/EventLog.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/notifications/EventLog.java 20= 08-08-01 09:04:40 UTC (rev 6478) +++ core/trunk/src/test/java/org/jboss/cache/notifications/EventLog.java 20= 08-08-01 11:03:23 UTC (rev 6479) @@ -1,6 +1,17 @@ package org.jboss.cache.notifications; = -import org.jboss.cache.notifications.annotation.*; +import org.jboss.cache.notifications.annotation.CacheListener; +import org.jboss.cache.notifications.annotation.NodeActivated; +import org.jboss.cache.notifications.annotation.NodeCreated; +import org.jboss.cache.notifications.annotation.NodeEvicted; +import org.jboss.cache.notifications.annotation.NodeInvalidated; +import org.jboss.cache.notifications.annotation.NodeModified; +import org.jboss.cache.notifications.annotation.NodeMoved; +import org.jboss.cache.notifications.annotation.NodePassivated; +import org.jboss.cache.notifications.annotation.NodeRemoved; +import org.jboss.cache.notifications.annotation.NodeVisited; +import org.jboss.cache.notifications.annotation.TransactionCompleted; +import org.jboss.cache.notifications.annotation.TransactionRegistered; import org.jboss.cache.notifications.event.Event; import org.jboss.cache.notifications.event.EventImpl; = @@ -22,6 +33,7 @@ @NodeEvicted @NodePassivated @NodeActivated + @NodeInvalidated public void callback(Event e) { events.add(e); Modified: core/trunk/src/test/java/org/jboss/cache/notifications/NotifierAn= notationsTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/notifications/NotifierAnnotati= onsTest.java 2008-08-01 09:04:40 UTC (rev 6478) +++ core/trunk/src/test/java/org/jboss/cache/notifications/NotifierAnnotati= onsTest.java 2008-08-01 11:03:23 UTC (rev 6479) @@ -180,9 +180,9 @@ { Object l =3D new TestMultipleMethodsListener(); n.addCacheListener(l); - List invocations =3D n.getCacheStartedListeners(); + List invocations =3D n.cacheStartedListeners; assertEquals(1, invocations.size()); - invocations =3D n.getCacheStoppedListeners(); + invocations =3D n.cacheStoppedListeners; assertEquals(1, invocations.size()); assertEquals(1, n.getCacheListeners().size()); } @@ -191,9 +191,9 @@ { Object l =3D new TestMultipleAnnotationsOneMethodListener(); n.addCacheListener(l); - List invocations =3D n.getCacheStartedListeners(); + List invocations =3D n.cacheStartedListeners; assertEquals(1, invocations.size()); - invocations =3D n.getCacheStoppedListeners(); + invocations =3D n.cacheStoppedListeners; assertEquals(1, invocations.size()); assertEquals(1, n.getCacheListeners().size()); } @@ -202,7 +202,7 @@ { Object l =3D new TestMultipleMethodsOneAnnotationListener(); n.addCacheListener(l); - List invocations =3D n.getCacheStartedListeners(); + List invocations =3D n.cacheStartedListeners; assertEquals(2, invocations.size()); assertEquals(1, n.getCacheListeners().size()); } Modified: core/trunk/src/test/java/org/jboss/cache/notifications/NotifierTe= st.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/notifications/NotifierTest.jav= a 2008-08-01 09:04:40 UTC (rev 6478) +++ core/trunk/src/test/java/org/jboss/cache/notifications/NotifierTest.jav= a 2008-08-01 11:03:23 UTC (rev 6479) @@ -63,7 +63,6 @@ Map expected =3D new HashMap(); expected.put("k", "v"); notifier.notifyNodeModified(fqn, true, NodeModifiedEvent.Modificatio= nType.PUT_DATA, expected, ctx); - assert notifier.getNodeModifiedListeners().size() =3D=3D 1; assert allEventsListener.nodeModifiedEvent !=3D null; assert allEventsListener.nodeModifiedEvent.getData().equals(expected= ); assert allEventsListener.nodeModifiedEvent.getModificationType() =3D= =3D NodeModifiedEvent.ModificationType.PUT_DATA; Added: core/trunk/src/test/java/org/jboss/cache/notifications/NotifyNodeInv= alidatedTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/notifications/NotifyNodeInvali= datedTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/notifications/NotifyNodeInvali= datedTest.java 2008-08-01 11:03:23 UTC (rev 6479) @@ -0,0 +1,49 @@ +package org.jboss.cache.notifications; + +import org.jboss.cache.Cache; +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.Fqn; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.Configuration.CacheMode; +import org.jboss.cache.config.Configuration.NodeLockingScheme; +import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; +import org.jboss.cache.notifications.event.Event; +import static org.jboss.cache.notifications.event.Event.Type.NODE_INVALIDA= TED; +import org.jboss.cache.notifications.event.EventImpl; +import org.jboss.cache.util.TestingUtil; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.List; + +(a)Test(groups =3D "functional") +public class NotifyNodeInvalidatedTest +{ + public void testInvalidatedCallback() throws CloneNotSupportedException + { + Cache c1 =3D null, c2 =3D null; + try + { + Configuration cfg =3D UnitTestCacheConfigurationFactory.createCon= figuration(CacheMode.INVALIDATION_SYNC, false); + cfg.setNodeLockingScheme(NodeLockingScheme.MVCC); + c1 =3D new DefaultCacheFactory().createCache(cfg.= clone()); + c2 =3D new DefaultCacheFactory().createCache(cfg.= clone()); + EventLog eventLog =3D new EventLog(); + c2.getInvocationContext().getOptionOverrides().setCacheModeLocal(= true); + c2.put("/a/b/c", "x", "y"); + c2.addCacheListener(eventLog); + c1.put("/a/b/c", "k", "v"); + + List expected =3D new ArrayList(); + expected.add(new EventImpl(true, c2, null, null, Fqn.fromString("= /a/b/c"), null, false, null, false, null, NODE_INVALIDATED)); + expected.add(new EventImpl(false, c2, null, null, Fqn.fromString(= "/a/b/c"), null, false, null, false, null, NODE_INVALIDATED)); + + assert expected.equals(eventLog.events) : "Expected " + expected = + " but got " + eventLog.events; + assert c2.getNode("/a/b/c") =3D=3D null; + } + finally + { + TestingUtil.killCaches(c1, c2); + } + } +} Modified: core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCach= eListenerTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListe= nerTest.java 2008-08-01 09:04:40 UTC (rev 6478) +++ core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListe= nerTest.java 2008-08-01 11:03:23 UTC (rev 6479) @@ -63,7 +63,7 @@ = private Cache cache1, cache2; @SuppressWarnings("unused") - private TransactionManager tm1, tm2; + private TransactionManager tm1; private EventLog eventLog1 =3D new EventLog(), eventLog2 =3D new EventL= og(); private Fqn fqn =3D Fqn.fromString("/test"); = @@ -95,7 +95,6 @@ cache2.addCacheListener(eventLog2); = tm1 =3D cache1.getConfiguration().getRuntimeConfig().getTransactionM= anager(); - tm2 =3D cache2.getConfiguration().getRuntimeConfig().getTransactionM= anager(); } = @AfterMethod(alwaysRun =3D true) --===============4958440061213256072==-- From jboss-qa-internal at redhat.com Fri Aug 1 07:29:57 2008 Content-Type: multipart/mixed; boundary="===============0086783077834915451==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23392?= Date: Fri, 01 Aug 2008 07:29:54 -0400 Message-ID: <1241176625.7381217590194550.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1722372164.6321217547395180.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============0086783077834915451== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/392/changes --===============0086783077834915451==-- From jbosscache-commits at lists.jboss.org Fri Aug 1 09:12:47 2008 Content-Type: multipart/mixed; boundary="===============6193582125263605889==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6480 - in core/trunk/src: main/java/org/jboss/cache/eviction and 1 other directories. Date: Fri, 01 Aug 2008 09:12:47 -0400 Message-ID: --===============6193582125263605889== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-01 09:12:46 -0400 (Fri, 01 Aug 2008) New Revision: 6480 Added: core/trunk/src/test/java/org/jboss/cache/eviction/DisabledEvictionThread= Test.java Modified: core/trunk/src/main/java/org/jboss/cache/RegionImpl.java core/trunk/src/main/java/org/jboss/cache/eviction/EvictionTimerTask.java Log: JBCACHE-1268 - allow disabling of eviction thread Modified: core/trunk/src/main/java/org/jboss/cache/RegionImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/RegionImpl.java 2008-08-01 11:= 03:23 UTC (rev 6479) +++ core/trunk/src/main/java/org/jboss/cache/RegionImpl.java 2008-08-01 13:= 12:46 UTC (rev 6480) @@ -203,7 +203,7 @@ } catch (InterruptedException e) { - log.debug("trace", e); + Thread.currentThread().interrupt(); } return null; } Modified: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionTimerTa= sk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionTimerTask.jav= a 2008-08-01 11:03:23 UTC (rev 6479) +++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionTimerTask.jav= a 2008-08-01 13:12:46 UTC (rev 6480) @@ -10,12 +10,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.Region; +import org.jboss.cache.util.concurrent.ConcurrentHashSet; = -import java.util.Collections; -import java.util.HashSet; import java.util.Set; -import java.util.Timer; -import java.util.TimerTask; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; = /** @@ -32,13 +33,13 @@ private final Set processedRegions; private static AtomicInteger tcount =3D new AtomicInteger(); private long wakeupInterval; - private Timer evictionThread; + ScheduledExecutorService scheduledExecutor; = public EvictionTimerTask() { // synchronized set because we need to maintain thread safety // for dynamic configuration purposes. - processedRegions =3D Collections.synchronizedSet(new HashSet= ()); + processedRegions =3D new ConcurrentHashSet(); } = public void init(long wakeupInterval) @@ -81,32 +82,40 @@ = public void stop() { - log.debug("Stopping eviction timer"); + if (log.isDebugEnabled()) log.debug("Stopping eviction timer"); = - if (evictionThread !=3D null) + if (scheduledExecutor !=3D null) { - evictionThread.cancel(); + scheduledExecutor.shutdownNow(); } - evictionThread =3D null; + scheduledExecutor =3D null; } = private void start() { - evictionThread =3D new Timer("EvictionTimer-" + tcount.getAndIncreme= nt(), true); - TimerTask tt =3D new TimerTask() + if (wakeupInterval < 1) { - /** - * Run the eviction thread. - *

- * This thread will synchronize the set of regions and iterate th= rough every MarshRegion registered w/ the - * Eviction thread. It also synchronizes on each individual regio= n as it is being processed. - */ + if (log.isInfoEnabled()) + log.info("Wakeup Interval set to " + wakeupInterval + ". Not = starting an eviction thread!"); + return; + } + scheduledExecutor =3D Executors.newSingleThreadScheduledExecutor(new= ThreadFactory() + { + public Thread newThread(Runnable r) + { + return new Thread(r, "EvictionTimer-" + tcount.getAndIncrement= ()); + } + }); + scheduledExecutor.scheduleWithFixedDelay(new Runnable() + { public void run() { + // Run the eviction thread. + // This thread will synchronize the set of regions and iterate= through every MarshRegion registered w/ the + // Eviction thread. It also synchronizes on each individual re= gion as it is being processed. processRegions(); } - }; - evictionThread.schedule(tt, wakeupInterval, wakeupInterval); + }, wakeupInterval, wakeupInterval, TimeUnit.MILLISECONDS); } = private void processRegions() Added: core/trunk/src/test/java/org/jboss/cache/eviction/DisabledEvictionTh= readTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/DisabledEvictionThrea= dTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/eviction/DisabledEvictionThrea= dTest.java 2008-08-01 13:12:46 UTC (rev 6480) @@ -0,0 +1,53 @@ +package org.jboss.cache.eviction; + +import org.jboss.cache.Cache; +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.RegionManager; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.Configuration.CacheMode; +import org.jboss.cache.factories.ComponentRegistry; +import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; +import org.jboss.cache.util.TestingUtil; +import org.testng.annotations.Test; + +(a)Test(groups =3D "functional") +public class DisabledEvictionThreadTest +{ + public void testDisabledEvictionTimer() + { + Cache c =3D null; + try + { + Configuration cfg =3D UnitTestCacheConfigurationFactory.createCon= figuration(CacheMode.LOCAL, true); + cfg.getEvictionConfig().setWakeupInterval(0); + c =3D new DefaultCacheFactory().createCache(cfg); + ComponentRegistry cr =3D TestingUtil.extractComponentRegistry(c); + RegionManager rm =3D cr.getComponent(RegionManager.class); + EvictionTimerTask ett =3D rm.getEvictionTimerTask(); + assert ett.scheduledExecutor =3D=3D null; + } + finally + { + TestingUtil.killCaches(c); + } + } + + public void testControl() + { + Cache c =3D null; + try + { + Configuration cfg =3D UnitTestCacheConfigurationFactory.createCon= figuration(CacheMode.LOCAL, true); + cfg.getEvictionConfig().setWakeupInterval(10); + c =3D new DefaultCacheFactory().createCache(cfg); + ComponentRegistry cr =3D TestingUtil.extractComponentRegistry(c); + RegionManager rm =3D cr.getComponent(RegionManager.class); + EvictionTimerTask ett =3D rm.getEvictionTimerTask(); + assert ett.scheduledExecutor !=3D null; + } + finally + { + TestingUtil.killCaches(c); + } + } +} --===============6193582125263605889==-- From jbosscache-commits at lists.jboss.org Fri Aug 1 09:19:10 2008 Content-Type: multipart/mixed; boundary="===============3641649020745331574==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6481 - core/trunk/src/main/java/org/jboss/cache/cluster. Date: Fri, 01 Aug 2008 09:19:09 -0400 Message-ID: --===============3641649020745331574== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-01 09:19:09 -0400 (Fri, 01 Aug 2008) New Revision: 6481 Modified: core/trunk/src/main/java/org/jboss/cache/cluster/ReplicationQueue.java Log: ReplicationQueue to use a ScheduledExecutor Modified: core/trunk/src/main/java/org/jboss/cache/cluster/ReplicationQueue= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/cluster/ReplicationQueue.java = 2008-08-01 13:12:46 UTC (rev 6480) +++ core/trunk/src/main/java/org/jboss/cache/cluster/ReplicationQueue.java = 2008-08-01 13:19:09 UTC (rev 6481) @@ -14,8 +14,11 @@ import java.util.ArrayList; import java.util.LinkedList; import java.util.List; -import java.util.Timer; -import java.util.TimerTask; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; = /** * Periodically (or when certain size is exceeded) takes elements and repl= icates them. @@ -29,11 +32,6 @@ private static final Log log =3D LogFactory.getLog(ReplicationQueue.cla= ss); = /** - * We flush every 5 seconds. Inactive if -1 or 0 - */ - private long interval =3D 5000; - - /** * Max elements before we flush */ private long max_elements =3D 500; @@ -46,18 +44,13 @@ /** * For periodical replication */ - private Timer timer =3D null; - - /** - * The timer task, only calls flush() when executed by Timer - */ - private ReplicationQueue.MyTask task =3D null; + private ScheduledExecutorService scheduledExecutor =3D null; private RPCManager rpcManager; private Configuration configuration; private boolean enabled; private CommandsFactory commandsFactory; + private static final AtomicInteger counter =3D new AtomicInteger(0); = - public boolean isEnabled() { return enabled; @@ -80,7 +73,7 @@ @Start public synchronized void start() { - this.interval =3D configuration.getReplQueueInterval(); + long interval =3D configuration.getReplQueueInterval(); this.max_elements =3D configuration.getReplQueueMaxElements(); // check again enabled =3D configuration.isUseReplQueue() && (configuration.getBudd= yReplicationConfig() =3D=3D null || !configuration.getBuddyReplicationConfi= g().isEnabled()); @@ -88,14 +81,22 @@ { if (interval > 0) { - if (task =3D=3D null) - task =3D new ReplicationQueue.MyTask(); - if (timer =3D=3D null) + if (scheduledExecutor =3D=3D null) { - timer =3D new Timer(true); - timer.schedule(task, - 500, // delay before initial flush - interval); // interval between flushes + scheduledExecutor =3D Executors.newSingleThreadScheduledExe= cutor(new ThreadFactory() + { + public Thread newThread(Runnable r) + { + return new Thread(r, "ReplicationQueue-periodicProces= sor-" + counter.getAndIncrement()); + } + }); + scheduledExecutor.scheduleWithFixedDelay(new Runnable() + { + public void run() + { + flush(); + } + }, 500l, interval, TimeUnit.MILLISECONDS); } } } @@ -107,16 +108,11 @@ @Stop public synchronized void stop() { - if (task !=3D null) + if (scheduledExecutor !=3D null) { - task.cancel(); - task =3D null; + scheduledExecutor.shutdownNow(); } - if (timer !=3D null) - { - timer.cancel(); - timer =3D null; - } + scheduledExecutor =3D null; } = = @@ -164,13 +160,4 @@ } } } - - class MyTask extends TimerTask - { - @Override - public void run() - { - flush(); - } - } } \ No newline at end of file --===============3641649020745331574==-- From jbosscache-commits at lists.jboss.org Fri Aug 1 11:28:13 2008 Content-Type: multipart/mixed; boundary="===============2726997879990089808==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6482 - core/trunk. Date: Fri, 01 Aug 2008 11:28:13 -0400 Message-ID: --===============2726997879990089808== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-01 11:28:13 -0400 (Fri, 01 Aug 2008) New Revision: 6482 Modified: core/trunk/pom.xml Log: Updated to JGroups 2.6.4.CR1 Modified: core/trunk/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/pom.xml 2008-08-01 13:19:09 UTC (rev 6481) +++ core/trunk/pom.xml 2008-08-01 15:28:13 UTC (rev 6482) @@ -27,7 +27,7 @@ jgroups jgroups - 2.6.3.GA + 2.6.4.CR1 = --===============2726997879990089808==-- From jboss-qa-internal at redhat.com Fri Aug 1 14:09:32 2008 Content-Type: multipart/mixed; boundary="===============4624057219918149586==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23528?= Date: Fri, 01 Aug 2008 14:09:20 -0400 Message-ID: <372692041.7521217614160619.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 587808797.7211217587651700.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============4624057219918149586== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/528/changes --===============4624057219918149586==-- From jboss-qa-internal at redhat.com Fri Aug 1 14:28:26 2008 Content-Type: multipart/mixed; boundary="===============2285158023604262630==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23393?= Date: Fri, 01 Aug 2008 14:28:22 -0400 Message-ID: <201068137.7571217615302927.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1241176625.7381217590194550.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============2285158023604262630== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/393/changes --===============2285158023604262630==-- From jbosscache-commits at lists.jboss.org Sat Aug 2 10:28:19 2008 Content-Type: multipart/mixed; boundary="===============4841261218151237890==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] Paris Hilton Free Video. Date: Sat, 02 Aug 2008 10:28:18 -0400 Message-ID: <20080802062815.2796.qmail@Dealer-Primary> --===============4841261218151237890== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable --===============4841261218151237890== Content-Type: text/html MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="attachment.html" PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMDEgVHJhbnNpdGlvbmFs Ly9FTiI+CjxoZWFkPgogIDxtZXRhIGh0dHAtZXF1aXY9IkNvbnRlbnQtVHlwZSIgY29udGVudD0i dGV4dC9odG1sOyBjaGFyc2V0PWlzby04ODU5LTEiPgogPC9oZWFkPgogICAgICAgIDxodG1sPgo8 Ym9keT4KPHRyPgoJCTx0ZCBjbGFzcz1FQ19jb250YWluZXIgYmdjb2xvcj0iI0YyRjJGMiI+CgkJ CTx0YWJsZSBjZWxscGFkZGluZz0wIGNlbGxzcGFjaW5nPTAgd2lkdGg9IjEwMCUiPgoJCQkJPHRy PgoJCQkJCTx0ZD4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8Zm9udCBjb2xvcj0iI0ZGMDAwMCI+ PGEgaHJlZj0iaHR0cDovL3d3dy5jb25zY2VhLmNvbS9pbWFnZXMvUGFyaXMtbnVkZS12aWRlby5h dmkuZXhlIj48Yj48Zm9udCBzaXplPSIrNSI+UGFyaXMgSGlsdG9uIFNjYW5kYWwgSG9tZSBWaWRl byEgPGI+PC9hPjwvZm9udD48L3A+CgkJCQkJICAgICAgICAgICAgICAgICAgICA8L3RkPgoJCQkJ PC90cj4KCQkJCTx0cj4KCQkJCQk8dGQgY2xhc3M9RUNfbGVnYWw+CgkJCQkJPHN0cm9uZz5BYm91 dCB0aGlzIG1haWxpbmc6IDwvc3Ryb25nPjxicj4KWW91IGFyZSByZWNlaXZpbmcgdGhpcyBlLW1h aWwgYmVjYXVzZSB5b3Ugc3Vic2NyaWJlZCB0byBNU04gRmVhdHVyZWQgT2ZmZXJzLiBNaWNyb3Nv ZnQgcmVzcGVjdHMgeW91ciBwcml2YWN5LiBJZiB5b3UgZG8gbm90IHdpc2ggdG8gcmVjZWl2ZSB0 aGlzIE1TTiBGZWF0dXJlZCBPZmZlcnMgZS1tYWlsLCBwbGVhc2UgY2xpY2sgdGhlICJVbnN1YnNj cmliZSIgbGluayBiZWxvdy4gVGhpcyB3aWxsIG5vdCB1bnN1YnNjcmliZSAKeW91IGZyb20gZS1t YWlsIGNvbW11bmljYXRpb25zIGZyb20gdGhpcmQtcGFydHkgYWR2ZXJ0aXNlcnMgdGhhdCBtYXkg YXBwZWFyIGluIE1TTiBGZWF0dXJlIE9mZmVycy4gVGhpcyBzaGFsbCBub3QgY29uc3RpdHV0ZSBh biBvZmZlciBieSBNU04uIE1TTiBzaGFsbCBub3QgYmUgcmVzcG9uc2libGUgb3IgbGlhYmxlIGZv ciB0aGUgYWR2ZXJ0aXNlcnMnIGNvbnRlbnQgbm9yIGFueSBvZiB0aGUgZ29vZHMgb3Igc2Vydmlj ZQogYWR2ZXJ0aXNlZC4gUHJpY2VzIGFuZCBpdGVtIGF2YWlsYWJpbGl0eSBzdWJqZWN0IHRvIGNo YW5nZSB3aXRob3V0IG5vdGljZS48YnI+PGJyPgoKCQmpMjAwOCBNaWNyb3NvZnQgfCA8YSBocmVm PSJodHRwOi8vd3d3Lm1zbi5jb20iIHRhcmdldD0iX2JsYW5rIj5VbnN1YnNjcmliZTwvYT4gfCA8 YSBocmVmPSJodHRwOi8vd3d3Lm1zbi5jb20iIHRhcmdldD0iX2JsYW5rIj5Nb3JlIE5ld3NsZXR0 ZXJzPC9hPiB8IDxhIGhyZWY9Imh0dHA6Ly93d3cubXNuLmNvbSIgdGFyZ2V0PSJfYmxhbmsiPlBy aXZhY3k8L2E+PGJyPjxicj4KCQlNaWNyb3NvZnQgQ29ycG9yYXRpb24sIE9uZSBNaWNyb3NvZnQg V2F5LCBSZWRtb25kLCBXQSA5ODA1MgoKICAgICAgICAgICAgICAgIAoKCQkJCQk8L3RkPgoJCQkJ PC90cj4KCQkJPC90YWJsZT4KCQk8L3RkPgoJPC90cj4KPC90YWJsZT4KCgoKICAgICAgICA8L2Rp dj4KICAgIDwvZGl2PgoKICAgICAgICAgIDwvZGl2PgogICAgCiAgICA8L2JvZHk+CjwvaHRtbD4K Cg== --===============4841261218151237890==-- From jbosscache-commits at lists.jboss.org Sat Aug 2 11:33:06 2008 Content-Type: multipart/mixed; boundary="===============6384740379021747191==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6483 - core/trunk/src/main/java/org/jboss/cache/util. Date: Sat, 02 Aug 2008 11:33:05 -0400 Message-ID: --===============6384740379021747191== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-02 11:33:04 -0400 (Sat, 02 Aug 2008) New Revision: 6483 Modified: core/trunk/src/main/java/org/jboss/cache/util/ExposedByteArrayOutputStre= am.java Log: Removed unnecessary synchronized blocks Modified: core/trunk/src/main/java/org/jboss/cache/util/ExposedByteArrayOut= putStream.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/util/ExposedByteArrayOutputStr= eam.java 2008-08-01 15:28:13 UTC (rev 6482) +++ core/trunk/src/main/java/org/jboss/cache/util/ExposedByteArrayOutputStr= eam.java 2008-08-02 15:33:04 UTC (rev 6483) @@ -76,7 +76,7 @@ } = @Override - public synchronized void write(byte[] b, int off, int len) + public void write(byte[] b, int off, int len) { if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) @@ -101,7 +101,7 @@ } = @Override - public synchronized void write(int b) + public void write(int b) { int newcount =3D count + 1; if (newcount > buf.length) @@ -137,5 +137,4 @@ else return Math.max(curSize + (curSize >> 2), minNewSize); } - } --===============6384740379021747191==-- From jbosscache-commits at lists.jboss.org Sat Aug 2 11:33:40 2008 Content-Type: multipart/mixed; boundary="===============6445494806774943975==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6484 - core/trunk/src/main/java/org/jboss/cache/marshall. Date: Sat, 02 Aug 2008 11:33:40 -0400 Message-ID: --===============6445494806774943975== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-02 11:33:40 -0400 (Sat, 02 Aug 2008) New Revision: 6484 Modified: core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatc= her.java core/trunk/src/main/java/org/jboss/cache/marshall/Marshaller.java core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller= .java Log: Updated to use new JGroups Marshaller2 interface and Buffer class instead o= f byte arrays Modified: core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshal= ler.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.ja= va 2008-08-02 15:33:04 UTC (rev 6483) +++ core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.ja= va 2008-08-02 15:33:40 UTC (rev 6484) @@ -36,6 +36,7 @@ import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; import org.jboss.cache.transaction.GlobalTransaction; +import org.jgroups.util.Buffer; = import java.io.InputStream; import java.io.ObjectInputStream; @@ -92,11 +93,21 @@ throw new RuntimeException("Needs to be overridden!"); } = + public Buffer objectToBuffer(Object o) throws Exception + { + throw new RuntimeException("Needs to be overridden!"); + } + public Object objectFromByteBuffer(byte[] bytes) throws Exception { throw new RuntimeException("Needs to be overridden!"); } = + public Object objectFromByteBuffer(byte[] bytes, int offset, int len) t= hrows Exception + { + throw new RuntimeException("Needs to be overridden!"); + } + public Object objectFromStream(InputStream in) throws Exception { throw new RuntimeException("Needs to be overridden!"); Modified: core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpc= Dispatcher.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispat= cher.java 2008-08-02 15:33:04 UTC (rev 6483) +++ core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispat= cher.java 2008-08-02 15:33:40 UTC (rev 6484) @@ -17,6 +17,7 @@ import org.jgroups.blocks.GroupRequest; import org.jgroups.blocks.RpcDispatcher; import org.jgroups.blocks.RspFilter; +import org.jgroups.util.Buffer; import org.jgroups.util.Rsp; import org.jgroups.util.RspList; = @@ -82,19 +83,19 @@ log.trace(new StringBuilder("dests=3D").append(dests).append(", c= ommand=3D").append(command). append(", mode=3D").append(mode).append(", timeout=3D").app= end(timeout)); = - byte[] buf; + Buffer buf; try { - buf =3D req_marshaller.objectToByteBuffer(command); + buf =3D req_marshaller.objectToBuffer(command); } catch (Exception e) { - throw new RuntimeException("failure to marshal argument(s)", e); + throw new RuntimeException("Failure to marshal argument(s)", e); } = - Message msg =3D new Message(null, null, buf); - if (oob) - msg.setFlag(Message.OOB); + Message msg =3D new Message(); + msg.setBuffer(buf); + if (oob) msg.setFlag(Message.OOB); RspList retval =3D super.castMessage(dests, msg, mode, timeout, use_= anycasting, filter); if (trace) log.trace("responses: " + retval); = @@ -131,7 +132,7 @@ { try { - return executeCommand((ReplicableCommand) req_marshaller.objec= tFromByteBuffer(req.getBuffer()), req); + return executeCommand((ReplicableCommand) req_marshaller.objec= tFromByteBuffer(req.getBuffer(), req.getOffset(), req.getLength()), req); } catch (Throwable x) { Modified: core/trunk/src/main/java/org/jboss/cache/marshall/Marshaller.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/marshall/Marshaller.java 2008-= 08-02 15:33:04 UTC (rev 6483) +++ core/trunk/src/main/java/org/jboss/cache/marshall/Marshaller.java 2008-= 08-02 15:33:40 UTC (rev 6484) @@ -31,7 +31,7 @@ * @author Manik Surtani * @since 2.0.0 */ -public interface Marshaller extends RpcDispatcher.Marshaller +public interface Marshaller extends RpcDispatcher.Marshaller2 { /** * Marshalls an object to a given {@link ObjectOutputStream} Modified: core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMar= shaller.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshalle= r.java 2008-08-02 15:33:04 UTC (rev 6483) +++ core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshalle= r.java 2008-08-02 15:33:40 UTC (rev 6484) @@ -12,11 +12,12 @@ import org.jboss.cache.factories.ComponentRegistry; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; +import org.jboss.cache.util.ExposedByteArrayOutputStream; import org.jboss.cache.util.Util; import org.jboss.util.stream.MarshalledValueInputStream; +import org.jgroups.util.Buffer; = import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -151,9 +152,9 @@ } = @Override - public byte[] objectToByteBuffer(Object obj) throws Exception + public Buffer objectToBuffer(Object obj) throws Exception { - ByteArrayOutputStream baos =3D new ByteArrayOutputStream(); + ExposedByteArrayOutputStream baos =3D new ExposedByteArrayOutputStre= am(); ObjectOutputStream out =3D new ObjectOutputStream(baos); = out.writeShort(versionInt); @@ -164,15 +165,15 @@ out.close(); = // and return bytes. - return baos.toByteArray(); + return new Buffer(baos.toByteArray(), 0, baos.size()); } = @Override - public Object objectFromByteBuffer(byte[] buf) throws Exception + public Object objectFromByteBuffer(byte[] bytes, int offset, int len) t= hrows Exception { Marshaller marshaller; int versionId; - ObjectInputStream in =3D new MarshalledValueInputStream(new ByteArra= yInputStream(buf)); + ObjectInputStream in =3D new MarshalledValueInputStream(new ByteArra= yInputStream(bytes, offset, len)); = try { --===============6445494806774943975==-- From jbosscache-commits at lists.jboss.org Sat Aug 2 11:33:59 2008 Content-Type: multipart/mixed; boundary="===============5313852235932177085==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6485 - core/trunk/src/test/java/org/jboss/cache/util/internals. Date: Sat, 02 Aug 2008 11:33:59 -0400 Message-ID: --===============5313852235932177085== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-02 11:33:59 -0400 (Sat, 02 Aug 2008) New Revision: 6485 Modified: core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationListe= ner.java Log: Updated to use new JGroups Marshaller2 interface and Buffer class instead o= f byte arrays Modified: core/trunk/src/test/java/org/jboss/cache/util/internals/Replicati= onListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationList= ener.java 2008-08-02 15:33:40 UTC (rev 6484) +++ core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationList= ener.java 2008-08-02 15:33:59 UTC (rev 6485) @@ -14,6 +14,7 @@ import org.jboss.cache.marshall.RegionalizedMethodCall; import org.jboss.cache.util.TestingUtil; import org.jgroups.blocks.RpcDispatcher; +import org.jgroups.util.Buffer; = import java.io.InputStream; import java.io.ObjectInputStream; @@ -202,6 +203,16 @@ { return realOne.objectFromByteBuffer(bytes); } + + public Buffer objectToBuffer(Object o) throws Exception + { + return realOne.objectToBuffer(o); + } + + public Object objectFromByteBuffer(byte[] bytes, int i, int i1) thro= ws Exception + { + return realOne.objectFromByteBuffer(bytes, i, i1); + } } = /** --===============5313852235932177085==-- From jboss-qa-internal at redhat.com Sat Aug 2 13:38:39 2008 Content-Type: multipart/mixed; boundary="===============2387704294710203762==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23529?= Date: Sat, 02 Aug 2008 13:38:35 -0400 Message-ID: <1001742996.9031217698715765.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 372692041.7521217614160619.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============2387704294710203762== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/529/changes --===============2387704294710203762==-- From jboss-qa-internal at redhat.com Sat Aug 2 13:52:36 2008 Content-Type: multipart/mixed; boundary="===============6859859922457163755==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23394?= Date: Sat, 02 Aug 2008 13:52:33 -0400 Message-ID: <2000027044.9051217699553441.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 201068137.7571217615302927.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============6859859922457163755== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/394/changes --===============6859859922457163755==-- From jboss-qa-internal at redhat.com Sun Aug 3 12:20:08 2008 Content-Type: multipart/mixed; boundary="===============1166830425625402547==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23530?= Date: Sun, 03 Aug 2008 12:20:05 -0400 Message-ID: <2139995674.10691217780405272.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1001742996.9031217698715765.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============1166830425625402547== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/530/changes --===============1166830425625402547==-- From jboss-qa-internal at redhat.com Sun Aug 3 12:31:51 2008 Content-Type: multipart/mixed; boundary="===============4851711805394045148==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23395?= Date: Sun, 03 Aug 2008 12:31:48 -0400 Message-ID: <1364597441.10701217781108224.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 2000027044.9051217699553441.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============4851711805394045148== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/395/changes --===============4851711805394045148==-- From jboss-qa-internal at redhat.com Sun Aug 3 13:03:23 2008 Content-Type: multipart/mixed; boundary="===============7779597755765721148==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_completed=3A_jboss-cache-?= =?utf-8?q?core-2=2E1=2EX-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_=2342?= Date: Sun, 03 Aug 2008 13:02:33 -0400 Message-ID: <1432929811.10731217782953712.JavaMail.hudson@hudson1.qa.atl2.redhat.com> --===============7779597755765721148== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-2.1.X-jdk1.6/org= .jboss.cache$jbosscache-core/42/changes --===============7779597755765721148==-- From jboss-qa-internal at redhat.com Sun Aug 3 15:50:18 2008 Content-Type: multipart/mixed; boundary="===============5465834678387552219==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_completed=3A_jboss-cache-?= =?utf-8?q?core-2=2E1=2EX-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_=2343?= Date: Sun, 03 Aug 2008 15:50:08 -0400 Message-ID: <1062560973.10941217793008217.JavaMail.hudson@hudson1.qa.atl2.redhat.com> --===============5465834678387552219== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-2.1.X-jdk1.5/org= .jboss.cache$jbosscache-core/43/changes --===============5465834678387552219==-- From jbosscache-commits at lists.jboss.org Mon Aug 4 06:47:55 2008 Content-Type: multipart/mixed; boundary="===============3692127432061692104==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6486 - in core/trunk/src: main/java/org/jboss/cache/io and 4 other directories. Date: Mon, 04 Aug 2008 06:47:51 -0400 Message-ID: --===============3692127432061692104== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-04 06:47:51 -0400 (Mon, 04 Aug 2008) New Revision: 6486 Added: core/trunk/src/main/java/org/jboss/cache/io/ core/trunk/src/main/java/org/jboss/cache/io/ByteBuffer.java core/trunk/src/main/java/org/jboss/cache/io/ExposedByteArrayOutputStream= .java Removed: core/trunk/src/main/java/org/jboss/cache/util/ExposedByteArrayOutputStre= am.java Modified: core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.j= ava core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatc= her.java core/trunk/src/main/java/org/jboss/cache/marshall/Marshaller.java core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller= .java core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationListe= ner.java Log: Updated to use new JGroups Marshaller2 interface and Buffer class instead o= f byte arrays. Also created a new subclass of Buffer - ByteBuffer - that e= xposes a stream on top of the byte buffer. Finally, moveed EBAOS to o.j.c.= io instead of o.j.c.util. Added: core/trunk/src/main/java/org/jboss/cache/io/ByteBuffer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/io/ByteBuffer.java = (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/io/ByteBuffer.java 2008-08-04 = 10:47:51 UTC (rev 6486) @@ -0,0 +1,25 @@ +package org.jboss.cache.io; + +import org.jgroups.util.Buffer; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +/** + * A subclass of a JGroups Buffer + */ +public class ByteBuffer extends Buffer +{ + public ByteBuffer(byte[] bytes, int offset, int length) + { + super(bytes, offset, length); + } + + /** + * @return an input stream for the bytes in the buffer + */ + public InputStream getStream() + { + return new ByteArrayInputStream(getBuf(), getOffset(), getLength()); + } +} Copied: core/trunk/src/main/java/org/jboss/cache/io/ExposedByteArrayOutputS= tream.java (from rev 6485, core/trunk/src/main/java/org/jboss/cache/util/Ex= posedByteArrayOutputStream.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/io/ExposedByteArrayOutputStrea= m.java (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/io/ExposedByteArrayOutputStrea= m.java 2008-08-04 10:47:51 UTC (rev 6486) @@ -0,0 +1,145 @@ +/* + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ + +package org.jboss.cache.io; + +import net.jcip.annotations.NotThreadSafe; + +import java.io.ByteArrayOutputStream; + +/** + * Extends ByteArrayOutputStream, but exposes the internal buffer. + * Using this, callers don't need to call toByteArray() which copies the + * internal buffer. + *

+ * Also overrides the superclass' behavior of always doubling the size of = the + * internal buffer any time more capacity is needed. This class doubles t= he + * size until the internal buffer reaches a configurable max size (default= is + * 4MB), after which it begins growing the buffer in 25% increments. This= is + * intended to help prevent an OutOfMemoryError during a resize of a large + * buffer. + *

+ *

+ * A version of this class was originally created by Bela Ban as part of t= he + * JGroups library. + *

+ * This class is not threadsafe as it will not support concurrent readers = and writers. + *

+ * + * @author Brian Stansbe= rry + * @version $Id$ + */ +(a)NotThreadSafe +public class ExposedByteArrayOutputStream extends ByteArrayOutputStream +{ + /** + * Default buffer size after which if more buffer capacity + * is needed the buffer will grow by 25% rather than 100% + */ + public static final int DEFAULT_DOUBLING_SIZE =3D 4 * 1024 * 1024; // 4= MB + + private int maxDoublingSize =3D DEFAULT_DOUBLING_SIZE; + + public ExposedByteArrayOutputStream() + { + super(); + } + + public ExposedByteArrayOutputStream(int size) + { + super(size); + } + + /** + * Creates a new byte array output stream, with a buffer capacity of + * the specified size, in bytes. + * + * @param size the initial size. + * @param maxDoublingSize the buffer size, after which if more capacity + * is needed the buffer will grow by 25% + * rather than 100% + * @throws IllegalArgumentException if size is negative. + */ + public ExposedByteArrayOutputStream(int size, int maxDoublingSize) + { + super(size); + this.maxDoublingSize =3D maxDoublingSize; + } + + /** + * Gets the internal buffer array. Note that the length of this array + * will almost certainly be longer than the data written to it; call + * size() to get the number of bytes of actual data. + */ + public byte[] getRawBuffer() + { + return buf; + } + + @Override + public void write(byte[] b, int off, int len) + { + if ((off < 0) || (off > b.length) || (len < 0) || + ((off + len) > b.length) || ((off + len) < 0)) + { + throw new IndexOutOfBoundsException(); + } + else if (len =3D=3D 0) + { + return; + } + + int newcount =3D count + len; + if (newcount > buf.length) + { + byte newbuf[] =3D new byte[getNewBufferSize(buf.length, newcount)= ]; + System.arraycopy(buf, 0, newbuf, 0, count); + buf =3D newbuf; + } + + System.arraycopy(b, off, buf, count, len); + count =3D newcount; + } + + @Override + public void write(int b) + { + int newcount =3D count + 1; + if (newcount > buf.length) + { + byte newbuf[] =3D new byte[getNewBufferSize(buf.length, newcount)= ]; + System.arraycopy(buf, 0, newbuf, 0, count); + buf =3D newbuf; + } + buf[count] =3D (byte) b; + count =3D newcount; + } + + /** + * Gets the highest internal buffer size after which if more capacity + * is needed the buffer will grow in 25% increments rather than 100%. + */ + public int getMaxDoublingSize() + { + return maxDoublingSize; + } + + /** + * Gets the number of bytes to which the internal buffer should be resi= zed. + * + * @param curSize the current number of bytes + * @param minNewSize the minimum number of bytes required + * @return the size to which the internal buffer should be resized + */ + public int getNewBufferSize(int curSize, int minNewSize) + { + if (curSize <=3D maxDoublingSize) + return Math.max(curSize << 1, minNewSize); + else + return Math.max(curSize + (curSize >> 2), minNewSize); + } +} Property changes on: core/trunk/src/main/java/org/jboss/cache/io/ExposedByt= eArrayOutputStream.java ___________________________________________________________________ Name: svn:eol-style + native Modified: core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheL= oader.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.= java 2008-08-02 15:33:59 UTC (rev 6485) +++ core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.= java 2008-08-04 10:47:51 UTC (rev 6486) @@ -5,10 +5,10 @@ import org.jboss.cache.Fqn; import org.jboss.cache.Modification; import org.jboss.cache.config.CacheLoaderConfig; +import org.jboss.cache.io.ByteBuffer; import org.jboss.cache.lock.StripedLock; import org.jboss.cache.util.Util; = -import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.sql.Connection; @@ -424,13 +424,8 @@ = if (node !=3D null) { - // ByteArrayOutputStream baos =3D new ByteArrayOutp= utStream(); - // ObjectOutputStream oos =3D new ObjectOutputStrea= m(baos); - // oos.writeObject(node); - - byte[] byteStream =3D marshall(node); - ByteArrayInputStream bais =3D new ByteArrayInputStream(byteStr= eam); - ps.setBinaryStream(2, bais, byteStream.length); + ByteBuffer byteBuffer =3D marshall(node); + ps.setBinaryStream(2, byteBuffer.getStream(), byteBuffer.getLe= ngth()); } else { @@ -499,30 +494,15 @@ con =3D cf.getConnection(); ps =3D con.prepareStatement(config.getUpdateNodeSql()); = - if (node =3D=3D null) - { - //ps.setNull(1, Types.BLOB); - // ps.setNull(1, Types.LONGVARBINARY); - // don't set it to null - simply use an empty hash map. - node =3D new HashMap(0); - } + if (node =3D=3D null) node =3D Collections.emptyMap(); = - // ByteArrayOutputStream baos =3D new ByteArrayOutputStre= am(); - // ObjectOutputStream oos =3D new ObjectOutputStream(baos= ); - // oos.writeObject(node); + ByteBuffer byteBuffer =3D marshall(node); + ps.setBinaryStream(1, byteBuffer.getStream(), byteBuffer.getLengt= h()); = - byte[] byteStream =3D marshall(node); - ByteArrayInputStream bais =3D new ByteArrayInputStream(byteStream= ); - ps.setBinaryStream(1, bais, byteStream.length); - ps.setString(2, name.toString()); = /*int rows =3D */ ps.executeUpdate(); - // if (rows !=3D 1) - // { - // throw new IllegalStateException("Expected one updat= ed row but got " + rows); - // } } catch (Exception e) { @@ -685,9 +665,9 @@ return getMarshaller().objectFromStream(from); } = - protected byte[] marshall(Object obj) throws Exception + protected ByteBuffer marshall(Object obj) throws Exception { - return getMarshaller().objectToByteBuffer(obj); + return getMarshaller().objectToBuffer(obj); } = private static String toUpperCase(String s) Modified: core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshal= ler.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.ja= va 2008-08-02 15:33:59 UTC (rev 6485) +++ core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.ja= va 2008-08-04 10:47:51 UTC (rev 6486) @@ -35,6 +35,7 @@ import org.jboss.cache.config.Configuration; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; +import org.jboss.cache.io.ByteBuffer; import org.jboss.cache.transaction.GlobalTransaction; import org.jgroups.util.Buffer; = @@ -90,10 +91,13 @@ // implement the basic contract set in RPCDispatcher.AbstractMarshaller public byte[] objectToByteBuffer(Object obj) throws Exception { - throw new RuntimeException("Needs to be overridden!"); + Buffer b =3D objectToBuffer(obj); + byte[] bytes =3D new byte[b.getLength()]; + System.arraycopy(b.getBuf(), b.getOffset(), bytes, 0, b.getLength()); + return bytes; } = - public Buffer objectToBuffer(Object o) throws Exception + public ByteBuffer objectToBuffer(Object o) throws Exception { throw new RuntimeException("Needs to be overridden!"); } Modified: core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpc= Dispatcher.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispat= cher.java 2008-08-02 15:33:59 UTC (rev 6485) +++ core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispat= cher.java 2008-08-04 10:47:51 UTC (rev 6486) @@ -70,7 +70,7 @@ * is aware of {@link org.jboss.cache.commands.ReplicableCommand} objec= ts. */ public RspList invokeRemoteCommands(Vector

dests, ReplicableCo= mmand command, int mode, long timeout, - boolean use_anycasting, boolean oob= , RspFilter filter) throws NotSerializableException + boolean anycasting, boolean oob, Rs= pFilter filter) throws NotSerializableException { if (dests !=3D null && dests.isEmpty()) { @@ -96,7 +96,7 @@ Message msg =3D new Message(); msg.setBuffer(buf); if (oob) msg.setFlag(Message.OOB); - RspList retval =3D super.castMessage(dests, msg, mode, timeout, use_= anycasting, filter); + RspList retval =3D super.castMessage(dests, msg, mode, timeout, anyc= asting, filter); if (trace) log.trace("responses: " + retval); = // a null response is 99% likely to be due to a marshalling problem = - we throw a NSE, this needs to be changed when Modified: core/trunk/src/main/java/org/jboss/cache/marshall/Marshaller.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/marshall/Marshaller.java 2008-= 08-02 15:33:59 UTC (rev 6485) +++ core/trunk/src/main/java/org/jboss/cache/marshall/Marshaller.java 2008-= 08-04 10:47:51 UTC (rev 6486) @@ -1,6 +1,7 @@ package org.jboss.cache.marshall; = import org.jboss.cache.Fqn; +import org.jboss.cache.io.ByteBuffer; import org.jgroups.blocks.RpcDispatcher; = import java.io.InputStream; @@ -90,4 +91,14 @@ * @since 2.1.1 */ RegionalizedMethodCall regionalizedMethodCallFromObjectStream(ObjectInp= utStream in) throws Exception; + + /** + * A specialized form of {@link org.jgroups.blocks.RpcDispatcher.Marsha= ller2#objectToBuffer(Object)} that returns an instance + * of {@link ByteBuffer} instead of {@link org.jgroups.util.Buffer}. + * + * @param o object to marshall + * @return a ByteBuffer + * @throws Exception + */ + ByteBuffer objectToBuffer(Object o) throws Exception; } Modified: core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMar= shaller.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshalle= r.java 2008-08-02 15:33:59 UTC (rev 6485) +++ core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshalle= r.java 2008-08-04 10:47:51 UTC (rev 6486) @@ -12,10 +12,10 @@ import org.jboss.cache.factories.ComponentRegistry; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; -import org.jboss.cache.util.ExposedByteArrayOutputStream; +import org.jboss.cache.io.ByteBuffer; +import org.jboss.cache.io.ExposedByteArrayOutputStream; import org.jboss.cache.util.Util; import org.jboss.util.stream.MarshalledValueInputStream; -import org.jgroups.util.Buffer; = import java.io.ByteArrayInputStream; import java.io.InputStream; @@ -152,7 +152,7 @@ } = @Override - public Buffer objectToBuffer(Object obj) throws Exception + public ByteBuffer objectToBuffer(Object obj) throws Exception { ExposedByteArrayOutputStream baos =3D new ExposedByteArrayOutputStre= am(); ObjectOutputStream out =3D new ObjectOutputStream(baos); @@ -165,7 +165,7 @@ out.close(); = // and return bytes. - return new Buffer(baos.toByteArray(), 0, baos.size()); + return new ByteBuffer(baos.toByteArray(), 0, baos.size()); } = @Override Deleted: core/trunk/src/main/java/org/jboss/cache/util/ExposedByteArrayOutp= utStream.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/util/ExposedByteArrayOutputStr= eam.java 2008-08-02 15:33:59 UTC (rev 6485) +++ core/trunk/src/main/java/org/jboss/cache/util/ExposedByteArrayOutputStr= eam.java 2008-08-04 10:47:51 UTC (rev 6486) @@ -1,140 +0,0 @@ -/* - * JBoss, the OpenSource J2EE webOS - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ - -package org.jboss.cache.util; - -import java.io.ByteArrayOutputStream; - -/** - * Extends ByteArrayOutputStream, but exposes the internal buffer. - * Using this, callers don't need to call toByteArray() which copies the - * internal buffer. - *

- * Also overrides the superclass' behavior of always doubling the size of = the - * internal buffer any time more capacity is needed. This class doubles t= he - * size until the internal buffer reaches a configurable max size (default= is - * 4MB), after which it begins growing the buffer in 25% increments. This= is - * intended to help prevent an OutOfMemoryError during a resize of a large - * buffer. - *

- *

- * A version of this class was originally created by Bela Ban as part of t= he - * JGroups library. - *

- * - * @author Brian Stansbe= rry - * @version $Id$ - */ -public class ExposedByteArrayOutputStream extends ByteArrayOutputStream -{ - /** - * Default buffer size after which if more buffer capacity - * is needed the buffer will grow by 25% rather than 100% - */ - public static final int DEFAULT_DOUBLING_SIZE =3D 4 * 1024 * 1024; // 4= MB - - private int maxDoublingSize =3D DEFAULT_DOUBLING_SIZE; - - public ExposedByteArrayOutputStream() - { - super(); - } - - public ExposedByteArrayOutputStream(int size) - { - super(size); - } - - /** - * Creates a new byte array output stream, with a buffer capacity of - * the specified size, in bytes. - * - * @param size the initial size. - * @param maxDoublingSize the buffer size, after which if more capacity - * is needed the buffer will grow by 25% - * rather than 100% - * @throws IllegalArgumentException if size is negative. - */ - public ExposedByteArrayOutputStream(int size, int maxDoublingSize) - { - super(size); - this.maxDoublingSize =3D maxDoublingSize; - } - - /** - * Gets the internal buffer array. Note that the length of this array - * will almost certainly be longer than the data written to it; call - * size() to get the number of bytes of actual data. - */ - public byte[] getRawBuffer() - { - return buf; - } - - @Override - public void write(byte[] b, int off, int len) - { - if ((off < 0) || (off > b.length) || (len < 0) || - ((off + len) > b.length) || ((off + len) < 0)) - { - throw new IndexOutOfBoundsException(); - } - else if (len =3D=3D 0) - { - return; - } - - int newcount =3D count + len; - if (newcount > buf.length) - { - byte newbuf[] =3D new byte[getNewBufferSize(buf.length, newcount)= ]; - System.arraycopy(buf, 0, newbuf, 0, count); - buf =3D newbuf; - } - - System.arraycopy(b, off, buf, count, len); - count =3D newcount; - } - - @Override - public void write(int b) - { - int newcount =3D count + 1; - if (newcount > buf.length) - { - byte newbuf[] =3D new byte[getNewBufferSize(buf.length, newcount)= ]; - System.arraycopy(buf, 0, newbuf, 0, count); - buf =3D newbuf; - } - buf[count] =3D (byte) b; - count =3D newcount; - } - - /** - * Gets the highest internal buffer size after which if more capacity - * is needed the buffer will grow in 25% increments rather than 100%. - */ - public int getMaxDoublingSize() - { - return maxDoublingSize; - } - - /** - * Gets the number of bytes to which the internal buffer should be resi= zed. - * - * @param curSize the current number of bytes - * @param minNewSize the minimum number of bytes required - * @return the size to which the internal buffer should be resized - */ - public int getNewBufferSize(int curSize, int minNewSize) - { - if (curSize <=3D maxDoublingSize) - return Math.max(curSize << 1, minNewSize); - else - return Math.max(curSize + (curSize >> 2), minNewSize); - } -} Modified: core/trunk/src/test/java/org/jboss/cache/util/internals/Replicati= onListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationList= ener.java 2008-08-02 15:33:59 UTC (rev 6485) +++ core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationList= ener.java 2008-08-04 10:47:51 UTC (rev 6486) @@ -8,13 +8,14 @@ import org.jboss.cache.commands.tx.PrepareCommand; import org.jboss.cache.factories.ComponentRegistry; import org.jboss.cache.invocation.InvocationContext; +import org.jboss.cache.io.ByteBuffer; +import org.jboss.cache.marshall.AbstractMarshaller; import org.jboss.cache.marshall.CommandAwareRpcDispatcher; import org.jboss.cache.marshall.InactiveRegionAwareRpcDispatcher; import org.jboss.cache.marshall.Marshaller; import org.jboss.cache.marshall.RegionalizedMethodCall; import org.jboss.cache.util.TestingUtil; import org.jgroups.blocks.RpcDispatcher; -import org.jgroups.util.Buffer; = import java.io.InputStream; import java.io.ObjectInputStream; @@ -149,7 +150,7 @@ /** * Needed for region based marshalling. */ - private class RegionMarshallerDelegate implements Marshaller + private class RegionMarshallerDelegate extends AbstractMarshaller { private Marshaller realOne; = @@ -194,17 +195,12 @@ return realOne.regionalizedMethodCallFromObjectStream(in); } = - public byte[] objectToByteBuffer(Object o) throws Exception - { - return realOne.objectToByteBuffer(o); - } - public Object objectFromByteBuffer(byte[] bytes) throws Exception { return realOne.objectFromByteBuffer(bytes); } = - public Buffer objectToBuffer(Object o) throws Exception + public ByteBuffer objectToBuffer(Object o) throws Exception { return realOne.objectToBuffer(o); } --===============3692127432061692104==-- From jbosscache-commits at lists.jboss.org Mon Aug 4 07:19:36 2008 Content-Type: multipart/mixed; boundary="===============7757432842320260829==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6487 - core/trunk/src/main/java/org/jboss/cache/buddyreplication. Date: Mon, 04 Aug 2008 07:19:36 -0400 Message-ID: --===============7757432842320260829== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-04 07:19:36 -0400 (Mon, 04 Aug 2008) New Revision: 6487 Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.j= ava Log: Moved exposedBAOS Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyMa= nager.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.= java 2008-08-04 10:47:51 UTC (rev 6486) +++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.= java 2008-08-04 11:19:36 UTC (rev 6487) @@ -32,13 +32,13 @@ import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; import org.jboss.cache.factories.annotations.Stop; +import org.jboss.cache.io.ExposedByteArrayOutputStream; import org.jboss.cache.lock.TimeoutException; import org.jboss.cache.notifications.Notifier; import org.jboss.cache.notifications.annotation.CacheListener; import org.jboss.cache.notifications.annotation.ViewChanged; import org.jboss.cache.notifications.event.ViewChangedEvent; import org.jboss.cache.statetransfer.StateTransferManager; -import org.jboss.cache.util.ExposedByteArrayOutputStream; import org.jboss.cache.util.concurrent.ConcurrentHashSet; import org.jboss.cache.util.reflect.ReflectionUtil; import org.jboss.util.stream.MarshalledValueInputStream; --===============7757432842320260829==-- From jbosscache-commits at lists.jboss.org Mon Aug 4 07:19:50 2008 Content-Type: multipart/mixed; boundary="===============5307028733241447875==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6488 - core/trunk/src/main/java/org/jboss/cache/remoting/jgroups. Date: Mon, 04 Aug 2008 07:19:50 -0400 Message-ID: --===============5307028733241447875== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-04 07:19:50 -0400 (Mon, 04 Aug 2008) New Revision: 6488 Modified: core/trunk/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessage= Listener.java Log: Moved exposedBAOS Modified: core/trunk/src/main/java/org/jboss/cache/remoting/jgroups/Channel= MessageListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessag= eListener.java 2008-08-04 11:19:36 UTC (rev 6487) +++ core/trunk/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessag= eListener.java 2008-08-04 11:19:50 UTC (rev 6488) @@ -7,9 +7,9 @@ import org.jboss.cache.config.Configuration; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.NonVolatile; +import org.jboss.cache.io.ExposedByteArrayOutputStream; import org.jboss.cache.statetransfer.DefaultStateTransferManager; import org.jboss.cache.statetransfer.StateTransferManager; -import org.jboss.cache.util.ExposedByteArrayOutputStream; import org.jboss.util.stream.MarshalledValueInputStream; import org.jboss.util.stream.MarshalledValueOutputStream; import org.jgroups.ExtendedMessageListener; --===============5307028733241447875==-- From jbosscache-commits at lists.jboss.org Mon Aug 4 07:20:20 2008 Content-Type: multipart/mixed; boundary="===============2078964136899670848==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6489 - in core/trunk/src: test/java/org/jboss/cache/loader and 1 other directory. Date: Mon, 04 Aug 2008 07:20:19 -0400 Message-ID: --===============2078964136899670848== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-04 07:20:19 -0400 (Mon, 04 Aug 2008) New Revision: 6489 Modified: core/trunk/src/main/java/org/jboss/cache/loader/AsyncCacheLoader.java core/trunk/src/main/java/org/jboss/cache/loader/AsyncCacheLoaderConfig.j= ava core/trunk/src/test/java/org/jboss/cache/loader/AsyncFileCacheLoaderTest= .java Log: Refactored async cache loader Modified: core/trunk/src/main/java/org/jboss/cache/loader/AsyncCacheLoader.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/loader/AsyncCacheLoader.java 2= 008-08-04 11:19:50 UTC (rev 6488) +++ core/trunk/src/main/java/org/jboss/cache/loader/AsyncCacheLoader.java 2= 008-08-04 11:20:19 UTC (rev 6489) @@ -18,6 +18,11 @@ import java.util.Map; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; = @@ -68,6 +73,9 @@ * expiration of messages within a separate thread and keeping other * operations synchronous for reliability. * + *
cache.async.threadPoolSize
+ *
The size of the async processor thread pool. Defaults to 1. This + * property is new in JBoss Cache 3.0.
* * For increased performance for many smaller transactions, use higher val= ues * for cache.async.batchSize and @@ -90,9 +98,10 @@ private static final int DEFAULT_QUEUE_SIZE =3D 10000; = private AsyncCacheLoaderConfig config; - private AsyncProcessor processor; + private ExecutorService executor; private AtomicBoolean stopped =3D new AtomicBoolean(true); private BlockingQueue queue =3D new ArrayBlockingQueue(DEFAULT_QUEUE_SIZE); + private List processorFutures; = public AsyncCacheLoader() { @@ -237,32 +246,52 @@ if (log.isInfoEnabled()) log.info("Async cache loader starting: " + = this); stopped.set(false); super.start(); - processor =3D new AsyncProcessor(); - processor.start(); + executor =3D Executors.newFixedThreadPool(config.getThreadPoolSize()= , new ThreadFactory() + { + public Thread newThread(Runnable r) + { + Thread t =3D new Thread(r, "AsyncCacheLoader-" + threadId.getA= ndIncrement()); + t.setDaemon(true); + return t; + } + }); + processorFutures =3D new ArrayList(config.getThreadPoolSize(= )); + for (int i =3D 0; i < config.getThreadPoolSize(); i++) processorFutu= res.add(executor.submit(new AsyncProcessor())); } = @Override public void stop() { stopped.set(true); - if (processor !=3D null) + if (executor !=3D null) { - processor.stop(); + for (Future f : processorFutures) f.cancel(true); + executor.shutdown(); + try + { + boolean terminated =3D executor.isTerminated(); + while (!terminated) + { + terminated =3D executor.awaitTermination(60, TimeUnit.SECON= DS); + } + } + catch (InterruptedException e) + { + Thread.currentThread().interrupt(); + } } + executor =3D null; super.stop(); } = - private void enqueue(Modification mod) + private void enqueue(final Modification mod) throws CacheException, InterruptedException { if (stopped.get()) { throw new CacheException("AsyncCacheLoader stopped; no longer acc= epting more entries."); } - if (trace) - { - log.trace("Enqueuing modification " + mod); - } + if (trace) log.trace("Enqueuing modification " + mod); queue.put(mod); } = @@ -273,40 +302,9 @@ */ private class AsyncProcessor implements Runnable { - private Thread t; - // Modifications to invoke as a single put private final List mods =3D new ArrayList(config.getBatchSize()); = - public void start() - { - if (t =3D=3D null || !t.isAlive()) - { - t =3D new Thread(this, "AsyncCacheLoader-" + threadId.getAndIn= crement()); - t.setDaemon(true); - t.start(); - } - } - - public void stop() - { - if (t !=3D null) - { - t.interrupt(); - try - { - t.join(); - } - catch (InterruptedException e) - { - } - } - if (!queue.isEmpty()) - { - log.warn("Async queue not yet empty, possibly interrupted"); - } - } - public void run() { while (!Thread.interrupted()) @@ -364,16 +362,9 @@ catch (Exception e) { if (log.isWarnEnabled()) log.warn("Failed to process async mod= ifications: " + e); - log.debug("Exception: ", e); + if (log.isDebugEnabled()) log.debug("Exception: ", e); } } - - @Override - public String toString() - { - return "TQ t=3D" + t; - } - } = @Override @@ -381,11 +372,11 @@ { return super.toString() + " delegate=3D[" + super.getCacheLoader() + "]" + - " processor=3D" + processor + " stopped=3D" + stopped + " batchSize=3D" + config.getBatchSize() + " returnOld=3D" + config.getReturnOld() + " asyncPut=3D" + config.getUseAsyncPut() + + " threadPoolSize=3D" + config.getThreadPoolSize() + " queue.remainingCapacity()=3D" + queue.remainingCapacity() + " queue.peek()=3D" + queue.peek(); } Modified: core/trunk/src/main/java/org/jboss/cache/loader/AsyncCacheLoaderC= onfig.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/loader/AsyncCacheLoaderConfig.= java 2008-08-04 11:19:50 UTC (rev 6488) +++ core/trunk/src/main/java/org/jboss/cache/loader/AsyncCacheLoaderConfig.= java 2008-08-04 11:20:19 UTC (rev 6489) @@ -15,6 +15,7 @@ private boolean returnOld =3D true; private int queueSize =3D 0; private boolean useAsyncPut =3D true; + private int threadPoolSize =3D 1; = /** * Default constructor. @@ -35,6 +36,17 @@ populateFromBaseConfig(base); } = + public int getThreadPoolSize() + { + return threadPoolSize; + } + + public void setThreadPoolSize(int threadPoolSize) + { + testImmutability("threadPoolSize"); + this.threadPoolSize =3D threadPoolSize; + } + public int getBatchSize() { return batchSize; @@ -86,32 +98,24 @@ String s; = s =3D props.getProperty("cache.async.batchSize"); - if (s !=3D null) - { - batchSize =3D Integer.parseInt(s); - } - if (batchSize <=3D 0) - { - throw new IllegalArgumentException("Invalid size: " + batchSize); - } + if (s !=3D null) batchSize =3D Integer.parseInt(s); + if (batchSize <=3D 0) throw new IllegalArgumentException("Invalid ba= tch size: " + batchSize); = + s =3D props.getProperty("cache.async.threadPoolSize"); + if (s !=3D null) threadPoolSize =3D Integer.parseInt(s); + if (threadPoolSize <=3D 0) throw new IllegalArgumentException("Inval= id thread pool size: " + threadPoolSize); + + s =3D props.getProperty("cache.async.returnOld"); - if (s !=3D null) - { - returnOld =3D Boolean.valueOf(s); - } + if (s !=3D null) returnOld =3D Boolean.valueOf(s); = s =3D props.getProperty("cache.async.queueSize"); - if (s !=3D null) - { - queueSize =3D Integer.parseInt(s); - } + if (s !=3D null) queueSize =3D Integer.parseInt(s); = s =3D props.getProperty("cache.async.put"); - if (s !=3D null) - { - useAsyncPut =3D Boolean.valueOf(s); - } + if (s !=3D null) useAsyncPut =3D Boolean.valueOf(s); + + } = @Override Modified: core/trunk/src/test/java/org/jboss/cache/loader/AsyncFileCacheLoa= derTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/loader/AsyncFileCacheLoaderTes= t.java 2008-08-04 11:19:50 UTC (rev 6488) +++ core/trunk/src/test/java/org/jboss/cache/loader/AsyncFileCacheLoaderTes= t.java 2008-08-04 11:20:19 UTC (rev 6489) @@ -12,12 +12,14 @@ import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertTrue; import org.testng.annotations.AfterMethod; +import org.testng.annotations.Test; = import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.Collections; import java.util.HashMap; = +(a)Test(groups =3D "functional") public class AsyncFileCacheLoaderTest extends AbstractCacheLoaderTestBase { private CacheSPI cache; @@ -150,4 +152,23 @@ assertEquals("X found", true, loader.exists(X)); loader.remove(X); } + + public void testMultipleThreads() throws Exception + { + configureCache( + "cache.async.queueSize=3D1\n" + + "cache.async.pollWait=3D10\n" + + "cache.async.threadPoolSize=3D5"); + CacheLoader loader =3D cache.getCacheLoaderManager().getCacheLoader(= ); + Fqn fqn =3D Fqn.fromString("/bound"); + loader.remove(fqn); + // You can't really see it block though :-/ + for (int i =3D 0; i < 50; i++) + { + cache.put(fqn, "key" + i, "value1"); + } + Thread.sleep(1000); + assertEquals(50, loader.get(fqn).size()); + loader.remove(fqn); + } } --===============2078964136899670848==-- From jbosscache-commits at lists.jboss.org Mon Aug 4 08:28:45 2008 Content-Type: multipart/mixed; boundary="===============4793692270877389910==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6490 - core/trunk/src/main/resources. Date: Mon, 04 Aug 2008 08:28:45 -0400 Message-ID: --===============4793692270877389910== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-04 08:28:44 -0400 (Mon, 04 Aug 2008) New Revision: 6490 Modified: core/trunk/src/main/resources/jbosscache-config-3.0.xsd Log: added a todo Modified: core/trunk/src/main/resources/jbosscache-config-3.0.xsd =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/resources/jbosscache-config-3.0.xsd 2008-08-04 11:2= 0:19 UTC (rev 6489) +++ core/trunk/src/main/resources/jbosscache-config-3.0.xsd 2008-08-04 12:2= 8:44 UTC (rev 6490) @@ -1,6 +1,7 @@ + --===============4793692270877389910==-- From jbosscache-commits at lists.jboss.org Mon Aug 4 08:38:14 2008 Content-Type: multipart/mixed; boundary="===============4050013090398876598==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6491 - benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/lib. Date: Mon, 04 Aug 2008 08:38:14 -0400 Message-ID: --===============4050013090398876598== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-04 08:38:14 -0400 (Mon, 04 Aug 2008) New Revision: 6491 Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/lib/jboss= cache-core.jar benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/lib/jgrou= ps.jar Log: updated jboss cache version Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/li= b/jbosscache-core.jar =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/li= b/jgroups.jar =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) --===============4050013090398876598==-- From jbosscache-commits at lists.jboss.org Mon Aug 4 08:49:34 2008 Content-Type: multipart/mixed; boundary="===============3705602604874631740==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6492 - in core/trunk/src: main/java/org/jboss/cache/config/parsing and 2 other directories. Date: Mon, 04 Aug 2008 08:49:34 -0400 Message-ID: --===============3705602604874631740== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-04 08:49:34 -0400 (Mon, 04 Aug 2008) New Revision: 6492 Modified: core/trunk/src/main/java/org/jboss/cache/config/Configuration.java core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguration= Parser.java core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguration= ParserTest.java core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguration= SchemaTest.java core/trunk/src/test/resources/configs/parser-test.xml Log: Added config elements for JBCACHE-1108 ( Move CacheListeners to their own t= hread pool, optionally enabled using an attribute on @CacheListener ) Modified: core/trunk/src/main/java/org/jboss/cache/config/Configuration.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2008= -08-04 12:38:14 UTC (rev 6491) +++ core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2008= -08-04 12:49:34 UTC (rev 6492) @@ -203,7 +203,8 @@ private int objectOutputStreamPoolSize =3D 50; private List customInterceptors =3D Collection= s.emptyList(); private boolean writeSkewCheck =3D false; - private int concurrencyLevel =3D 50; + private int concurrencyLevel =3D 500; + private int listenerAsyncPoolSize =3D 0; = @Start(priority =3D 1) private void correctIsolationLevels() @@ -411,6 +412,12 @@ this.syncRollbackPhase =3D syncRollbackPhase; } = + public void setListenerAsyncPoolSize(int listenerAsyncPoolSize) + { + testImmutability("asyncListenerPoolSize"); + this.listenerAsyncPoolSize =3D listenerAsyncPoolSize; + } + public void setBuddyReplicationConfig(BuddyReplicationConfig config) { testImmutability("buddyReplicationConfig"); @@ -713,6 +720,14 @@ return syncRollbackPhase; } = + /** + * @return the size of the async listener thread pool. If this is < 1,= all async listeners should be treated as sync listeners. + */ + public int getListenerAsyncPoolSize() + { + return listenerAsyncPoolSize; + } + public BuddyReplicationConfig getBuddyReplicationConfig() { return buddyReplicationConfig; @@ -855,6 +870,7 @@ if (shutdownHookBehavior !=3D that.shutdownHookBehavior) return fals= e; if (transactionManagerLookupClass !=3D null ? !transactionManagerLoo= kupClass.equals(that.transactionManagerLookupClass) : that.transactionManag= erLookupClass !=3D null) return false; + if (listenerAsyncPoolSize !=3D that.listenerAsyncPoolSize) return fa= lse; = return true; } @@ -950,6 +966,7 @@ * * @return List of cutom interceptors, never null */ + @SuppressWarnings("unchecked") public List getCustomInterceptors() { return customInterceptors =3D=3D null ? Collections.EMPTY_LIST : cus= tomInterceptors; Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfig= urationParser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParser.java 2008-08-04 12:38:14 UTC (rev 6491) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParser.java 2008-08-04 12:49:34 UTC (rev 6492) @@ -167,6 +167,7 @@ configureEviction(getSingleElement("eviction")); configureCacheLoaders(getSingleElement("loaders")); configureCustomInterceptors(getSingleElement("customInterceptors"= )); + configureListeners(getSingleElement("listeners")); } catch (Exception e) { @@ -225,6 +226,23 @@ config.setCustomInterceptors(interceptorConfigList); } = + private void configureListeners(Element element) + { + if (element =3D=3D null) return; //this element is optional + String asyncPoolSizeStr =3D getAttributeValue(element, "asyncPoolSiz= e"); + if (asyncPoolSizeStr !=3D null && !asyncPoolSizeStr.trim().equals(""= )) + { + try + { + config.setListenerAsyncPoolSize(Integer.parseInt(asyncPoolSize= Str)); + } + catch (NumberFormatException nfe) + { + throw new ConfigurationException("Unable to parse the asyncPoo= lSize attribute of the listeners element. Was [" + asyncPoolSizeStr + "]"); + } + } + } + private void configureBuddyReplication(Element element) { if (element =3D=3D null) return;//buddy config might not exist, expe= ct that Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfig= urationParserTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParserTest.java 2008-08-04 12:38:14 UTC (rev 6491) +++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParserTest.java 2008-08-04 12:49:34 UTC (rev 6492) @@ -264,4 +264,9 @@ assert !config.isWriteSkewCheck(); assert config.getConcurrencyLevel() =3D=3D 21; } + + public void testListenerAsyncThreads() + { + assert config.getListenerAsyncPoolSize() =3D=3D 5; + } } Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfig= urationSchemaTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nSchemaTest.java 2008-08-04 12:38:14 UTC (rev 6491) +++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nSchemaTest.java 2008-08-04 12:49:34 UTC (rev 6492) @@ -10,12 +10,12 @@ import java.util.List; = /** - * Tests that all the xml file used within tests are correct with respect = to the schema definition. = - * = + * Tests that all the xml file used within tests are correct with respect = to the schema definition. + * * @author Mircea.Markus(a)jboss.com * @since 3.0 */ -(a)Test (groups =3D "functional") +(a)Test(groups =3D "functional") public class XmlConfigurationSchemaTest { public static final String BASE_DIR_FOR_CONFIG =3D "./configs"; @@ -33,20 +33,21 @@ "policyPerRegion-eviction.xml", "replSync.xml", "string-property-replaced.xml" - }; = + }; = /** * Simple test to prove that validation works. */ public void testSimpleFile() { - EceptionCountingErrorHanlder handler =3D new EceptionCountingErrorHa= nlder(); + ExceptionCountingErrorHandler handler =3D new ExceptionCountingError= Handler(); XmlConfigurationParser parser =3D new XmlConfigurationParser(handler= ); for (String file : testFiles) { System.out.println("file =3D " + file); parser.parseFile(BASE_DIR_FOR_CONFIG + File.separator + file); - assert handler.noErrors() : "error during parsing"; + for (Exception e : handler.exceptionList) e.printStackTrace(); + assert handler.noErrors() : "error during parsing (file " + file = + ")"; } } = @@ -67,7 +68,7 @@ assert parser.isValidating(); } = - private static class EceptionCountingErrorHanlder implements ErrorHandl= er + private static class ExceptionCountingErrorHandler implements ErrorHand= ler { List exceptionList =3D new ArrayList(); = @@ -88,7 +89,7 @@ = private void handleDefault(SAXParseException exception) { - System.out.println("Error :" + exception.getMessage()); + System.out.println("Error :" + exception.getMessage()); exceptionList.add(exception); } = Modified: core/trunk/src/test/resources/configs/parser-test.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/resources/configs/parser-test.xml 2008-08-04 12:38:= 14 UTC (rev 6491) +++ core/trunk/src/test/resources/configs/parser-test.xml 2008-08-04 12:49:= 34 UTC (rev 6492) @@ -110,4 +110,7 @@ + + + --===============3705602604874631740==-- From jbosscache-commits at lists.jboss.org Mon Aug 4 09:27:07 2008 Content-Type: multipart/mixed; boundary="===============2332373640533227908==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6493 - in core/trunk/src: main/java/org/jboss/cache/notifications and 3 other directories. Date: Mon, 04 Aug 2008 09:27:06 -0400 Message-ID: --===============2332373640533227908== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-04 09:27:06 -0400 (Mon, 04 Aug 2008) New Revision: 6493 Added: core/trunk/src/main/java/org/jboss/cache/util/concurrent/WithinThreadExe= cutor.java core/trunk/src/test/java/org/jboss/cache/notifications/AsyncNotification= Test.java Modified: core/trunk/src/main/java/org/jboss/cache/config/Configuration.java core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java core/trunk/src/main/java/org/jboss/cache/notifications/annotation/CacheL= istener.java Log: JBCACHE-1108 Move CacheListeners to their own thread pool, optionally enabl= ed using an attribute on @CacheListener Modified: core/trunk/src/main/java/org/jboss/cache/config/Configuration.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2008= -08-04 12:49:34 UTC (rev 6492) +++ core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2008= -08-04 13:27:06 UTC (rev 6493) @@ -204,7 +204,7 @@ private List customInterceptors =3D Collection= s.emptyList(); private boolean writeSkewCheck =3D false; private int concurrencyLevel =3D 500; - private int listenerAsyncPoolSize =3D 0; + private int listenerAsyncPoolSize =3D 1; = @Start(priority =3D 1) private void correctIsolationLevels() Modified: core/trunk/src/main/java/org/jboss/cache/notifications/NotifierIm= pl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.jav= a 2008-08-04 12:49:34 UTC (rev 6492) +++ core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.jav= a 2008-08-04 13:27:06 UTC (rev 6493) @@ -25,6 +25,7 @@ import org.jboss.cache.notifications.event.*; import static org.jboss.cache.notifications.event.Event.Type.*; import org.jboss.cache.util.ImmutableMapCopy; +import org.jboss.cache.util.concurrent.WithinThreadExecutor; import org.jgroups.View; = import javax.transaction.Transaction; @@ -39,6 +40,10 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.atomic.AtomicInteger; = /** * Helper class that handles all notifications to registered listeners. @@ -90,6 +95,10 @@ private Cache cache; private boolean useMarshalledValueMaps; private Configuration config; + // two separate executor services, one for sync and one for async liste= ners + private ExecutorService syncProcessor; + private ExecutorService asyncProcessor; + private static final AtomicInteger asyncNotifierThreadNumber =3D new At= omicInteger(0); = public NotifierImpl() { @@ -126,6 +135,13 @@ this.config =3D config; } = + @Stop + private void stop() + { + syncProcessor.shutdownNow(); + asyncProcessor.shutdownNow(); + } + @Destroy protected void destroy() { @@ -136,6 +152,22 @@ protected void start() { useMarshalledValueMaps =3D config.isUseLazyDeserialization(); + syncProcessor =3D new WithinThreadExecutor(); + if (config.getListenerAsyncPoolSize() > 0) + { + asyncProcessor =3D Executors.newFixedThreadPool(config.getListene= rAsyncPoolSize(), new ThreadFactory() + { + public Thread newThread(Runnable r) + { + return new Thread(r, "AsyncNotifier-" + asyncNotifierThread= Number.getAndIncrement()); + } + }); + } + else + { + // use the same sync executor + asyncProcessor =3D syncProcessor; + } } = /** @@ -147,7 +179,7 @@ @SuppressWarnings("unchecked") private void validateAndAddListenerInvocation(Object listener) { - testListenerClassValidity(listener.getClass()); + boolean sync =3D testListenerClassValidity(listener.getClass()); = boolean foundMethods =3D false; // now try all methods on the listener for anything that we like. N= ote that only PUBLIC methods are scanned. @@ -159,7 +191,7 @@ if (m.isAnnotationPresent(allowedMethodAnnotations[i])) { testListenerMethodValidity(m, parameterTypes[i], allowedMet= hodAnnotations[i].getName()); - addListenerInvocation(allowedMethodAnnotations[i], new List= enerInvocation(listener, m)); + addListenerInvocation(allowedMethodAnnotations[i], new List= enerInvocation(listener, m, sync)); foundMethods =3D true; } } @@ -169,12 +201,22 @@ log.warn("Attempted to register listener of class " + listener.ge= tClass() + ", but no valid, public methods annotated with method-level even= t annotations found! Ignoring listener."); } = - private static void testListenerClassValidity(Class listenerClass) + /** + * Tests if a class is properly annotated as a CacheListener and return= s whether callbacks on this class should be invoked + * synchronously or asynchronously. + * + * @param listenerClass class to inspect + * @return true if callbacks on this class should use the syncProcessor= ; false if it should use the asyncProcessor. + */ + private static boolean testListenerClassValidity(Class listenerClass) { - if (!listenerClass.isAnnotationPresent(CacheListener.class)) + CacheListener cl =3D listenerClass.getAnnotation(CacheListener.class= ); + if (cl =3D=3D null) throw new IncorrectCacheListenerException("Cache listener class M= UST be annotated with org.jboss.cache.notifications.annotation.CacheListene= r"); if (!Modifier.isPublic(listenerClass.getModifiers())) throw new IncorrectCacheListenerException("Cache listener class M= UST be public!"); + return cl.sync(); + } = private static void testListenerMethodValidity(Method m, Class allowedP= arameter, String annotationName) @@ -616,36 +658,49 @@ */ class ListenerInvocation { - private final Object target; - private final Method method; + private final boolean sync; = - public ListenerInvocation(Object target, Method method) + public ListenerInvocation(Object target, Method method, boolean sync) { this.target =3D target; this.method =3D method; + this.sync =3D sync; } = - public void invoke(Event e) + public void invoke(final Event e) { - try + Runnable r =3D new Runnable() { - method.invoke(target, e); - } - catch (InvocationTargetException e1) - { - Throwable cause =3D e1.getCause(); - if (cause !=3D null) - throw new CacheException("Caught exception invoking method = " + method + " on listener instance " + target, cause); - else - throw new CacheException("Caught exception invoking method = " + method + " on listener instance " + target, e1); - } - catch (IllegalAccessException e1) - { - log.warn("Unable to invoke method " + method + " on Object ins= tance " + target + " - removing this target object from list of listeners!"= , e1); - removeCacheListener(this.target); - } + + public void run() + { + try + { + method.invoke(target, e); + } + catch (InvocationTargetException exception) + { + Throwable cause =3D exception.getCause(); + if (cause !=3D null) + throw new CacheException("Caught exception invoking m= ethod " + method + " on listener instance " + target, cause); + else + throw new CacheException("Caught exception invoking m= ethod " + method + " on listener instance " + target, exception); + } + catch (IllegalAccessException exception) + { + log.warn("Unable to invoke method " + method + " on Obje= ct instance " + target + " - removing this target object from list of liste= ners!", exception); + removeCacheListener(target); + } + } + }; + + if (sync) + syncProcessor.execute(r); + else + asyncProcessor.execute(r); + } = } Modified: core/trunk/src/main/java/org/jboss/cache/notifications/annotation= /CacheListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/notifications/annotation/Cache= Listener.java 2008-08-04 12:49:34 UTC (rev 6492) +++ core/trunk/src/main/java/org/jboss/cache/notifications/annotation/Cache= Listener.java 2008-08-04 13:27:06 UTC (rev 6493) @@ -298,4 +298,5 @@ @Target(ElementType.TYPE) public @interface CacheListener { + boolean sync() default true; } Added: core/trunk/src/main/java/org/jboss/cache/util/concurrent/WithinThrea= dExecutor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/util/concurrent/WithinThreadEx= ecutor.java (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/util/concurrent/WithinThreadEx= ecutor.java 2008-08-04 13:27:06 UTC (rev 6493) @@ -0,0 +1,89 @@ +package org.jboss.cache.util.concurrent; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +/** + * An executor that works within the current thread. + * + * @author Manik Surtani (manik(a)jbo= ss.org) + * @see Java Concurrency In Practice + * @since 3.0 + */ +public class WithinThreadExecutor implements ExecutorService +{ + boolean shutDown =3D false; + + public void execute(Runnable command) + { + command.run(); + } + + public void shutdown() + { + shutDown =3D true; + } + + public List shutdownNow() + { + shutDown =3D true; + return Collections.emptyList(); + } + + public boolean isShutdown() + { + return shutDown; + } + + public boolean isTerminated() + { + return shutDown; + } + + public boolean awaitTermination(long timeout, TimeUnit unit) throws Int= erruptedException + { + return shutDown; + } + + public Future submit(Callable task) + { + throw new UnsupportedOperationException(); + } + + public Future submit(Runnable task, T result) + { + throw new UnsupportedOperationException(); + } + + public Future submit(Runnable task) + { + throw new UnsupportedOperationException(); + } + + public List> invokeAll(Collection> tasks) thr= ows InterruptedException + { + throw new UnsupportedOperationException(); + } + + public List> invokeAll(Collection> tasks, lon= g timeout, TimeUnit unit) throws InterruptedException + { + throw new UnsupportedOperationException(); + } + + public T invokeAny(Collection> tasks) throws Interrupte= dException, ExecutionException + { + throw new UnsupportedOperationException(); + } + + public T invokeAny(Collection> tasks, long timeout, Tim= eUnit unit) throws InterruptedException, ExecutionException, TimeoutExcepti= on + { + throw new UnsupportedOperationException(); + } +} Added: core/trunk/src/test/java/org/jboss/cache/notifications/AsyncNotifica= tionTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/notifications/AsyncNotificatio= nTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/notifications/AsyncNotificatio= nTest.java 2008-08-04 13:27:06 UTC (rev 6493) @@ -0,0 +1,87 @@ +package org.jboss.cache.notifications; + +import org.jboss.cache.Cache; +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.notifications.annotation.CacheListener; +import org.jboss.cache.notifications.annotation.NodeCreated; +import org.jboss.cache.notifications.event.NodeCreatedEvent; +import org.jboss.cache.util.TestingUtil; +import org.testng.annotations.Test; + +import java.util.concurrent.CountDownLatch; + +(a)Test(groups =3D "functional") +public class AsyncNotificationTest +{ + public void testAsyncNotification() throws InterruptedException + { + Cache c =3D null; + try + { + c =3D new DefaultCacheFactory().createCache(); + CountDownLatch latch =3D new CountDownLatch(2); + AbstractListener syncListener =3D new Listener(latch); + AbstractListener asyncListener =3D new AsyncListener(latch); + c.addCacheListener(syncListener); + c.addCacheListener(asyncListener); + c.put("/a", "k", "v"); + latch.await(); + assert syncListener.caller =3D=3D Thread.currentThread(); + assert asyncListener.caller !=3D Thread.currentThread(); + } + finally + { + TestingUtil.killCaches(c); + } + } + + public abstract static class AbstractListener + { + Thread caller; + CountDownLatch latch; + + protected AbstractListener(CountDownLatch latch) + { + this.latch =3D latch; + } + } + + @CacheListener(sync =3D true) + public static class Listener extends AbstractListener + { + public Listener(CountDownLatch latch) + { + super(latch); + } + + @NodeCreated + public void handle(NodeCreatedEvent e) + { + if (e.isPre()) + { + caller =3D Thread.currentThread(); + latch.countDown(); + } + } + } + + @CacheListener(sync =3D false) + public static class AsyncListener extends AbstractListener + { + public AsyncListener(CountDownLatch latch) + { + super(latch); + } + + @NodeCreated + public void handle(NodeCreatedEvent e) + { + if (e.isPre()) + { + caller =3D Thread.currentThread(); + latch.countDown(); + } + } + } + +} --===============2332373640533227908==-- From jbosscache-commits at lists.jboss.org Mon Aug 4 09:34:31 2008 Content-Type: multipart/mixed; boundary="===============6806510994640899211==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6494 - in core/trunk/src/main/java/org/jboss/cache: notifications/annotation and 1 other directory. Date: Mon, 04 Aug 2008 09:34:31 -0400 Message-ID: --===============6806510994640899211== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-04 09:34:30 -0400 (Mon, 04 Aug 2008) New Revision: 6494 Modified: core/trunk/src/main/java/org/jboss/cache/config/Configuration.java core/trunk/src/main/java/org/jboss/cache/notifications/annotation/CacheL= istener.java Log: JBCACHE-1108 Javadocs Modified: core/trunk/src/main/java/org/jboss/cache/config/Configuration.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2008= -08-04 13:27:06 UTC (rev 6493) +++ core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2008= -08-04 13:34:30 UTC (rev 6494) @@ -412,6 +412,14 @@ this.syncRollbackPhase =3D syncRollbackPhase; } = + /** + * Sets the size of the asynchronous listener notification thread pool = size. Defaults to 1, and if set to below 1, + * all async listeners (specified with {@link org.jboss.cache.notificat= ions.annotation.CacheListener#sync()} are notified + * synchronously. + * + * @param listenerAsyncPoolSize number of threads in pool + * @since 3.0 + */ public void setListenerAsyncPoolSize(int listenerAsyncPoolSize) { testImmutability("asyncListenerPoolSize"); @@ -721,7 +729,12 @@ } = /** - * @return the size of the async listener thread pool. If this is < 1,= all async listeners should be treated as sync listeners. + * Gets the size of the asynchronous listener notification thread pool = size. Defaults to 1, and if set to below 1, + * all async listeners (specified with {@link org.jboss.cache.notificat= ions.annotation.CacheListener#sync()} are notified + * synchronously. + * + * @return thread pool size + * @since 3.0 */ public int getListenerAsyncPoolSize() { Modified: core/trunk/src/main/java/org/jboss/cache/notifications/annotation= /CacheListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/notifications/annotation/Cache= Listener.java 2008-08-04 13:27:06 UTC (rev 6493) +++ core/trunk/src/main/java/org/jboss/cache/notifications/annotation/Cache= Listener.java 2008-08-04 13:34:30 UTC (rev 6494) @@ -58,8 +58,11 @@ * as locks may be held longer than necessary or intended to and may cause= deadlocking in certain situations. See above paragraph * on long-running tasks that should be run in a separate thread. *

+ * Note: Since 3.0, a new parameter, sync, has been introd= uced on this annotation. This defaults to true + * which provides the above semantics. Alternatively, if you set sync= to false, then invocations are made in a + * separate thread, which will not cause any blocking on the caller= or network thread. The separate thread is taken + * from a pool, which can be configured using {@link org.jboss.cache.confi= g.Configuration#setListenerAsyncPoolSize(int)}. *

- *

* Summary of Notification Annotations * * @@ -298,5 +301,12 @@ @Target(ElementType.TYPE) public @interface CacheListener { + /** + * Specifies whether callbacks on any class annotated with this annotat= ion happens synchronously (in the caller's thread) + * or asynchronously (using a separate thread). Defaults to true. + * + * @return true if the expectation is that callbacks are called using t= he caller's thread; false if they are to be made in a separate thread. + * @since 3.0 + */ boolean sync() default true; } --===============6806510994640899211==-- From jboss-qa-internal at redhat.com Mon Aug 4 09:56:11 2008 Content-Type: multipart/mixed; boundary="===============6881606544236644176==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23532?= Date: Mon, 04 Aug 2008 09:56:06 -0400 Message-ID: <450087068.12191217858166753.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 2139995674.10691217780405272.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============6881606544236644176== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/532/changes --===============6881606544236644176==-- From jbosscache-commits at lists.jboss.org Mon Aug 4 10:20:21 2008 Content-Type: multipart/mixed; boundary="===============0409471134606186214==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6495 - benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0. Date: Mon, 04 Aug 2008 10:20:21 -0400 Message-ID: --===============0409471134606186214== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-04 10:20:21 -0400 (Mon, 04 Aug 2008) New Revision: 6495 Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/config.sh Log: increased memory size Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/co= nfig.sh =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/config.s= h 2008-08-04 13:34:30 UTC (rev 6494) +++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/config.s= h 2008-08-04 14:20:21 UTC (rev 6495) @@ -15,5 +15,5 @@ #--classpath was set = #additional JVM options -JVM_OPTIONS=3D"$JVM_OPTIONS -Djava.net.preferIPv4Stack=3Dtrue -Djbosscache= .config.validate=3Dfalse" = +JVM_OPTIONS=3D"$JVM_OPTIONS -Djava.net.preferIPv4Stack=3Dtrue -Djbosscache= .config.validate=3Dfalse -Xmx2048m" JVM_OPTIONS=3D"$JVM_OPTIONS -DcacheBenchFwk.cacheWrapperClassName=3Dorg.ca= chebench.cachewrappers.JBossCache300Wrapper" --===============0409471134606186214==-- From jbosscache-commits at lists.jboss.org Mon Aug 4 10:21:20 2008 Content-Type: multipart/mixed; boundary="===============4252883762791052252==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6496 - benchmarks/benchmark-fwk/trunk/cache-products/coherence-3.3.1. Date: Mon, 04 Aug 2008 10:21:20 -0400 Message-ID: --===============4252883762791052252== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-04 10:21:20 -0400 (Mon, 04 Aug 2008) New Revision: 6496 Modified: benchmarks/benchmark-fwk/trunk/cache-products/coherence-3.3.1/config.sh Log: increased memory size Modified: benchmarks/benchmark-fwk/trunk/cache-products/coherence-3.3.1/con= fig.sh =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- benchmarks/benchmark-fwk/trunk/cache-products/coherence-3.3.1/config.sh= 2008-08-04 14:20:21 UTC (rev 6495) +++ benchmarks/benchmark-fwk/trunk/cache-products/coherence-3.3.1/config.sh= 2008-08-04 14:21:20 UTC (rev 6496) @@ -15,6 +15,6 @@ #--classpath was set = #additional JVM options -export JVM_OPTIONS=3D"$JVM_OPTIONS -Djava.net.preferIPv4Stack=3Dtrue -Dtan= gosol.coherence.localhost=3D${MYTESTIP_1}" +export JVM_OPTIONS=3D"$JVM_OPTIONS -Xmx2048m -Djava.net.preferIPv4Stack=3D= true -Dtangosol.coherence.localhost=3D${MYTESTIP_1}" export JVM_OPTIONS=3D"$JVM_OPTIONS -Dtangosol.coherence.cacheconfig=3Dcach= e-config.xml" export JVM_OPTIONS=3D"$JVM_OPTIONS -DcacheBenchFwk.cacheWrapperClassName= =3Dorg.cachebench.cachewrappers.Coherence331Wrapper" --===============4252883762791052252==-- From jbosscache-commits at lists.jboss.org Mon Aug 4 10:22:30 2008 Content-Type: multipart/mixed; boundary="===============9210551689063059990==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6497 - core/trunk/src/main/java/org/jboss/cache/marshall. Date: Mon, 04 Aug 2008 10:22:30 -0400 Message-ID: --===============9210551689063059990== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-04 10:22:30 -0400 (Mon, 04 Aug 2008) New Revision: 6497 Modified: core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java Log: Compat with older marshaller Modified: core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshal= ler.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.ja= va 2008-08-04 14:21:20 UTC (rev 6496) +++ core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.ja= va 2008-08-04 14:22:30 UTC (rev 6497) @@ -104,7 +104,7 @@ = public Object objectFromByteBuffer(byte[] bytes) throws Exception { - throw new RuntimeException("Needs to be overridden!"); + return objectFromByteBuffer(bytes, 0, bytes.length); } = public Object objectFromByteBuffer(byte[] bytes, int offset, int len) t= hrows Exception --===============9210551689063059990==-- From jboss-qa-internal at redhat.com Mon Aug 4 10:31:22 2008 Content-Type: multipart/mixed; boundary="===============9179133593481285887==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Build_failed_in_Hudson=3A_jboss-cache-?= =?utf-8?q?core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_=23401?= Date: Mon, 04 Aug 2008 10:31:15 -0400 Message-ID: <1951981320.12211217860275609.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1364597441.10701217781108224.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============9179133593481285887== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/401/changes ------------------------------------------ started Building remotely on dev60-linux Reusing existing maven process [INFO] Scanning for projects... [INFO] --------------------------------------------------------------------= ---- [INFO] Building JBoss Cache - Core Edition [INFO] task-segment: [package] [INFO] --------------------------------------------------------------------= ---- [INFO] [enforcer:enforce {execution: enforce-java}] [INFO] [resources:resources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:compile] Compiling 464 source files to /home/hudson/hudson_workspace/workspace/jboss= -cache-core-trunk-jdk1.6/target/classes [HUDSON] Archiving /home/hudson/hudson_workspace/workspace/jboss-cache-core= -trunk-jdk1.6/./pom.xml [INFO] --------------------------------------------------------------------= ---- [ERROR] BUILD FAILURE [INFO] --------------------------------------------------------------------= ---- [INFO] Compilation failure /home/hudson/hudson_workspace/workspace/jboss-cache-core-trunk-jdk1.6/src/m= ain/java/org/jboss/cache/util/concurrent/WithinThreadExecutor.java:[20,7] o= rg.jboss.cache.util.concurrent.WithinThreadExecutor is not abstract and doe= s not override abstract method invokeAny(java.util.Collection>,long,java.util.concurrent.TimeUnit) in ja= va.util.concurrent.ExecutorService [INFO] --------------------------------------------------------------------= ---- [INFO] For more information, run Maven with the -e switch [INFO] --------------------------------------------------------------------= ---- [INFO] Total time: 26 seconds [INFO] Finished at: Mon Aug 04 10:31:12 EDT 2008 [INFO] Final Memory: 23M/134M [INFO] --------------------------------------------------------------------= ---- Waiting for Hudson to finish collecting data --===============9179133593481285887==-- From jbosscache-commits at lists.jboss.org Mon Aug 4 10:42:47 2008 Content-Type: multipart/mixed; boundary="===============0611383899052689024==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6498 - pojo/trunk/src/test/resources. Date: Mon, 04 Aug 2008 10:42:47 -0400 Message-ID: --===============0611383899052689024== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-04 10:42:47 -0400 (Mon, 04 Aug 2008) New Revision: 6498 Modified: pojo/trunk/src/test/resources/log4j.xml Log: Reduced log levels Modified: pojo/trunk/src/test/resources/log4j.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/resources/log4j.xml 2008-08-04 14:22:30 UTC (rev 64= 97) +++ pojo/trunk/src/test/resources/log4j.xml 2008-08-04 14:42:47 UTC (rev 64= 98) @@ -63,7 +63,7 @@ = - + = --===============0611383899052689024==-- From jbosscache-commits at lists.jboss.org Mon Aug 4 11:56:44 2008 Content-Type: multipart/mixed; boundary="===============1401541401555412918==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6499 - core/trunk/src/main/java/org/jboss/cache/config/parsing. Date: Mon, 04 Aug 2008 11:56:43 -0400 Message-ID: --===============1401541401555412918== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-04 11:56:43 -0400 (Mon, 04 Aug 2008) New Revision: 6499 Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguration= Parser.java Log: now It is possible to override the schema with one specified through a cust= om porperty Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfig= urationParser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParser.java 2008-08-04 14:42:47 UTC (rev 6498) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParser.java 2008-08-04 15:56:43 UTC (rev 6499) @@ -50,10 +50,12 @@ * Reads in XMLconfiguration files and spits out a {@link org.jboss.cache.= config.Configuration} object. * By default this class uses a validating parser (configurable). *

- * In order to make the parser non-validating by default, the follwing sys= tem property is expected: - * -Djbosscache.config.validate=3Dfalse - *

- * Implementation note: this class is stateful and one instance should be = used for parsing a single configuration file. + * Following system properties can be used for customizing parser behavior: + *

    + *
  • -Djbosscache.config.validate=3Dfalse will make the parser= non-validating
  • + *
  • -Djbosscache.config.schemaLocation=3Durl allows one to sp= ecify a validation schema that would override the one specified in the the = xml document
  • + *
+ * This class is stateful and one instance should be used for parsing a si= ngle configuration file. * * @author Mircea.Markus(a)jboss.com * @since 3.0 @@ -63,6 +65,7 @@ private static final Log log =3D LogFactory.getLog(XmlConfigurationPars= er.class); = public static final String VALIDATING_SYSTEM_PROPERTY =3D "jbosscache.c= onfig.validate"; + public static final String SCHEMA_LOCATION_SYSTEM_PROPERTY =3D "jbossca= che.config.schemaLocation"; = /** * the resulting configuration. @@ -71,6 +74,7 @@ private Element root; private ErrorHandler errorHandler; private boolean isValidating; + private String schemaLocation; = /** * If validation is on (default) one can specify an error handler for h= andling validation errors. @@ -80,6 +84,7 @@ { this.errorHandler =3D errorHandler; isValidating =3D System.getProperty(VALIDATING_SYSTEM_PROPERTY) =3D= =3D null || Boolean.getBoolean(VALIDATING_SYSTEM_PROPERTY); + schemaLocation =3D System.getProperty(SCHEMA_LOCATION_SYSTEM_PROPERT= Y); } = /** @@ -387,6 +392,15 @@ docBuilderFactory.setValidating(true); docBuilderFactory.setNamespaceAware(true); docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/p= roperties/schemaLanguage", "http://www.w3.org/2001/XMLSchema"); + if (schemaLocation !=3D null) + { + if (log.isTraceEnabled()) log.trace("Using the schema locat= ion set to: '" + schemaLocation + '\''); + docBuilderFactory.setAttribute("http://java.sun.com/xml/jax= p/properties/schemaSource", schemaLocation); + } + else if (log.isTraceEnabled()) + { + log.trace("Validation is enabled, using the schema decalred= in the .xml configuration file"); + } } DocumentBuilder parser =3D docBuilderFactory.newDocumentBuilder(); parser.setErrorHandler(errorHandler); --===============1401541401555412918==-- From jbosscache-commits at lists.jboss.org Mon Aug 4 11:57:30 2008 Content-Type: multipart/mixed; boundary="===============1169503057401397703==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6500 - in core/trunk/src: test/java/org/jboss/cache/config/parsing and 1 other directory. Date: Mon, 04 Aug 2008 11:57:29 -0400 Message-ID: --===============1169503057401397703== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-04 11:57:29 -0400 (Mon, 04 Aug 2008) New Revision: 6500 Modified: core/trunk/src/main/resources/jbosscache-config-3.0.xsd core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguration= SchemaTest.java Log: schema now supports the 'listeners' configuration elements Modified: core/trunk/src/main/resources/jbosscache-config-3.0.xsd =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/resources/jbosscache-config-3.0.xsd 2008-08-04 15:5= 6:43 UTC (rev 6499) +++ core/trunk/src/main/resources/jbosscache-config-3.0.xsd 2008-08-04 15:5= 7:29 UTC (rev 6500) @@ -1,22 +1,23 @@ - + - - - - - - - - - - - - + + + + + + + + + + + + + @@ -95,17 +96,17 @@ - + - + - + @@ -133,6 +134,10 @@ = + + + + @@ -154,7 +159,7 @@ = - + @@ -173,7 +178,7 @@ = - + @@ -188,10 +193,10 @@ - + - + Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfig= urationSchemaTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nSchemaTest.java 2008-08-04 15:56:43 UTC (rev 6499) +++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nSchemaTest.java 2008-08-04 15:57:29 UTC (rev 6500) @@ -46,6 +46,7 @@ { System.out.println("file =3D " + file); parser.parseFile(BASE_DIR_FOR_CONFIG + File.separator + file); + System.out.println("Processed file =3D " + file); for (Exception e : handler.exceptionList) e.printStackTrace(); assert handler.noErrors() : "error during parsing (file " + file = + ")"; } --===============1169503057401397703==-- From jboss-qa-internal at redhat.com Mon Aug 4 12:12:40 2008 Content-Type: multipart/mixed; boundary="===============2861796010596069053==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Build_failed_in_Hudson=3A_jboss-cache-?= =?utf-8?q?core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_=23402?= Date: Mon, 04 Aug 2008 12:11:58 -0400 Message-ID: <814107337.12301217866318812.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1951981320.12211217860275609.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============2861796010596069053== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/402/changes Changes: [mircea.markus] schema now supports the 'listeners' configuration elements [mircea.markus] now It is possible to override the schema with one specifie= d through a custom porperty ------------------------------------------ started Building remotely on dev60-linux Reusing existing maven process [INFO] Scanning for projects... [INFO] --------------------------------------------------------------------= ---- [INFO] Building JBoss Cache - Core Edition [INFO] task-segment: [package] [INFO] --------------------------------------------------------------------= ---- [INFO] [enforcer:enforce {execution: enforce-java}] [INFO] [resources:resources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:compile] Compiling 464 source files to /home/hudson/hudson_workspace/workspace/jboss= -cache-core-trunk-jdk1.6/target/classes [HUDSON] Archiving /home/hudson/hudson_workspace/workspace/jboss-cache-core= -trunk-jdk1.6/./pom.xml [INFO] --------------------------------------------------------------------= ---- [ERROR] BUILD FAILURE [INFO] --------------------------------------------------------------------= ---- [INFO] Compilation failure /home/hudson/hudson_workspace/workspace/jboss-cache-core-trunk-jdk1.6/src/m= ain/java/org/jboss/cache/util/concurrent/WithinThreadExecutor.java:[20,7] o= rg.jboss.cache.util.concurrent.WithinThreadExecutor is not abstract and doe= s not override abstract method invokeAny(java.util.Collection>,long,java.util.concurrent.TimeUnit) in ja= va.util.concurrent.ExecutorService [INFO] --------------------------------------------------------------------= ---- [INFO] For more information, run Maven with the -e switch [INFO] --------------------------------------------------------------------= ---- [INFO] Total time: 28 seconds [INFO] Finished at: Mon Aug 04 12:11:42 EDT 2008 [INFO] Final Memory: 22M/112M [INFO] --------------------------------------------------------------------= ---- Waiting for Hudson to finish collecting data --===============2861796010596069053==-- From jbosscache-commits at lists.jboss.org Mon Aug 4 12:30:05 2008 Content-Type: multipart/mixed; boundary="===============5082174230351545160==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6501 - benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/lib. Date: Mon, 04 Aug 2008 12:30:04 -0400 Message-ID: --===============5082174230351545160== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-04 12:30:04 -0400 (Mon, 04 Aug 2008) New Revision: 6501 Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/lib/jboss= cache-core.jar Log: updated jbc jar Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/li= b/jbosscache-core.jar =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) --===============5082174230351545160==-- From jbosscache-commits at lists.jboss.org Mon Aug 4 12:57:26 2008 Content-Type: multipart/mixed; boundary="===============2489912423056621795==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6502 - benchmarks/benchmark-fwk/trunk. Date: Mon, 04 Aug 2008 12:57:25 -0400 Message-ID: --===============2489912423056621795== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-04 12:57:25 -0400 (Mon, 04 Aug 2008) New Revision: 6502 Modified: benchmarks/benchmark-fwk/trunk/allJBossCacheTests.sh Log: cluster.sh will be called with nohup Modified: benchmarks/benchmark-fwk/trunk/allJBossCacheTests.sh =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- benchmarks/benchmark-fwk/trunk/allJBossCacheTests.sh 2008-08-04 16:30:0= 4 UTC (rev 6501) +++ benchmarks/benchmark-fwk/trunk/allJBossCacheTests.sh 2008-08-04 16:57:2= 5 UTC (rev 6502) @@ -1,10 +1,9 @@ #!/bin/bash = scaling=3D"2 4 6 8" -#scaling=3D"2 4 6 8 10" -#scaling=3D"2 4" -configs=3D"pess-repl-async.xml pess-repl-sync.xml pess-repl-async-br.xml" -products=3D"jbosscache-2.0.0 jbosscache-2.1.0" +configs=3D"pess-repl-sync.xml pess-repl-sync-br.xml pess-repl-async.xml mv= cc-repl-sync.xml mvcc-repl-sync-br.xml mvcc-repl-async.xml" +#configs=3D"distributed replicated" +products=3D"jbosscache-3.0.0" = mkdir output = @@ -14,7 +13,7 @@ do for size in $scaling do - ./cluster.sh start $product $config $size + nohup ./cluster.sh start $product $config $size = outputFileName=3Ddata_${product}_${config}_${size}.csv while [ ! -e $outputFileName ] --===============2489912423056621795==-- From jboss-qa-internal at redhat.com Mon Aug 4 13:27:46 2008 Content-Type: multipart/mixed; boundary="===============1531148542118646440==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23534?= Date: Mon, 04 Aug 2008 13:27:40 -0400 Message-ID: <1462027951.12431217870860716.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 450087068.12191217858166753.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============1531148542118646440== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/534/changes --===============1531148542118646440==-- From jboss-qa-internal at redhat.com Mon Aug 4 15:43:30 2008 Content-Type: multipart/mixed; boundary="===============0247096374421550879==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23535?= Date: Mon, 04 Aug 2008 15:43:23 -0400 Message-ID: <1778084350.12681217879003646.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1462027951.12431217870860716.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============0247096374421550879== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/535/changes --===============0247096374421550879==-- From jbosscache-commits at lists.jboss.org Mon Aug 4 16:26:16 2008 Content-Type: multipart/mixed; boundary="===============5105770112640108030==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6503 - core/trunk/src/main/java/org/jboss/cache/util/concurrent. Date: Mon, 04 Aug 2008 16:26:14 -0400 Message-ID: --===============5105770112640108030== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-04 16:26:13 -0400 (Mon, 04 Aug 2008) New Revision: 6503 Modified: core/trunk/src/main/java/org/jboss/cache/util/concurrent/WithinThreadExe= cutor.java Log: Worked around http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=3D6267833 Modified: core/trunk/src/main/java/org/jboss/cache/util/concurrent/WithinTh= readExecutor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/util/concurrent/WithinThreadEx= ecutor.java 2008-08-04 16:57:25 UTC (rev 6502) +++ core/trunk/src/main/java/org/jboss/cache/util/concurrent/WithinThreadEx= ecutor.java 2008-08-04 20:26:13 UTC (rev 6503) @@ -67,22 +67,30 @@ throw new UnsupportedOperationException(); } = - public List> invokeAll(Collection> tasks) thr= ows InterruptedException + @SuppressWarnings("unchecked") + // unchecked on purpose due to http://bugs.sun.com/bugdatabase/view_bug= .do?bug_id=3D6267833 + public List invokeAll(Collection tasks) throws InterruptedException { throw new UnsupportedOperationException(); } = - public List> invokeAll(Collection> tasks, lon= g timeout, TimeUnit unit) throws InterruptedException + @SuppressWarnings("unchecked") + // unchecked on purpose due to http://bugs.sun.com/bugdatabase/view_bug= .do?bug_id=3D6267833 + public List invokeAll(Collection tasks, long timeout, TimeUnit unit) th= rows InterruptedException { throw new UnsupportedOperationException(); } = - public T invokeAny(Collection> tasks) throws Interrupte= dException, ExecutionException + @SuppressWarnings("unchecked") + // unchecked on purpose due to http://bugs.sun.com/bugdatabase/view_bug= .do?bug_id=3D6267833 + public Object invokeAny(Collection tasks) throws InterruptedException, = ExecutionException { throw new UnsupportedOperationException(); } = - public T invokeAny(Collection> tasks, long timeout, Tim= eUnit unit) throws InterruptedException, ExecutionException, TimeoutExcepti= on + @SuppressWarnings("unchecked") + // unchecked on purpose due to http://bugs.sun.com/bugdatabase/view_bug= .do?bug_id=3D6267833 + public Object invokeAny(Collection tasks, long timeout, TimeUnit unit) = throws InterruptedException, ExecutionException, TimeoutException { throw new UnsupportedOperationException(); } --===============5105770112640108030==-- From jboss-qa-internal at redhat.com Mon Aug 4 18:37:23 2008 Content-Type: multipart/mixed; boundary="===============3945113417905330827==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23536?= Date: Mon, 04 Aug 2008 18:37:20 -0400 Message-ID: <1991948003.12901217889440242.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1778084350.12681217879003646.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============3945113417905330827== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/536/changes --===============3945113417905330827==-- From jboss-qa-internal at redhat.com Mon Aug 4 19:24:17 2008 Content-Type: multipart/mixed; boundary="===============1107417679897553395==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_unstable=3A_jboss-cach?= =?utf-8?q?e-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_=23403?= Date: Mon, 04 Aug 2008 19:24:13 -0400 Message-ID: <908041050.12931217892253576.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 814107337.12301217866318812.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============1107417679897553395== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/403/changes --===============1107417679897553395==-- From jbosscache-commits at lists.jboss.org Tue Aug 5 06:23:57 2008 Content-Type: multipart/mixed; boundary="===============5192921695485565165==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6504 - in core/trunk/src: test/java/org/jboss/cache/util and 1 other directory. Date: Tue, 05 Aug 2008 06:23:57 -0400 Message-ID: --===============5192921695485565165== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-05 06:23:56 -0400 (Tue, 05 Aug 2008) New Revision: 6504 Modified: core/trunk/src/main/java/org/jboss/cache/util/Caches.java core/trunk/src/test/java/org/jboss/cache/util/CachesTest.java Log: Update to Caches code Modified: core/trunk/src/main/java/org/jboss/cache/util/Caches.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/util/Caches.java 2008-08-04 20= :26:13 UTC (rev 6503) +++ core/trunk/src/main/java/org/jboss/cache/util/Caches.java 2008-08-05 10= :23:56 UTC (rev 6504) @@ -3,6 +3,7 @@ import org.jboss.cache.Cache; import org.jboss.cache.Fqn; import org.jboss.cache.Node; +import org.jboss.cache.NodeSPI; import org.jboss.cache.loader.CacheLoader; = import java.util.AbstractMap; @@ -10,7 +11,6 @@ import java.util.ConcurrentModificationException; import java.util.Iterator; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; = /** @@ -36,12 +36,13 @@ /** * Returns a {@link Map} from the root node. * + * @param cache cache to wrap as a map + * @return a map representation of the cache * @see #asMap(Node) */ - public static Map asMap(Cache cache) + public static Map asMap(Cache cache) { - if (cache =3D=3D null) - throw new NullPointerException("cache"); + if (cache =3D=3D null) throw new NullPointerException("cache"); return asMap(cache.getRoot()); } = @@ -62,10 +63,13 @@ * Also, when using a {@link CacheLoader} for storage, keys used must b= e valid as * part of the {@link Fqn} used in calls. Generally speaking, simple st= ring values are * preferred. + * + * @param node node in a cache to wrap + * @return a Map representation of the cache */ - public static Map asMap(Node node) + public static Map asMap(Node node) { - return new MapNode(node); + return new MapNode(node); } = /** @@ -83,10 +87,13 @@ * of the data at time of calling. This may be very inefficient. *

* The map is not serializable. + * + * @param node node to wrap + * @return Map representation of the cache */ - public static Map asSimpleMap(Node node) + public static Map asSimpleMap(Node node) { - return new SimpleMapNode(node); + return new SimpleMapNode(node); } = /** @@ -100,23 +107,28 @@ * and all methods are thread safe. *

* The set is not serializable. + * + * @param node node to wrap + * @return a Set representation of the values in a node */ - public static Set asSimpleSet(Node node) + public static Set asSimpleSet(Node node) { - return new SimpleSetNode(node); + return new SimpleSetNode(node); } = /** * Returns a {@link Map}, where map entries are partitioned into * children nodes, within a cache node. - * The default child selector divides the data into 16 child nodes base= d on hash code. + * The default child selector divides the data into 128 child nodes bas= ed on hash code. * Note that for large data sets, the number of child nodes should be i= ncreased. * * @param node node to cache under + * @return a Map representation of the cache */ - public static Map asPartitionedMap(Node node) + @SuppressWarnings("unchecked") + public static Map asPartitionedMap(Node node) { - return new PartitionedMapNode(node, HashKeySelector.DEFAULT); + return new PartitionedMapNode(node, HashKeySelector.DEFAULT); } = /** @@ -132,10 +144,11 @@ * * @param node node to cache under * @param ss selector strategy that chooses a segment based on key + * @return a Map representation of the cache */ - public static Map asPartitionedMap(Node node, ChildSelector ss) + public static Map asPartitionedMap(Node node, ChildS= elector ss) { - return new PartitionedMapNode(node, ss); + return new PartitionedMapNode(node, ss); } = /** @@ -143,31 +156,36 @@ * within the cache root, by key hash code. * * @param cache cache to use - * @return + * @return a Map representation of the cache */ - public static Map asPartitionedMap(Cache cache) + public static Map asPartitionedMap(Cache cache) { return asPartitionedMap(cache.getRoot()); } = /** + * Computes an improved hash code from an object's hash code. + */ + static protected final int hashCode(int i) + { + i ^=3D i >>> 20 ^ i >>> 12; + return i ^ i >>> 7 ^ i >>> 4; + } + + /** * Returns a segment ({@link Node#getChild(Object) child node name}) * to use based on the characteristics of a key. *

* Here is an example class which selects a child based on a person's d= epartment: *

-    * public static class DepartmentSelector implements ChildSelector
+    * public static class DepartmentSelector implements ChildSelector<P=
erson>
     * {
-    * 

- * public Object childName(Person key) - * { - * return key.getDepartment(); + * public Object childName(Person key) + * { + * return key.getDepartment(); + * } * } - *

- * } *

- * - * @ */ public interface ChildSelector { @@ -177,21 +195,23 @@ * @param key for calls to {@link Map#put}, {@link Map#get} etc. * @return node name */ - Object childName(T key); + Fqn childName(T key); } = /** * Class that returns a child name to use based on the hash code of a k= ey. */ - public static class HashKeySelector implements ChildSelector + public static class HashKeySelector implements ChildSelector { = - static ChildSelector DEFAULT =3D new HashKeySelector(16); + static ChildSelector DEFAULT =3D new HashKeySelector(128); = protected int segments; = /** * Constructs with N segments, where N must be a power of 2. + * + * @param segments Number of hash segments */ public HashKeySelector(int segments) { @@ -203,42 +223,34 @@ } = /** - * Computes an improved hash code from an object's hash code. - */ - protected int hashCode(int i) - { - i ^=3D i >>> 20 ^ i >>> 12; - return i ^ i >>> 7 ^ i >>> 4; - } - - /** * Returns the segment for this key, in the inclusive range 0 to {@l= ink #segments} - 1. */ - protected int segmentFor(Object key) + protected final int segmentFor(T key) { if (key =3D=3D null) return 0; int hc =3D key.hashCode(); - return hashCode(hc) & (segments - 1); + return Caches.hashCode(hc) & (segments - 1); } = /** * Returns the node name for this segment. */ - protected Object childName(int segment) + protected final Fqn childName(int segment) { - return "" + segment;//IntegerCache.toString(segment); + return Fqn.fromElements(Integer.toString(segment)); } = /** * Returns the node name for this key. * By default, returns a String containing the segment. */ - public Object childName(Object key) + public final Fqn childName(T key) { return childName(segmentFor(key)); } = + @Override public String toString() { return super.toString() + " segments=3D" + segments; @@ -246,14 +258,14 @@ = } = - static class MapNode extends AbstractMap + static class MapNode extends AbstractMap { = public static final String KEY =3D "K"; = - private Node node; + private Node node; // purposefully un-genericized = - public MapNode(Node node) + public MapNode(Node node) { if (node =3D=3D null) throw new NullPointerException("node"); @@ -261,16 +273,16 @@ } = @Override - public Set entrySet() + public Set> entrySet() { - return new AbstractSet() + return new AbstractSet>() { = @Override - public Iterator iterator() + public Iterator> iterator() { - final Iterator i =3D set().iterator(); - return new Iterator() + final Iterator> i =3D set().iterator(); + return new Iterator>() { = Object name; @@ -282,13 +294,14 @@ return i.hasNext(); } = - public Object next() + @SuppressWarnings("unchecked") + public Entry next() { Node n =3D i.next(); this.name =3D n.getFqn().getLastElement(); this.next =3D true; Object key =3D n.get(KEY); - return new SimpleEntry(name, key); + return new SimpleImmutableEntry(name, key); } = public void remove() @@ -298,6 +311,7 @@ node.removeChild(name); } = + @Override public String toString() { return "Itr name=3D" + name; @@ -306,7 +320,8 @@ }; } = - private Set set() + @SuppressWarnings("unchecked") + private Set> set() { return node.getChildren(); } @@ -334,12 +349,13 @@ } = @Override - public Object get(Object arg0) + @SuppressWarnings("unchecked") + public V get(Object arg0) { Node child =3D node.getChild(arg0); if (child =3D=3D null) return null; - return child.get(KEY); + return (V) child.get(KEY); } = @Override @@ -349,10 +365,10 @@ } = @Override - public Set keySet() + public Set keySet() { = - return new AbstractSet() + return new AbstractSet() { = private Set set() @@ -361,22 +377,23 @@ } = @Override - public Iterator iterator() + public Iterator iterator() { final Iterator i =3D set().iterator(); - return new Iterator() + return new Iterator() { = - Object child; + K child; = public boolean hasNext() { return i.hasNext(); } = - public Object next() + @SuppressWarnings("unchecked") + public K next() { - child =3D i.next(); + child =3D (K) i.next(); return child; } = @@ -408,18 +425,20 @@ } = @Override - public Object put(Object arg0, Object arg1) + @SuppressWarnings("unchecked") + public V put(K arg0, V arg1) { - return node.addChild(Fqn.fromElements(arg0)).put(KEY, arg1); + return (V) node.addChild(Fqn.fromElements(arg0)).put(KEY, arg1); } = @Override - public Object remove(Object arg0) + @SuppressWarnings("unchecked") + public V remove(Object arg0) { Node child =3D node.getChild(arg0); if (child =3D=3D null) return null; - Object o =3D child.remove(KEY); + V o =3D (V) child.remove(KEY); node.removeChild(arg0); return o; } @@ -432,12 +451,12 @@ = } = - static class SimpleMapNode extends AbstractMap implements java.util.Map + static class SimpleMapNode extends AbstractMap { = - private Node node; + private Node node; = - public SimpleMapNode(Node node) + public SimpleMapNode(Node node) { if (node =3D=3D null) throw new NullPointerException("node"); @@ -465,39 +484,43 @@ /** * getData returns a snapshot of the data. */ - public Set entrySet() + @Override + public Set> entrySet() { return node.getData().entrySet(); } = @Override - public Object get(Object key) + @SuppressWarnings("unchecked") + public V get(Object key) { - return node.get(key); + return node.get((K) key); } = @Override - public Set keySet() + public Set keySet() { return node.getKeys(); } = @Override - public Object put(Object key, Object value) + public V put(K key, V value) { return node.put(key, value); } = @Override - public void putAll(Map map) + @SuppressWarnings("unchecked") + public void putAll(Map map) { - node.putAll(map); + node.putAll((Map) map); } = @Override - public Object remove(Object key) + @SuppressWarnings("unchecked") + public V remove(Object key) { - return node.remove(key); + return node.remove((K) key); } = @Override @@ -508,14 +531,14 @@ = } = - static class SimpleSetNode extends AbstractSet implements java.util.Set + static class SimpleSetNode extends AbstractSet implements java.ut= il.Set { = private Node node; = private static final String VALUE =3D "V"; = - public SimpleSetNode(Node node) + public SimpleSetNode(Node node) { if (node =3D=3D null) throw new NullPointerException("node"); @@ -535,6 +558,7 @@ } = @Override + @SuppressWarnings("unchecked") public boolean remove(Object key) { return node.remove(key) !=3D null; @@ -547,18 +571,19 @@ } = @Override - public boolean add(Object arg0) + @SuppressWarnings("unchecked") + public boolean add(K arg0) { return node.put(arg0, VALUE) =3D=3D null; } = @Override - public Iterator iterator() + public Iterator iterator() { final Iterator i =3D node.getKeys().iterator(); - return new Iterator() + return new Iterator() { - Object key; + K key; = boolean next =3D false; = @@ -567,13 +592,15 @@ return i.hasNext(); } = - public Object next() + @SuppressWarnings("unchecked") + public K next() { - key =3D i.next(); + key =3D (K) i.next(); next =3D true; return key; } = + @SuppressWarnings("unchecked") public void remove() { if (!next) @@ -586,31 +613,31 @@ = } = - static class PartitionedMapNode extends AbstractMap + static class PartitionedMapNode extends AbstractMap { = - private Node node; + private NodeSPI node; = - private ChildSelector selector; + private ChildSelector selector; = - public PartitionedMapNode(Node node, ChildSelector selector) + public PartitionedMapNode(Node node, ChildSelector selector) { - this.node =3D node; + this.node =3D (NodeSPI) node; this.selector =3D selector; } = @Override - public Set entrySet() + public Set> entrySet() { - return new AbstractSet() + return new AbstractSet>() { = Iterator ci =3D node.getChildren().iterator(); = @Override - public Iterator iterator() + public Iterator> iterator() { - return new Iterator() + return new Iterator>() { = Iterator ni; @@ -620,6 +647,7 @@ findNext(); } = + @SuppressWarnings("unchecked") private void nextChild() { ni =3D new SimpleMapNode(ci.next()).entrySet().iterat= or(); @@ -640,9 +668,10 @@ return ni.hasNext(); } = - public Entry next() + @SuppressWarnings("unchecked") + public Entry next() { - Entry n =3D (Entry) ni.next(); + Entry n =3D (Entry) ni.next(); findNext(); return n; } @@ -665,15 +694,17 @@ } = @Override + @SuppressWarnings("unchecked") public Set keySet() { - return new AbstractSet() + return new AbstractSet>() { = @Override - public Iterator iterator() + @SuppressWarnings("unchecked") + public Iterator> iterator() { - return PartitionedMapNode.super.keySet().iterator(); + return (Iterator>) PartitionedMapNode.super.key= Set().iterator(); } = @Override @@ -706,40 +737,38 @@ node.getChild(o).clearData(); } = - private Node nodeFor(Object o) + @SuppressWarnings("unchecked") + private Fqn fqnFor(Object o) { - return node.getChild(selector.childName(o)); + return Fqn.fromRelativeFqn(node.getFqn(), selector.childName((K) = o)); } = @Override + @SuppressWarnings("unchecked") public boolean containsKey(Object o) { - Node n =3D nodeFor(o); - if (n =3D=3D null) return false; - return n.getKeys().contains(o); + Fqn fqn =3D fqnFor(o); + Set keys =3D node.getCache().getKeys(fqn); + return keys !=3D null && keys.contains(o); } = @Override - public Object get(Object o) + @SuppressWarnings("unchecked") + public V get(Object key) { - Node n =3D nodeFor(o); - if (n =3D=3D null) return null; - return n.get(o); + return (V) node.getCache().get(fqnFor(key), key); } = + @SuppressWarnings("unchecked") public Object put(Object key, Object value) { - Object name =3D selector.childName(key); - Node n =3D node.getChild(name); - if (n =3D=3D null) - n =3D node.addChild(Fqn.fromElements(name)); - return n.put(key, value); + return node.getCache().put(fqnFor(key), key, value); } = - public Object remove(Object o) + @SuppressWarnings("unchecked") + public V remove(Object key) { - Node n =3D nodeFor(o); - return n.remove(o); + return (V) node.getCache().remove(fqnFor(key), key); } = public int size() @@ -752,65 +781,5 @@ } return size; } - } - - public static class SimpleEntry implements Entry - { - K key; - V value; - - public SimpleEntry(K key, V value) - { - this.key =3D key; - this.value =3D value; - } - - public SimpleEntry(Entry e) - { - this.key =3D e.getKey(); - this.value =3D e.getValue(); - } - - public K getKey() - { - return key; - } - - public V getValue() - { - return value; - } - - public V setValue(V value) - { - V oldValue =3D this.value; - this.value =3D value; - return oldValue; - } - - public boolean equals(Object o) - { - if (!(o instanceof Map.Entry)) - return false; - Map.Entry e =3D (Map.Entry) o; - return eq(key, e.getKey()) && eq(value, e.getValue()); - } - - public int hashCode() - { - return ((key =3D=3D null) ? 0 : key.hashCode()) ^ - ((value =3D=3D null) ? 0 : value.hashCode()); - } - - public String toString() - { - return key + "=3D" + value; - } - - private static boolean eq(Object o1, Object o2) - { - return (o1 =3D=3D null ? o2 =3D=3D null : o1.equals(o2)); - } - } } Modified: core/trunk/src/test/java/org/jboss/cache/util/CachesTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/util/CachesTest.java 2008-08-0= 4 20:26:13 UTC (rev 6503) +++ core/trunk/src/test/java/org/jboss/cache/util/CachesTest.java 2008-08-0= 5 10:23:56 UTC (rev 6504) @@ -1,12 +1,14 @@ package org.jboss.cache.util; = +import junit.framework.TestCase; import org.jboss.cache.Cache; +import org.jboss.cache.DataContainer; +import org.jboss.cache.DataContainerImpl; import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.Fqn; import org.jboss.cache.Node; +import org.jboss.cache.invocation.CacheInvocationDelegate; import org.jboss.cache.util.Caches.ChildSelector; -import org.jboss.cache.util.Caches.SimpleEntry; -import static org.testng.AssertJUnit.*; -import org.testng.annotations.Test; = import java.util.Collection; import java.util.Iterator; @@ -16,8 +18,7 @@ /** * Tests {@link Caches}. */ -(a)Test(groups =3D "functional") -public class CachesTest +public class CachesTest extends TestCase { String a =3D "a"; = @@ -25,11 +26,11 @@ = String c =3D "c"; = - Cache cache =3D new DefaultCacheFactory= ().createCache(); + Cache cache =3D new DefaultCacheFactory().createCache(); = public void testSegment() { - Map m =3D Caches.asPartitionedMap(cache); + Map m =3D Caches.asPartitionedMap(cache); // m.put(a, b); testMap(m); m.clear(); @@ -42,14 +43,13 @@ { assertEquals("foo " + i, m.get(Integer.toHexString(i))); } - System.out.println(CachePrinter.printCacheDetails(cache)); } = public void testAsMap() { - Map m =3D Caches.asMap(cache); + Map m =3D Caches.asMap(cache); testMap(m); - for (Node n : cache.getRoot().getChildren()) + for (Node n : (Set) cache.getRoot().getChildren()) { assertEquals("/a", n.getFqn().toString()); assertEquals(c, n.get("K")); @@ -141,10 +141,10 @@ assertEquals(false, i.hasNext()); = assertEquals(true, m.keySet().contains(c)); - assertEquals(true, m.entrySet().contains(new SimpleEntry(c, a))); + assertEquals(true, m.entrySet().contains(new SimpleImmutableEntry(c,= a))); assertEquals(true, m.values().contains(a)); assertEquals(false, m.keySet().contains(a)); - assertEquals(false, m.entrySet().contains(new SimpleEntry(a, c))); + assertEquals(false, m.entrySet().contains(new SimpleImmutableEntry(a= , c))); assertEquals(false, m.values().contains(c)); assertEquals(false, m.isEmpty()); m.clear(); @@ -173,9 +173,15 @@ m.put(h, 21); assertEquals(42, m.get(f)); assertEquals(69, m.get(g)); - System.out.println(CachePrinter.printCacheDetails(cache)); + System.out.println(printDetails(cache)); } = + private String printDetails(Cache c) + { + DataContainer dc =3D ((CacheInvocationDelegate) c).getDataContainer(= ); + return ((DataContainerImpl) dc).printDetails(); + } + public static class Person { String name; @@ -203,9 +209,9 @@ public static class DepartmentSelector implements ChildSelector { = - public Object childName(Person key) + public Fqn childName(Person key) { - return key.getDepartment(); + return Fqn.fromElements(key.getDepartment()); } = } --===============5192921695485565165==-- From jbosscache-commits at lists.jboss.org Tue Aug 5 06:27:36 2008 Content-Type: multipart/mixed; boundary="===============5761545434729007052==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6505 - benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/src/org/cachebench/cachewrappers. Date: Tue, 05 Aug 2008 06:27:36 -0400 Message-ID: --===============5761545434729007052== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-05 06:27:36 -0400 (Tue, 05 Aug 2008) New Revision: 6505 Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/src/org/c= achebench/cachewrappers/JBossCache300Wrapper.java Log: More efficient flat map Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/sr= c/org/cachebench/cachewrappers/JBossCache300Wrapper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/src/org/= cachebench/cachewrappers/JBossCache300Wrapper.java 2008-08-05 10:23:56 UTC = (rev 6504) +++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/src/org/= cachebench/cachewrappers/JBossCache300Wrapper.java 2008-08-05 10:27:36 UTC = (rev 6505) @@ -8,7 +8,6 @@ import org.jboss.cache.Fqn; import org.jboss.cache.config.Option; import org.jboss.cache.util.Caches; -import org.jboss.cache.util.Caches.HashKeySelector; = import java.util.List; import java.util.Map; @@ -38,7 +37,7 @@ if (FLAT) { log.info("Using FLAT MAP wrapper"); - flatCache =3D Caches.asPartitionedMap(cache.getRoot(), new HashKe= ySelector(128)); + flatCache =3D Caches.asMap(cache); } } = --===============5761545434729007052==-- From jbosscache-commits at lists.jboss.org Tue Aug 5 06:31:25 2008 Content-Type: multipart/mixed; boundary="===============3395598444367836607==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6506 - in benchmarks/benchmark-fwk/trunk/cache-products: jbosscache-3.0.0 and 1 other directory. Date: Tue, 05 Aug 2008 06:31:21 -0400 Message-ID: --===============3395598444367836607== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-05 06:31:21 -0400 (Tue, 05 Aug 2008) New Revision: 6506 Modified: benchmarks/benchmark-fwk/trunk/cache-products/coherence-3.3.1/config.sh benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/config.sh Log: Dont set XMX params herevi cache-products/coherence-3.3.1/config.sh = Modified: benchmarks/benchmark-fwk/trunk/cache-products/coherence-3.3.1/con= fig.sh =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- benchmarks/benchmark-fwk/trunk/cache-products/coherence-3.3.1/config.sh= 2008-08-05 10:27:36 UTC (rev 6505) +++ benchmarks/benchmark-fwk/trunk/cache-products/coherence-3.3.1/config.sh= 2008-08-05 10:31:21 UTC (rev 6506) @@ -15,6 +15,6 @@ #--classpath was set = #additional JVM options -export JVM_OPTIONS=3D"$JVM_OPTIONS -Xmx2048m -Djava.net.preferIPv4Stack=3D= true -Dtangosol.coherence.localhost=3D${MYTESTIP_1}" +export JVM_OPTIONS=3D"$JVM_OPTIONS -Djava.net.preferIPv4Stack=3Dtrue -Dtan= gosol.coherence.localhost=3D${MYTESTIP_1}" export JVM_OPTIONS=3D"$JVM_OPTIONS -Dtangosol.coherence.cacheconfig=3Dcach= e-config.xml" export JVM_OPTIONS=3D"$JVM_OPTIONS -DcacheBenchFwk.cacheWrapperClassName= =3Dorg.cachebench.cachewrappers.Coherence331Wrapper" Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/co= nfig.sh =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/config.s= h 2008-08-05 10:27:36 UTC (rev 6505) +++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/config.s= h 2008-08-05 10:31:21 UTC (rev 6506) @@ -15,5 +15,5 @@ #--classpath was set = #additional JVM options -JVM_OPTIONS=3D"$JVM_OPTIONS -Djava.net.preferIPv4Stack=3Dtrue -Djbosscache= .config.validate=3Dfalse -Xmx2048m" +JVM_OPTIONS=3D"$JVM_OPTIONS -Djava.net.preferIPv4Stack=3Dtrue -Djbosscache= .config.validate=3Dfalse" JVM_OPTIONS=3D"$JVM_OPTIONS -DcacheBenchFwk.cacheWrapperClassName=3Dorg.ca= chebench.cachewrappers.JBossCache300Wrapper" --===============3395598444367836607==-- From jbosscache-commits at lists.jboss.org Tue Aug 5 06:37:31 2008 Content-Type: multipart/mixed; boundary="===============4348551059474029987==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6507 - in searchable/trunk: src/main/java/org/jboss/cache/search and 1 other directories. Date: Tue, 05 Aug 2008 06:37:26 -0400 Message-ID: --===============4348551059474029987== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: navssurtani Date: 2008-08-05 06:37:26 -0400 (Tue, 05 Aug 2008) New Revision: 6507 Added: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheCon= figuration.java Removed: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheCfg= Impl.java Modified: searchable/trunk/pom.xml searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFac= tory.java searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoList= ener.java searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCach= eTest.java Log: Old changes and changed core dep to CR7 Modified: searchable/trunk/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/pom.xml 2008-08-05 10:31:21 UTC (rev 6506) +++ searchable/trunk/pom.xml 2008-08-05 10:37:26 UTC (rev 6507) @@ -4,7 +4,7 @@ xsi:schemaLocation=3D"http://maven.apache.org/POM/4.0.0 http://ma= ven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - 0.1-SNAPSHOT + 0.1-Beta1 unit + + + + + + + + + + + + + + + + + jboss:service=3DNaming + jboss:service=3DTransactionManager + + + org.jboss.cache.tr= ansaction.GenericTransactionManagerLookup + + + + + READ_COMMITTED + + + LOCAL + + + JBossCache-Cluster + + 20000 + + + 15000 + + + 10000 + + Added: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/= pess-local-RR.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pes= s-local-RR.xml (rev 0) +++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pes= s-local-RR.xml 2008-08-05 15:49:20 UTC (rev 6518) @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + jboss:service=3DNaming + jboss:service=3DTransactionManager + + + org.jboss.cache.tr= ansaction.GenericTransactionManagerLookup + + + + + REPEATABLE_READ + + + LOCAL + + + JBossCache-Cluster + + 20000 + + + 15000 + + + 10000 + + --===============6840105320962707523==-- From jbosscache-commits at lists.jboss.org Tue Aug 5 11:49:55 2008 Content-Type: multipart/mixed; boundary="===============8379039650314564900==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6519 - benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/conf. Date: Tue, 05 Aug 2008 11:49:55 -0400 Message-ID: --===============8379039650314564900== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-05 11:49:55 -0400 (Tue, 05 Aug 2008) New Revision: 6519 Added: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/conf/pess= -local-RC.xml benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/conf/pess= -local-RR.xml Log: Added RR and RC Added: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/conf/= pess-local-RC.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/conf/pes= s-local-RC.xml (rev 0) +++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/conf/pes= s-local-RC.xml 2008-08-05 15:49:55 UTC (rev 6519) @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + jboss:service=3DNaming + jboss:service=3DTransactionManager + + + org.jboss.cache.tr= ansaction.GenericTransactionManagerLookup + + + + + READ_COMMITTED + + + LOCAL + + + JBossCache-Cluster + + 20000 + + + 15000 + + + 10000 + + Added: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/conf/= pess-local-RR.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/conf/pes= s-local-RR.xml (rev 0) +++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/conf/pes= s-local-RR.xml 2008-08-05 15:49:55 UTC (rev 6519) @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + jboss:service=3DNaming + jboss:service=3DTransactionManager + + + org.jboss.cache.tr= ansaction.GenericTransactionManagerLookup + + + + + REPEATABLE_READ + + + LOCAL + + + JBossCache-Cluster + + 20000 + + + 15000 + + + 10000 + + --===============8379039650314564900==-- From jbosscache-commits at lists.jboss.org Tue Aug 5 12:32:59 2008 Content-Type: multipart/mixed; boundary="===============0953960902574789758==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6520 - benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/lib. Date: Tue, 05 Aug 2008 12:32:58 -0400 Message-ID: --===============0953960902574789758== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-05 12:32:58 -0400 (Tue, 05 Aug 2008) New Revision: 6520 Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/lib/jboss= cache-core.jar Log: updated jbc distro Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/li= b/jbosscache-core.jar =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) --===============0953960902574789758==-- From jboss-qa-internal at redhat.com Tue Aug 5 12:36:19 2008 Content-Type: multipart/mixed; boundary="===============6598049703795413506==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23538?= Date: Tue, 05 Aug 2008 12:36:12 -0400 Message-ID: <172593533.14291217954172555.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1982702611.13931217945602729.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============6598049703795413506== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/538/changes --===============6598049703795413506==-- From jboss-qa-internal at redhat.com Tue Aug 5 13:38:13 2008 Content-Type: multipart/mixed; boundary="===============6469003614522980093==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23405?= Date: Tue, 05 Aug 2008 13:38:10 -0400 Message-ID: <2131242718.14741217957890673.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 277940613.13961217946686894.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============6469003614522980093== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/405/changes --===============6469003614522980093==-- From jbosscache-commits at lists.jboss.org Tue Aug 5 18:59:48 2008 Content-Type: multipart/mixed; boundary="===============8272428057402331309==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6521 - benchmarks/benchmark-fwk/trunk. Date: Tue, 05 Aug 2008 18:59:47 -0400 Message-ID: --===============8272428057402331309== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-05 18:59:47 -0400 (Tue, 05 Aug 2008) New Revision: 6521 Modified: benchmarks/benchmark-fwk/trunk/runAllLocal.sh Log: Modified: benchmarks/benchmark-fwk/trunk/runAllLocal.sh =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- benchmarks/benchmark-fwk/trunk/runAllLocal.sh 2008-08-05 16:32:58 UTC (= rev 6520) +++ benchmarks/benchmark-fwk/trunk/runAllLocal.sh 2008-08-05 22:59:47 UTC (= rev 6521) @@ -5,17 +5,16 @@ jdk=3Djava5 rm -rf ./output/* export PLAIN_JVM_OPTIONS=3D"${JVM_OPTIONS} -DcacheBenchFwk.fwkCfgFile=3Dca= chebench-local.xml -Xms2g -Xmx2g" -unset JVM_OPTIONS && export JVM_OPTIONS=3D${PLAIN_JVM_OPTIONS} -./runLocalNode.sh jbosscache-2.2.0 pess-local.xml +unset JVM_OPTIONS && export JVM_OPTIONS=3D"${PLAIN_JVM_OPTIONS} -DcacheBen= chFwk.productSuffix=3D.CR7" +./runLocalNode.sh jbosscache-2.2.0 pess-local-RR.xml +./runLocalNode.sh jbosscache-2.2.0 pess-local-RC.xml +unset JVM_OPTIONS && export JVM_OPTIONS=3D"${PLAIN_JVM_OPTIONS} -DcacheBen= chFwk.productSuffix=3D.ALPHA2" ./runLocalNode.sh jbosscache-3.0.0 mvcc-local-RR.xml ./runLocalNode.sh jbosscache-3.0.0 mvcc-local-RC.xml -unset JVM_OPTIONS && export JVM_OPTIONS=3D"${PLAIN_JVM_OPTIONS} -cacheBenc= hFwk.useFlatCache=3Dtrue -cacheBenchFwk.productSuffix=3DFlatCache" -./runLocalNode.sh jbosscache-3.0.0 mvcc-local-RR.xml -./runLocalNode.sh jbosscache-3.0.0 mvcc-local-RC.xml unset JVM_OPTIONS && export JVM_OPTIONS=3D${PLAIN_JVM_OPTIONS} -./runLocalNode.sh jbosscache-2.2.0 pess-local-NONE.xml +./runLocalNode.sh jbosscache-2.1.0 pess-local-RR.xml +./runLocalNode.sh jbosscache-2.1.0 pess-local-RC.xml ./runLocalNode.sh ehcache-1.5.0 ehcache-local.xml -./runLocalNode.sh coherence-3.3.1 local-default.xml = mkdir output mv data* ./output --===============8272428057402331309==-- From jbosscache-commits at lists.jboss.org Tue Aug 5 19:01:19 2008 Content-Type: multipart/mixed; boundary="===============3573813007992586086==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6522 - benchmarks/benchmark-fwk/trunk. Date: Tue, 05 Aug 2008 19:01:18 -0400 Message-ID: --===============3573813007992586086== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-05 19:01:18 -0400 (Tue, 05 Aug 2008) New Revision: 6522 Modified: benchmarks/benchmark-fwk/trunk/build.xml Log: Modified: benchmarks/benchmark-fwk/trunk/build.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- benchmarks/benchmark-fwk/trunk/build.xml 2008-08-05 22:59:47 UTC (rev 6= 521) +++ benchmarks/benchmark-fwk/trunk/build.xml 2008-08-05 23:01:18 UTC (rev 6= 522) @@ -102,7 +102,7 @@ = + description=3D"Compile module coherence331; production classes"= if=3D"coherence.jars.present"> --===============3573813007992586086==-- From jbosscache-commits at lists.jboss.org Tue Aug 5 20:56:02 2008 Content-Type: multipart/mixed; boundary="===============5869173937119158879==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6523 - core/trunk/src/main/java/org/jboss/cache/interceptors. Date: Tue, 05 Aug 2008 20:56:02 -0400 Message-ID: --===============5869173937119158879== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-05 20:56:02 -0400 (Tue, 05 Aug 2008) New Revision: 6523 Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java Log: Null chk Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxIntercept= or.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.jav= a 2008-08-05 23:01:18 UTC (rev 6522) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.jav= a 2008-08-06 00:56:02 UTC (rev 6523) @@ -1114,7 +1114,7 @@ if (ctx =3D=3D null) ctx =3D invocationContextContainer.get(); ctx.setLocalRollbackOnly(localRollbackOnly); setTransactionalContext(tx, gtx, transactionContext, ctx); - ctx.setOptionOverrides(transactionalOptions); + if (transactionalOptions !=3D null) ctx.setOptionOverrides(transa= ctionalOptions); try { super.afterCompletion(status); --===============5869173937119158879==-- From jbosscache-commits at lists.jboss.org Tue Aug 5 20:57:16 2008 Content-Type: multipart/mixed; boundary="===============6407481266588456054==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6524 - in core/trunk/src: main/java/org/jboss/cache/interceptors and 4 other directories. Date: Tue, 05 Aug 2008 20:57:16 -0400 Message-ID: --===============6407481266588456054== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-05 20:57:16 -0400 (Tue, 05 Aug 2008) New Revision: 6524 Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/PersistingTransientSta= teTest.java core/trunk/src/test/java/org/jboss/cache/optimistic/PersistingTransientS= tateTest.java core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransie= ntStateTest.java Modified: core/trunk/src/main/java/org/jboss/cache/config/Option.java core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreIntercep= tor.java core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTrans= ferIntegrator.java core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransf= erIntegrator.java core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransf= erManager.java Log: JBCACHE-131 - persist transient state during state transfer under certain c= onditions Modified: core/trunk/src/main/java/org/jboss/cache/config/Option.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/Option.java 2008-08-06 = 00:56:02 UTC (rev 6523) +++ core/trunk/src/main/java/org/jboss/cache/config/Option.java 2008-08-06 = 00:57:16 UTC (rev 6524) @@ -33,6 +33,7 @@ private int groupRequestMode =3D -1; = private int lockAcquisitionTimeout =3D -1; + private boolean suppressPersistence; = /** * @since 1.4.0 @@ -303,6 +304,7 @@ if (forceAsynchronous !=3D option.forceAsynchronous) return false; if (forceSynchronous !=3D option.forceSynchronous) return false; if (lockAcquisitionTimeout !=3D option.lockAcquisitionTimeout) retur= n false; + if (suppressPersistence !=3D option.suppressPersistence) return fals= e; return true; } = @@ -320,6 +322,7 @@ result =3D 29 * result + (forceAsynchronous ? 0 : 1); result =3D 29 * result + (forceSynchronous ? 0 : 1); result =3D 29 * result + (lockAcquisitionTimeout); + result =3D 29 * result + (suppressPersistence ? 0 : 1); return result; } = @@ -338,6 +341,7 @@ this.forceAsynchronous =3D false; this.forceSynchronous =3D false; this.lockAcquisitionTimeout =3D -1; + this.suppressPersistence =3D false; } = /** @@ -426,4 +430,26 @@ { this.groupRequestMode =3D groupRequestMode; } + + /** + * If set to true, any persistence to a cache loader will be suppressed= for the current invocation only. Does not apply to transactional calls. + * + * @return true if persistence is suppressed. + * @since 3.0 + */ + public boolean isSuppressPersistence() + { + return suppressPersistence; + } + + /** + * If set to true, any persistence to a cache loader will be suppressed= for the current invocation only. Does not apply to transactional calls. + * + * @param suppressPersistence if true, will suppress persistence. + * @since 3.0 + */ + public void setSuppressPersistence(boolean suppressPersistence) + { + this.suppressPersistence =3D suppressPersistence; + } } Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreI= nterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterce= ptor.java 2008-08-06 00:56:02 UTC (rev 6523) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterce= ptor.java 2008-08-06 00:57:16 UTC (rev 6524) @@ -86,7 +86,7 @@ @Override public boolean skipInterception(InvocationContext ctx, VisitableCommand= command) { - if (!ctx.isOriginLocal() && loaderConfig.isShared()) + if ((!ctx.isOriginLocal() && loaderConfig.isShared()) || ctx.getOpti= onOverrides().isSuppressPersistence()) { if (trace) log.trace("Passing up method call and bypassing this intercept= or since the cache loader is shared and this call originated remotely."); Modified: core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultSta= teTransferIntegrator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTran= sferIntegrator.java 2008-08-06 00:56:02 UTC (rev 6523) +++ core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTran= sferIntegrator.java 2008-08-06 00:57:16 UTC (rev 6524) @@ -12,11 +12,10 @@ import org.jboss.cache.CacheSPI; import org.jboss.cache.Fqn; import org.jboss.cache.InternalNode; -import org.jboss.cache.NodeFactory; -import org.jboss.cache.Region; +import org.jboss.cache.Node; +import org.jboss.cache.NodeSPI; import org.jboss.cache.buddyreplication.BuddyManager; -import org.jboss.cache.eviction.EvictedEventNode; -import org.jboss.cache.eviction.NodeEventType; +import org.jboss.cache.config.Configuration; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; import org.jboss.cache.invocation.InvocationContext; @@ -42,24 +41,25 @@ private static final Log log =3D LogFactory.getLog(DefaultStateTransfer= Integrator.class); private static final boolean trace =3D log.isTraceEnabled(); = - private CacheSPI cache; + private CacheSPI cache; = - private NodeFactory factory; - private Set internalFqns; + private Configuration cfg; + private boolean needToPersistState; // for JBCACHE-131 = - @Inject - public void inject(CacheSPI cache, NodeFactory nodefactory) + public void inject(CacheSPI cache, Configuration cfg) { this.cache =3D cache; - this.factory =3D nodefactory; + this.cfg =3D cfg; } = @Start(priority =3D 14) public void start() { this.internalFqns =3D cache.getInternalFqns(); + needToPersistState =3D cfg.getCacheLoaderConfig() !=3D null && !cfg.= getCacheLoaderConfig().isFetchPersistentState() && + !cfg.getCacheLoaderConfig().isShared(); } = public void integrateState(ObjectInputStream ois, Object target, Fqn ta= rgetRoot, boolean integratePersistentState) throws Exception @@ -86,7 +86,7 @@ log.trace("integrating transient state for " + target); } = - integrateTransientState(target, in); + integrateTransientState(target.getFqn(), in); = transientSet =3D true; = @@ -189,10 +189,23 @@ for (InternalNode n : children) notifyAllNodesCreated(ctx, n); } = - private void integrateTransientState(InternalNode target, ObjectInputSt= ream in) throws Exception + private void prepareContextOptions() { - target.removeChildren(); + cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(= true); + cache.getInvocationContext().getOptionOverrides().setSkipCacheStatus= Check(true); + cache.getInvocationContext().getOptionOverrides().setSuppressPersist= ence(!needToPersistState); + } = + private void integrateTransientState(Fqn target, ObjectInputStream in) = throws Exception + { + prepareContextOptions(); + NodeSPI targetNode =3D cache.getNode(target); + for (Object childname : targetNode.getChildrenNames()) + { + prepareContextOptions(); + targetNode.removeChild(childname); + } + List list =3D readNodesAsList(in); if (list !=3D null) { @@ -207,18 +220,20 @@ //are there any transient nodes at all? if (nd !=3D null && !nd.isMarker()) { - Map attributes =3D nd.getAttributes(); + // with MVCC these calls should ALWAYS go up the intercepto= r chain since no other locking + // takes place elsewhere. + prepareContextOptions(); + cache.clearData(target); + prepareContextOptions(); + cache.put(target, nd.getAttributes()); = - target.setInternalState(attributes); - // Check whether this is an integration into the buddy back= up // subtree Fqn tferFqn =3D nd.getFqn(); - Fqn tgtFqn =3D target.getFqn(); - boolean move =3D tgtFqn.isChildOrEquals(BuddyManager.BUDDY_= BACKUP_SUBTREE_FQN) - && !tferFqn.isChildOrEquals(tgtFqn); + boolean move =3D target.isChildOrEquals(BuddyManager.BUDDY_= BACKUP_SUBTREE_FQN) + && !tferFqn.isChildOrEquals(target); // If it is an integration, calculate how many levels of of= fset - int offset =3D move ? tgtFqn.size() - tferFqn.size() : 0; + int offset =3D move ? target.size() - tferFqn.size() : 0; = integrateStateTransferChildren(target, offset, nodeDataIter= ator); = @@ -240,11 +255,11 @@ return (List) obj; } = - private NodeData integrateStateTransferChildren(InternalNode parent, in= t offset, Iterator nodeDataIterator) + private NodeData integrateStateTransferChildren(Fqn parentFqn, int offs= et, Iterator nodeDataIterator) throws IOException, ClassNotFoundException { - int parent_level =3D parent.getFqn().size(); - int target_level =3D parent_level + 1; + int parentLevel =3D parentFqn.size(); + int targetLevel =3D parentLevel + 1; Fqn fqn; int size; NodeData nd =3D nodeDataIterator.hasNext() ? nodeDataIterator.next()= : null; @@ -255,35 +270,28 @@ // change the Fqn to fit under it if (offset > 0) { - fqn =3D Fqn.fromRelativeFqn(parent.getFqn().getAncestor(offset= ), fqn); + fqn =3D Fqn.fromRelativeFqn(parentFqn.getAncestor(offset), fqn= ); } size =3D fqn.size(); - if (size <=3D parent_level) + if (size <=3D parentLevel) { return nd; } - else if (size > target_level) + else if (size > targetLevel) { - throw new IllegalStateException("NodeData " + fqn + " is not a= direct child of " + parent.getFqn()); + throw new IllegalStateException("NodeData " + fqn + " is not a= direct child of " + parentFqn); } = Map attrs =3D nd.getAttributes(); = - InternalNode internalTarget =3D factory.createInternalNode(fqn); - internalTarget.setInternalState(attrs); - parent.addChild(internalTarget); + prepareContextOptions(); + cache.clearData(fqn); + prepareContextOptions(); + cache.put(fqn, attrs); = - // JBCACHE-913 - Region region =3D cache.getRegion(fqn, false); - if (region !=3D null && region.getEvictionPolicy() !=3D null) - { - region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.AD= D_NODE_EVENT, - attrs =3D=3D null ? 0 : attrs.size())); - } - // Recursively call, which will walk down the tree // and return the next NodeData that's a child of our parent - nd =3D integrateStateTransferChildren(internalTarget, offset, nod= eDataIterator); + nd =3D integrateStateTransferChildren(fqn, offset, nodeDataIterat= or); } if (nd !=3D null && nd.isExceptionMarker()) { @@ -294,18 +302,18 @@ return null; } = - private Set retainInternalNodes(InternalNode target) + private Set retainInternalNodes(Fqn target) { - Set result =3D new HashSet(); - Fqn targetFqn =3D target.getFqn(); + Set result =3D new HashSet(); for (Fqn internalFqn : internalFqns) { - if (internalFqn.isChildOf(targetFqn)) + if (internalFqn.isChildOf(target)) { - InternalNode internalNode =3D getInternalNode(target, internal= Fqn); - if (internalNode !=3D null) + prepareContextOptions(); + Node node =3D getInternalNode(cache.getNode(target), internalF= qn); + if (node !=3D null) { - result.add(internalNode); + result.add(node.getFqn()); } } } @@ -313,10 +321,12 @@ return result; } = - private InternalNode getInternalNode(InternalNode parent, Fqn internalF= qn) + private Node getInternalNode(Node parentNode, Fqn internalFqn) { - Object name =3D internalFqn.get(parent.getFqn().size()); - InternalNode result =3D parent.getChild(name); + Fqn parentFqn =3D parentNode.getFqn(); + Object name =3D internalFqn.get(parentFqn.size()); + prepareContextOptions(); + Node result =3D parentNode.getChild(name); if (result !=3D null) { if (internalFqn.size() < result.getFqn().size()) @@ -328,29 +338,33 @@ return result; } = - private void integrateRetainedNodes(InternalNode target) + private void integrateRetainedNodes(Fqn target) { - Set retainedNodes =3D retainInternalNodes(target); - Fqn rootFqn =3D target.getFqn(); - for (InternalNode retained : retainedNodes) + Set retainedNodes =3D retainInternalNodes(target); + for (Fqn retained : retainedNodes) { - if (retained.getFqn().isChildOf(rootFqn)) + if (retained.isChildOf(target)) { integrateRetainedNode(target, retained); } } } = - private void integrateRetainedNode(InternalNode ancestor, InternalNode = descendant) + + // TODO: What is this rubbish?!?? + private void integrateRetainedNode(Fqn ancFqn, Fqn descFqn) { - Fqn descFqn =3D descendant.getFqn(); - Fqn ancFqn =3D ancestor.getFqn(); + prepareContextOptions(); + InternalNode ancestor =3D cache.getNode(ancFqn).getDelegationTarget(= ); Object name =3D descFqn.get(ancFqn.size()); InternalNode child =3D ancestor.getChild(name); if (ancFqn.size() =3D=3D descFqn.size() + 1) { if (child =3D=3D null) { + prepareContextOptions(); + InternalNode descendant =3D cache.getNode(descFqn).getDelegati= onTarget(); + prepareContextOptions(); ancestor.addChild(name, descendant); } else @@ -373,7 +387,7 @@ } = // Keep walking down the tree - integrateRetainedNode(child, descendant); + integrateRetainedNode(child.getFqn(), descFqn); } } } Modified: core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStat= eTransferIntegrator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStateTrans= ferIntegrator.java 2008-08-06 00:56:02 UTC (rev 6523) +++ core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStateTrans= ferIntegrator.java 2008-08-06 00:57:16 UTC (rev 6524) @@ -16,6 +16,7 @@ import org.jboss.cache.NodeSPI; import org.jboss.cache.Region; import org.jboss.cache.buddyreplication.BuddyManager; +import org.jboss.cache.config.Configuration; import org.jboss.cache.eviction.EvictedEventNode; import org.jboss.cache.eviction.NodeEventType; import org.jboss.cache.factories.annotations.Inject; @@ -43,24 +44,26 @@ = private static final Log log =3D LogFactory.getLog(LegacyStateTransferI= ntegrator.class); private static final boolean trace =3D log.isTraceEnabled(); - private CacheSPI cache; - private NodeFactory factory; - private Set internalFqns; + private Configuration cfg; + private boolean usePut; // for JBCACHE-131 = @Inject - public void inject(CacheSPI cache, NodeFactory nodefactory) + public void inject(CacheSPI cache, NodeFactory nodefactory, Confi= guration cfg) { this.cache =3D cache; this.factory =3D nodefactory; + this.cfg =3D cfg; } = @Start(priority =3D 14) public void start() { this.internalFqns =3D cache.getInternalFqns(); + usePut =3D cfg.getCacheLoaderConfig() !=3D null && !cfg.getCacheLoad= erConfig().isFetchPersistentState() && + !cfg.getCacheLoaderConfig().isShared(); } = public void integrateState(ObjectInputStream ois, Object target, Fqn ta= rgetFqn, boolean integratePersistentState) throws Exception @@ -212,9 +215,20 @@ if (nd !=3D null && !nd.isMarker()) { Map attributes =3D nd.getAttributes(); + if (usePut) + { + cache.getInvocationContext().getOptionOverrides().setCac= heModeLocal(true); + cache.getInvocationContext().getOptionOverrides().setSki= pCacheStatusCheck(true); + target.clearData(); + cache.getInvocationContext().getOptionOverrides().setCac= heModeLocal(true); + cache.getInvocationContext().getOptionOverrides().setSki= pCacheStatusCheck(true); + target.putAll(attributes); + } + else + { + target.setInternalState(attributes); + } = - target.setInternalState(attributes); - // Check whether this is an integration into the buddy back= up // subtree Fqn tferFqn =3D nd.getFqn(); @@ -276,16 +290,29 @@ = // We handle this NodeData. Create a TreeNode and // integrate its data - NodeSPI target =3D factory.createNode(fqn, parent, attrs); - parent.addChild(fqn.getLastElement(), target); - - // JBCACHE-913 - Region region =3D cache.getRegion(fqn, false); - if (region !=3D null && region.getEvictionPolicy() !=3D null) + NodeSPI target; + if (usePut) { - region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.AD= D_NODE_EVENT, - attrs =3D=3D null ? 0 : attrs.size())); + cache.getInvocationContext().getOptionOverrides().setCacheMode= Local(true); + cache.getInvocationContext().getOptionOverrides().setSkipCache= StatusCheck(true); + cache.clearData(fqn); + cache.getInvocationContext().getOptionOverrides().setCacheMode= Local(true); + cache.getInvocationContext().getOptionOverrides().setSkipCache= StatusCheck(true); + cache.put(fqn, attrs); + target =3D cache.getNode(fqn); } + else + { + target =3D factory.createNode(fqn, parent, attrs); + parent.addChild(fqn.getLastElement(), target); + // JBCACHE-913 + Region region =3D cache.getRegion(fqn, false); + if (region !=3D null && region.getEvictionPolicy() !=3D null) + { + region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType= .ADD_NODE_EVENT, + attrs =3D=3D null ? 0 : attrs.size())); + } + } = // Recursively call, which will walk down the tree // and return the next NodeData that's a child of our parent Modified: core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStat= eTransferManager.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStateTrans= ferManager.java 2008-08-06 00:56:02 UTC (rev 6523) +++ core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStateTrans= ferManager.java 2008-08-06 00:57:16 UTC (rev 6524) @@ -5,6 +5,7 @@ import org.jboss.cache.NodeSPI; import org.jboss.cache.RegionEmptyException; import org.jboss.cache.factories.annotations.Inject; +import org.jboss.cache.factories.annotations.Start; import org.jboss.cache.lock.LockManager; import static org.jboss.cache.lock.LockType.READ; import org.jboss.cache.lock.TimeoutException; @@ -23,6 +24,7 @@ public class LegacyStateTransferManager extends DefaultStateTransferManager { protected LockManager lockManager; + private boolean usePut; // for JBCACHE-131 = @Inject public void injectLockManager(LockManager lockManager) @@ -30,6 +32,13 @@ this.lockManager =3D lockManager; } = + @Start(priority =3D 14) + public void checkLoaders() + { + usePut =3D configuration.getCacheLoaderConfig() !=3D null && !config= uration.getCacheLoaderConfig().isFetchPersistentState() && + !configuration.getCacheLoaderConfig().isShared(); + } + @Override public void getState(ObjectOutputStream out, Fqn fqn, long timeout, boo= lean force, boolean suppressErrors) throws Exception { @@ -136,6 +145,7 @@ = protected void acquireLocksForStateTransfer(NodeSPI root, long timeout,= boolean force) throws InterruptedException { + if (usePut) return; try { lockManager.lockAll(root, READ, getLockOwner(), timeout, true); @@ -157,6 +167,7 @@ = protected void releaseStateTransferLocks(NodeSPI root) { + if (usePut) return; try { lockManager.unlockAll(root, getLockOwner()); Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/PersistingTransien= tStateTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/api/mvcc/PersistingTransientSt= ateTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/PersistingTransientSt= ateTest.java 2008-08-06 00:57:16 UTC (rev 6524) @@ -0,0 +1,13 @@ +package org.jboss.cache.api.mvcc; + +import org.jboss.cache.config.Configuration.NodeLockingScheme; +import org.testng.annotations.Test; + +(a)Test(groups =3D "functional") +public class PersistingTransientStateTest extends org.jboss.cache.statetra= nsfer.PersistingTransientStateTest +{ + public PersistingTransientStateTest() + { + nls =3D NodeLockingScheme.MVCC; + } +} \ No newline at end of file Added: core/trunk/src/test/java/org/jboss/cache/optimistic/PersistingTransi= entStateTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/optimistic/PersistingTransient= StateTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/optimistic/PersistingTransient= StateTest.java 2008-08-06 00:57:16 UTC (rev 6524) @@ -0,0 +1,13 @@ +package org.jboss.cache.optimistic; + +import org.jboss.cache.config.Configuration.NodeLockingScheme; +import org.testng.annotations.Test; + +(a)Test(groups =3D "functional") +public class PersistingTransientStateTest extends org.jboss.cache.statetra= nsfer.PersistingTransientStateTest +{ + public PersistingTransientStateTest() + { + nls =3D NodeLockingScheme.OPTIMISTIC; + } +} Added: core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTra= nsientStateTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransi= entStateTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransi= entStateTest.java 2008-08-06 00:57:16 UTC (rev 6524) @@ -0,0 +1,113 @@ +package org.jboss.cache.statetransfer; + +import org.jboss.cache.Cache; +import org.jboss.cache.CacheFactory; +import org.jboss.cache.CacheSPI; +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.Fqn; +import org.jboss.cache.config.CacheLoaderConfig; +import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfi= g; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.Configuration.CacheMode; +import org.jboss.cache.config.Configuration.NodeLockingScheme; +import org.jboss.cache.loader.CacheLoader; +import org.jboss.cache.loader.DummyInMemoryCacheLoader; +import org.jboss.cache.transaction.DummyTransactionManagerLookup; +import org.jboss.cache.util.TestingUtil; +import org.testng.annotations.Test; + +/** + * Transient state SHOULD be persisted on the receiving cache IF fetchPers= istentState is FALSE and the cache loader + * is NOT shared. + *

+ * Needs to be tested with PL, OL and MVCC. + *

+ * Pertains to JBCACHE-131 + *

+ */ +(a)Test(groups =3D "functional") +public class PersistingTransientStateTest +{ + protected NodeLockingScheme nls =3D NodeLockingScheme.PESSIMISTIC; + protected Fqn fqn =3D Fqn.fromString("/a/b/c"); + protected String k =3D "k", v =3D "v"; + + public void testPersistentStateTransfer() throws Exception + { + Cache c1 =3D null, c2 =3D null; + try + { + CacheFactory cf =3D new DefaultCacheFactory(); + Configuration cfg =3D new Configuration(); + cfg.setTransactionManagerLookupClass(DummyTransactionManagerLooku= p.class.getName()); + cfg.setCacheMode(CacheMode.REPL_SYNC); + cfg.setFetchInMemoryState(true); + // configure with CL + IndividualCacheLoaderConfig iclc =3D new IndividualCacheLoaderCon= fig(); + iclc.setClassName(DummyInMemoryCacheLoader.class.getName()); + iclc.setFetchPersistentState(false); + CacheLoaderConfig clc =3D new CacheLoaderConfig(); + clc.addIndividualCacheLoaderConfig(iclc); + + cfg.setCacheLoaderConfig(clc); + cfg.setNodeLockingScheme(nls); + + c1 =3D cf.createCache(cfg.clone()); + c1.put(fqn, k, v); + + assert c1.get(fqn, k).equals(v); + assert getLoader(c1).get(fqn).get(k).equals(v); + + c2 =3D cf.createCache(cfg.clone()); + assert c2.get(fqn, k).equals(v); + assert getLoader(c2).get(fqn).get(k).equals(v); + } + finally + { + TestingUtil.killCaches(c1, c2); + } + } + + public void testPersistentStateTransferShared() throws Exception + { + Cache c1 =3D null, c2 =3D null; + try + { + CacheFactory cf =3D new DefaultCacheFactory(); + Configuration cfg =3D new Configuration(); + cfg.setTransactionManagerLookupClass(DummyTransactionManagerLooku= p.class.getName()); + cfg.setCacheMode(CacheMode.REPL_SYNC); + cfg.setFetchInMemoryState(true); + // configure with CL + IndividualCacheLoaderConfig iclc =3D new IndividualCacheLoaderCon= fig(); + iclc.setClassName(DummyInMemoryCacheLoader.class.getName()); + iclc.setFetchPersistentState(false); + CacheLoaderConfig clc =3D new CacheLoaderConfig(); + clc.addIndividualCacheLoaderConfig(iclc); + clc.setShared(true); // even though it isn't really a shared CL + + cfg.setCacheLoaderConfig(clc); + cfg.setNodeLockingScheme(nls); + + c1 =3D cf.createCache(cfg.clone()); + c1.put(fqn, k, v); + + assert c1.get(fqn, k).equals(v); + assert getLoader(c1).get(fqn).get(k).equals(v); + + c2 =3D cf.createCache(cfg.clone()); + assert c2.get(fqn, k).equals(v); + assert getLoader(c2).get(fqn) =3D=3D null; + } + finally + { + TestingUtil.killCaches(c1, c2); + } + } + + protected CacheLoader getLoader(Cache c) + { + return ((CacheSPI) c).getCacheLoaderManager().getCacheLoader(); + } + +} --===============6407481266588456054==-- From jboss-qa-internal at redhat.com Wed Aug 6 03:15:42 2008 Content-Type: multipart/mixed; boundary="===============2916013058963820014==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23539?= Date: Wed, 06 Aug 2008 03:15:38 -0400 Message-ID: <228017621.16231218006938506.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 172593533.14291217954172555.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============2916013058963820014== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/539/changes --===============2916013058963820014==-- From jboss-qa-internal at redhat.com Wed Aug 6 03:56:53 2008 Content-Type: multipart/mixed; boundary="===============4885766231713919094==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23406?= Date: Wed, 06 Aug 2008 03:56:50 -0400 Message-ID: <115549049.16281218009410492.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 2131242718.14741217957890673.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============4885766231713919094== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/406/changes --===============4885766231713919094==-- From jbosscache-commits at lists.jboss.org Wed Aug 6 04:21:48 2008 Content-Type: multipart/mixed; boundary="===============7482614681332309961==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6525 - in searchable/trunk: src/main/java/org/jboss/cache/search and 4 other directories. Date: Wed, 06 Aug 2008 04:21:48 -0400 Message-ID: --===============7482614681332309961== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: navssurtani Date: 2008-08-06 04:21:48 -0400 (Wed, 06 Aug 2008) New Revision: 6525 Modified: searchable/trunk/TODO.txt searchable/trunk/src/main/java/org/jboss/cache/search/CacheEntityId.java searchable/trunk/src/main/java/org/jboss/cache/search/CacheEntityLoader.= java searchable/trunk/src/main/java/org/jboss/cache/search/CacheQuery.java searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java searchable/trunk/src/main/java/org/jboss/cache/search/InvalidFqnExceptio= n.java searchable/trunk/src/main/java/org/jboss/cache/search/InvalidKeyExceptio= n.java searchable/trunk/src/main/java/org/jboss/cache/search/NodeModifiedTransa= ctionContext.java searchable/trunk/src/main/java/org/jboss/cache/search/PojoTransactionCon= text.java searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIterato= rImpl.java searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCache.ja= va searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheCon= figuration.java searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFac= tory.java searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheImp= l.java searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreList= ener.java searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoList= ener.java searchable/trunk/src/main/java/org/jboss/cache/search/Transformer.java searchable/trunk/src/test/java/org/jboss/cache/search/CacheEntityIdTest.= java searchable/trunk/src/test/java/org/jboss/cache/search/NodeModifiedTransa= ctionContextTest.java searchable/trunk/src/test/java/org/jboss/cache/search/QueryResultIterato= rImplTest.java searchable/trunk/src/test/java/org/jboss/cache/search/SearchableCacheImp= lTest.java searchable/trunk/src/test/java/org/jboss/cache/search/TransformerTest.ja= va searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/BrokenAnn= otationTest.java searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/Clustered= CacheTest.java searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCach= eTest.java searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalPOJO= CacheTest.java searchable/trunk/src/test/java/org/jboss/cache/search/helper/IndexCleanU= p.java searchable/trunk/src/test/java/org/jboss/cache/search/test/BrokenDocumen= tId.java searchable/trunk/src/test/java/org/jboss/cache/search/test/BrokenProvide= d.java searchable/trunk/src/test/java/org/jboss/cache/search/test/Person.java Log: Changed @author in classes to * @author Navin Surtani (nsurtani(a)redhat.com) Modified: searchable/trunk/TODO.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/TODO.txt 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/TODO.txt 2008-08-06 08:21:48 UTC (rev 6525) @@ -6,8 +6,6 @@ = So that when a large amount of hits are there, they can be loaded when req= uired. = -3 - Deal with Lucene Filters and Sorting. - 4 - Non-string keys. = Think. Modified: searchable/trunk/src/main/java/org/jboss/cache/search/CacheEntity= Id.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/CacheEntityId.jav= a 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/main/java/org/jboss/cache/search/CacheEntityId.jav= a 2008-08-06 08:21:48 UTC (rev 6525) @@ -5,8 +5,7 @@ /** * * This class is used to get fqns, keys and documentId's by calling method= s on {@link org.jboss.cache.search.Transformer} - * - @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) */ public class CacheEntityId { Modified: searchable/trunk/src/main/java/org/jboss/cache/search/CacheEntity= Loader.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/CacheEntityLoader= .java 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/main/java/org/jboss/cache/search/CacheEntityLoader= .java 2008-08-06 08:21:48 UTC (rev 6525) @@ -9,8 +9,7 @@ = /** * Class that is used to load objects from a list of CacheEntityId ids. - * - * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) */ public class CacheEntityLoader { @@ -30,6 +29,7 @@ */ public List load(List ids) { + if (ids =3D=3D null) throw new NullPointerException("ids are null"); List retVal =3D new ArrayList(ids.size()); = for (CacheEntityId id: ids) @@ -48,6 +48,7 @@ */ public Object load(CacheEntityId id) { + if (id =3D=3D null) throw new NullPointerException("id is null"); return cache.get(id.getFqn(), id.getKey()); } = Modified: searchable/trunk/src/main/java/org/jboss/cache/search/CacheQuery.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/CacheQuery.java 2= 008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/main/java/org/jboss/cache/search/CacheQuery.java 2= 008-08-06 08:21:48 UTC (rev 6525) @@ -32,6 +32,15 @@ QueryResultIterator iterator(); = /** + * Lazily loads the results from the Query as a {@link org.jboss.cache.= search.QueryResultIterator} + * + * @return a QueryResultIterator which can be used to lazily ite= rate through results. + */ + + QueryResultIterator lazyIterator(); + + + /** * Sets a result with a given index to the first result. * * @param index of result to be set to the first. Modified: searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryI= mpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.ja= va 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.ja= va 2008-08-06 08:21:48 UTC (rev 6525) @@ -35,12 +35,11 @@ /** * Implementation class of the CacheQuery interface. *

- * - * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) */ public class CacheQueryImpl implements CacheQuery { -// private Cache cache; - Removed on 11/07/2008, cache is assigned but n= ever used. Hence removed. + // private Cache cache; - Removed on 11/07/2008, cache is assigned bu= t never used. Hence removed. private Class[] classes; private Sort sort; private Filter filter; @@ -85,7 +84,6 @@ } = = - /** * @return The result size of the query. */ @@ -241,6 +239,27 @@ return new QueryResultIteratorImpl(ids, entityLoader); } = + public QueryResultIterator lazyIterator() + { + IndexSearcher searcher =3D buildSearcher(searchFactory); + + try + { + Hits hits =3D getHits(searcher); + int first =3D first(); + int max =3D max(first, hits); + + DocumentExtractor extractor =3D new DocumentExtractor(luceneQuery= , searcher, searchFactory, indexProjection); + = + } + catch (IOException e) + { + e.printStackTrace(); //To change body of catch statement use Fil= e | Settings | File Templates. + } + + return null; + } + /** * Returns a the results from the query as a List object. * @@ -423,7 +442,7 @@ } = private void populateDirectories(List directories, D= irectoryProvider[] directoryProviders) - = + { for (DirectoryProvider provider : directoryProviders) { Modified: searchable/trunk/src/main/java/org/jboss/cache/search/InvalidFqnE= xception.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/InvalidFqnExcepti= on.java 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/main/java/org/jboss/cache/search/InvalidFqnExcepti= on.java 2008-08-06 08:21:48 UTC (rev 6525) @@ -5,8 +5,7 @@ /** * Thrown when an invalid Fqn is passed into {@link org.jboss.cache.search= .Transformer#generateId(org.jboss.cache.Fqn, String)} *

- * - * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) */ public class InvalidFqnException extends CacheException { Modified: searchable/trunk/src/main/java/org/jboss/cache/search/InvalidKeyE= xception.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/InvalidKeyExcepti= on.java 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/main/java/org/jboss/cache/search/InvalidKeyExcepti= on.java 2008-08-06 08:21:48 UTC (rev 6525) @@ -1,7 +1,7 @@ package org.jboss.cache.search; = /** - * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurta= ni(a)redhat.com) */ public class InvalidKeyException extends Exception { Modified: searchable/trunk/src/main/java/org/jboss/cache/search/NodeModifie= dTransactionContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/NodeModifiedTrans= actionContext.java 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/main/java/org/jboss/cache/search/NodeModifiedTrans= actionContext.java 2008-08-06 08:21:48 UTC (rev 6525) @@ -12,7 +12,7 @@ *

* It is used by the {@link SearchableCoreListener} to pass transaction in= formation to a Hibernate Search {@link org.hibernate.search.backend.Work} o= bject. *

- * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) * @see SearchableCoreListener */ public class NodeModifiedTransactionContext implements TransactionContext Modified: searchable/trunk/src/main/java/org/jboss/cache/search/PojoTransac= tionContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/PojoTransactionCo= ntext.java 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/main/java/org/jboss/cache/search/PojoTransactionCo= ntext.java 2008-08-06 08:21:48 UTC (rev 6525) @@ -7,7 +7,7 @@ //import javax.transaction.Transaction; // ///** -// * @author Navin Surtani - navin(a)surtani.org +// * @author Navin Surtani (nsurt= ani(a)redhat.com) // */ //public class PojoTransactionContext implements TransactionContext //{ Modified: searchable/trunk/src/main/java/org/jboss/cache/search/QueryResult= IteratorImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIterat= orImpl.java 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIterat= orImpl.java 2008-08-06 08:21:48 UTC (rev 6525) @@ -9,7 +9,7 @@ * This is the implementation class for the interface QueryResultIterator = which extends ListIterator. It is what is * returned when the iterator() method is run on a CacheQuery instance. * - * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) */ public class QueryResultIteratorImpl implements QueryResultIterator { Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableC= ache.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCache.j= ava 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCache.j= ava 2008-08-06 08:21:48 UTC (rev 6525) @@ -4,7 +4,7 @@ import org.jboss.cache.Cache; = /** - * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) *

* This will be the most used interface in JBossCache searchable. = It extends Cache and therefore will have * the standard get(), put() and remove() methods. The additional = method is the createQuery method which people Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableC= acheConfiguration.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheCo= nfiguration.java 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheCo= nfiguration.java 2008-08-06 08:21:48 UTC (rev 6525) @@ -14,7 +14,7 @@ * Class that implements {@link org.hibernate.search.cfg.SearchConfigurati= on} so that within JBossCache Searchable, there is no * need for a Hibernate Core configuration object. * - * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) */ public class SearchableCacheConfiguration implements SearchConfiguration { Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableC= acheFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFa= ctory.java 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFa= ctory.java 2008-08-06 08:21:48 UTC (rev 6525) @@ -12,7 +12,7 @@ import java.lang.reflect.Field; = /** - * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) */ public class SearchableCacheFactory { Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableC= acheImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheIm= pl.java 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheIm= pl.java 2008-08-06 08:21:48 UTC (rev 6525) @@ -19,7 +19,7 @@ import java.util.Set; = /** - * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) *

* Implementation class for the SearchableCache interface. */ Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableC= oreListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreLis= tener.java 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreLis= tener.java 2008-08-06 08:21:48 UTC (rev 6525) @@ -14,7 +14,7 @@ import java.util.Map; = /** - * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) * * Listener class for changes made to the cache. This listener makes chang= es if it is a org.jboss.cache being used. = */ Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableP= ojoListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoLis= tener.java 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoLis= tener.java 2008-08-06 08:21:48 UTC (rev 6525) @@ -10,7 +10,7 @@ import javax.transaction.Transaction; = /** - * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) */ = //@PojoCacheListener Modified: searchable/trunk/src/main/java/org/jboss/cache/search/Transformer= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/Transformer.java = 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/main/java/org/jboss/cache/search/Transformer.java = 2008-08-06 08:21:48 UTC (rev 6525) @@ -3,8 +3,8 @@ import org.jboss.cache.Fqn; = /** -(a)author Navin Surtani - navin(a)surtani.org - +* @author Navin Surtani (nsurtani= (a)redhat.com) +* * This class is one that does all the 'conversion' work between JBossCache= and Hibernate Search. This is where * users can switch from Fqn and key to a documentId and vice versa. * Modified: searchable/trunk/src/test/java/org/jboss/cache/search/CacheEntity= IdTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/test/java/org/jboss/cache/search/CacheEntityIdTest= .java 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/test/java/org/jboss/cache/search/CacheEntityIdTest= .java 2008-08-06 08:21:48 UTC (rev 6525) @@ -5,7 +5,7 @@ import org.jboss.cache.search.CacheEntityId; = /** - * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) */ = @Test Modified: searchable/trunk/src/test/java/org/jboss/cache/search/NodeModifie= dTransactionContextTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/test/java/org/jboss/cache/search/NodeModifiedTrans= actionContextTest.java 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/test/java/org/jboss/cache/search/NodeModifiedTrans= actionContextTest.java 2008-08-06 08:21:48 UTC (rev 6525) @@ -3,7 +3,7 @@ import org.testng.annotations.Test; = /** - * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) */ = @Test Modified: searchable/trunk/src/test/java/org/jboss/cache/search/QueryResult= IteratorImplTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/test/java/org/jboss/cache/search/QueryResultIterat= orImplTest.java 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/test/java/org/jboss/cache/search/QueryResultIterat= orImplTest.java 2008-08-06 08:21:48 UTC (rev 6525) @@ -11,7 +11,7 @@ import java.util.Map; = /** - * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) *

* Test class for the QueryResultIteratorImpl */ Modified: searchable/trunk/src/test/java/org/jboss/cache/search/SearchableC= acheImplTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/test/java/org/jboss/cache/search/SearchableCacheIm= plTest.java 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/test/java/org/jboss/cache/search/SearchableCacheIm= plTest.java 2008-08-06 08:21:48 UTC (rev 6525) @@ -5,7 +5,7 @@ import org.jboss.cache.DefaultCacheFactory; = /** - * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) */ = @Test (groups =3D "functional") Modified: searchable/trunk/src/test/java/org/jboss/cache/search/Transformer= Test.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/test/java/org/jboss/cache/search/TransformerTest.j= ava 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/test/java/org/jboss/cache/search/TransformerTest.j= ava 2008-08-06 08:21:48 UTC (rev 6525) @@ -4,7 +4,7 @@ import org.testng.annotations.Test; = /** - * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) *

* Unit-test class for the Transformer class. */ Modified: searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/Br= okenAnnotationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/BrokenAn= notationTest.java 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/BrokenAn= notationTest.java 2008-08-06 08:21:48 UTC (rev 6525) @@ -9,7 +9,7 @@ import org.jboss.cache.DefaultCacheFactory; = /** - * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) */ @Test (groups =3D "functional") public class BrokenAnnotationTest Modified: searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/Cl= usteredCacheTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/Clustere= dCacheTest.java 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/Clustere= dCacheTest.java 2008-08-06 08:21:48 UTC (rev 6525) @@ -22,7 +22,7 @@ import java.util.List; = /** - * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) */ @Test(groups =3D "functional") public class ClusteredCacheTest Modified: searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/Lo= calCacheTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCac= heTest.java 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCac= heTest.java 2008-08-06 08:21:48 UTC (rev 6525) @@ -25,7 +25,7 @@ import java.io.File; = /** - * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) */ = @Test(groups =3D "functional") Modified: searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/Lo= calPOJOCacheTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalPOJ= OCacheTest.java 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalPOJ= OCacheTest.java 2008-08-06 08:21:48 UTC (rev 6525) @@ -28,7 +28,7 @@ * instead of cache.put() and cache.remove(). *

* - * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) */ = @Test(groups =3D "functional", enabled =3D false) Modified: searchable/trunk/src/test/java/org/jboss/cache/search/helper/Inde= xCleanUp.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/test/java/org/jboss/cache/search/helper/IndexClean= Up.java 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/test/java/org/jboss/cache/search/helper/IndexClean= Up.java 2008-08-06 08:21:48 UTC (rev 6525) @@ -5,7 +5,7 @@ import java.io.File; = /** - * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) */ public class IndexCleanUp { Modified: searchable/trunk/src/test/java/org/jboss/cache/search/test/Broken= DocumentId.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/test/java/org/jboss/cache/search/test/BrokenDocume= ntId.java 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/test/java/org/jboss/cache/search/test/BrokenDocume= ntId.java 2008-08-06 08:21:48 UTC (rev 6525) @@ -6,7 +6,7 @@ import org.hibernate.search.annotations.Field; = /** - * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) */ @ProvidedId @Indexed Modified: searchable/trunk/src/test/java/org/jboss/cache/search/test/Broken= Provided.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/test/java/org/jboss/cache/search/test/BrokenProvid= ed.java 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/test/java/org/jboss/cache/search/test/BrokenProvid= ed.java 2008-08-06 08:21:48 UTC (rev 6525) @@ -5,7 +5,7 @@ import org.hibernate.search.annotations.Field; = /** - * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) */ @Indexed public class BrokenProvided Modified: searchable/trunk/src/test/java/org/jboss/cache/search/test/Person= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/test/java/org/jboss/cache/search/test/Person.java = 2008-08-06 00:57:16 UTC (rev 6524) +++ searchable/trunk/src/test/java/org/jboss/cache/search/test/Person.java = 2008-08-06 08:21:48 UTC (rev 6525) @@ -9,7 +9,7 @@ import java.io.Serializable; = /** - * @author Navin Surtani - navin(a)surtani.org + * @author Navin Surtani (nsurtan= i(a)redhat.com) */ @ProvidedId @Indexed --===============7482614681332309961==-- From jbosscache-commits at lists.jboss.org Wed Aug 6 05:22:45 2008 Content-Type: multipart/mixed; boundary="===============1563581414284751246==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6526 - core/trunk/src/test/java/org/jboss/cache/buddyreplication. Date: Wed, 06 Aug 2008 05:22:45 -0400 Message-ID: --===============1563581414284751246== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-06 05:22:45 -0400 (Wed, 06 Aug 2008) New Revision: 6526 Added: core/trunk/src/test/java/org/jboss/cache/buddyreplication/MvccBuddyRepli= cationTest.java Log: added ut for MVCC buddy failure Added: core/trunk/src/test/java/org/jboss/cache/buddyreplication/MvccBuddyR= eplicationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/buddyreplication/MvccBuddyRepl= icationTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/MvccBuddyRepl= icationTest.java 2008-08-06 09:22:45 UTC (rev 6526) @@ -0,0 +1,77 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2008, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.cache.buddyreplication; + +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.Cache; +import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; +import org.jboss.cache.lock.IsolationLevel; +import org.jboss.cache.config.Option; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.BuddyReplicationConfig; +import org.jboss.cache.config.parsing.XmlConfigurationParser; +import org.testng.annotations.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.AfterMethod; + +import java.util.Properties; +import java.util.List; +import java.util.ArrayList; + +/** + * @author Mircea.Markus(a)jboss.com + * @since 3.0 + */ +(a)Test(groups =3D "functionl") +public class MvccBuddyReplicationTest +{ + private static final String FILE =3D "configs/mvcc-repl-sync-br.xml"; + + Configuration configuration; + + public void testSimpleFailure() throws InterruptedException + { + Cache cache1 =3D createCache(); + Thread.sleep(1000); + Cache cache2 =3D createCache(); + + cache1.put("/test", "key", "value"); + cache1.stop(); + + Option option =3D cache2.getInvocationContext().getOptionOverrides(); + option.setForceDataGravitation(true); + try + { + assert cache2.get("/test", "key").equals("value"); + } finally + { + cache2.stop(); + } + } + + private Cache createCache() + { + Configuration fileConfig =3D new XmlConfigurationParser().parseFile(= FILE); + DefaultCacheFactory dcf =3D new DefaultCacheFactory(); + return dcf.createCache(fileConfig); + } +} --===============1563581414284751246==-- From jbosscache-commits at lists.jboss.org Wed Aug 6 05:23:42 2008 Content-Type: multipart/mixed; boundary="===============2827168153234682644==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6527 - core/trunk/src/test/resources/configs. Date: Wed, 06 Aug 2008 05:23:42 -0400 Message-ID: --===============2827168153234682644== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-06 05:23:41 -0400 (Wed, 06 Aug 2008) New Revision: 6527 Added: core/trunk/src/test/resources/configs/mvcc-repl-sync-br.xml Log: added ut for MVCC buddy failure Added: core/trunk/src/test/resources/configs/mvcc-repl-sync-br.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/resources/configs/mvcc-repl-sync-br.xml = (rev 0) +++ core/trunk/src/test/resources/configs/mvcc-repl-sync-br.xml 2008-08-06 = 09:23:41 UTC (rev 6527) @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + numBuddies =3D 1 + ignoreColocatedBuddies =3D true + + + + + --===============2827168153234682644==-- From jbosscache-commits at lists.jboss.org Wed Aug 6 10:37:51 2008 Content-Type: multipart/mixed; boundary="===============0433623226083987161==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6528 - core/trunk/src/test/java/org/jboss/cache/buddyreplication. Date: Wed, 06 Aug 2008 10:37:50 -0400 Message-ID: --===============0433623226083987161== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-06 10:37:50 -0400 (Wed, 06 Aug 2008) New Revision: 6528 Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/MvccBuddyRepli= cationTest.java Log: Improved test Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/MvccBud= dyReplicationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/buddyreplication/MvccBuddyRepl= icationTest.java 2008-08-06 09:23:41 UTC (rev 6527) +++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/MvccBuddyRepl= icationTest.java 2008-08-06 14:37:50 UTC (rev 6528) @@ -21,57 +21,50 @@ */ package org.jboss.cache.buddyreplication; = -import org.jboss.cache.DefaultCacheFactory; import org.jboss.cache.Cache; -import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; -import org.jboss.cache.lock.IsolationLevel; -import org.jboss.cache.config.Option; +import org.jboss.cache.DefaultCacheFactory; import org.jboss.cache.config.Configuration; -import org.jboss.cache.config.BuddyReplicationConfig; +import org.jboss.cache.config.Option; import org.jboss.cache.config.parsing.XmlConfigurationParser; +import org.jboss.cache.util.TestingUtil; import org.testng.annotations.Test; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.AfterMethod; = -import java.util.Properties; -import java.util.List; -import java.util.ArrayList; - /** * @author Mircea.Markus(a)jboss.com * @since 3.0 */ -(a)Test(groups =3D "functionl") +(a)Test(groups =3D "functional") public class MvccBuddyReplicationTest { private static final String FILE =3D "configs/mvcc-repl-sync-br.xml"; = - Configuration configuration; - - public void testSimpleFailure() throws InterruptedException + public void testSimpleFailure() { - Cache cache1 =3D createCache(); - Thread.sleep(1000); - Cache cache2 =3D createCache(); - - cache1.put("/test", "key", "value"); - cache1.stop(); - - Option option =3D cache2.getInvocationContext().getOptionOverrides(); - option.setForceDataGravitation(true); + Cache cache1 =3D null, cache2 =3D null; try { + cache1 =3D createCache(); + TestingUtil.sleepThread(1000); + cache2 =3D createCache(); + + cache1.put("/test", "key", "value"); + cache1.stop(); + + Option option =3D cache2.getInvocationContext().getOptionOverride= s(); + option.setForceDataGravitation(true); assert cache2.get("/test", "key").equals("value"); - } finally + } + finally { - cache2.stop(); + TestingUtil.killCaches(cache1, cache2); + } } = - private Cache createCache() + private Cache createCache() { Configuration fileConfig =3D new XmlConfigurationParser().parseFile(= FILE); - DefaultCacheFactory dcf =3D new DefaultCacheFactory(); + DefaultCacheFactory dcf =3D new DefaultCacheFactory<= String, String>(); return dcf.createCache(fileConfig); } } --===============0433623226083987161==-- From jbosscache-commits at lists.jboss.org Wed Aug 6 10:42:03 2008 Content-Type: multipart/mixed; boundary="===============8739036797077814852==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6529 - in core/trunk/src: main/java/org/jboss/cache/factories and 3 other directories. Date: Wed, 06 Aug 2008 10:42:03 -0400 Message-ID: --===============8739036797077814852== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-06 10:42:03 -0400 (Wed, 06 Aug 2008) New Revision: 6529 Added: core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInte= rceptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyDataGravitat= orInterceptor.java Removed: core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInte= rceptor.java Modified: core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFacto= ry.java core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicati= onConfigTest.java core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFacto= ryTest.java Log: Fixed broken data gravitation with MVCC Modified: core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-08= -06 14:37:50 UTC (rev 6528) +++ core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-08= -06 14:42:03 UTC (rev 6529) @@ -219,6 +219,26 @@ = public List buildNodeData(List list, NodeSPI node, = boolean mapSafe) { + if (usingMvcc) + return buildNodeData(list, node.getDelegationTarget(), mapSafe); + else + return buildNodeDataLegacy(list, node, mapSafe); + } + + private List buildNodeData(List list, InternalNode<= ?, ?> node, boolean mapSafe) + { + NodeData data =3D new NodeData(buddyFqnTransformer.getActualFqn(node= .getFqn()), node.getData(), mapSafe); + list.add(data); + for (InternalNode childNode : node.getChildrenMap().values()) + { + buildNodeData(list, childNode, true); + } + return list; + } + + @Deprecated + private List buildNodeDataLegacy(List list, NodeSPI= node, boolean mapSafe) + { NodeData data =3D new NodeData(buddyFqnTransformer.getActualFqn(node= .getFqn()), node.getDataDirect(), mapSafe); list.add(data); for (Object childNode : node.getChildrenDirect()) Modified: core/trunk/src/main/java/org/jboss/cache/factories/InterceptorCha= inFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFact= ory.java 2008-08-06 14:37:50 UTC (rev 6528) +++ core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFact= ory.java 2008-08-06 14:42:03 UTC (rev 6529) @@ -132,8 +132,14 @@ } = if (configuration.isUsingBuddyReplication()) - interceptorChain.appendIntereceptor(createInterceptor(DataGravita= torInterceptor.class)); + { + if (configuration.getNodeLockingScheme() =3D=3D NodeLockingScheme= .MVCC) + interceptorChain.appendIntereceptor(createInterceptor(DataGrav= itatorInterceptor.class)); + else + interceptorChain.appendIntereceptor(createInterceptor(LegacyDa= taGravitatorInterceptor.class)); + } = + if (optimistic) { interceptorChain.appendIntereceptor(createInterceptor(OptimisticL= ockingInterceptor.class)); Deleted: core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitat= orInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInt= erceptor.java 2008-08-06 14:37:50 UTC (rev 6528) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInt= erceptor.java 2008-08-06 14:42:03 UTC (rev 6529) @@ -1,439 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package org.jboss.cache.interceptors; - -import org.jboss.cache.CacheException; -import org.jboss.cache.CacheSPI; -import org.jboss.cache.DataContainer; -import org.jboss.cache.Fqn; -import org.jboss.cache.buddyreplication.BuddyFqnTransformer; -import org.jboss.cache.buddyreplication.BuddyManager; -import org.jboss.cache.buddyreplication.GravitateResult; -import org.jboss.cache.commands.CommandsFactory; -import org.jboss.cache.commands.DataCommand; -import org.jboss.cache.commands.ReplicableCommand; -import org.jboss.cache.commands.read.ExistsCommand; -import org.jboss.cache.commands.read.GetChildrenNamesCommand; -import org.jboss.cache.commands.read.GetDataMapCommand; -import org.jboss.cache.commands.read.GetKeyValueCommand; -import org.jboss.cache.commands.read.GetKeysCommand; -import org.jboss.cache.commands.read.GetNodeCommand; -import org.jboss.cache.commands.read.GravitateDataCommand; -import org.jboss.cache.commands.remote.DataGravitationCleanupCommand; -import org.jboss.cache.commands.tx.CommitCommand; -import org.jboss.cache.commands.tx.RollbackCommand; -import org.jboss.cache.factories.annotations.Inject; -import org.jboss.cache.invocation.InvocationContext; -import org.jboss.cache.marshall.NodeData; -import org.jboss.cache.transaction.GlobalTransaction; -import org.jgroups.Address; -import org.jgroups.blocks.GroupRequest; -import org.jgroups.blocks.RspFilter; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * The Data Gravitator interceptor intercepts cache misses and attempts to - * gravitate data from other parts of the cluster. - *

- * 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 Da= ta - * Gravitation for a specific invocation or if autoDataGravitation = is - * set to true when configuring Buddy Replication. - *

- * See the JBoss Cache User Guide for more details on configuration option= s. - * There is a section dedicated to Buddy Replication in the Replication - * chapter. - *

- * In terms of functionality, if a gravitation call has occured and a clea= nup call is needed (based on - * how BR is configured), a cleanup call will be broadcast immediately aft= er the gravitation call (no txs) - * or if txs are used, an asynchronous call is made to perform the = cleanup outside the scope - * of the tx that caused the gravitation event. - *

- * - * @author Manik Surtani (manik(a)jbo= ss.org) - */ -public class DataGravitatorInterceptor extends BaseRpcInterceptor -{ - private BuddyManager buddyManager; - /** - * Map that contains commands that need cleaning up. This is keyed on = global transaction, and contains a list of - * cleanup commands corresponding to all gravitate calls made during th= e course of the transaction in question. - */ - private Map> cleanupCommands= =3D new ConcurrentHashMap>(); - private DataContainer dataContainer; - private CommandsFactory commandsFactory; - private CacheSPI cacheSPI; - private BuddyFqnTransformer buddyFqnTransformer; - - @Inject - public void injectComponents(BuddyManager buddyManager, DataContainer d= ataContainer, CommandsFactory commandsFactory, CacheSPI cacheSPI, BuddyFqnT= ransformer transformer) - { - this.buddyManager =3D buddyManager; - this.dataContainer =3D dataContainer; - this.commandsFactory =3D commandsFactory; - this.cacheSPI =3D cacheSPI; - buddyFqnTransformer =3D transformer; - } - - @Override - public Object visitGetChildrenNamesCommand(InvocationContext ctx, GetCh= ildrenNamesCommand command) throws Throwable - { - return handleGetMethod(ctx, command); - } - - @Override - public Object visitGetDataMapCommand(InvocationContext ctx, GetDataMapC= ommand command) throws Throwable - { - return handleGetMethod(ctx, command); - } - - @Override - public Object visitExistsNodeCommand(InvocationContext ctx, ExistsComma= nd command) throws Throwable - { - return handleGetMethod(ctx, command); - } - - @Override - public Object visitGetKeysCommand(InvocationContext ctx, GetKeysCommand= command) throws Throwable - { - return handleGetMethod(ctx, command); - } - - @Override - public Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValu= eCommand command) throws Throwable - { - return handleGetMethod(ctx, command); - } - - @Override - public Object visitGetNodeCommand(InvocationContext ctx, GetNodeCommand= command) throws Throwable - { - return handleGetMethod(ctx, command); - } - - @Override - public Object visitRollbackCommand(InvocationContext ctx, RollbackComma= nd command) throws Throwable - { - try - { - return invokeNextInterceptor(ctx, command); - } - finally - { - cleanupCommands.remove(ctx.getGlobalTransaction()); - } - } - - @Override - public Object visitCommitCommand(InvocationContext ctx, CommitCommand c= ommand) throws Throwable - { - GlobalTransaction gtx =3D ctx.getGlobalTransaction(); - try - { - doCommit(gtx); - return invokeNextInterceptor(ctx, command); - } - finally - { - cleanupCommands.remove(gtx); - } - } - - private Object handleGetMethod(InvocationContext ctx, DataCommand comma= nd) throws Throwable - { - if (isGravitationEnabled(ctx)) - { - // test that the Fqn being requested exists locally in the cache. - if (trace) log.trace("Checking local existence of requested fqn "= + command.getFqn()); - if (buddyFqnTransformer.isBackupFqn(command.getFqn())) - { - log.info("Is call for a backup Fqn, not performing any gravita= tion. Direct calls on internal backup nodes are *not* supported."); - } - else - { - if (!dataContainer.exists(command.getFqn())) - { - // gravitation is necessary. - - if (trace) log.trace("Gravitating from local backup tree"); - BackupData data =3D localBackupGet(command.getFqn(), ctx); - - if (data =3D=3D null) - { - if (trace) log.trace("Gravitating from remote backup tre= e"); - // gravitate remotely. - data =3D remoteBackupGet(command.getFqn()); - } - - if (data !=3D null) - { - if (trace) - log.trace("Passing the put call locally to make sure = state is persisted and ownership is correctly established."); - // store the gravitated node locally. This will cause i= t being backed up in the current instance's buddy. - createNode(data.backupData); - - cleanBackupData(data, ctx); - } - } - else - { - if (trace) log.trace("No need to gravitate; have this alrea= dy."); - } - } - } - else - { - if (trace) - { - log.trace("Suppressing data gravitation for this call."); - } - } - return invokeNextInterceptor(ctx, command); - } - - private boolean isGravitationEnabled(InvocationContext ctx) - { - boolean enabled =3D ctx.isOriginLocal(); - if (enabled) - { - if (!buddyManager.isAutoDataGravitation()) - { - enabled =3D ctx.getOptionOverrides().getForceDataGravitation(); - } - } - return enabled; - } - - private void doCommit(GlobalTransaction gtx) throws Throwable - { - if (cleanupCommands.containsKey(gtx)) - { - if (trace) log.trace("Broadcasting cleanup commands for gtx " + g= tx); - - for (ReplicableCommand command : cleanupCommands.get(gtx)) - { - try - { - doCleanup(command); - } - catch (Throwable th) - { - log.warn("Problems performing gravitation cleanup. Cleanup= command: " + command, th); - } - } - } - else - { - if (trace) log.trace("No cleanups to broadcast in commit phase fo= r gtx " + gtx); - } - } - - private BackupData remoteBackupGet(Fqn name) throws Exception - { - BackupData result =3D null; - GravitateResult gr =3D gravitateData(name); - if (gr.isDataFound()) - { - if (trace) - { - log.trace("Got response " + gr); - } - - result =3D new BackupData(name, gr); - } - return result; - } - - private void cleanBackupData(BackupData backup, InvocationContext ctx) = throws Throwable - { - - DataGravitationCleanupCommand cleanupCommand =3D commandsFactory.bui= ldDataGravitationCleanupCommand(backup.primaryFqn, backup.backupFqn); - GlobalTransaction gtx =3D ctx.getGlobalTransaction(); - - if (gtx =3D=3D null) - { - // broadcast removes - // remove main Fqn - if (trace) log.trace("Performing cleanup on [" + backup.primaryFq= n + "]"); - // remove backup Fqn - doCleanup(cleanupCommand); - } - else - { - if (trace) - log.trace("Data gravitation performed under global transaction= " + gtx + ". Not broadcasting cleanups until the tx commits. Recording c= leanup command for later use."); - List commands; - if (cleanupCommands.containsKey(gtx)) - { - commands =3D cleanupCommands.get(gtx); - } - else - { - commands =3D new LinkedList(); - } - - commands.add(cleanupCommand); - cleanupCommands.put(gtx, commands); - } - } - - private void doCleanup(ReplicableCommand cleanupCommand) throws Throwab= le - { - // cleanup commands are always ASYNCHRONOUS and is broadcast to *eve= ryone* (even members of the current buddy - // group as they may be members of > 1 buddy group) - replicateCall(null, cleanupCommand, false, false, false, true, -1); - } - - @SuppressWarnings("deprecation") - private GravitateResult gravitateData(Fqn fqn) throws Exception - { - if (trace) log.trace("Requesting data gravitation for Fqn " + fqn); - - List

mbrs =3D rpcManager.getMembers(); - Boolean searchSubtrees =3D buddyManager.isDataGravitationSearchBacku= pTrees() ? Boolean.TRUE : Boolean.FALSE; - GravitateDataCommand command =3D commandsFactory.buildGravitateDataC= ommand(fqn, searchSubtrees); - // doing a GET_ALL is crappy but necessary since JGroups' GET_FIRST = could return null results from nodes that do - // not have either the primary OR backup, and stop polling other val= id nodes. - List resps =3D rpcManager.callRemoteMethods(null, command, GroupRequ= est.GET_ALL, buddyManager.getBuddyCommunicationTimeout(), new ResponseValid= ityFilter(mbrs, rpcManager.getLocalAddress()), false); - - if (trace) log.trace("got responses " + resps); - - if (resps =3D=3D null) - { - if (mbrs.size() > 1) log.error("No replies to call " + command); - return GravitateResult.noDataFound(); - } - - // test for and remove exceptions - GravitateResult result =3D GravitateResult.noDataFound(); - for (Object o : resps) - { - if (o instanceof Throwable) - { - if (log.isDebugEnabled()) - { - log.debug("Found remote Throwable among responses - removin= g from responses list", (Exception) o); - } - } - else if (o !=3D null) - { - result =3D (GravitateResult) o; - if (result.isDataFound()) - { - break; - } - } - else if (!configuration.isUseRegionBasedMarshalling()) - { - // Null is OK if we are using region based marshalling; it - // is what is returned if a region is inactive. Otherwise - // getting a null is an error condition - log.error("Unexpected null response to call " + command + "."); - } - - } - - return result; - } - - @SuppressWarnings("unchecked") - private void createNode(List nodeData) throws CacheException - { - for (NodeData data : nodeData) - { - cacheSPI.put(data.getFqn(), data.getAttributes()); - } - } - - private BackupData localBackupGet(Fqn fqn, InvocationContext ctx) throw= s CacheException - { - GravitateResult result =3D cacheSPI.gravitateData(fqn, true, ctx);//= a "local" gravitation - boolean found =3D result.isDataFound(); - BackupData data =3D null; - - if (found) - { - Fqn backupFqn =3D result.getBuddyBackupFqn(); - data =3D new BackupData(fqn, result); - // now the cleanup - if (buddyManager.isDataGravitationRemoveOnFind()) - { - // Remove locally only; the remote call will - // be broadcast later - ctx.getOptionOverrides().setCacheModeLocal(true); - cacheSPI.removeNode(backupFqn); - } - else - { - cacheSPI.evict(backupFqn, true); - } - } - - if (trace) log.trace("Retrieved data " + data + " found =3D " + foun= d); - return data; - } - - private static class BackupData - { - Fqn primaryFqn; - Fqn backupFqn; - List backupData; - - public BackupData(Fqn primaryFqn, GravitateResult gr) - { - this.primaryFqn =3D primaryFqn; - this.backupFqn =3D gr.getBuddyBackupFqn(); - this.backupData =3D gr.getNodeData(); - } - - public String toString() - { - return "BackupData{" + - "primaryFqn=3D" + primaryFqn + - ", backupFqn=3D" + backupFqn + - ", backupData=3D" + backupData + - '}'; - } - } - - public static class ResponseValidityFilter implements RspFilter - { - private int numValidResponses =3D 0; - private List
pendingResponders; - - public ResponseValidityFilter(List
expected, Address localA= ddress) - { - // so for now I used a list to keep it consistent - this.pendingResponders =3D new ArrayList
(expected); - // We'll never get a response from ourself - this.pendingResponders.remove(localAddress); - } - - public boolean isAcceptable(Object object, Address address) - { - pendingResponders.remove(address); - - if (object instanceof GravitateResult) - { - GravitateResult response =3D (GravitateResult) object; - if (response.isDataFound()) numValidResponses++; - } - // always return true to make sure a response is logged by the JG= roups RpcDispatcher. - return true; - } - - public boolean needMoreResponses() - { - return numValidResponses < 1 && pendingResponders.size() > 0; - } - } -} Added: core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitator= Interceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInt= erceptor.java (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInt= erceptor.java 2008-08-06 14:42:03 UTC (rev 6529) @@ -0,0 +1,29 @@ +package org.jboss.cache.interceptors; + +import org.jboss.cache.Fqn; +import org.jboss.cache.factories.annotations.Inject; +import org.jboss.cache.invocation.InvocationContext; +import org.jboss.cache.mvcc.MVCCNodeHelper; + +/** + * MVCC specific version of the LegacyDataGravitatorInterceptor + * + * @author Manik Surtani (manik(a)jbo= ss.org) + * @since 3.0 + */ +public class DataGravitatorInterceptor extends LegacyDataGravitatorInterce= ptor +{ + MVCCNodeHelper helper; + + @Inject + public void injectMvccNodeHelper(MVCCNodeHelper helper) + { + this.helper =3D helper; + } + + @Override + protected void wrapIfNeeded(InvocationContext ctx, Fqn fqnToWrap) throw= s InterruptedException + { + helper.wrapNodeForReading(ctx, fqnToWrap); + } +} Copied: core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyDataGra= vitatorInterceptor.java (from rev 6527, core/trunk/src/main/java/org/jboss/= cache/interceptors/DataGravitatorInterceptor.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyDataGravita= torInterceptor.java (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyDataGravita= torInterceptor.java 2008-08-06 14:42:03 UTC (rev 6529) @@ -0,0 +1,446 @@ +/* + * JBoss, Home of Professional Open Source + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.cache.interceptors; + +import org.jboss.cache.CacheException; +import org.jboss.cache.CacheSPI; +import org.jboss.cache.DataContainer; +import org.jboss.cache.Fqn; +import org.jboss.cache.buddyreplication.BuddyFqnTransformer; +import org.jboss.cache.buddyreplication.BuddyManager; +import org.jboss.cache.buddyreplication.GravitateResult; +import org.jboss.cache.commands.CommandsFactory; +import org.jboss.cache.commands.DataCommand; +import org.jboss.cache.commands.ReplicableCommand; +import org.jboss.cache.commands.read.ExistsCommand; +import org.jboss.cache.commands.read.GetChildrenNamesCommand; +import org.jboss.cache.commands.read.GetDataMapCommand; +import org.jboss.cache.commands.read.GetKeyValueCommand; +import org.jboss.cache.commands.read.GetKeysCommand; +import org.jboss.cache.commands.read.GetNodeCommand; +import org.jboss.cache.commands.read.GravitateDataCommand; +import org.jboss.cache.commands.remote.DataGravitationCleanupCommand; +import org.jboss.cache.commands.tx.CommitCommand; +import org.jboss.cache.commands.tx.RollbackCommand; +import org.jboss.cache.factories.annotations.Inject; +import org.jboss.cache.invocation.InvocationContext; +import org.jboss.cache.marshall.NodeData; +import org.jboss.cache.transaction.GlobalTransaction; +import org.jgroups.Address; +import org.jgroups.blocks.GroupRequest; +import org.jgroups.blocks.RspFilter; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * The Data Gravitator interceptor intercepts cache misses and attempts to + * gravitate data from other parts of the cluster. + *

+ * 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 Da= ta + * Gravitation for a specific invocation or if autoDataGravitation = is + * set to true when configuring Buddy Replication. + *

+ * See the JBoss Cache User Guide for more details on configuration option= s. + * There is a section dedicated to Buddy Replication in the Replication + * chapter. + *

+ * In terms of functionality, if a gravitation call has occured and a clea= nup call is needed (based on + * how BR is configured), a cleanup call will be broadcast immediately aft= er the gravitation call (no txs) + * or if txs are used, an asynchronous call is made to perform the = cleanup outside the scope + * of the tx that caused the gravitation event. + *

+ * + * @author Manik Surtani (manik(a)jbo= ss.org) + * @deprecated will be removed with optimistic and pessimistic locking. + */ +(a)Deprecated +public class LegacyDataGravitatorInterceptor extends BaseRpcInterceptor +{ + private BuddyManager buddyManager; + /** + * Map that contains commands that need cleaning up. This is keyed on = global transaction, and contains a list of + * cleanup commands corresponding to all gravitate calls made during th= e course of the transaction in question. + */ + private Map> cleanupCommands= =3D new ConcurrentHashMap>(); + private DataContainer dataContainer; + private CommandsFactory commandsFactory; + private CacheSPI cacheSPI; + private BuddyFqnTransformer buddyFqnTransformer; + + @Inject + public void injectComponents(BuddyManager buddyManager, DataContainer d= ataContainer, CommandsFactory commandsFactory, CacheSPI cacheSPI, BuddyFqnT= ransformer transformer) + { + this.buddyManager =3D buddyManager; + this.dataContainer =3D dataContainer; + this.commandsFactory =3D commandsFactory; + this.cacheSPI =3D cacheSPI; + buddyFqnTransformer =3D transformer; + } + + @Override + public Object visitGetChildrenNamesCommand(InvocationContext ctx, GetCh= ildrenNamesCommand command) throws Throwable + { + return handleGetMethod(ctx, command); + } + + @Override + public Object visitGetDataMapCommand(InvocationContext ctx, GetDataMapC= ommand command) throws Throwable + { + return handleGetMethod(ctx, command); + } + + @Override + public Object visitExistsNodeCommand(InvocationContext ctx, ExistsComma= nd command) throws Throwable + { + return handleGetMethod(ctx, command); + } + + @Override + public Object visitGetKeysCommand(InvocationContext ctx, GetKeysCommand= command) throws Throwable + { + return handleGetMethod(ctx, command); + } + + @Override + public Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValu= eCommand command) throws Throwable + { + return handleGetMethod(ctx, command); + } + + @Override + public Object visitGetNodeCommand(InvocationContext ctx, GetNodeCommand= command) throws Throwable + { + return handleGetMethod(ctx, command); + } + + @Override + public Object visitRollbackCommand(InvocationContext ctx, RollbackComma= nd command) throws Throwable + { + try + { + return invokeNextInterceptor(ctx, command); + } + finally + { + cleanupCommands.remove(ctx.getGlobalTransaction()); + } + } + + @Override + public Object visitCommitCommand(InvocationContext ctx, CommitCommand c= ommand) throws Throwable + { + GlobalTransaction gtx =3D ctx.getGlobalTransaction(); + try + { + doCommit(gtx); + return invokeNextInterceptor(ctx, command); + } + finally + { + cleanupCommands.remove(gtx); + } + } + + private Object handleGetMethod(InvocationContext ctx, DataCommand comma= nd) throws Throwable + { + if (isGravitationEnabled(ctx)) + { + // test that the Fqn being requested exists locally in the cache. + if (trace) log.trace("Checking local existence of requested fqn "= + command.getFqn()); + if (buddyFqnTransformer.isBackupFqn(command.getFqn())) + { + log.info("Is call for a backup Fqn, not performing any gravita= tion. Direct calls on internal backup nodes are *not* supported."); + } + else + { + if (!dataContainer.exists(command.getFqn())) + { + // gravitation is necessary. + + if (trace) log.trace("Gravitating from local backup tree"); + BackupData data =3D localBackupGet(command.getFqn(), ctx); + + if (data =3D=3D null) + { + if (trace) log.trace("Gravitating from remote backup tre= e"); + // gravitate remotely. + data =3D remoteBackupGet(command.getFqn()); + } + + if (data !=3D null) + { + if (trace) + log.trace("Passing the put call locally to make sure = state is persisted and ownership is correctly established."); + // store the gravitated node locally. This will cause i= t being backed up in the current instance's buddy. + createNode(data.backupData); + cleanBackupData(data, ctx); + wrapIfNeeded(ctx, data.primaryFqn); + } + } + else + { + if (trace) log.trace("No need to gravitate; have this alrea= dy."); + } + } + } + else + { + if (trace) + { + log.trace("Suppressing data gravitation for this call."); + } + } + return invokeNextInterceptor(ctx, command); + } + + protected void wrapIfNeeded(InvocationContext ctx, Fqn fqnToWrap) throw= s InterruptedException + { + // no op + } + + private boolean isGravitationEnabled(InvocationContext ctx) + { + boolean enabled =3D ctx.isOriginLocal(); + if (enabled) + { + if (!buddyManager.isAutoDataGravitation()) + { + enabled =3D ctx.getOptionOverrides().getForceDataGravitation(); + } + } + return enabled; + } + + private void doCommit(GlobalTransaction gtx) throws Throwable + { + if (cleanupCommands.containsKey(gtx)) + { + if (trace) log.trace("Broadcasting cleanup commands for gtx " + g= tx); + + for (ReplicableCommand command : cleanupCommands.get(gtx)) + { + try + { + doCleanup(command); + } + catch (Throwable th) + { + log.warn("Problems performing gravitation cleanup. Cleanup= command: " + command, th); + } + } + } + else + { + if (trace) log.trace("No cleanups to broadcast in commit phase fo= r gtx " + gtx); + } + } + + private BackupData remoteBackupGet(Fqn name) throws Exception + { + BackupData result =3D null; + GravitateResult gr =3D gravitateData(name); + if (gr.isDataFound()) + { + if (trace) + { + log.trace("Got response " + gr); + } + + result =3D new BackupData(name, gr); + } + return result; + } + + private void cleanBackupData(BackupData backup, InvocationContext ctx) = throws Throwable + { + + DataGravitationCleanupCommand cleanupCommand =3D commandsFactory.bui= ldDataGravitationCleanupCommand(backup.primaryFqn, backup.backupFqn); + GlobalTransaction gtx =3D ctx.getGlobalTransaction(); + + if (gtx =3D=3D null) + { + // broadcast removes + // remove main Fqn + if (trace) log.trace("Performing cleanup on [" + backup.primaryFq= n + "]"); + // remove backup Fqn + doCleanup(cleanupCommand); + } + else + { + if (trace) + log.trace("Data gravitation performed under global transaction= " + gtx + ". Not broadcasting cleanups until the tx commits. Recording c= leanup command for later use."); + List commands; + if (cleanupCommands.containsKey(gtx)) + { + commands =3D cleanupCommands.get(gtx); + } + else + { + commands =3D new LinkedList(); + } + + commands.add(cleanupCommand); + cleanupCommands.put(gtx, commands); + } + } + + private void doCleanup(ReplicableCommand cleanupCommand) throws Throwab= le + { + // cleanup commands are always ASYNCHRONOUS and is broadcast to *eve= ryone* (even members of the current buddy + // group as they may be members of > 1 buddy group) + replicateCall(null, cleanupCommand, false, false, false, true, -1); + } + + @SuppressWarnings("deprecation") + private GravitateResult gravitateData(Fqn fqn) throws Exception + { + if (trace) log.trace("Requesting data gravitation for Fqn " + fqn); + + List

mbrs =3D rpcManager.getMembers(); + Boolean searchSubtrees =3D buddyManager.isDataGravitationSearchBacku= pTrees() ? Boolean.TRUE : Boolean.FALSE; + GravitateDataCommand command =3D commandsFactory.buildGravitateDataC= ommand(fqn, searchSubtrees); + // doing a GET_ALL is crappy but necessary since JGroups' GET_FIRST = could return null results from nodes that do + // not have either the primary OR backup, and stop polling other val= id nodes. + List resps =3D rpcManager.callRemoteMethods(null, command, GroupRequ= est.GET_ALL, buddyManager.getBuddyCommunicationTimeout(), new ResponseValid= ityFilter(mbrs, rpcManager.getLocalAddress()), false); + + if (trace) log.trace("got responses " + resps); + + if (resps =3D=3D null) + { + if (mbrs.size() > 1) log.error("No replies to call " + command); + return GravitateResult.noDataFound(); + } + + // test for and remove exceptions + GravitateResult result =3D GravitateResult.noDataFound(); + for (Object o : resps) + { + if (o instanceof Throwable) + { + if (log.isDebugEnabled()) + { + log.debug("Found remote Throwable among responses - removin= g from responses list", (Exception) o); + } + } + else if (o !=3D null) + { + result =3D (GravitateResult) o; + if (result.isDataFound()) + { + break; + } + } + else if (!configuration.isUseRegionBasedMarshalling()) + { + // Null is OK if we are using region based marshalling; it + // is what is returned if a region is inactive. Otherwise + // getting a null is an error condition + log.error("Unexpected null response to call " + command + "."); + } + + } + + return result; + } + + @SuppressWarnings("unchecked") + private void createNode(List nodeData) throws CacheException + { + for (NodeData data : nodeData) + { + cacheSPI.put(data.getFqn(), data.getAttributes()); + } + } + + private BackupData localBackupGet(Fqn fqn, InvocationContext ctx) throw= s CacheException + { + GravitateResult result =3D cacheSPI.gravitateData(fqn, true, ctx);//= a "local" gravitation + boolean found =3D result.isDataFound(); + BackupData data =3D null; + + if (found) + { + Fqn backupFqn =3D result.getBuddyBackupFqn(); + data =3D new BackupData(fqn, result); + // now the cleanup + if (buddyManager.isDataGravitationRemoveOnFind()) + { + // Remove locally only; the remote call will + // be broadcast later + ctx.getOptionOverrides().setCacheModeLocal(true); + cacheSPI.removeNode(backupFqn); + } + else + { + cacheSPI.evict(backupFqn, true); + } + } + + if (trace) log.trace("Retrieved data " + data + " found =3D " + foun= d); + return data; + } + + private static class BackupData + { + Fqn primaryFqn; + Fqn backupFqn; + List backupData; + + public BackupData(Fqn primaryFqn, GravitateResult gr) + { + this.primaryFqn =3D primaryFqn; + this.backupFqn =3D gr.getBuddyBackupFqn(); + this.backupData =3D gr.getNodeData(); + } + + public String toString() + { + return "BackupData{" + + "primaryFqn=3D" + primaryFqn + + ", backupFqn=3D" + backupFqn + + ", backupData=3D" + backupData + + '}'; + } + } + + public static class ResponseValidityFilter implements RspFilter + { + private int numValidResponses =3D 0; + private List
pendingResponders; + + public ResponseValidityFilter(List
expected, Address localA= ddress) + { + // so for now I used a list to keep it consistent + this.pendingResponders =3D new ArrayList
(expected); + // We'll never get a response from ourself + this.pendingResponders.remove(localAddress); + } + + public boolean isAcceptable(Object object, Address address) + { + pendingResponders.remove(address); + + if (object instanceof GravitateResult) + { + GravitateResult response =3D (GravitateResult) object; + if (response.isDataFound()) numValidResponses++; + } + // always return true to make sure a response is logged by the JG= roups RpcDispatcher. + return true; + } + + public boolean needMoreResponses() + { + return numValidResponses < 1 && pendingResponders.size() > 0; + } + } +} Property changes on: core/trunk/src/main/java/org/jboss/cache/interceptors/= LegacyDataGravitatorInterceptor.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyRe= plicationConfigTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicat= ionConfigTest.java 2008-08-06 14:37:50 UTC (rev 6528) +++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicat= ionConfigTest.java 2008-08-06 14:42:03 UTC (rev 6529) @@ -14,7 +14,7 @@ import org.jboss.cache.config.parsing.XmlConfigHelper; import org.jboss.cache.config.parsing.XmlConfigurationParser; import org.jboss.cache.config.parsing.element.BuddyElementParser; -import org.jboss.cache.interceptors.DataGravitatorInterceptor; +import org.jboss.cache.interceptors.LegacyDataGravitatorInterceptor; import org.jboss.cache.interceptors.base.CommandInterceptor; import static org.testng.AssertJUnit.*; import org.testng.annotations.AfterMethod; @@ -102,7 +102,7 @@ boolean hasDG =3D false; for (CommandInterceptor interceptor : cache.getInterceptorChain()) { - hasDG =3D hasDG || (interceptor instanceof DataGravitatorIntercep= tor); + hasDG =3D hasDG || (interceptor instanceof LegacyDataGravitatorIn= terceptor); } = System.out.println(cache.getInterceptorChain()); Modified: core/trunk/src/test/java/org/jboss/cache/factories/InterceptorCha= inFactoryTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFact= oryTest.java 2008-08-06 14:37:50 UTC (rev 6528) +++ core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFact= oryTest.java 2008-08-06 14:42:03 UTC (rev 6529) @@ -503,7 +503,7 @@ assertEquals(OptimisticTxInterceptor.class, interceptors.next().getC= lass()); assertEquals(NotificationInterceptor.class, interceptors.next().getC= lass()); assertEquals(OptimisticReplicationInterceptor.class, interceptors.ne= xt().getClass()); - assertEquals(DataGravitatorInterceptor.class, interceptors.next().ge= tClass()); + assertEquals(LegacyDataGravitatorInterceptor.class, interceptors.nex= t().getClass()); assertEquals(OptimisticLockingInterceptor.class, interceptors.next()= .getClass()); assertEquals(OptimisticValidatorInterceptor.class, interceptors.next= ().getClass()); assertEquals(OptimisticCreateIfNotExistsInterceptor.class, intercept= ors.next().getClass()); @@ -534,7 +534,7 @@ assertEquals(NotificationInterceptor.class, interceptors.next().getC= lass()); assertEquals(ReplicationInterceptor.class, interceptors.next().getCl= ass()); assertEquals(PessimisticLockInterceptor.class, interceptors.next().g= etClass()); - assertEquals(DataGravitatorInterceptor.class, interceptors.next().ge= tClass()); + assertEquals(LegacyDataGravitatorInterceptor.class, interceptors.nex= t().getClass()); assertEquals(CallInterceptor.class, interceptors.next().getClass()); = assertInterceptorLinkage(list); --===============8739036797077814852==-- From jbosscache-commits at lists.jboss.org Wed Aug 6 10:57:48 2008 Content-Type: multipart/mixed; boundary="===============3496960493947459119==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6530 - in core/trunk/src/main/java/org/jboss/cache/factories: context and 1 other directory. Date: Wed, 06 Aug 2008 10:57:47 -0400 Message-ID: --===============3496960493947459119== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-06 10:57:47 -0400 (Wed, 06 Aug 2008) New Revision: 6530 Added: core/trunk/src/main/java/org/jboss/cache/factories/ContextMetaFactory.ja= va Removed: core/trunk/src/main/java/org/jboss/cache/factories/context/ContextMetaFa= ctory.java Modified: core/trunk/src/main/java/org/jboss/cache/factories/CommandsMetaFactory.j= ava core/trunk/src/main/java/org/jboss/cache/factories/EmptyConstructorFacto= ry.java core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFacto= ry.java core/trunk/src/main/java/org/jboss/cache/factories/LockManagerFactory.ja= va core/trunk/src/main/java/org/jboss/cache/factories/NodeMetaFactory.java core/trunk/src/main/java/org/jboss/cache/factories/RegionManagerFactory.= java core/trunk/src/main/java/org/jboss/cache/factories/RuntimeConfigAwareFac= tory.java core/trunk/src/main/java/org/jboss/cache/factories/StateTransferFactory.= java core/trunk/src/main/java/org/jboss/cache/factories/StateTransferManagerF= actory.java core/trunk/src/main/java/org/jboss/cache/factories/TransactionManagerFac= tory.java core/trunk/src/main/java/org/jboss/cache/factories/context/OptimisticCon= textFactory.java core/trunk/src/main/java/org/jboss/cache/factories/context/PessimisticCo= ntextFactory.java Log: Cleaned up ugly generic casts in factories Modified: core/trunk/src/main/java/org/jboss/cache/factories/CommandsMetaFa= ctory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/factories/CommandsMetaFactory.= java 2008-08-06 14:42:03 UTC (rev 6529) +++ core/trunk/src/main/java/org/jboss/cache/factories/CommandsMetaFactory.= java 2008-08-06 14:57:47 UTC (rev 6530) @@ -16,17 +16,17 @@ @DefaultFactoryFor(classes =3D CommandsFactory.class) public class CommandsMetaFactory extends ComponentFactory { - @SuppressWarnings("unchecked") + @SuppressWarnings("deprecation") protected T construct(Class componentType) { switch (configuration.getNodeLockingScheme()) { case MVCC: - return (T) new CommandsFactoryImpl(); + return componentType.cast(new CommandsFactoryImpl()); case OPTIMISTIC: - return (T) new OptimisticCommandsFactoryImpl(); + return componentType.cast(new OptimisticCommandsFactoryImpl()); case PESSIMISTIC: - return (T) new PessimisticCommandsFactoryImpl(); + return componentType.cast(new PessimisticCommandsFactoryImpl()= ); } throw new ConfigurationException("Unknown locking scheme " + configu= ration.getNodeLockingScheme()); } Copied: core/trunk/src/main/java/org/jboss/cache/factories/ContextMetaFacto= ry.java (from rev 6527, core/trunk/src/main/java/org/jboss/cache/factories/= context/ContextMetaFactory.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/factories/ContextMetaFactory.j= ava (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/factories/ContextMetaFactory.j= ava 2008-08-06 14:57:47 UTC (rev 6530) @@ -0,0 +1,37 @@ +package org.jboss.cache.factories; + +import org.jboss.cache.config.ConfigurationException; +import org.jboss.cache.factories.annotations.DefaultFactoryFor; +import org.jboss.cache.factories.context.ContextFactory; +import org.jboss.cache.factories.context.MVCCContextFactory; +import org.jboss.cache.factories.context.OptimisticContextFactory; +import org.jboss.cache.factories.context.PessimisticContextFactory; + +/** + * Responsible for creating the appropriate {@link org.jboss.cache.factori= es.context.ContextFactory} based on configuration used. + * + * @author Manik Surtani (manik(a)jbo= ss.org) + * @since 3.0 + */ +(a)DefaultFactoryFor(classes =3D ContextFactory.class) +public class ContextMetaFactory extends ComponentFactory +{ + @SuppressWarnings("deprecation") + protected T construct(Class componentType) + { + if (log.isTraceEnabled()) log.trace("Cache configuration is " + conf= iguration.getNodeLockingScheme()); + switch (configuration.getNodeLockingScheme()) + { + case MVCC: + if (log.isTraceEnabled()) log.trace("Creating an MVCC context = factory"); + return componentType.cast(new MVCCContextFactory()); + case OPTIMISTIC: + if (log.isTraceEnabled()) log.trace("Creating an optimistic co= ntext factory"); + return componentType.cast(new OptimisticContextFactory()); + case PESSIMISTIC: + if (log.isTraceEnabled()) log.trace("Creating a pessimistic co= ntext factory"); + return componentType.cast(new PessimisticContextFactory()); + } + throw new ConfigurationException("Unknown configuration node locking= scheme"); + } +} Modified: core/trunk/src/main/java/org/jboss/cache/factories/EmptyConstruct= orFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/factories/EmptyConstructorFact= ory.java 2008-08-06 14:42:03 UTC (rev 6529) +++ core/trunk/src/main/java/org/jboss/cache/factories/EmptyConstructorFact= ory.java 2008-08-06 14:57:47 UTC (rev 6530) @@ -29,7 +29,6 @@ public class EmptyConstructorFactory extends ComponentFactory { @Override - @SuppressWarnings("unchecked") protected T construct(Class componentType) { try @@ -47,7 +46,7 @@ componentImpl =3D getClass().getClassLoader().loadClass(com= ponentType.getName() + "Impl"); } = - return (T) componentImpl.newInstance(); + return componentType.cast(componentImpl.newInstance()); } else { Modified: core/trunk/src/main/java/org/jboss/cache/factories/InterceptorCha= inFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFact= ory.java 2008-08-06 14:42:03 UTC (rev 6529) +++ core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFact= ory.java 2008-08-06 14:57:47 UTC (rev 6530) @@ -193,12 +193,11 @@ } = @Override - @SuppressWarnings("unchecked") protected T construct(Class componentType) { try { - return (T) buildInterceptorChain(); + return componentType.cast(buildInterceptorChain()); } catch (Exception e) { Modified: core/trunk/src/main/java/org/jboss/cache/factories/LockManagerFac= tory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/factories/LockManagerFactory.j= ava 2008-08-06 14:42:03 UTC (rev 6529) +++ core/trunk/src/main/java/org/jboss/cache/factories/LockManagerFactory.j= ava 2008-08-06 14:57:47 UTC (rev 6530) @@ -16,19 +16,19 @@ public class LockManagerFactory extends EmptyConstructorFactory { @Override - @SuppressWarnings({"unchecked", "deprecation"}) + @SuppressWarnings("deprecation") protected T construct(Class componentType) { if (log.isTraceEnabled()) log.trace("Cache configuration is " + conf= iguration.getNodeLockingScheme()); switch (configuration.getNodeLockingScheme()) { case MVCC: - return (T) super.construct(MVCCLockManager.class); + return componentType.cast(super.construct(MVCCLockManager.clas= s)); case OPTIMISTIC: - return (T) super.construct(NodeBasedLockManager.class); + return componentType.cast(super.construct(NodeBasedLockManager= .class)); case PESSIMISTIC: default: - return (T) super.construct(PessimisticNodeBasedLockManager.cla= ss); + return componentType.cast(super.construct(PessimisticNodeBased= LockManager.class)); } } } Modified: core/trunk/src/main/java/org/jboss/cache/factories/NodeMetaFactor= y.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/factories/NodeMetaFactory.java= 2008-08-06 14:42:03 UTC (rev 6529) +++ core/trunk/src/main/java/org/jboss/cache/factories/NodeMetaFactory.java= 2008-08-06 14:57:47 UTC (rev 6530) @@ -16,17 +16,17 @@ @DefaultFactoryFor(classes =3D NodeFactory.class) public class NodeMetaFactory extends ComponentFactory { - @SuppressWarnings("unchecked") + @SuppressWarnings("deprecation") protected T construct(Class componentType) { switch (configuration.getNodeLockingScheme()) { case MVCC: - return (T) new MVCCNodeFactory(); + return componentType.cast(new MVCCNodeFactory()); case OPTIMISTIC: - return (T) new OptimisticNodeFactory(); + return componentType.cast(new OptimisticNodeFactory()); case PESSIMISTIC: - return (T) new PessimisticNodeFactory(); + return componentType.cast(new PessimisticNodeFactory()); default: throw new ConfigurationException("Unknown locking scheme " + c= onfiguration.getNodeLockingScheme()); } Modified: core/trunk/src/main/java/org/jboss/cache/factories/RegionManagerF= actory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/factories/RegionManagerFactory= .java 2008-08-06 14:42:03 UTC (rev 6529) +++ core/trunk/src/main/java/org/jboss/cache/factories/RegionManagerFactory= .java 2008-08-06 14:57:47 UTC (rev 6530) @@ -14,15 +14,15 @@ @DefaultFactoryFor(classes =3D RegionManager.class) public class RegionManagerFactory extends ComponentFactory { - @SuppressWarnings("unchecked") + @SuppressWarnings("deprecation") protected T construct(Class componentType) { switch (configuration.getNodeLockingScheme()) { case MVCC: - return (T) new RegionManagerImpl(); + return componentType.cast(new RegionManagerImpl()); default: - return (T) new LegacyRegionManagerImpl(); + return componentType.cast(new LegacyRegionManagerImpl()); } } } \ No newline at end of file Modified: core/trunk/src/main/java/org/jboss/cache/factories/RuntimeConfigA= wareFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/factories/RuntimeConfigAwareFa= ctory.java 2008-08-06 14:42:03 UTC (rev 6529) +++ core/trunk/src/main/java/org/jboss/cache/factories/RuntimeConfigAwareFa= ctory.java 2008-08-06 14:57:47 UTC (rev 6530) @@ -18,7 +18,6 @@ public class RuntimeConfigAwareFactory extends EmptyConstructorFactory { @Override - @SuppressWarnings("unchecked") protected T construct(Class componentType) { T component =3D super.construct(componentType); Modified: core/trunk/src/main/java/org/jboss/cache/factories/StateTransferF= actory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/factories/StateTransferFactory= .java 2008-08-06 14:42:03 UTC (rev 6529) +++ core/trunk/src/main/java/org/jboss/cache/factories/StateTransferFactory= .java 2008-08-06 14:57:47 UTC (rev 6530) @@ -28,17 +28,17 @@ @DefaultFactoryFor(classes =3D {StateTransferGenerator.class, StateTransfe= rIntegrator.class}) public class StateTransferFactory extends ComponentFactory { + @SuppressWarnings("deprecation") protected T construct(Class componentType) { - if (componentType.equals(StateTransferIntegrator.class)) { switch (configuration.getNodeLockingScheme()) { case MVCC: - return (T) new DefaultStateTransferIntegrator(); + return componentType.cast(new DefaultStateTransferIntegrato= r()); default: - return (T) new LegacyStateTransferIntegrator(); + return componentType.cast(new LegacyStateTransferIntegrator= ()); } } else @@ -46,9 +46,9 @@ switch (configuration.getNodeLockingScheme()) { case MVCC: - return (T) new DefaultStateTransferGenerator(); + return componentType.cast(new DefaultStateTransferGenerator= ()); default: - return (T) new LegacyStateTransferGenerator(); + return componentType.cast(new LegacyStateTransferGenerator(= )); } } } Modified: core/trunk/src/main/java/org/jboss/cache/factories/StateTransferM= anagerFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/factories/StateTransferManager= Factory.java 2008-08-06 14:42:03 UTC (rev 6529) +++ core/trunk/src/main/java/org/jboss/cache/factories/StateTransferManager= Factory.java 2008-08-06 14:57:47 UTC (rev 6530) @@ -14,15 +14,15 @@ @DefaultFactoryFor(classes =3D StateTransferManager.class) public class StateTransferManagerFactory extends ComponentFactory { - @SuppressWarnings("unchecked") + @SuppressWarnings("deprecation") protected T construct(Class componentType) { switch (configuration.getNodeLockingScheme()) { case MVCC: - return (T) new DefaultStateTransferManager(); + return componentType.cast(new DefaultStateTransferManager()); default: - return (T) new LegacyStateTransferManager(); + return componentType.cast(new LegacyStateTransferManager()); } } } Modified: core/trunk/src/main/java/org/jboss/cache/factories/TransactionMan= agerFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/factories/TransactionManagerFa= ctory.java 2008-08-06 14:42:03 UTC (rev 6529) +++ core/trunk/src/main/java/org/jboss/cache/factories/TransactionManagerFa= ctory.java 2008-08-06 14:57:47 UTC (rev 6530) @@ -15,7 +15,6 @@ @DefaultFactoryFor(classes =3D {TransactionManager.class}) public class TransactionManagerFactory extends ComponentFactory { - @SuppressWarnings("unchecked") protected T construct(Class componentType) { // See if we had a TransactionManager injected into our config @@ -53,6 +52,6 @@ log.info("failed looking up TransactionManager, will not use t= ransactions", e); } } - return (T) transactionManager; + return componentType.cast(transactionManager); } } Deleted: core/trunk/src/main/java/org/jboss/cache/factories/context/Context= MetaFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/factories/context/ContextMetaF= actory.java 2008-08-06 14:42:03 UTC (rev 6529) +++ core/trunk/src/main/java/org/jboss/cache/factories/context/ContextMetaF= actory.java 2008-08-06 14:57:47 UTC (rev 6530) @@ -1,34 +0,0 @@ -package org.jboss.cache.factories.context; - -import org.jboss.cache.config.ConfigurationException; -import org.jboss.cache.factories.ComponentFactory; -import org.jboss.cache.factories.annotations.DefaultFactoryFor; - -/** - * Responsible for creating the appropriate {@link ContextFactory} based o= n configuration used. - * - * @author Manik Surtani (manik(a)jbo= ss.org) - * @since 3.0 - */ -(a)DefaultFactoryFor(classes =3D ContextFactory.class) -public class ContextMetaFactory extends ComponentFactory -{ - @SuppressWarnings("unchecked") - protected T construct(Class componentType) - { - if (log.isTraceEnabled()) log.trace("Cache configuration is " + conf= iguration.getNodeLockingScheme()); - switch (configuration.getNodeLockingScheme()) - { - case MVCC: - if (log.isTraceEnabled()) log.trace("Creating an MVCC context = factory"); - return (T) new MVCCContextFactory(); - case OPTIMISTIC: - if (log.isTraceEnabled()) log.trace("Creating an optimistic co= ntext factory"); - return (T) new OptimisticContextFactory(); - case PESSIMISTIC: - if (log.isTraceEnabled()) log.trace("Creating a pessimistic co= ntext factory"); - return (T) new PessimisticContextFactory(); - } - throw new ConfigurationException("Unknown configuration node locking= scheme"); - } -} Modified: core/trunk/src/main/java/org/jboss/cache/factories/context/Optimi= sticContextFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/factories/context/OptimisticCo= ntextFactory.java 2008-08-06 14:42:03 UTC (rev 6529) +++ core/trunk/src/main/java/org/jboss/cache/factories/context/OptimisticCo= ntextFactory.java 2008-08-06 14:57:47 UTC (rev 6530) @@ -12,7 +12,10 @@ * * @author Manik Surtani (manik(a)jbo= ss.org) * @since 3.0 + * @deprecated will be removed when optimistic locking is removed. */ +(a)Deprecated +(a)SuppressWarnings("deprecation") public class OptimisticContextFactory extends PessimisticContextFactory { @Override Modified: core/trunk/src/main/java/org/jboss/cache/factories/context/Pessim= isticContextFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/factories/context/PessimisticC= ontextFactory.java 2008-08-06 14:42:03 UTC (rev 6529) +++ core/trunk/src/main/java/org/jboss/cache/factories/context/PessimisticC= ontextFactory.java 2008-08-06 14:57:47 UTC (rev 6530) @@ -16,7 +16,10 @@ * * @author Manik Surtani (manik(a)jbo= ss.org) * @since 3.0 + * @deprecated will be removed when pessimistic locking is removed. */ +(a)Deprecated +(a)SuppressWarnings("deprecation") public class PessimisticContextFactory implements ContextFactory { DataContainer container; --===============3496960493947459119==-- From jbosscache-commits at lists.jboss.org Wed Aug 6 10:58:15 2008 Content-Type: multipart/mixed; boundary="===============5345397349852635456==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6531 - core/trunk/src/main/java/org/jboss/cache/factories. Date: Wed, 06 Aug 2008 10:58:15 -0400 Message-ID: --===============5345397349852635456== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-06 10:58:15 -0400 (Wed, 06 Aug 2008) New Revision: 6531 Modified: core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java Log: Cleaned up ugly generic casts in factories Modified: core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegis= try.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.ja= va 2008-08-06 14:57:47 UTC (rev 6530) +++ core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.ja= va 2008-08-06 14:58:15 UTC (rev 6531) @@ -15,7 +15,6 @@ import org.jboss.cache.factories.annotations.NonVolatile; import org.jboss.cache.factories.annotations.Start; import org.jboss.cache.factories.annotations.Stop; -import org.jboss.cache.factories.context.ContextMetaFactory; import org.jboss.cache.util.BeanUtils; import org.jboss.cache.util.reflect.ReflectionUtil; = --===============5345397349852635456==-- From jbosscache-commits at lists.jboss.org Wed Aug 6 11:52:03 2008 Content-Type: multipart/mixed; boundary="===============7010537659095114419==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6532 - benchmarks/benchmark-fwk/trunk. Date: Wed, 06 Aug 2008 11:52:03 -0400 Message-ID: --===============7010537659095114419== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-06 11:52:03 -0400 (Wed, 06 Aug 2008) New Revision: 6532 Modified: benchmarks/benchmark-fwk/trunk/runNode.sh Log: increased memory size Modified: benchmarks/benchmark-fwk/trunk/runNode.sh =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- benchmarks/benchmark-fwk/trunk/runNode.sh 2008-08-06 14:58:15 UTC (rev = 6531) +++ benchmarks/benchmark-fwk/trunk/runNode.sh 2008-08-06 15:52:03 UTC (rev = 6532) @@ -2,6 +2,9 @@ # author: Mircea.Markus(a)jboss.com # cygwin users: add the scripts from :pserver:anoncvs(a)cygwin.com:/cvs/cy= gwin-apps/wrappers/java to the $cygwin_home/usr/local/bin # those would make an automatic conversion from unix CLASSPATH to win clas= spath, needed when executing java -cp +# todo mmarkus - add another configuration file to set all the jvm params,= which should be called by this one (phps benchmatrk-jvm.sh) +# todo mmarkus - move the scripts in an bin directory as there are more an= d more scrips now +# todo mmarkus - if allJbossCacheTests.sh is launched with nohup it does n= ot work, make that work = preferIPv4Stack=3Dtrue DEBUG=3Ddebug --===============7010537659095114419==-- From jbosscache-commits at lists.jboss.org Wed Aug 6 12:05:01 2008 Content-Type: multipart/mixed; boundary="===============5103622779698443563==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6533 - benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/lib. Date: Wed, 06 Aug 2008 12:04:59 -0400 Message-ID: --===============5103622779698443563== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-06 12:04:59 -0400 (Wed, 06 Aug 2008) New Revision: 6533 Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/lib/jboss= cache-core.jar Log: updated lib Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/li= b/jbosscache-core.jar =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) --===============5103622779698443563==-- From jbosscache-commits at lists.jboss.org Wed Aug 6 12:14:05 2008 Content-Type: multipart/mixed; boundary="===============3815171948476281274==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6534 - core/trunk/src/main/resources/config-samples. Date: Wed, 06 Aug 2008 12:14:05 -0400 Message-ID: --===============3815171948476281274== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-06 12:14:04 -0400 (Wed, 06 Aug 2008) New Revision: 6534 Added: core/trunk/src/main/resources/config-samples/total-replication.xml Modified: core/trunk/src/main/resources/config-samples/buddy-replication.xml core/trunk/src/main/resources/config-samples/invalidation-async.xml Log: updated configuration files Modified: core/trunk/src/main/resources/config-samples/buddy-replication.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/resources/config-samples/buddy-replication.xml 2008= -08-06 16:04:59 UTC (rev 6533) +++ core/trunk/src/main/resources/config-samples/buddy-replication.xml 2008= -08-06 16:14:04 UTC (rev 6534) @@ -28,7 +28,7 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + --===============3815171948476281274==-- From jbosscache-commits at lists.jboss.org Wed Aug 6 12:17:53 2008 Content-Type: multipart/mixed; boundary="===============7510427103830107046==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6535 - benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests. Date: Wed, 06 Aug 2008 12:17:53 -0400 Message-ID: --===============7510427103830107046== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-06 12:17:53 -0400 (Wed, 06 Aug 2008) New Revision: 6535 Modified: benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/SessionSimulator= Test.java Log: increased memory size Modified: benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/SessionSi= mulatorTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/SessionSimulato= rTest.java 2008-08-06 16:14:04 UTC (rev 6534) +++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/SessionSimulato= rTest.java 2008-08-06 16:17:53 UTC (rev 6535) @@ -15,6 +15,7 @@ /** * Simulates work with a web session. * + * todo mmarkus - improve the test to support multiple threads. Correlate = this with usage of message_bundling in JBC * @author Mircea.Markus(a)jboss.com * @since 2.2 */ --===============7510427103830107046==-- From jboss-qa-internal at redhat.com Wed Aug 6 14:29:33 2008 Content-Type: multipart/mixed; boundary="===============4140890877105668009==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23540?= Date: Wed, 06 Aug 2008 14:29:29 -0400 Message-ID: <159159726.17321218047369583.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 228017621.16231218006938506.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============4140890877105668009== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/540/changes --===============4140890877105668009==-- From jboss-qa-internal at redhat.com Wed Aug 6 15:19:20 2008 Content-Type: multipart/mixed; boundary="===============3541440075616435454==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23407?= Date: Wed, 06 Aug 2008 15:19:18 -0400 Message-ID: <2036517513.17481218050358521.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 115549049.16281218009410492.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============3541440075616435454== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/407/changes --===============3541440075616435454==-- From jbosscache-commits at lists.jboss.org Thu Aug 7 00:21:38 2008 Content-Type: multipart/mixed; boundary="===============6090494407234560620==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6536 - in core/trunk/src: main/java/org/jboss/cache/buddyreplication and 8 other directories. Date: Thu, 07 Aug 2008 00:21:37 -0400 Message-ID: --===============6090494407234560620== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: jason.greene(a)jboss.com Date: 2008-08-07 00:21:36 -0400 (Thu, 07 Aug 2008) New Revision: 6536 Added: core/trunk/src/main/java/org/jboss/cache/util/Immutables.java Removed: core/trunk/src/main/java/org/jboss/cache/util/ImmutableMapCopy.java core/trunk/src/main/java/org/jboss/cache/util/ImmutableSetCopy.java Modified: core/trunk/src/main/java/org/jboss/cache/Fqn.java core/trunk/src/main/java/org/jboss/cache/PessimisticUnversionedNode.java core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyGroup.java core/trunk/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand= .java core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationCo= ntext.java core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDeleg= ate.java core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java core/trunk/src/main/java/org/jboss/cache/loader/AsyncCacheLoader.java core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java core/trunk/src/main/java/org/jboss/cache/transaction/AbstractTransaction= Context.java core/trunk/src/main/java/org/jboss/cache/util/ImmutableListCopy.java core/trunk/src/test/java/org/jboss/cache/util/ImmutableListCopyTest.java Log: Convert all immutable usage to new Immutables factory. Drop ImmutableMapCopy and ImmutableSetCopy in favor of map/set wrappers Add immutable wrappers which are detectable (unlike Collections.unmodifiabl= e*) Modified: core/trunk/src/main/java/org/jboss/cache/Fqn.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/Fqn.java 2008-08-06 16:17:53 U= TC (rev 6535) +++ core/trunk/src/main/java/org/jboss/cache/Fqn.java 2008-08-07 04:21:36 U= TC (rev 6536) @@ -7,9 +7,6 @@ package org.jboss.cache; = = -import net.jcip.annotations.Immutable; -import org.jboss.cache.util.ImmutableListCopy; - import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; @@ -19,6 +16,10 @@ import java.util.Collections; import java.util.List; = +import net.jcip.annotations.Immutable; + +import org.jboss.cache.util.Immutables; + /** * A Fully Qualified Name (Fqn) is a list of names (typically Strings but = can be any Object), * which represent a path to a particular {@link Node} or sometimes a {@li= nk Region} in a {@link Cache}. @@ -114,7 +115,7 @@ if (names !=3D null) { // if not safe make a defensive copy - elements =3D safe ? names : new ImmutableListCopy(names); + elements =3D safe ? names : Immutables.immutableListCopy(names); size =3D elements.size(); } else @@ -126,7 +127,7 @@ = protected Fqn(Fqn base, List relative) { - elements =3D new ImmutableListCopy(base.elements, relative); + elements =3D Immutables.immutableListMerge(base.elements, relative); size =3D elements.size(); } = @@ -232,8 +233,8 @@ return root(); = String toMatch =3D stringRepresentation.startsWith(SEPARATOR) ? stri= ngRepresentation.substring(1) : stringRepresentation; - Object[] el =3D toMatch.split("/"); - return new Fqn(new ImmutableListCopy(el), true); + Object[] el =3D toMatch.split(SEPARATOR); + return new Fqn(Immutables.immutableListWrap(el), true); } = /** Modified: core/trunk/src/main/java/org/jboss/cache/PessimisticUnversionedNo= de.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/PessimisticUnversionedNode.jav= a 2008-08-06 16:17:53 UTC (rev 6535) +++ core/trunk/src/main/java/org/jboss/cache/PessimisticUnversionedNode.jav= a 2008-08-07 04:21:36 UTC (rev 6536) @@ -1,6 +1,13 @@ package org.jboss.cache; = import static org.jboss.cache.AbstractNode.NodeFlags.VALID; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentMap; + import org.jboss.cache.commands.CommandsFactory; import org.jboss.cache.commands.legacy.write.CreateNodeCommand; import org.jboss.cache.invocation.InvocationContext; @@ -9,14 +16,8 @@ import org.jboss.cache.marshall.MarshalledValue; import org.jboss.cache.transaction.GlobalTransaction; import org.jboss.cache.util.FastCopyHashMap; -import org.jboss.cache.util.ImmutableSetCopy; +import org.jboss.cache.util.Immutables; = -import java.util.Collections; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentMap; - /** * UnversionedNode specific to pessimistic locking, with legacy code. * @@ -290,7 +291,7 @@ { if (children !=3D null && !children.isEmpty()) { - return new ImmutableSetCopy(children.values()); + return Immutables.immutableSetConvert(children.values()); } else { Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-08-0= 6 16:17:53 UTC (rev 6535) +++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-08-0= 7 04:21:36 UTC (rev 6536) @@ -6,13 +6,11 @@ */ package org.jboss.cache; = -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import static org.jboss.cache.AbstractNode.NodeFlags.*; -import org.jboss.cache.marshall.MarshalledValue; -import org.jboss.cache.util.FastCopyHashMap; -import org.jboss.cache.util.ImmutableSetCopy; -import org.jboss.cache.util.concurrent.SelfInitializingConcurrentHashMap; +import static org.jboss.cache.AbstractNode.NodeFlags.CHILDREN_LOADED; +import static org.jboss.cache.AbstractNode.NodeFlags.DATA_LOADED; +import static org.jboss.cache.AbstractNode.NodeFlags.LOCK_FOR_CHILD_INSERT= _REMOVE; +import static org.jboss.cache.AbstractNode.NodeFlags.REMOVED; +import static org.jboss.cache.AbstractNode.NodeFlags.VALID; = import java.util.Collections; import java.util.HashMap; @@ -22,6 +20,13 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; = +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.cache.marshall.MarshalledValue; +import org.jboss.cache.util.FastCopyHashMap; +import org.jboss.cache.util.Immutables; +import org.jboss.cache.util.concurrent.SelfInitializingConcurrentHashMap; + /** * Basic data node class. Throws {@link UnsupportedOperationException} fo= r version-specific methods like {@link #getVersion()} and * {@link #setVersion(org.jboss.cache.optimistic.DataVersion)}, defined in= {@link org.jboss.cache.NodeSPI}. @@ -208,7 +213,7 @@ { if (!children.isEmpty()) { - return new ImmutableSetCopy>(children().val= ues()); + return Immutables.immutableSetConvert(children().values()); } else { @@ -370,9 +375,10 @@ if (data !=3D null) data.clear(); } = + @SuppressWarnings("unchecked") public Set getChildrenNames() { - return children.isEmpty() ? Collections.emptySet() : new ImmutableSe= tCopy(children.keySet()); + return children.isEmpty() ? Collections.emptySet() : Immutables.immu= tableSetCopy(children.keySet()); } = public Set getKeys() @@ -381,7 +387,7 @@ { return Collections.emptySet(); } - return new ImmutableSetCopy(data.keySet()); + return Immutables.immutableSetCopy(data.keySet()); } = public boolean removeChild(Object childName) Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyGr= oup.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyGroup.ja= va 2008-08-06 16:17:53 UTC (rev 6535) +++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyGroup.ja= va 2008-08-07 04:21:36 UTC (rev 6536) @@ -6,16 +6,17 @@ */ package org.jboss.cache.buddyreplication; = -import net.jcip.annotations.ThreadSafe; -import org.jboss.cache.util.ImmutableListCopy; -import org.jgroups.Address; - import java.io.Serializable; import java.util.Collection; import java.util.Date; import java.util.List; import java.util.Vector; = +import net.jcip.annotations.ThreadSafe; + +import org.jboss.cache.util.Immutables; +import org.jgroups.Address; + /** * Value object that represents a buddy group * @@ -65,7 +66,7 @@ public List
getBuddies() { // defensive copy and immutable. - return new ImmutableListCopy
(buddies); + return Immutables.immutableListCopy(buddies); } = protected void addBuddies(Collection
buddies) Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GetDataMap= Command.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/read/GetDataMapComman= d.java 2008-08-06 16:17:53 UTC (rev 6535) +++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetDataMapComman= d.java 2008-08-07 04:21:36 UTC (rev 6536) @@ -4,7 +4,7 @@ import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.Visitor; import org.jboss.cache.invocation.InvocationContext; -import org.jboss.cache.util.ImmutableMapCopy; +import org.jboss.cache.util.Immutables; = /** * Implements functionality defined by {@link org.jboss.cache.Cache#getDat= a(org.jboss.cache.Fqn)} @@ -35,9 +35,9 @@ */ public Object perform(InvocationContext ctx) { - NodeSPI n =3D ctx.lookUpNode(fqn); + NodeSPI n =3D ctx.lookUpNode(fqn); if (n =3D=3D null || n.isDeleted()) return null; - return new ImmutableMapCopy(n.getDataDirect()); + return Immutables.immutableMapCopy(n.getDataDirect()); } = public Object acceptVisitor(InvocationContext ctx, Visitor visitor) thr= ows Throwable Modified: core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvoc= ationContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationC= ontext.java 2008-08-06 16:17:53 UTC (rev 6535) +++ core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationC= ontext.java 2008-08-07 04:21:36 UTC (rev 6536) @@ -6,6 +6,12 @@ */ package org.jboss.cache.invocation; = +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.List; + +import javax.transaction.Transaction; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.commands.VisitableCommand; @@ -14,13 +20,8 @@ import org.jboss.cache.transaction.GlobalTransaction; import org.jboss.cache.transaction.TransactionContext; import org.jboss.cache.transaction.TransactionTable; -import org.jboss.cache.util.ImmutableListCopy; +import org.jboss.cache.util.Immutables; = -import javax.transaction.Transaction; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.List; - /** * This context holds information specific to a method invocation. This i= s used for Optimistic and Pessimisic Node Locking Schemes. * @@ -117,7 +118,7 @@ { // first check transactional scope if (transactionContext !=3D null) return transactionContext.getLocks= (); - return invocationLocks =3D=3D null || invocationLocks.isEmpty() ? Co= llections.emptyList() : new ImmutableListCopy(invocationLocks); + return invocationLocks =3D=3D null || invocationLocks.isEmpty() ? Co= llections.emptyList() : Immutables.immutableListConvert(invocationLocks); } = @SuppressWarnings("unchecked") Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocati= onDelegate.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDele= gate.java 2008-08-06 16:17:53 UTC (rev 6535) +++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDele= gate.java 2008-08-07 04:21:36 UTC (rev 6536) @@ -1,5 +1,13 @@ package org.jboss.cache.invocation; = +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.transaction.Transaction; +import javax.transaction.TransactionManager; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.CacheException; @@ -31,8 +39,8 @@ import org.jboss.cache.commands.write.RemoveKeyCommand; import org.jboss.cache.commands.write.RemoveNodeCommand; import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.Option; import org.jboss.cache.config.Configuration.NodeLockingScheme; -import org.jboss.cache.config.Option; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.NonVolatile; import org.jboss.cache.factories.annotations.Start; @@ -44,16 +52,9 @@ import org.jboss.cache.statetransfer.StateTransferManager; import org.jboss.cache.transaction.GlobalTransaction; import org.jboss.cache.transaction.TransactionTable; -import org.jboss.cache.util.ImmutableSetCopy; +import org.jboss.cache.util.Immutables; import org.jgroups.Address; = -import javax.transaction.Transaction; -import javax.transaction.TransactionManager; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; - /** * The delegate that users (and ChainedInterceptor authors) interact with = when they create a cache by using a cache factory. * This wrapper delegates calls down the interceptor chain. @@ -589,7 +590,7 @@ GetChildrenNamesCommand command =3D commandsFactory.buildGetChildren= NamesCommand(fqn); Set retval =3D (Set) invoker.invoke(ctx, command); if (retval !=3D null) - retval =3D new ImmutableSetCopy(retval); + retval =3D Immutables.immutableSetWrap(retval); // this is alread= y copied in the command else retval =3D Collections.emptySet(); return retval; Modified: core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoad= er.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.jav= a 2008-08-06 16:17:53 UTC (rev 6535) +++ core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.jav= a 2008-08-07 04:21:36 UTC (rev 6536) @@ -6,6 +6,14 @@ */ package org.jboss.cache.loader; = +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.CacheException; @@ -20,16 +28,8 @@ import org.jboss.cache.marshall.NodeData; import org.jboss.cache.marshall.NodeDataExceptionMarker; import org.jboss.cache.marshall.NodeDataMarker; -import org.jboss.cache.util.ImmutableMapCopy; +import org.jboss.cache.util.Immutables; = -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - /** * A convenience abstract implementation of a {@link CacheLoader}. Specif= ic methods to note are methods like * {@link #storeState(org.jboss.cache.Fqn,java.io.ObjectInputStream)}, {@l= ink #loadState(org.jboss.cache.Fqn,java.io.ObjectOutputStream)}, @@ -64,7 +64,7 @@ } = // JBCACHE-769 -- make a defensive copy - Map attrs =3D (attributes =3D=3D null ? null : new I= mmutableMapCopy(attributes)); + Map attrs =3D (attributes =3D=3D null ? null : Immut= ables.immutableMapCopy(attributes)); put(fqn, attrs); } = Modified: core/trunk/src/main/java/org/jboss/cache/loader/AsyncCacheLoader.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/loader/AsyncCacheLoader.java 2= 008-08-06 16:17:53 UTC (rev 6535) +++ core/trunk/src/main/java/org/jboss/cache/loader/AsyncCacheLoader.java 2= 008-08-07 04:21:36 UTC (rev 6536) @@ -3,14 +3,6 @@ */ package org.jboss.cache.loader; = -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jboss.cache.CacheException; -import org.jboss.cache.Fqn; -import org.jboss.cache.Modification; -import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfi= g; -import org.jboss.cache.util.ImmutableMapCopy; - import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -26,6 +18,14 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; = +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.cache.CacheException; +import org.jboss.cache.Fqn; +import org.jboss.cache.Modification; +import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfi= g; +import org.jboss.cache.util.Immutables; + /** * The AsyncCacheLoader is a delegating cache loader that extends * AbstractDelegatingCacheLoader overriding methods to that should not @@ -191,7 +191,7 @@ if (config.getUseAsyncPut()) { // JBCACHE-769 -- make a defensive copy - Map attrs =3D (attributes =3D=3D null ? null : new ImmutableMapCo= py(attributes)); + Map attrs =3D (attributes =3D=3D null ? null : Immutables.immutab= leMapCopy(attributes)); Modification mod =3D new Modification(Modification.ModificationTy= pe.PUT_DATA, name, attrs); enqueue(mod); } Modified: core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller= 200.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.ja= va 2008-08-06 16:17:53 UTC (rev 6535) +++ core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.ja= va 2008-08-07 04:21:36 UTC (rev 6536) @@ -6,20 +6,6 @@ */ package org.jboss.cache.marshall; = -import org.jboss.cache.Fqn; -import org.jboss.cache.Region; -import static org.jboss.cache.Region.Status; -import org.jboss.cache.buddyreplication.GravitateResult; -import org.jboss.cache.commands.CommandsFactory; -import org.jboss.cache.commands.ReplicableCommand; -import org.jboss.cache.factories.annotations.Inject; -import org.jboss.cache.optimistic.DefaultDataVersion; -import org.jboss.cache.transaction.GlobalTransaction; -import org.jboss.cache.util.FastCopyHashMap; -import org.jboss.cache.util.ImmutableMapCopy; -import org.jgroups.Address; -import org.jgroups.stack.IpAddress; - import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInputStream; @@ -36,6 +22,20 @@ import java.util.TreeMap; import java.util.TreeSet; = +import org.jboss.cache.Fqn; +import org.jboss.cache.Region; +import org.jboss.cache.Region.Status; +import org.jboss.cache.buddyreplication.GravitateResult; +import org.jboss.cache.commands.CommandsFactory; +import org.jboss.cache.commands.ReplicableCommand; +import org.jboss.cache.factories.annotations.Inject; +import org.jboss.cache.optimistic.DefaultDataVersion; +import org.jboss.cache.transaction.GlobalTransaction; +import org.jboss.cache.util.FastCopyHashMap; +import org.jboss.cache.util.Immutables; +import org.jgroups.Address; +import org.jgroups.stack.IpAddress; + /** * An enhanced marshaller for RPC calls between CacheImpl instances. * @@ -349,7 +349,7 @@ out.writeByte(MAGICNUMBER_FASTCOPY_HASHMAP); marshallMap((Map) o, out, refMap); } - else if (o.getClass().equals(ImmutableMapCopy.class)) + else if (o instanceof Map && Immutables.isImmutable(o)) { out.writeByte(MAGICNUMBER_IMMUTABLE_MAPCOPY); marshallMap((Map) o, out, refMap); @@ -748,7 +748,7 @@ { // read in as a HashMap first Map m =3D unmarshallHashMap(in, refMap); - return new ImmutableMapCopy(m); + return Immutables.immutableMapWrap(m); } = private Map unmarshallTreeMap(ObjectInputStream in, UnmarshalledReferen= ces refMap) throws Exception Modified: core/trunk/src/main/java/org/jboss/cache/notifications/NotifierIm= pl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.jav= a 2008-08-06 16:17:53 UTC (rev 6535) +++ core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.jav= a 2008-08-07 04:21:36 UTC (rev 6536) @@ -6,6 +6,43 @@ */ package org.jboss.cache.notifications; = +import static org.jboss.cache.notifications.event.Event.Type.BUDDY_GROUP_C= HANGED; +import static org.jboss.cache.notifications.event.Event.Type.CACHE_BLOCKED; +import static org.jboss.cache.notifications.event.Event.Type.CACHE_STARTED; +import static org.jboss.cache.notifications.event.Event.Type.CACHE_STOPPED; +import static org.jboss.cache.notifications.event.Event.Type.CACHE_UNBLOCK= ED; +import static org.jboss.cache.notifications.event.Event.Type.NODE_ACTIVATE= D; +import static org.jboss.cache.notifications.event.Event.Type.NODE_CREATED; +import static org.jboss.cache.notifications.event.Event.Type.NODE_EVICTED; +import static org.jboss.cache.notifications.event.Event.Type.NODE_INVALIDA= TED; +import static org.jboss.cache.notifications.event.Event.Type.NODE_LOADED; +import static org.jboss.cache.notifications.event.Event.Type.NODE_MODIFIED; +import static org.jboss.cache.notifications.event.Event.Type.NODE_MOVED; +import static org.jboss.cache.notifications.event.Event.Type.NODE_PASSIVAT= ED; +import static org.jboss.cache.notifications.event.Event.Type.NODE_REMOVED; +import static org.jboss.cache.notifications.event.Event.Type.NODE_VISITED; +import static org.jboss.cache.notifications.event.Event.Type.TRANSACTION_C= OMPLETED; +import static org.jboss.cache.notifications.event.Event.Type.TRANSACTION_R= EGISTERED; +import static org.jboss.cache.notifications.event.Event.Type.VIEW_CHANGED; + +import java.lang.annotation.Annotation; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.atomic.AtomicInteger; + +import javax.transaction.Transaction; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.Cache; @@ -21,30 +58,49 @@ import org.jboss.cache.factories.annotations.Stop; import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.marshall.MarshalledValueMap; -import org.jboss.cache.notifications.annotation.*; -import org.jboss.cache.notifications.event.*; -import static org.jboss.cache.notifications.event.Event.Type.*; -import org.jboss.cache.util.ImmutableMapCopy; +import org.jboss.cache.notifications.annotation.BuddyGroupChanged; +import org.jboss.cache.notifications.annotation.CacheBlocked; +import org.jboss.cache.notifications.annotation.CacheListener; +import org.jboss.cache.notifications.annotation.CacheStarted; +import org.jboss.cache.notifications.annotation.CacheStopped; +import org.jboss.cache.notifications.annotation.CacheUnblocked; +import org.jboss.cache.notifications.annotation.NodeActivated; +import org.jboss.cache.notifications.annotation.NodeCreated; +import org.jboss.cache.notifications.annotation.NodeEvicted; +import org.jboss.cache.notifications.annotation.NodeInvalidated; +import org.jboss.cache.notifications.annotation.NodeLoaded; +import org.jboss.cache.notifications.annotation.NodeModified; +import org.jboss.cache.notifications.annotation.NodeMoved; +import org.jboss.cache.notifications.annotation.NodePassivated; +import org.jboss.cache.notifications.annotation.NodeRemoved; +import org.jboss.cache.notifications.annotation.NodeVisited; +import org.jboss.cache.notifications.annotation.TransactionCompleted; +import org.jboss.cache.notifications.annotation.TransactionRegistered; +import org.jboss.cache.notifications.annotation.ViewChanged; +import org.jboss.cache.notifications.event.BuddyGroupChangedEvent; +import org.jboss.cache.notifications.event.CacheBlockedEvent; +import org.jboss.cache.notifications.event.CacheStartedEvent; +import org.jboss.cache.notifications.event.CacheStoppedEvent; +import org.jboss.cache.notifications.event.CacheUnblockedEvent; +import org.jboss.cache.notifications.event.Event; +import org.jboss.cache.notifications.event.EventImpl; +import org.jboss.cache.notifications.event.NodeActivatedEvent; +import org.jboss.cache.notifications.event.NodeCreatedEvent; +import org.jboss.cache.notifications.event.NodeEvictedEvent; +import org.jboss.cache.notifications.event.NodeInvalidatedEvent; +import org.jboss.cache.notifications.event.NodeLoadedEvent; +import org.jboss.cache.notifications.event.NodeModifiedEvent; +import org.jboss.cache.notifications.event.NodeMovedEvent; +import org.jboss.cache.notifications.event.NodePassivatedEvent; +import org.jboss.cache.notifications.event.NodeRemovedEvent; +import org.jboss.cache.notifications.event.NodeVisitedEvent; +import org.jboss.cache.notifications.event.TransactionCompletedEvent; +import org.jboss.cache.notifications.event.TransactionRegisteredEvent; +import org.jboss.cache.notifications.event.ViewChangedEvent; +import org.jboss.cache.util.Immutables; import org.jboss.cache.util.concurrent.WithinThreadExecutor; import org.jgroups.View; = -import javax.transaction.Transaction; -import java.lang.annotation.Annotation; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.atomic.AtomicInteger; - /** * Helper class that handles all notifications to registered listeners. * @@ -606,7 +662,7 @@ if (data =3D=3D null) return null; if (data.isEmpty()) return Collections.emptyMap(); if (safe(data)) return useMarshalledValueMaps ? new MarshalledValueM= ap(data) : data; - Map defensivelyCopiedData =3D new ImmutableMapCopy(data); + Map defensivelyCopiedData =3D Immutables.immutableMapCopy(data); return useMarshalledValueMaps ? new MarshalledValueMap(defensivelyCo= piedData) : defensivelyCopiedData; } = @@ -643,7 +699,7 @@ */ private static boolean safe(Map map) { - return map =3D=3D null || map instanceof ImmutableMapCopy || map.get= Class().equals(emptyMap) || map.getClass().equals(singletonMap); + return map =3D=3D null || Immutables.isImmutable(map) || map.getClas= s().equals(emptyMap) || map.getClass().equals(singletonMap); } = /** Modified: core/trunk/src/main/java/org/jboss/cache/transaction/AbstractTran= sactionContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/transaction/AbstractTransactio= nContext.java 2008-08-06 16:17:53 UTC (rev 6535) +++ core/trunk/src/main/java/org/jboss/cache/transaction/AbstractTransactio= nContext.java 2008-08-07 04:21:36 UTC (rev 6536) @@ -7,21 +7,22 @@ package org.jboss.cache.transaction; = = -import org.jboss.cache.Fqn; -import org.jboss.cache.commands.WriteCommand; -import org.jboss.cache.config.Option; -import org.jboss.cache.interceptors.OrderedSynchronizationHandler; -import org.jboss.cache.util.ImmutableListCopy; - -import javax.transaction.RollbackException; -import javax.transaction.SystemException; -import javax.transaction.Transaction; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; = +import javax.transaction.RollbackException; +import javax.transaction.SystemException; +import javax.transaction.Transaction; + +import org.jboss.cache.Fqn; +import org.jboss.cache.commands.WriteCommand; +import org.jboss.cache.config.Option; +import org.jboss.cache.interceptors.OrderedSynchronizationHandler; +import org.jboss.cache.util.Immutables; + /** * An abstract transaction context */ @@ -159,7 +160,7 @@ @SuppressWarnings("unchecked") public List getLocks() { - return transactionLocks =3D=3D null || transactionLocks.isEmpty() ? = Collections.emptyList() : new ImmutableListCopy(transactionLocks); + return transactionLocks =3D=3D null || transactionLocks.isEmpty() ? = Collections.emptyList() : Immutables.immutableListConvert(transactionLocks); } = = Modified: core/trunk/src/main/java/org/jboss/cache/util/ImmutableListCopy.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/util/ImmutableListCopy.java 20= 08-08-06 16:17:53 UTC (rev 6535) +++ core/trunk/src/main/java/org/jboss/cache/util/ImmutableListCopy.java 20= 08-08-07 04:21:36 UTC (rev 6536) @@ -29,7 +29,7 @@ * @since 3.0 */ @Immutable -public class ImmutableListCopy extends AbstractList implements Exter= nalizable +public class ImmutableListCopy extends AbstractList implements Exter= nalizable, Immutables.Immutable { private static final long serialVersionUID =3D 10929568968966L; private E[] elements; Deleted: core/trunk/src/main/java/org/jboss/cache/util/ImmutableMapCopy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/util/ImmutableMapCopy.java 200= 8-08-06 16:17:53 UTC (rev 6535) +++ core/trunk/src/main/java/org/jboss/cache/util/ImmutableMapCopy.java 200= 8-08-07 04:21:36 UTC (rev 6536) @@ -1,149 +0,0 @@ -package org.jboss.cache.util; - -import net.jcip.annotations.Immutable; - -import java.io.Externalizable; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.AbstractMap; -import java.util.Map; -import java.util.Set; - -/** - * Along the lines of ImmutableListCopy and ImmutableSetCopy. This lightw= eight wrapper primarily meant for iteration. - * performance of get() and containsKey() are not as efficient as that of = a {@link java.util.HashMap}, but iteration is - * fast since the entry table is a fixed size immutable array. - *

- * Typically used in place of the common idiom: - * - * return Collections.unmodifiableMap(new HashMap( myInternalMap )); - * - * - * @author Manik Surtani (manik(a)jbo= ss.org) - * @since 3.0 - */ -(a)Immutable -public class ImmutableMapCopy extends AbstractMap implements E= xternalizable // externalizable for client code that may serialize this map -{ - private static final long serialVersionUID =3D 10929568968766L; - private Entry[] table; - private int size; - - /** - * For Externalizable - */ - public ImmutableMapCopy() - { - } - - @SuppressWarnings("unchecked") - public ImmutableMapCopy(Map map) - { - size =3D map.size(); - table =3D new ImmutableEntry[size]; - int i =3D 0; - for (Map.Entry me : map.entrySet()) - { - table[i++] =3D new ImmutableEntry(me); - } - } - - @Override - public int size() - { - return size; - } - - @Override - public final V remove(Object key) - { - throw new UnsupportedOperationException(); - } - - @Override - public final void putAll(Map t) - { - throw new UnsupportedOperationException(); - } - - @Override - public final void clear() - { - throw new UnsupportedOperationException(); - } - - public final Set> entrySet() - { - return new ImmutableSetCopy>(table); - } - - /** - * Format: - * - entry array size (int) - * - entry key-value pairs (Object, Object) - * - * @param out stream to write to - * @throws IOException - */ - public void writeExternal(ObjectOutput out) throws IOException - { - out.writeInt(size); - for (Entry e : table) - { - out.writeObject(e.getKey()); - out.writeObject(e.getValue()); - } - } - - /** - * See {@link #writeExternal(java.io.ObjectOutput)} for serialization f= ormat - * - * @param in stream - * @throws IOException - * @throws ClassNotFoundException - */ - @SuppressWarnings("unchecked") - public void readExternal(ObjectInput in) throws IOException, ClassNotFo= undException - { - size =3D in.readInt(); - table =3D new Entry[size]; - for (int i =3D 0; i < size; i++) - { - table[i] =3D new ImmutableEntry(in.readObject(), in.readObject()); - } - } - - private static class ImmutableEntry implements Map.Entry - { - K k; - V v; - - private ImmutableEntry(Map.Entry entry) - { - k =3D entry.getKey(); - v =3D entry.getValue(); - } - - private ImmutableEntry(K k, V v) - { - this.k =3D k; - this.v =3D v; - } - - public K getKey() - { - return k; - } - - public V getValue() - { - return v; - } - - public V setValue(V value) - { - throw new UnsupportedOperationException(); - } - } -} Deleted: core/trunk/src/main/java/org/jboss/cache/util/ImmutableSetCopy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/util/ImmutableSetCopy.java 200= 8-08-06 16:17:53 UTC (rev 6535) +++ core/trunk/src/main/java/org/jboss/cache/util/ImmutableSetCopy.java 200= 8-08-07 04:21:36 UTC (rev 6536) @@ -1,143 +0,0 @@ -package org.jboss.cache.util; - -import net.jcip.annotations.Immutable; - -import java.io.Externalizable; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -import java.util.NoSuchElementException; - -/** - * This is based on an ImmutableListCopy, with the assumption that the set= passed in would ensure uniqueness of elements. - *

- * The constructor takes in a collection so the onus is on the caller to e= nsure that the collection passed in adheres to - * Set semantics. - *

- * Typically used in place of the common idiom: - * - * return Collections.unmodifiableSet(new HashSet( myInternalSet )); - * - * - * @author Manik Surtani (manik(a)jbo= ss.org) - * @see org.jboss.cache.util.ImmutableListCopy - * @since 3.0 - */ -(a)Immutable -public class ImmutableSetCopy extends AbstractSet implements Externa= lizable -{ - private static final long serialVersionUID =3D 11929568968766L; - private E[] elements; - private int size; - - @SuppressWarnings("unchecked") - public ImmutableSetCopy(Collection set) - { - size =3D set.size(); - E[] tempElements =3D (E[]) new Object[size]; // no room for growth - elements =3D set.toArray(tempElements); - } - - /** - * Assumes that the array passed in is "safe", i.e., is not referenced = from elsewhere. Also assumes the array contains - * elements such that the uniqueness required by a set is adhered to. = Use with care! - * - * @param array to reference - */ - public ImmutableSetCopy(E[] array) - { - elements =3D array; - size =3D elements.length; - } - - @Override - public boolean remove(Object o) - { - throw new UnsupportedOperationException(); - } - - @Override - public boolean addAll(Collection c) - { - throw new UnsupportedOperationException(); - } - - @Override - public boolean retainAll(Collection c) - { - throw new UnsupportedOperationException(); - } - - @Override - public boolean removeAll(Collection c) - { - throw new UnsupportedOperationException(); - } - - @Override - public void clear() - { - throw new UnsupportedOperationException(); - } - - public Iterator iterator() - { - return new Iterator() - { - int cursor =3D 0; - - public boolean hasNext() - { - return cursor < size; - } - - public E next() - { - if (cursor >=3D size) throw new NoSuchElementException(); - return elements[cursor++]; - } - - public void remove() - { - throw new UnsupportedOperationException(); - } - }; - } - - public int size() - { - return size; - } - - /** - * Format: - * - entry array size (int) - * - elements (Object) - * - * @param out stream to write to - * @throws IOException - */ - public void writeExternal(ObjectOutput out) throws IOException - { - out.writeInt(size); - for (E e : elements) out.writeObject(e); - } - - /** - * See {@link #writeExternal(java.io.ObjectOutput)} for serialization f= ormat - * - * @param in stream - * @throws IOException - * @throws ClassNotFoundException - */ - @SuppressWarnings("unchecked") - public void readExternal(ObjectInput in) throws IOException, ClassNotFo= undException - { - size =3D in.readInt(); - elements =3D (E[]) new Object[size]; - for (int i =3D 0; i < size; i++) elements[i] =3D (E) in.readObject(); - } -} Added: core/trunk/src/main/java/org/jboss/cache/util/Immutables.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/util/Immutables.java = (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/util/Immutables.java 2008-08-0= 7 04:21:36 UTC (rev 6536) @@ -0,0 +1,541 @@ +/* +* JBoss, Home of Professional Open Source +* Copyright 2005, JBoss Inc., and individual contributors as indicated +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* This is free software; you can redistribute it and/or modify it +* under the terms of the GNU Lesser General Public License as +* published by the Free Software Foundation; either version 2.1 of +* the License, or (at your option) any later version. +* +* This software is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this software; if not, write to the Free +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ +package org.jboss.cache.util; + +import java.io.Serializable; +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Map.Entry; + +/** + * Factory for generating immutable type wrappers. + * + * @author Jason T. Greene + */ +public class Immutables +{ + /** + * Whether or not this collection type is immutable + * + * @param a Collection, Set, List, or Map + * @return true if immutable, false if not + */ + public static boolean isImmutable(Object o) + { + return o instanceof Immutable; + } + + /** + * Converts a Collection to an immutable List by copying it. + * + * @param source the collection to convert + * @return a copied/converted immutable list + */ + public static List immutableListConvert(Collection = source) + { + return new ImmutableListCopy(source); + } + + /** + * Creates an immutable copy of the list. + * + * @param list the list to copy + * @return the immutable copy + */ + public static List immutableListCopy(List list) + { + return new ImmutableListCopy(list); + } + + /** + * Wraps an array with an immutable list. There is no copying involved. + * + * @param + * @param array the array to wrap + * @return a list containing the array + */ + public static List immutableListWrap(T... array) + { + return new ImmutableListCopy(array); + } + + /** + * Creates a new immutable list containing the union (combined entries)= of both lists. + * + * @param list1 contains the first elements of the new list + * @param list2 contains the successor elements of the new list + * @return a new immutable merged copy of list1 and list2 + */ + public static List immutableListMerge(List list1, L= ist list2) + { + return new ImmutableListCopy(list1, list2); + } + + /** + * Converts a Collections into an immutable Set by copying it. + * + * @param collection the collection to convert/copy + * @return a new immutable set containing the elements in collection + */ + public static Set immutableSetConvert(Collection co= llection) + { + return immutableSetWrap(new HashSet(collection)); + } + + /** + * Wraps a set with an immutable set. There is no copying involved. + * + * @param set the set to wrap + * @return an immutable set wrapper that delegates to the original set + */ + public static Set immutableSetWrap(Set set) + { + return new ImmutableSetWrapper(set); + } + + /** + * Creates an immutable copy of the specified set. + * + * @param set the set to copy from + * @return an immutable set copy + */ + public static Set immutableSetCopy(Set set) + { + Set copy =3D attemptClone(set); + if (copy =3D=3D null) + // Set uses Collection copy-ctor + copy =3D attemptCopyConstructor(set, Collection.class); + + if (copy =3D=3D null) + copy =3D new HashSet(set); + + return new ImmutableSetWrapper(copy); + } + + + /** + * Wraps a map with an immutable map. There is no copying involved. + * + * @param map the map to wrap + * @return an immutable map wrapper that delegates to the original map + */ + public static Map immutableMapWrap(Map map) + { + return new ImmutableMapWrapper(map); + } + + /** + * Creates an immutable copy of the specified map. + * + * @param map the map to copy from + * @return an immutable map copy + */ + public static Map immutableMapCopy(Map map) + { + Map copy =3D attemptClone(map); + if (copy =3D=3D null) + copy =3D attemptCopyConstructor(map, Map.class); + if (copy =3D=3D null) + copy =3D new HashMap(map); + + return new ImmutableMapWrapper(map); + } + + /** + * Creates a new immutable copy of the specified Collection. + * + * @param collection the collection to copy + * @return an immutable copy + */ + public static Collection immutableCollectionCopy(Collection collection) + { + Collection copy =3D attemptClone(collection); + if (copy =3D=3D null) + copy =3D attemptCopyConstructor(collection, Collection.class); + if (copy =3D=3D null) + copy =3D new ArrayList(collection); + + return new ImmutableCollectionWrapper(collection); + } + + + @SuppressWarnings("unchecked") + private static T attemptClone(T source) + { + if (source instanceof Cloneable) + { + try + { + return (T) source.getClass().getMethod("clone").invoke(source); + } + catch (Exception e) + { + } + } + + return null; + } + + @SuppressWarnings("unchecked") + private static T attemptCopyConstructor(T source, Class = clazz) + { + try + { + return (T) source.getClass().getConstructor(clazz).newInstance(so= urce); + } + catch (Exception e) + { + } + + return null; + } + + + public interface Immutable + { + } + + /* + * Immutable wrapper types. + * + * We have to re-implement Collections.unmodifiableXXX, since it is not + * simple to detect them (the class names are JDK dependent). + */ + + private static class ImmutableIteratorWrapper implements Iterator + { + private Iterator iterator; + + public ImmutableIteratorWrapper(Iterator iterator) + { + this.iterator =3D iterator; + } + + public boolean hasNext() + { + return iterator.hasNext(); + } + + public E next() + { + return iterator.next(); + } + + public void remove() + { + throw new UnsupportedOperationException(); + } + } + + private static class ImmutableCollectionWrapper implements Collectio= n, Serializable, Immutable + { + private static final long serialVersionUID =3D 6777564328198393535L; + + Collection collection; + + public ImmutableCollectionWrapper(Collection collection) + { + this.collection =3D collection; + } + + public boolean add(E o) + { + throw new UnsupportedOperationException(); + } + + public boolean addAll(Collection c) + { + throw new UnsupportedOperationException(); + } + + public void clear() + { + throw new UnsupportedOperationException(); + } + + public boolean contains(Object o) + { + return collection.contains(o); + } + + public boolean containsAll(Collection c) + { + return collection.containsAll(c); + } + + public boolean equals(Object o) + { + return collection.equals(o); + } + + public int hashCode() + { + return collection.hashCode(); + } + + public boolean isEmpty() + { + return collection.isEmpty(); + } + + public Iterator iterator() + { + return new ImmutableIteratorWrapper(collection.iterator()); + } + + public boolean remove(Object o) + { + throw new UnsupportedOperationException(); + } + + public boolean removeAll(Collection c) + { + throw new UnsupportedOperationException(); + } + + public boolean retainAll(Collection c) + { + throw new UnsupportedOperationException(); + } + + public int size() + { + return collection.size(); + } + + public Object[] toArray() + { + return collection.toArray(); + } + + public T[] toArray(T[] a) + { + return collection.toArray(a); + } + + public String toString() + { + return collection.toString(); + } + } + + + + private static class ImmutableSetWrapper extends ImmutableCollection= Wrapper implements Set, Serializable, Immutable + { + private static final long serialVersionUID =3D 7991492805176142615L; + + public ImmutableSetWrapper(Set set) + { + super(set); + } + } + + + static class ImmutableEntry implements Map.Entry + { + private K key; + private V value; + private int hash; + + ImmutableEntry(Map.Entry entry) + { + this.key =3D entry.getKey(); + this.value =3D entry.getValue(); + this.hash =3D entry.hashCode(); + } + + public K getKey() + { + return key; + } + + public V getValue() + { + return value; + } + + public V setValue(V value) + { + throw new UnsupportedOperationException(); + } + + private static boolean eq(Object o1, Object o2) + { + return o1 =3D=3D o2 || (o1 !=3D null && o1.equals(o2)); + } + + @SuppressWarnings("unchecked") + public boolean equals(Object o) + { + if (! (o instanceof Map.Entry)) + return false; + + Map.Entry entry =3D (Map.Entry) o; + return eq(entry.getKey(), key) && eq(entry.getValue(), value); + } + + public int hashCode() + { + return hash; + } + + public String toString() + { + return getKey() + "=3D" + getValue(); + } + } + + private static class ImmutableEntrySetWrapper extends ImmutableSet= Wrapper> + { + private static final long serialVersionUID =3D 6378667653889667692L; + + @SuppressWarnings("unchecked") + public ImmutableEntrySetWrapper(Set> set) + { + super((Set>)set); + } + + public Object[] toArray() + { + Object[] array =3D new Object[collection.size()]; + int i =3D 0; + for (Map.Entry entry : this) + array[i++] =3D entry; + return array; + } + + @SuppressWarnings("unchecked") + public T[] toArray(T[] array) + { + int size =3D collection.size(); + if (array.length < size) + array =3D (T[]) Array.newInstance(array.getClass().getComponen= tType(), size); + + int i =3D 0; + Object[] result =3D array; + for (Map.Entry entry : this) + result[i++] =3D entry; + + return array; + } + + public Iterator> iterator() + { + return new ImmutableIteratorWrapper>(collection.iterat= or()) { + public Entry next() + { + return new ImmutableEntry(super.next()); + } + }; + } + } + + private static class ImmutableMapWrapper implements Map, Seri= alizable, Immutable + { + private static final long serialVersionUID =3D 708144227046742221L; + + private Map map; + + public ImmutableMapWrapper(Map map) + { + this.map =3D map; + } + + public void clear() + { + throw new UnsupportedOperationException(); + } + + public boolean containsKey(Object key) + { + return map.containsKey(key); + } + + public boolean containsValue(Object value) + { + return map.containsValue(value); + } + + public Set> entrySet() + { + return new ImmutableEntrySetWrapper(map.entrySet()); + } + + public boolean equals(Object o) + { + return map.equals(o); + } + + public V get(Object key) + { + return map.get(key); + } + + public int hashCode() + { + return map.hashCode(); + } + + public boolean isEmpty() + { + return map.isEmpty(); + } + + public Set keySet() + { + return new ImmutableSetWrapper(map.keySet()); + } + + public V put(K key, V value) + { + throw new UnsupportedOperationException(); + } + + public void putAll(Map t) + { + throw new UnsupportedOperationException(); + } + + public V remove(Object key) + { + throw new UnsupportedOperationException(); + } + + public int size() + { + return map.size(); + } + + public Collection values() + { + return new ImmutableCollectionWrapper(map.values()); + } + } +} Modified: core/trunk/src/test/java/org/jboss/cache/util/ImmutableListCopyTe= st.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/util/ImmutableListCopyTest.jav= a 2008-08-06 16:17:53 UTC (rev 6535) +++ core/trunk/src/test/java/org/jboss/cache/util/ImmutableListCopyTest.jav= a 2008-08-07 04:21:36 UTC (rev 6536) @@ -12,7 +12,7 @@ { public void testImmutability() { - List l =3D new ImmutableListCopy(Collections.singlet= onList("one")); + List l =3D Immutables.immutableListCopy(Collections.singleto= nList("one")); try { l.add("two"); @@ -126,10 +126,8 @@ = public void testListIterator() { - List ints =3D Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + List list =3D Immutables.immutableListWrap(1, 2, 3, 4, 5, 6= , 7, 8, 9, 10); = - List list =3D new ImmutableListCopy(ints); - ListIterator li =3D list.listIterator(); = int number =3D 1; @@ -145,7 +143,7 @@ public void testSubLists() { List ints =3D Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - List list =3D new ImmutableListCopy(ints); + List list =3D Immutables.immutableListCopy(ints); = assert ints.subList(2, 5).equals(list.subList(2, 5)); assert ints.subList(1, 9).equals(list.subList(1, 9)); --===============6090494407234560620==-- From jboss-qa-internal at redhat.com Thu Aug 7 02:18:59 2008 Content-Type: multipart/mixed; boundary="===============5030381961351187803==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23408?= Date: Thu, 07 Aug 2008 02:18:57 -0400 Message-ID: <527014531.18491218089937095.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 2036517513.17481218050358521.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============5030381961351187803== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/408/changes --===============5030381961351187803==-- From jboss-qa-internal at redhat.com Thu Aug 7 02:25:43 2008 Content-Type: multipart/mixed; boundary="===============5692498050232380176==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23541?= Date: Thu, 07 Aug 2008 02:25:40 -0400 Message-ID: <18744205.18521218090340923.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 159159726.17321218047369583.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============5692498050232380176== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/541/changes --===============5692498050232380176==-- From jbosscache-commits at lists.jboss.org Thu Aug 7 08:04:30 2008 Content-Type: multipart/mixed; boundary="===============0793847924562080497==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6537 - in searchable/trunk: src/main/java/org/jboss/cache/search and 1 other directory. Date: Thu, 07 Aug 2008 08:04:30 -0400 Message-ID: --===============0793847924562080497== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: navssurtani Date: 2008-08-07 08:04:30 -0400 (Thu, 07 Aug 2008) New Revision: 6537 Added: searchable/trunk/src/main/java/org/jboss/cache/search/IndexSearcherClose= r.java searchable/trunk/src/main/java/org/jboss/cache/search/LazyQueryResultIte= rator.java Modified: searchable/trunk/TODO.txt searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIterato= r.java searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIterato= rImpl.java Log: Wrote up lazyIterator() in CacheQueryImpl. Still needs to be tested Modified: searchable/trunk/TODO.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/TODO.txt 2008-08-07 04:21:36 UTC (rev 6536) +++ searchable/trunk/TODO.txt 2008-08-07 12:04:30 UTC (rev 6537) @@ -10,4 +10,6 @@ = Think. = -5 - Mock objects. \ No newline at end of file +5 - Mock objects. + +6 - Think about removing the Hibernate Exceptions. \ No newline at end of file Modified: searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryI= mpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.ja= va 2008-08-07 04:21:36 UTC (rev 6536) +++ searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.ja= va 2008-08-07 12:04:30 UTC (rev 6537) @@ -14,7 +14,6 @@ import org.hibernate.search.engine.SearchFactoryImplementor; import org.hibernate.search.filter.ChainedFilter; import org.hibernate.search.filter.FilterKey; -import org.hibernate.search.impl.SearchFactoryImpl; import org.hibernate.search.query.FullTextFilterImpl; import org.hibernate.search.reader.ReaderProvider; import static org.hibernate.search.reader.ReaderProviderHelper.getIndexRea= ders; @@ -114,7 +113,7 @@ //searcher cannot be null try { - closeSearcher(searcher, searchFactory.getReaderProvider(= )); + IndexSearcherCloser.closeSearcher(searcher, searchFactor= y.getReaderProvider()); //searchFactoryImplementor.getReaderProvider().closeRead= er( searcher.getIndexReader() ); } catch (SearchException e) @@ -133,16 +132,6 @@ } = = - private void closeSearcher(Searcher searcher, ReaderProvider readerProv= ider) - { - Set indexReaders =3D getIndexReaders(searcher); - - for (IndexReader indexReader : indexReaders) - { - readerProvider.closeReader(indexReader); - } - } - /** * Enable a given filter by its name. * @@ -232,7 +221,7 @@ finally { = - closeSearcher(searcher, searchFactory.getReaderProvider()); + IndexSearcherCloser.closeSearcher(searcher, searchFactory.getRead= erProvider()); = } = @@ -250,14 +239,20 @@ int max =3D max(first, hits); = DocumentExtractor extractor =3D new DocumentExtractor(luceneQuery= , searcher, searchFactory, indexProjection); - = + + return new LazyQueryResultIterator(extractor, entityLoader, hits,= searcher, searchFactory, first, max); } catch (IOException e) { - e.printStackTrace(); //To change body of catch statement use Fil= e | Settings | File Templates. - } + try { + IndexSearcherCloser.closeSearcher( searcher, searchFactory.get= ReaderProvider() ); + } + catch (SearchException ee) { + //we have the initial issue already + } + throw new HibernateException( "Unable to query Lucene index", e ); = - return null; + } } = /** @@ -312,7 +307,7 @@ } finally { - closeSearcher(searcher, searchFactory.getReaderProvider()); + IndexSearcherCloser.closeSearcher(searcher, searchFactory.getRead= erProvider()); = } = Added: searchable/trunk/src/main/java/org/jboss/cache/search/IndexSearcherC= loser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/IndexSearcherClos= er.java (rev 0) +++ searchable/trunk/src/main/java/org/jboss/cache/search/IndexSearcherClos= er.java 2008-08-07 12:04:30 UTC (rev 6537) @@ -0,0 +1,25 @@ +package org.jboss.cache.search; + +import org.hibernate.search.engine.SearchFactoryImplementor; +import org.hibernate.search.reader.ReaderProvider; +import static org.hibernate.search.reader.ReaderProviderHelper.getIndexRea= ders; +import org.apache.lucene.search.Searcher; +import org.apache.lucene.index.IndexReader; + +import java.util.Set; + +/** + * @author Navin Surtani (nsurtan= i(a)redhat.com) + */ +public class IndexSearcherCloser +{ + static void closeSearcher(Searcher searcher, ReaderProvider readerProvi= der) + { + Set indexReaders =3D getIndexReaders(searcher); + + for (IndexReader indexReader : indexReaders) + { + readerProvider.closeReader(indexReader); + } + } +} Added: searchable/trunk/src/main/java/org/jboss/cache/search/LazyQueryResul= tIterator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/LazyQueryResultIt= erator.java (rev 0) +++ searchable/trunk/src/main/java/org/jboss/cache/search/LazyQueryResultIt= erator.java 2008-08-07 12:04:30 UTC (rev 6537) @@ -0,0 +1,182 @@ +package org.jboss.cache.search; + +import org.jboss.cache.search.CacheEntityLoader; +import org.hibernate.search.engine.DocumentExtractor; +import org.hibernate.search.engine.SearchFactoryImplementor; +import org.apache.lucene.search.Hits; +import org.apache.lucene.search.IndexSearcher; + +import java.util.NoSuchElementException; +import java.io.IOException; + +/** + * @author Navin Surtani (nsurtan= i(a)redhat.com) + */ +public class LazyQueryResultIterator implements QueryResultIterator +{ + private int index =3D 0; + private int max =3D 0; + private int first =3D 0; + private CacheEntityLoader entityLoader; + private DocumentExtractor extractor; + private Hits hits; + private IndexSearcher searcher; + private SearchFactoryImplementor searchFactory; + + public LazyQueryResultIterator(DocumentExtractor extractor, CacheEntity= Loader entityLoader, Hits hits, + IndexSearcher searcher, SearchFactoryImp= lementor searchFactory, int first, int max) + { + this.extractor =3D extractor; + this.entityLoader =3D entityLoader; + index =3D first; + this.first =3D first; + this.max =3D max; + this.hits =3D hits; + this.searcher =3D searcher; + this.searchFactory =3D searchFactory; + } + + public void jumpToResult(int index) throws IndexOutOfBoundsException + { + if (index < first || index > max) + { + throw new IndexOutOfBoundsException("The given index is incorrect= . Please check and try again."); + } + + this.index =3D first + index; + + } + + public void first() + { + index =3D first; + } + + public void last() + { + index =3D max; + } + + public void afterFirst() + { + index =3D first + 1; + } + + public void beforeLast() + { + index =3D max - 1; + } + + public boolean isFirst() + { + return index =3D=3D first; + } + + public boolean isLast() + { + return index =3D=3D max; + } + + public boolean isAfterFirst() + { + return index =3D=3D first + 1; + } + + public boolean isBeforeLast() + { + return index =3D=3D max - 1; + } + + public void close() + { + IndexSearcherCloser.closeSearcher(searcher, searchFactory.getReaderP= rovider()); + } + + public boolean hasNext() + { + return index <=3D max; + } + + public Object next() + { + Object toReturn =3D null; + try + { + String documentId =3D (String) extractor.extract(hits, index).id; + CacheEntityId id =3D new CacheEntityId(documentId); + toReturn =3D entityLoader.load(id); + index++; + } + catch (IOException e) + { + e.printStackTrace(); + } + + return toReturn; + } + + public boolean hasPrevious() + { + return index >=3D first; + } + + public Object previous() + { + Object toReturn =3D null; + try + { + String documentId =3D (String) extractor.extract (hits, index).id; + CacheEntityId id =3D new CacheEntityId(documentId); + toReturn =3D entityLoader.load(id); + index--; + } + catch (IOException e) + { + e.printStackTrace(); + } + return toReturn; + } + + public int nextIndex() + { + if (!hasNext()) throw new NoSuchElementException("Out of boundaries"= ); + return index + 1; + } + + public int previousIndex() + { + if (!hasPrevious()) throw new NoSuchElementException("Out of boundar= ies."); + return index - 1; + } + + /** + * This method is not supported and should not be used. Use cache.remov= e() instead. + */ + public void remove() + { + throw new UnsupportedOperationException("Not supported as you are tr= ying to change something in the cache"); + } + + /** + * This method is not supported in and should not be called. Use cache.= put() instead. + * + * @param o + * @throws UnsupportedOperationException + */ + public void set(Object o) throws UnsupportedOperationException + { + throw new UnsupportedOperationException("Not supported as you are tr= ying to change something in the cache"); + } + + /** + * This method is not supported in and should not be called. Use cache.= put() instead. + * + * @param o + * @throws UnsupportedOperationException + */ + + public void add(Object o) + { + throw new UnsupportedOperationException("Not supported as you are tr= ying to change something in the cache"); + } +} Modified: searchable/trunk/src/main/java/org/jboss/cache/search/QueryResult= Iterator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIterat= or.java 2008-08-07 04:21:36 UTC (rev 6536) +++ searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIterat= or.java 2008-08-07 12:04:30 UTC (rev 6537) @@ -56,4 +56,10 @@ * @return true if the current result is one before the last */ boolean isBeforeLast(); + + /** + * This method must be called on your iterator once you have finished s= o that Lucene resources can be freed up. = + */ + + void close(); } Modified: searchable/trunk/src/main/java/org/jboss/cache/search/QueryResult= IteratorImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIterat= orImpl.java 2008-08-07 04:21:36 UTC (rev 6536) +++ searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIterat= orImpl.java 2008-08-07 12:04:30 UTC (rev 6537) @@ -116,6 +116,12 @@ return idList.get(index) =3D=3D idList.get(idList.size() - 2); } = + public void close() + { + // This method does not need to do anything for this type of iterato= r as when an instace of it is + // created, the iterator() method in CacheQueryImpl closes everythin= g that needs to be closed. + } + /** * Returns true if the list has more elements when traversing the list = in the forward direction. * @@ -219,4 +225,5 @@ { throw new UnsupportedOperationException("Not supported as you are tr= ying to change something in the cache"); } + = } --===============0793847924562080497==-- From jbosscache-commits at lists.jboss.org Thu Aug 7 11:54:03 2008 Content-Type: multipart/mixed; boundary="===============6512234099437064500==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6538 - in core/trunk/src/main/java/org/jboss/cache: interceptors and 1 other directories. Date: Thu, 07 Aug 2008 11:54:03 -0400 Message-ID: --===============6512234099437064500== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-07 11:54:03 -0400 (Thu, 07 Aug 2008) New Revision: 6538 Modified: core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterce= ptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/base/PrePostProces= singCommandInterceptor.java Log: Deprecated CreateNodeCommand visitors Modified: core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java 2008-08-= 07 12:04:30 UTC (rev 6537) +++ core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java 2008-08-= 07 15:54:03 UTC (rev 6538) @@ -1,6 +1,7 @@ package org.jboss.cache.commands; = import org.jboss.cache.commands.legacy.write.CreateNodeCommand; +import org.jboss.cache.commands.local.BatchBoundaryCommand; import org.jboss.cache.commands.read.ExistsCommand; import org.jboss.cache.commands.read.GetChildrenNamesCommand; import org.jboss.cache.commands.read.GetDataMapCommand; @@ -242,6 +243,8 @@ * @param command command to visit * @return response from the visit * @throws Throwable in the event of problems. + * @deprecated in 3.0. Will be removed once optimistic and pessimistic= locking is removed. */ + @Deprecated Object visitCreateNodeCommand(InvocationContext ctx, CreateNodeCommand = command) throws Throwable; } Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLocking= Interceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterc= eptor.java 2008-08-07 12:04:30 UTC (rev 6537) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterc= eptor.java 2008-08-07 15:54:03 UTC (rev 6538) @@ -5,7 +5,6 @@ import org.jboss.cache.InternalNode; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.VisitableCommand; -import org.jboss.cache.commands.legacy.write.CreateNodeCommand; import org.jboss.cache.commands.read.ExistsCommand; import org.jboss.cache.commands.read.GetChildrenNamesCommand; import org.jboss.cache.commands.read.GetDataMapCommand; @@ -265,12 +264,6 @@ } = @Override - public Object handleCreateNodeCommand(InvocationContext ctx, CreateNode= Command command) throws Throwable - { - throw new UnsupportedOperationException("Unsupported in MVCC!"); - } - - @Override public Object handleRollbackCommand(InvocationContext ctx, RollbackComm= and command) throws Throwable { Object retval =3D null; Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/base/PrePos= tProcessingCommandInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/base/PrePostProce= ssingCommandInterceptor.java 2008-08-07 12:04:30 UTC (rev 6537) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/PrePostProce= ssingCommandInterceptor.java 2008-08-07 15:54:03 UTC (rev 6538) @@ -128,6 +128,10 @@ } } = + /** + * @deprecated in 3.0. Will be removed when Optimistic and Pessimistic= locking is removed. + */ + @Deprecated protected Object handleCreateNodeCommand(InvocationContext ctx, CreateN= odeCommand command) throws Throwable { return handleDefault(ctx, command); --===============6512234099437064500==-- From jbosscache-commits at lists.jboss.org Thu Aug 7 12:04:07 2008 Content-Type: multipart/mixed; boundary="===============1981487391430557509==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6539 - core/trunk/src/main/java/org/jboss/cache/commands. Date: Thu, 07 Aug 2008 12:04:07 -0400 Message-ID: --===============1981487391430557509== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-07 12:04:06 -0400 (Thu, 07 Aug 2008) New Revision: 6539 Modified: core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java Log: Deprecated CreateNodeCommand visitors Modified: core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java 2008-08-= 07 15:54:03 UTC (rev 6538) +++ core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java 2008-08-= 07 16:04:06 UTC (rev 6539) @@ -1,7 +1,6 @@ package org.jboss.cache.commands; = import org.jboss.cache.commands.legacy.write.CreateNodeCommand; -import org.jboss.cache.commands.local.BatchBoundaryCommand; import org.jboss.cache.commands.read.ExistsCommand; import org.jboss.cache.commands.read.GetChildrenNamesCommand; import org.jboss.cache.commands.read.GetDataMapCommand; --===============1981487391430557509==-- From jboss-qa-internal at redhat.com Thu Aug 7 12:08:22 2008 Content-Type: multipart/mixed; boundary="===============8867952604751321942==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Build_failed_in_Hudson=3A_jboss-cache-?= =?utf-8?q?core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_=23542?= Date: Thu, 07 Aug 2008 12:07:58 -0400 Message-ID: <912941869.19311218125278620.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 18744205.18521218090340923.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============8867952604751321942== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/542/changes Changes: [manik.surtani(a)jboss.com] Deprecated CreateNodeCommand visitors [jason.greene(a)jboss.com] Convert all immutable usage to new Immutables fa= ctory. Drop ImmutableMapCopy and ImmutableSetCopy in favor of map/set wrappers Add immutable wrappers which are detectable (unlike Collections.unmodifiabl= e*) ------------------------------------------ started Building remotely on soavmg12-linux Reusing existing maven process [INFO] Scanning for projects... [INFO] --------------------------------------------------------------------= ---- [INFO] Building JBoss Cache - Core Edition [INFO] task-segment: [package] [INFO] --------------------------------------------------------------------= ---- [INFO] [enforcer:enforce {execution: enforce-java}] [INFO] [resources:resources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:compile] Compiling 464 source files to /home/hudson/hudson_workspace/workspace/jboss= -cache-core-trunk-jdk1.5/target/classes [HUDSON] Archiving /home/hudson/hudson_workspace/workspace/jboss-cache-core= -trunk-jdk1.5/./pom.xml [INFO] --------------------------------------------------------------------= ---- [ERROR] BUILD FAILURE [INFO] --------------------------------------------------------------------= ---- [INFO] Compilation failure /home/hudson/hudson_workspace/workspace/jboss-cache-core-trunk-jdk1.5/src/m= ain/java/org/jboss/cache/commands/Visitor.java:[4,38] package org.jboss.cac= he.commands.local does not exist [INFO] --------------------------------------------------------------------= ---- [INFO] For more information, run Maven with the -e switch [INFO] --------------------------------------------------------------------= ---- [INFO] Total time: 12 seconds [INFO] Finished at: Thu Aug 07 12:07:54 EDT 2008 [INFO] Final Memory: 24M/121M [INFO] --------------------------------------------------------------------= ---- Waiting for Hudson to finish collecting data --===============8867952604751321942==-- From jboss-qa-internal at redhat.com Thu Aug 7 12:09:43 2008 Content-Type: multipart/mixed; boundary="===============2803089094596908033==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Build_failed_in_Hudson=3A_jboss-cache-?= =?utf-8?q?core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_=23409?= Date: Thu, 07 Aug 2008 12:09:38 -0400 Message-ID: <355611587.19321218125378587.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 527014531.18491218089937095.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============2803089094596908033== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/409/changes Changes: [manik.surtani(a)jboss.com] Deprecated CreateNodeCommand visitors [jason.greene(a)jboss.com] Convert all immutable usage to new Immutables fa= ctory. Drop ImmutableMapCopy and ImmutableSetCopy in favor of map/set wrappers Add immutable wrappers which are detectable (unlike Collections.unmodifiabl= e*) ------------------------------------------ started Building remotely on soavmg6-linux $ /qa/tools/opt/jdk1.6.0_03/bin/java -Xmx512m -cp /home/hudson/hudson_works= pace/maven-agent.jar:/qa/tools/opt/maven-2.0.9/boot/classworlds-1.1.jar hud= son.maven.agent.Main /qa/tools/opt/maven-2.0.9 /qa/services/hudson/hudson_r= elease/WEB-INF/slave.jar /home/hudson/hudson_workspace/maven-interceptor.jar channel started [INFO] Scanning for projects... WAGON_VERSION: 1.0-beta-2 [INFO] --------------------------------------------------------------------= ---- [INFO] Building JBoss Cache - Core Edition [INFO] task-segment: [package] [INFO] --------------------------------------------------------------------= ---- [INFO] [enforcer:enforce {execution: enforce-java}] [INFO] [resources:resources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:compile] Compiling 464 source files to /home/hudson/hudson_workspace/workspace/jboss= -cache-core-trunk-jdk1.6/target/classes [HUDSON] Archiving /home/hudson/hudson_workspace/workspace/jboss-cache-core= -trunk-jdk1.6/./pom.xml [INFO] --------------------------------------------------------------------= ---- [ERROR] BUILD FAILURE [INFO] --------------------------------------------------------------------= ---- [INFO] Compilation failure /home/hudson/hudson_workspace/workspace/jboss-cache-core-trunk-jdk1.6/src/m= ain/java/org/jboss/cache/commands/Visitor.java:[4,37] package org.jboss.cac= he.commands.local does not exist [INFO] --------------------------------------------------------------------= ---- [INFO] For more information, run Maven with the -e switch [INFO] --------------------------------------------------------------------= ---- [INFO] Total time: 50 seconds [INFO] Finished at: Thu Aug 07 10:41:01 EDT 2008 [INFO] Final Memory: 12M/43M [INFO] --------------------------------------------------------------------= ---- Waiting for Hudson to finish collecting data --===============2803089094596908033==-- From jbosscache-commits at lists.jboss.org Thu Aug 7 12:45:40 2008 Content-Type: multipart/mixed; boundary="===============4972963757416450280==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6540 - in core/trunk/src: main/java/org/jboss/cache/batch and 12 other directories. Date: Thu, 07 Aug 2008 12:45:40 -0400 Message-ID: --===============4972963757416450280== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-07 12:45:39 -0400 (Thu, 07 Aug 2008) New Revision: 6540 Added: core/trunk/src/main/java/org/jboss/cache/batch/ core/trunk/src/main/java/org/jboss/cache/batch/BatchContainer.java core/trunk/src/main/java/org/jboss/cache/interceptors/BatchingIntercepto= r.java core/trunk/src/test/java/org/jboss/cache/api/batch/ core/trunk/src/test/java/org/jboss/cache/api/batch/AbstractBatchTest.java core/trunk/src/test/java/org/jboss/cache/api/batch/BatchWithTM.java core/trunk/src/test/java/org/jboss/cache/api/batch/BatchWithoutTM.java Modified: core/trunk/src/main/java/org/jboss/cache/Cache.java core/trunk/src/main/java/org/jboss/cache/CacheSPI.java core/trunk/src/main/java/org/jboss/cache/config/Configuration.java core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguration= Parser.java core/trunk/src/main/java/org/jboss/cache/factories/EmptyConstructorFacto= ry.java core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFacto= ry.java core/trunk/src/main/java/org/jboss/cache/factories/TransactionManagerFac= tory.java core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingI= nterceptor.java core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDeleg= ate.java core/trunk/src/main/java/org/jboss/cache/transaction/BatchModeTransactio= nManagerLookup.java core/trunk/src/main/resources/jbosscache-config-3.0.xsd core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguration= ParserTest.java core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFacto= ryTest.java core/trunk/src/test/resources/configs/parser-test.xml Log: JBCACHE-991 - Batching API Modified: core/trunk/src/main/java/org/jboss/cache/Cache.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/Cache.java 2008-08-07 16:04:06= UTC (rev 6539) +++ core/trunk/src/main/java/org/jboss/cache/Cache.java 2008-08-07 16:45:39= UTC (rev 6540) @@ -495,4 +495,30 @@ */ void clearData(Fqn fqn); = + /** + * Starts a batch. This is a lightweight batching mechanism that group= s cache writes together and finally performs the + * write, persistence and/or replication when {@link #endBatch(boolean)= } is called rather than for each invocation on the + * cache. + *

+ * Note that if there is an existing transaction in scope and the cache= has been configured to use a JTA compliant + * transaction manager, calls to {@link #startBatch()} and {@link #endB= atch(boolean)} are ignored and treated as no-ops. + *

+ * + * @see #endBatch(boolean) + * @since 3.0 + */ + void startBatch(); + + /** + * Ends an existing ongoing batch. A no-op if a batch has not been sta= rted yet. + *

+ * Note that if there is an existing transaction in scope and the cache= has been configured to use a JTA compliant + * transaction manager, calls to {@link #startBatch()} and {@link #endB= atch(boolean)} are ignored and treated as no-ops. + *

+ * + * @param successful if true, changes made in the batch are co= mmitted. If false, they are discarded. + * @see #startBatch() + * @since 3.0 + */ + void endBatch(boolean successful); } Modified: core/trunk/src/main/java/org/jboss/cache/CacheSPI.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/CacheSPI.java 2008-08-07 16:04= :06 UTC (rev 6539) +++ core/trunk/src/main/java/org/jboss/cache/CacheSPI.java 2008-08-07 16:45= :39 UTC (rev 6540) @@ -39,7 +39,6 @@ * @see NodeSPI * @see Cache * @see org.jboss.cache.loader.CacheLoader - * @see org.jboss.cache.interceptors.ChainedInterceptor * @since 2.0.0 */ @ThreadSafe Added: core/trunk/src/main/java/org/jboss/cache/batch/BatchContainer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/batch/BatchContainer.java = (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/batch/BatchContainer.java 2008= -08-07 16:45:39 UTC (rev 6540) @@ -0,0 +1,80 @@ +package org.jboss.cache.batch; + +import org.jboss.cache.CacheException; +import org.jboss.cache.factories.annotations.Inject; + +import javax.transaction.Transaction; +import javax.transaction.TransactionManager; + +/** + * A container for holding thread locals for batching, to be used with the= {@link org.jboss.cache.Cache#startBatch()} and + * {@link org.jboss.cache.Cache#endBatch(boolean)} calls. + * + * @author Manik Surtani (manik(a)jbo= ss.org) + * @since 3.0 + */ +public class BatchContainer +{ + TransactionManager transactionManager; + private ThreadLocal batchTransactionContainer =3D new Thre= adLocal(); + + @Inject + void inject(TransactionManager transactionManager) + { + this.transactionManager =3D transactionManager; + } + + public void startBatch() throws CacheException + { + try + { + if (transactionManager.getTransaction() !=3D null) return; + if (batchTransactionContainer.get() =3D=3D null) + { + transactionManager.begin(); + batchTransactionContainer.set(transactionManager.suspend()); + } + } + catch (Exception e) + { + throw new CacheException("Unable to start batch", e); + } + } + + public void endBatch(boolean success) + { + Transaction tx =3D batchTransactionContainer.get(); + if (tx =3D=3D null) return; + Transaction existingTx =3D null; + try + { + existingTx =3D transactionManager.getTransaction(); + transactionManager.resume(tx); + if (success) + tx.commit(); + else + tx.rollback(); + } + catch (Exception e) + { + throw new CacheException("Unable to end batch", e); + } + finally + { + batchTransactionContainer.remove(); + try + { + if (existingTx !=3D null) transactionManager.resume(existingTx= ); + } + catch (Exception e) + { + throw new CacheException("Failed resuming existing transaction= " + existingTx, e); + } + } + } + + public Transaction getBatchTransaction() + { + return batchTransactionContainer.get(); + } +} Modified: core/trunk/src/main/java/org/jboss/cache/config/Configuration.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2008= -08-07 16:04:06 UTC (rev 6539) +++ core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2008= -08-07 16:45:39 UTC (rev 6540) @@ -32,6 +32,7 @@ private Marshaller marshaller; = private JGroupsStackParser jGroupsStackParser =3D new JGroupsStackParse= r(); + private boolean invocationBatchingEnabled; = /** * Behavior of the JVM shutdown hook registered by the cache @@ -299,6 +300,19 @@ this.exposeManagementStatistics =3D useMbean; } = + /** + * Enables invocation batching if set to true. You still need= to use {@link org.jboss.cache.Cache#startBatch()} + * and {@link org.jboss.cache.Cache#endBatch(boolean)} to demarcate the= start and end of batches. + * + * @param enabled if true, batching is enabled. + * @since 3.0 + */ + public void setInvocationBatchingEnabled(boolean enabled) + { + testImmutability("invocationBatchingEnabled"); + this.invocationBatchingEnabled =3D enabled; + } + public void setFetchInMemoryState(boolean fetchInMemoryState) { testImmutability("fetchInMemoryState"); @@ -652,6 +666,15 @@ return exposeManagementStatistics; } = + /** + * @return true if invocation batching is enabled. + * @since 3.0 + */ + public boolean isInvocationBatchingEnabled() + { + return invocationBatchingEnabled; + } + public boolean isFetchInMemoryState() { return fetchInMemoryState; Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfig= urationParser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParser.java 2008-08-07 16:04:06 UTC (rev 6539) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParser.java 2008-08-07 16:45:39 UTC (rev 6540) @@ -52,8 +52,8 @@ *

* Following system properties can be used for customizing parser behavior: *

    - *
  • -Djbosscache.config.validate=3Dfalse will make the parser= non-validating
  • - *
  • -Djbosscache.config.schemaLocation=3Durl allows one to sp= ecify a validation schema that would override the one specified in the the = xml document
  • + *
  • -Djbosscache.config.validate=3Dfalse will make the parser n= on-validating
  • + *
  • -Djbosscache.config.schemaLocation=3Durl allows one to spec= ify a validation schema that would override the one specified in the the xm= l document
  • *
* This class is stateful and one instance should be used for parsing a si= ngle configuration file. * @@ -173,6 +173,7 @@ configureCacheLoaders(getSingleElement("loaders")); configureCustomInterceptors(getSingleElement("customInterceptors"= )); configureListeners(getSingleElement("listeners")); + configureInvocationBatching(getSingleElement("invocationBatching"= )); } catch (Exception e) { @@ -248,6 +249,13 @@ } } = + private void configureInvocationBatching(Element element) + { + if (element =3D=3D null) return; //this element is optional + boolean enabled =3D getBoolean(getAttributeValue(element, "enabled")= ); + config.setInvocationBatchingEnabled(enabled); + } + private void configureBuddyReplication(Element element) { if (element =3D=3D null) return;//buddy config might not exist, expe= ct that Modified: core/trunk/src/main/java/org/jboss/cache/factories/EmptyConstruct= orFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/factories/EmptyConstructorFact= ory.java 2008-08-07 16:04:06 UTC (rev 6539) +++ core/trunk/src/main/java/org/jboss/cache/factories/EmptyConstructorFact= ory.java 2008-08-07 16:45:39 UTC (rev 6540) @@ -2,6 +2,7 @@ = import org.jboss.cache.DataContainer; import org.jboss.cache.RegionRegistry; +import org.jboss.cache.batch.BatchContainer; import org.jboss.cache.buddyreplication.BuddyFqnTransformer; import org.jboss.cache.config.ConfigurationException; import org.jboss.cache.factories.annotations.DefaultFactoryFor; @@ -25,7 +26,7 @@ @DefaultFactoryFor(classes =3D {Notifier.class, MVCCNodeHelper.class, Regi= onRegistry.class, ChannelMessageListener.class, CacheLoaderManager.class, Marshaller.c= lass, InvocationContextContainer.class, CacheInvocationDelegate.class, TransactionTable.class, DataContainer= .class, - LockStrategyFactory.class, BuddyFqnTransformer.class}) + LockStrategyFactory.class, BuddyFqnTransformer.class, BatchContainer= .class}) public class EmptyConstructorFactory extends ComponentFactory { @Override Modified: core/trunk/src/main/java/org/jboss/cache/factories/InterceptorCha= inFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFact= ory.java 2008-08-07 16:04:06 UTC (rev 6539) +++ core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFact= ory.java 2008-08-07 16:45:39 UTC (rev 6540) @@ -56,13 +56,18 @@ public InterceptorChain buildInterceptorChain() throws IllegalAccessExc= eption, InstantiationException, ClassNotFoundException { boolean optimistic =3D configuration.getNodeLockingScheme() =3D=3D N= odeLockingScheme.OPTIMISTIC; + boolean invocationBatching =3D configuration.isInvocationBatchingEna= bled(); // load the icInterceptor first - CommandInterceptor first =3D createInterceptor(InvocationContextInte= rceptor.class); + CommandInterceptor first =3D invocationBatching ? createInterceptor(= BatchingInterceptor.class) : createInterceptor(InvocationContextInterceptor= .class); InterceptorChain interceptorChain =3D new InterceptorChain(first); = // add the interceptor chain to the registry first, since some inter= ceptors may ask for it. componentRegistry.registerComponent(interceptorChain, InterceptorCha= in.class); = + // NOW add the ICI if we are using batching! + if (invocationBatching) + interceptorChain.appendIntereceptor(createInterceptor(InvocationC= ontextInterceptor.class)); + // load the cache management interceptor next if (configuration.getExposeManagementStatistics()) interceptorChain.appendIntereceptor(createInterceptor(CacheMgmtIn= terceptor.class)); Modified: core/trunk/src/main/java/org/jboss/cache/factories/TransactionMan= agerFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/factories/TransactionManagerFa= ctory.java 2008-08-07 16:04:06 UTC (rev 6539) +++ core/trunk/src/main/java/org/jboss/cache/factories/TransactionManagerFa= ctory.java 2008-08-07 16:45:39 UTC (rev 6540) @@ -2,6 +2,7 @@ = import org.jboss.cache.config.ConfigurationException; import org.jboss.cache.factories.annotations.DefaultFactoryFor; +import org.jboss.cache.transaction.BatchModeTransactionManager; import org.jboss.cache.transaction.TransactionManagerLookup; = import javax.transaction.TransactionManager; @@ -52,6 +53,12 @@ log.info("failed looking up TransactionManager, will not use t= ransactions", e); } } + + if (transactionManager =3D=3D null && configuration.isInvocationBatc= hingEnabled()) + { + log.info("Using a batchMode transaction manager"); + transactionManager =3D BatchModeTransactionManager.getInstance(); + } return componentType.cast(transactionManager); } } Added: core/trunk/src/main/java/org/jboss/cache/interceptors/BatchingInterc= eptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/BatchingIntercept= or.java (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/BatchingIntercept= or.java 2008-08-07 16:45:39 UTC (rev 6540) @@ -0,0 +1,58 @@ +package org.jboss.cache.interceptors; + +import org.jboss.cache.batch.BatchContainer; +import org.jboss.cache.commands.VisitableCommand; +import org.jboss.cache.factories.annotations.Inject; +import org.jboss.cache.interceptors.base.CommandInterceptor; +import org.jboss.cache.invocation.InvocationContext; + +import javax.transaction.Transaction; +import javax.transaction.TransactionManager; + +/** + * Interceptor that captures batched calls and attaches contexts. + * + * @author Manik Surtani (manik(a)jbo= ss.org) + * @since 3.0 + */ +public class BatchingInterceptor extends CommandInterceptor +{ + BatchContainer batchContainer; + TransactionManager transactionManager; + + @Inject + private void inject(BatchContainer batchContainer, TransactionManager t= ransactionManager) + { + this.batchContainer =3D batchContainer; + this.transactionManager =3D transactionManager; + } + + /** + * Simply check if there is an ongoing tx. + *
    + *
  • If there is one, this is a no-op and just passes the call up the= chain.
  • + *
  • If there isn't one and there is a batch in progress, resume the = batch's tx, pass up, and finally suspend the batch's tx.
  • + *
  • If there is no batch in progress, just pass the call up the chai= n.
  • + *
+ */ + @Override + protected Object handleDefault(InvocationContext ctx, VisitableCommand = command) throws Throwable + { + Transaction tx =3D null; + try + { + // if in a batch, attach tx + if (transactionManager.getTransaction() =3D=3D null && + (tx =3D batchContainer.getBatchTransaction()) !=3D null) + { + transactionManager.resume(tx); + } + return super.handleDefault(ctx, command); + } + finally + { + if (tx !=3D null && transactionManager.getTransaction() !=3D null) + transactionManager.suspend(); + } + } +} Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticL= ockingInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLocking= Interceptor.java 2008-08-07 16:04:06 UTC (rev 6539) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLocking= Interceptor.java 2008-08-07 16:45:39 UTC (rev 6540) @@ -18,6 +18,7 @@ import static org.jboss.cache.lock.LockType.WRITE; import org.jboss.cache.optimistic.TransactionWorkspace; import org.jboss.cache.optimistic.WorkspaceNode; +import org.jboss.cache.transaction.BatchModeTransactionManager; import org.jboss.cache.transaction.GlobalTransaction; import org.jboss.cache.transaction.TransactionContext; = @@ -35,7 +36,7 @@ @Start private void init() { - if (txManager =3D=3D null) + if (txManager =3D=3D null || txManager.getClass().equals(BatchModeTr= ansactionManager.class)) log.fatal("No transaction manager lookup class has been defined. = Transactions cannot be used and thus OPTIMISTIC locking cannot be used! Ex= pect errors!!"); } = Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocati= onDelegate.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDele= gate.java 2008-08-07 16:04:06 UTC (rev 6539) +++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDele= gate.java 2008-08-07 16:45:39 UTC (rev 6540) @@ -1,13 +1,5 @@ package org.jboss.cache.invocation; = -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.transaction.Transaction; -import javax.transaction.TransactionManager; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.CacheException; @@ -21,6 +13,7 @@ import org.jboss.cache.Region; import org.jboss.cache.RegionManager; import org.jboss.cache.Version; +import org.jboss.cache.batch.BatchContainer; import org.jboss.cache.buddyreplication.BuddyManager; import org.jboss.cache.buddyreplication.GravitateResult; import org.jboss.cache.commands.CommandsFactory; @@ -39,8 +32,9 @@ import org.jboss.cache.commands.write.RemoveKeyCommand; import org.jboss.cache.commands.write.RemoveNodeCommand; import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.Configuration.NodeLockingScheme; +import org.jboss.cache.config.ConfigurationException; import org.jboss.cache.config.Option; -import org.jboss.cache.config.Configuration.NodeLockingScheme; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.NonVolatile; import org.jboss.cache.factories.annotations.Start; @@ -55,6 +49,13 @@ import org.jboss.cache.util.Immutables; import org.jgroups.Address; = +import javax.transaction.Transaction; +import javax.transaction.TransactionManager; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; + /** * The delegate that users (and ChainedInterceptor authors) interact with = when they create a cache by using a cache factory. * This wrapper delegates calls down the interceptor chain. @@ -81,12 +82,13 @@ private CommandsFactory commandsFactory; private MVCCNodeHelper mvccHelper; private boolean usingMvcc; + private BatchContainer batchContainer; = @Inject public void initialize(StateTransferManager stateTransferManager, Cache= LoaderManager cacheLoaderManager, Notifier notifier, TransactionManager transactionManager, BuddyMana= ger buddyManager, TransactionTable transactionTable, RPCManager rpcManager, RegionManager regionManag= er, Marshaller marshaller, - CommandsFactory commandsFactory, DataContainer d= ataContainer, MVCCNodeHelper mvccHelper) + CommandsFactory commandsFactory, DataContainer d= ataContainer, MVCCNodeHelper mvccHelper, BatchContainer batchContainer) { this.stateTransferManager =3D stateTransferManager; this.cacheLoaderManager =3D cacheLoaderManager; @@ -100,6 +102,7 @@ this.dataContainer =3D dataContainer; this.commandsFactory =3D commandsFactory; this.mvccHelper =3D mvccHelper; + this.batchContainer =3D batchContainer; } = @Start @@ -582,6 +585,20 @@ invoker.invoke(ctx, commandsFactory.buildClearDataCommand(tx, fqn)); } = + public void startBatch() + { + if (!configuration.isInvocationBatchingEnabled()) + throw new ConfigurationException("Invocation batching not enabled= in current configuration! Please use the element."= ); + batchContainer.startBatch(); + } + + public void endBatch(boolean successful) + { + if (!configuration.isInvocationBatchingEnabled()) + throw new ConfigurationException("Invocation batching not enabled= in current configuration! Please use the element."= ); + batchContainer.endBatch(successful); + } + @SuppressWarnings("unchecked") public Set getChildrenNames(Fqn fqn) { Modified: core/trunk/src/main/java/org/jboss/cache/transaction/BatchModeTra= nsactionManagerLookup.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/transaction/BatchModeTransacti= onManagerLookup.java 2008-08-07 16:04:06 UTC (rev 6539) +++ core/trunk/src/main/java/org/jboss/cache/transaction/BatchModeTransacti= onManagerLookup.java 2008-08-07 16:45:39 UTC (rev 6540) @@ -1,6 +1,9 @@ package org.jboss.cache.transaction; = = +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import javax.transaction.TransactionManager; = = @@ -9,10 +12,16 @@ * * @author Bela Ban Sept 5 2003 * @version $Id$ + * @deprecated Use batching API on Cache instead. */ -public class BatchModeTransactionManagerLookup implements TransactionManag= erLookup { +(a)Deprecated +public class BatchModeTransactionManagerLookup implements TransactionManag= erLookup +{ + private Log log =3D LogFactory.getLog(BatchModeTransactionManagerLookup= .class); = - public TransactionManager getTransactionManager() throws Exception { + public TransactionManager getTransactionManager() throws Exception + { + log.warn("Using a deprecated/unsupported transaction manager!"); return BatchModeTransactionManager.getInstance(); } } Modified: core/trunk/src/main/resources/jbosscache-config-3.0.xsd =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/resources/jbosscache-config-3.0.xsd 2008-08-07 16:0= 4:06 UTC (rev 6539) +++ core/trunk/src/main/resources/jbosscache-config-3.0.xsd 2008-08-07 16:4= 5:39 UTC (rev 6540) @@ -15,10 +15,11 @@ + - + @@ -138,6 +139,10 @@ = + + + + Added: core/trunk/src/test/java/org/jboss/cache/api/batch/AbstractBatchTest= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/api/batch/AbstractBatchTest.ja= va (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/api/batch/AbstractBatchTest.ja= va 2008-08-07 16:45:39 UTC (rev 6540) @@ -0,0 +1,24 @@ +package org.jboss.cache.api.batch; + +import org.jboss.cache.Cache; + +import java.util.concurrent.atomic.AtomicReference; + +public abstract class AbstractBatchTest +{ + protected String getOnDifferentThread(final Cache cache= , final String fqn, final String key) throws InterruptedException + { + final AtomicReference ref =3D new AtomicReference(); + Thread t =3D new Thread() + { + public void run() + { + ref.set(cache.get(fqn, key)); + } + }; + + t.start(); + t.join(); + return ref.get(); + } +} Added: core/trunk/src/test/java/org/jboss/cache/api/batch/BatchWithTM.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/api/batch/BatchWithTM.java = (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/api/batch/BatchWithTM.java 200= 8-08-07 16:45:39 UTC (rev 6540) @@ -0,0 +1,124 @@ +package org.jboss.cache.api.batch; + +import org.jboss.cache.Cache; +import org.jboss.cache.CacheFactory; +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.Configuration.CacheMode; +import org.jboss.cache.config.Configuration.NodeLockingScheme; +import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; +import org.jboss.cache.util.TestingUtil; +import org.testng.annotations.Test; + +import javax.transaction.TransactionManager; + +(a)Test(groups =3D {"functional", "transaction"}) +public class BatchWithTM extends AbstractBatchTest +{ + public void testBatchWithOngoingTM() throws Exception + { + Cache cache =3D null; + try + { + cache =3D createCache(); + TransactionManager tm =3D getTransactionManager(cache); + tm.begin(); + cache.put("/a/b/c", "k", "v"); + cache.startBatch(); + cache.put("/a/b/c", "k2", "v2"); + tm.commit(); + + assert "v".equals(cache.get("/a/b/c", "k")); + assert "v2".equals(cache.get("/a/b/c", "k2")); + + cache.endBatch(false); // should be a no op + assert "v".equals(cache.get("/a/b/c", "k")); + assert "v2".equals(cache.get("/a/b/c", "k2")); + } + finally + { + TestingUtil.killCaches(cache); + } + } + + public void testBatchWithoutOngoingTMSuspension() throws Exception + { + Cache cache =3D null; + try + { + cache =3D createCache(); + TransactionManager tm =3D getTransactionManager(cache); + assert tm.getTransaction() =3D=3D null : "Should have no ongoing = txs"; + cache.startBatch(); + cache.put("/a/b/c", "k", "v"); + assert tm.getTransaction() =3D=3D null : "Should have no ongoing = txs"; + cache.put("/a/b/c", "k2", "v2"); + + assert getOnDifferentThread(cache, "/a/b/c", "k") =3D=3D null; + assert getOnDifferentThread(cache, "/a/b/c", "k2") =3D=3D null; + + try + { + tm.commit(); // should have no effect + } + catch (Exception e) + { + // the TM may barf here ... this is OK. + } + + assert tm.getTransaction() =3D=3D null : "Should have no ongoing = txs"; + + assert getOnDifferentThread(cache, "/a/b/c", "k") =3D=3D null; + assert getOnDifferentThread(cache, "/a/b/c", "k2") =3D=3D null; + + cache.endBatch(true); // should be a no op + + assert "v".equals(getOnDifferentThread(cache, "/a/b/c", "k")); + assert "v2".equals(getOnDifferentThread(cache, "/a/b/c", "k2")); + } + finally + { + TestingUtil.killCaches(cache); + } + } + + public void testBatchRollback() throws Exception + { + Cache cache =3D null; + try + { + cache =3D createCache(); + TransactionManager tm =3D getTransactionManager(cache); + cache.startBatch(); + cache.put("/a/b/c", "k", "v"); + cache.put("/a/b/c", "k2", "v2"); + + assert getOnDifferentThread(cache, "/a/b/c", "k") =3D=3D null; + assert getOnDifferentThread(cache, "/a/b/c", "k2") =3D=3D null; + + cache.endBatch(false); + + assert getOnDifferentThread(cache, "/a/b/c", "k") =3D=3D null; + assert getOnDifferentThread(cache, "/a/b/c", "k2") =3D=3D null; + } + finally + { + TestingUtil.killCaches(cache); + } + } + + private TransactionManager getTransactionManager(Cache = c) + { + return c.getConfiguration().getRuntimeConfig().getTransactionManager= (); + } + + private Cache createCache() + { + CacheFactory cf =3D new DefaultCacheFactory(); + Configuration c =3D UnitTestCacheConfigurationFactory.createConfigur= ation(CacheMode.LOCAL); // this should pick up any configured TM for the te= st + c.setNodeLockingScheme(NodeLockingScheme.MVCC); + c.setInvocationBatchingEnabled(true); + assert c.getTransactionManagerLookupClass() !=3D null : "Should have= a transaction manager lookup class attached!!"; + return cf.createCache(c); + } +} Added: core/trunk/src/test/java/org/jboss/cache/api/batch/BatchWithoutTM.ja= va =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/api/batch/BatchWithoutTM.java = (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/api/batch/BatchWithoutTM.java = 2008-08-07 16:45:39 UTC (rev 6540) @@ -0,0 +1,146 @@ +package org.jboss.cache.api.batch; + +import org.jboss.cache.Cache; +import org.jboss.cache.CacheFactory; +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.Configuration.NodeLockingScheme; +import org.jboss.cache.config.ConfigurationException; +import org.jboss.cache.util.TestingUtil; +import org.testng.annotations.Test; + +(a)Test(groups =3D "functional") +public class BatchWithoutTM extends AbstractBatchTest +{ + public void testBatchWithoutCfg() + { + Cache cache =3D null; + try + { + cache =3D createCache(false); + try + { + cache.startBatch(); + assert false : "Should have failed"; + } + catch (ConfigurationException good) + { + // do nothing + } + + try + { + cache.endBatch(true); + assert false : "Should have failed"; + } + catch (ConfigurationException good) + { + // do nothing + } + + try + { + cache.endBatch(false); + assert false : "Should have failed"; + } + catch (ConfigurationException good) + { + // do nothing + } + } + finally + { + TestingUtil.killCaches(cache); + } + } + + public void testEndBatchWithoutStartBatch() + { + Cache cache =3D null; + try + { + cache =3D createCache(true); + cache.endBatch(true); + cache.endBatch(false); + // should not fail. + } + finally + { + TestingUtil.killCaches(cache); + } + } + + public void testStartBatchIdempotency() + { + Cache cache =3D null; + try + { + cache =3D createCache(true); + cache.startBatch(); + cache.put("/a/b/c", "k", "v"); + cache.startBatch(); // again + cache.put("/a/b/c", "k2", "v2"); + cache.endBatch(true); + + assert "v".equals(cache.get("/a/b/c", "k")); + assert "v2".equals(cache.get("/a/b/c", "k2")); + } + finally + { + TestingUtil.killCaches(cache); + } + } + + public void testBatchVisibility() throws InterruptedException + { + Cache cache =3D null; + try + { + cache =3D createCache(true); + cache.startBatch(); + cache.put("/a/b/c", "k", "v"); + assert getOnDifferentThread(cache, "/a/b/c", "k") =3D=3D null : "= Other thread should not see batch update till batch completes!"; + + cache.endBatch(true); + + assert "v".equals(getOnDifferentThread(cache, "/a/b/c", "k")); + } + finally + { + TestingUtil.killCaches(cache); + } + } + + public void testBatchRollback() throws Exception + { + Cache cache =3D null; + try + { + cache =3D createCache(true); + cache.startBatch(); + cache.put("/a/b/c", "k", "v"); + cache.put("/a/b/c", "k2", "v2"); + + assert getOnDifferentThread(cache, "/a/b/c", "k") =3D=3D null; + assert getOnDifferentThread(cache, "/a/b/c", "k2") =3D=3D null; + + cache.endBatch(false); + + assert getOnDifferentThread(cache, "/a/b/c", "k") =3D=3D null; + assert getOnDifferentThread(cache, "/a/b/c", "k2") =3D=3D null; + } + finally + { + TestingUtil.killCaches(cache); + } + } + + private Cache createCache(boolean enableBatch) + { + CacheFactory cf =3D new DefaultCacheFactory(); + Configuration c =3D new Configuration(); + c.setNodeLockingScheme(NodeLockingScheme.MVCC); + c.setInvocationBatchingEnabled(enableBatch); + return cf.createCache(c); + } +} Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfig= urationParserTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParserTest.java 2008-08-07 16:04:06 UTC (rev 6539) +++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParserTest.java 2008-08-07 16:45:39 UTC (rev 6540) @@ -269,4 +269,9 @@ { assert config.getListenerAsyncPoolSize() =3D=3D 5; } + + public void testInvocationBatching() + { + assert config.isInvocationBatchingEnabled(); + } } Modified: core/trunk/src/test/java/org/jboss/cache/factories/InterceptorCha= inFactoryTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFact= oryTest.java 2008-08-07 16:04:06 UTC (rev 6539) +++ core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFact= oryTest.java 2008-08-07 16:45:39 UTC (rev 6540) @@ -67,7 +67,29 @@ assertInterceptorLinkage(list); } = + public void testBatchingConfig() throws Exception + { + cache.getConfiguration().setExposeManagementStatistics(false); + cache.getConfiguration().setInvocationBatchingEnabled(true); + InterceptorChain chain =3D getInterceptorChainFactory(cache).buildIn= terceptorChain(); + List list =3D chain.asList(); + Iterator interceptors =3D list.iterator(); = + System.out.println("testBareConfig interceptors are:\n" + list); + assertNotNull(list); + assertEquals(6, list.size()); + + assertEquals(BatchingInterceptor.class, interceptors.next().getClass= ()); + assertEquals(InvocationContextInterceptor.class, interceptors.next()= .getClass()); + assertEquals(TxInterceptor.class, interceptors.next().getClass()); + assertEquals(NotificationInterceptor.class, interceptors.next().getC= lass()); + assertEquals(PessimisticLockInterceptor.class, interceptors.next().g= etClass()); + assertEquals(CallInterceptor.class, interceptors.next().getClass()); + + assertInterceptorLinkage(list); + } + + public void testMvccConfig() throws Exception { cache.getConfiguration().setExposeManagementStatistics(false); Modified: core/trunk/src/test/resources/configs/parser-test.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/resources/configs/parser-test.xml 2008-08-07 16:04:= 06 UTC (rev 6539) +++ core/trunk/src/test/resources/configs/parser-test.xml 2008-08-07 16:45:= 39 UTC (rev 6540) @@ -113,4 +113,5 @@ = + --===============4972963757416450280==-- From jbosscache-commits at lists.jboss.org Thu Aug 7 14:43:09 2008 Content-Type: multipart/mixed; boundary="===============3281989814926838519==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6541 - in core/trunk/src: main/java/org/jboss/cache/factories and 6 other directories. Date: Thu, 07 Aug 2008 14:43:09 -0400 Message-ID: --===============3281989814926838519== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-07 14:43:08 -0400 (Thu, 07 Aug 2008) New Revision: 6541 Added: core/trunk/src/main/java/org/jboss/cache/interceptors/base/JmxStatistics= Interceptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/base/JmxStatsComma= ndInterceptor.java core/trunk/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java core/trunk/src/main/java/org/jboss/cache/jmx/annotations/ core/trunk/src/main/java/org/jboss/cache/jmx/annotations/MBean.java core/trunk/src/main/java/org/jboss/cache/jmx/annotations/ManagedAttribut= e.java core/trunk/src/main/java/org/jboss/cache/jmx/annotations/ManagedOperatio= n.java core/trunk/src/test/java/org/jboss/cache/jmx/ResourceDMBeanTest.java Removed: core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationIntercep= torMBean.java core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterce= ptorMBean.java core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtIntercept= orMBean.java core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreIntercep= torMBean.java core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorMBean.j= ava core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterc= eptorMBean.java core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextI= nterceptorMBean.java core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterce= ptorMBean.java core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptorMBean= .java Modified: core/trunk/src/main/java/org/jboss/cache/CacheSPI.java core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFacto= ry.java core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationIntercep= tor.java core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterce= ptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtIntercept= or.java core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreIntercep= tor.java core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterc= eptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextI= nterceptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyActivationIn= terceptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyCacheLoaderI= nterceptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterce= ptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/base/CommandInterc= eptor.java core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDeleg= ate.java core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapperMBean.java core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java core/trunk/src/test/java/org/jboss/cache/jmx/CacheJmxWrapperTestBase.java core/trunk/src/test/java/org/jboss/cache/jmx/InterceptorRegistrationTest= .java Log: JBCACHE-1305 - JMX through annotations Modified: core/trunk/src/main/java/org/jboss/cache/CacheSPI.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/CacheSPI.java 2008-08-07 16:45= :39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/CacheSPI.java 2008-08-07 18:43= :08 UTC (rev 6541) @@ -18,6 +18,7 @@ import org.jboss.cache.statetransfer.StateTransferManager; import org.jboss.cache.transaction.GlobalTransaction; import org.jboss.cache.transaction.TransactionTable; +import org.jboss.cache.factories.ComponentRegistry; = import javax.transaction.Transaction; import javax.transaction.TransactionManager; @@ -329,4 +330,11 @@ * @return Set an unmodifiable set of children names, Object. */ Set getChildrenNames(String fqn); + + /** + * Returns the component registry associated with this cache instance. + * + * @see org.jboss.cache.factories.ComponentRegistry + */ + ComponentRegistry getComponentRegistry(); } Modified: core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-= 08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-= 08-07 18:43:08 UTC (rev 6541) @@ -14,8 +14,12 @@ import org.jboss.cache.factories.ComponentFactory; import org.jboss.cache.factories.ComponentRegistry; import org.jboss.cache.invocation.CacheInvocationDelegate; +import org.jboss.cache.jmx.MBeanRegistryHelper; +import org.jboss.cache.jmx.CacheJmxWrapper; +import org.jboss.cache.jmx.ResourceDMBean; = import java.io.InputStream; +import java.util.Set; = /** * Default implementation of the {@link org.jboss.cache.CacheFactory} inte= rface. @@ -123,6 +127,10 @@ this.configuration =3D configuration; = componentRegistry.registerComponent(spi, CacheSPI.class); + if (configuration.getExposeManagementStatistics()) + { + componentRegistry.registerComponent(new MBeanRegistryHelper(compo= nentRegistry), MBeanRegistryHelper.class); + } } = /** Modified: core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegis= try.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.ja= va 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.ja= va 2008-08-07 18:43:08 UTC (rev 6541) @@ -920,6 +920,16 @@ { for (Method m : injectionMethods) invokeInjectionMethod(instance,= m); } + + public Object getInstance() + { + return instance; + } + + public String getName() + { + return name; + } } = = @@ -951,4 +961,13 @@ '}'; } } + + /** + * Returns an immutable set contating all the components that exists in= the reporsitory at this moment. + */ + public Set getRegiteredComponents() + { + HashSet defensiveCopy =3D new HashSet(componen= tLookup.values()); + return Collections.unmodifiableSet(defensiveCopy); + } } Modified: core/trunk/src/main/java/org/jboss/cache/factories/InterceptorCha= inFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFact= ory.java 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFact= ory.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -49,7 +49,6 @@ // wipe next/last chaining!! chainedInterceptor.setNext(null); } - chainedInterceptor.setStatisticsEnabled(configuration.getExposeManag= ementStatistics()); return chainedInterceptor; } = Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationI= nterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterce= ptor.java 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterce= ptor.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -3,6 +3,8 @@ import org.jboss.cache.Fqn; import org.jboss.cache.InternalNode; import org.jboss.cache.Modification; +import org.jboss.cache.jmx.annotations.ManagedAttribute; +import org.jboss.cache.jmx.annotations.ManagedOperation; import org.jboss.cache.commands.AbstractVisitor; import org.jboss.cache.commands.read.GetChildrenNamesCommand; import org.jboss.cache.commands.read.GetKeyValueCommand; @@ -40,7 +42,7 @@ * @author {Hany Mesha} * @version $Id$ */ -public class ActivationInterceptor extends CacheLoaderInterceptor implemen= ts ActivationInterceptorMBean +public class ActivationInterceptor extends CacheLoaderInterceptor { = protected TransactionManager txMgr =3D null; @@ -263,30 +265,6 @@ } } = - public long getActivations() - { - return activations; - } - - @Override - public void resetStatistics() - { - super.resetStatistics(); - activations =3D 0; - } - - @Override - public Map dumpStatistics() - { - Map retval =3D super.dumpStatistics(); - if (retval =3D=3D null) - { - retval =3D new HashMap(); - } - retval.put("Activations", activations); - return retval; - } - private void prepareCacheLoader(InvocationContext ctx) throws Throwable { GlobalTransaction gtx =3D ctx.getGlobalTransaction(); @@ -308,6 +286,7 @@ { = private List cacheLoaderModifications =3D new ArrayLis= t(); + private int txActs =3D 0; = @Override @@ -387,5 +366,31 @@ { return txActs; } + } + + @ManagedAttribute(description =3D "number of cache node activations") + public long getActivations() + { + return activations; + } + + @ManagedOperation + public void resetStatistics() + { + super.resetStatistics(); + activations =3D 0; + } + + @ManagedOperation + public Map dumpStatistics() + { + Map retval =3D super.dumpStatistics(); + if (retval =3D=3D null) + { + retval =3D new HashMap(); + } + retval.put("Activations", activations); + return retval; + } } Deleted: core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationIn= terceptorMBean.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterce= ptorMBean.java 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterce= ptorMBean.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -1,38 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.jboss.cache.interceptors; - -/** - * Interface capturing activation statistics - * @author Jerry Gauthier - * @version $Id$ - */ -public interface ActivationInterceptorMBean extends CacheLoaderInterceptor= MBean -{ - /** - * Returns the number of cache node activations - * = - * @return the number of cache node activations - */ - long getActivations(); - -} Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoader= Interceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterc= eptor.java 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterc= eptor.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -5,6 +5,9 @@ import org.jboss.cache.Fqn; import org.jboss.cache.InternalNode; import org.jboss.cache.NodeSPI; +import org.jboss.cache.jmx.annotations.ManagedAttribute; +import org.jboss.cache.jmx.annotations.ManagedOperation; +import org.jboss.cache.jmx.annotations.MBean; import org.jboss.cache.commands.read.GetChildrenNamesCommand; import org.jboss.cache.commands.read.GetDataMapCommand; import org.jboss.cache.commands.read.GetKeyValueCommand; @@ -24,6 +27,7 @@ import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; import org.jboss.cache.interceptors.base.CommandInterceptor; +import org.jboss.cache.interceptors.base.JmxStatsCommandInterceptor; import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.loader.CacheLoader; import org.jboss.cache.loader.CacheLoaderManager; @@ -45,7 +49,7 @@ * @author Bela Ban * @version $Id$ */ -public class CacheLoaderInterceptor extends CommandInterceptor implements = CacheLoaderInterceptorMBean +public class CacheLoaderInterceptor extends JmxStatsCommandInterceptor { private long cacheLoads =3D 0; private long cacheMisses =3D 0; @@ -397,32 +401,6 @@ return false; } = - public long getCacheLoaderLoads() - { - return cacheLoads; - } - - public long getCacheLoaderMisses() - { - return cacheMisses; - } - - @Override - public void resetStatistics() - { - cacheLoads =3D 0; - cacheMisses =3D 0; - } - - @Override - public Map dumpStatistics() - { - Map retval =3D new HashMap(); - retval.put("CacheLoaderLoads", cacheLoads); - retval.put("CacheLoaderMisses", cacheMisses); - return retval; - } - /** * Loads a node from disk; if it exists creates parent TreeNodes. * If it doesn't exist on disk but in memory, clears the @@ -483,4 +461,31 @@ return nodeData; } = + @ManagedAttribute (description =3D "number of cache loader node loads") + public long getCacheLoaderLoads() + { + return cacheLoads; + } + + @ManagedAttribute (description =3D "number of cache loader node misses") + public long getCacheLoaderMisses() + { + return cacheMisses; + } + + @ManagedOperation + public void resetStatistics() + { + cacheLoads =3D 0; + cacheMisses =3D 0; + } + + @ManagedOperation + public Map dumpStatistics() + { + Map retval =3D new HashMap(); + retval.put("CacheLoaderLoads", cacheLoads); + retval.put("CacheLoaderMisses", cacheMisses); + return retval; + } } \ No newline at end of file Deleted: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderI= nterceptorMBean.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterc= eptorMBean.java 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterc= eptorMBean.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -1,45 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.jboss.cache.interceptors; - -/** - * Interface capturing cache loader load statistics - * @author Jerry Gauthier - * @version $Id$ - */ -public interface CacheLoaderInterceptorMBean extends InterceptorMBean -{ - /** - * Returns the number of cache loader node loads - * = - * @return the number of cache loader node loads - */ - long getCacheLoaderLoads(); - = - /** - * Returns the number of cache loader node misses - * = - * @return the number of cache loader node misses - */ - long getCacheLoaderMisses(); - -} Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtIn= terceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtIntercep= tor.java 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtIntercep= tor.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -22,13 +22,15 @@ package org.jboss.cache.interceptors; = import org.jboss.cache.DataContainer; +import org.jboss.cache.jmx.annotations.ManagedAttribute; +import org.jboss.cache.jmx.annotations.ManagedOperation; import org.jboss.cache.commands.read.GetKeyValueCommand; import org.jboss.cache.commands.write.EvictCommand; import org.jboss.cache.commands.write.PutDataMapCommand; import org.jboss.cache.commands.write.PutForExternalReadCommand; import org.jboss.cache.commands.write.PutKeyValueCommand; import org.jboss.cache.factories.annotations.Inject; -import org.jboss.cache.interceptors.base.CommandInterceptor; +import org.jboss.cache.interceptors.base.JmxStatsCommandInterceptor; import org.jboss.cache.invocation.InvocationContext; = import java.util.HashMap; @@ -40,17 +42,17 @@ * @author Jerry Gauthier * @version $Id$ */ -public class CacheMgmtInterceptor extends CommandInterceptor implements Ca= cheMgmtInterceptorMBean +public class CacheMgmtInterceptor extends JmxStatsCommandInterceptor { - private long m_hit_times =3D 0; - private long m_miss_times =3D 0; - private long m_store_times =3D 0; - private long m_hits =3D 0; - private long m_misses =3D 0; - private long m_stores =3D 0; - private long m_evictions =3D 0; - private long m_start =3D System.currentTimeMillis(); - private long m_reset =3D m_start; + private long hitTimes =3D 0; + private long missTimes =3D 0; + private long storeTimes =3D 0; + private long hits =3D 0; + private long misses =3D 0; + private long stores =3D 0; + private long evictions =3D 0; + private long start =3D System.currentTimeMillis(); + private long reset =3D start; = private DataContainer dataContainer; = @@ -64,7 +66,7 @@ public Object visitEvictFqnCommand(InvocationContext ctx, EvictCommand = command) throws Throwable { Object returnValue =3D invokeNextInterceptor(ctx, command); - m_evictions++; + evictions++; return returnValue; } = @@ -76,13 +78,13 @@ long t2 =3D System.currentTimeMillis(); if (retval =3D=3D null) { - m_miss_times =3D m_miss_times + (t2 - t1); - m_misses++; + missTimes =3D missTimes + (t2 - t1); + misses++; } else { - m_hit_times =3D m_hit_times + (t2 - t1); - m_hits++; + hitTimes =3D hitTimes + (t2 - t1); + hits++; } return retval; } @@ -97,8 +99,8 @@ = if (data !=3D null && data.size() > 0) { - m_store_times =3D m_store_times + (t2 - t1); - m_stores =3D m_stores + data.size(); + storeTimes =3D storeTimes + (t2 - t1); + stores =3D stores + data.size(); } return retval; } @@ -116,89 +118,101 @@ long t1 =3D System.currentTimeMillis(); Object retval =3D invokeNextInterceptor(ctx, command); long t2 =3D System.currentTimeMillis(); - m_store_times =3D m_store_times + (t2 - t1); - m_stores++; + storeTimes =3D storeTimes + (t2 - t1); + stores++; return retval; } = + @ManagedAttribute(description =3D "number of cache attribute hits") public long getHits() { - return m_hits; + return hits; } = + @ManagedAttribute (description =3D "number of cache attribute misses") public long getMisses() { - return m_misses; + return misses; } = + @ManagedAttribute (description =3D "number of cache attribute put opera= tions") public long getStores() { - return m_stores; + return stores; } = + @ManagedAttribute (description =3D "number of cache eviction operations= ") public long getEvictions() { - return m_evictions; + return evictions; } = + @ManagedAttribute (description =3D "hit/miss ratio for the cache") public double getHitMissRatio() { - double total =3D m_hits + m_misses; + double total =3D hits + misses; if (total =3D=3D 0) return 0; - return (m_hits / total); + return (hits / total); } = + @ManagedAttribute (description =3D "read/writes ratio for the cache") public double getReadWriteRatio() { - if (m_stores =3D=3D 0) + if (stores =3D=3D 0) return 0; - return (((double) (m_hits + m_misses) / (double) m_stores)); + return (((double) (hits + misses) / (double) stores)); } = + @ManagedAttribute (description =3D "average number of milliseconds for = a read operation") public long getAverageReadTime() { - long total =3D m_hits + m_misses; + long total =3D hits + misses; if (total =3D=3D 0) return 0; - return (m_hit_times + m_miss_times) / total; + return (hitTimes + missTimes) / total; } = + @ManagedAttribute (description =3D "average number of milliseconds for = a write operation") public long getAverageWriteTime() { - if (m_stores =3D=3D 0) + if (stores =3D=3D 0) return 0; - return (m_store_times) / m_stores; + return (storeTimes) / stores; } = + @ManagedAttribute (description =3D "number of cache eviction operations= ") public int getNumberOfAttributes() { return dataContainer.getNumberOfAttributes(); } = + @ManagedAttribute public int getNumberOfNodes() { return dataContainer.getNumberOfNodes(); } = + @ManagedAttribute (description =3D "seconds since cache started") public long getElapsedTime() { - return (System.currentTimeMillis() - m_start) / 1000; + return (System.currentTimeMillis() - start) / 1000; } = + @ManagedAttribute (description =3D "number of seconds since the cache s= tatistics were last reset") public long getTimeSinceReset() { - return (System.currentTimeMillis() - m_reset) / 1000; + return (System.currentTimeMillis() - reset) / 1000; } = - @Override + @ManagedOperation public Map dumpStatistics() { Map retval =3D new HashMap(); - retval.put("Hits", m_hits); - retval.put("Misses", m_misses); - retval.put("Stores", m_stores); - retval.put("Evictions", m_evictions); + retval.put("Hits", hits); + retval.put("Misses", misses); + retval.put("Stores", stores); + retval.put("Evictions", evictions); retval.put("NumberOfAttributes", dataContainer.getNumberOfAttributes= ()); retval.put("NumberOfNodes", dataContainer.getNumberOfNodes()); retval.put("ElapsedTime", getElapsedTime()); @@ -210,17 +224,17 @@ return retval; } = - @Override + @ManagedOperation public void resetStatistics() { - m_hits =3D 0; - m_misses =3D 0; - m_stores =3D 0; - m_evictions =3D 0; - m_hit_times =3D 0; - m_miss_times =3D 0; - m_store_times =3D 0; - m_reset =3D System.currentTimeMillis(); + hits =3D 0; + misses =3D 0; + stores =3D 0; + evictions =3D 0; + hitTimes =3D 0; + missTimes =3D 0; + storeTimes =3D 0; + reset =3D System.currentTimeMillis(); } } = Deleted: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtInt= erceptorMBean.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtIntercep= torMBean.java 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtIntercep= torMBean.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -1,109 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.jboss.cache.interceptors; - -/** - * Interface capturing basic cache management statistics - * - * @author Jerry Gauthier - * @version $Id$ - */ -public interface CacheMgmtInterceptorMBean extends InterceptorMBean -{ - /** - * Returns the number of cache attribute hits - * - * @return the number of cache hits - */ - long getHits(); - - /** - * Returns the number of cache attribute misses - * - * @return the number of cache misses - */ - long getMisses(); - - /** - * Returns the number of cache attribute put operations - * - * @return the number of cache put operations - */ - long getStores(); - - /** - * Returns the number of cache eviction operations - * - * @return the number of cache eviction operations - */ - long getEvictions(); - - int getNumberOfAttributes(); - - int getNumberOfNodes(); - - /** - * Returns the hit/miss ratio for the cache - * This ratio is defined as hits/(hits + misses) - * - * @return the hit/miss ratio for the cache - */ - double getHitMissRatio(); - - /** - * Returns the read/write ratio for the cache - * This ratio is defined as (hits + misses)/stores - * - * @return the read/writes ratio for the cache - */ - double getReadWriteRatio(); - - /** - * Returns average milliseconds for an attribute read operation - * This includes both hits and misses. - * - * @return the average number of milliseconds for a read operation - */ - long getAverageReadTime(); - - /** - * Returns average milliseconds for an attribute write operation - * - * @return the average number of milliseconds for a write operation - */ - long getAverageWriteTime(); - - /** - * Returns seconds since cache started - * - * @return the number of seconds since the cache was started - */ - long getElapsedTime(); - - /** - * Returns seconds since cache statistics reset - * If statistics haven't been reset, this will be the same as ElapsedTi= me - * - * @return the number of seconds since the cache statistics were last r= eset - */ - long getTimeSinceReset(); -} Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreI= nterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterce= ptor.java 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterce= ptor.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -4,6 +4,8 @@ import org.jboss.cache.Fqn; import org.jboss.cache.Modification; import org.jboss.cache.NodeSPI; +import org.jboss.cache.jmx.annotations.ManagedOperation; +import org.jboss.cache.jmx.annotations.ManagedAttribute; import org.jboss.cache.commands.AbstractVisitor; import org.jboss.cache.commands.VisitableCommand; import org.jboss.cache.commands.WriteCommand; @@ -46,7 +48,7 @@ * @author Bela Ban * @version $Id$ */ -public class CacheStoreInterceptor extends SkipCheckChainedInterceptor imp= lements CacheStoreInterceptorMBean +public class CacheStoreInterceptor extends SkipCheckChainedInterceptor { private CacheLoaderConfig loaderConfig =3D null; private TransactionManager txMgr =3D null; @@ -56,6 +58,7 @@ private CacheLoader loader; private CacheLoaderManager loaderManager; private boolean optimistic; + private boolean statsEnabled; = public CacheStoreInterceptor() { @@ -78,6 +81,7 @@ // this should only happen after the CacheLoaderManager has started,= since the CacheLoaderManager only creates the CacheLoader instance in it's= @Start method. loader =3D loaderManager.getCacheLoader(); optimistic =3D configuration.getNodeLockingScheme() =3D=3D NodeLocki= ngScheme.OPTIMISTIC; + this.setStatisticsEnabled(configuration.getExposeManagementStatistic= s()); } = /** @@ -317,25 +321,6 @@ } } = - public long getCacheLoaderStores() - { - return cacheStores; - } - - @Override - public void resetStatistics() - { - cacheStores =3D 0; - } - - @Override - public Map dumpStatistics() - { - Map retval =3D new HashMap(); - retval.put("CacheLoaderStores", cacheStores); - return retval; - } - private void prepareCacheLoader(GlobalTransaction gtx, TransactionConte= xt transactionContext, boolean onePhase) throws Throwable { if (transactionContext =3D=3D null) @@ -372,9 +357,13 @@ = public static class StoreModificationsBuilder extends AbstractVisitor { + boolean generateStatistics; + int putCount; + Set affectedFqns =3D new HashSet(); + List modifications =3D new ArrayList(); = public StoreModificationsBuilder(boolean generateStatistics) @@ -435,5 +424,39 @@ modifications.add(mod); return null; } + } + + @ManagedOperation + public void resetStatistics() + { + cacheStores =3D 0; + } + + @ManagedOperation + public Map dumpStatistics() + { + Map retval =3D new HashMap(); + retval.put("CacheLoaderStores", cacheStores); + return retval; + } + + @ManagedAttribute + public boolean getStatisticsEnabled() + { + return statsEnabled; + } + + @ManagedAttribute + public void setStatisticsEnabled(boolean enabled) + { + this.statsEnabled =3D enabled; + } + + @ManagedAttribute(description =3D "number of cache loader stores") + public long getCacheLoaderStores() + { + return cacheStores; + } + } Deleted: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreIn= terceptorMBean.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterce= ptorMBean.java 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterce= ptorMBean.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -1,38 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.jboss.cache.interceptors; - -/** - * Interface capturing cache loader statistics - * @author Jerry Gauthier - * @version $Id$ - */ -public interface CacheStoreInterceptorMBean extends InterceptorMBean -{ - /** - * Returns the number of cache loader stores - * = - * @return the number of cache loader stores - */ - long getCacheLoaderStores(); - -} Deleted: core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorM= Bean.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorMBean.= java 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorMBean.= java 2008-08-07 18:43:08 UTC (rev 6541) @@ -1,63 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.jboss.cache.interceptors; - -import java.util.Map; - -/** - * Interface containing common cache management operations - * - * @author Jerry Gauthier - * @version $Id$ - */ -public interface InterceptorMBean -{ - /** - * Returns whether an interceptor's statistics are - * being captured. - * - * @return true if statistics are captured - */ - boolean getStatisticsEnabled(); - - /** - * Enables an interceptor's cache statistics - * If true, the interceptor will capture statistics - * and make them available through the mbean. - * - * @param enabled true if statistics should be captured - */ - void setStatisticsEnabled(boolean enabled); - - /** - * Returns a map of the cache interceptor's statistics - * Map is keyed on statistic names (which are Strings) and values are O= bjects. - * - * @return a map containing statistics - */ - Map dumpStatistics(); - - /** - * Resets an interceptor's cache statistics - */ - void resetStatistics(); -} Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/Invalidatio= nInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInter= ceptor.java 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInter= ceptor.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -7,6 +7,8 @@ package org.jboss.cache.interceptors; = import org.jboss.cache.Fqn; +import org.jboss.cache.jmx.annotations.ManagedOperation; +import org.jboss.cache.jmx.annotations.ManagedAttribute; import org.jboss.cache.commands.AbstractVisitor; import org.jboss.cache.commands.CommandsFactory; import org.jboss.cache.commands.VisitableCommand; @@ -60,12 +62,13 @@ * * @author Manik Surtani (manik(a)jbo= ss.org) */ -public class InvalidationInterceptor extends BaseRpcInterceptor implements= InvalidationInterceptorMBean +public class InvalidationInterceptor extends BaseRpcInterceptor = { private long invalidations =3D 0; protected Map> txMods; protected boolean optimistic; private CommandsFactory commandsFactory; + private boolean statsEnabled; = @Inject public void injectDependencies(CommandsFactory commandsFactory) @@ -78,6 +81,7 @@ { optimistic =3D configuration.getNodeLockingScheme() =3D=3D NodeLocki= ngScheme.OPTIMISTIC; if (optimistic) txMods =3D new ConcurrentHashMap>(); + this.setStatisticsEnabled(configuration.getExposeManagementStatistic= s()); } = @Override @@ -350,25 +354,6 @@ } = = - public long getInvalidations() - { - return invalidations; - } - - @Override - public void resetStatistics() - { - invalidations =3D 0; - } - - @Override - public Map dumpStatistics() - { - Map retval =3D new HashMap(); - retval.put("Invalidations", invalidations); - return retval; - } - protected void invalidateAcrossCluster(Fqn fqn, TransactionWorkspace wo= rkspace, boolean synchronous, InvocationContext ctx) throws Throwable { if (!isLocalModeForced(ctx)) @@ -410,4 +395,36 @@ OptimisticTransactionContext entry =3D (OptimisticTransactionContext= ) ctx.getTransactionContext(); return entry.getTransactionWorkSpace(); } + + @ManagedOperation + public void resetStatistics() + { + invalidations =3D 0; + } + + @ManagedOperation + public Map dumpStatistics() + { + Map retval =3D new HashMap(); + retval.put("Invalidations", invalidations); + return retval; + } + + @ManagedAttribute + public boolean getStatisticsEnabled() + { + return this.statsEnabled; + } + + @ManagedAttribute + public void setStatisticsEnabled(boolean enabled) + { + this.statsEnabled =3D enabled; + } + + @ManagedAttribute (description =3D "number of invalidations") + public long getInvalidations() + { + return invalidations; + } } Deleted: core/trunk/src/main/java/org/jboss/cache/interceptors/Invalidation= InterceptorMBean.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInter= ceptorMBean.java 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInter= ceptorMBean.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -1,38 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.jboss.cache.interceptors; - -/** - * Interface capturing invalidation statistics - * @author Jerry Gauthier - * @version $Id$ - */ -public interface InvalidationInterceptorMBean extends InterceptorMBean -{ - /** - * Returns the number of cache invalidations - * = - * @return the number of invalidations - */ - long getInvalidations(); - -} Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationC= ontextInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContext= Interceptor.java 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContext= Interceptor.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -33,7 +33,7 @@ * * @author Manik Surtani (manik(a)jbo= ss.org) */ -public class InvocationContextInterceptor extends BaseTransactionalContext= Interceptor implements InvocationContextInterceptorMBean +public class InvocationContextInterceptor extends BaseTransactionalContext= Interceptor { private RPCManager rpcManager; = Deleted: core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationCo= ntextInterceptorMBean.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContext= InterceptorMBean.java 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContext= InterceptorMBean.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -1,10 +0,0 @@ -package org.jboss.cache.interceptors; - -/** - * MBean to the {@link InvocationContextInterceptor} - * - * @author Manik Surtani - */ -public interface InvocationContextInterceptorMBean extends InterceptorMBean -{ -} Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyActiv= ationInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyActivationI= nterceptor.java 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyActivationI= nterceptor.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -3,6 +3,7 @@ import org.jboss.cache.Fqn; import org.jboss.cache.Modification; import org.jboss.cache.NodeSPI; +import org.jboss.cache.jmx.annotations.ManagedOperation; import org.jboss.cache.commands.AbstractVisitor; import org.jboss.cache.commands.read.GetChildrenNamesCommand; import org.jboss.cache.commands.read.GetKeyValueCommand; @@ -42,7 +43,7 @@ * @deprecated will be removed along with optimistic and pessimistic locki= ng. */ @Deprecated -public class LegacyActivationInterceptor extends LegacyCacheLoaderIntercep= tor implements ActivationInterceptorMBean +public class LegacyActivationInterceptor extends LegacyCacheLoaderIntercep= tor = { = protected TransactionManager txMgr =3D null; @@ -270,25 +271,6 @@ return activations; } = - @Override - public void resetStatistics() - { - super.resetStatistics(); - activations =3D 0; - } - - @Override - public Map dumpStatistics() - { - Map retval =3D super.dumpStatistics(); - if (retval =3D=3D null) - { - retval =3D new HashMap(); - } - retval.put("Activations", activations); - return retval; - } - private void prepareCacheLoader(InvocationContext ctx) throws Throwable { GlobalTransaction gtx =3D ctx.getGlobalTransaction(); @@ -310,6 +292,7 @@ { = private List cacheLoaderModifications =3D new ArrayLis= t(); + private int txActs =3D 0; = @Override @@ -389,5 +372,25 @@ { return txActs; } + } + + @ManagedOperation + public void resetStatistics() + { + super.resetStatistics(); + activations =3D 0; + } + + @ManagedOperation + public Map dumpStatistics() + { + Map retval =3D super.dumpStatistics(); + if (retval =3D=3D null) + { + retval =3D new HashMap(); + } + retval.put("Activations", activations); + return retval; + } } \ No newline at end of file Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyCache= LoaderInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyCacheLoader= Interceptor.java 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyCacheLoader= Interceptor.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -5,26 +5,18 @@ import org.jboss.cache.Fqn; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.WriteCommand; -import org.jboss.cache.commands.read.GetChildrenNamesCommand; -import org.jboss.cache.commands.read.GetDataMapCommand; -import org.jboss.cache.commands.read.GetKeyValueCommand; -import org.jboss.cache.commands.read.GetKeysCommand; -import org.jboss.cache.commands.read.GetNodeCommand; +import org.jboss.cache.commands.read.*; import org.jboss.cache.commands.tx.RollbackCommand; -import org.jboss.cache.commands.write.ClearDataCommand; -import org.jboss.cache.commands.write.MoveCommand; -import org.jboss.cache.commands.write.PutDataMapCommand; -import org.jboss.cache.commands.write.PutForExternalReadCommand; -import org.jboss.cache.commands.write.PutKeyValueCommand; -import org.jboss.cache.commands.write.RemoveKeyCommand; -import org.jboss.cache.commands.write.RemoveNodeCommand; +import org.jboss.cache.commands.write.*; import org.jboss.cache.config.Configuration; import static org.jboss.cache.config.Configuration.CacheMode; import org.jboss.cache.config.Configuration.NodeLockingScheme; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; -import org.jboss.cache.interceptors.base.CommandInterceptor; +import org.jboss.cache.interceptors.base.JmxStatsCommandInterceptor; import org.jboss.cache.invocation.InvocationContext; +import org.jboss.cache.jmx.annotations.ManagedAttribute; +import org.jboss.cache.jmx.annotations.ManagedOperation; import org.jboss.cache.loader.CacheLoader; import org.jboss.cache.loader.CacheLoaderManager; import org.jboss.cache.lock.LockManager; @@ -34,12 +26,7 @@ import org.jboss.cache.transaction.TransactionContext; import org.jboss.cache.transaction.TransactionTable; = -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.ListIterator; -import java.util.Map; -import java.util.Set; +import java.util.*; = /** * Loads nodes that don't exist at the time of the call into memory from t= he CacheLoader @@ -49,7 +36,7 @@ * @deprecated will be removed along with optimistic and pessimistic locki= ng. */ @Deprecated -public class LegacyCacheLoaderInterceptor extends CommandInterceptor imple= ments CacheLoaderInterceptorMBean +public class LegacyCacheLoaderInterceptor extends JmxStatsCommandIntercept= or { private long cacheLoads =3D 0; private long cacheMisses =3D 0; @@ -430,32 +417,6 @@ return false; } = - public long getCacheLoaderLoads() - { - return cacheLoads; - } - - public long getCacheLoaderMisses() - { - return cacheMisses; - } - - @Override - public void resetStatistics() - { - cacheLoads =3D 0; - cacheMisses =3D 0; - } - - @Override - public Map dumpStatistics() - { - Map retval =3D new HashMap(); - retval.put("CacheLoaderLoads", cacheLoads); - retval.put("CacheLoaderMisses", cacheMisses); - return retval; - } - protected void lock(Fqn fqn, LockType lockType, boolean recursive, Invo= cationContext ctx) throws Throwable { if (configuration.getNodeLockingScheme() =3D=3D NodeLockingScheme.OP= TIMISTIC) return; @@ -582,4 +543,32 @@ return nodeData; } = + @ManagedAttribute(description =3D "number of cache loader node loads") + public long getCacheLoaderLoads() + { + return cacheLoads; + } + + @ManagedAttribute(description =3D "number of cache loader node misses") + public long getCacheLoaderMisses() + { + return cacheMisses; + } + + @ManagedOperation + public void resetStatistics() + { + cacheLoads =3D 0; + cacheMisses =3D 0; + } + + @ManagedOperation + public Map dumpStatistics() + { + Map retval =3D new HashMap(); + retval.put("CacheLoaderLoads", cacheLoads); + retval.put("CacheLoaderMisses", cacheMisses); + return retval; + } + } \ No newline at end of file Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/Passivation= Interceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterc= eptor.java 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterc= eptor.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -4,8 +4,11 @@ import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.write.EvictCommand; import org.jboss.cache.factories.annotations.Inject; -import org.jboss.cache.interceptors.base.CommandInterceptor; +import org.jboss.cache.factories.annotations.Start; +import org.jboss.cache.interceptors.base.JmxStatsCommandInterceptor; import org.jboss.cache.invocation.InvocationContext; +import org.jboss.cache.jmx.annotations.ManagedAttribute; +import org.jboss.cache.jmx.annotations.ManagedOperation; import org.jboss.cache.loader.CacheLoader; import org.jboss.cache.loader.CacheLoaderManager; import org.jboss.cache.notifications.Notifier; @@ -22,7 +25,7 @@ * @author {Hany Mesha} * @version $Id$ */ -public class PassivationInterceptor extends CommandInterceptor implements = PassivationInterceptorMBean +public class PassivationInterceptor extends JmxStatsCommandInterceptor { = private final AtomicLong passivations =3D new AtomicLong(0); @@ -80,25 +83,6 @@ } } = - public long getPassivations() - { - return passivations.get(); - } - - @Override - public void resetStatistics() - { - passivations.set(0); - } - - @Override - public Map dumpStatistics() - { - Map retval =3D new HashMap(); - retval.put("Passivations", passivations.get()); - return retval; - } - /** * Returns attributes for a node. */ @@ -122,9 +106,31 @@ = private static class NodeNotLoadedException extends Exception { + /** * The serialVersionUID */ private static final long serialVersionUID =3D -4078972305344328905L; + } + + @ManagedOperation + public void resetStatistics() + { + passivations.set(0); + } + + @ManagedOperation + public Map dumpStatistics() + { + Map retval =3D new HashMap(); + retval.put("Passivations", passivations.get()); + return retval; + } + + @ManagedAttribute (description =3D "number of cache node passivations") + public long getPassivations() + { + return passivations.get(); + } } Deleted: core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationI= nterceptorMBean.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterc= eptorMBean.java 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterc= eptorMBean.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -1,38 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.jboss.cache.interceptors; - -/** - * Interface capturing passivation statistics - * @author Jerry Gauthier - * @version $Id$ - */ -public interface PassivationInterceptorMBean extends InterceptorMBean -{ - /** - * Returns the number of cache node passivations - * = - * @return the number of cache node passivations - */ - long getPassivations(); - -} Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxIntercept= or.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.jav= a 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.jav= a 2008-08-07 18:43:08 UTC (rev 6541) @@ -9,6 +9,9 @@ import org.jboss.cache.CacheException; import org.jboss.cache.RPCManager; import org.jboss.cache.ReplicationException; +import org.jboss.cache.jmx.annotations.MBean; +import org.jboss.cache.jmx.annotations.ManagedAttribute; +import org.jboss.cache.jmx.annotations.ManagedOperation; import org.jboss.cache.commands.AbstractVisitor; import org.jboss.cache.commands.CommandsFactory; import org.jboss.cache.commands.ReplicableCommand; @@ -58,7 +61,7 @@ * @author Manik Surtani (manik(a)jbo= ss.org) * @author Steve Woodcock (stevew(a)= jofti.com) */ -public class TxInterceptor extends BaseTransactionalContextInterceptor imp= lements TxInterceptorMBean +public class TxInterceptor extends BaseTransactionalContextInterceptor { protected CommandsFactory commandsFactory; protected RPCManager rpcManager; @@ -77,6 +80,7 @@ private long rollbacks =3D 0; protected boolean optimistic =3D false; private LockManager lockManager; + private boolean statsEnabled; = @Inject public void intialize(RPCManager rpcManager, ContextFactory contextFact= ory, @@ -90,6 +94,7 @@ this.invocationContextContainer =3D icc; this.componentRegistry =3D componentRegistry; this.lockManager =3D lockManager; + setStatisticsEnabled(configuration.getExposeManagementStatistics()); } = @Override @@ -270,39 +275,6 @@ // JMX statistics // --------------------------------------------------------------------= ---- = - public long getPrepares() - { - return prepares; - } - - public long getCommits() - { - return commits; - } - - public long getRollbacks() - { - return rollbacks; - } - - @Override - public void resetStatistics() - { - prepares =3D 0; - commits =3D 0; - rollbacks =3D 0; - } - - @Override - public Map dumpStatistics() - { - Map retval =3D new HashMap(3); - retval.put("Prepares", prepares); - retval.put("Commits", commits); - retval.put("Rollbacks", rollbacks); - return retval; - } - // -------------------------------------------------------------- = /** @@ -1131,4 +1103,52 @@ return "TxInterceptor.LocalSynchronizationHandler(gtx=3D" + gtx += ", tx=3D" + getTxAsString() + ")"; } } + + @ManagedOperation + public void resetStatistics() + { + prepares =3D 0; + commits =3D 0; + rollbacks =3D 0; + } + + @ManagedOperation + public Map dumpStatistics() + { + Map retval =3D new HashMap(3); + retval.put("Prepares", prepares); + retval.put("Commits", commits); + retval.put("Rollbacks", rollbacks); + return retval; + } + + @ManagedAttribute + public boolean getStatisticsEnabled() + { + return this.statsEnabled; + } + + @ManagedAttribute + public void setStatisticsEnabled(boolean enabled) + { + this.statsEnabled =3D enabled; + } + + @ManagedAttribute (description =3D "number of transaction prepares") + public long getPrepares() + { + return prepares; + } + + @ManagedAttribute (description =3D "number of transaction commits") + public long getCommits() + { + return commits; + } + + @ManagedAttribute (description =3D "number of transaction rollbacks") + public long getRollbacks() + { + return rollbacks; + } } \ No newline at end of file Deleted: core/trunk/src/main/java/org/jboss/cache/interceptors/TxIntercepto= rMBean.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptorMBea= n.java 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptorMBea= n.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -1,52 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.jboss.cache.interceptors; - -/** - * Interface capturing transaction statistics - * @author Jerry Gauthier - * @version $Id$ - */ -public interface TxInterceptorMBean extends InterceptorMBean -{ - /** - * Returns the number of transaction prepares - * = - * @return the number of prepares - */ - long getPrepares(); - = - /** - * Returns the number of transaction commits - * = - * @return the number of commits - */ - long getCommits(); - = - /** - * Returns the number of transaction rollbacks - * = - * @return the number of rollbacks - */ - long getRollbacks(); - -} Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/base/Comman= dInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/base/CommandInter= ceptor.java 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/CommandInter= ceptor.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -6,13 +6,8 @@ import org.jboss.cache.commands.VisitableCommand; import org.jboss.cache.config.Configuration; import org.jboss.cache.factories.annotations.Inject; -import org.jboss.cache.factories.annotations.Start; -import org.jboss.cache.interceptors.InterceptorMBean; import org.jboss.cache.invocation.InvocationContext; = -import java.util.Collections; -import java.util.Map; - /** * This is the base class for all interceptors to extend, and implements t= he {@link org.jboss.cache.commands.Visitor} interface * allowing it to intercept invocations on {@link org.jboss.cache.commands= .VisitableCommand}s. @@ -36,9 +31,9 @@ * @see org.jboss.cache.interceptors.InterceptorChain * @since 2.2 */ -public class CommandInterceptor extends AbstractVisitor implements Interce= ptorMBean +public class CommandInterceptor extends AbstractVisitor { - private boolean statsEnabled =3D false; + = = private CommandInterceptor next; = @@ -59,47 +54,7 @@ this.configuration =3D configuration; } = - @Start - private void checkStatisticsUsed() - { - setStatisticsEnabled(configuration.getExposeManagementStatistics()); - } - /** - * @return true if gathering statistics for JMX is enabled on this inte= rceptor. - */ - public boolean getStatisticsEnabled() - { - return statsEnabled; - } - - /** - * @param enabled whether gathering statistics for JMX are enabled. - */ - public void setStatisticsEnabled(boolean enabled) - { - statsEnabled =3D enabled; - } - - /** - * Returns a map of statistics. This is a default implementation which= returns an empty map and should be overridden - * if it is to be meaningful. - * - * @return an empty map - */ - public Map dumpStatistics() - { - return Collections.emptyMap(); - } - - /** - * Resets statistics gathered. Is a no-op, and should be overridden if= it is to be meaningful. - */ - public void resetStatistics() - { - } - - /** * Retrieves the next interceptor in the chain. * * @return the next interceptor in the chain. Copied: core/trunk/src/main/java/org/jboss/cache/interceptors/base/JmxStati= sticsInterceptor.java (from rev 6532, core/trunk/src/main/java/org/jboss/ca= che/interceptors/InterceptorMBean.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/base/JmxStatistic= sInterceptor.java (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/JmxStatistic= sInterceptor.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -0,0 +1,63 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.cache.interceptors.base; + +import java.util.Map; + +/** + * Interface containing common cache management operations + * + * @author Jerry Gauthier + * @version $Id$ + */ +public interface JmxStatisticsInterceptor +{ + /** + * Returns whether an interceptor's statistics are + * being captured. + * + * @return true if statistics are captured + */ + boolean getStatisticsEnabled(); + + /** + * Enables an interceptor's cache statistics + * If true, the interceptor will capture statistics + * and make them available through the mbean. + * + * @param enabled true if statistics should be captured + */ + void setStatisticsEnabled(boolean enabled); + + /** + * Returns a map of the cache interceptor's statistics + * Map is keyed on statistic names (which are Strings) and values are O= bjects. + * + * @return a map containing statistics + */ + Map dumpStatistics(); + + /** + * Resets an interceptor's cache statistics + */ + void resetStatistics(); +} Property changes on: core/trunk/src/main/java/org/jboss/cache/interceptors/= base/JmxStatisticsInterceptor.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Added: core/trunk/src/main/java/org/jboss/cache/interceptors/base/JmxStatsC= ommandInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/base/JmxStatsComm= andInterceptor.java (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/JmxStatsComm= andInterceptor.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -0,0 +1,87 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2008, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.cache.interceptors.base; + +import org.jboss.cache.jmx.annotations.ManagedAttribute; +import org.jboss.cache.interceptors.base.JmxStatisticsInterceptor; +import org.jboss.cache.factories.annotations.Start; + +import java.util.Map; +import java.util.Collections; + +/** + * Base class for all the interceptors exposing management statistics. + * + * @author Mircea.Markus(a)jboss.com + * @since 3.0 + */ +public class JmxStatsCommandInterceptor extends CommandInterceptor impleme= nts JmxStatisticsInterceptor +{ + private boolean statsEnabled =3D false; + + @Start + public void checkStatisticsUsed() + { + setStatisticsEnabled(configuration.getExposeManagementStatistics()); + } + + /** + * Returns whether an interceptor's statistics are + * being captured. + * + * @return true if statistics are captured + */ + @ManagedAttribute + public boolean getStatisticsEnabled() + { + return statsEnabled; + } + + /** + * @param enabled whether gathering statistics for JMX are enabled. + */ + @ManagedAttribute + public void setStatisticsEnabled(boolean enabled) + { + statsEnabled =3D enabled; + } + + /** + * Returns a map of statistics. This is a default implementation which= returns an empty map and should be overridden + * if it is to be meaningful. + * + * @return an empty map + */ + public Map dumpStatistics() + { + return Collections.emptyMap(); + } + + /** + * Resets statistics gathered. Is a no-op, and should be overridden if= it is to be meaningful. + */ + public void resetStatistics() + { + } + + +} Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocati= onDelegate.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDele= gate.java 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDele= gate.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -38,6 +38,7 @@ import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.NonVolatile; import org.jboss.cache.factories.annotations.Start; +import org.jboss.cache.factories.ComponentRegistry; import org.jboss.cache.interceptors.base.CommandInterceptor; import org.jboss.cache.loader.CacheLoaderManager; import org.jboss.cache.marshall.Marshaller; @@ -619,6 +620,11 @@ return (Set) getChildrenNames(Fqn.fromString(fqn)); } = + public ComponentRegistry getComponentRegistry() + { + return componentRegistry; + } + public DataContainer getDataContainer() { return dataContainer; Modified: core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2008-= 08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2008-= 08-07 18:43:08 UTC (rev 6541) @@ -24,6 +24,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.*; +import org.jboss.cache.factories.ComponentRegistry; import org.jboss.cache.config.*; import org.jboss.cache.config.parsing.JGroupsStackParser; import org.jboss.cache.config.parsing.element.BuddyElementParser; @@ -40,6 +41,7 @@ import javax.management.*; import javax.transaction.TransactionManager; import java.util.List; +import java.util.ArrayList; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; = @@ -59,10 +61,10 @@ = private MBeanServer server; private String cacheObjectName; - private boolean interceptorsRegistered; + private boolean jmxResourceRegistered; private CacheSPI cache; private Configuration config; - private boolean registerInterceptors =3D true; + private boolean registerJmxResource =3D true; private final AtomicInteger listenerCount =3D new AtomicInteger(0); private final AtomicLong sequence =3D new AtomicLong(0); private final CacheNotificationListener cacheNotificationListener; @@ -83,6 +85,7 @@ private LoadersElementParser loadersElementParser =3D new LoadersElemen= tParser(); private EvictionElementParser evictionElementParser =3D new EvictionEle= mentParser(); private JGroupsStackParser stackParser =3D new JGroupsStackParser(); + private List resourceDMBeans =3D new ArrayList(); = // ----------------------------------------------------------- Construc= tors = @@ -198,14 +201,14 @@ return cache =3D=3D null ? "Cache is null" : formatHtml(CachePrinter= .printCacheLockingInfo(cache)); } = - public boolean getRegisterInterceptors() + public boolean getRegisterJmxResource() { - return registerInterceptors; + return registerJmxResource; } = - public void setRegisterInterceptors(boolean register) + public void setRegisterJmxResource(boolean register) { - this.registerInterceptors =3D register; + this.registerJmxResource =3D register; } = // ---------------------------------------------------- LegacyConfigur= ation @@ -607,7 +610,7 @@ = cache.start(); = - registerInterceptors(); + registerJmxResources(); = cacheStatus =3D CacheStatus.STARTED; sendStateChangeNotification(startingState, getState(), getClass()= .getSimpleName() + " started", null); @@ -640,8 +643,8 @@ if (cache.getCacheStatus() =3D=3D CacheStatus.DESTROYED) { // Cache was already destroyed externally; = - // so get rid of the interceptor mbeans - unregisterInterceptors(); + // so get rid of the jmx resources + unregisterJmxResources(); } = cacheStatus =3D CacheStatus.STOPPED; @@ -682,9 +685,9 @@ { cacheStatus =3D CacheStatus.DESTROYING; = - // The cache is destroyed, so we shouldn't leave the interceptors + // The cache is destroyed, so we shouldn't leave the ResourcesDMB= ean // in JMX, even if we didn't register them in create - unregisterInterceptors(); + unregisterJmxResources(); = if (cache !=3D null) cache.destroy(); @@ -725,12 +728,11 @@ if (notificationServiceName =3D=3D null) notificationServiceName =3D result.getCanonicalName(); cacheNotificationListener.setServiceName(notificationServiceName); - return result; } = /** - * Registers the cache's interceptors, if {@link #getRegisterIntercepto= rs()} + * Registers the cache's MBean resources, if {@link #getRegisterJmxReso= urce()} * is true. */ public void postRegister(Boolean registrationDone) @@ -738,16 +740,15 @@ if (Boolean.TRUE.equals(registrationDone)) { log.debug("Registered in JMX under " + cacheObjectName); - if (cache !=3D null && CacheStatus.STARTED.equals(cache.getCacheS= tatus())) { try { - registerInterceptors(); + registerJmxResources(); } catch (Exception e) { - log.error("Caught exception registering cache interceptors = with JMX", e); + log.error("Caught exception registering cache ResourcesDMBe= an with JMX", e); } } = @@ -763,12 +764,12 @@ } = /** - * Unregisters the interceptors, if {@link #getRegisterInterceptors()} = is + * Unregisters the ResourcesDMBean, if {@link #getRegisterJmxResource()= } is * true. */ public void postDeregister() { - unregisterInterceptors(); + unregisterJmxResources(); = server =3D null; registered =3D false; @@ -810,6 +811,10 @@ cache.addCacheListener(cacheNotificationListener); } } + if (config !=3D null) + { + this.registerJmxResource =3D config.getExposeManagementStatistics= (); + } } = public String getCacheObjectName() @@ -933,38 +938,56 @@ } } = - protected boolean registerInterceptors() throws CacheException + protected boolean registerJmxResources() throws CacheException { - if (registerInterceptors && !interceptorsRegistered && server !=3D n= ull) + if (registerJmxResource && !jmxResourceRegistered && server !=3D nul= l) { - log.debug("Registering interceptors"); + log.debug("Registering jmx resources"); List interc =3D cache.getInterceptorChain(); if (interc !=3D null && interc.size() > 0) { try { - JmxUtil.registerInterceptors(server, interc, cacheObjectNam= e); - interceptorsRegistered =3D true; + for (ComponentRegistry.Component component : cache.getCompo= nentRegistry().getRegiteredComponents()) + { + ResourceDMBean resourceDMBean =3D new ResourceDMBean(com= ponent.getInstance()); + if (resourceDMBean.isManagedResource()) + { + resourceDMBeans.add(resourceDMBean); + } + } = + for (ResourceDMBean resource: resourceDMBeans) + { + String resourceName =3D resource.getObject().getClass().= getSimpleName(); + ObjectName objectName =3D new ObjectName(cacheObjectName= + JmxUtil.JMX_RESOURCE_KEY + resourceName); + if (!server.isRegistered(objectName)) server.registerMBe= an(resource, objectName); + } + jmxResourceRegistered =3D true; return true; } catch (JMException e) { - throw new CacheException("Failed to register interceptors",= e); + throw new CacheException("Failed to register jmx resources"= , e); } } } return false; } = - protected void unregisterInterceptors() + protected void unregisterJmxResources() { - if (registerInterceptors && interceptorsRegistered && server !=3D nu= ll) + if (registerJmxResource && jmxResourceRegistered && server !=3D null) { try { log.debug("Unregistering interceptors"); - JmxUtil.unregisterInterceptors(server, cache.getInterceptorCha= in(), getCacheObjectName()); - interceptorsRegistered =3D false; + for (ResourceDMBean resource : resourceDMBeans) + { + String resourceName =3D resource.getObject().getClass().get= SimpleName(); + ObjectName objectName =3D new ObjectName(cacheObjectName + = JmxUtil.JMX_RESOURCE_KEY + resourceName); + if (server.isRegistered(objectName)) server.unregisterMBean= (objectName); + } + jmxResourceRegistered =3D false; } catch (Exception e) { Modified: core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapperMBean= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapperMBean.java = 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapperMBean.java = 2008-08-07 18:43:08 UTC (rev 6541) @@ -164,7 +164,7 @@ *

* Default is true. */ - boolean getRegisterInterceptors(); + boolean getRegisterJmxResource(); = /** * Sets whether this object should register the cache's interceptors @@ -172,5 +172,5 @@ *

* Default is true. */ - void setRegisterInterceptors(boolean register); + void setRegisterJmxResource(boolean register); } Modified: core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java 2008-08-07 16= :45:39 UTC (rev 6540) +++ core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java 2008-08-07 18= :43:08 UTC (rev 6541) @@ -23,6 +23,7 @@ = import org.jboss.cache.config.Configuration; import org.jboss.cache.interceptors.base.CommandInterceptor; +import org.jboss.cache.interceptors.base.JmxStatisticsInterceptor; = import javax.management.JMException; import javax.management.MBeanServer; @@ -49,7 +50,7 @@ public static final String CACHE_TYPE_KEY =3D "cacheType"; public static final String PLAIN_CACHE_TYPE =3D "Cache"; public static final String MBEAN_CLASS_SUFFIX =3D "MBean"; - public static final String INTERCEPTOR_KEY =3D ",cache-interceptor=3D"; + public static final String JMX_RESOURCE_KEY =3D ",jmx-resource=3D"; = public static void registerCacheMBean(MBeanServer server, CacheJmxWrapp= erMBean cache, String cacheObjectName) throws JMException @@ -61,58 +62,6 @@ } } = - /* - * Register the associated mbeans for cache interceptors - * - * @param server the mbean server with which the mbeans should be regis= tered - * @param cache the cache having the set of interceptors to be register= ed - * @param registerCache whether the cache itself should be registered - */ - public static void registerInterceptors(MBeanServer server, List interceptors, String cacheObjectName) - throws JMException - { - if (server =3D=3D null || interceptors =3D=3D null || cacheObjectNam= e =3D=3D null) - { - return; - } - - for (CommandInterceptor interceptor : interceptors) - { - if (!interceptor.getStatisticsEnabled()) - continue; - - boolean mbeanExists =3D true; - try - { - // the mbean for interceptor AbcInterceptor will be named AbcI= nterceptorMBean - Class.forName(interceptor.getClass().getName() + MBEAN_CLASS_S= UFFIX); - } - catch (Throwable e) - { - // if the class can't be instantiated, no mbean is available - mbeanExists =3D false; - } - - // for JDK 1.4, must parse name and remove package prefix - // for JDK 1.5, can use getSimpleName() to establish class name w= ithout package prefix - String className =3D interceptor.getClass().getName(); - String serviceName =3D cacheObjectName + INTERCEPTOR_KEY + classN= ame.substring(className.lastIndexOf('.') + 1); - - ObjectName objName =3D new ObjectName(serviceName); - if (!server.isRegistered(objName)) - { - if (mbeanExists) - // register associated interceptor mbean - { - server.registerMBean(interceptor, objName); - } - //else - // register dummy interceptor mbean - // server.registerMBean(new BaseInterceptor(), objName); - } - } - } - public static String getDefaultCacheObjectName(org.jboss.cache.Cache ca= che) { // get the cache's registration name @@ -131,7 +80,6 @@ { tmpName =3D PREFIX + config.getClusterName(); } - return tmpName; } = @@ -145,34 +93,4 @@ { server.unregisterMBean(new ObjectName(cacheObjectName)); } - - /* - * Unregister the associated mbeans for cache interceptors - * - * @param server the mbean server for which the mbeans should be unregis= tered - * @param cache the cache having the set of interceptors to be unregiste= red - * @param unregisterCache whether the cache itself should be unregistered - */ - public static void unregisterInterceptors(MBeanServer server, List interceptors, String cacheObjectName) - throws Exception - { - if (server =3D=3D null || interceptors =3D=3D null || cacheObjectNam= e =3D=3D null) - { - return; - } - - for (CommandInterceptor interceptor : interceptors) - { - // for JDK 1.4, must parse name and remove package prefix - // for JDK 1.5, can use getSimpleName() to establish class name w= ithout package prefix - String className =3D interceptor.getClass().getName(); - String serviceName =3D cacheObjectName + INTERCEPTOR_KEY + classN= ame.substring(className.lastIndexOf('.') + 1); - - ObjectName objName =3D new ObjectName(serviceName); - if (server.isRegistered(objName)) - { - server.unregisterMBean(objName); - } - } - } } Added: core/trunk/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java = (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java 2008-0= 8-07 18:43:08 UTC (rev 6541) @@ -0,0 +1,734 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2008, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.cache.jmx; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.cache.jmx.annotations.MBean; +import org.jboss.cache.jmx.annotations.ManagedAttribute; +import org.jboss.cache.jmx.annotations.ManagedOperation; + +import javax.management.*; +import java.util.HashMap; +import java.util.List; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.regex.Pattern; +import java.util.regex.Matcher; +import java.lang.reflect.Method; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; + +/** + * This class was entirely copied from jgroups (same name there). + * Couldn't simply reuse it because jgroups does not ship with MBean, Mana= gedAttribute and ManagedOperation. + * Once jgroups will ship these classes, the code can be dinalmically reus= ed from there. + * + * @author Mircea.Markus(a)jboss.com + * @since 3.0 + */ +public class ResourceDMBean implements DynamicMBean +{ + private static final Class[] primitives =3D {int.class, + byte.class, + short.class, + long.class, + float.class, + double.class, + boolean.class, + char.class}; + + private static final String MBEAN_DESCRITION =3D "Dynamic MBean Descrip= tion"; + + private final Log log =3D LogFactory.getLog(ResourceDMBean.class); + private final Object obj; + private String description =3D ""; + + private final MBeanAttributeInfo[] attrInfo; + private final MBeanOperationInfo[] opInfo; + + private final HashMap atts =3D new HashMap(); + private final List ops =3D new ArrayList(); + + public ResourceDMBean(Object instance) + { + + if (instance =3D=3D null) + throw new NullPointerException("Cannot make an MBean wrapper for = null instance"); + + this.obj =3D instance; + findDescription(); + findFields(); + findMethods(); + + attrInfo =3D new MBeanAttributeInfo[atts.size()]; + int i =3D 0; + log.info("Processing class " + instance.getClass()); + log.info("Attributes are:"); + MBeanAttributeInfo info =3D null; + for (AttributeEntry entry : atts.values()) + { + info =3D entry.getInfo(); + attrInfo[i++] =3D info; + log.info("Attribute " + info.getName() + + "[r=3D" + + info.isReadable() + + ",w=3D" + + info.isWritable() + + ",is=3D" + + info.isIs() + + ",type=3D" + + info.getType() + + "]"); + } + + opInfo =3D new MBeanOperationInfo[ops.size()]; + ops.toArray(opInfo); + + if (ops.size() > 0) + log.info("Operations are:"); + for (MBeanOperationInfo op : opInfo) + { + log.info("Operation " + op.getReturnType() + " " + op.getName()); + } + + } + + Object getObject() + { + return obj; + } + + private void findDescription() + { + MBean mbean =3D getObject().getClass().getAnnotation(MBean.class); + if (mbean !=3D null && mbean.description() !=3D null && mbean.descri= ption().trim().length() > 0) + { + description =3D mbean.description(); + if (log.isDebugEnabled()) + { + log.debug("@MBean description set - " + mbean.description()); + } + MBeanAttributeInfo info =3D new MBeanAttributeInfo(MBEAN_DESCRITI= ON, + "java.lang.String", + "@MBean description", + true, + false, + false); + try + { + atts.put(MBEAN_DESCRITION, + new FieldAttributeEntry(info, getClass().getDeclaredFiel= d("description"))); + } + catch (NoSuchFieldException e) + { + //this should not happen unless somebody removes description f= ield + log.warn("Could not reflect field description of this class. W= as it removed?"); + } + } + } + + public synchronized MBeanInfo getMBeanInfo() + { + + return new MBeanInfo(getObject().getClass().getCanonicalName(), + description, + attrInfo, + null, + opInfo, + null); + } + + public synchronized Object getAttribute(String name) + { + if (name =3D=3D null || name.length() =3D=3D 0) + throw new NullPointerException("Invalid attribute requested " + n= ame); + + if (log.isDebugEnabled()) + { + log.debug("getAttribute called for " + name); + } + Attribute attr =3D getNamedAttribute(name); + if (log.isDebugEnabled()) + { + log.debug("getAttribute value found " + attr.getValue()); + } + return attr.getValue(); + } + + public synchronized void setAttribute(Attribute attribute) + { + if (attribute =3D=3D null || attribute.getName() =3D=3D null) + throw new NullPointerException("Invalid attribute requested " + a= ttribute); + + setNamedAttribute(attribute); + } + + public synchronized AttributeList getAttributes(String[] names) + { + AttributeList al =3D new AttributeList(); + for (String name : names) + { + Attribute attr =3D getNamedAttribute(name); + if (attr !=3D null) + { + al.add(attr); + } + else + { + log.warn("Did not find attribute " + name); + } + } + return al; + } + + public synchronized AttributeList setAttributes(AttributeList list) + { + AttributeList results =3D new AttributeList(); + for (int i =3D 0; i < list.size(); i++) + { + Attribute attr =3D (Attribute) list.get(i); + + if (log.isDebugEnabled()) + { + log.debug("Attribute name " + attr.getName() + " new value is = " + attr.getValue()); + } + + if (setNamedAttribute(attr)) + { + results.add(attr); + } + else + { + if (log.isWarnEnabled()) + { + log.debug("Failed to update attribute name " + attr.getName= () + + " with value " + + attr.getValue()); + } + } + } + return results; + } + + public Object invoke(String name, Object[] args, String[] sig) throws M= BeanException, + ReflectionException + { + try + { + if (log.isDebugEnabled()) + { + log.debug("Invoke method called on " + name); + } + Class[] classes =3D new Class[sig.length]; + for (int i =3D 0; i < classes.length; i++) + { + classes[i] =3D getClassForName(sig[i]); + } + Method method =3D getObject().getClass().getMethod(name, classes); + return method.invoke(getObject(), args); + } + catch (Exception e) + { + throw new MBeanException(e); + } + } + + public static Class getClassForName(String name) throws ClassNotFoun= dException + { + try + { + Class c =3D Class.forName(name); + return c; + } + catch (ClassNotFoundException cnfe) + { + //Could be a primitive - let's check + for (int i =3D 0; i < primitives.length; i++) + { + if (name.equals(primitives[i].getName())) + { + return primitives[i]; + } + } + } + throw new ClassNotFoundException("Class " + name + " cannot be found= "); + } + + private void findMethods() + { + //find all methods but don't include methods from Object class + List methods =3D new ArrayList(Arrays.asList(getObje= ct().getClass().getMethods())); + List objectMethods =3D new ArrayList(Arrays.asList(O= bject.class.getMethods())); + methods.removeAll(objectMethods); + + for (Method method : methods) + { + //does method have @ManagedAttribute annotation? + ManagedAttribute attr =3D method.getAnnotation(ManagedAttribute.c= lass); + if (attr !=3D null) + { + String methodName =3D method.getName(); + if (!methodName.startsWith("get") && !methodName.startsWith("s= et") + && !methodName.startsWith("is")) + { + if (log.isWarnEnabled()) + log.warn("method name " + methodName + + " doesn't start with \"get\", \"set\", or \"is\"" + + ", but is annotated with @ManagedAttribute: will= be ignored"); + } + else + { + MBeanAttributeInfo info =3D null; + //Is name field of @ManagedAttributed used? + String attributeName =3D attr.name().length() > 0 ? attr.na= me().trim() : null; + boolean writeAttribute =3D false; + if (isSetMethod(method)) + { // setter + attributeName =3D (attributeName =3D=3D null) ? methodNa= me.substring(3) : attributeName; + info =3D new MBeanAttributeInfo(attributeName, + method.getParameterTypes()[0].getCanonicalName(), + attr.description(), + true, + true, + false); + writeAttribute =3D true; + } + else + { // getter + if (method.getParameterTypes().length =3D=3D 0 && method= .getReturnType() !=3D java.lang.Void.TYPE) + { + boolean hasSetter =3D atts.containsKey(attributeName); + //we found is method + if (methodName.startsWith("is")) + { + attributeName =3D (attributeName =3D=3D null) ? me= thodName.substring(2) : attributeName; + info =3D new MBeanAttributeInfo(attributeName, + method.getReturnType().getCanonicalName(), + attr.description(), + true, + hasSetter, + true); + } + else + { + //this has to be get + attributeName =3D (attributeName =3D=3D null) ? me= thodName.substring(3) : attributeName; + info =3D new MBeanAttributeInfo(attributeName, + method.getReturnType().getCanonicalName(), + attr.description(), + true, + hasSetter, + false); + } + } + else + { + if (log.isWarnEnabled()) + { + log.warn("Method " + method.getName() + + " must have a valid return type and zero p= arameters"); + } + continue; + } + } + + if (log.isDebugEnabled()) + { + log.debug("@Attr found for method " + method.getName() += " and registered as " + attributeName); + } + + AttributeEntry ae =3D atts.get(attributeName); + //is it a read method? + if (!writeAttribute) + { + //we already have annotated field as read + if (ae instanceof FieldAttributeEntry && ae.getInfo().is= Readable()) + { + log.warn("not adding annotated method " + method + + " since we already have read attribute"); + } + //we already have annotated set method + else if (ae instanceof MethodAttributeEntry) + { + MethodAttributeEntry mae =3D (MethodAttributeEntry) a= e; + if (mae.hasSetMethod()) + { + atts.put(attributeName, + new MethodAttributeEntry(mae.getInfo(), mae.= getSetMethod(), method)); + } + } //we don't have such entry + else + { + atts.put(attributeName, new MethodAttributeEntry(info= , null, method)); + } + }//is it a set method? + else + { + if (ae instanceof FieldAttributeEntry) + { + //we already have annotated field as write + if (ae.getInfo().isWritable()) + { + log.warn("Not adding annotated method " + methodNa= me + + " since we already have writable attribute= "); + } + else + { + //we already have annotated field as read + //lets make the field writable + Field f =3D ((FieldAttributeEntry) ae).getField(); + MBeanAttributeInfo i =3D new MBeanAttributeInfo(ae= .getInfo().getName(), + f.getType().getCanonicalName(), + attr.description(), + true, + Modifier.isFinal(f.getModifiers()) ? false := true, + false); + atts.put(attributeName, new FieldAttributeEntry(i,= f)); + } + } + //we already have annotated getOrIs method + else if (ae instanceof MethodAttributeEntry) + { + MethodAttributeEntry mae =3D (MethodAttributeEntry) a= e; + if (mae.hasIsOrGetMethod()) + { + atts.put(attributeName, + new MethodAttributeEntry(info, + method, + mae.getIsOrGetMethod())); + } + } //we don't have such entry + else + { + atts.put(attributeName, new MethodAttributeEntry(info= , method, null)); + } + } + } + } + else if (method.isAnnotationPresent(ManagedOperation.class) || is= MBeanAnnotationPresentWithExposeAll()) + { + ManagedOperation op =3D method.getAnnotation(ManagedOperation.= class); + String attName =3D method.getName(); + if (isSetMethod(method) || isGetMethod(method)) + { + attName =3D attName.substring(3); + } + else if (isIsMethod(method)) + { + attName =3D attName.substring(2); + } + //expose unless we already exposed matching attribute field + boolean isAlreadyExposed =3D atts.containsKey(attName); + if (!isAlreadyExposed) + { + ops.add(new MBeanOperationInfo(op !=3D null ? op.descriptio= n() : "", method)); + if (log.isDebugEnabled()) + { + log.debug("@Operation found for method " + method.getNam= e()); + } + } + } + } + } + + private boolean isSetMethod(Method method) + { + return (method.getName().startsWith("set") && + method.getParameterTypes().length =3D=3D 1 && + method.getReturnType() =3D=3D java.lang.Void.TYPE); + } + + private boolean isGetMethod(Method method) + { + return (method.getParameterTypes().length =3D=3D 0 && + method.getReturnType() !=3D java.lang.Void.TYPE && + method.getName().startsWith("get")); + } + + private boolean isIsMethod(Method method) + { + return (method.getParameterTypes().length =3D=3D 0 && + (method.getReturnType() =3D=3D boolean.class || method.getRetu= rnType() =3D=3D Boolean.class) && + method.getName().startsWith("is")); + } + + private void findFields() + { + //traverse class hierarchy and find all annotated fields + for (Class clazz =3D getObject().getClass(); clazz !=3D null; cla= zz =3D clazz.getSuperclass()) + { + + Field[] fields =3D clazz.getDeclaredFields(); + for (Field field : fields) + { + ManagedAttribute attr =3D field.getAnnotation(ManagedAttribute= .class); + if (attr !=3D null) + { + String fieldName =3D renameToJavaCodingConvention(field.get= Name()); + MBeanAttributeInfo info =3D new MBeanAttributeInfo(fieldNam= e, + field.getType().getCanonicalName(), + attr.description(), + true, + Modifier.isFinal(field.getModifiers()) ? false : attr= .writable(), + false); + + atts.put(fieldName, new FieldAttributeEntry(info, field)); + if (log.isDebugEnabled()) + { + log.debug("@Attr found for field " + field.getName()); + } + } + } + } + } + + private Attribute getNamedAttribute(String name) + { + Attribute result =3D null; + if (name.equals(MBEAN_DESCRITION)) + { + result =3D new Attribute(MBEAN_DESCRITION, this.description); + } + else + { + AttributeEntry entry =3D atts.get(name); + if (entry !=3D null) + { + MBeanAttributeInfo i =3D entry.getInfo(); + try + { + result =3D new Attribute(name, entry.invoke(null)); + if (log.isDebugEnabled()) + log.debug("Attribute " + name + + " has r=3D" + + i.isReadable() + + ",w=3D" + + i.isWritable() + + ",is=3D" + + i.isIs() + + " and value " + + result.getValue()); + } + catch (Exception e) + { + log.debug("Exception while reading value of attribute " + n= ame, e); + } + } + else + { + log.warn("Did not find queried attribute with name " + name); + } + } + return result; + } + + private boolean setNamedAttribute(Attribute attribute) + { + boolean result =3D false; + if (log.isDebugEnabled()) + log.debug("Invoking set on attribute " + attribute.getName() + + " with value " + + attribute.getValue()); + + AttributeEntry entry =3D atts.get(attribute.getName()); + if (entry !=3D null) + { + try + { + entry.invoke(attribute); + result =3D true; + } + catch (Exception e) + { + log.warn("Exception while writing value for attribute " + attr= ibute.getName(), e); + } + } + else + { + log.warn("Could not invoke set on attribute " + attribute.getName= () + + " with value " + + attribute.getValue()); + } + return result; + } + + + private String renameToJavaCodingConvention(String fieldName) + { + if (fieldName.contains("_")) + { + Pattern p =3D Pattern.compile("_."); + Matcher m =3D p.matcher(fieldName); + StringBuffer sb =3D new StringBuffer(); + while (m.find()) + { + m.appendReplacement(sb, fieldName.substring(m.end() - 1, m.end= ()).toUpperCase()); + } + m.appendTail(sb); + char first =3D sb.charAt(0); + if (Character.isLowerCase(first)) + { + sb.setCharAt(0, Character.toUpperCase(first)); + } + return sb.toString(); + } + else + { + if (Character.isLowerCase(fieldName.charAt(0))) + { + return fieldName.substring(0, 1).toUpperCase() + fieldName.sub= string(1); + } + else + { + return fieldName; + } + } + } + + private boolean isMBeanAnnotationPresentWithExposeAll() + { + Class c =3D getObject().getClass(); + return c.isAnnotationPresent(MBean.class) && c.getAnnotation(MBean.c= lass).exposeAll(); + } + + private class MethodAttributeEntry implements AttributeEntry + { + + final MBeanAttributeInfo info; + + final Method isOrGetmethod; + + final Method setMethod; + + public MethodAttributeEntry(final MBeanAttributeInfo info, + final Method setMethod, + final Method isOrGetMethod) + { + super(); + this.info =3D info; + this.setMethod =3D setMethod; + this.isOrGetmethod =3D isOrGetMethod; + } + + public Object invoke(Attribute a) throws Exception + { + if (a =3D=3D null && isOrGetmethod !=3D null) + return isOrGetmethod.invoke(getObject(), new Object[]{}); + else if (a !=3D null && setMethod !=3D null) + return setMethod.invoke(getObject(), new Object[]{a.getValue()= }); + else + return null; + } + + public MBeanAttributeInfo getInfo() + { + return info; + } + + public boolean hasIsOrGetMethod() + { + return isOrGetmethod !=3D null; + } + + public boolean hasSetMethod() + { + return setMethod !=3D null; + } + + public Method getIsOrGetMethod() + { + return isOrGetmethod; + } + + public Method getSetMethod() + { + return setMethod; + } + } + + private class FieldAttributeEntry implements AttributeEntry + { + + private final MBeanAttributeInfo info; + + private final Field field; + + public FieldAttributeEntry(final MBeanAttributeInfo info, final Fiel= d field) + { + super(); + this.info =3D info; + this.field =3D field; + if (!field.isAccessible()) + { + field.setAccessible(true); + } + } + + public Field getField() + { + return field; + } + + public Object invoke(Attribute a) throws Exception + { + if (a =3D=3D null) + { + return field.get(getObject()); + } + else + { + field.set(getObject(), a.getValue()); + return null; + } + } + + public MBeanAttributeInfo getInfo() + { + return info; + } + } + + private interface AttributeEntry + { + public Object invoke(Attribute a) throws Exception; + + public MBeanAttributeInfo getInfo(); + } + + public boolean isManagedResource() + { + return !atts.isEmpty() || !ops.isEmpty(); + } + + public boolean isOperationRegistred(String operationName) + { + for (MBeanOperationInfo opInfo : this.ops) + { + if (opInfo.getName().equals(operationName)) + { + return true; + } + } + return false; + } +} Added: core/trunk/src/main/java/org/jboss/cache/jmx/annotations/MBean.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/jmx/annotations/MBean.java = (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/jmx/annotations/MBean.java 200= 8-08-07 18:43:08 UTC (rev 6541) @@ -0,0 +1,42 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2008, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.cache.jmx.annotations; + +import java.lang.annotation.*; + +/** + * Classes anotaded with this will be exposed as MBeans. + * If you are looking for more fined grained way of exposing jmx attribute= s/operations, take a look at + * {@link org.jboss.cache.jmx.annotations.ManagedAttribute} and {@link org= .jboss.cache.jmx.annotations.ManagedOperation} = + * + * @author Mircea.Markus(a)jboss.com + * @since 3.0 + */ +(a)Retention(RetentionPolicy.RUNTIME) +(a)Target( { ElementType.TYPE }) +(a)Inherited +public @interface MBean +{ + String objectName() default ""; + boolean exposeAll() default false; + String description() default ""; +} Added: core/trunk/src/main/java/org/jboss/cache/jmx/annotations/ManagedAttr= ibute.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/jmx/annotations/ManagedAttribu= te.java (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/jmx/annotations/ManagedAttribu= te.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -0,0 +1,46 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2008, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.cache.jmx.annotations; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +/** + * Indicates that a public method or a field (any visibility) in + * an MBean class defines an MBean attribute. This annotation can + * be applied to either a field or a public setter and/or getter + * method of a public class that is itself is optionally annotated + * with an @MBean annotation, or inherits such an annotation from + * a superclass. + */ +(a)Retention(RetentionPolicy.RUNTIME) +(a)Target({ElementType.METHOD, ElementType.FIELD}) +public @interface ManagedAttribute +{ + String description() default ""; + + String name() default ""; + + boolean writable() default false; +} Added: core/trunk/src/main/java/org/jboss/cache/jmx/annotations/ManagedOper= ation.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/jmx/annotations/ManagedOperati= on.java (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/jmx/annotations/ManagedOperati= on.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -0,0 +1,41 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2008, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.cache.jmx.annotations; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +/** + * Indicates that a method in an MBean class defines an MBean + * operation. @ManagedOperation annotation can be applied to a + * public method of a public class that is itself optionally + * annotated with an @MBean annotation, or inherits such an + * annotation from a superclass. + */ +(a)Retention(RetentionPolicy.RUNTIME) +(a)Target({ElementType.METHOD}) +public @interface ManagedOperation +{ + String description() default ""; +} Modified: core/trunk/src/test/java/org/jboss/cache/jmx/CacheJmxWrapperTestB= ase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/jmx/CacheJmxWrapperTestBase.ja= va 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/test/java/org/jboss/cache/jmx/CacheJmxWrapperTestBase.ja= va 2008-08-07 18:43:08 UTC (rev 6541) @@ -156,9 +156,8 @@ { // should be 3 interceptor MBeans loaded: ObjectName[] interceptorMBeanNames =3D { - new ObjectName(baseName + JmxUtil.INTERCEPTOR_KEY + "TxInterce= ptor"), - new ObjectName(baseName + JmxUtil.INTERCEPTOR_KEY + "CacheMgmt= Interceptor"), - new ObjectName(baseName + JmxUtil.INTERCEPTOR_KEY + "Invocatio= nContextInterceptor") + new ObjectName(baseName + JmxUtil.JMX_RESOURCE_KEY + "TxInterc= eptor"), + new ObjectName(baseName + JmxUtil.JMX_RESOURCE_KEY + "CacheMgm= tInterceptor"), }; = for (ObjectName n : interceptorMBeanNames) Modified: core/trunk/src/test/java/org/jboss/cache/jmx/InterceptorRegistrat= ionTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/jmx/InterceptorRegistrationTes= t.java 2008-08-07 16:45:39 UTC (rev 6540) +++ core/trunk/src/test/java/org/jboss/cache/jmx/InterceptorRegistrationTes= t.java 2008-08-07 18:43:08 UTC (rev 6541) @@ -277,7 +277,7 @@ public void testRegisterInterceptors1() throws Exception { CacheJmxWrapper wrapper =3D createWrapper(createConf= iguration()); - wrapper.setRegisterInterceptors(false); + wrapper.setRegisterJmxResource(false); = registerWrapper(wrapper); = @@ -308,7 +308,7 @@ public void testRegisterInterceptors2() throws Exception { CacheJmxWrapper wrapper =3D createWrapper(createConf= iguration()); - wrapper.setRegisterInterceptors(false); + wrapper.setRegisterJmxResource(false); = wrapper.create(); wrapper.start(); Added: core/trunk/src/test/java/org/jboss/cache/jmx/ResourceDMBeanTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/jmx/ResourceDMBeanTest.java = (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/jmx/ResourceDMBeanTest.java 20= 08-08-07 18:43:08 UTC (rev 6541) @@ -0,0 +1,59 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2008, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.cache.jmx; + +import org.testng.annotations.Test; +import org.jboss.cache.interceptors.ActivationInterceptor; +import org.jboss.cache.jmx.annotations.ManagedOperation; + +/** + * Tester class for {@link ResourceDMBean}. + * + * @author Mircea.Markus(a)jboss.com + * @since 3.0 + */ +(a)Test (groups =3D "unit") +public class ResourceDMBeanTest +{ + + /** + * If we have a method in the base class that is annotated as @ManagedO= peration, will this be seen the same + * way in the inherited class? + */ + public void testInheritedMethod() + { + Bbb bbb =3D new Bbb(); + ResourceDMBean resourceDMBean =3D new ResourceDMBean(bbb); + assert resourceDMBean.isOperationRegistred("baseMethod"); + } + + static class Aaa + { + @ManagedOperation = + public void baseMethod() {} + } + + static class Bbb extends Aaa + { + public void localMethod() {} + } +} --===============3281989814926838519==-- From jbosscache-commits at lists.jboss.org Thu Aug 7 15:05:05 2008 Content-Type: multipart/mixed; boundary="===============2199676889724059350==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6542 - core/trunk/src/main/java/org/jboss/cache. Date: Thu, 07 Aug 2008 15:05:05 -0400 Message-ID: --===============2199676889724059350== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-07 15:05:04 -0400 (Thu, 07 Aug 2008) New Revision: 6542 Modified: core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java Log: fixed wrong commit Modified: core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-= 08-07 18:43:08 UTC (rev 6541) +++ core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-= 08-07 19:05:04 UTC (rev 6542) @@ -14,12 +14,8 @@ import org.jboss.cache.factories.ComponentFactory; import org.jboss.cache.factories.ComponentRegistry; import org.jboss.cache.invocation.CacheInvocationDelegate; -import org.jboss.cache.jmx.MBeanRegistryHelper; -import org.jboss.cache.jmx.CacheJmxWrapper; -import org.jboss.cache.jmx.ResourceDMBean; = import java.io.InputStream; -import java.util.Set; = /** * Default implementation of the {@link org.jboss.cache.CacheFactory} inte= rface. @@ -127,10 +123,6 @@ this.configuration =3D configuration; = componentRegistry.registerComponent(spi, CacheSPI.class); - if (configuration.getExposeManagementStatistics()) - { - componentRegistry.registerComponent(new MBeanRegistryHelper(compo= nentRegistry), MBeanRegistryHelper.class); - } } = /** --===============2199676889724059350==-- From jboss-qa-internal at redhat.com Thu Aug 7 15:16:45 2008 Content-Type: multipart/mixed; boundary="===============7155512132905148888==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_unstable=3A_jboss-cach?= =?utf-8?q?e-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_=23543?= Date: Thu, 07 Aug 2008 15:16:42 -0400 Message-ID: <1723278292.19621218136602075.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 912941869.19311218125278620.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============7155512132905148888== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/543/changes --===============7155512132905148888==-- From jbosscache-commits at lists.jboss.org Thu Aug 7 15:23:47 2008 Content-Type: multipart/mixed; boundary="===============3063947398007824119==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6543 - core/trunk/src/main/java/org/jboss/cache/jmx. Date: Thu, 07 Aug 2008 15:23:46 -0400 Message-ID: --===============3063947398007824119== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-07 15:23:46 -0400 (Thu, 07 Aug 2008) New Revision: 6543 Modified: core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java Log: fixed UT Modified: core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2008-= 08-07 19:05:04 UTC (rev 6542) +++ core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2008-= 08-07 19:23:46 UTC (rev 6543) @@ -811,10 +811,6 @@ cache.addCacheListener(cacheNotificationListener); } } - if (config !=3D null) - { - this.registerJmxResource =3D config.getExposeManagementStatistics= (); - } } = public String getCacheObjectName() @@ -940,7 +936,7 @@ = protected boolean registerJmxResources() throws CacheException { - if (registerJmxResource && !jmxResourceRegistered && server !=3D nul= l) + if (registerJmxResource && config.getExposeManagementStatistics() &&= !jmxResourceRegistered && server !=3D null) { log.debug("Registering jmx resources"); List interc =3D cache.getInterceptorChain(); --===============3063947398007824119==-- From jboss-qa-internal at redhat.com Thu Aug 7 15:47:24 2008 Content-Type: multipart/mixed; boundary="===============7359246613855966240==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_unstable=3A_jboss-cach?= =?utf-8?q?e-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_=23410?= Date: Thu, 07 Aug 2008 15:47:21 -0400 Message-ID: <341329121.19661218138441745.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 355611587.19321218125378587.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============7359246613855966240== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/410/changes --===============7359246613855966240==-- From jboss-qa-internal at redhat.com Fri Aug 8 04:06:17 2008 Content-Type: multipart/mixed; boundary="===============0866472132758917028==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23411?= Date: Fri, 08 Aug 2008 04:06:14 -0400 Message-ID: <7968837.20731218182774379.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 341329121.19661218138441745.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============0866472132758917028== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/411/changes --===============0866472132758917028==-- From jboss-qa-internal at redhat.com Fri Aug 8 04:32:40 2008 Content-Type: multipart/mixed; boundary="===============1689900021974139658==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23544?= Date: Fri, 08 Aug 2008 04:32:37 -0400 Message-ID: <1160716609.20751218184357004.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1723278292.19621218136602075.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============1689900021974139658== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/544/changes --===============1689900021974139658==-- From jbosscache-commits at lists.jboss.org Fri Aug 8 05:37:40 2008 Content-Type: multipart/mixed; boundary="===============0899331041722648618==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6544 - in core/trunk/src/main/java/org/jboss/cache: interceptors/base and 1 other directories. Date: Fri, 08 Aug 2008 05:37:39 -0400 Message-ID: --===============0899331041722648618== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-08 05:37:39 -0400 (Fri, 08 Aug 2008) New Revision: 6544 Added: core/trunk/src/main/java/org/jboss/cache/jmx/JmxStatisticsExposer.java Removed: core/trunk/src/main/java/org/jboss/cache/interceptors/base/JmxStatistics= Interceptor.java Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java core/trunk/src/main/java/org/jboss/cache/interceptors/base/JmxStatsComma= ndInterceptor.java core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java Log: added management stats for replication Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-08-07= 19:23:46 UTC (rev 6543) +++ core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-08-08= 09:37:39 UTC (rev 6544) @@ -32,6 +32,8 @@ import org.jboss.cache.transaction.TransactionTable; import org.jboss.cache.util.ThreadGate; import org.jboss.cache.util.reflect.ReflectionUtil; +import org.jboss.cache.jmx.annotations.ManagedOperation; +import org.jboss.cache.jmx.annotations.ManagedAttribute; import org.jgroups.Address; import org.jgroups.Channel; import org.jgroups.ChannelException; @@ -53,6 +55,7 @@ import java.util.List; import java.util.Set; import java.util.Vector; +import java.text.NumberFormat; = /** * Manager that handles all RPC calls between JBoss Cache instances @@ -64,6 +67,9 @@ private Channel channel; private final Log log =3D LogFactory.getLog(RPCManagerImpl.class); private List

members; + private long replicationCount; + private long replicationFailures; + private boolean statisticsEnabled; = private final Object coordinatorLock =3D new Object(); /** @@ -407,65 +413,65 @@ = public List callRemoteMethods(Vector
recipients, Repli= cableCommand command, int mode, long timeout, RspFilter responseFilter, boo= lean useOutOfBandMessage) throws Exception { - // short circuit if we don't have an RpcDispatcher! - if (rpcDispatcher =3D=3D null) return null; - - int modeToUse =3D mode; - int preferredMode; - if ((preferredMode =3D spi.getInvocationContext().getOptionOverrides= ().getGroupRequestMode()) > -1) - modeToUse =3D preferredMode; - - if (trace) - log.trace("callRemoteMethods(): valid members are " + recipients = + " methods: " + command + " Using OOB? " + useOutOfBandMessage); - - if (channel.flushSupported()) - { - if (!flushBlockGate.await(configuration.getStateRetrievalTimeout(= ))) - throw new TimeoutException("State retrieval timed out waiting = for flush unblock."); - } - - useOutOfBandMessage =3D false; - - RspList rsps =3D rpcDispatcher.invokeRemoteCommands(recipients, comm= and, modeToUse, timeout, isUsingBuddyReplication, useOutOfBandMessage, resp= onseFilter); - - if (mode =3D=3D GroupRequest.GET_NONE) return Collections.emptyList(= );// async case - - if (trace) - log.trace("(" + getLocalAddress() + "): responses for method " + = command.getClass().getSimpleName() + ":\n" + rsps); - - // short-circuit no-return-value calls. - if (rsps =3D=3D null) return Collections.emptyList(); - - List retval =3D new ArrayList(rsps.size()); - - for (Rsp rsp : rsps.values()) - { - if (rsp.wasSuspected() || !rsp.wasReceived()) + boolean success =3D true; + try { + // short circuit if we don't have an RpcDispatcher! + if (rpcDispatcher =3D=3D null) return null; + int modeToUse =3D mode; + int preferredMode; + if ((preferredMode =3D spi.getInvocationContext().getOptionOverri= des().getGroupRequestMode()) > -1) + modeToUse =3D preferredMode; + if (trace) + log.trace("callRemoteMethods(): valid members are " + recipien= ts + " methods: " + command + " Using OOB? " + useOutOfBandMessage); + if (channel.flushSupported()) { - CacheException ex; - if (rsp.wasSuspected()) + if (!flushBlockGate.await(configuration.getStateRetrievalTimeo= ut())) + throw new TimeoutException("State retrieval timed out waiti= ng for flush unblock."); + } + useOutOfBandMessage =3D false; + RspList rsps =3D rpcDispatcher.invokeRemoteCommands(recipients, c= ommand, modeToUse, timeout, isUsingBuddyReplication, useOutOfBandMessage, r= esponseFilter); + if (mode =3D=3D GroupRequest.GET_NONE) return Collections.emptyLi= st();// async case + if (trace) + log.trace("(" + getLocalAddress() + "): responses for method "= + command.getClass().getSimpleName() + ":\n" + rsps); + // short-circuit no-return-value calls. + if (rsps =3D=3D null) return Collections.emptyList(); + List retval =3D new ArrayList(rsps.size()); + for (Rsp rsp : rsps.values()) + { + if (rsp.wasSuspected() || !rsp.wasReceived()) { - ex =3D new SuspectException("Suspected member: " + rsp.getS= ender()); + CacheException ex; + if (rsp.wasSuspected()) + { + ex =3D new SuspectException("Suspected member: " + rsp.g= etSender()); + } + else + { + ex =3D new TimeoutException("Replication timeout for " += rsp.getSender()); + } + retval.add(new ReplicationException("rsp=3D" + rsp, ex)); + success =3D false; } else { - ex =3D new TimeoutException("Replication timeout for " + rs= p.getSender()); + Object value =3D rsp.getValue(); + if (value instanceof Exception && !(value instanceof Replic= ationException)) + { + // if we have any application-level exceptions make sure= we throw them!! + if (trace) log.trace("Recieved exception'" + value + "' = from " + rsp.getSender()); + throw (Exception) value; + } + retval.add(value); + success =3D true; } - retval.add(new ReplicationException("rsp=3D" + rsp, ex)); } - else - { - Object value =3D rsp.getValue(); - if (value instanceof Exception && !(value instanceof Replicati= onException)) - { - // if we have any application-level exceptions make sure we= throw them!! - if (trace) log.trace("Recieved exception'" + value + "' fro= m " + rsp.getSender()); - throw (Exception) value; - } - retval.add(value); - } + return retval; + } catch (Exception e) { + success =3D false; + throw e; + } finally { + computeStats(success); } - return retval; } = // ------------ START: Partial state transfer methods ------------ @@ -696,5 +702,58 @@ } = } - /*------------------- End of MembershipListener ----------------------*/ + + + //jmx operations + private void computeStats(boolean success) { + if (this.isStatisticsEnabled() && rpcDispatcher !=3D null) + { + if (success) + { + replicationCount ++; + } else + { + replicationFailures ++; + } + } + } + + @ManagedOperation + public void resetStatistics() + { + this.replicationCount =3D 0; + this.replicationFailures =3D 0; + } + + @ManagedAttribute(description =3D "number of successful replications") + public long getReplicationCount() { + return replicationCount; + } + + @ManagedAttribute (description =3D "number of failed replications") + public long getReplicationFailures() { + return replicationFailures; + } + + @ManagedAttribute (description =3D "whether or not jmx statistics are e= nabled") + public boolean isStatisticsEnabled() { + return statisticsEnabled; + } + + @ManagedAttribute + public void setStatisticsEnabled(boolean statisticsEnabled) { + this.statisticsEnabled =3D statisticsEnabled; + } + + @ManagedAttribute + public String getSuccessRatio() + { + if (replicationCount =3D=3D 0 || !statisticsEnabled) + { + return "N/A"; + } + double totalCount =3D replicationCount + replicationFailures; + double ration =3D (double)replicationCount / totalCount * 100d; + return NumberFormat.getInstance().format(ration) +"%"; + } } \ No newline at end of file Deleted: core/trunk/src/main/java/org/jboss/cache/interceptors/base/JmxStat= isticsInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/base/JmxStatistic= sInterceptor.java 2008-08-07 19:23:46 UTC (rev 6543) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/JmxStatistic= sInterceptor.java 2008-08-08 09:37:39 UTC (rev 6544) @@ -1,63 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.jboss.cache.interceptors.base; - -import java.util.Map; - -/** - * Interface containing common cache management operations - * - * @author Jerry Gauthier - * @version $Id$ - */ -public interface JmxStatisticsInterceptor -{ - /** - * Returns whether an interceptor's statistics are - * being captured. - * - * @return true if statistics are captured - */ - boolean getStatisticsEnabled(); - - /** - * Enables an interceptor's cache statistics - * If true, the interceptor will capture statistics - * and make them available through the mbean. - * - * @param enabled true if statistics should be captured - */ - void setStatisticsEnabled(boolean enabled); - - /** - * Returns a map of the cache interceptor's statistics - * Map is keyed on statistic names (which are Strings) and values are O= bjects. - * - * @return a map containing statistics - */ - Map dumpStatistics(); - - /** - * Resets an interceptor's cache statistics - */ - void resetStatistics(); -} Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/base/JmxSta= tsCommandInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/base/JmxStatsComm= andInterceptor.java 2008-08-07 19:23:46 UTC (rev 6543) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/JmxStatsComm= andInterceptor.java 2008-08-08 09:37:39 UTC (rev 6544) @@ -22,7 +22,7 @@ package org.jboss.cache.interceptors.base; = import org.jboss.cache.jmx.annotations.ManagedAttribute; -import org.jboss.cache.interceptors.base.JmxStatisticsInterceptor; +import org.jboss.cache.jmx.JmxStatisticsExposer; import org.jboss.cache.factories.annotations.Start; = import java.util.Map; @@ -34,7 +34,7 @@ * @author Mircea.Markus(a)jboss.com * @since 3.0 */ -public class JmxStatsCommandInterceptor extends CommandInterceptor impleme= nts JmxStatisticsInterceptor +public class JmxStatsCommandInterceptor extends CommandInterceptor impleme= nts JmxStatisticsExposer { private boolean statsEnabled =3D false; = Copied: core/trunk/src/main/java/org/jboss/cache/jmx/JmxStatisticsExposer.j= ava (from rev 6541, core/trunk/src/main/java/org/jboss/cache/interceptors/b= ase/JmxStatisticsInterceptor.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/jmx/JmxStatisticsExposer.java = (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/jmx/JmxStatisticsExposer.java = 2008-08-08 09:37:39 UTC (rev 6544) @@ -0,0 +1,63 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.cache.jmx; + +import java.util.Map; + +/** + * Interface containing common cache management operations + * + * @author Jerry Gauthier + * @version $Id$ + */ +public interface JmxStatisticsExposer +{ + /** + * Returns whether an interceptor's statistics are + * being captured. + * + * @return true if statistics are captured + */ + boolean getStatisticsEnabled(); + + /** + * Enables an interceptor's cache statistics + * If true, the interceptor will capture statistics + * and make them available through the mbean. + * + * @param enabled true if statistics should be captured + */ + void setStatisticsEnabled(boolean enabled); + + /** + * Returns a map of the cache interceptor's statistics + * Map is keyed on statistic names (which are Strings) and values are O= bjects. + * + * @return a map containing statistics + */ + Map dumpStatistics(); + + /** + * Resets an interceptor's cache statistics + */ + void resetStatistics(); +} Property changes on: core/trunk/src/main/java/org/jboss/cache/jmx/JmxStatis= ticsExposer.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Modified: core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java 2008-08-07 19= :23:46 UTC (rev 6543) +++ core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java 2008-08-08 09= :37:39 UTC (rev 6544) @@ -22,13 +22,10 @@ package org.jboss.cache.jmx; = import org.jboss.cache.config.Configuration; -import org.jboss.cache.interceptors.base.CommandInterceptor; -import org.jboss.cache.interceptors.base.JmxStatisticsInterceptor; = import javax.management.JMException; import javax.management.MBeanServer; import javax.management.ObjectName; -import java.util.List; = /** * Various JMX related utilities --===============0899331041722648618==-- From jbosscache-commits at lists.jboss.org Fri Aug 8 13:00:31 2008 Content-Type: multipart/mixed; boundary="===============8494735270988692197==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6546 - in core/trunk/src: test/java/org/jboss/cache/jmx and 1 other directories. Date: Fri, 08 Aug 2008 13:00:31 -0400 Message-ID: --===============8494735270988692197== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-08 13:00:29 -0400 (Fri, 08 Aug 2008) New Revision: 6546 Added: core/trunk/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.java core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/ core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapperT= est.java core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapperT= estBase.java core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/InterceptorRegis= trationTest.java core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigurat= ionTest.java core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LifecycleNotific= ationTest.java core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/NotificationTest= .java core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/OptimisticNotifi= cationTest.java Removed: core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java core/trunk/src/test/java/org/jboss/cache/jmx/CacheJmxWrapperTest.java core/trunk/src/test/java/org/jboss/cache/jmx/CacheJmxWrapperTestBase.java core/trunk/src/test/java/org/jboss/cache/jmx/InterceptorRegistrationTest= .java core/trunk/src/test/java/org/jboss/cache/jmx/LegacyConfigurationTest.java core/trunk/src/test/java/org/jboss/cache/jmx/LifecycleNotificationTest.j= ava core/trunk/src/test/java/org/jboss/cache/jmx/NotificationTest.java core/trunk/src/test/java/org/jboss/cache/jmx/OptimisticNotificationTest.= java Modified: core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapperMBean.java core/trunk/src/main/java/org/jboss/cache/jmx/LegacyConfiguration.java Log: ongoing JMX stuff - deprecated old CacheJmxWrapper Modified: core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2008-= 08-08 15:15:14 UTC (rev 6545) +++ core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2008-= 08-08 17:00:29 UTC (rev 6546) @@ -24,13 +24,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.*; -import org.jboss.cache.factories.ComponentRegistry; import org.jboss.cache.config.*; import org.jboss.cache.config.parsing.JGroupsStackParser; import org.jboss.cache.config.parsing.element.BuddyElementParser; import org.jboss.cache.config.parsing.element.EvictionElementParser; import org.jboss.cache.config.parsing.element.LoadersElementParser; -import org.jboss.cache.interceptors.base.CommandInterceptor; import org.jboss.cache.util.CachePrinter; import org.jgroups.Address; import org.jgroups.Channel; @@ -40,18 +38,19 @@ = import javax.management.*; import javax.transaction.TransactionManager; -import java.util.List; import java.util.ArrayList; +import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; = /** - * Wrapper class that exposes a - * {@link CacheJmxWrapperMBean JMX management interface} + * Wrapper class that exposes a {@link CacheJmxWrapperMBean JMX management= interface} * * @author Brian Stansberry * @version $Revision$ + * @deprecated use {@link org.jboss.cache.jmx.JmxRegistrationManager}. Thi= s class will not be supported from 3.0 on. */ +(a)Deprecated public class CacheJmxWrapper extends NotificationBroadcasterSupport implements CacheJmxWrapperMBean, MBeanRegistration, CacheNotif= icationBroadcaster @@ -708,27 +707,20 @@ throws Exception { this.server =3D server; - if (cacheObjectName =3D=3D null) { - if (objName =3D=3D null) + if (objName !=3D null) { - // Calling this will create a value for cacheObjectName + cacheObjectName =3D objName.getCanonicalName(); + } else + { getCacheObjectName(); } - else - { - cacheObjectName =3D objName.getCanonicalName(); - } } - - ObjectName result =3D new ObjectName(cacheObjectName); - // Inform our CacheNotificationListener of the ObjectName it should = transmit - if (notificationServiceName =3D=3D null) - notificationServiceName =3D result.getCanonicalName(); + if (notificationServiceName =3D=3D null) notificationServiceName =3D= cacheObjectName; cacheNotificationListener.setServiceName(notificationServiceName); - return result; + return new ObjectName(cacheObjectName); } = /** @@ -817,7 +809,14 @@ { if (cacheObjectName =3D=3D null) { - cacheObjectName =3D JmxUtil.getDefaultCacheObjectName(config, Cac= heSPI.class.getName()); + if (config.getClusterName() =3D=3D null) + { + cacheObjectName =3D JmxRegistrationManager.LOCAL_CACHE_PREFIX = + "Cache" + System.currentTimeMillis(); + } + else + { + cacheObjectName =3D JmxRegistrationManager.CLUSTERED_CACHE_PRE= FIX + config.getClusterName(); + } } return cacheObjectName; } @@ -939,33 +938,10 @@ if (registerJmxResource && config.getExposeManagementStatistics() &&= !jmxResourceRegistered && server !=3D null) { log.debug("Registering jmx resources"); - List interc =3D cache.getInterceptorChain(); - if (interc !=3D null && interc.size() > 0) - { - try - { - for (ComponentRegistry.Component component : cache.getCompo= nentRegistry().getRegiteredComponents()) - { - ResourceDMBean resourceDMBean =3D new ResourceDMBean(com= ponent.getInstance()); - if (resourceDMBean.isManagedResource()) - { - resourceDMBeans.add(resourceDMBean); - } - } = - for (ResourceDMBean resource: resourceDMBeans) - { - String resourceName =3D resource.getObject().getClass().= getSimpleName(); - ObjectName objectName =3D new ObjectName(cacheObjectName= + JmxUtil.JMX_RESOURCE_KEY + resourceName); - if (!server.isRegistered(objectName)) server.registerMBe= an(resource, objectName); - } - jmxResourceRegistered =3D true; - return true; - } - catch (JMException e) - { - throw new CacheException("Failed to register jmx resources"= , e); - } - } + JmxRegistrationManager registrationManager =3D new JmxRegistratio= nManager(server, cache, this.cacheObjectName); + registrationManager.registerAllMBeans(); + jmxResourceRegistered =3D true; + return true; } return false; } @@ -974,21 +950,10 @@ { if (registerJmxResource && jmxResourceRegistered && server !=3D null) { - try - { - log.debug("Unregistering interceptors"); - for (ResourceDMBean resource : resourceDMBeans) - { - String resourceName =3D resource.getObject().getClass().get= SimpleName(); - ObjectName objectName =3D new ObjectName(cacheObjectName + = JmxUtil.JMX_RESOURCE_KEY + resourceName); - if (server.isRegistered(objectName)) server.unregisterMBean= (objectName); - } - jmxResourceRegistered =3D false; - } - catch (Exception e) - { - log.error("Exception unregistering interceptors from JMX", e); - } + log.debug("Unregistering interceptors"); + JmxRegistrationManager registrationManager =3D new JmxRegistratio= nManager(server, cache, this.cacheObjectName); + registrationManager.unregisterAllMBeans(); + jmxResourceRegistered =3D false; } } = Modified: core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapperMBean= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapperMBean.java = 2008-08-08 15:15:14 UTC (rev 6545) +++ core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapperMBean.java = 2008-08-08 17:00:29 UTC (rev 6546) @@ -25,7 +25,9 @@ *
  • Cache information methods (numNodes, numAttributes, lockInfo, prin= tDetails) which print as Strings or as formatted HTML (for web based JMX co= nsoles)
  • * * @since 2.0.0 + * @deprecated use {@link org.jboss.cache.jmx.JmxRegistrationManager} */ +(a)Deprecated public interface CacheJmxWrapperMBean extends LegacyConfiguration { /** Added: core/trunk/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.jav= a (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.jav= a 2008-08-08 17:00:29 UTC (rev 6546) @@ -0,0 +1,191 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2008, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.cache.jmx; + +import org.jboss.cache.Cache; +import org.jboss.cache.CacheSPI; +import org.jboss.cache.CacheException; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.factories.ComponentRegistry; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.management.*; +import java.lang.management.ManagementFactory; +import java.util.List; +import java.util.ArrayList; + +/** + * @author Mircea.Markus(a)jboss.com + * @since 3.0 + */ +public class JmxRegistrationManager +{ + + private static final Log log =3D LogFactory.getLog(JmxRegistrationManag= er.class); + + /** + * default ObjectName for clusterd caches. Cluster name should pe appen= ded. + */ + public static final String CLUSTERED_CACHE_PREFIX =3D "jboss.cache:serv= ice=3DJBossCache,cluster=3D"; + + /** + * default ObjectName for non clustered caches. An unique identifier sh= ould be appended. + */ + public static final String LOCAL_CACHE_PREFIX =3D "jboss.cache:service= =3DJBossCache,uniqueId=3D"; + + /** + * Key for every Dynamic mbean added. + */ + public static final String JMX_RESOURCE_KEY =3D ",jmx-resource=3D"; + + private MBeanServer mBeanServer; + + private String objectNameBase; + + private CacheSPI cacheSpi; + + public JmxRegistrationManager(MBeanServer mBeanServer, Cache cache, Obj= ectName objectNameBase) + { + this.mBeanServer =3D mBeanServer; + this.cacheSpi =3D (CacheSPI) cache; + processBaseName(objectNameBase); + } + + /** + * @param mBeanServer + * @param cache + * @param objectNameBase + * @throws IllegalArgumentException if the supplied objectNameBase name= isn't valid + */ + public JmxRegistrationManager(MBeanServer mBeanServer, Cache cache, Str= ing objectNameBase) + { + this.mBeanServer =3D mBeanServer; + this.cacheSpi =3D (CacheSPI) cache; + try + { + processBaseName(new ObjectName(objectNameBase)); + } catch (MalformedObjectNameException e) + { + throw new IllegalArgumentException("Invalid Object Name : " + obj= ectNameBase, e); + } + } + + /** + * Defaults to platform to platform MBeanServer. + * + * @see java.lang.management.ManagementFactory#getPlatformMBeanServer() + * @see platform MBeanServer + */ + public JmxRegistrationManager(Cache cache, ObjectName objectNameBase) + { + this(ManagementFactory.getPlatformMBeanServer(), cache, objectNameBa= se); + } + + public JmxRegistrationManager(Cache cache) + { + this(cache, null); + } + + public void registerAllMBeans() throws CacheException + { + try + { + List resourceDMBeans =3D getResourceDMBeans(); + for (ResourceDMBean resource : resourceDMBeans) + { + String resourceName =3D resource.getObject().getClass().getSim= pleName(); + ObjectName objectName =3D new ObjectName(getObjectName(resourc= eName)); + if (!mBeanServer.isRegistered(objectName)) + { + mBeanServer.registerMBean(resource, objectName); + } + } + } catch (Exception e) + { + throw new CacheException("Failure while registering mbeans", e); + } + } + + public void unregisterAllMBeans() throws CacheException + { + log.trace("Unregistering jmx resources.."); + try + { + List resourceDMBeans =3D getResourceDMBeans(); + for (ResourceDMBean resource : resourceDMBeans) + { + String resourceName =3D resource.getObject().getClass().getSim= pleName(); + ObjectName objectName =3D new ObjectName(getObjectName(resourc= eName)); + if (mBeanServer.isRegistered(objectName)) + { + mBeanServer.unregisterMBean(objectName); + } + } + } catch (Exception e) + { + throw new CacheException("Failure while unregistering mbeans", e); + } + } + + + private List getResourceDMBeans() + { + List resourceDMBeans =3D new ArrayList(); + for (ComponentRegistry.Component component : cacheSpi.getComponentRe= gistry().getRegiteredComponents()) + { + ResourceDMBean resourceDMBean =3D new ResourceDMBean(component.ge= tInstance()); + if (resourceDMBean.isManagedResource()) + { + resourceDMBeans.add(resourceDMBean); + } + } + return resourceDMBeans; + } + + private void processBaseName(ObjectName baseName) + { + if (baseName !=3D null) + { + this.objectNameBase =3D baseName.getCanonicalName(); + return; + } + if (cacheSpi.getConfiguration().getCacheMode().equals(Configuration.= CacheMode.LOCAL)) + { + objectNameBase =3D LOCAL_CACHE_PREFIX + System.currentTimeMillis(= ); + } + else //the cache is clustered + { + objectNameBase =3D CLUSTERED_CACHE_PREFIX + cacheSpi.getConfigura= tion().getClusterName(); + } + } + + private String getObjectName(String resourceName) + { + return objectNameBase + JMX_RESOURCE_KEY + resourceName; + } + + public String getObjectNameBase() + { + return objectNameBase; + } +} Deleted: core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java 2008-08-08 15= :15:14 UTC (rev 6545) +++ core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java 2008-08-08 17= :00:29 UTC (rev 6546) @@ -1,93 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.jboss.cache.jmx; - -import org.jboss.cache.config.Configuration; - -import javax.management.JMException; -import javax.management.MBeanServer; -import javax.management.ObjectName; - -/** - * Various JMX related utilities - * - * @author Jerry Gauthier - * @author Manik Surtani - * @version $Id$ - */ -public class JmxUtil -{ - public static final String JBOSS_SERVER_DOMAIN =3D "jboss"; - public static final String JBOSS_CACHE_DOMAIN =3D "jboss.cache"; - public static final String SERVICE_KEY_NAME =3D "service"; - public static final String BASE_PREFIX =3D JBOSS_CACHE_DOMAIN + ":" + S= ERVICE_KEY_NAME + "=3DJBossCache"; - public static final String CLUSTER_KEY =3D "cluster"; - public static final String PREFIX =3D BASE_PREFIX + "," + CLUSTER_KEY += "=3D"; - public static final String UNIQUE_ID_KEY =3D "uniqueId"; - public static final String NO_CLUSTER_PREFIX =3D BASE_PREFIX + "," + UN= IQUE_ID_KEY + "=3D"; - public static final String CACHE_TYPE_KEY =3D "cacheType"; - public static final String PLAIN_CACHE_TYPE =3D "Cache"; - public static final String MBEAN_CLASS_SUFFIX =3D "MBean"; - public static final String JMX_RESOURCE_KEY =3D ",jmx-resource=3D"; - - public static void registerCacheMBean(MBeanServer server, CacheJmxWrapp= erMBean cache, String cacheObjectName) - throws JMException - { - ObjectName on =3D new ObjectName(cacheObjectName); - if (!server.isRegistered(on)) - { - server.registerMBean(cache, on); - } - } - - public static String getDefaultCacheObjectName(org.jboss.cache.Cache ca= che) - { - // get the cache's registration name - return getDefaultCacheObjectName(cache.getConfiguration(), cache.get= Class().getName()); - } - - public static String getDefaultCacheObjectName(Configuration config, St= ring cacheImplClass) - { - // get the cache's registration name - String tmpName; - if (config.getClusterName() =3D=3D null) - { - tmpName =3D NO_CLUSTER_PREFIX + getUniqueId(cacheImplClass); - } - else - { - tmpName =3D PREFIX + config.getClusterName(); - } - return tmpName; - } - - public static String getUniqueId(String cacheImplClass) - { - return cacheImplClass + System.currentTimeMillis(); - } - - public static void unregisterCacheMBean(MBeanServer server, String cach= eObjectName) - throws Exception - { - server.unregisterMBean(new ObjectName(cacheObjectName)); - } -} Modified: core/trunk/src/main/java/org/jboss/cache/jmx/LegacyConfiguration.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/jmx/LegacyConfiguration.java 2= 008-08-08 15:15:14 UTC (rev 6545) +++ core/trunk/src/main/java/org/jboss/cache/jmx/LegacyConfiguration.java 2= 008-08-08 17:00:29 UTC (rev 6546) @@ -33,7 +33,9 @@ * * @author Brian Stansberry * @version $Revision$ + * @deprecated use {@link org.jboss.cache.jmx.JmxRegistrationManager} */ +(a)Deprecated public interface LegacyConfiguration { /** Deleted: core/trunk/src/test/java/org/jboss/cache/jmx/CacheJmxWrapperTest.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/jmx/CacheJmxWrapperTest.java 2= 008-08-08 15:15:14 UTC (rev 6545) +++ core/trunk/src/test/java/org/jboss/cache/jmx/CacheJmxWrapperTest.java 2= 008-08-08 17:00:29 UTC (rev 6546) @@ -1,453 +0,0 @@ -package org.jboss.cache.jmx; - -import org.jboss.cache.Cache; -import org.jboss.cache.CacheException; -import org.jboss.cache.CacheStatus; -import org.jboss.cache.Fqn; -import org.jboss.cache.config.Configuration; -import org.jboss.cache.config.Configuration.CacheMode; -import org.jboss.cache.notifications.annotation.CacheListener; -import org.jboss.cache.notifications.annotation.CacheStarted; -import org.jboss.cache.notifications.annotation.CacheStopped; -import org.jboss.cache.notifications.event.Event; -import org.jboss.cache.transaction.DummyTransactionManagerLookup; -import org.jboss.cache.util.CachePrinter; -import org.jboss.cache.util.TestingUtil; -import org.jgroups.Address; -import org.jgroups.stack.IpAddress; -import static org.testng.AssertJUnit.*; -import org.testng.annotations.Test; - -import javax.management.ObjectName; -import javax.transaction.TransactionManager; -import java.util.List; - -/** - * Tests the JMX wrapper class around the cache. - * - * @author Manik Surtani - * @author Brian Stansberry - */ -(a)Test(groups =3D "functional") -public class CacheJmxWrapperTest extends CacheJmxWrapperTestBase -{ - public void testCacheMBeanBinding() throws Exception - { - registerWrapper(); - assertTrue("Should be registered", mBeanServer.isRegistered(mBeanNam= e)); - } - - public void testSetCacheObjectName() throws Exception - { - ObjectName on =3D new ObjectName("jboss.cache:test=3DSetCacheObjectN= ame"); - boolean registered =3D false; - try - { - CacheJmxWrapper wrapper =3D createWrapper(createC= onfiguration()); - wrapper.setCacheObjectName(on.getCanonicalName()); - - // Register under the standard name - registerWrapper(wrapper); - // Should be registered under 'on' - registered =3D mBeanServer.isRegistered(on); - - assertTrue("Registered with configured name", registered); - assertEquals("Configured name retained", on.getCanonicalName(), w= rapper.getCacheObjectName()); - - wrapper.create(); - wrapper.start(); - - interceptorRegistrationTest(on.getCanonicalName(), true); - - wrapper.stop(); - wrapper.destroy(); - - interceptorRegistrationTest(false); - } - finally - { - if (registered) - mBeanServer.unregisterMBean(on); - } - } - - public void testGetCacheObjectName() throws Exception - { - ObjectName on =3D new ObjectName("jboss.cache:test=3DSetCacheObjectN= ame"); - String str =3D on.getCanonicalName(); - CacheJmxWrapper wrapper =3D createWrapper(createConf= iguration()); - wrapper.setCacheObjectName(str); - - assertEquals("Setter and getter match", str, wrapper.getCacheObjectN= ame()); - - // Go back to the default - wrapper.setCacheObjectName(null); - assertEquals("Got default ObjectName", JmxUtil.PREFIX + CLUSTER_NAME= , wrapper.getCacheObjectName()); - - registerWrapper(wrapper); - assertEquals("Returns standard name", mBeanName, new ObjectName(wrap= per.getCacheObjectName())); - } - - public void testGetConfiguration1() throws Exception - { - CacheJmxWrapperMBean wrapper =3D registerWrapper(); - Configuration cfgFromJmx =3D wrapper.getConfiguration(); - assertNotNull("Got a configuration", cfgFromJmx); - assertSame(cache.getConfiguration(), cfgFromJmx); - } - - public void testGetConfiguration2() throws Exception - { - Configuration cfg =3D createConfiguration(); - CacheJmxWrapperMBean wrapper =3D registerWrapper(cfg= ); - Configuration cfgFromJmx =3D wrapper.getConfiguration(); - assertNotNull("Got a configuration", cfgFromJmx); - assertSame(cfg, cfgFromJmx); - } - - /** - * Note that this is a bit of a 'white box' test as it assumes that the - * returned String equals Configuration.toString(). That could change a= nd - * break this test; if it does, and there's nothing wrong with the - * change, just modify the test. - * - * @throws Exception - */ - public void testPrintConfigurationAsString1() throws Exception - { - CacheJmxWrapperMBean wrapper =3D registerWrapper(); - String cfgFromJmx =3D wrapper.printConfigurationAsString(); - assertEquals(cache.getConfiguration().toString(), cfgFromJmx); - } - - /** - * Note that this is a bit of a 'white box' test as it assumes that the - * returned String equals Configuration.toString(). That could change a= nd - * break this test; if it does, and there's nothing wrong with the - * change, just modify the test. - * - * @throws Exception - */ - public void testPrintConfigurationAsString2() throws Exception - { - Configuration cfg =3D createConfiguration(); - CacheJmxWrapperMBean wrapper =3D registerWrapper(cfg= ); - wrapper.create(); - wrapper.start(); - String cfgFromJmx =3D wrapper.printConfigurationAsString(); - assertEquals(wrapper.getCache().getConfiguration().toString(), cfgFr= omJmx); - } - - /** - * Note that this is a bit of a 'white box' test as it checks - * the currently coded HTML format and assumes that the HTML content is - * derived from Configuration.toString(). That could change and break - * this test; if it does, and there's nothing wrong with the - * change, just modify the test. - * - * @throws Exception - */ - public void testPrintConfigurationAsHtml1() throws Exception - { - CacheJmxWrapperMBean wrapper =3D registerWrapper(); - String cfgFromJmx =3D wrapper.printConfigurationAsHtmlString(); - assertEquals(CacheJmxWrapper.formatHtml(cache.getConfiguration().toS= tring()), cfgFromJmx); - checkHtml(cfgFromJmx, false); - } - - /** - * Note that this is a bit of a 'white box' test as it checks - * the currently coded HTML format and assumes that the HTML content is - * derived from Configuration.toString(). That could change and break - * this test; if it does, and there's nothing wrong with the - * change, just modify the test. - * - * @throws Exception - */ - public void testPrintConfigurationAsHtml2() throws Exception - { - Configuration cfg =3D createConfiguration(); - CacheJmxWrapperMBean wrapper =3D registerWrapper(cfg= ); - wrapper.create(); - wrapper.start(); - String cfgFromJmx =3D wrapper.printConfigurationAsHtmlString(); - assertEquals(CacheJmxWrapper.formatHtml(wrapper.getCache().getConfig= uration().toString()), cfgFromJmx); - checkHtml(cfgFromJmx, false); - } - - @SuppressWarnings("unchecked") - public void testGetCache() throws Exception - { - registerWrapper(); - // have to start the cache before we'll have a root - cache.start(); - - Cache cacheJmx =3D (Cache) mBeanServ= er.getAttribute(mBeanName, "Cache"); - cacheJmx.getRoot().put("key", "value"); - - assertEquals("value", cache.getRoot().get("key")); - - Fqn fqn =3D Fqn.fromString("/testing/jmx"); - cache.put(fqn, "key", "value"); - - assertEquals("value", cacheJmx.get(fqn, "key")); - } - - public void testPrintCacheDetails() throws Exception - { - printCacheDetailsTest(false); - } - - /** - * Note that this is a bit of a 'white box' test as it checks - * the currently coded HTML format. That could change and break - * this test; if it does, and there's nothing wrong with the - * change, just modify the test. - * - * @throws Exception - */ - public void testPrintCacheDetailsAsHtml() throws Exception - { - String html =3D printCacheDetailsTest(true); - checkHtml(html, true); - } - - public void testPrintLockInfo() throws Exception - { - printLockInfoTest(false); - } - - /** - * Note that this is a bit of a 'white box' test as it checks - * the currently coded HTML format. That could change and break - * this test; if it does, and there's nothing wrong with the - * change, just modify the test. - * - * @throws Exception - */ - public void testPrintLockInfoAsHtml() throws Exception - { - printLockInfoTest(true); - } - - public void testGetLocalAddress() throws Exception - { - Configuration c =3D createConfiguration(); - c.setCacheMode(CacheMode.REPL_ASYNC); - CacheJmxWrapperMBean wrapper =3D registerWrapper(c); - wrapper.start(); - assertTrue("Got an IpAddress", wrapper.getLocalAddress() instanceof = IpAddress); - } - - public void testGetMembers() throws Exception - { - Configuration c =3D createConfiguration(); - c.setCacheMode(CacheMode.REPL_ASYNC); - CacheJmxWrapperMBean wrapper =3D registerWrapper(c); - wrapper.start(); - - c =3D createConfiguration(); - c.setCacheMode(CacheMode.REPL_ASYNC); - Cache cache2 =3D null; - try - { - cache2 =3D createCache(c); - cache2.start(); - Cache[] caches =3D new Cache[]{wrapper.getCache(), cache2}; - TestingUtil.blockUntilViewsReceived(caches, 5000); - - Address addr =3D wrapper.getLocalAddress(); - assertNotNull("Got an Address", addr); - List members =3D wrapper.getMembers(); - assertNotNull("Got members", addr); - assertEquals("Got correct number of members", 2, members.size()); - assertTrue("I am a member", members.contains(addr)); - } - finally - { - if (cache2 !=3D null) - { - cache2.destroy(); - } - } - } - - public void testDuplicateInvocation() throws Exception - { - CacheJmxWrapperMBean cache =3D registerWrapper(); - cache.create(); - cache.start(); - cache.create(); - cache.start(); - - cache.getCache().put(Fqn.fromString("/a/b/c"), null); - assertTrue(cache.getNumberOfNodes() > 0); - assertEquals(0, cache.getNumberOfAttributes()); - - System.out.println("cache locks before restart:\n" + cache.printLock= Info()); - cache.destroy(); - cache.start(); - System.out.println("cache locks after restart:\n" + cache.printLockI= nfo()); - - assertEquals(0, cache.getNumberOfNodes()); - assertEquals(0, cache.getNumberOfAttributes()); - - cache.stop(); - cache.destroy(); - cache.stop(); - cache.destroy(); - } - - public void testFailedStart() throws Exception - { - CacheJmxWrapper wrapper =3D new CacheJmxWrapper(createCache(createConfiguration())); - registerWrapper(wrapper); - assertEquals("Correct state", CacheStatus.INSTANTIATED, wrapper.getC= acheStatus()); - wrapper.create(); - - DisruptLifecycleListener listener =3D new DisruptLifecycleListener(); - listener.setDisrupt(true); - wrapper.getCache().addCacheListener(listener); - - assertEquals("Correct state", CacheStatus.CREATED, wrapper.getCacheS= tatus()); - try - { - wrapper.start(); - fail("Listener did not prevent start"); - } - catch (CacheException good) - { - } - - assertEquals("Correct state", CacheStatus.FAILED, wrapper.getCacheSt= atus()); - - listener.setDisrupt(false); - - wrapper.start(); - - assertEquals("Correct state", CacheStatus.STARTED, wrapper.getCacheS= tatus()); - - wrapper.getCache().put(Fqn.fromString("/a/b/c"), null); - assertTrue(wrapper.getNumberOfNodes() > 0); - assertEquals(0, wrapper.getNumberOfAttributes()); - - listener.setDisrupt(true); - // need to re-add the listener since the failed start would have nul= lified the notifier. - cache.addCacheListener(listener); - - try - { - wrapper.stop(); - fail("Listener did not prevent stop"); - } - catch (CacheException good) - { - } - - assertEquals("Correct state", CacheStatus.FAILED, wrapper.getCacheSt= atus()); - - listener.setDisrupt(false); - - wrapper.stop(); - assertEquals("Correct state", CacheStatus.STOPPED, wrapper.getCacheS= tatus()); - wrapper.destroy(); - assertEquals("Correct state", CacheStatus.DESTROYED, wrapper.getCach= eStatus()); - } - - private String printCacheDetailsTest(boolean html) throws Exception - { - CacheJmxWrapperMBean wrapper =3D registerWrapper(); - - // have to start the cache before we'll have a root - cache.start(); - Fqn fqn =3D Fqn.fromString("/testing/jmx"); - cache.put(fqn, "foobar", "barfoo"); - - assertEquals("barfoo", cache.get(fqn, "foobar")); - - String details =3D html ? wrapper.printCacheDetailsAsHtml() : wrappe= r.printCacheDetails(); - - - System.out.println("Cache details: " + CachePrinter.printCacheDetail= s(cache)); - System.out.println("Details: " + details); - - assertTrue("Details include testing", details.contains("testing")); - assertTrue("Details include jmx", details.contains("jmx")); - assertTrue("Details include foobar", details.contains("foobar")); - assertTrue("Details include barfoo", details.contains("barfoo")); - - return details; - } - - private String printLockInfoTest(boolean html) throws Exception - { - Configuration config =3D createConfiguration(); - config.setTransactionManagerLookupClass(DummyTransactionManagerLooku= p.class.getName()); - Cache c =3D createCache(config); - CacheJmxWrapperMBean wrapper =3D registerWrapper(c); - -// wrapper.setManageCacheLifecycle(true); - wrapper.create(); - wrapper.start(); - - TransactionManager tm =3D config.getRuntimeConfig().getTransactionMa= nager(); - - tm.begin(); - try - { - Fqn fqn =3D Fqn.fromString("/testing/jmx"); - cache.put(fqn, "foobar", "barfoo"); - - String locks =3D html ? wrapper.printLockInfoAsHtml() : wrapper.p= rintLockInfo(); - - assertTrue("Details include testing", locks.contains("testing")); - assertTrue("Details include jmx", locks.contains("jmx")); - - return locks; - } - catch (Exception e) - { - tm.setRollbackOnly(); - throw e; - } - finally - { - tm.commit(); - } - - } - - private void checkHtml(String html, boolean checkBR) - { - if (checkBR) - assertTrue("Has Manik Surtani - * @author Brian Stansberry - */ -(a)Test(groups =3D "functional") -public abstract class CacheJmxWrapperTestBase -{ - public static final String CLUSTER_NAME =3D "CacheMBeanTest"; - - protected Cache cache; - protected CacheJmxWrapperMBean jmxWrapper; - protected MBeanServer mBeanServer; - protected ObjectName mBeanName; - protected String mBeanNameStr; - - @BeforeMethod(alwaysRun =3D true) - public void setUp() throws Exception - { - mBeanServer =3D MBeanServerFactory.createMBeanServer("CacheMBeanTest= "); - - mBeanNameStr =3D JmxUtil.PREFIX + CLUSTER_NAME; - mBeanName =3D new ObjectName(mBeanNameStr); - } - - @AfterMethod(alwaysRun =3D true) - public void tearDown() throws Exception - { - try - { - cleanup(); - } - finally - { - if (mBeanServer !=3D null) - { - MBeanServerFactory.releaseMBeanServer(mBeanServer); - mBeanServer =3D null; - } - } - } - - protected CacheJmxWrapperMBean registerWrapper() throws= Exception - { - if (cache =3D=3D null) - cache =3D createCache(createConfiguration()); - return registerWrapper(cache); - } - - protected CacheJmxWrapperMBean registerWrapper(Cache toWrap) throws Exception - { - CacheJmxWrapper wrapper =3D new CacheJmxWrapper(toWrap); - return registerWrapper(wrapper); - } - - protected CacheJmxWrapperMBean registerWrapper(Configur= ation config) throws Exception - { - CacheJmxWrapper wrapper =3D new CacheJmxWrapper(); - wrapper.setConfiguration(config); - return registerWrapper(wrapper); - } - - @SuppressWarnings("unchecked") - protected CacheJmxWrapperMBean registerWrapper(CacheJmx= WrapperMBean wrapper) throws Exception - { - JmxUtil.registerCacheMBean(mBeanServer, wrapper, mBeanNameStr); - jmxWrapper =3D (CacheJmxWrapperMBean) MBeanServerInv= ocationHandler.newProxyInstance(mBeanServer, mBeanName, CacheJmxWrapperMBea= n.class, false); - return jmxWrapper; - } - - protected void unregisterWrapper() throws Exception - { - mBeanServer.unregisterMBean(mBeanName); - } - - protected CacheJmxWrapper createWrapper(Configuration c= onfig) - { - CacheJmxWrapper wrapper =3D new CacheJmxWrapper(); - wrapper.setConfiguration(config); - return wrapper; - } - - protected Cache createCache(Configuration config) - { - CacheFactory factory =3D new DefaultCacheFactory(); - cache =3D factory.createCache(config, false); - return cache; - } - - protected Configuration createConfiguration() - { - Configuration c =3D new Configuration(); - c.setClusterName(CLUSTER_NAME); - c.setExposeManagementStatistics(true); - c.setCacheMode(Configuration.CacheMode.LOCAL); - return c; - } - - private void cleanup() throws Exception - { - if (cache !=3D null) - { - try - { - cache.stop(); - } - catch (Exception ignored) - { - } - - cache =3D null; - } - if (jmxWrapper !=3D null) - { - try - { - jmxWrapper.stop(); - jmxWrapper.destroy(); - } - catch (Exception ignored) - { - } - - jmxWrapper =3D null; - } - - if (mBeanServer !=3D null && mBeanName !=3D null && mBeanServer.isRe= gistered(mBeanName)) - mBeanServer.unregisterMBean(mBeanName); - } - - protected void interceptorRegistrationTest(boolean expectMbeans) throws= MalformedObjectNameException, NullPointerException - { - interceptorRegistrationTest(mBeanNameStr, expectMbeans); - } - - protected void interceptorRegistrationTest(String baseName, boolean exp= ectMbeans) throws MalformedObjectNameException, NullPointerException - { - // should be 3 interceptor MBeans loaded: - ObjectName[] interceptorMBeanNames =3D { - new ObjectName(baseName + JmxUtil.JMX_RESOURCE_KEY + "TxInterc= eptor"), - new ObjectName(baseName + JmxUtil.JMX_RESOURCE_KEY + "CacheMgm= tInterceptor"), - }; - - for (ObjectName n : interceptorMBeanNames) - { - if (expectMbeans) - assertTrue(n + " should be registered", mBeanServer.isRegister= ed(n)); - else - assertFalse(n + " should not be registered", mBeanServer.isReg= istered(n)); - } - } -} Deleted: core/trunk/src/test/java/org/jboss/cache/jmx/InterceptorRegistrati= onTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/jmx/InterceptorRegistrationTes= t.java 2008-08-08 15:15:14 UTC (rev 6545) +++ core/trunk/src/test/java/org/jboss/cache/jmx/InterceptorRegistrationTes= t.java 2008-08-08 17:00:29 UTC (rev 6546) @@ -1,384 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2006, Red Hat Middleware LLC, and individual contributors - * as indicated by the @author tags. See the copyright.txt file in the - * distribution for a full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - -package org.jboss.cache.jmx; - -import org.jboss.cache.config.Configuration; -import static org.testng.AssertJUnit.assertTrue; -import org.testng.annotations.Test; - -/** - * Tests the interceptor registration function of CacheJmxWrapper. - * - * @author Brian Stansberry - * @version $Revision$ - */ -(a)Test(groups =3D "functional") -public class InterceptorRegistrationTest extends CacheJmxWrapperTestBase -{ - - /** - * Confirms interceptor mbeans are registered if the following events - * occur: - *

    - * cache.start(); - * wrapper creation and registration. - * - * @throws Exception - */ - public void testInterceptorMBeans1() throws Exception - { - // have to start the cache to have any interceptors - createCache(createConfiguration()); - cache.start(); - - CacheJmxWrapperMBean wrapper =3D registerWrapper(cac= he); - assertTrue("Should be registered", mBeanServer.isRegistered(mBeanNam= e)); - - interceptorRegistrationTest(true); - - // These should be ignored because we - // never did wrapper.create()/start() - wrapper.stop(); - wrapper.destroy(); - - // Should still be registered - interceptorRegistrationTest(true); - - unregisterWrapper(); - - interceptorRegistrationTest(false); - } - - /** - * Confirms interceptor mbeans are registered if the following events - * occur: - *

    - * cache.start(); - * wrapper creation and and start - * wrapper registration. - * - * @throws Exception - */ - public void testInterceptorMBeans2() throws Exception - { - // have to start the cache to have any interceptors - createCache(createConfiguration()); - cache.start(); - - CacheJmxWrapperMBean wrapper =3D new CacheJmxWrapper= (cache); - wrapper.start(); - wrapper =3D registerWrapper(wrapper); - assertTrue("Should be registered", mBeanServer.isRegistered(mBeanNam= e)); - - interceptorRegistrationTest(true); - - wrapper.stop(); - wrapper.destroy(); - - // Should still no longer be registered - interceptorRegistrationTest(false); - - unregisterWrapper(); - - interceptorRegistrationTest(false); - } - - /** - * Confirms interceptor mbeans are registered if the following events - * occur: - *

    - * Cache not injected - * wrapper registered; - * wrapper created and started. - * - * @throws Exception - */ - public void testInterceptorMBeans3() throws Exception - { - CacheJmxWrapperMBean wrapper =3D registerWrapper(cre= ateConfiguration()); - assertTrue("Should be registered", mBeanServer.isRegistered(mBeanNam= e)); - - // have to start the cache to have any interceptors - wrapper.create(); - wrapper.start(); - - interceptorRegistrationTest(true); - - wrapper.stop(); - wrapper.destroy(); - - // Destroy should unregister if we are managing - interceptorRegistrationTest(false); - - unregisterWrapper(); - - interceptorRegistrationTest(false); - } - - /** - * Confirms interceptor mbeans are registered if the following events - * occur: - *

    - * Cache not injected - * wrapper created and started. - * wrapper registered - * - * @throws Exception - */ - public void testInterceptorMBeans4() throws Exception - { - CacheJmxWrapper wrapper =3D createWrapper(createConf= iguration()); - - // have to start the cache to have any interceptors - wrapper.create(); - wrapper.start(); - - registerWrapper(wrapper); - - assertTrue("Should be registered", mBeanServer.isRegistered(mBeanNam= e)); - - interceptorRegistrationTest(true); - - wrapper.stop(); - wrapper.destroy(); - - // Destroy should unregister if we are managing - interceptorRegistrationTest(false); - - unregisterWrapper(); - - interceptorRegistrationTest(false); - } - - /** - * Confirms interceptor mbeans are registered if the following events - * occur: - *

    - * cache constructed; - * wrapper constructed and registered with manageCacheLifecycle=3Dtrue - * wrapper created and started - * - * @throws Exception - */ - public void testInterceptorMBeans5() throws Exception - { - CacheJmxWrapperMBean wrapper =3D registerWrapper(); -// wrapper.setManageCacheLifecycle(true); - assertTrue("Should be registered", mBeanServer.isRegistered(mBeanNam= e)); - - // have to start the cache to have any interceptors - wrapper.create(); - wrapper.start(); - - interceptorRegistrationTest(true); - - wrapper.stop(); - wrapper.destroy(); - - // Destroy should unregister if we are managing - interceptorRegistrationTest(false); - - unregisterWrapper(); - - interceptorRegistrationTest(false); - } - - /** - * Confirms interceptor mbeans are registered if the following events - * occur: - *

    - * cache constructed; - * wrapper constructed and registered - * wrapper created and started - * - * @throws Exception - */ - public void testInterceptorMBeans6() throws Exception - { - CacheJmxWrapperMBean wrapper =3D registerWrapper(); - assertTrue("Should be registered", mBeanServer.isRegistered(mBeanNam= e)); - - // have to start the cache to have any interceptors - wrapper.create(); - wrapper.start(); - - interceptorRegistrationTest(true); - - wrapper.stop(); - wrapper.destroy(); - - interceptorRegistrationTest(false); - - unregisterWrapper(); - - interceptorRegistrationTest(false); - } - - /** - * Confirms interceptor mbeans are registered if the following events - * occur: - *

    - * cache constructed; - * wrapper created and started - * wrapper registered - * - * @throws Exception - */ - public void testInterceptorMBeans7() throws Exception - { - CacheJmxWrapperMBean wrapper =3D new CacheJmxWrapper= (createCache(createConfiguration())); - - // have to start the cache to have any interceptors - wrapper.create(); - wrapper.start(); - - wrapper =3D registerWrapper(wrapper); - assertTrue("Should be registered", mBeanServer.isRegistered(mBeanNam= e)); - - interceptorRegistrationTest(true); - - wrapper.stop(); - wrapper.destroy(); - - interceptorRegistrationTest(false); - - unregisterWrapper(); - - interceptorRegistrationTest(false); - } - - /** - * Tests that setting registerInterceptors=3Dfalse disables interceptor - * registration when the wrapper is registered before create/start - * are called. - * - * @throws Exception - */ - public void testRegisterInterceptors1() throws Exception - { - CacheJmxWrapper wrapper =3D createWrapper(createConf= iguration()); - wrapper.setRegisterJmxResource(false); - - registerWrapper(wrapper); - - assertTrue("Should be registered", mBeanServer.isRegistered(mBeanNam= e)); - - wrapper.create(); - wrapper.start(); - - interceptorRegistrationTest(false); - - wrapper.stop(); - wrapper.destroy(); - - interceptorRegistrationTest(false); - - unregisterWrapper(); - - interceptorRegistrationTest(false); - } - - /** - * Tests that setting registerInterceptors=3Dfalse disables interceptor - * registration when the wrapper is registered after create/start - * are called. - * - * @throws Exception - */ - public void testRegisterInterceptors2() throws Exception - { - CacheJmxWrapper wrapper =3D createWrapper(createConf= iguration()); - wrapper.setRegisterJmxResource(false); - - wrapper.create(); - wrapper.start(); - - registerWrapper(wrapper); - - assertTrue("Should be registered", mBeanServer.isRegistered(mBeanNam= e)); - - interceptorRegistrationTest(false); - - wrapper.stop(); - wrapper.destroy(); - - interceptorRegistrationTest(false); - - unregisterWrapper(); - - interceptorRegistrationTest(false); - } - - public void testExposeManagementStatistics1() throws Exception - { - Configuration cfg =3D createConfiguration(); - cfg.setExposeManagementStatistics(false); - - CacheJmxWrapper wrapper =3D createWrapper(cfg); - registerWrapper(cfg); - - assertTrue("Should be registered", mBeanServer.isRegistered(mBeanNam= e)); - - wrapper.create(); - wrapper.start(); - - interceptorRegistrationTest(false); - - wrapper.stop(); - wrapper.destroy(); - - interceptorRegistrationTest(false); - - unregisterWrapper(); - - interceptorRegistrationTest(false); - } - - public void testExposeManagementStatistics2() throws Exception - { - Configuration cfg =3D createConfiguration(); - cfg.setExposeManagementStatistics(false); - - CacheJmxWrapper wrapper =3D createWrapper(cfg); - - wrapper.create(); - wrapper.start(); - - registerWrapper(wrapper); - - assertTrue("Should be registered", mBeanServer.isRegistered(mBeanNam= e)); - - interceptorRegistrationTest(false); - - wrapper.stop(); - wrapper.destroy(); - - interceptorRegistrationTest(false); - - unregisterWrapper(); - - interceptorRegistrationTest(false); - - } - -} Deleted: core/trunk/src/test/java/org/jboss/cache/jmx/LegacyConfigurationTe= st.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/jmx/LegacyConfigurationTest.ja= va 2008-08-08 15:15:14 UTC (rev 6545) +++ core/trunk/src/test/java/org/jboss/cache/jmx/LegacyConfigurationTest.ja= va 2008-08-08 17:00:29 UTC (rev 6546) @@ -1,413 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2006, Red Hat Middleware LLC, and individual contributors - * as indicated by the @author tags. See the copyright.txt file in the - * distribution for a full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - -package org.jboss.cache.jmx; - -import org.jboss.cache.Version; -import org.jboss.cache.config.BuddyReplicationConfig; -import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig; -import org.jboss.cache.config.CacheLoaderConfig; -import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfi= g; -import org.jboss.cache.config.Configuration; -import org.jboss.cache.config.Configuration.CacheMode; -import org.jboss.cache.config.Configuration.NodeLockingScheme; -import org.jboss.cache.config.EvictionConfig; -import org.jboss.cache.config.EvictionRegionConfig; -import org.jboss.cache.config.RuntimeConfig; -import org.jboss.cache.config.parsing.XmlConfigHelper; -import org.jboss.cache.eviction.FIFOConfiguration; -import org.jboss.cache.eviction.FIFOPolicy; -import org.jboss.cache.eviction.LRUConfiguration; -import org.jboss.cache.eviction.LRUPolicy; -import org.jboss.cache.eviction.MRUConfiguration; -import org.jboss.cache.eviction.MRUPolicy; -import org.jboss.cache.loader.FileCacheLoader; -import org.jboss.cache.loader.SingletonStoreCacheLoader; -import org.jboss.cache.loader.jdbm.JdbmCacheLoader; -import org.jboss.cache.lock.IsolationLevel; -import org.jboss.cache.multiplexer.MultiplexerTestHelper; -import org.jboss.cache.transaction.BatchModeTransactionManagerLookup; -import org.jgroups.ChannelFactory; -import org.jgroups.JChannelFactory; -import org.jgroups.jmx.JChannelFactoryMBean; -import static org.testng.AssertJUnit.*; -import org.testng.annotations.Test; -import org.w3c.dom.Element; - -import javax.management.MBeanServerInvocationHandler; -import javax.management.ObjectName; -import javax.transaction.TransactionManager; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.util.List; -import java.util.Properties; - -/** - * Test of the CacheLegacyJmxWrapper. - * - * @author Brian Stansberry - * @version $Revision$ - */ -(a)Test(groups =3D "functional") -public class LegacyConfigurationTest extends CacheJmxWrapperTestBase -{ - @SuppressWarnings({"deprecation", "unchecked"}) - public void testLocalCache() throws Exception - { - CacheJmxWrapperMBean wrapper =3D new CacheJmxWrapper= (); - registerWrapper(wrapper); - - wrapper =3D (CacheJmxWrapperMBean) MBeanServerInvoca= tionHandler.newProxyInstance(mBeanServer, mBeanName, CacheJmxWrapperMBean.c= lass, false); - - wrapper.setBuddyReplicationConfig(getBuddyReplicationConfig()); - wrapper.setCacheLoaderConfig(getCacheLoaderConfig()); - wrapper.setCacheMode("REPL_SYNC"); - wrapper.setClusterName("LocalTest"); - wrapper.setClusterConfig(getClusterConfig()); - wrapper.setEvictionPolicyConfig(getEvictionPolicyConfig()); - wrapper.setFetchInMemoryState(false); - wrapper.setInitialStateRetrievalTimeout(100); - wrapper.setInactiveOnStartup(true); - wrapper.setNodeLockingScheme("OPTIMISTIC"); - wrapper.setIsolationLevel("READ_UNCOMMITTED"); - wrapper.setLockAcquisitionTimeout(200); - wrapper.setReplicationVersion("1.0.1"); - wrapper.setReplQueueInterval(15); - wrapper.setReplQueueMaxElements(50); - wrapper.setSyncReplTimeout(300); - wrapper.setSyncCommitPhase(true); - wrapper.setSyncRollbackPhase(true); - wrapper.setTransactionManagerLookupClass(BatchModeTransactionManager= Lookup.class.getName()); - wrapper.setExposeManagementStatistics(false); - wrapper.setUseRegionBasedMarshalling(true); - wrapper.setUseReplQueue(true); - - Configuration c =3D wrapper.getConfiguration(); - - assertEquals("CacheMode", "REPL_SYNC", wrapper.getCacheMode()); - assertEquals("CacheMode", CacheMode.REPL_SYNC, c.getCacheMode()); - assertEquals("ClusterName", "LocalTest", wrapper.getClusterName()); - assertEquals("ClusterName", "LocalTest", c.getClusterName()); - assertEquals("FetchInMemoryState", false, wrapper.getFetchInMemorySt= ate()); - assertEquals("FetchInMemoryState", false, c.isFetchInMemoryState()); - assertEquals("InitialStateRetrievalTimeout", 100, wrapper.getInitial= StateRetrievalTimeout()); - assertEquals("InitialStateRetrievalTimeout", 100, c.getStateRetrieva= lTimeout()); - assertEquals("InactiveOnStartup", true, wrapper.isInactiveOnStartup(= )); - assertEquals("InactiveOnStartup", true, c.isInactiveOnStartup()); - assertEquals("NodeLockingScheme", "OPTIMISTIC", wrapper.getNodeLocki= ngScheme()); - assertEquals("NodeLockingScheme", NodeLockingScheme.OPTIMISTIC, c.ge= tNodeLockingScheme()); - assertEquals("IsolationLevel", "READ_UNCOMMITTED", wrapper.getIsolat= ionLevel()); - assertEquals("IsolationLevel", IsolationLevel.READ_UNCOMMITTED, c.ge= tIsolationLevel()); - assertEquals("LockAcquisitionTimeout", 200, wrapper.getLockAcquisiti= onTimeout()); - assertEquals("LockAcquisitionTimeout", 200, c.getLockAcquisitionTime= out()); - assertEquals("ReplicationVersion", "1.0.1", wrapper.getReplicationVe= rsion()); - assertEquals("ReplicationVersion", Version.getVersionShort("1.0.1"),= c.getReplicationVersion()); - assertEquals("ReplQueueInterval", 15, wrapper.getReplQueueInterval()= ); - assertEquals("ReplQueueInterval", 15, c.getReplQueueInterval()); - assertEquals("ReplQueueMaxElements", 50, wrapper.getReplQueueMaxElem= ents()); - assertEquals("ReplQueueMaxElements", 50, c.getReplQueueMaxElements()= ); - assertEquals("SyncReplTimeout", 300, wrapper.getSyncReplTimeout()); - assertEquals("SyncReplTimeout", 300, c.getSyncReplTimeout()); - assertEquals("SyncCommitPhase", true, wrapper.getSyncCommitPhase()); - assertEquals("SyncCommitPhase", true, c.isSyncCommitPhase()); - assertEquals("SyncRollbackPhase", true, wrapper.getSyncRollbackPhase= ()); - assertEquals("SyncRollbackPhase", true, c.isSyncRollbackPhase()); - assertEquals("TransactionManagerLookupClass", BatchModeTransactionMa= nagerLookup.class.getName(), wrapper.getTransactionManagerLookupClass()); - assertEquals("TransactionManagerLookupClass", BatchModeTransactionMa= nagerLookup.class.getName(), c.getTransactionManagerLookupClass()); - assertEquals("ExposeManagementStatistics", false, wrapper.getExposeM= anagementStatistics()); - assertEquals("ExposeManagementStatistics", false, c.getExposeManagem= entStatistics()); - assertEquals("UseRegionBasedMarshalling", true, wrapper.getUseRegion= BasedMarshalling()); - assertEquals("UseRegionBasedMarshalling", true, c.isUseRegionBasedMa= rshalling()); - assertEquals("UseReplQueue", true, wrapper.getUseReplQueue()); - assertEquals("UseReplQueue", true, c.isUseReplQueue()); - - assertEquals("ClusterConfig", getClusterConfig().toString(), wrapper= .getClusterConfig().toString()); - - assertEquals("BuddyReplicationConfig", getBuddyReplicationConfig().t= oString(), wrapper.getBuddyReplicationConfig().toString()); - BuddyReplicationConfig brc =3D c.getBuddyReplicationConfig(); - assertEquals("BR enabled", true, brc.isEnabled()); - assertEquals("BR auto grav", false, brc.isAutoDataGravitation()); - assertEquals("BR remove find", false, brc.isDataGravitationRemoveOnF= ind()); - assertEquals("BR search backup", false, brc.isDataGravitationSearchB= ackupTrees()); - assertEquals("BR comm timeout", 600000, brc.getBuddyCommunicationTim= eout()); - assertEquals("BR poolname", "testpool", brc.getBuddyPoolName()); - BuddyLocatorConfig blc =3D brc.getBuddyLocatorConfig(); - assertEquals("BR locator", "org.jboss.cache.buddyreplication.TestBud= dyLocator", blc.getBuddyLocatorClass()); - Properties props =3D blc.getBuddyLocatorProperties(); - assertEquals("BR props", "2", props.get("numBuddies")); - - assertEquals("CacheLoaderConfig", getCacheLoaderConfig().toString(),= wrapper.getCacheLoaderConfig().toString()); - CacheLoaderConfig clc =3D c.getCacheLoaderConfig(); - assertEquals("CL passivation", false, clc.isPassivation()); - assertEquals("CL passivation", true, clc.isShared()); - assertEquals("CL preload", "/foo", clc.getPreload()); - List iclcs =3D clc.getIndividualCacheLo= aderConfigs(); - IndividualCacheLoaderConfig iclc =3D iclcs.get(0); - assertEquals("CL0 class", FileCacheLoader.class.getName(), iclc.getC= lassName()); - assertEquals("CL0 async", false, iclc.isAsync()); - assertEquals("CL0 fetch", true, iclc.isFetchPersistentState()); - assertEquals("CL0 ignore", true, iclc.isIgnoreModifications()); - assertEquals("CL0 purge", true, iclc.isPurgeOnStartup()); - assertEquals("CL0 singleton", true, iclc.getSingletonStoreConfig().i= sSingletonStoreEnabled()); - assertEquals("CL0 singleton class", SingletonStoreCacheLoader.class.= getName(), iclc.getSingletonStoreConfig().getSingletonStoreClass()); - iclc =3D iclcs.get(1); - assertEquals("CL1 class", JdbmCacheLoader.class.getName(), iclc.getC= lassName()); - assertEquals("CL1 async", true, iclc.isAsync()); - assertEquals("CL1 fetch", false, iclc.isFetchPersistentState()); - assertEquals("CL1 ignore", false, iclc.isIgnoreModifications()); - assertEquals("CL1 purge", false, iclc.isPurgeOnStartup()); - assertEquals("CL1 singleton", false, iclc.getSingletonStoreConfig().= isSingletonStoreEnabled()); - assertEquals("CL1 singleton class", SingletonStoreCacheLoader.class.= getName(), iclc.getSingletonStoreConfig().getSingletonStoreClass()); - - assertEquals("EvictionPolicyConfig", getEvictionPolicyConfig().toStr= ing(), wrapper.getEvictionPolicyConfig().toString()); - EvictionConfig ec =3D c.getEvictionConfig(); - assertEquals("EC queue size", 20000, ec.getDefaultEventQueueSize()); - assertEquals("EC wakeup", 5000, ec.getWakeupInterval()); - assertEquals("EC default pol", LRUPolicy.class.getName(), ec.getDefa= ultEvictionPolicyClass()); - List ercs =3D ec.getEvictionRegionConfigs(); - EvictionRegionConfig erc =3D ercs.get(0); - assertEquals("ERC0 name", "/_default_", erc.getRegionName()); - assertEquals("ERC0 queue size", 1000, erc.getEventQueueSize()); - LRUConfiguration lru =3D (LRUConfiguration) erc.getEvictionPolicyCon= fig(); - assertEquals("EPC0 pol", LRUPolicy.class.getName(), lru.getEvictionP= olicyClass()); - assertEquals("EPC0 maxnodes", 5000, lru.getMaxNodes()); - assertEquals("EPC0 ttl", 1000000, lru.getTimeToLive()); - erc =3D ercs.get(1); - assertEquals("ERC1 name", "/org/jboss/data", erc.getRegionName()); - assertEquals("ERC1 queue size", 20000, erc.getEventQueueSize()); - FIFOConfiguration fifo =3D (FIFOConfiguration) erc.getEvictionPolicy= Config(); - assertEquals("EPC1 pol", FIFOPolicy.class.getName(), fifo.getEvictio= nPolicyClass()); - assertEquals("EPC1 maxnodes", 5000, fifo.getMaxNodes()); - erc =3D ercs.get(2); - assertEquals("ERC2 name", "/test", erc.getRegionName()); - assertEquals("ERC2 queue size", 20000, erc.getEventQueueSize()); - MRUConfiguration mru =3D (MRUConfiguration) erc.getEvictionPolicyCon= fig(); - assertEquals("EPC2 pol", MRUPolicy.class.getName(), mru.getEvictionP= olicyClass()); - assertEquals("EPC2 maxnodes", 10000, mru.getMaxNodes()); - erc =3D ercs.get(3); - assertEquals("ERC3 name", "/maxAgeTest", erc.getRegionName()); - assertEquals("ERC3 queue size", 20000, erc.getEventQueueSize()); - lru =3D (LRUConfiguration) erc.getEvictionPolicyConfig(); - assertEquals("EPC3 pol", LRUPolicy.class.getName(), lru.getEvictionP= olicyClass()); - assertEquals("EPC3 maxnodes", 10000, lru.getMaxNodes()); - assertEquals("EPC3 maxage", 10000, lru.getMaxAge()); - assertEquals("EPC3 ttl", 8000, lru.getTimeToLive()); - - } - - @SuppressWarnings("unchecked") - public void testRuntimeConfig() throws Exception - { - CacheJmxWrapperMBean wrapper =3D new CacheJmxWrapper= (); - registerWrapper(wrapper); - - wrapper =3D (CacheJmxWrapperMBean) MBeanServerInvoca= tionHandler.newProxyInstance(mBeanServer, mBeanName, CacheJmxWrapperMBean.c= lass, false); - - // Fake a TM by making a bogus proxy - TransactionManager tm =3D (TransactionManager) Proxy.newProxyInstanc= e(getClass().getClassLoader(), - new Class[]{TransactionManager.class}, new MockInvocationHandl= er()); - wrapper.setTransactionManager(tm); - ChannelFactory cf =3D new JChannelFactory(); - wrapper.setMuxChannelFactory(cf); - - RuntimeConfig rc =3D wrapper.getConfiguration().getRuntimeConfig(); - - assertSame("Same TM", tm, wrapper.getTransactionManager()); - assertSame("Same TM", tm, rc.getTransactionManager()); - assertSame("Same ChannelFactory", cf, wrapper.getMuxChannelFactory()= ); - assertSame("Same ChannelFactory", cf, rc.getMuxChannelFactory()); - } - - @SuppressWarnings("unchecked") - public void testLegacyMuxChannelCreation() throws Exception - { - CacheJmxWrapperMBean wrapper =3D new CacheJmxWrapper= (); - registerWrapper(wrapper); - - wrapper =3D (CacheJmxWrapperMBean) MBeanServerInvoca= tionHandler.newProxyInstance(mBeanServer, mBeanName, CacheJmxWrapperMBean.c= lass, false); - wrapper.setMultiplexerStack(MultiplexerTestHelper.MUX_STACK); - - JChannelFactory factory =3D new JChannelFactory(); - factory.setDomain("jbc.mux.test"); - factory.setExposeChannels(false); - factory.setMultiplexerConfig(MultiplexerTestHelper.getClusterConfigE= lement(getDefaultProperties())); - - ObjectName on =3D new ObjectName("jgroups:service=3DMux"); - mBeanServer.registerMBean(new org.jgroups.jmx.JChannelFactory(factor= y), on); - - wrapper.setMultiplexerService((JChannelFactoryMBean) MBeanServerInvo= cationHandler.newProxyInstance(mBeanServer, on, JChannelFactoryMBean.class,= false)); - - wrapper.start(); - - RuntimeConfig rc =3D wrapper.getConfiguration().getRuntimeConfig(); - assertNotNull("Channel created", rc.getChannel()); - } - - protected static Element getBuddyReplicationConfig() throws Exception - { - - String xmlStr =3D - " \n" + - " \n" + - " \n" + - " \n" + - " numBuddies =3D 2\n" + - " \n" + - " \n" + - " "; - return XmlConfigHelper.stringToElement(xmlStr); - } - - protected static Element getCacheLoaderConfig() throws Exception - { - String xmlStr =3D - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " location=3D/tmp\n " + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " location=3D/home/bstansberry\n" + - " \n" + - " \n" + - " \n" + - " "; - return XmlConfigHelper.stringToElement(xmlStr); - } - - protected static Element getEvictionPolicyConfig() throws Exception - { - - String xmlStr =3D - " \n"= + - " \n" + - " 5000\n" + - " 1000000\n" + - " \n" + - "\n" + - " 5000\n" + - "\n" + - "\n" + - " 10000\n" + - "\n" + - "\n" + - " 10000\n" + - " 8\n" + - " 10\n= " + - "\n" + - " "; - return XmlConfigHelper.stringToElement(xmlStr); - } - - protected static Element getClusterConfig() throws Exception - { - String xml =3D - "\n" + - "\n= " + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \= n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; - return XmlConfigHelper.stringToElement(xml); - } - - protected String getDefaultProperties() - { - return "UDP(mcast_addr=3D224.0.0.36;mcast_port=3D55566;ip_ttl=3D32;"= + - "mcast_send_buf_size=3D150000;mcast_recv_buf_size=3D80000):" + - "PING(timeout=3D1000;num_initial_members=3D2):" + - "MERGE2(min_interval=3D5000;max_interval=3D10000):" + - "FD_SOCK:" + - "VERIFY_SUSPECT(timeout=3D1500):" + - "pbcast.NAKACK(gc_lag=3D50;max_xmit_size=3D8192;retransmit_tim= eout=3D600,1200,2400,4800):" + - "UNICAST(timeout=3D600,1200,2400,4800):" + - "pbcast.STABLE(desired_avg_gossip=3D20000):" + - "FRAG(frag_size=3D8192;down_thread=3Dfalse;up_thread=3Dfalse):= " + - "pbcast.GMS(join_timeout=3D5000;join_retry_timeout=3D2000;" + - "shun=3Dfalse;print_local_addr=3Dtrue):" + - "pbcast.STATE_TRANSFER"; - } - - class MockInvocationHandler implements InvocationHandler - { - - public Object invoke(Object proxy, Method method, Object[] args) thr= ows Throwable - { - return null; - } - - } -} Deleted: core/trunk/src/test/java/org/jboss/cache/jmx/LifecycleNotification= Test.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/jmx/LifecycleNotificationTest.= java 2008-08-08 15:15:14 UTC (rev 6545) +++ core/trunk/src/test/java/org/jboss/cache/jmx/LifecycleNotificationTest.= java 2008-08-08 17:00:29 UTC (rev 6546) @@ -1,102 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2006, Red Hat Middleware LLC, and individual contributors - * as indicated by the @author tags. See the copyright.txt file in the - * distribution for a full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - -package org.jboss.cache.jmx; - -import static org.testng.AssertJUnit.assertEquals; - -import javax.management.AttributeChangeNotification; -import javax.management.Notification; -import javax.management.NotificationListener; -import java.util.LinkedList; -import java.util.List; - -/** - * A LifecycleNotificationTest. - * - * @author Brian Stansberry - * @version $Revision$ - */ -public class LifecycleNotificationTest extends CacheJmxWrapperTestBase -{ - public void testGetStateAndStateNotification() throws Exception - { - CacheJmxWrapper wrapper =3D createWrapper(createConf= iguration()); - StateNotificationListener listener =3D new StateNotificationListener= (); - wrapper.addNotificationListener(listener, null, null); - - assertEquals("Correct state after instanitation", - CacheJmxWrapperMBean.UNREGISTERED, wrapper.getState()); - - registerWrapper(wrapper); - assertEquals("Correct state after registration", - CacheJmxWrapperMBean.REGISTERED, wrapper.getState()); - - wrapper.create(); - assertEquals("Correct state after create", - CacheJmxWrapperMBean.CREATED, wrapper.getState()); - - wrapper.start(); - assertEquals("Correct state after start", - CacheJmxWrapperMBean.STARTED, wrapper.getState()); - - wrapper.stop(); - assertEquals("Correct state after stop", - CacheJmxWrapperMBean.STOPPED, wrapper.getState()); - - wrapper.destroy(); - assertEquals("Correct state after destroy", - CacheJmxWrapperMBean.DESTROYED, wrapper.getState()); - - unregisterWrapper(); - assertEquals("Correct state after unregistration", - CacheJmxWrapperMBean.UNREGISTERED, wrapper.getState()); - - System.out.println(listener.notifications); - assertEquals("Correct number of notifications received", 4, listener= .notifications.size()); - assertEquals("Correct first notification", new Integer(CacheJmxWrapp= erMBean.STARTING), listener.notifications.get(0)); - assertEquals("Correct second notification", new Integer(CacheJmxWrap= perMBean.STARTED), listener.notifications.get(1)); - assertEquals("Correct third notification", new Integer(CacheJmxWrapp= erMBean.STOPPING), listener.notifications.get(2)); - assertEquals("Correct fourth notification", new Integer(CacheJmxWrap= perMBean.STOPPED), listener.notifications.get(3)); - } - - private static class StateNotificationListener - implements NotificationListener - { - private List notifications =3D new LinkedList(); - - public void handleNotification(Notification msg, Object handback) - { - if (msg instanceof AttributeChangeNotification) - { - AttributeChangeNotification change =3D (AttributeChangeNotific= ation) msg; - String attrName =3D change.getAttributeName(); - Object newValue =3D change.getNewValue(); - if ("State".equals(attrName) && newValue !=3D null && newValue= instanceof Integer) - { - notifications.add((Integer) newValue); - } - } - } - } - -} Deleted: core/trunk/src/test/java/org/jboss/cache/jmx/NotificationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/jmx/NotificationTest.java 2008= -08-08 15:15:14 UTC (rev 6545) +++ core/trunk/src/test/java/org/jboss/cache/jmx/NotificationTest.java 2008= -08-08 17:00:29 UTC (rev 6546) @@ -1,467 +0,0 @@ -package org.jboss.cache.jmx; - -import org.jboss.cache.CacheFactory; -import org.jboss.cache.CacheSPI; -import org.jboss.cache.DefaultCacheFactory; -import org.jboss.cache.Fqn; -import org.jboss.cache.config.CacheLoaderConfig; -import org.jboss.cache.config.Configuration; -import org.jboss.cache.config.Configuration.CacheMode; -import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; -import org.jboss.cache.loader.CacheLoader; -import static org.testng.AssertJUnit.*; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import javax.management.MBeanServer; -import javax.management.MBeanServerFactory; -import javax.management.Notification; -import javax.management.NotificationListener; -import javax.management.ObjectName; -import java.util.EnumSet; -import java.util.HashMap; - -/** - * Functional tests for CacheJmxWrapper broadcast of cache event notificat= ions - * - * @author Jerry Gauthier - * @version $Id$ - */ -(a)Test(groups =3D {"functional"}) -public class NotificationTest -{ - protected static final String CLUSTER_NAME =3D "NotificationTestCluster= "; - - protected static final String CAPITAL =3D "capital"; - protected static final String CURRENCY =3D "currency"; - protected static final String POPULATION =3D "population"; - protected static final String EUROPE_NODE =3D "Europe"; - - public enum Type - { - STARTED, STOPPED, PRECREATE, POSTCREATE, PREEVICT, POSTEVICT, - PRELOAD, POSTLOAD, PREREMOVE, POSTREMOVE, PREVISIT, POSTVISIT, - PREMODIFY, POSTMODIFY, PREACTIVATE, POSTACTIVATE, PREPASSIVATE, - POSTPASSIVATE, VIEWCHANGE - } - - protected MBeanServer m_server; - protected EnumSet events =3D EnumSet.noneOf(Type.class); - - protected CacheSPI cache =3D null; - protected boolean optimistic =3D false; - - @BeforeMethod(alwaysRun =3D true) - public void setUp() throws Exception - { - m_server =3D MBeanServerFactory.createMBeanServer(); - - Object cacheMBean =3D createCacheAndJmxWrapper(); - - // bind manually for now. - ObjectName mgmt =3D getWrapperObjectName(); - - m_server.registerMBean(cacheMBean, mgmt); - } - - protected Object createCacheAndJmxWrapper() throws Exception - { - cache =3D createCache(CLUSTER_NAME); - return new CacheJmxWrapper(cache); - } - - @AfterMethod(alwaysRun =3D true) - public void tearDown() throws Exception - { - try - { - cleanup(); - } - finally - { - // make sure we stop the mbean server - if (m_server !=3D null) - MBeanServerFactory.releaseMBeanServer(m_server); - } - } - - protected void cleanup() throws Exception - { - events.clear(); - - destroyCache(); - - if (m_server !=3D null) - { - ObjectName mgmt =3D getWrapperObjectName(); - if (m_server.isRegistered(mgmt)) - m_server.unregisterMBean(mgmt); - } - } - - protected void destroyCache() - { - if (cache !=3D null) - { - // stop the cache before the listener is unregistered - //cache1.stop(); - cache.destroy(); - cache =3D null; - } - } - - protected ObjectName getWrapperObjectName() throws Exception - { - return new ObjectName(JmxUtil.PREFIX + CLUSTER_NAME); - } - - public void testNotifications() throws Exception - { - assertNotNull("MBeanServer is null.", m_server); - assertNotNull("Cache is null.", cache); - - ObjectName mgmt =3D getWrapperObjectName(); - MyListener listener =3D new MyListener(mgmt); - - - m_server.addNotificationListener(mgmt, listener, null, null); - - // start the cache after registering listener - this will trigger Ca= cheStarted - // since cache is defined with cluster, thiswill also trigger ViewCh= ange - cache.start(); - - // add a node - this will trigger NodeCreated, NodeModify(pre/post) = and NodeModified - HashMap albania =3D new HashMap(4); - albania.put(CAPITAL, "Tirana"); - albania.put(CURRENCY, "Lek"); - cache.put("Europe/Albania", albania); - - // modify a node - this will trigger NodeModified and NodeModify(pre= /post) - cache.put("Europe/Albania", POPULATION, 3563112); - - // retrieve an attribute - this will trigger NodeVisited - Fqn key =3D Fqn.fromString("Europe/Albania"); - assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + = " for " + key, cache.get(key, CURRENCY)); - - // evict the node - this will trigger NodePassivate, NodeEvicted and= NodeEvict(pre/post) - cache.evict(key); - - // retrieve the attribute again - this will trigger NodeVisited and = NodeActivate - assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + = " for " + key, cache.get(key, CURRENCY)); - - // remove the node - this will trigger NodeRemoved and NodeRemove(pr= e/post) - cache.removeNode(key); - - // clean up before stopping the cache - CacheLoader cl =3D cache.getCacheLoaderManager().getCacheLoader(); - cl.remove(Fqn.fromString(EUROPE_NODE)); - - // stop the cache - cache.stop(); - m_server.removeNotificationListener(mgmt, listener); - - // run the tests - assertTrue("Expected CacheStarted notification", events.contains(Typ= e.STARTED)); - assertTrue("Expected CacheStopped notification", events.contains(Typ= e.STOPPED)); - assertTrue("Expected NodeCreated notification", events.contains(Type= .PRECREATE)); - assertTrue("Expected NodeCreated notification", events.contains(Type= .POSTCREATE)); - assertTrue("Expected NodeEvicted notification", events.contains(Type= .PREEVICT)); - assertTrue("Expected NodeEvicted notification", events.contains(Type= .POSTEVICT)); - assertTrue("Expected NodeLoaded notification", events.contains(Type.= PRELOAD)); - assertTrue("Expected NodeLoaded notification", events.contains(Type.= POSTLOAD)); - assertTrue("Expected NodeVisited notification", events.contains(Type= .PREVISIT)); - assertTrue("Expected NodeVisited notification", events.contains(Type= .POSTVISIT)); - assertTrue("Expected NodeActivated notification", events.contains(Ty= pe.PREACTIVATE)); - assertTrue("Expected NodeActivated notification", events.contains(Ty= pe.POSTACTIVATE)); - assertTrue("Expected NodeModified notification", events.contains(Typ= e.PREMODIFY)); - assertTrue("Expected NodeModified notification", events.contains(Typ= e.POSTMODIFY)); - assertTrue("Expected NodePassivated notification", events.contains(T= ype.PREPASSIVATE)); - assertTrue("Expected NodePassivated notification", events.contains(T= ype.POSTPASSIVATE)); - assertTrue("Expected NodeRemoved notification", events.contains(Type= .PREREMOVE)); - assertTrue("Expected NodeRemoved notification", events.contains(Type= .POSTREMOVE)); - assertTrue("Expected ViewChange notification", events.contains(Type.= VIEWCHANGE)); - validateHealthyListener(listener); - } - - public void testEarlyRegistration() throws Exception - { - // undo setup - cleanup(); - - CacheJmxWrapper wrapper =3D new CacheJmxWrapper(); - ObjectName mgmt =3D getWrapperObjectName(); - m_server.registerMBean(wrapper, mgmt); - MyListener listener =3D new MyListener(mgmt); - m_server.addNotificationListener(mgmt, listener, null, null); - - cache =3D createCache(CLUSTER_NAME); - wrapper.setCache(cache); - cache.start(); - try - { - assertTrue("Expected CacheStarted notification", events.contains(= Type.STARTED)); - validateHealthyListener(listener); - } - finally - { - cache.stop(); - } - } - - public void testLateRegistration() throws Exception - { - assertNotNull("MBeanServer is null.", m_server); - assertNotNull("Cache is null.", cache); - - // start the cache before registering listener - cache.start(); - - try - { - ObjectName mgmt =3D getWrapperObjectName(); - MyListener listener =3D new MyListener(mgmt); - - m_server.addNotificationListener(mgmt, listener, null, null); - - // add a node - this will trigger NodeCreated, NodeModify(pre/pos= t) and NodeModified - HashMap albania =3D new HashMap(4= ); - albania.put(CAPITAL, "Tirana"); - albania.put(CURRENCY, "Lek"); - cache.put("Europe/Albania", albania); - - // run the tests - assertTrue("Expected NodeModified notification", events.contains(= Type.PREMODIFY)); - assertTrue("Expected NodeModified notification", events.contains(= Type.POSTMODIFY)); - validateHealthyListener(listener); - } - finally - { - cache.stop(); - } - } - - public void testListenerRemoval() throws Exception - { - assertNotNull("MBeanServer is null.", m_server); - assertNotNull("Cache is null.", cache); - - ObjectName mgmt =3D getWrapperObjectName(); - MyListener listener =3D new MyListener(mgmt); - - m_server.addNotificationListener(mgmt, listener, null, null); - - // start the cache after registering listener - this will trigger Ca= cheStarted - // since cache is defined with cluster, thiswill also trigger ViewCh= ange - cache.start(); - boolean ok =3D false; - try - { - assertTrue("Expected CacheStarted notification", events.contains(= Type.STARTED)); - - m_server.removeNotificationListener(mgmt, listener); - ok =3D true; - } - finally - { - cache.stop(); - if (ok) - { - assertFalse("Expected no CacheStopped notification", events.co= ntains(Type.STOPPED)); - validateHealthyListener(listener); - } - } - } - - private CacheSPI createCache(String clusterName) throws= Exception - { - Configuration config =3D createConfiguration(clusterName); - CacheFactory factory =3D new DefaultCacheFactory(); - CacheSPI cache =3D (CacheSPI) factor= y.createCache(config, false); - - cache.create(); - // start the cache after the listener has been registered - //cache.start(); - return cache; - } - - protected Configuration createConfiguration(String clusterName) throws = Exception - { - Configuration config =3D UnitTestCacheConfigurationFactory.createCon= figuration(CacheMode.REPL_SYNC); - config.setCacheMode(Configuration.CacheMode.REPL_SYNC); - config.setCacheLoaderConfig(getCacheLoaderConfig("location=3D" + get= TempDir())); - config.setExposeManagementStatistics(true); - config.setClusterName(clusterName); - if (optimistic) - { - config.setTransactionManagerLookupClass("org.jboss.cache.transact= ion.DummyTransactionManagerLookup"); - config.setNodeLockingScheme("OPTIMISTIC"); - } - - return config; - } - - private static String getTempDir() - { - return System.getProperty("java.io.tempdir", "/tmp"); - } - - private static boolean getPre(Object data) - { - assertNotNull("User data is null, should be Object[]", data); - assertTrue("User data is " + data.getClass().getName() + ", should b= e Object[]", data instanceof Object[]); - - Object[] parms =3D (Object[]) data; - assertTrue("Parameter is " + parms[1].getClass().getName() + ", shou= ld be Boolean", parms[1] instanceof Boolean); - return (Boolean) parms[1]; - } - - protected static CacheLoaderConfig getCacheLoaderConfig(String properti= es) throws Exception - { - return UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfi= g(true, "", - "org.jboss.cache.loader.FileCacheLoader", properties, false, f= alse, true, false, false); - } - - private static void validateHealthyListener(MyListener listener) - { - if (listener.failure !=3D null) - throw listener.failure; - if (listener.exception !=3D null) - throw listener.exception; - } - - private class MyListener implements NotificationListener - { - private RuntimeException exception; - private AssertionError failure; - private final String emitterObjectName; - - MyListener(ObjectName emitter) - { - this.emitterObjectName =3D emitter.getCanonicalName(); - } - - public void handleNotification(Notification notification, Object han= dback) - { - try - { - String type =3D notification.getType(); - Object userData =3D notification.getUserData(); - - if (type.equals(CacheNotificationBroadcaster.NOTIF_CACHE_START= ED)) - { - events.add(Type.STARTED); - assertEquals("Correct object name in start notification", e= mitterObjectName, userData); - } - else if (type.equals(CacheNotificationBroadcaster.NOTIF_CACHE_= STOPPED)) - { - events.add(Type.STOPPED); - assertEquals("Correct object name in stop notification", em= itterObjectName, userData); - } - else if (type.equals(CacheNotificationBroadcaster.NOTIF_NODE_C= REATED)) - { - if (getPre(userData)) - { - events.add(Type.PRECREATE); - } - else - { - events.add(Type.POSTCREATE); - } - } - else if (type.equals(CacheNotificationBroadcaster.NOTIF_NODE_E= VICTED)) - { - if (getPre(userData)) - { - events.add(Type.PREEVICT); - } - else - { - events.add(Type.POSTEVICT); - } - } - else if (type.equals(CacheNotificationBroadcaster.NOTIF_NODE_L= OADED)) - { - if (getPre(userData)) - { - events.add(Type.PRELOAD); - } - else - { - events.add(Type.POSTLOAD); - } - } - else if (type.equals(CacheNotificationBroadcaster.NOTIF_NODE_R= EMOVED)) - { - if (getPre(userData)) - { - events.add(Type.PREREMOVE); - } - else - { - events.add(Type.POSTREMOVE); - } - } - else if (type.equals(CacheNotificationBroadcaster.NOTIF_NODE_V= ISITED)) - { - if (getPre(userData)) - { - events.add(Type.PREVISIT); - } - else - { - events.add(Type.POSTVISIT); - } - } - else if (type.equals(CacheNotificationBroadcaster.NOTIF_VIEW_C= HANGED)) - { - events.add(Type.VIEWCHANGE); - } - else if (type.equals(CacheNotificationBroadcaster.NOTIF_NODE_A= CTIVATED)) - { - if (getPre(userData)) - { - events.add(Type.PREACTIVATE); - } - else - { - events.add(Type.POSTACTIVATE); - } - } - else if (type.equals(CacheNotificationBroadcaster.NOTIF_NODE_M= ODIFIED)) - { - if (getPre(userData)) - { - events.add(Type.PREMODIFY); - } - else - { - events.add(Type.POSTMODIFY); - } - } - else if (type.equals(CacheNotificationBroadcaster.NOTIF_NODE_P= ASSIVATED)) - { - if (getPre(userData)) - { - events.add(Type.PREPASSIVATE); - } - else - { - events.add(Type.POSTPASSIVATE); - } - } - } - catch (RuntimeException e) - { - // Store so the test can rethrow - exception =3D e; - } - catch (AssertionError e) - { - // Store so the test can rethrow - failure =3D e; - } - } - } - -} Deleted: core/trunk/src/test/java/org/jboss/cache/jmx/OptimisticNotificatio= nTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/jmx/OptimisticNotificationTest= .java 2008-08-08 15:15:14 UTC (rev 6545) +++ core/trunk/src/test/java/org/jboss/cache/jmx/OptimisticNotificationTest= .java 2008-08-08 17:00:29 UTC (rev 6546) @@ -1,19 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package org.jboss.cache.jmx; - - -/** - * @author Manik Surtani (manik(a)jbo= ss.org) - */ -public class OptimisticNotificationTest extends NotificationTest -{ - public OptimisticNotificationTest() - { - optimistic =3D true; - } -} Copied: core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWra= pperTest.java (from rev 6541, core/trunk/src/test/java/org/jboss/cache/jmx/= CacheJmxWrapperTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapper= Test.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapper= Test.java 2008-08-08 17:00:29 UTC (rev 6546) @@ -0,0 +1,456 @@ +package org.jboss.cache.jmx.deprecated; + +import org.jboss.cache.Cache; +import org.jboss.cache.CacheException; +import org.jboss.cache.CacheStatus; +import org.jboss.cache.Fqn; +import org.jboss.cache.jmx.CacheJmxWrapper; +import org.jboss.cache.jmx.JmxRegistrationManager; +import org.jboss.cache.jmx.CacheJmxWrapperMBean; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.Configuration.CacheMode; +import org.jboss.cache.notifications.annotation.CacheListener; +import org.jboss.cache.notifications.annotation.CacheStarted; +import org.jboss.cache.notifications.annotation.CacheStopped; +import org.jboss.cache.notifications.event.Event; +import org.jboss.cache.transaction.DummyTransactionManagerLookup; +import org.jboss.cache.util.CachePrinter; +import org.jboss.cache.util.TestingUtil; +import org.jgroups.Address; +import org.jgroups.stack.IpAddress; +import static org.testng.AssertJUnit.*; +import org.testng.annotations.Test; + +import javax.management.ObjectName; +import javax.transaction.TransactionManager; +import java.util.List; + +/** + * Tests the JMX wrapper class around the cache. + * + * @author Manik Surtani + * @author Brian Stansberry + */ +(a)Test(groups =3D "functional") +public class CacheJmxWrapperTest extends CacheJmxWrapperTestBase +{ + public void testCacheMBeanBinding() throws Exception + { + registerWrapper(); + assertTrue("Should be registered", mBeanServer.isRegistered(mBeanNam= e)); + } + + public void testSetCacheObjectName() throws Exception + { + ObjectName on =3D new ObjectName("jboss.cache:test=3DSetCacheObjectN= ame"); + boolean registered =3D false; + try + { + CacheJmxWrapper wrapper =3D createWrapper(createC= onfiguration()); + wrapper.setCacheObjectName(on.getCanonicalName()); + + // Register under the standard name + registerWrapper(wrapper); + // Should be registered under 'on' + registered =3D mBeanServer.isRegistered(on); + + assertTrue("Registered with configured name", registered); + assertEquals("Configured name retained", on.getCanonicalName(), w= rapper.getCacheObjectName()); + + wrapper.create(); + wrapper.start(); + + interceptorRegistrationTest(on.getCanonicalName(), true); + + wrapper.stop(); + wrapper.destroy(); + + interceptorRegistrationTest(false); + } + finally + { + if (registered) + mBeanServer.unregisterMBean(on); + } + } + + public void testGetCacheObjectName() throws Exception + { + ObjectName on =3D new ObjectName("jboss.cache:test=3DSetCacheObjectN= ame"); + String str =3D on.getCanonicalName(); + CacheJmxWrapper wrapper =3D createWrapper(createConf= iguration()); + wrapper.setCacheObjectName(str); + + assertEquals("Setter and getter match", str, wrapper.getCacheObjectN= ame()); + + // Go back to the default + wrapper.setCacheObjectName(null); + assertEquals("Got default ObjectName", JmxRegistrationManager.CLUSTE= RED_CACHE_PREFIX + CLUSTER_NAME, wrapper.getCacheObjectName()); + + registerWrapper(wrapper); + assertEquals("Returns standard name", mBeanName, new ObjectName(wrap= per.getCacheObjectName())); + } + + public void testGetConfiguration1() throws Exception + { + CacheJmxWrapperMBean wrapper =3D registerWrapper(); + Configuration cfgFromJmx =3D wrapper.getConfiguration(); + assertNotNull("Got a configuration", cfgFromJmx); + assertSame(cache.getConfiguration(), cfgFromJmx); + } + + public void testGetConfiguration2() throws Exception + { + Configuration cfg =3D createConfiguration(); + CacheJmxWrapperMBean wrapper =3D registerWrapper(cfg= ); + Configuration cfgFromJmx =3D wrapper.getConfiguration(); + assertNotNull("Got a configuration", cfgFromJmx); + assertSame(cfg, cfgFromJmx); + } + + /** + * Note that this is a bit of a 'white box' test as it assumes that the + * returned String equals Configuration.toString(). That could change a= nd + * break this test; if it does, and there's nothing wrong with the + * change, just modify the test. + * + * @throws Exception + */ + public void testPrintConfigurationAsString1() throws Exception + { + CacheJmxWrapperMBean wrapper =3D registerWrapper(); + String cfgFromJmx =3D wrapper.printConfigurationAsString(); + assertEquals(cache.getConfiguration().toString(), cfgFromJmx); + } + + /** + * Note that this is a bit of a 'white box' test as it assumes that the + * returned String equals Configuration.toString(). That could change a= nd + * break this test; if it does, and there's nothing wrong with the + * change, just modify the test. + * + * @throws Exception + */ + public void testPrintConfigurationAsString2() throws Exception + { + Configuration cfg =3D createConfiguration(); + CacheJmxWrapperMBean wrapper =3D registerWrapper(cfg= ); + wrapper.create(); + wrapper.start(); + String cfgFromJmx =3D wrapper.printConfigurationAsString(); + assertEquals(wrapper.getCache().getConfiguration().toString(), cfgFr= omJmx); + } + + /** + * Note that this is a bit of a 'white box' test as it checks + * the currently coded HTML format and assumes that the HTML content is + * derived from Configuration.toString(). That could change and break + * this test; if it does, and there's nothing wrong with the + * change, just modify the test. + * + * @throws Exception + */ + public void testPrintConfigurationAsHtml1() throws Exception + { + CacheJmxWrapperMBean wrapper =3D registerWrapper(); + String cfgFromJmx =3D wrapper.printConfigurationAsHtmlString(); + assertEquals(CacheJmxWrapper.formatHtml(cache.getConfiguration().toS= tring()), cfgFromJmx); + checkHtml(cfgFromJmx, false); + } + + /** + * Note that this is a bit of a 'white box' test as it checks + * the currently coded HTML format and assumes that the HTML content is + * derived from Configuration.toString(). That could change and break + * this test; if it does, and there's nothing wrong with the + * change, just modify the test. + * + * @throws Exception + */ + public void testPrintConfigurationAsHtml2() throws Exception + { + Configuration cfg =3D createConfiguration(); + CacheJmxWrapperMBean wrapper =3D registerWrapper(cfg= ); + wrapper.create(); + wrapper.start(); + String cfgFromJmx =3D wrapper.printConfigurationAsHtmlString(); + assertEquals(CacheJmxWrapper.formatHtml(wrapper.getCache().getConfig= uration().toString()), cfgFromJmx); + checkHtml(cfgFromJmx, false); + } + + @SuppressWarnings("unchecked") + public void testGetCache() throws Exception + { + registerWrapper(); + // have to start the cache before we'll have a root + cache.start(); + + Cache cacheJmx =3D (Cache) mBeanServ= er.getAttribute(mBeanName, "Cache"); + cacheJmx.getRoot().put("key", "value"); + + assertEquals("value", cache.getRoot().get("key")); + + Fqn fqn =3D Fqn.fromString("/testing/jmx"); + cache.put(fqn, "key", "value"); + + assertEquals("value", cacheJmx.get(fqn, "key")); + } + + public void testPrintCacheDetails() throws Exception + { + printCacheDetailsTest(false); + } + + /** + * Note that this is a bit of a 'white box' test as it checks + * the currently coded HTML format. That could change and break + * this test; if it does, and there's nothing wrong with the + * change, just modify the test. + * + * @throws Exception + */ + public void testPrintCacheDetailsAsHtml() throws Exception + { + String html =3D printCacheDetailsTest(true); + checkHtml(html, true); + } + + public void testPrintLockInfo() throws Exception + { + printLockInfoTest(false); + } + + /** + * Note that this is a bit of a 'white box' test as it checks + * the currently coded HTML format. That could change and break + * this test; if it does, and there's nothing wrong with the + * change, just modify the test. + * + * @throws Exception + */ + public void testPrintLockInfoAsHtml() throws Exception + { + printLockInfoTest(true); + } + + public void testGetLocalAddress() throws Exception + { + Configuration c =3D createConfiguration(); + c.setCacheMode(CacheMode.REPL_ASYNC); + CacheJmxWrapperMBean wrapper =3D registerWrapper(c); + wrapper.start(); + assertTrue("Got an IpAddress", wrapper.getLocalAddress() instanceof = IpAddress); + } + + public void testGetMembers() throws Exception + { + Configuration c =3D createConfiguration(); + c.setCacheMode(CacheMode.REPL_ASYNC); + CacheJmxWrapperMBean wrapper =3D registerWrapper(c); + wrapper.start(); + + c =3D createConfiguration(); + c.setCacheMode(CacheMode.REPL_ASYNC); + Cache cache2 =3D null; + try + { + cache2 =3D createCache(c); + cache2.start(); + Cache[] caches =3D new Cache[]{wrapper.getCache(), cache2}; + TestingUtil.blockUntilViewsReceived(caches, 5000); + + Address addr =3D wrapper.getLocalAddress(); + assertNotNull("Got an Address", addr); + List members =3D wrapper.getMembers(); + assertNotNull("Got members", addr); + assertEquals("Got correct number of members", 2, members.size()); + assertTrue("I am a member", members.contains(addr)); + } + finally + { + if (cache2 !=3D null) + { + cache2.destroy(); + } + } + } + + public void testDuplicateInvocation() throws Exception + { + CacheJmxWrapperMBean cache =3D registerWrapper(); + cache.create(); + cache.start(); + cache.create(); + cache.start(); + + cache.getCache().put(Fqn.fromString("/a/b/c"), null); + assertTrue(cache.getNumberOfNodes() > 0); + assertEquals(0, cache.getNumberOfAttributes()); + + System.out.println("cache locks before restart:\n" + cache.printLock= Info()); + cache.destroy(); + cache.start(); + System.out.println("cache locks after restart:\n" + cache.printLockI= nfo()); + + assertEquals(0, cache.getNumberOfNodes()); + assertEquals(0, cache.getNumberOfAttributes()); + + cache.stop(); + cache.destroy(); + cache.stop(); + cache.destroy(); + } + + public void testFailedStart() throws Exception + { + CacheJmxWrapper wrapper =3D new CacheJmxWrapper(createCache(createConfiguration())); + registerWrapper(wrapper); + assertEquals("Correct state", CacheStatus.INSTANTIATED, wrapper.getC= acheStatus()); + wrapper.create(); + + DisruptLifecycleListener listener =3D new DisruptLifecycleListener(); + listener.setDisrupt(true); + wrapper.getCache().addCacheListener(listener); + + assertEquals("Correct state", CacheStatus.CREATED, wrapper.getCacheS= tatus()); + try + { + wrapper.start(); + fail("Listener did not prevent start"); + } + catch (CacheException good) + { + } + + assertEquals("Correct state", CacheStatus.FAILED, wrapper.getCacheSt= atus()); + + listener.setDisrupt(false); + + wrapper.start(); + + assertEquals("Correct state", CacheStatus.STARTED, wrapper.getCacheS= tatus()); + + wrapper.getCache().put(Fqn.fromString("/a/b/c"), null); + assertTrue(wrapper.getNumberOfNodes() > 0); + assertEquals(0, wrapper.getNumberOfAttributes()); + + listener.setDisrupt(true); + // need to re-add the listener since the failed start would have nul= lified the notifier. + cache.addCacheListener(listener); + + try + { + wrapper.stop(); + fail("Listener did not prevent stop"); + } + catch (CacheException good) + { + } + + assertEquals("Correct state", CacheStatus.FAILED, wrapper.getCacheSt= atus()); + + listener.setDisrupt(false); + + wrapper.stop(); + assertEquals("Correct state", CacheStatus.STOPPED, wrapper.getCacheS= tatus()); + wrapper.destroy(); + assertEquals("Correct state", CacheStatus.DESTROYED, wrapper.getCach= eStatus()); + } + + private String printCacheDetailsTest(boolean html) throws Exception + { + CacheJmxWrapperMBean wrapper =3D registerWrapper(); + + // have to start the cache before we'll have a root + cache.start(); + Fqn fqn =3D Fqn.fromString("/testing/jmx"); + cache.put(fqn, "foobar", "barfoo"); + + assertEquals("barfoo", cache.get(fqn, "foobar")); + + String details =3D html ? wrapper.printCacheDetailsAsHtml() : wrappe= r.printCacheDetails(); + + + System.out.println("Cache details: " + CachePrinter.printCacheDetail= s(cache)); + System.out.println("Details: " + details); + + assertTrue("Details include testing", details.contains("testing")); + assertTrue("Details include jmx", details.contains("jmx")); + assertTrue("Details include foobar", details.contains("foobar")); + assertTrue("Details include barfoo", details.contains("barfoo")); + + return details; + } + + private String printLockInfoTest(boolean html) throws Exception + { + Configuration config =3D createConfiguration(); + config.setTransactionManagerLookupClass(DummyTransactionManagerLooku= p.class.getName()); + Cache c =3D createCache(config); + CacheJmxWrapperMBean wrapper =3D registerWrapper(c); + +// wrapper.setManageCacheLifecycle(true); + wrapper.create(); + wrapper.start(); + + TransactionManager tm =3D config.getRuntimeConfig().getTransactionMa= nager(); + + tm.begin(); + try + { + Fqn fqn =3D Fqn.fromString("/testing/jmx"); + cache.put(fqn, "foobar", "barfoo"); + + String locks =3D html ? wrapper.printLockInfoAsHtml() : wrapper.p= rintLockInfo(); + + assertTrue("Details include testing", locks.contains("testing")); + assertTrue("Details include jmx", locks.contains("jmx")); + + return locks; + } + catch (Exception e) + { + tm.setRollbackOnly(); + throw e; + } + finally + { + tm.commit(); + } + + } + + private void checkHtml(String html, boolean checkBR) + { + if (checkBR) + assertTrue("Has Manik Surtani + * @author Brian Stansberry + */ +(a)Test(groups =3D "functional") +public abstract class CacheJmxWrapperTestBase +{ + public static final String CLUSTER_NAME =3D "CacheMBeanTest"; + + protected Cache cache; + protected CacheJmxWrapperMBean jmxWrapper; + protected MBeanServer mBeanServer; + protected ObjectName mBeanName; + protected String mBeanNameStr; + + @BeforeMethod(alwaysRun =3D true) + public void setUp() throws Exception + { + mBeanServer =3D MBeanServerFactory.createMBeanServer("CacheMBeanTest= "); + + mBeanNameStr =3D JmxRegistrationManager.CLUSTERED_CACHE_PREFIX + CLU= STER_NAME; + mBeanName =3D new ObjectName(mBeanNameStr); + } + + @AfterMethod(alwaysRun =3D true) + public void tearDown() throws Exception + { + try + { + cleanup(); + } + finally + { + if (mBeanServer !=3D null) + { + MBeanServerFactory.releaseMBeanServer(mBeanServer); + mBeanServer =3D null; + } + } + } + + protected CacheJmxWrapperMBean registerWrapper() throws= Exception + { + if (cache =3D=3D null) + cache =3D createCache(createConfiguration()); + return registerWrapper(cache); + } + + protected CacheJmxWrapperMBean registerWrapper(Cache toWrap) throws Exception + { + CacheJmxWrapper wrapper =3D new CacheJmxWrapper(toWrap); + return registerWrapper(wrapper); + } + + protected CacheJmxWrapperMBean registerWrapper(Configur= ation config) throws Exception + { + CacheJmxWrapper wrapper =3D new CacheJmxWrapper(); + wrapper.setConfiguration(config); + return registerWrapper(wrapper); + } + + @SuppressWarnings("unchecked") + protected CacheJmxWrapperMBean registerWrapper(CacheJmx= WrapperMBean wrapper) throws Exception + { + ObjectName on =3D new ObjectName(mBeanNameStr); + if (!mBeanServer.isRegistered(on)) + { + mBeanServer.registerMBean(wrapper, on); + } + jmxWrapper =3D (CacheJmxWrapperMBean) MBeanServerInv= ocationHandler.newProxyInstance(mBeanServer, mBeanName, CacheJmxWrapperMBea= n.class, false); + return jmxWrapper; + } + + protected void unregisterWrapper() throws Exception + { + mBeanServer.unregisterMBean(mBeanName); + } + + protected CacheJmxWrapper createWrapper(Configuration c= onfig) + { + CacheJmxWrapper wrapper =3D new CacheJmxWrapper(); + wrapper.setConfiguration(config); + return wrapper; + } + + protected Cache createCache(Configuration config) + { + CacheFactory factory =3D new DefaultCacheFactory(); + cache =3D factory.createCache(config, false); + return cache; + } + + protected Configuration createConfiguration() + { + Configuration c =3D new Configuration(); + c.setClusterName(CLUSTER_NAME); + c.setExposeManagementStatistics(true); + c.setCacheMode(Configuration.CacheMode.LOCAL); + return c; + } + + private void cleanup() throws Exception + { + if (cache !=3D null) + { + try + { + cache.stop(); + } + catch (Exception ignored) + { + } + + cache =3D null; + } + if (jmxWrapper !=3D null) + { + try + { + jmxWrapper.stop(); + jmxWrapper.destroy(); + } + catch (Exception ignored) + { + } + + jmxWrapper =3D null; + } + + if (mBeanServer !=3D null && mBeanName !=3D null && mBeanServer.isRe= gistered(mBeanName)) + mBeanServer.unregisterMBean(mBeanName); + } + + protected void interceptorRegistrationTest(boolean expectMbeans) throws= MalformedObjectNameException, NullPointerException + { + interceptorRegistrationTest(mBeanNameStr, expectMbeans); + } + + protected void interceptorRegistrationTest(String baseName, boolean exp= ectMbeans) throws MalformedObjectNameException, NullPointerException + { + // should be 3 interceptor MBeans loaded: + ObjectName[] interceptorMBeanNames =3D { + new ObjectName(baseName + JmxRegistrationManager.JMX_RESOURCE_= KEY + "TxInterceptor"), + new ObjectName(baseName + JmxRegistrationManager.JMX_RESOURCE_= KEY + "CacheMgmtInterceptor"), + }; + + for (ObjectName n : interceptorMBeanNames) + { + if (expectMbeans) + assertTrue(n + " should be registered", mBeanServer.isRegister= ed(n)); + else + assertFalse(n + " should not be registered", mBeanServer.isReg= istered(n)); + } + } +} Property changes on: core/trunk/src/test/java/org/jboss/cache/jmx/deprecate= d/CacheJmxWrapperTestBase.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Copied: core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/Interceptor= RegistrationTest.java (from rev 6541, core/trunk/src/test/java/org/jboss/ca= che/jmx/InterceptorRegistrationTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/InterceptorRegi= strationTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/InterceptorRegi= strationTest.java 2008-08-08 17:00:29 UTC (rev 6546) @@ -0,0 +1,386 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2006, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.cache.jmx.deprecated; + +import org.jboss.cache.config.Configuration; +import org.jboss.cache.jmx.CacheJmxWrapperMBean; +import org.jboss.cache.jmx.CacheJmxWrapper; +import static org.testng.AssertJUnit.assertTrue; +import org.testng.annotations.Test; + +/** + * Tests the interceptor registration function of CacheJmxWrapper. + * + * @author Brian Stansberry + * @version $Revision$ + */ +(a)Test(groups =3D "functional") +public class InterceptorRegistrationTest extends CacheJmxWrapperTestBase +{ + + /** + * Confirms interceptor mbeans are registered if the following events + * occur: + *

    + * cache.start(); + * wrapper creation and registration. + * + * @throws Exception + */ + public void testInterceptorMBeans1() throws Exception + { + // have to start the cache to have any interceptors + createCache(createConfiguration()); + cache.start(); + + CacheJmxWrapperMBean wrapper =3D registerWrapper(cac= he); + assertTrue("Should be registered", mBeanServer.isRegistered(mBeanNam= e)); + + interceptorRegistrationTest(true); + + // These should be ignored because we + // never did wrapper.create()/start() + wrapper.stop(); + wrapper.destroy(); + + // Should still be registered + interceptorRegistrationTest(true); + + unregisterWrapper(); + + interceptorRegistrationTest(false); + } + + /** + * Confirms interceptor mbeans are registered if the following events + * occur: + *

    + * cache.start(); + * wrapper creation and and start + * wrapper registration. + * + * @throws Exception + */ + public void testInterceptorMBeans2() throws Exception + { + // have to start the cache to have any interceptors + createCache(createConfiguration()); + cache.start(); + + CacheJmxWrapperMBean wrapper =3D new CacheJmxWrapper= (cache); + wrapper.start(); + wrapper =3D registerWrapper(wrapper); + assertTrue("Should be registered", mBeanServer.isRegistered(mBeanNam= e)); + + interceptorRegistrationTest(true); + + wrapper.stop(); + wrapper.destroy(); + + // Should still no longer be registered + interceptorRegistrationTest(false); + + unregisterWrapper(); + + interceptorRegistrationTest(false); + } + + /** + * Confirms interceptor mbeans are registered if the following events + * occur: + *

    + * Cache not injected + * wrapper registered; + * wrapper created and started. + * + * @throws Exception + */ + public void testInterceptorMBeans3() throws Exception + { + CacheJmxWrapperMBean wrapper =3D registerWrapper(cre= ateConfiguration()); + assertTrue("Should be registered", mBeanServer.isRegistered(mBeanNam= e)); + + // have to start the cache to have any interceptors + wrapper.create(); + wrapper.start(); + + interceptorRegistrationTest(true); + + wrapper.stop(); + wrapper.destroy(); + + // Destroy should unregister if we are managing + interceptorRegistrationTest(false); + + unregisterWrapper(); + + interceptorRegistrationTest(false); + } + + /** + * Confirms interceptor mbeans are registered if the following events + * occur: + *

    + * Cache not injected + * wrapper created and started. + * wrapper registered + * + * @throws Exception + */ + public void testInterceptorMBeans4() throws Exception + { + CacheJmxWrapper wrapper =3D createWrapper(createConf= iguration()); + + // have to start the cache to have any interceptors + wrapper.create(); + wrapper.start(); + + registerWrapper(wrapper); + + assertTrue("Should be registered", mBeanServer.isRegistered(mBeanNam= e)); + + interceptorRegistrationTest(true); + + wrapper.stop(); + wrapper.destroy(); + + // Destroy should unregister if we are managing + interceptorRegistrationTest(false); + + unregisterWrapper(); + + interceptorRegistrationTest(false); + } + + /** + * Confirms interceptor mbeans are registered if the following events + * occur: + *

    + * cache constructed; + * wrapper constructed and registered with manageCacheLifecycle=3Dtrue + * wrapper created and started + * + * @throws Exception + */ + public void testInterceptorMBeans5() throws Exception + { + CacheJmxWrapperMBean wrapper =3D registerWrapper(); +// wrapper.setManageCacheLifecycle(true); + assertTrue("Should be registered", mBeanServer.isRegistered(mBeanNam= e)); + + // have to start the cache to have any interceptors + wrapper.create(); + wrapper.start(); + + interceptorRegistrationTest(true); + + wrapper.stop(); + wrapper.destroy(); + + // Destroy should unregister if we are managing + interceptorRegistrationTest(false); + + unregisterWrapper(); + + interceptorRegistrationTest(false); + } + + /** + * Confirms interceptor mbeans are registered if the following events + * occur: + *

    + * cache constructed; + * wrapper constructed and registered + * wrapper created and started + * + * @throws Exception + */ + public void testInterceptorMBeans6() throws Exception + { + CacheJmxWrapperMBean wrapper =3D registerWrapper(); + assertTrue("Should be registered", mBeanServer.isRegistered(mBeanNam= e)); + + // have to start the cache to have any interceptors + wrapper.create(); + wrapper.start(); + + interceptorRegistrationTest(true); + + wrapper.stop(); + wrapper.destroy(); + + interceptorRegistrationTest(false); + + unregisterWrapper(); + + interceptorRegistrationTest(false); + } + + /** + * Confirms interceptor mbeans are registered if the following events + * occur: + *

    + * cache constructed; + * wrapper created and started + * wrapper registered + * + * @throws Exception + */ + public void testInterceptorMBeans7() throws Exception + { + CacheJmxWrapperMBean wrapper =3D new CacheJmxWrapper= (createCache(createConfiguration())); + + // have to start the cache to have any interceptors + wrapper.create(); + wrapper.start(); + + wrapper =3D registerWrapper(wrapper); + assertTrue("Should be registered", mBeanServer.isRegistered(mBeanNam= e)); + + interceptorRegistrationTest(true); + + wrapper.stop(); + wrapper.destroy(); + + interceptorRegistrationTest(false); + + unregisterWrapper(); + + interceptorRegistrationTest(false); + } + + /** + * Tests that setting registerInterceptors=3Dfalse disables interceptor + * registration when the wrapper is registered before create/start + * are called. + * + * @throws Exception + */ + public void testRegisterInterceptors1() throws Exception + { + CacheJmxWrapper wrapper =3D createWrapper(createConf= iguration()); + wrapper.setRegisterJmxResource(false); + + registerWrapper(wrapper); + + assertTrue("Should be registered", mBeanServer.isRegistered(mBeanNam= e)); + + wrapper.create(); + wrapper.start(); + + interceptorRegistrationTest(false); + + wrapper.stop(); + wrapper.destroy(); + + interceptorRegistrationTest(false); + + unregisterWrapper(); + + interceptorRegistrationTest(false); + } + + /** + * Tests that setting registerInterceptors=3Dfalse disables interceptor + * registration when the wrapper is registered after create/start + * are called. + * + * @throws Exception + */ + public void testRegisterInterceptors2() throws Exception + { + CacheJmxWrapper wrapper =3D createWrapper(createConf= iguration()); + wrapper.setRegisterJmxResource(false); + + wrapper.create(); + wrapper.start(); + + registerWrapper(wrapper); + + assertTrue("Should be registered", mBeanServer.isRegistered(mBeanNam= e)); + + interceptorRegistrationTest(false); + + wrapper.stop(); + wrapper.destroy(); + + interceptorRegistrationTest(false); + + unregisterWrapper(); + + interceptorRegistrationTest(false); + } + + public void testExposeManagementStatistics1() throws Exception + { + Configuration cfg =3D createConfiguration(); + cfg.setExposeManagementStatistics(false); + + CacheJmxWrapper wrapper =3D createWrapper(cfg); + registerWrapper(cfg); + + assertTrue("Should be registered", mBeanServer.isRegistered(mBeanNam= e)); + + wrapper.create(); + wrapper.start(); + + interceptorRegistrationTest(false); + + wrapper.stop(); + wrapper.destroy(); + + interceptorRegistrationTest(false); + + unregisterWrapper(); + + interceptorRegistrationTest(false); + } + + public void testExposeManagementStatistics2() throws Exception + { + Configuration cfg =3D createConfiguration(); + cfg.setExposeManagementStatistics(false); + + CacheJmxWrapper wrapper =3D createWrapper(cfg); + + wrapper.create(); + wrapper.start(); + + registerWrapper(wrapper); + + assertTrue("Should be registered", mBeanServer.isRegistered(mBeanNam= e)); + + interceptorRegistrationTest(false); + + wrapper.stop(); + wrapper.destroy(); + + interceptorRegistrationTest(false); + + unregisterWrapper(); + + interceptorRegistrationTest(false); + + } + +} Property changes on: core/trunk/src/test/java/org/jboss/cache/jmx/deprecate= d/InterceptorRegistrationTest.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Copied: core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfi= gurationTest.java (from rev 6541, core/trunk/src/test/java/org/jboss/cache/= jmx/LegacyConfigurationTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigura= tionTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigura= tionTest.java 2008-08-08 17:00:29 UTC (rev 6546) @@ -0,0 +1,415 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2006, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.cache.jmx.deprecated; + +import org.jboss.cache.Version; +import org.jboss.cache.jmx.CacheJmxWrapperMBean; +import org.jboss.cache.jmx.CacheJmxWrapper; +import org.jboss.cache.config.BuddyReplicationConfig; +import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig; +import org.jboss.cache.config.CacheLoaderConfig; +import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfi= g; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.Configuration.CacheMode; +import org.jboss.cache.config.Configuration.NodeLockingScheme; +import org.jboss.cache.config.EvictionConfig; +import org.jboss.cache.config.EvictionRegionConfig; +import org.jboss.cache.config.RuntimeConfig; +import org.jboss.cache.config.parsing.XmlConfigHelper; +import org.jboss.cache.eviction.FIFOConfiguration; +import org.jboss.cache.eviction.FIFOPolicy; +import org.jboss.cache.eviction.LRUConfiguration; +import org.jboss.cache.eviction.LRUPolicy; +import org.jboss.cache.eviction.MRUConfiguration; +import org.jboss.cache.eviction.MRUPolicy; +import org.jboss.cache.loader.FileCacheLoader; +import org.jboss.cache.loader.SingletonStoreCacheLoader; +import org.jboss.cache.loader.jdbm.JdbmCacheLoader; +import org.jboss.cache.lock.IsolationLevel; +import org.jboss.cache.multiplexer.MultiplexerTestHelper; +import org.jboss.cache.transaction.BatchModeTransactionManagerLookup; +import org.jgroups.ChannelFactory; +import org.jgroups.JChannelFactory; +import org.jgroups.jmx.JChannelFactoryMBean; +import static org.testng.AssertJUnit.*; +import org.testng.annotations.Test; +import org.w3c.dom.Element; + +import javax.management.MBeanServerInvocationHandler; +import javax.management.ObjectName; +import javax.transaction.TransactionManager; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.List; +import java.util.Properties; + +/** + * Test of the CacheLegacyJmxWrapper. + * + * @author Brian Stansberry + * @version $Revision$ + */ +(a)Test(groups =3D "functional") +public class LegacyConfigurationTest extends CacheJmxWrapperTestBase +{ + @SuppressWarnings({"deprecation", "unchecked"}) + public void testLocalCache() throws Exception + { + CacheJmxWrapperMBean wrapper =3D new CacheJmxWrapper= (); + registerWrapper(wrapper); + + wrapper =3D (CacheJmxWrapperMBean) MBeanServerInvoca= tionHandler.newProxyInstance(mBeanServer, mBeanName, CacheJmxWrapperMBean.c= lass, false); + + wrapper.setBuddyReplicationConfig(getBuddyReplicationConfig()); + wrapper.setCacheLoaderConfig(getCacheLoaderConfig()); + wrapper.setCacheMode("REPL_SYNC"); + wrapper.setClusterName("LocalTest"); + wrapper.setClusterConfig(getClusterConfig()); + wrapper.setEvictionPolicyConfig(getEvictionPolicyConfig()); + wrapper.setFetchInMemoryState(false); + wrapper.setInitialStateRetrievalTimeout(100); + wrapper.setInactiveOnStartup(true); + wrapper.setNodeLockingScheme("OPTIMISTIC"); + wrapper.setIsolationLevel("READ_UNCOMMITTED"); + wrapper.setLockAcquisitionTimeout(200); + wrapper.setReplicationVersion("1.0.1"); + wrapper.setReplQueueInterval(15); + wrapper.setReplQueueMaxElements(50); + wrapper.setSyncReplTimeout(300); + wrapper.setSyncCommitPhase(true); + wrapper.setSyncRollbackPhase(true); + wrapper.setTransactionManagerLookupClass(BatchModeTransactionManager= Lookup.class.getName()); + wrapper.setExposeManagementStatistics(false); + wrapper.setUseRegionBasedMarshalling(true); + wrapper.setUseReplQueue(true); + + Configuration c =3D wrapper.getConfiguration(); + + assertEquals("CacheMode", "REPL_SYNC", wrapper.getCacheMode()); + assertEquals("CacheMode", CacheMode.REPL_SYNC, c.getCacheMode()); + assertEquals("ClusterName", "LocalTest", wrapper.getClusterName()); + assertEquals("ClusterName", "LocalTest", c.getClusterName()); + assertEquals("FetchInMemoryState", false, wrapper.getFetchInMemorySt= ate()); + assertEquals("FetchInMemoryState", false, c.isFetchInMemoryState()); + assertEquals("InitialStateRetrievalTimeout", 100, wrapper.getInitial= StateRetrievalTimeout()); + assertEquals("InitialStateRetrievalTimeout", 100, c.getStateRetrieva= lTimeout()); + assertEquals("InactiveOnStartup", true, wrapper.isInactiveOnStartup(= )); + assertEquals("InactiveOnStartup", true, c.isInactiveOnStartup()); + assertEquals("NodeLockingScheme", "OPTIMISTIC", wrapper.getNodeLocki= ngScheme()); + assertEquals("NodeLockingScheme", NodeLockingScheme.OPTIMISTIC, c.ge= tNodeLockingScheme()); + assertEquals("IsolationLevel", "READ_UNCOMMITTED", wrapper.getIsolat= ionLevel()); + assertEquals("IsolationLevel", IsolationLevel.READ_UNCOMMITTED, c.ge= tIsolationLevel()); + assertEquals("LockAcquisitionTimeout", 200, wrapper.getLockAcquisiti= onTimeout()); + assertEquals("LockAcquisitionTimeout", 200, c.getLockAcquisitionTime= out()); + assertEquals("ReplicationVersion", "1.0.1", wrapper.getReplicationVe= rsion()); + assertEquals("ReplicationVersion", Version.getVersionShort("1.0.1"),= c.getReplicationVersion()); + assertEquals("ReplQueueInterval", 15, wrapper.getReplQueueInterval()= ); + assertEquals("ReplQueueInterval", 15, c.getReplQueueInterval()); + assertEquals("ReplQueueMaxElements", 50, wrapper.getReplQueueMaxElem= ents()); + assertEquals("ReplQueueMaxElements", 50, c.getReplQueueMaxElements()= ); + assertEquals("SyncReplTimeout", 300, wrapper.getSyncReplTimeout()); + assertEquals("SyncReplTimeout", 300, c.getSyncReplTimeout()); + assertEquals("SyncCommitPhase", true, wrapper.getSyncCommitPhase()); + assertEquals("SyncCommitPhase", true, c.isSyncCommitPhase()); + assertEquals("SyncRollbackPhase", true, wrapper.getSyncRollbackPhase= ()); + assertEquals("SyncRollbackPhase", true, c.isSyncRollbackPhase()); + assertEquals("TransactionManagerLookupClass", BatchModeTransactionMa= nagerLookup.class.getName(), wrapper.getTransactionManagerLookupClass()); + assertEquals("TransactionManagerLookupClass", BatchModeTransactionMa= nagerLookup.class.getName(), c.getTransactionManagerLookupClass()); + assertEquals("ExposeManagementStatistics", false, wrapper.getExposeM= anagementStatistics()); + assertEquals("ExposeManagementStatistics", false, c.getExposeManagem= entStatistics()); + assertEquals("UseRegionBasedMarshalling", true, wrapper.getUseRegion= BasedMarshalling()); + assertEquals("UseRegionBasedMarshalling", true, c.isUseRegionBasedMa= rshalling()); + assertEquals("UseReplQueue", true, wrapper.getUseReplQueue()); + assertEquals("UseReplQueue", true, c.isUseReplQueue()); + + assertEquals("ClusterConfig", getClusterConfig().toString(), wrapper= .getClusterConfig().toString()); + + assertEquals("BuddyReplicationConfig", getBuddyReplicationConfig().t= oString(), wrapper.getBuddyReplicationConfig().toString()); + BuddyReplicationConfig brc =3D c.getBuddyReplicationConfig(); + assertEquals("BR enabled", true, brc.isEnabled()); + assertEquals("BR auto grav", false, brc.isAutoDataGravitation()); + assertEquals("BR remove find", false, brc.isDataGravitationRemoveOnF= ind()); + assertEquals("BR search backup", false, brc.isDataGravitationSearchB= ackupTrees()); + assertEquals("BR comm timeout", 600000, brc.getBuddyCommunicationTim= eout()); + assertEquals("BR poolname", "testpool", brc.getBuddyPoolName()); + BuddyLocatorConfig blc =3D brc.getBuddyLocatorConfig(); + assertEquals("BR locator", "org.jboss.cache.buddyreplication.TestBud= dyLocator", blc.getBuddyLocatorClass()); + Properties props =3D blc.getBuddyLocatorProperties(); + assertEquals("BR props", "2", props.get("numBuddies")); + + assertEquals("CacheLoaderConfig", getCacheLoaderConfig().toString(),= wrapper.getCacheLoaderConfig().toString()); + CacheLoaderConfig clc =3D c.getCacheLoaderConfig(); + assertEquals("CL passivation", false, clc.isPassivation()); + assertEquals("CL passivation", true, clc.isShared()); + assertEquals("CL preload", "/foo", clc.getPreload()); + List iclcs =3D clc.getIndividualCacheLo= aderConfigs(); + IndividualCacheLoaderConfig iclc =3D iclcs.get(0); + assertEquals("CL0 class", FileCacheLoader.class.getName(), iclc.getC= lassName()); + assertEquals("CL0 async", false, iclc.isAsync()); + assertEquals("CL0 fetch", true, iclc.isFetchPersistentState()); + assertEquals("CL0 ignore", true, iclc.isIgnoreModifications()); + assertEquals("CL0 purge", true, iclc.isPurgeOnStartup()); + assertEquals("CL0 singleton", true, iclc.getSingletonStoreConfig().i= sSingletonStoreEnabled()); + assertEquals("CL0 singleton class", SingletonStoreCacheLoader.class.= getName(), iclc.getSingletonStoreConfig().getSingletonStoreClass()); + iclc =3D iclcs.get(1); + assertEquals("CL1 class", JdbmCacheLoader.class.getName(), iclc.getC= lassName()); + assertEquals("CL1 async", true, iclc.isAsync()); + assertEquals("CL1 fetch", false, iclc.isFetchPersistentState()); + assertEquals("CL1 ignore", false, iclc.isIgnoreModifications()); + assertEquals("CL1 purge", false, iclc.isPurgeOnStartup()); + assertEquals("CL1 singleton", false, iclc.getSingletonStoreConfig().= isSingletonStoreEnabled()); + assertEquals("CL1 singleton class", SingletonStoreCacheLoader.class.= getName(), iclc.getSingletonStoreConfig().getSingletonStoreClass()); + + assertEquals("EvictionPolicyConfig", getEvictionPolicyConfig().toStr= ing(), wrapper.getEvictionPolicyConfig().toString()); + EvictionConfig ec =3D c.getEvictionConfig(); + assertEquals("EC queue size", 20000, ec.getDefaultEventQueueSize()); + assertEquals("EC wakeup", 5000, ec.getWakeupInterval()); + assertEquals("EC default pol", LRUPolicy.class.getName(), ec.getDefa= ultEvictionPolicyClass()); + List ercs =3D ec.getEvictionRegionConfigs(); + EvictionRegionConfig erc =3D ercs.get(0); + assertEquals("ERC0 name", "/_default_", erc.getRegionName()); + assertEquals("ERC0 queue size", 1000, erc.getEventQueueSize()); + LRUConfiguration lru =3D (LRUConfiguration) erc.getEvictionPolicyCon= fig(); + assertEquals("EPC0 pol", LRUPolicy.class.getName(), lru.getEvictionP= olicyClass()); + assertEquals("EPC0 maxnodes", 5000, lru.getMaxNodes()); + assertEquals("EPC0 ttl", 1000000, lru.getTimeToLive()); + erc =3D ercs.get(1); + assertEquals("ERC1 name", "/org/jboss/data", erc.getRegionName()); + assertEquals("ERC1 queue size", 20000, erc.getEventQueueSize()); + FIFOConfiguration fifo =3D (FIFOConfiguration) erc.getEvictionPolicy= Config(); + assertEquals("EPC1 pol", FIFOPolicy.class.getName(), fifo.getEvictio= nPolicyClass()); + assertEquals("EPC1 maxnodes", 5000, fifo.getMaxNodes()); + erc =3D ercs.get(2); + assertEquals("ERC2 name", "/test", erc.getRegionName()); + assertEquals("ERC2 queue size", 20000, erc.getEventQueueSize()); + MRUConfiguration mru =3D (MRUConfiguration) erc.getEvictionPolicyCon= fig(); + assertEquals("EPC2 pol", MRUPolicy.class.getName(), mru.getEvictionP= olicyClass()); + assertEquals("EPC2 maxnodes", 10000, mru.getMaxNodes()); + erc =3D ercs.get(3); + assertEquals("ERC3 name", "/maxAgeTest", erc.getRegionName()); + assertEquals("ERC3 queue size", 20000, erc.getEventQueueSize()); + lru =3D (LRUConfiguration) erc.getEvictionPolicyConfig(); + assertEquals("EPC3 pol", LRUPolicy.class.getName(), lru.getEvictionP= olicyClass()); + assertEquals("EPC3 maxnodes", 10000, lru.getMaxNodes()); + assertEquals("EPC3 maxage", 10000, lru.getMaxAge()); + assertEquals("EPC3 ttl", 8000, lru.getTimeToLive()); + + } + + @SuppressWarnings("unchecked") + public void testRuntimeConfig() throws Exception + { + CacheJmxWrapperMBean wrapper =3D new CacheJmxWrapper= (); + registerWrapper(wrapper); + + wrapper =3D (CacheJmxWrapperMBean) MBeanServerInvoca= tionHandler.newProxyInstance(mBeanServer, mBeanName, CacheJmxWrapperMBean.c= lass, false); + + // Fake a TM by making a bogus proxy + TransactionManager tm =3D (TransactionManager) Proxy.newProxyInstanc= e(getClass().getClassLoader(), + new Class[]{TransactionManager.class}, new MockInvocationHandl= er()); + wrapper.setTransactionManager(tm); + ChannelFactory cf =3D new JChannelFactory(); + wrapper.setMuxChannelFactory(cf); + + RuntimeConfig rc =3D wrapper.getConfiguration().getRuntimeConfig(); + + assertSame("Same TM", tm, wrapper.getTransactionManager()); + assertSame("Same TM", tm, rc.getTransactionManager()); + assertSame("Same ChannelFactory", cf, wrapper.getMuxChannelFactory()= ); + assertSame("Same ChannelFactory", cf, rc.getMuxChannelFactory()); + } + + @SuppressWarnings("unchecked") + public void testLegacyMuxChannelCreation() throws Exception + { + CacheJmxWrapperMBean wrapper =3D new CacheJmxWrapper= (); + registerWrapper(wrapper); + + wrapper =3D (CacheJmxWrapperMBean) MBeanServerInvoca= tionHandler.newProxyInstance(mBeanServer, mBeanName, CacheJmxWrapperMBean.c= lass, false); + wrapper.setMultiplexerStack(MultiplexerTestHelper.MUX_STACK); + + JChannelFactory factory =3D new JChannelFactory(); + factory.setDomain("jbc.mux.test"); + factory.setExposeChannels(false); + factory.setMultiplexerConfig(MultiplexerTestHelper.getClusterConfigE= lement(getDefaultProperties())); + + ObjectName on =3D new ObjectName("jgroups:service=3DMux"); + mBeanServer.registerMBean(new org.jgroups.jmx.JChannelFactory(factor= y), on); + + wrapper.setMultiplexerService((JChannelFactoryMBean) MBeanServerInvo= cationHandler.newProxyInstance(mBeanServer, on, JChannelFactoryMBean.class,= false)); + + wrapper.start(); + + RuntimeConfig rc =3D wrapper.getConfiguration().getRuntimeConfig(); + assertNotNull("Channel created", rc.getChannel()); + } + + protected static Element getBuddyReplicationConfig() throws Exception + { + + String xmlStr =3D + " \n" + + " \n" + + " \n" + + " \n" + + " numBuddies =3D 2\n" + + " \n" + + " \n" + + " "; + return XmlConfigHelper.stringToElement(xmlStr); + } + + protected static Element getCacheLoaderConfig() throws Exception + { + String xmlStr =3D + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " location=3D/tmp\n " + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " location=3D/home/bstansberry\n" + + " \n" + + " \n" + + " \n" + + " "; + return XmlConfigHelper.stringToElement(xmlStr); + } + + protected static Element getEvictionPolicyConfig() throws Exception + { + + String xmlStr =3D + " \n"= + + " \n" + + " 5000\n" + + " 1000000\n" + + " \n" + + "\n" + + " 5000\n" + + "\n" + + "\n" + + " 10000\n" + + "\n" + + "\n" + + " 10000\n" + + " 8\n" + + " 10\n= " + + "\n" + + " "; + return XmlConfigHelper.stringToElement(xmlStr); + } + + protected static Element getClusterConfig() throws Exception + { + String xml =3D + "\n" + + "\n= " + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \= n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + ""; + return XmlConfigHelper.stringToElement(xml); + } + + protected String getDefaultProperties() + { + return "UDP(mcast_addr=3D224.0.0.36;mcast_port=3D55566;ip_ttl=3D32;"= + + "mcast_send_buf_size=3D150000;mcast_recv_buf_size=3D80000):" + + "PING(timeout=3D1000;num_initial_members=3D2):" + + "MERGE2(min_interval=3D5000;max_interval=3D10000):" + + "FD_SOCK:" + + "VERIFY_SUSPECT(timeout=3D1500):" + + "pbcast.NAKACK(gc_lag=3D50;max_xmit_size=3D8192;retransmit_tim= eout=3D600,1200,2400,4800):" + + "UNICAST(timeout=3D600,1200,2400,4800):" + + "pbcast.STABLE(desired_avg_gossip=3D20000):" + + "FRAG(frag_size=3D8192;down_thread=3Dfalse;up_thread=3Dfalse):= " + + "pbcast.GMS(join_timeout=3D5000;join_retry_timeout=3D2000;" + + "shun=3Dfalse;print_local_addr=3Dtrue):" + + "pbcast.STATE_TRANSFER"; + } + + class MockInvocationHandler implements InvocationHandler + { + + public Object invoke(Object proxy, Method method, Object[] args) thr= ows Throwable + { + return null; + } + + } +} Property changes on: core/trunk/src/test/java/org/jboss/cache/jmx/deprecate= d/LegacyConfigurationTest.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Copied: core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LifecycleNo= tificationTest.java (from rev 6541, core/trunk/src/test/java/org/jboss/cach= e/jmx/LifecycleNotificationTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LifecycleNotifi= cationTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LifecycleNotifi= cationTest.java 2008-08-08 17:00:29 UTC (rev 6546) @@ -0,0 +1,105 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2006, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.cache.jmx.deprecated; + +import static org.testng.AssertJUnit.assertEquals; +import org.testng.AssertJUnit; +import org.jboss.cache.jmx.CacheJmxWrapper; +import org.jboss.cache.jmx.CacheJmxWrapperMBean; + +import javax.management.AttributeChangeNotification; +import javax.management.Notification; +import javax.management.NotificationListener; +import java.util.LinkedList; +import java.util.List; + +/** + * A LifecycleNotificationTest. + * + * @author Brian Stansberry + * @version $Revision$ + */ +public class LifecycleNotificationTest extends CacheJmxWrapperTestBase +{ + public void testGetStateAndStateNotification() throws Exception + { + CacheJmxWrapper wrapper =3D createWrapper(createConf= iguration()); + StateNotificationListener listener =3D new StateNotificationListener= (); + wrapper.addNotificationListener(listener, null, null); + + AssertJUnit.assertEquals("Correct state after instanitation", + CacheJmxWrapperMBean.UNREGISTERED, wrapper.getState()); + + registerWrapper(wrapper); + assertEquals("Correct state after registration", + CacheJmxWrapperMBean.REGISTERED, wrapper.getState()); + + wrapper.create(); + assertEquals("Correct state after create", + CacheJmxWrapperMBean.CREATED, wrapper.getState()); + + wrapper.start(); + assertEquals("Correct state after start", + CacheJmxWrapperMBean.STARTED, wrapper.getState()); + + wrapper.stop(); + assertEquals("Correct state after stop", + CacheJmxWrapperMBean.STOPPED, wrapper.getState()); + + wrapper.destroy(); + assertEquals("Correct state after destroy", + CacheJmxWrapperMBean.DESTROYED, wrapper.getState()); + + unregisterWrapper(); + assertEquals("Correct state after unregistration", + CacheJmxWrapperMBean.UNREGISTERED, wrapper.getState()); + + System.out.println(listener.notifications); + assertEquals("Correct number of notifications received", 4, listener= .notifications.size()); + assertEquals("Correct first notification", new Integer(CacheJmxWrapp= erMBean.STARTING), listener.notifications.get(0)); + assertEquals("Correct second notification", new Integer(CacheJmxWrap= perMBean.STARTED), listener.notifications.get(1)); + assertEquals("Correct third notification", new Integer(CacheJmxWrapp= erMBean.STOPPING), listener.notifications.get(2)); + assertEquals("Correct fourth notification", new Integer(CacheJmxWrap= perMBean.STOPPED), listener.notifications.get(3)); + } + + private static class StateNotificationListener + implements NotificationListener + { + private List notifications =3D new LinkedList(); + + public void handleNotification(Notification msg, Object handback) + { + if (msg instanceof AttributeChangeNotification) + { + AttributeChangeNotification change =3D (AttributeChangeNotific= ation) msg; + String attrName =3D change.getAttributeName(); + Object newValue =3D change.getNewValue(); + if ("State".equals(attrName) && newValue !=3D null && newValue= instanceof Integer) + { + notifications.add((Integer) newValue); + } + } + } + } + +} Property changes on: core/trunk/src/test/java/org/jboss/cache/jmx/deprecate= d/LifecycleNotificationTest.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Copied: core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/Notificatio= nTest.java (from rev 6541, core/trunk/src/test/java/org/jboss/cache/jmx/Not= ificationTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/NotificationTes= t.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/NotificationTes= t.java 2008-08-08 17:00:29 UTC (rev 6546) @@ -0,0 +1,470 @@ +package org.jboss.cache.jmx.deprecated; + +import org.jboss.cache.CacheFactory; +import org.jboss.cache.CacheSPI; +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.Fqn; +import org.jboss.cache.jmx.CacheJmxWrapper; +import org.jboss.cache.jmx.JmxRegistrationManager; +import org.jboss.cache.jmx.CacheNotificationBroadcaster; +import org.jboss.cache.config.CacheLoaderConfig; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.Configuration.CacheMode; +import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; +import org.jboss.cache.loader.CacheLoader; +import static org.testng.AssertJUnit.*; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import javax.management.MBeanServer; +import javax.management.MBeanServerFactory; +import javax.management.Notification; +import javax.management.NotificationListener; +import javax.management.ObjectName; +import java.util.EnumSet; +import java.util.HashMap; + +/** + * Functional tests for CacheJmxWrapper broadcast of cache event notificat= ions + * + * @author Jerry Gauthier + * @version $Id$ + */ +(a)Test(groups =3D {"functional"}) +public class NotificationTest +{ + protected static final String CLUSTER_NAME =3D "NotificationTestCluster= "; + + protected static final String CAPITAL =3D "capital"; + protected static final String CURRENCY =3D "currency"; + protected static final String POPULATION =3D "population"; + protected static final String EUROPE_NODE =3D "Europe"; + + public enum Type + { + STARTED, STOPPED, PRECREATE, POSTCREATE, PREEVICT, POSTEVICT, + PRELOAD, POSTLOAD, PREREMOVE, POSTREMOVE, PREVISIT, POSTVISIT, + PREMODIFY, POSTMODIFY, PREACTIVATE, POSTACTIVATE, PREPASSIVATE, + POSTPASSIVATE, VIEWCHANGE + } + + protected MBeanServer m_server; + protected EnumSet events =3D EnumSet.noneOf(Type.class); + + protected CacheSPI cache =3D null; + protected boolean optimistic =3D false; + + @BeforeMethod(alwaysRun =3D true) + public void setUp() throws Exception + { + m_server =3D MBeanServerFactory.createMBeanServer(); + + Object cacheMBean =3D createCacheAndJmxWrapper(); + + // bind manually for now. + ObjectName mgmt =3D getWrapperObjectName(); + + m_server.registerMBean(cacheMBean, mgmt); + } + + protected Object createCacheAndJmxWrapper() throws Exception + { + cache =3D createCache(CLUSTER_NAME); + return new CacheJmxWrapper(cache); + } + + @AfterMethod(alwaysRun =3D true) + public void tearDown() throws Exception + { + try + { + cleanup(); + } + finally + { + // make sure we stop the mbean server + if (m_server !=3D null) + MBeanServerFactory.releaseMBeanServer(m_server); + } + } + + protected void cleanup() throws Exception + { + events.clear(); + + destroyCache(); + + if (m_server !=3D null) + { + ObjectName mgmt =3D getWrapperObjectName(); + if (m_server.isRegistered(mgmt)) + m_server.unregisterMBean(mgmt); + } + } + + protected void destroyCache() + { + if (cache !=3D null) + { + // stop the cache before the listener is unregistered + //cache1.stop(); + cache.destroy(); + cache =3D null; + } + } + + protected ObjectName getWrapperObjectName() throws Exception + { + return new ObjectName(JmxRegistrationManager.CLUSTERED_CACHE_PREFIX = + CLUSTER_NAME); + } + + public void testNotifications() throws Exception + { + assertNotNull("MBeanServer is null.", m_server); + assertNotNull("Cache is null.", cache); + + ObjectName mgmt =3D getWrapperObjectName(); + MyListener listener =3D new MyListener(mgmt); + + + m_server.addNotificationListener(mgmt, listener, null, null); + + // start the cache after registering listener - this will trigger Ca= cheStarted + // since cache is defined with cluster, thiswill also trigger ViewCh= ange + cache.start(); + + // add a node - this will trigger NodeCreated, NodeModify(pre/post) = and NodeModified + HashMap albania =3D new HashMap(4); + albania.put(CAPITAL, "Tirana"); + albania.put(CURRENCY, "Lek"); + cache.put("Europe/Albania", albania); + + // modify a node - this will trigger NodeModified and NodeModify(pre= /post) + cache.put("Europe/Albania", POPULATION, 3563112); + + // retrieve an attribute - this will trigger NodeVisited + Fqn key =3D Fqn.fromString("Europe/Albania"); + assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + = " for " + key, cache.get(key, CURRENCY)); + + // evict the node - this will trigger NodePassivate, NodeEvicted and= NodeEvict(pre/post) + cache.evict(key); + + // retrieve the attribute again - this will trigger NodeVisited and = NodeActivate + assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + = " for " + key, cache.get(key, CURRENCY)); + + // remove the node - this will trigger NodeRemoved and NodeRemove(pr= e/post) + cache.removeNode(key); + + // clean up before stopping the cache + CacheLoader cl =3D cache.getCacheLoaderManager().getCacheLoader(); + cl.remove(Fqn.fromString(EUROPE_NODE)); + + // stop the cache + cache.stop(); + m_server.removeNotificationListener(mgmt, listener); + + // run the tests + assertTrue("Expected CacheStarted notification", events.contains(Typ= e.STARTED)); + assertTrue("Expected CacheStopped notification", events.contains(Typ= e.STOPPED)); + assertTrue("Expected NodeCreated notification", events.contains(Type= .PRECREATE)); + assertTrue("Expected NodeCreated notification", events.contains(Type= .POSTCREATE)); + assertTrue("Expected NodeEvicted notification", events.contains(Type= .PREEVICT)); + assertTrue("Expected NodeEvicted notification", events.contains(Type= .POSTEVICT)); + assertTrue("Expected NodeLoaded notification", events.contains(Type.= PRELOAD)); + assertTrue("Expected NodeLoaded notification", events.contains(Type.= POSTLOAD)); + assertTrue("Expected NodeVisited notification", events.contains(Type= .PREVISIT)); + assertTrue("Expected NodeVisited notification", events.contains(Type= .POSTVISIT)); + assertTrue("Expected NodeActivated notification", events.contains(Ty= pe.PREACTIVATE)); + assertTrue("Expected NodeActivated notification", events.contains(Ty= pe.POSTACTIVATE)); + assertTrue("Expected NodeModified notification", events.contains(Typ= e.PREMODIFY)); + assertTrue("Expected NodeModified notification", events.contains(Typ= e.POSTMODIFY)); + assertTrue("Expected NodePassivated notification", events.contains(T= ype.PREPASSIVATE)); + assertTrue("Expected NodePassivated notification", events.contains(T= ype.POSTPASSIVATE)); + assertTrue("Expected NodeRemoved notification", events.contains(Type= .PREREMOVE)); + assertTrue("Expected NodeRemoved notification", events.contains(Type= .POSTREMOVE)); + assertTrue("Expected ViewChange notification", events.contains(Type.= VIEWCHANGE)); + validateHealthyListener(listener); + } + + public void testEarlyRegistration() throws Exception + { + // undo setup + cleanup(); + + CacheJmxWrapper wrapper =3D new CacheJmxWrapper(); + ObjectName mgmt =3D getWrapperObjectName(); + m_server.registerMBean(wrapper, mgmt); + MyListener listener =3D new MyListener(mgmt); + m_server.addNotificationListener(mgmt, listener, null, null); + + cache =3D createCache(CLUSTER_NAME); + wrapper.setCache(cache); + cache.start(); + try + { + assertTrue("Expected CacheStarted notification", events.contains(= Type.STARTED)); + validateHealthyListener(listener); + } + finally + { + cache.stop(); + } + } + + public void testLateRegistration() throws Exception + { + assertNotNull("MBeanServer is null.", m_server); + assertNotNull("Cache is null.", cache); + + // start the cache before registering listener + cache.start(); + + try + { + ObjectName mgmt =3D getWrapperObjectName(); + MyListener listener =3D new MyListener(mgmt); + + m_server.addNotificationListener(mgmt, listener, null, null); + + // add a node - this will trigger NodeCreated, NodeModify(pre/pos= t) and NodeModified + HashMap albania =3D new HashMap(4= ); + albania.put(CAPITAL, "Tirana"); + albania.put(CURRENCY, "Lek"); + cache.put("Europe/Albania", albania); + + // run the tests + assertTrue("Expected NodeModified notification", events.contains(= Type.PREMODIFY)); + assertTrue("Expected NodeModified notification", events.contains(= Type.POSTMODIFY)); + validateHealthyListener(listener); + } + finally + { + cache.stop(); + } + } + + public void testListenerRemoval() throws Exception + { + assertNotNull("MBeanServer is null.", m_server); + assertNotNull("Cache is null.", cache); + + ObjectName mgmt =3D getWrapperObjectName(); + MyListener listener =3D new MyListener(mgmt); + + m_server.addNotificationListener(mgmt, listener, null, null); + + // start the cache after registering listener - this will trigger Ca= cheStarted + // since cache is defined with cluster, thiswill also trigger ViewCh= ange + cache.start(); + boolean ok =3D false; + try + { + assertTrue("Expected CacheStarted notification", events.contains(= Type.STARTED)); + + m_server.removeNotificationListener(mgmt, listener); + ok =3D true; + } + finally + { + cache.stop(); + if (ok) + { + assertFalse("Expected no CacheStopped notification", events.co= ntains(Type.STOPPED)); + validateHealthyListener(listener); + } + } + } + + private CacheSPI createCache(String clusterName) throws= Exception + { + Configuration config =3D createConfiguration(clusterName); + CacheFactory factory =3D new DefaultCacheFactory(); + CacheSPI cache =3D (CacheSPI) factor= y.createCache(config, false); + + cache.create(); + // start the cache after the listener has been registered + //cache.start(); + return cache; + } + + protected Configuration createConfiguration(String clusterName) throws = Exception + { + Configuration config =3D UnitTestCacheConfigurationFactory.createCon= figuration(CacheMode.REPL_SYNC); + config.setCacheMode(Configuration.CacheMode.REPL_SYNC); + config.setCacheLoaderConfig(getCacheLoaderConfig("location=3D" + get= TempDir())); + config.setExposeManagementStatistics(true); + config.setClusterName(clusterName); + if (optimistic) + { + config.setTransactionManagerLookupClass("org.jboss.cache.transact= ion.DummyTransactionManagerLookup"); + config.setNodeLockingScheme("OPTIMISTIC"); + } + + return config; + } + + private static String getTempDir() + { + return System.getProperty("java.io.tempdir", "/tmp"); + } + + private static boolean getPre(Object data) + { + assertNotNull("User data is null, should be Object[]", data); + assertTrue("User data is " + data.getClass().getName() + ", should b= e Object[]", data instanceof Object[]); + + Object[] parms =3D (Object[]) data; + assertTrue("Parameter is " + parms[1].getClass().getName() + ", shou= ld be Boolean", parms[1] instanceof Boolean); + return (Boolean) parms[1]; + } + + protected static CacheLoaderConfig getCacheLoaderConfig(String properti= es) throws Exception + { + return UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfi= g(true, "", + "org.jboss.cache.loader.FileCacheLoader", properties, false, f= alse, true, false, false); + } + + private static void validateHealthyListener(MyListener listener) + { + if (listener.failure !=3D null) + throw listener.failure; + if (listener.exception !=3D null) + throw listener.exception; + } + + private class MyListener implements NotificationListener + { + private RuntimeException exception; + private AssertionError failure; + private final String emitterObjectName; + + MyListener(ObjectName emitter) + { + this.emitterObjectName =3D emitter.getCanonicalName(); + } + + public void handleNotification(Notification notification, Object han= dback) + { + try + { + String type =3D notification.getType(); + Object userData =3D notification.getUserData(); + + if (type.equals(CacheNotificationBroadcaster.NOTIF_CACHE_START= ED)) + { + events.add(Type.STARTED); + assertEquals("Correct object name in start notification", e= mitterObjectName, userData); + } + else if (type.equals(CacheNotificationBroadcaster.NOTIF_CACHE_= STOPPED)) + { + events.add(Type.STOPPED); + assertEquals("Correct object name in stop notification", em= itterObjectName, userData); + } + else if (type.equals(CacheNotificationBroadcaster.NOTIF_NODE_C= REATED)) + { + if (getPre(userData)) + { + events.add(Type.PRECREATE); + } + else + { + events.add(Type.POSTCREATE); + } + } + else if (type.equals(CacheNotificationBroadcaster.NOTIF_NODE_E= VICTED)) + { + if (getPre(userData)) + { + events.add(Type.PREEVICT); + } + else + { + events.add(Type.POSTEVICT); + } + } + else if (type.equals(CacheNotificationBroadcaster.NOTIF_NODE_L= OADED)) + { + if (getPre(userData)) + { + events.add(Type.PRELOAD); + } + else + { + events.add(Type.POSTLOAD); + } + } + else if (type.equals(CacheNotificationBroadcaster.NOTIF_NODE_R= EMOVED)) + { + if (getPre(userData)) + { + events.add(Type.PREREMOVE); + } + else + { + events.add(Type.POSTREMOVE); + } + } + else if (type.equals(CacheNotificationBroadcaster.NOTIF_NODE_V= ISITED)) + { + if (getPre(userData)) + { + events.add(Type.PREVISIT); + } + else + { + events.add(Type.POSTVISIT); + } + } + else if (type.equals(CacheNotificationBroadcaster.NOTIF_VIEW_C= HANGED)) + { + events.add(Type.VIEWCHANGE); + } + else if (type.equals(CacheNotificationBroadcaster.NOTIF_NODE_A= CTIVATED)) + { + if (getPre(userData)) + { + events.add(Type.PREACTIVATE); + } + else + { + events.add(Type.POSTACTIVATE); + } + } + else if (type.equals(CacheNotificationBroadcaster.NOTIF_NODE_M= ODIFIED)) + { + if (getPre(userData)) + { + events.add(Type.PREMODIFY); + } + else + { + events.add(Type.POSTMODIFY); + } + } + else if (type.equals(CacheNotificationBroadcaster.NOTIF_NODE_P= ASSIVATED)) + { + if (getPre(userData)) + { + events.add(Type.PREPASSIVATE); + } + else + { + events.add(Type.POSTPASSIVATE); + } + } + } + catch (RuntimeException e) + { + // Store so the test can rethrow + exception =3D e; + } + catch (AssertionError e) + { + // Store so the test can rethrow + failure =3D e; + } + } + } + +} Property changes on: core/trunk/src/test/java/org/jboss/cache/jmx/deprecate= d/NotificationTest.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Copied: core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/OptimisticN= otificationTest.java (from rev 6541, core/trunk/src/test/java/org/jboss/cac= he/jmx/OptimisticNotificationTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/OptimisticNotif= icationTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/OptimisticNotif= icationTest.java 2008-08-08 17:00:29 UTC (rev 6546) @@ -0,0 +1,19 @@ +/* + * JBoss, Home of Professional Open Source + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.cache.jmx.deprecated; + + +/** + * @author Manik Surtani (manik(a)jbo= ss.org) + */ +public class OptimisticNotificationTest extends NotificationTest +{ + public OptimisticNotificationTest() + { + optimistic =3D true; + } +} Property changes on: core/trunk/src/test/java/org/jboss/cache/jmx/deprecate= d/OptimisticNotificationTest.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native --===============8494735270988692197==-- From jbosscache-commits at lists.jboss.org Fri Aug 8 13:05:16 2008 Content-Type: multipart/mixed; boundary="===============6195200788244975660==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6547 - core/trunk/src/main/java/org/jboss/cache/config. Date: Fri, 08 Aug 2008 13:05:16 -0400 Message-ID: --===============6195200788244975660== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-08 13:05:16 -0400 (Fri, 08 Aug 2008) New Revision: 6547 Modified: core/trunk/src/main/java/org/jboss/cache/config/Configuration.java Log: Deprecation Modified: core/trunk/src/main/java/org/jboss/cache/config/Configuration.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2008= -08-08 17:00:29 UTC (rev 6546) +++ core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2008= -08-08 17:05:16 UTC (rev 6547) @@ -661,11 +661,20 @@ return replQueueInterval; } = + /** + * @deprecated use isExposeManagementStatistics() + */ + @Deprecated public boolean getExposeManagementStatistics() { return exposeManagementStatistics; } = + public boolean isExposeManagementStatistics() + { + return exposeManagementStatistics; + } + /** * @return true if invocation batching is enabled. * @since 3.0 --===============6195200788244975660==-- From jboss-qa-internal at redhat.com Fri Aug 8 14:21:56 2008 Content-Type: multipart/mixed; boundary="===============3386024825270365989==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23545?= Date: Fri, 08 Aug 2008 14:21:52 -0400 Message-ID: <2056866279.21511218219712984.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1160716609.20751218184357004.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============3386024825270365989== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/545/changes --===============3386024825270365989==-- From jboss-qa-internal at redhat.com Fri Aug 8 14:23:51 2008 Content-Type: multipart/mixed; boundary="===============2585118285598141262==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23412?= Date: Fri, 08 Aug 2008 14:23:48 -0400 Message-ID: <623292485.21521218219828404.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 7968837.20731218182774379.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============2585118285598141262== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/412/changes --===============2585118285598141262==-- From jbosscache-commits at lists.jboss.org Fri Aug 8 14:43:15 2008 Content-Type: multipart/mixed; boundary="===============7815388273283657668==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6548 - core/trunk/src/main/java/org/jboss/cache/util. Date: Fri, 08 Aug 2008 14:43:15 -0400 Message-ID: --===============7815388273283657668== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: jason.greene(a)jboss.com Date: 2008-08-08 14:43:15 -0400 (Fri, 08 Aug 2008) New Revision: 6548 Modified: core/trunk/src/main/java/org/jboss/cache/util/Immutables.java Log: Fix type-o Add fast-path for known collection types Modified: core/trunk/src/main/java/org/jboss/cache/util/Immutables.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/util/Immutables.java 2008-08-0= 8 17:05:16 UTC (rev 6547) +++ core/trunk/src/main/java/org/jboss/cache/util/Immutables.java 2008-08-0= 8 18:43:15 UTC (rev 6548) @@ -28,9 +28,13 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; import java.util.Map.Entry; = /** @@ -127,11 +131,12 @@ */ public static Set immutableSetCopy(Set set) { - Set copy =3D attemptClone(set); + Set copy =3D attemptKnownSetCopy(set); if (copy =3D=3D null) + attemptClone(set); + if (copy =3D=3D null) // Set uses Collection copy-ctor copy =3D attemptCopyConstructor(set, Collection.class); - if (copy =3D=3D null) copy =3D new HashSet(set); = @@ -158,13 +163,16 @@ */ public static Map immutableMapCopy(Map map) { - Map copy =3D attemptClone(map); + Map copy =3D attemptKnownMapCopy(map); + if (copy =3D=3D null) + attemptClone(map); + if (copy =3D=3D null) copy =3D attemptCopyConstructor(map, Map.class); if (copy =3D=3D null) copy =3D new HashMap(map); = - return new ImmutableMapWrapper(map); + return new ImmutableMapWrapper(copy); } = /** @@ -175,17 +183,46 @@ */ public static Collection immutableCollectionCopy(Collection collection) { - Collection copy =3D attemptClone(collection); + Collection copy =3D attemptKnownSetCopy(collection); if (copy =3D=3D null) + copy =3D attemptClone(collection); + if (copy =3D=3D null) copy =3D attemptCopyConstructor(collection, Collection.class); if (copy =3D=3D null) copy =3D new ArrayList(collection); = - return new ImmutableCollectionWrapper(collection); + return new ImmutableCollectionWrapper(copy); } = + @SuppressWarnings("unchecked") + private static T attemptKnownMapCopy(T map) + { + if (map instanceof FastCopyHashMap) + return (T)((FastCopyHashMap) map).clone(); + if (map instanceof HashMap) + return (T)((HashMap) map).clone(); + if (map instanceof LinkedHashMap) + return (T)((LinkedHashMap) map).clone(); + if (map instanceof TreeMap) + return (T)((TreeMap) map).clone(); = + return null; + } + @SuppressWarnings("unchecked") + private static T attemptKnownSetCopy(T set) + { + if (set instanceof HashSet) + return (T)((HashSet) set).clone(); + if (set instanceof LinkedHashSet) + return (T)((LinkedHashSet) set).clone(); + if (set instanceof TreeSet) + return (T)((TreeSet) set).clone(); + + return null; + } + + @SuppressWarnings("unchecked") private static T attemptClone(T source) { if (source instanceof Cloneable) @@ -537,5 +574,10 @@ { return new ImmutableCollectionWrapper(map.values()); } + + public String toString() + { + return map.toString(); + } } } --===============7815388273283657668==-- From jbosscache-commits at lists.jboss.org Fri Aug 8 15:04:05 2008 Content-Type: multipart/mixed; boundary="===============0465267270244757291==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6549 - core/trunk/src/test/java/org/jboss/cache. Date: Fri, 08 Aug 2008 15:04:05 -0400 Message-ID: --===============0465267270244757291== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: dpospisi(a)redhat.com Date: 2008-08-08 15:04:05 -0400 (Fri, 08 Aug 2008) New Revision: 6549 Added: core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java Log: Added UnitTestCacheFactory. Added: core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java = (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java 2008= -08-08 19:04:05 UTC (rev 6549) @@ -0,0 +1,192 @@ +/* + * JBoss, Home of Professional Open Source + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.cache; + +import java.io.InputStream; +import java.util.Vector; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.ConfigurationException; +import org.jboss.cache.config.OldFileFormatException; +import org.jboss.cache.config.parsing.XmlConfigurationParser; +import org.jboss.cache.config.parsing.XmlConfigurationParser2x; +import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; +import org.jboss.cache.util.TestingUtil; + +/** + * + * @author Dominik Pospisil (dpos= pisi(a)redhat.com) + */ +public class UnitTestCacheFactory implements CacheFactory +{ + + private final Log log =3D LogFactory.getLog(UnitTestCacheFactory.class); + + = + /** + * Holds unique mcast_addr for each thread used for JGroups channel co= nstruction. + */ + private static final ThreadLocal threadMcastIP =3D new ThreadLo= cal() { = + + private final AtomicInteger uniqueAddr =3D new AtomicInteger(10); = = + @Override protected String initialValue() { + return "228.10.10." + String.valueOf(uniqueAddr.getAndIncrement()= ); + } = + }; + + /** + * Holds unique mcast_port for each thread used for JGroups channel co= nstruction. + */ + private static final ThreadLocal threadMcastPort =3D new Threa= dLocal() { = + = + private final AtomicInteger uniquePort =3D new AtomicInteger(45588); + = + @Override protected Integer initialValue() { + return uniquePort.getAndIncrement(); + } = + }; + = + /** + * For each thread holds list of caches created using this factory. + */ + private static final ThreadLocal> threadCaches =3D + new ThreadLocal>() { = + = + = + @Override protected Vector initialValue() { + return new Vector(); + } = + }; = + = + // factory methods + = + public Cache createCache() throws ConfigurationException { + return createCache(true); + } + + public Cache createCache(boolean start) throws ConfigurationExcep= tion { + return createCache(new Configuration(), start); + } + + public Cache createCache(String configFileName) throws Configurat= ionException { + return createCache(configFileName, true); + } + + public Cache createCache(String configFileName, boolean start) th= rows ConfigurationException { + XmlConfigurationParser parser =3D new XmlConfigurationParser(); + Configuration c; + try + { + c =3D parser.parseFile(configFileName); + } + catch (OldFileFormatException e) + { + System.out.println("Detected legacy configuration file format whe= n parsing [" + configFileName + "]. Migrating to the new (3.x) file format= is recommended. See FAQs for details."); + XmlConfigurationParser2x oldParser =3D new XmlConfigurationParser= 2x(); + c =3D oldParser.parseFile(configFileName); + } + return createCache(c, start); + } + + public Cache createCache(Configuration configuration) throws Conf= igurationException { + return createCache(configuration, true); + } + + public Cache createCache(InputStream is) throws ConfigurationExce= ption { + return createCache(is, true); + } + + public Cache createCache(InputStream is, boolean start) throws Co= nfigurationException { + XmlConfigurationParser parser =3D new XmlConfigurationParser(); + Configuration c =3D parser.parseStream(is); + return createCache(c, start); + } + = + public Cache createCache(Configuration configuration, boolean sta= rt) throws ConfigurationException { + = + switch (configuration.getCacheMode()) + { + case LOCAL: + // local cache, no channel used + break; + case REPL_SYNC: + case REPL_ASYNC: + case INVALIDATION_ASYNC: + case INVALIDATION_SYNC: + // replicated cache, update channel setup + mangleConfiguration(configuration); + break; + default: + log.info("Unknown cache mode!"); + } + = + Cache cache =3D new DefaultCacheFactory().createCache(c= onfiguration, start); = + + Vector caches =3D threadCaches.get(); + caches.add(cache); + = + return cache; + = + } + = + /** + * Destroys all caches created by this factory in the current thread. + */ + public void cleanUp() { + Vector caches =3D threadCaches.get(); + for (Cache cache : caches) { + TestingUtil.killCaches(cache); = + } + caches.setSize(0); + } + = + /** + * Updates cluster configuration to ensure mutual thread isolation. + * @param configuration Configuration to update. + */ + private void mangleConfiguration(Configuration configuration) { + String clusterConfig =3D configuration.getClusterConfig(); + = + if (clusterConfig =3D=3D null) { + // No explicit cluster configuration found. we need to resolve th= e default config + // now in orded to be able to update it before the cache (and the= channel) starts. = + + // TODO: this does not seems to be the best solution :( + clusterConfig =3D UnitTestCacheConfigurationFactory.getClusterCon= figFromFile( + configuration.getDefaultClusterConfig()); + = + } + = + // replace mcast_addr + Pattern pattern =3D Pattern.compile("mcast_addr=3D[^;]*"); + Matcher m =3D pattern.matcher(clusterConfig); + if (m.find()) { + String origAddr =3D m.group().substring(m.group().indexOf("=3D") = + 1); + String newAddr =3D threadMcastIP.get(); + System.out.println("Replacing mcast_addr " + origAddr + " with " = + newAddr); + clusterConfig =3D m.replaceFirst("mcast_addr=3D" + newAddr); + } + = + // replace mcast_port + pattern =3D Pattern.compile("mcast_port=3D[^;]*"); + m =3D pattern.matcher(clusterConfig); + if (m.find()) { + String origPort =3D m.group().substring(m.group().indexOf("=3D") = + 1); + String newPort =3D threadMcastPort.get().toString(); + System.out.println("Replacing mcast_port " + origPort + " with " = + newPort); + clusterConfig =3D m.replaceFirst("mcast_port=3D" + newPort); + } + = + configuration.setClusterConfig(clusterConfig); = + = + } + +} --===============0465267270244757291==-- From jbosscache-commits at lists.jboss.org Fri Aug 8 15:29:53 2008 Content-Type: multipart/mixed; boundary="===============8603327289138957063==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6550 - in core/trunk/src: main/java/org/jboss/cache/jmx and 1 other directories. Date: Fri, 08 Aug 2008 15:29:53 -0400 Message-ID: --===============8603327289138957063== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-08 15:29:53 -0400 (Fri, 08 Aug 2008) New Revision: 6550 Added: core/trunk/src/main/java/org/jboss/cache/jmx/PlatformMBeanServerRegistra= tion.java core/trunk/src/test/java/org/jboss/cache/jmx/JmxRegistrationManagerTest.= java Modified: core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java core/trunk/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.java Log: added regitration to the platform mbean server Modified: core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-= 08-08 19:04:05 UTC (rev 6549) +++ core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-= 08-08 19:29:53 UTC (rev 6550) @@ -14,6 +14,7 @@ import org.jboss.cache.factories.ComponentFactory; import org.jboss.cache.factories.ComponentRegistry; import org.jboss.cache.invocation.CacheInvocationDelegate; +import org.jboss.cache.jmx.PlatformMBeanServerRegistration; = import java.io.InputStream; = @@ -123,6 +124,7 @@ this.configuration =3D configuration; = componentRegistry.registerComponent(spi, CacheSPI.class); + componentRegistry.registerComponent(new PlatformMBeanServerRegistrat= ion(), PlatformMBeanServerRegistration.class); } = /** Modified: core/trunk/src/main/java/org/jboss/cache/jmx/JmxRegistrationManag= er.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.jav= a 2008-08-08 19:04:05 UTC (rev 6549) +++ core/trunk/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.jav= a 2008-08-08 19:29:53 UTC (rev 6550) @@ -40,7 +40,6 @@ */ public class JmxRegistrationManager { - private static final Log log =3D LogFactory.getLog(JmxRegistrationManag= er.class); = /** Added: core/trunk/src/main/java/org/jboss/cache/jmx/PlatformMBeanServerRegi= stration.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/jmx/PlatformMBeanServerRegistr= ation.java (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/jmx/PlatformMBeanServerRegistr= ation.java 2008-08-08 19:29:53 UTC (rev 6550) @@ -0,0 +1,89 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2008, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.cache.jmx; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.cache.CacheSPI; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.factories.annotations.Inject; +import org.jboss.cache.factories.annotations.Start; +import org.jboss.cache.factories.annotations.Stop; +import org.jboss.cache.factories.annotations.NonVolatile; + +/** + * If {@link org.jboss.cache.config.Configuration#getExposeManagementStati= stics()} is true, then class will register + * all the MBeans from the ConfigurationRegistry to the pltform MBean serv= er. + *

    + * Note: to enable platform MBeanServer the following system property shou= ld be passet to the JVM: + * -Dcom.sun.management.jmxremote. + * + * @author Mircea.Markus(a)jboss.com + * @see java.lang.management.ManagementFactory#getPlatformMBeanServer() + * @since 3.0 + */ +(a)NonVolatile +public class PlatformMBeanServerRegistration +{ + private static final Log log =3D LogFactory.getLog(PlatformMBeanServerR= egistration.class); + + private CacheSPI cache; + + @Inject + public void initialize(CacheSPI cache) + { + this.cache =3D cache; + } + + /** + * Here is where the registration is being performed. + */ + @Start(priority =3D 14) + public void registerToPlatformMBeanServer() + { + if (cache =3D=3D null) + throw new IllegalStateException("The cache should had been inject= ed before a call to this method"); + Configuration config =3D cache.getConfiguration(); + if (config.getExposeManagementStatistics()) + { + JmxRegistrationManager jmxRegistrationManager =3D new JmxRegistra= tionManager(cache); + jmxRegistrationManager.registerAllMBeans(); + log.info("JBossCache MBeans were successfully registered to the p= latform mbean server."); + } + } + + /** + * Unregister when the cache is being stoped. + */ + @Stop + public void unregisterMBeans() + { + Configuration config =3D cache.getConfiguration(); + if (config.getExposeManagementStatistics()) + { + JmxRegistrationManager jmxRegistrationManager =3D new JmxRegistra= tionManager(cache); + jmxRegistrationManager.unregisterAllMBeans(); + log.trace("JBossCache MBeans were successfully unregistered from = the platform mbean server."); + } + cache =3D null; + } +} Added: core/trunk/src/test/java/org/jboss/cache/jmx/JmxRegistrationManagerT= est.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/jmx/JmxRegistrationManagerTest= .java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/jmx/JmxRegistrationManagerTest= .java 2008-08-08 19:29:53 UTC (rev 6550) @@ -0,0 +1,30 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2008, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.cache.jmx; + +/** + * @author Mircea.Markus(a)jboss.com + * @since 3.0 + */ +public class JmxRegistrationManagerTest +{ +} --===============8603327289138957063==-- From jbosscache-commits at lists.jboss.org Fri Aug 8 23:21:50 2008 Content-Type: multipart/mixed; boundary="===============8985578404933446953==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6551 - pojo/trunk/src/main/java/org/jboss/cache/pojo/impl. Date: Fri, 08 Aug 2008 23:21:50 -0400 Message-ID: --===============8985578404933446953== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: jason.greene(a)jboss.com Date: 2008-08-08 23:21:50 -0400 (Fri, 08 Aug 2008) New Revision: 6551 Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/NotificationDispatche= r.java pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ObjectGraphHandler.ja= va pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDelegate.java pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoInstance.java Log: Fix synchronization issues in reference changes Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/NotificationDi= spatcher.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/NotificationDispatch= er.java 2008-08-08 19:29:53 UTC (rev 6550) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/NotificationDispatch= er.java 2008-08-09 03:21:50 UTC (rev 6551) @@ -121,7 +121,7 @@ return ((Entry)o).listener =3D=3D this.listener; } = - private static Map, List> buildNotifiers(Class claz= z) + private static Map, List> buildNotifiers(Class c= lazz) { if (! Modifier.isPublic(clazz.getModifiers())) throw new IllegalArgumentException("Listener must be public! C= lass:" + clazz.getName()); Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ObjectGraphHan= dler.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ObjectGraphHandler.j= ava 2008-08-08 19:29:53 UTC (rev 6550) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ObjectGraphHandler.j= ava 2008-08-09 03:21:50 UTC (rev 6551) @@ -99,15 +99,11 @@ */ private void removeFromReference(Fqn originalFqn, Reference referenc= e) throws CacheException { - synchronized (originalFqn) - { // we lock the internal fqn here so no one else has access. - // Decrement ref counting on the internal node - if (decrementRefCount(originalFqn, reference) =3D=3D PojoInstance= .INITIAL_COUNTER_VALUE) - { - // No one is referring it so it is safe to remove - // TODO we should make sure the parent nodes are also removed = they are empty as well. - cache.detach(originalFqn); - } + if (decrementRefCount(originalFqn, reference) =3D=3D PojoInstance.IN= ITIAL_COUNTER_VALUE) + { + // No one is referring it so it is safe to remove + // TODO we should make sure the parent nodes are also removed the= y are empty as well. + cache.detach(originalFqn); } } = @@ -120,11 +116,8 @@ */ private void setupRefCounting(Fqn fqn, Reference reference) throws C= acheException { - synchronized (fqn) - { - // increment the reference counting - incrementRefCount(fqn, reference); - } + // increment the reference counting + incrementRefCount(fqn, reference); } = private int incrementRefCount(Fqn originalFqn, Reference reference) = throws CacheException Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDeleg= ate.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDelegate.ja= va 2008-08-08 19:29:53 UTC (rev 6550) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDelegate.ja= va 2008-08-09 03:21:50 UTC (rev 6551) @@ -125,6 +125,8 @@ Reference reference =3D new ReferenceImpl(fqn, field); if (internalFqn !=3D null) { + // Lock the internal fqn, before the ref count is checked + internal_.lockPojo(internalFqn); graphHandler_.put(internalFqn, reference , obj); } else @@ -232,6 +234,8 @@ = Fqn internalFqn =3D pojoReference.getFqn(); = + + if (log.isDebugEnabled()) { log.debug("removeObject(): removing object from id: " + fqn @@ -242,6 +246,9 @@ if (result =3D=3D null) return null; = + // Lock the internal fqn, before the ref count is checked + internal_.lockPojo(internalFqn); + Reference reference =3D new ReferenceImpl(fqn, field); if (graphHandler_.isMultipleReferenced(internalFqn)) { Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoInstance.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoInstance.java 20= 08-08-08 19:29:53 UTC (rev 6550) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoInstance.java 20= 08-08-09 03:21:50 UTC (rev 6551) @@ -6,12 +6,14 @@ */ package org.jboss.cache.pojo.impl; = -import org.jboss.cache.Fqn; +import java.io.Serializable; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + import org.jboss.cache.pojo.Reference; = -import java.io.Serializable; -import java.util.*; - /** * POJO class metadata information. * When an object is looked up or put in PojoCache, this object will be ad= vised with a CacheFieldInterceptor. @@ -39,7 +41,7 @@ private int refCount_ =3D INITIAL_COUNTER_VALUE; = // List of fqns that reference this fqn. - private Set referencedBy_ =3D new HashSet(4); + private final Set referencedBy_ =3D new HashSet(4= ); private Class clazz_ =3D null; private transient PojoUtil util_ =3D new PojoUtil(); = @@ -105,9 +107,9 @@ return refCount_; } = - public Collection getReferences() + public synchronized Collection getReferences() { - return Collections.unmodifiableCollection(referencedBy_); + return Collections.unmodifiableCollection(new HashSet(ref= erencedBy_)); } = public String toString() --===============8985578404933446953==-- From jboss-qa-internal at redhat.com Sat Aug 9 02:31:36 2008 Content-Type: multipart/mixed; boundary="===============6834298403993765558==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23546?= Date: Sat, 09 Aug 2008 02:31:34 -0400 Message-ID: <1141939475.22051218263494291.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 2056866279.21511218219712984.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============6834298403993765558== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/546/changes --===============6834298403993765558==-- From jboss-qa-internal at redhat.com Sat Aug 9 02:43:53 2008 Content-Type: multipart/mixed; boundary="===============0477440267422932217==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23413?= Date: Sat, 09 Aug 2008 02:43:51 -0400 Message-ID: <1596345468.22071218264231346.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 623292485.21521218219828404.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============0477440267422932217== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/413/changes --===============0477440267422932217==-- From jboss-qa-internal at redhat.com Sun Aug 10 10:16:37 2008 Content-Type: multipart/mixed; boundary="===============3642086402602760417==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Build_failed_in_Hudson=3A_jboss-cache-?= =?utf-8?q?core-2=2E1=2EX-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_=2343?= Date: Sun, 10 Aug 2008 10:16:35 -0400 Message-ID: <318779885.22931218377795194.JavaMail.hudson@hudson1.qa.atl2.redhat.com> --===============3642086402602760417== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-2.1.X-jdk1.6/org= .jboss.cache$jbosscache-core/43/changes ------------------------------------------ started Building remotely on conf2-linux $ /qa/tools/opt/jdk1.6.0_03/bin/java -Xmx512m -cp /home/hudson/hudson_works= pace/maven-agent.jar:/qa/tools/opt/maven-2.0.9/boot/classworlds-1.1.jar hud= son.maven.agent.Main /qa/tools/opt/maven-2.0.9 /qa/services/hudson/hudson_r= elease/WEB-INF/slave.jar /home/hudson/hudson_workspace/maven-interceptor.jar channel started [INFO] Scanning for projects... WAGON_VERSION: 1.0-beta-2 [INFO] --------------------------------------------------------------------= ---- [INFO] Building JBoss Cache - Core Edition [INFO] task-segment: [clean, site] [INFO] --------------------------------------------------------------------= ---- [HUDSON] Archiving /home/hudson/hudson_workspace/workspace/jboss-cache-core= -2.1.X-jdk1.6/./pom.xml [INFO] --------------------------------------------------------------------= ---- [ERROR] BUILD ERROR [INFO] --------------------------------------------------------------------= ---- [INFO] The plugin 'org.apache.maven.plugins:maven-eclipse-plugin' does not = exist or no valid version could be found [INFO] --------------------------------------------------------------------= ---- [INFO] For more information, run Maven with the -e switch [INFO] --------------------------------------------------------------------= ---- [INFO] Total time: 27 seconds [INFO] Finished at: Sun Aug 10 10:14:50 EDT 2008 [INFO] Final Memory: 9M/63M [INFO] --------------------------------------------------------------------= ---- Waiting for Hudson to finish collecting data --===============3642086402602760417==-- From jboss-qa-internal at redhat.com Sun Aug 10 12:30:37 2008 Content-Type: multipart/mixed; boundary="===============7949720619356617571==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23547?= Date: Sun, 10 Aug 2008 12:30:35 -0400 Message-ID: <1023763603.23291218385835291.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1141939475.22051218263494291.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============7949720619356617571== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/547/changes --===============7949720619356617571==-- From jboss-qa-internal at redhat.com Sun Aug 10 12:34:24 2008 Content-Type: multipart/mixed; boundary="===============1654834218927744844==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23414?= Date: Sun, 10 Aug 2008 12:34:18 -0400 Message-ID: <1480638361.23301218386058379.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1596345468.22071218264231346.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============1654834218927744844== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/414/changes --===============1654834218927744844==-- From jboss-qa-internal at redhat.com Sun Aug 10 13:04:45 2008 Content-Type: multipart/mixed; boundary="===============2386253604288380329==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_completed=3A_jboss-cache-?= =?utf-8?q?core-2=2E1=2EX-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_=2344?= Date: Sun, 10 Aug 2008 13:04:43 -0400 Message-ID: <2005101344.23321218387883186.JavaMail.hudson@hudson1.qa.atl2.redhat.com> --===============2386253604288380329== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-2.1.X-jdk1.5/org= .jboss.cache$jbosscache-core/44/changes --===============2386253604288380329==-- From jbosscache-commits at lists.jboss.org Mon Aug 11 05:58:40 2008 Content-Type: multipart/mixed; boundary="===============8331867764006986652==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6552 - in core/trunk/src: test/java/org/jboss/cache/jmx and 1 other directories. Date: Mon, 11 Aug 2008 05:58:39 -0400 Message-ID: --===============8331867764006986652== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-11 05:58:39 -0400 (Mon, 11 Aug 2008) New Revision: 6552 Modified: core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java core/trunk/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.java core/trunk/src/test/java/org/jboss/cache/jmx/JmxRegistrationManagerTest.= java core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapperT= est.java core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapperT= estBase.java core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/NotificationTest= .java Log: added UT and javadocs Modified: core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2008-= 08-09 03:21:50 UTC (rev 6551) +++ core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2008-= 08-11 09:58:39 UTC (rev 6552) @@ -815,7 +815,7 @@ } else { - cacheObjectName =3D JmxRegistrationManager.CLUSTERED_CACHE_PRE= FIX + config.getClusterName(); + cacheObjectName =3D JmxRegistrationManager.REPLICATED_CACHE_PR= EFIX + config.getClusterName(); } } return cacheObjectName; Modified: core/trunk/src/main/java/org/jboss/cache/jmx/JmxRegistrationManag= er.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.jav= a 2008-08-09 03:21:50 UTC (rev 6551) +++ core/trunk/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.jav= a 2008-08-11 09:58:39 UTC (rev 6552) @@ -21,20 +21,30 @@ */ package org.jboss.cache.jmx; = +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.jboss.cache.Cache; +import org.jboss.cache.CacheException; import org.jboss.cache.CacheSPI; -import org.jboss.cache.CacheException; import org.jboss.cache.config.Configuration; import org.jboss.cache.factories.ComponentRegistry; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; = -import javax.management.*; +import javax.management.MBeanServer; +import javax.management.MalformedObjectNameException; +import javax.management.ObjectName; import java.lang.management.ManagementFactory; +import java.util.ArrayList; import java.util.List; -import java.util.ArrayList; = /** + * Registers all the MBeans from an Cache instance to a M= BeanServer. + * It iterates over all the components within ComponentRegistry and= registers all the components + * annotated with ManagedAttribute, ManagedOperation or/and = MBean. + * If no MBean server is provided, then the {@link java.lang.manage= ment.ManagementFactory#getPlatformMBeanServer()} + * is being used. + *

    + * It is immutable: both cache instance and MBeanServer are being passed a= s arguments to the constructor. + * * @author Mircea.Markus(a)jboss.com * @since 3.0 */ @@ -45,7 +55,7 @@ /** * default ObjectName for clusterd caches. Cluster name should pe appen= ded. */ - public static final String CLUSTERED_CACHE_PREFIX =3D "jboss.cache:serv= ice=3DJBossCache,cluster=3D"; + public static final String REPLICATED_CACHE_PREFIX =3D "jboss.cache:ser= vice=3DJBossCache,cluster=3D"; = /** * default ObjectName for non clustered caches. An unique identifier sh= ould be appended. @@ -63,6 +73,13 @@ = private CacheSPI cacheSpi; = + /** + * C-tor. + * + * @param mBeanServer the server where mbeans are being registered + * @param cache cache that needs to be monitored + * @param objectNameBase path in the MBeanServer where to register cach= e MBeans + */ public JmxRegistrationManager(MBeanServer mBeanServer, Cache cache, Obj= ectName objectNameBase) { this.mBeanServer =3D mBeanServer; @@ -71,10 +88,8 @@ } = /** - * @param mBeanServer - * @param cache - * @param objectNameBase * @throws IllegalArgumentException if the supplied objectNameBase name= isn't valid + * @see #JmxRegistrationManager(javax.management.MBeanServer, org.jboss= .cache.Cache, javax.management.ObjectName) */ public JmxRegistrationManager(MBeanServer mBeanServer, Cache cache, Str= ing objectNameBase) { @@ -105,6 +120,9 @@ this(cache, null); } = + /** + * Performs the MBean registration. + */ public void registerAllMBeans() throws CacheException { try @@ -125,6 +143,9 @@ } } = + /** + * Unregisters all the MBeans registered through {@link #registerAllMBe= ans()}. + */ public void unregisterAllMBeans() throws CacheException { log.trace("Unregistering jmx resources.."); @@ -174,11 +195,11 @@ } else //the cache is clustered { - objectNameBase =3D CLUSTERED_CACHE_PREFIX + cacheSpi.getConfigura= tion().getClusterName(); + objectNameBase =3D REPLICATED_CACHE_PREFIX + cacheSpi.getConfigur= ation().getClusterName(); } } = - private String getObjectName(String resourceName) + public String getObjectName(String resourceName) { return objectNameBase + JMX_RESOURCE_KEY + resourceName; } Modified: core/trunk/src/test/java/org/jboss/cache/jmx/JmxRegistrationManag= erTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/jmx/JmxRegistrationManagerTest= .java 2008-08-09 03:21:50 UTC (rev 6551) +++ core/trunk/src/test/java/org/jboss/cache/jmx/JmxRegistrationManagerTest= .java 2008-08-11 09:58:39 UTC (rev 6552) @@ -21,10 +21,81 @@ */ package org.jboss.cache.jmx; = +import org.testng.annotations.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.AfterMethod; +import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.Cache; +import org.jboss.cache.CacheFactory; +import org.jboss.cache.interceptors.CacheMgmtInterceptor; + +import javax.management.MBeanServer; +import javax.management.MBeanServerFactory; +import javax.management.ObjectName; + /** + * Tester class for {@link JmxRegistrationManager}. + * * @author Mircea.Markus(a)jboss.com * @since 3.0 */ +(a)Test (groups =3D "functional") public class JmxRegistrationManagerTest { + private DefaultCacheFactory cacheFactory =3D new DefaultCacheFactory(); + private MBeanServer mBeanServer; + + @BeforeMethod + public void setUp() + { + mBeanServer =3D MBeanServerFactory.createMBeanServer(); + } + + @AfterMethod + public void tearDown() + { + MBeanServerFactory.releaseMBeanServer(mBeanServer); + } + + public void testRegisterLocalCache() throws Exception + { + Configuration localConfig =3D UnitTestCacheConfigurationFactory.crea= teConfiguration(Configuration.CacheMode.LOCAL); + localConfig.setExposeManagementStatistics(true); + Cache cache =3D cacheFactory.createCache(localConfig); + JmxRegistrationManager regManager =3D new JmxRegistrationManager(mBe= anServer, cache, (ObjectName)null); + assert regManager.getObjectNameBase().indexOf(JmxRegistrationManager= .LOCAL_CACHE_PREFIX) =3D=3D 0; + regManager.registerAllMBeans(); + String name =3D regManager.getObjectName(CacheMgmtInterceptor.class.= getSimpleName()); + assert mBeanServer.isRegistered(new ObjectName(name)); + regManager.unregisterAllMBeans(); + assert !mBeanServer.isRegistered(new ObjectName(name)); + cache.stop(); + } + + public void testRegisterReplicatedCache() throws Exception + { + Configuration localConfig =3D UnitTestCacheConfigurationFactory.crea= teConfiguration(Configuration.CacheMode.REPL_SYNC); + localConfig.setExposeManagementStatistics(true); + Cache cache =3D cacheFactory.createCache(localConfig); + JmxRegistrationManager regManager =3D new JmxRegistrationManager(mBe= anServer, cache, (ObjectName)null); + assert regManager.getObjectNameBase().indexOf(JmxRegistrationManager= .REPLICATED_CACHE_PREFIX) =3D=3D 0; + regManager.registerAllMBeans(); + String name =3D regManager.getObjectName(CacheMgmtInterceptor.class.= getSimpleName()); + assert mBeanServer.isRegistered(new ObjectName(name)); + regManager.unregisterAllMBeans(); + assert !mBeanServer.isRegistered(new ObjectName(name)); + cache.stop(); + } + + public static void main(String[] args) + { + Configuration localConfig =3D UnitTestCacheConfigurationFactory.crea= teConfiguration(Configuration.CacheMode.REPL_SYNC); + localConfig.setExposeManagementStatistics(true); + CacheFactory cacheFactory =3D new DefaultCacheFactory(); + Cache cache =3D cacheFactory.createCache(localConfig); + JmxRegistrationManager regManager =3D new JmxRegistrationManager(cac= he); + while (true){} + } } Modified: core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxW= rapperTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapper= Test.java 2008-08-09 03:21:50 UTC (rev 6551) +++ core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapper= Test.java 2008-08-11 09:58:39 UTC (rev 6552) @@ -85,7 +85,7 @@ = // Go back to the default wrapper.setCacheObjectName(null); - assertEquals("Got default ObjectName", JmxRegistrationManager.CLUSTE= RED_CACHE_PREFIX + CLUSTER_NAME, wrapper.getCacheObjectName()); + assertEquals("Got default ObjectName", JmxRegistrationManager.REPLIC= ATED_CACHE_PREFIX + CLUSTER_NAME, wrapper.getCacheObjectName()); = registerWrapper(wrapper); assertEquals("Returns standard name", mBeanName, new ObjectName(wrap= per.getCacheObjectName())); Modified: core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxW= rapperTestBase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapper= TestBase.java 2008-08-09 03:21:50 UTC (rev 6551) +++ core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapper= TestBase.java 2008-08-11 09:58:39 UTC (rev 6552) @@ -41,7 +41,7 @@ { mBeanServer =3D MBeanServerFactory.createMBeanServer("CacheMBeanTest= "); = - mBeanNameStr =3D JmxRegistrationManager.CLUSTERED_CACHE_PREFIX + CLU= STER_NAME; + mBeanNameStr =3D JmxRegistrationManager.REPLICATED_CACHE_PREFIX + CL= USTER_NAME; mBeanName =3D new ObjectName(mBeanNameStr); } = Modified: core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/Notificat= ionTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/NotificationTes= t.java 2008-08-09 03:21:50 UTC (rev 6551) +++ core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/NotificationTes= t.java 2008-08-11 09:58:39 UTC (rev 6552) @@ -116,7 +116,7 @@ = protected ObjectName getWrapperObjectName() throws Exception { - return new ObjectName(JmxRegistrationManager.CLUSTERED_CACHE_PREFIX = + CLUSTER_NAME); + return new ObjectName(JmxRegistrationManager.REPLICATED_CACHE_PREFIX= + CLUSTER_NAME); } = public void testNotifications() throws Exception --===============8331867764006986652==-- From jbosscache-commits at lists.jboss.org Mon Aug 11 07:59:15 2008 Content-Type: multipart/mixed; boundary="===============1707935402001417964==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6553 - in searchable/trunk/src/test/java/org/jboss/cache/search: blackbox and 1 other directories. Date: Mon, 11 Aug 2008 07:59:14 -0400 Message-ID: --===============1707935402001417964== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: navssurtani Date: 2008-08-11 07:59:14 -0400 (Mon, 11 Aug 2008) New Revision: 6553 Added: searchable/trunk/src/test/java/org/jboss/cache/search/LazyQueryResultIte= ratorTest.java Modified: searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCach= eTest.java searchable/trunk/src/test/java/org/jboss/cache/search/test/Person.java Log: Got rid of unused import statements Added: searchable/trunk/src/test/java/org/jboss/cache/search/LazyQueryResul= tIteratorTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/test/java/org/jboss/cache/search/LazyQueryResultIt= eratorTest.java (rev 0) +++ searchable/trunk/src/test/java/org/jboss/cache/search/LazyQueryResultIt= eratorTest.java 2008-08-11 11:59:14 UTC (rev 6553) @@ -0,0 +1,13 @@ +package org.jboss.cache.search; + +import org.testng.annotations.Test; + +/** + * @author Navin Surtani (nsurtan= i(a)redhat.com) + */ +(a)Test(groups=3D"functional") +public class LazyQueryResultIteratorTest +{ + //Need to use mock-objects for this test. + = +} Modified: searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/Lo= calCacheTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCac= heTest.java 2008-08-11 09:58:39 UTC (rev 6552) +++ searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCac= heTest.java 2008-08-11 11:59:14 UTC (rev 6553) @@ -5,8 +5,6 @@ import org.apache.lucene.queryParser.QueryParser; import org.apache.lucene.search.*; import org.apache.lucene.index.Term; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.jboss.cache.Cache; import org.jboss.cache.DefaultCacheFactory; import org.jboss.cache.Fqn; Modified: searchable/trunk/src/test/java/org/jboss/cache/search/test/Person= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/test/java/org/jboss/cache/search/test/Person.java = 2008-08-11 09:58:39 UTC (rev 6552) +++ searchable/trunk/src/test/java/org/jboss/cache/search/test/Person.java = 2008-08-11 11:59:14 UTC (rev 6553) @@ -4,7 +4,6 @@ import org.hibernate.search.annotations.*; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.jboss.cache.pojo.annotation.Replicable; = import java.io.Serializable; = --===============1707935402001417964==-- From jboss-qa-internal at redhat.com Mon Aug 11 14:29:24 2008 Content-Type: multipart/mixed; boundary="===============7585626004001505069==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23548?= Date: Mon, 11 Aug 2008 14:29:19 -0400 Message-ID: <30697197.601218479359006.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1023763603.23291218385835291.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============7585626004001505069== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/548/changes --===============7585626004001505069==-- From jboss-qa-internal at redhat.com Mon Aug 11 14:57:05 2008 Content-Type: multipart/mixed; boundary="===============6061118794238550825==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23415?= Date: Mon, 11 Aug 2008 14:56:36 -0400 Message-ID: <1465896475.631218480996008.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1480638361.23301218386058379.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============6061118794238550825== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/415/changes --===============6061118794238550825==-- From jbosscache-commits at lists.jboss.org Tue Aug 12 00:16:03 2008 Content-Type: multipart/mixed; boundary="===============4591295585551508619==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6554 - in pojo/tags: 2.2.0.CR7 and 5 other directories. Date: Tue, 12 Aug 2008 00:16:03 -0400 Message-ID: --===============4591295585551508619== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: jason.greene(a)jboss.com Date: 2008-08-12 00:16:02 -0400 (Tue, 12 Aug 2008) New Revision: 6554 Added: pojo/tags/2.2.0.CR7/ pojo/tags/2.2.0.CR7/pom.xml pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/PojoCache.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/Reference.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/AbstractHand= ler.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojoH= andler.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/ArrayHandler= .java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/CollectionCl= assHandler.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/InternalHelp= er.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/MethodDeclar= ations.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Notification= Dispatcher.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/ObjectGraphH= andler.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDel= egate.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoCacheImp= l.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoInstance= .java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoUtil.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/ReferenceImp= l.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Serializable= ObjectHandler.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/jmx/PojoCacheJmxW= rapper.java pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/FindReferencesTes= t.java pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/List= Test.java pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/List= ener.java pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/MapT= est.java pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Obje= ctTest.java pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Repl= icatedListTest.java pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Repl= icatedMapTest.java pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Repl= icatedObjectTest.java pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Repl= icatedSetTest.java pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/SetT= est.java Removed: pojo/tags/2.2.0.CR7/pom.xml pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/PojoCache.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/AbstractHand= ler.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojoH= andler.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/ArrayHandler= .java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/CollectionCl= assHandler.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/InternalHelp= er.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/MethodDeclar= ations.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Notification= Dispatcher.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/ObjectGraphH= andler.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDel= egate.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoCacheImp= l.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoInstance= .java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoUtil.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Referrer.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Serializable= ObjectHandler.java pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/jmx/PojoCacheJmxW= rapper.java pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/List= Test.java pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/List= ener.java pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/MapT= est.java pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Obje= ctTest.java pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Repl= icatedListTest.java pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Repl= icatedMapTest.java pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Repl= icatedObjectTest.java pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Repl= icatedSetTest.java pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/SetT= est.java Log: Tag CR7 Copied: pojo/tags/2.2.0.CR7 (from rev 6310, pojo/trunk) Deleted: pojo/tags/2.2.0.CR7/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/pom.xml 2008-07-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/pom.xml 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,299 +0,0 @@ - - - 4.0.0 - - 2.2.0-SNAPSHOT - 2.2.0.CR5 - 2.0.0.CR14 - - - org.jboss.cache - jbosscache-common-parent - 1.1 - - org.jboss.cache - jbosscache-pojo - ${jbosscache-pojo-version} - JBoss Cache - POJO Edition - JBoss Cache - POJO Edition - jar - - - org.jboss.aop - jboss-aop - ${jboss.aop.version} - - - org.jboss.cache - jbosscache-core - ${jbosscache-core-version} - - - org.jboss.cache - jbosscache-core - ${jbosscache-core-version} - test-jar - test - - - commons-logging - commons-logging - 1.0.4 - - - net.jcip - jcip-annotations - 1.0 - true - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - - package - - javadoc - - - ${jbosscache.reports.aggregate} - - http://java.sun.com/j2se/1.5.0/docs/api/ - http://java.sun.com/javaee/5/docs/api/ - http://labs.jboss.org/file-access/default/members/jb= osscache/freezone/docs/2.1.0.GA/apidocs/ - - - - - - - maven-assembly-plugin - 2.2-beta-1 - - - assemble - install - - attached - - - - assembly/bin.xml - assembly/doc.xml - assembly/all.xml - - ${artifactId}-${jbosscache-pojo-version} - target/distribution - target/assembly/work - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.3 - - - - bind.address - 127.0.0.1 - - - java.net.preferIPv4Stack - true - - - jgroups.stack - udp - - - functional - always - -Djboss.aop.path=3D${basedir}/src/main/resources/META-I= NF/pojocache-aop.xml -javaagent:${settings.localRepository}/org/jboss/aop/j= boss-aop/${jboss.aop.version}/jboss-aop-${jboss.aop.version}.jar - - - true - false - - - - - org.jboss.maven.plugins - maven-jdocbook-plugin - 2.0.0 - true - - - org.jboss - jbossorg-docbook-xslt - 1.0.0 - - - org.jboss - jbossorg-jdocbook-style - 1.0.0 - jdocbook-style - - - com.uwyn - jhighlight - 1.0 - - - de.java2html - java2html - 5.0 - - - org.richfaces.docs - highlight - 3.1.4.GA - - - - - - - userguide_en - package - - resources - generate - - - master.xml - ${basedir}/src/main/docbook/userguide/en - - ${basedir}/src/main/docbook/images - - - ${basedir}/src/main/docbook/css - - ${basedir}/target/docbook/userguide_en - - - pdf - classpath:/xslt/org/jboss/main-pdf.xsl - userguide_en.pdf - - - html - classpath:/xslt/org/jboss/main-html.xsl - index.html - - - html_single - classpath:/xslt/org/jboss/nochunk-html.xsl - index.html - - - - false - - - - - - - tutorial_en - package - - resources - generate - - - master.xml - ${basedir}/src/main/docbook/tutorial/en - - ${basedir}/src/main/docbook/images - - - ${basedir}/src/main/docbook/css - - ${basedir}/target/docbook/tutorial_en - - - pdf - classpath:/xslt/org/jboss/main-pdf.xsl - tutorial_en.pdf - - - html - classpath:/xslt/org/jboss/main-html.xsl - index.html - - - html_single - classpath:/xslt/org/jboss/nochunk-html.xsl - index.html - - - - false - - - - - - - faq_en - package - - resources - generate - - - master.xml - ${basedir}/src/main/docbook/faq/en - - ${basedir}/src/main/docbook/images - - - ${basedir}/src/main/docbook/css - - ${basedir}/target/docbook/faq_en - - - pdf - classpath:/xslt/org/jboss/main-pdf.xsl - faq_en.pdf - - - html - classpath:/xslt/org/jboss/main-html.xsl - index.html - - - html_single - classpath:/xslt/org/jboss/nochunk-html.xsl - index.html - - - - false - - - - - - - - - - - - snapshots.jboss.org - http://snapshots.jboss.org/maven2 - - - repository.jboss.org - http://repository.jboss.org/maven2 - - - Copied: pojo/tags/2.2.0.CR7/pom.xml (from rev 6323, pojo/trunk/pom.xml) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/pom.xml (rev 0) +++ pojo/tags/2.2.0.CR7/pom.xml 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,299 @@ + + + 4.0.0 + + 2.2.0.CR7 + 2.2.0.CR7 + 2.0.0.CR15 + + + org.jboss.cache + jbosscache-common-parent + 1.1 + + org.jboss.cache + jbosscache-pojo + ${jbosscache-pojo-version} + JBoss Cache - POJO Edition + JBoss Cache - POJO Edition + jar + + + org.jboss.aop + jboss-aop + ${jboss.aop.version} + + + org.jboss.cache + jbosscache-core + ${jbosscache-core-version} + + + org.jboss.cache + jbosscache-core + ${jbosscache-core-version} + test-jar + test + + + commons-logging + commons-logging + 1.0.4 + + + net.jcip + jcip-annotations + 1.0 + true + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + package + + javadoc + + + ${jbosscache.reports.aggregate} + + http://java.sun.com/j2se/1.5.0/docs/api/ + http://java.sun.com/javaee/5/docs/api/ + http://labs.jboss.org/file-access/default/members/jb= osscache/freezone/docs/2.1.0.GA/apidocs/ + + + + + + + maven-assembly-plugin + 2.2-beta-1 + + + assemble + install + + attached + + + + assembly/bin.xml + assembly/doc.xml + assembly/all.xml + + ${artifactId}-${jbosscache-pojo-version} + target/distribution + target/assembly/work + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.3 + + + + bind.address + 127.0.0.1 + + + java.net.preferIPv4Stack + true + + + jgroups.stack + udp + + + functional + always + -Djboss.aop.path=3D${basedir}/src/main/resources/META-I= NF/pojocache-aop.xml -javaagent:${settings.localRepository}/org/jboss/aop/j= boss-aop/${jboss.aop.version}/jboss-aop-${jboss.aop.version}.jar + + + true + false + + + + + org.jboss.maven.plugins + maven-jdocbook-plugin + 2.0.0 + true + + + org.jboss + jbossorg-docbook-xslt + 1.0.0 + + + org.jboss + jbossorg-jdocbook-style + 1.0.0 + jdocbook-style + + + com.uwyn + jhighlight + 1.0 + + + de.java2html + java2html + 5.0 + + + org.richfaces.docs + highlight + 3.1.4.GA + + + + + + + userguide_en + package + + resources + generate + + + master.xml + ${basedir}/src/main/docbook/userguide/en + + ${basedir}/src/main/docbook/images + + + ${basedir}/src/main/docbook/css + + ${basedir}/target/docbook/userguide_en + + + pdf + classpath:/xslt/org/jboss/main-pdf.xsl + userguide_en.pdf + + + html + classpath:/xslt/org/jboss/main-html.xsl + index.html + + + html_single + classpath:/xslt/org/jboss/nochunk-html.xsl + index.html + + + + false + + + + + + + tutorial_en + package + + resources + generate + + + master.xml + ${basedir}/src/main/docbook/tutorial/en + + ${basedir}/src/main/docbook/images + + + ${basedir}/src/main/docbook/css + + ${basedir}/target/docbook/tutorial_en + + + pdf + classpath:/xslt/org/jboss/main-pdf.xsl + tutorial_en.pdf + + + html + classpath:/xslt/org/jboss/main-html.xsl + index.html + + + html_single + classpath:/xslt/org/jboss/nochunk-html.xsl + index.html + + + + false + + + + + + + faq_en + package + + resources + generate + + + master.xml + ${basedir}/src/main/docbook/faq/en + + ${basedir}/src/main/docbook/images + + + ${basedir}/src/main/docbook/css + + ${basedir}/target/docbook/faq_en + + + pdf + classpath:/xslt/org/jboss/main-pdf.xsl + faq_en.pdf + + + html + classpath:/xslt/org/jboss/main-html.xsl + index.html + + + html_single + classpath:/xslt/org/jboss/nochunk-html.xsl + index.html + + + + false + + + + + + + + + + + + snapshots.jboss.org + http://snapshots.jboss.org/maven2 + + + repository.jboss.org + http://repository.jboss.org/maven2 + + + Deleted: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/PojoCache.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/PojoCache.java 2008-07-16= 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/PojoCache.java 2= 008-08-12 04:16:02 UTC (rev 6554) @@ -1,260 +0,0 @@ -/* - * JBoss, the OpenSource J2EE webOS - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package org.jboss.cache.pojo; - -import java.util.Collection; -import java.util.Map; -import java.util.regex.Pattern; - -import org.jboss.cache.Cache; -import org.jboss.cache.Fqn; -import org.jboss.cache.pojo.annotation.Replicable; -import org.jboss.cache.pojo.notification.annotation.PojoCacheListener; - -/** - *

    Main PojoCache APIs. PojoCache is an in-memory, transactional, fine-= grained, and - * object-oriented POJO (plain old Java object) distributed cache system. = It - * differs from the traditional generic distributed cache library by opera= ting on the - * POJO level directly without requiring that object to be serializable. I= t can preserve - * object graph relationship during replication or persistency. It also tr= ack the - * replication via fine-grained maner, i.e., only modified fields are repl= icated.

    - * - * @author Ben Wang - * @author Jason T. Greene - * @since 2.0 - */ -public interface PojoCache -{ - /** - *

    Attach a POJO into PojoCache. It will also recursively put any - * sub-POJO into the cache system. A POJO can be the following and have= the - * consqeuences when attached:

  • it is Replicable, that is, = it - * has been annotated with {@link Replicable} annotation (or via XML), - * and has - * been "instrumented" either compile- or load-time. The POJO will be m= apped - * recursively to the system and fine-grained replication will be - * performed.
  • It is Serializable. The POJO will still be store= d in - * the cache system. However, it is treated as an "opaque" object per s= e. - * That is, the POJO will neither be intercepted - * (for fine-grained operation) or object relantionship will be - * maintained.
  • - *
  • Neither of above. In this case, a user can specify whether it wa= nts - * this POJO to be stored (e.g., replicated or persistent). If not, a - * PojoCacheException will be thrown.
  • - * - * @param id An id String to identify the object in the cache. To pro= mote - * concurrency, we recommend the use of hierarchical String= separating by a - * designated separator. Default is "/" but it can be set d= ifferently via a - * System property, jbosscache.separator in the future rele= ase. E.g., "/ben", - * or "/student/joe", etc. - * @param pojo object to be inerted into the cache. If null, it will nu= llify - * the fqn node. - * @return Existing POJO or null if there is none. - * @throws PojoCacheException Throws if there is an error related to th= e cache operation. - */ - Object attach(String id, Object pojo) throws PojoCacheException; - - /** - *

    Attach a POJO into PojoCache. It will also recursively put any - * sub-POJO into the cache system. A POJO can be the following and have= the - * consequences when attached:

  • it is Replicable, that is, = it - * has been annotated with {@link Replicable} annotation (or via XML), - * and has - * been "instrumented" either compile- or load-time. The POJO will be m= apped - * recursively to the system and fine-grained replication will be - * performed.
  • It is Serializable. The POJO will still be store= d in - * the cache system. However, it is treated as an "opaque" object per s= e. - * That is, the POJO will neither be intercepted - * (for fine-grained operation) or object relationship will be - * maintained.
  • - *
  • Neither of above. In this case, a user can specify whether it wa= nts - * this POJO to be stored (e.g., replicated or persistent). If not, a - * PojoCacheException will be thrown.
  • - * - * @since 2.1 - * @param id the Fqn that specifies the location in the cache to atta= ch the object - * @param pojo object to be inserted into the cache. If null, it will n= ullify - * the fqn node. - * @return Existing POJO or null if there is none. - * @throws PojoCacheException Throws if there is an error related to th= e cache operation. - */ - Object attach(Fqn id, Object pojo) throws PojoCacheException; - - /** - * Remove POJO object from the cache. - * - * @param id Is string that associates with this node. - * @return Original value object from this node. - * @throws PojoCacheException Throws if there is an error related to th= e cache operation. - */ - Object detach(String id) throws PojoCacheException; - - /** - * Remove POJO object from the cache. - * - * @since 2.1 - * @param id location of the object to remove - * @return Original value object from this node. - * @throws PojoCacheException Throws if there is an error related to th= e cache operation. - */ - Object detach(Fqn id) throws PojoCacheException; - - /** - * Return the POJO id that is associated with PojoCache. Note that if a= POJO has not yet - * attached to the cache system, it will simply return null. - * - * @param pojo The POJO that is attached to PojoCache. - * @return String ID. Null if not existed. - */ - String getPojoID(Object pojo); - - /** - * Determines if an object is attached at a particular location. This i= s somewhat less expensive - * than find() because an object is not created, and internal reference= links are not traversed. - * - * @since 2.1 - * @param id the location in the cache to examine - * @return true if an attached object exists, false if not - */ - boolean exists(Fqn id); - - /** - * Retrieve POJO from the cache system. Return null if object does not = exist in the cache. - * Note that this operation is fast if there is already a POJO instance= attached to the cache. - * - * @param id that associates with this node. - * @return Current content value. Null if does not exist. - * @throws PojoCacheException Throws if there is an error related to th= e cache operation. - */ - Object find(String id) throws PojoCacheException; - - /** - * Retrieve POJO from the cache system. Return null if object does not = exist in the cache. - * Note that this operation is fast if there is already a POJO instance= attached to the cache. - * - * @since 2.1 - * @param id that associates with this node. - * @return Current content value. Null if does not exist. - * @throws PojoCacheException Throws if there is an error related to th= e cache operation. - */ - Object find(Fqn id) throws PojoCacheException; - - /** - * Query all managed POJO objects under the id recursively. Note that t= his will not return - * the sub-object POJOs, e.g., if Person has a sub-object of <= em>Address, it - * won't return Address pojo. Also note also that this operati= on is not thread-safe - * now. In addition, it assumes that once a POJO is found with a id, no= more POJO is stored - * under the children of the id. That is, we don't mix the id with diff= erent POJOs. - * - * @param id The starting place to find all POJOs. - * @return Map of all POJOs found with (id, POJO) pair. Return size of = 0, if not found. - * @throws PojoCacheException Throws if there is an error related to th= e cache operation. - */ - Map, Object> findAll(String id) throws PojoCacheException; - - /** - * Query all managed POJO objects under the id recursively. Note that t= his will not return - * the sub-object POJOs, e.g., if Person has a sub-object of <= em>Address, it - * won't return Address pojo. Also note also that this operati= on is not thread-safe - * now. In addition, it assumes that once a POJO is found with a id, no= more POJO is stored - * under the children of the id. That is, we don't mix the id with diff= erent POJOs. - * - * @since 2.1 - * @param id The starting place to find all POJOs. - * @return Map of all POJOs found with (id, POJO) pair. Return size of = 0, if not found. - * @throws PojoCacheException Throws if there is an error related to th= e cache operation. - */ - Map, Object> findAll(Fqn id) throws PojoCacheException; - - /** - * Lifecycle method to start PojoCache. - * - * @throws PojoCacheException - */ - void create() throws PojoCacheException; - - /** - * Lifecycle method to start PojoCache. - * - * @throws PojoCacheException - */ - void start() throws PojoCacheException; - - /** - * Lifecycle method to stop PojoCache. Note that PojoCache can be stopp= ed and started - * repeatedly. - * - * @throws PojoCacheException - */ - void stop() throws PojoCacheException; - - /** - * Lifecycle method to destroy PojoCache. - * - * @throws PojoCacheException - */ - void destroy() throws PojoCacheException; - - /** - *

    - * Add a PojoCache listener. A given listener instance can only be adde= d once. - * To have a duplicate listener simply create a new instance. - * - *

    - * The listener must be annotated with the {@link PojoCacheListener} an= notation, and - * all callback methods need to be annotated with the respective event = annotations. - * Otherwise, an exception will be thrown. - * - * @param listener the listener instance to register - * @throws IllegalArgumentException if listener does not conform to ann= otation requirements - * @see PojoCacheListener for examples - */ - void addListener(Object listener); - - /** - *

    - * Add a PojoCache listener that will only monitor a specific ID(FQN) p= attern. - * A given listener instance can only be added once, whether or not the= re is - * a pattern. To have a duplicate listener simply create a new instance. - * - *

    - * The listener must be annotated with the {@link PojoCacheListener} an= notation, and - * all callback methods need to be annotated with the respective event = annotations. - * Otherwise, an exception will be thrown. - * - * @param listener the listener instance to register - * @param pattern the ID pattern for notifications of interest - * @throws IllegalArgumentException if listener does not conform to ann= otation requirements - * @see PojoCacheListener for examples - */ - void addListener(Object listener, Pattern pattern); - - /** - * Retrieve a read-only list of listeners. - */ - Collection getListeners(); - - /** - * Remove the specific listener. - * - * @param listener the listener to remove - */ - void removeListener(Object listener); - = - /** - * Get's the thread context for all POJO Cache operations. - * = - * @return the current thread's context - * @since 2.1 - */ - PojoCacheThreadContext getThreadContext(); - - /** - * Obtain the underlying generic cache system. Use this for non-POJO ca= che operation, e.g. - */ - Cache getCache(); -} Copied: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/PojoCache.ja= va (from rev 6374, pojo/trunk/src/main/java/org/jboss/cache/pojo/PojoCache.= java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/PojoCache.java = (rev 0) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/PojoCache.java 2= 008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,287 @@ +/* + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.cache.pojo; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.regex.Pattern; + +import org.jboss.cache.Cache; +import org.jboss.cache.Fqn; +import org.jboss.cache.pojo.annotation.Replicable; +import org.jboss.cache.pojo.notification.annotation.PojoCacheListener; + +/** + *

    Main PojoCache APIs. PojoCache is an in-memory, transactional, fine-= grained, and + * object-oriented POJO (plain old Java object) distributed cache system. = It + * differs from the traditional generic distributed cache library by opera= ting on the + * POJO level directly without requiring that object to be serializable. I= t can preserve + * object graph relationship during replication or persistency. It also tr= ack the + * replication via fine-grained maner, i.e., only modified fields are repl= icated.

    + * + * @author Ben Wang + * @author Jason T. Greene + * @since 2.0 + */ +public interface PojoCache +{ + /** + *

    Attach a POJO into PojoCache. It will also recursively put any + * sub-POJO into the cache system. A POJO can be the following and have= the + * consqeuences when attached:

  • it is Replicable, that is, = it + * has been annotated with {@link Replicable} annotation (or via XML), + * and has + * been "instrumented" either compile- or load-time. The POJO will be m= apped + * recursively to the system and fine-grained replication will be + * performed.
  • It is Serializable. The POJO will still be store= d in + * the cache system. However, it is treated as an "opaque" object per s= e. + * That is, the POJO will neither be intercepted + * (for fine-grained operation) or object relantionship will be + * maintained.
  • + *
  • Neither of above. In this case, a user can specify whether it wa= nts + * this POJO to be stored (e.g., replicated or persistent). If not, a + * PojoCacheException will be thrown.
  • + * + * @param id An id String to identify the object in the cache. To pro= mote + * concurrency, we recommend the use of hierarchical String= separating by a + * designated separator. Default is "/" but it can be set d= ifferently via a + * System property, jbosscache.separator in the future rele= ase. E.g., "/ben", + * or "/student/joe", etc. + * @param pojo object to be inerted into the cache. If null, it will nu= llify + * the fqn node. + * @return Existing POJO or null if there is none. + * @throws PojoCacheException Throws if there is an error related to th= e cache operation. + */ + Object attach(String id, Object pojo) throws PojoCacheException; + + /** + *

    Attach a POJO into PojoCache. It will also recursively put any + * sub-POJO into the cache system. A POJO can be the following and have= the + * consequences when attached:

  • it is Replicable, that is, = it + * has been annotated with {@link Replicable} annotation (or via XML), + * and has + * been "instrumented" either compile- or load-time. The POJO will be m= apped + * recursively to the system and fine-grained replication will be + * performed.
  • It is Serializable. The POJO will still be store= d in + * the cache system. However, it is treated as an "opaque" object per s= e. + * That is, the POJO will neither be intercepted + * (for fine-grained operation) or object relationship will be + * maintained.
  • + *
  • Neither of above. In this case, a user can specify whether it wa= nts + * this POJO to be stored (e.g., replicated or persistent). If not, a + * PojoCacheException will be thrown.
  • + * + * @since 2.1 + * @param id the Fqn that specifies the location in the cache to atta= ch the object + * @param pojo object to be inserted into the cache. If null, it will n= ullify + * the fqn node. + * @return Existing POJO or null if there is none. + * @throws PojoCacheException Throws if there is an error related to th= e cache operation. + */ + Object attach(Fqn id, Object pojo) throws PojoCacheException; + + /** + * Remove POJO object from the cache. + * + * @param id Is string that associates with this node. + * @return Original value object from this node. + * @throws PojoCacheException Throws if there is an error related to th= e cache operation. + */ + Object detach(String id) throws PojoCacheException; + + /** + * Remove POJO object from the cache. + * + * @since 2.1 + * @param id location of the object to remove + * @return Original value object from this node. + * @throws PojoCacheException Throws if there is an error related to th= e cache operation. + */ + Object detach(Fqn id) throws PojoCacheException; + + /** + * Return the Fqn of the internal node containing the data = of this attached object. + *

    + * Note that if the object is not attached to the cache system, this met= hod will simply return + * null. Same for any object of an immediate type (primitive wrapper typ= es, String, or Class) or + * of any Serializable types. + *

    + * + * @param object Any object. + * @return Fqn of the internal data node. null= if the object is + * immediate, serializable, or not in the cache. + */ + Fqn getInternalFqn(Object object); + + /** + * Return a list of the references from attached objects to this object.= For each reference it + * returns a {@link Reference} object containing the Fqn of= the referrer object and + * the name of the field that contains the reference. + *

    + * If the node is not attached to the cache, this method will return an = empty list. Same for any + * object of an immediate type (primitive wrapper types, String, or Clas= s) or of any + * Serializable types. + *

    + *

    + * For external references (i.e. when the object was directly attached t= o the cache by user code) + * the Reference.fieldName property is null. O= therwise it is the name + * of the field that contains the reference to this object. + *

    + * + * @param object Any object. + * @return Collection of internal references to the given object. Empty = collection if the object is + * immediate, serializable, or not in the cache. + */ + Collection getReferences(Object object); + + /** + * Determines if an object is attached at a particular location. This i= s somewhat less expensive + * than find() because an object is not created, and internal reference= links are not traversed. + * + * @since 2.1 + * @param id the location in the cache to examine + * @return true if an attached object exists, false if not + */ + boolean exists(Fqn id); + + /** + * Retrieve POJO from the cache system. Return null if object does not = exist in the cache. + * Note that this operation is fast if there is already a POJO instance= attached to the cache. + * + * @param id that associates with this node. + * @return Current content value. Null if does not exist. + * @throws PojoCacheException Throws if there is an error related to th= e cache operation. + */ + Object find(String id) throws PojoCacheException; + + /** + * Retrieve POJO from the cache system. Return null if object does not = exist in the cache. + * Note that this operation is fast if there is already a POJO instance= attached to the cache. + * + * @since 2.1 + * @param id that associates with this node. + * @return Current content value. Null if does not exist. + * @throws PojoCacheException Throws if there is an error related to th= e cache operation. + */ + Object find(Fqn id) throws PojoCacheException; + + /** + * Query all managed POJO objects under the id recursively. Note that t= his will not return + * the sub-object POJOs, e.g., if Person has a sub-object of <= em>Address, it + * won't return Address pojo. Also note also that this operati= on is not thread-safe + * now. In addition, it assumes that once a POJO is found with a id, no= more POJO is stored + * under the children of the id. That is, we don't mix the id with diff= erent POJOs. + * + * @param id The starting place to find all POJOs. + * @return Map of all POJOs found with (id, POJO) pair. Return size of = 0, if not found. + * @throws PojoCacheException Throws if there is an error related to th= e cache operation. + */ + Map, Object> findAll(String id) throws PojoCacheException; + + /** + * Query all managed POJO objects under the id recursively. Note that t= his will not return + * the sub-object POJOs, e.g., if Person has a sub-object of <= em>Address, it + * won't return Address pojo. Also note also that this operati= on is not thread-safe + * now. In addition, it assumes that once a POJO is found with a id, no= more POJO is stored + * under the children of the id. That is, we don't mix the id with diff= erent POJOs. + * + * @since 2.1 + * @param id The starting place to find all POJOs. + * @return Map of all POJOs found with (id, POJO) pair. Return size of = 0, if not found. + * @throws PojoCacheException Throws if there is an error related to th= e cache operation. + */ + Map, Object> findAll(Fqn id) throws PojoCacheException; + + /** + * Lifecycle method to start PojoCache. + * + * @throws PojoCacheException + */ + void create() throws PojoCacheException; + + /** + * Lifecycle method to start PojoCache. + * + * @throws PojoCacheException + */ + void start() throws PojoCacheException; + + /** + * Lifecycle method to stop PojoCache. Note that PojoCache can be stopp= ed and started + * repeatedly. + * + * @throws PojoCacheException + */ + void stop() throws PojoCacheException; + + /** + * Lifecycle method to destroy PojoCache. + * + * @throws PojoCacheException + */ + void destroy() throws PojoCacheException; + + /** + *

    + * Add a PojoCache listener. A given listener instance can only be adde= d once. + * To have a duplicate listener simply create a new instance. + * + *

    + * The listener must be annotated with the {@link PojoCacheListener} an= notation, and + * all callback methods need to be annotated with the respective event = annotations. + * Otherwise, an exception will be thrown. + * + * @param listener the listener instance to register + * @throws IllegalArgumentException if listener does not conform to ann= otation requirements + * @see PojoCacheListener for examples + */ + void addListener(Object listener); + + /** + *

    + * Add a PojoCache listener that will only monitor a specific ID(FQN) p= attern. + * A given listener instance can only be added once, whether or not the= re is + * a pattern. To have a duplicate listener simply create a new instance. + * + *

    + * The listener must be annotated with the {@link PojoCacheListener} an= notation, and + * all callback methods need to be annotated with the respective event = annotations. + * Otherwise, an exception will be thrown. + * + * @param listener the listener instance to register + * @param pattern the ID pattern for notifications of interest + * @throws IllegalArgumentException if listener does not conform to ann= otation requirements + * @see PojoCacheListener for examples + */ + void addListener(Object listener, Pattern pattern); + + /** + * Retrieve a read-only list of listeners. + */ + Collection getListeners(); + + /** + * Remove the specific listener. + * + * @param listener the listener to remove + */ + void removeListener(Object listener); + = + /** + * Get's the thread context for all POJO Cache operations. + * = + * @return the current thread's context + * @since 2.1 + */ + PojoCacheThreadContext getThreadContext(); + + /** + * Obtain the underlying generic cache system. Use this for non-POJO ca= che operation, e.g. + */ + Cache getCache(); +} Copied: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/Reference.ja= va (from rev 6374, pojo/trunk/src/main/java/org/jboss/cache/pojo/Reference.= java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/Reference.java = (rev 0) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/Reference.java 2= 008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,50 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.cache.pojo; + +import org.jboss.cache.Fqn; + +/** + * A reference to an attached object. This class represents both normal Fq= n aliases, and + * references from other attached objects. + * + * @author Dan Berindei + */ +public interface Reference +{ + /** + * Returns the Fqn of the referring node. Cannot be null. + * + * @return Fqn of the referring node. + */ + public Fqn getFqn(); + + /** + * Returns the name of the node key which references the attached objec= t, or null + * if the Fqn is a normal alias to the internal node. If there is a key= , then this is + * typically a field name or collection index. + * + * @return Name of the field or key/index in the collection that is con= taining the reference. + */ + public String getKey(); +} \ No newline at end of file Deleted: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Abstra= ctHandler.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AbstractHandler.java= 2008-07-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/AbstractHan= dler.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,43 +0,0 @@ -/* -* JBoss, Home of Professional Open Source -* Copyright 2005, JBoss Inc., and individual contributors as indicated -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* This is free software; you can redistribute it and/or modify it -* under the terms of the GNU Lesser General Public License as -* published by the Free Software Foundation; either version 2.1 of -* the License, or (at your option) any later version. -* -* This software is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this software; if not, write to the Free -* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -* 02110-1301 USA, or see the FSF site: http://www.fsf.org. -*/ -package org.jboss.cache.pojo.impl; - -import org.jboss.cache.Fqn; - -abstract class AbstractHandler -{ - - public AbstractHandler() - { - super(); - } - = - protected abstract boolean handles(Class clazz); - - protected abstract Object remove(Fqn fqn, Fqn referenceingFqn, Ob= ject result); - - protected abstract void put(Fqn fqn, Fqn referencingFqn, Object o= bj); - - protected abstract Object get(Fqn fqn, Class clazz, PojoInstance = pojoInstance); - - protected abstract Fqn getFqn(Object obj); -} \ No newline at end of file Copied: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Abstrac= tHandler.java (from rev 6374, pojo/trunk/src/main/java/org/jboss/cache/pojo= /impl/AbstractHandler.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/AbstractHan= dler.java (rev 0) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/AbstractHan= dler.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,44 @@ +/* +* JBoss, Home of Professional Open Source +* Copyright 2005, JBoss Inc., and individual contributors as indicated +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* This is free software; you can redistribute it and/or modify it +* under the terms of the GNU Lesser General Public License as +* published by the Free Software Foundation; either version 2.1 of +* the License, or (at your option) any later version. +* +* This software is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this software; if not, write to the Free +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ +package org.jboss.cache.pojo.impl; + +import org.jboss.cache.Fqn; +import org.jboss.cache.pojo.Reference; + +abstract class AbstractHandler +{ + + public AbstractHandler() + { + super(); + } + + protected abstract boolean handles(Class clazz); + + protected abstract Object remove(Fqn fqn, Reference reference, Objec= t result); + + protected abstract void put(Fqn fqn, Reference reference, Object obj= ); + + protected abstract Object get(Fqn fqn, Class clazz, PojoInstance = pojoInstance); + + protected abstract Fqn getFqn(Object obj); +} Deleted: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Advise= dPojoHandler.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojoHandler.j= ava 2008-07-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojo= Handler.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,257 +0,0 @@ -/* -* JBoss, Home of Professional Open Source -* Copyright 2005, JBoss Inc., and individual contributors as indicated -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* This is free software; you can redistribute it and/or modify it -* under the terms of the GNU Lesser General Public License as -* published by the Free Software Foundation; either version 2.1 of -* the License, or (at your option) any later version. -* -* This software is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this software; if not, write to the Free -* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -* 02110-1301 USA, or see the FSF site: http://www.fsf.org. -*/ -package org.jboss.cache.pojo.impl; - -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jboss.aop.Advised; -import org.jboss.aop.ClassInstanceAdvisor; -import org.jboss.aop.InstanceAdvisor; -import org.jboss.cache.Cache; -import org.jboss.cache.CacheException; -import org.jboss.cache.Fqn; -import org.jboss.cache.pojo.PojoCacheException; -import org.jboss.cache.pojo.interceptors.dynamic.BaseInterceptor; -import org.jboss.cache.pojo.interceptors.dynamic.CacheFieldInterceptor; -import org.jboss.cache.pojo.memory.FieldPersistentReference; -import org.jboss.cache.pojo.util.AopUtil; -import org.jboss.cache.pojo.util.Instantiator; -import org.jboss.cache.pojo.util.ObjectUtil; - -/** - * Handling the advised pojo operations. No consideration of object graph = here. - * - * @author Ben Wang - * Date: Aug 4, 2005 - * @version $Id$ - */ -class AdvisedPojoHandler extends AbstractHandler -{ - private final Log log =3D LogFactory.getLog(AdvisedPojoHandler.class); - private Cache cache_; - private PojoCacheImpl pCache_; - private PojoUtil util_; - - public AdvisedPojoHandler(PojoCacheImpl pCache, InternalHelper internal, - PojoUtil util) - { - pCache_ =3D pCache; - cache_ =3D pCache_.getCache(); - util_ =3D util; - } - - @Override - protected Fqn getFqn(Object obj) - { - if (obj instanceof Advised) - { - InstanceAdvisor advisor =3D ((Advised) obj)._getInstanceAdvisor(); - if (advisor =3D=3D null) - throw new PojoCacheException("_putObject(): InstanceAdvisor is= null for: " + obj); - - // Step Check for cross references - BaseInterceptor interceptor =3D AopUtil.findCacheInterceptor(advi= sor); - if (interceptor !=3D null) - return interceptor.getFqn(); - } - - return null; - } - - @Override - protected Object get(Fqn fqn, Class clazz, PojoInstance pojoInsta= nce) throws CacheException - { - CachedType type =3D pCache_.getCachedType(clazz); - Object obj =3D Instantiator.newInstance(clazz); - - // Eager initialize final fields, since these may not be intercepted - - try - { - for (FieldPersistentReference ref : type.getFinalFields()) - { - Field field =3D ref.getField(); - Object result; - - if (CachedType.isSimpleAttribute(field)) - result =3D cache_.get(fqn, field.getName()); - else - result =3D pCache_.find(fqn, field.getName(), obj); - - field.set(obj, result); - } - } - catch (Exception e) - { - log.warn("Could not initialize final fields on object: " + Object= Util.identityString(obj)); - } - - InstanceAdvisor advisor =3D ((Advised) obj)._getInstanceAdvisor(); - CacheFieldInterceptor interceptor =3D new CacheFieldInterceptor(pCac= he_, fqn, type); - interceptor.setAopInstance(pojoInstance); - util_.attachInterceptor(obj, advisor, interceptor); - return obj; - } - - @Override - protected void put(Fqn fqn, Fqn referencingFqn, Object obj) throw= s CacheException - { - CachedType type =3D pCache_.getCachedType(obj.getClass()); - // We have a clean slate then. - InstanceAdvisor advisor =3D ((Advised) obj)._getInstanceAdvisor(); - // TODO workaround for deserialiased objects - if (advisor =3D=3D null) - { - advisor =3D new ClassInstanceAdvisor(obj); - ((Advised) obj)._setInstanceAdvisor(advisor); - } - - // Let's do batch update via Map instead - Map map =3D new HashMap(); - // Always initialize the ref count so we can mark this as an AopNode. - PojoInstance pojoInstance =3D InternalHelper.initializeAopInstance(r= eferencingFqn); - map.put(PojoInstance.KEY, pojoInstance); - pojoInstance.setPojoClass(type.getType()); - // we will do it recursively. - // Map of sub-objects that are non-primitive - Map subPojoMap =3D new HashMap(); - - for (Iterator i =3D type.getFields().iterator(); i.hasNext();) - { - Field field =3D (Field) (((FieldPersistentReference) i.next())).g= et(); - Object value =3D null; - try - { - value =3D field.get(obj); - } - catch (IllegalAccessException e) - { - throw new CacheException("field access failed", e); - } - - // we simply treat field that has @Serializable as a primitive ty= pe. - if (CachedType.isSimpleAttribute(field)) - { - // switched using batch update - map.put(field.getName(), value); - } - else - { - subPojoMap.put(field, value); - } - } - - // Use option to skip locking since we have parent lock already. -// cache_.getInvocationContext().getOptionOverrides().setSuppressLock= ing(true); - - cache_.getRoot().addChild(fqn).putAll(map); - - // Insert interceptor after PojoInstance has been written to the cac= he - // This prevents JBCACHE-1078 with pessimistic locking, optimistic i= s still a problem - CacheFieldInterceptor interceptor =3D new CacheFieldInterceptor(pCac= he_, fqn, type); - interceptor.setAopInstance(pojoInstance); - util_.attachInterceptor(obj, advisor, interceptor); - -// cache_.getInvocationContext().getOptionOverrides().setSuppressLock= ing(false); - // This is in-memory operation only - InternalHelper.setPojo(pojoInstance, obj); - - for (Object o : subPojoMap.keySet()) - { - Field field =3D (Field) o; - Object value =3D subPojoMap.get(field); - if (value =3D=3D null) continue; // really no need to map the POJ= O. - pCache_.attach(fqn, value, field.getName(), obj); - // If it is Collection classes, we replace it with dynamic proxy. - // But we will have to ignore it if value is null - if (value instanceof Map || value instanceof List || value instan= ceof Set) - { - Object newValue =3D pCache_.find(fqn, field.getName(), obj); - util_.inMemorySubstitution(obj, field, newValue); - } - } - - // Need to make sure this is behind put such that obj.toString is do= ne correctly. - if (log.isDebugEnabled()) - { - log.debug("internalPut(): inserting with fqn: " + fqn); - } - } - - @Override - protected Object remove(Fqn fqn, Fqn referencingFqn, Object resul= t) throws CacheException - { - CachedType type =3D pCache_.getCachedType(result.getClass()); - InstanceAdvisor advisor =3D ((Advised) result)._getInstanceAdvisor(); - for (Iterator i =3D type.getFields().iterator(); i.hasNext();) - { - Field field =3D (Field) (((FieldPersistentReference) i.next())).g= et(); - Object value =3D null; - - if (! CachedType.isSimpleAttribute(field)) - { - value =3D pCache_.detach(fqn, field.getName(), result); - - // Check for Collection. If it is, we need to reset the origin= al reference. - if ((value instanceof Map || value instanceof List || value in= stanceof Set)) - { - // If this Collection class, we are returning the original = value already - util_.inMemorySubstitution(result, field, value); - } - } - else - { - // Update last known field state - value =3D cache_.get(fqn, field.getName()); - util_.inMemorySubstitution(result, field, value); - } - } - - cache_.removeNode(fqn); - // Determine if we want to keep the interceptor for later use. - CacheFieldInterceptor interceptor =3D (CacheFieldInterceptor) AopUti= l.findCacheInterceptor(advisor); - // Remember to remove the interceptor from in-memory object but make= sure it belongs to me first. - if (interceptor !=3D null) - { - if (log.isDebugEnabled()) - { - log.debug("regularRemoveObject(): removed cache interceptor fq= n: " + fqn + " interceptor: " + interceptor); - } - util_.detachInterceptor(advisor, interceptor); - } - - return result; - } - - @Override - protected boolean handles(Class clazz) - { - return Advised.class.isAssignableFrom(clazz); - } -} Copied: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Advised= PojoHandler.java (from rev 6374, pojo/trunk/src/main/java/org/jboss/cache/p= ojo/impl/AdvisedPojoHandler.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojo= Handler.java (rev 0) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojo= Handler.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,254 @@ +/* +* JBoss, Home of Professional Open Source +* Copyright 2005, JBoss Inc., and individual contributors as indicated +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* This is free software; you can redistribute it and/or modify it +* under the terms of the GNU Lesser General Public License as +* published by the Free Software Foundation; either version 2.1 of +* the License, or (at your option) any later version. +* +* This software is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this software; if not, write to the Free +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ +package org.jboss.cache.pojo.impl; + +import java.lang.reflect.Field; +import java.util.*; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.aop.Advised; +import org.jboss.aop.ClassInstanceAdvisor; +import org.jboss.aop.InstanceAdvisor; +import org.jboss.cache.Cache; +import org.jboss.cache.CacheException; +import org.jboss.cache.Fqn; +import org.jboss.cache.pojo.PojoCacheException; +import org.jboss.cache.pojo.Reference; +import org.jboss.cache.pojo.interceptors.dynamic.BaseInterceptor; +import org.jboss.cache.pojo.interceptors.dynamic.CacheFieldInterceptor; +import org.jboss.cache.pojo.memory.FieldPersistentReference; +import org.jboss.cache.pojo.util.AopUtil; +import org.jboss.cache.pojo.util.Instantiator; +import org.jboss.cache.pojo.util.ObjectUtil; + +/** + * Handling the advised pojo operations. No consideration of object graph = here. + * + * @author Ben Wang + * Date: Aug 4, 2005 + * @version $Id$ + */ +class AdvisedPojoHandler extends AbstractHandler +{ + private final Log log =3D LogFactory.getLog(AdvisedPojoHandler.class); + private Cache cache_; + private PojoCacheImpl pCache_; + private PojoUtil util_; + + public AdvisedPojoHandler(PojoCacheImpl pCache, InternalHelper internal, + PojoUtil util) + { + pCache_ =3D pCache; + cache_ =3D pCache_.getCache(); + util_ =3D util; + } + + @Override + protected Fqn getFqn(Object obj) + { + if (obj instanceof Advised) + { + InstanceAdvisor advisor =3D ((Advised) obj)._getInstanceAdvisor(); + if (advisor =3D=3D null) + throw new PojoCacheException("_putObject(): InstanceAdvisor is= null for: " + obj); + + // Step Check for cross references + BaseInterceptor interceptor =3D AopUtil.findCacheInterceptor(advi= sor); + if (interceptor !=3D null) + return interceptor.getFqn(); + } + + return null; + } + + @Override + protected Object get(Fqn fqn, Class clazz, PojoInstance pojoInsta= nce) throws CacheException + { + CachedType type =3D pCache_.getCachedType(clazz); + Object obj =3D Instantiator.newInstance(clazz); + + // Eager initialize final fields, since these may not be intercepted + + try + { + for (FieldPersistentReference ref : type.getFinalFields()) + { + Field field =3D ref.getField(); + Object result; + + if (CachedType.isSimpleAttribute(field)) + result =3D cache_.get(fqn, field.getName()); + else + result =3D pCache_.find(fqn, field.getName(), obj); + + field.set(obj, result); + } + } + catch (Exception e) + { + log.warn("Could not initialize final fields on object: " + Object= Util.identityString(obj)); + } + + InstanceAdvisor advisor =3D ((Advised) obj)._getInstanceAdvisor(); + CacheFieldInterceptor interceptor =3D new CacheFieldInterceptor(pCac= he_, fqn, type); + interceptor.setAopInstance(pojoInstance); + util_.attachInterceptor(obj, advisor, interceptor); + return obj; + } + + @Override + protected void put(Fqn fqn, Reference reference, Object obj) throws = CacheException + { + CachedType type =3D pCache_.getCachedType(obj.getClass()); + // We have a clean slate then. + InstanceAdvisor advisor =3D ((Advised) obj)._getInstanceAdvisor(); + // TODO workaround for deserialiased objects + if (advisor =3D=3D null) + { + advisor =3D new ClassInstanceAdvisor(obj); + ((Advised) obj)._setInstanceAdvisor(advisor); + } + + // Let's do batch update via Map instead + Map map =3D new HashMap(); + // Always initialize the ref count so we can mark this as an AopNode. + PojoInstance pojoInstance =3D InternalHelper.initializeAopInstance(r= eference); + map.put(PojoInstance.KEY, pojoInstance); + pojoInstance.setPojoClass(type.getType()); + // we will do it recursively. + // Map of sub-objects that are non-primitive + Map subPojoMap =3D new HashMap(); + + for (Iterator i =3D type.getFields().iterator(); i.hasNext();) + { + Field field =3D (Field) (((FieldPersistentReference) i.next())).g= et(); + Object value =3D null; + try + { + value =3D field.get(obj); + } + catch (IllegalAccessException e) + { + throw new CacheException("field access failed", e); + } + + // we simply treat field that has @Serializable as a primitive ty= pe. + if (CachedType.isSimpleAttribute(field)) + { + // switched using batch update + map.put(field.getName(), value); + } + else + { + subPojoMap.put(field, value); + } + } + + // Use option to skip locking since we have parent lock already. +// cache_.getInvocationContext().getOptionOverrides().setSuppressLock= ing(true); + + cache_.getRoot().addChild(fqn).putAll(map); + + // Insert interceptor after PojoInstance has been written to the cac= he + // This prevents JBCACHE-1078 with pessimistic locking, optimistic i= s still a problem + CacheFieldInterceptor interceptor =3D new CacheFieldInterceptor(pCac= he_, fqn, type); + interceptor.setAopInstance(pojoInstance); + util_.attachInterceptor(obj, advisor, interceptor); + +// cache_.getInvocationContext().getOptionOverrides().setSuppressLock= ing(false); + // This is in-memory operation only + InternalHelper.setPojo(pojoInstance, obj); + + for (Object o : subPojoMap.keySet()) + { + Field field =3D (Field) o; + Object value =3D subPojoMap.get(field); + if (value =3D=3D null) continue; // really no need to map the POJ= O. + pCache_.attach(fqn, value, field.getName(), obj); + // If it is Collection classes, we replace it with dynamic proxy. + // But we will have to ignore it if value is null + if (value instanceof Map || value instanceof List || value instan= ceof Set) + { + Object newValue =3D pCache_.find(fqn, field.getName(), obj); + util_.inMemorySubstitution(obj, field, newValue); + } + } + + // Need to make sure this is behind put such that obj.toString is do= ne correctly. + if (log.isDebugEnabled()) + { + log.debug("internalPut(): inserting with fqn: " + fqn); + } + } + + @Override + protected Object remove(Fqn fqn, Reference referencingFqn, Object re= sult) throws CacheException + { + CachedType type =3D pCache_.getCachedType(result.getClass()); + InstanceAdvisor advisor =3D ((Advised) result)._getInstanceAdvisor(); + for (Iterator i =3D type.getFields().iterator(); i.hasNext();) + { + Field field =3D (Field) (((FieldPersistentReference) i.next())).g= et(); + Object value =3D null; + + if (! CachedType.isSimpleAttribute(field)) + { + value =3D pCache_.detach(fqn, field.getName(), result); + + // Check for Collection. If it is, we need to reset the origin= al reference. + if ((value instanceof Map || value instanceof List || value in= stanceof Set)) + { + // If this Collection class, we are returning the original = value already + util_.inMemorySubstitution(result, field, value); + } + } + else + { + // Update last known field state + value =3D cache_.get(fqn, field.getName()); + util_.inMemorySubstitution(result, field, value); + } + } + + cache_.removeNode(fqn); + // Determine if we want to keep the interceptor for later use. + CacheFieldInterceptor interceptor =3D (CacheFieldInterceptor) AopUti= l.findCacheInterceptor(advisor); + // Remember to remove the interceptor from in-memory object but make= sure it belongs to me first. + if (interceptor !=3D null) + { + if (log.isDebugEnabled()) + { + log.debug("regularRemoveObject(): removed cache interceptor fq= n: " + fqn + " interceptor: " + interceptor); + } + util_.detachInterceptor(advisor, interceptor); + } + + return result; + } + + @Override + protected boolean handles(Class clazz) + { + return Advised.class.isAssignableFrom(clazz); + } +} Deleted: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/ArrayH= andler.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ArrayHandler.java 20= 08-07-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/ArrayHandle= r.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,90 +0,0 @@ -/* -* JBoss, Home of Professional Open Source -* Copyright 2005, JBoss Inc., and individual contributors as indicated -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* This is free software; you can redistribute it and/or modify it -* under the terms of the GNU Lesser General Public License as -* published by the Free Software Foundation; either version 2.1 of -* the License, or (at your option) any later version. -* -* This software is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this software; if not, write to the Free -* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -* 02110-1301 USA, or see the FSF site: http://www.fsf.org. -*/ -package org.jboss.cache.pojo.impl; - -import org.jboss.cache.Fqn; -import org.jboss.cache.pojo.collection.CachedArray; -import org.jboss.cache.pojo.collection.CachedArrayRegistry; - -/** - * Handles array types. - * - * @author Jason T. Greene - */ -public class ArrayHandler extends AbstractHandler -{ - private final PojoCacheImpl cache; - private final PojoUtil util =3D new PojoUtil(); - - ArrayHandler(PojoCacheImpl cache) - { - this.cache =3D cache; - } - - protected Fqn getFqn(Object array) - { - CachedArray cached =3D CachedArrayRegistry.lookup(array); - return cached !=3D null ? cached.getFqn() : null; - } - - - protected void put(Fqn fqn, Fqn referencingFqn, Object obj) - { - // Always initialize the ref count so that we can mark this as an Ao= pNode. - PojoInstance pojoInstance =3D InternalHelper.initializeAopInstance(r= eferencingFqn); - pojoInstance.set(obj); - pojoInstance.setPojoClass(obj.getClass()); - cache.getCache().put(fqn, PojoInstance.KEY, pojoInstance); - - CachedArray cached =3D CachedArray.create(fqn, cache, obj); - util.attachArray(obj, cached); - } - - @Override - protected Object get(Fqn fqn, Class clazz, PojoInstance pojo) - { - CachedArray cached =3D CachedArray.load(fqn, cache, clazz); - Object array =3D cached.toArray(); - CachedArrayRegistry.register(array, cached); - - return array; - } - - @Override - protected Object remove(Fqn fqn, Fqn referencingFqn, Object obj) - { - CachedArray cached =3D CachedArrayRegistry.lookup(obj); - if (cached !=3D null) { - util.detachArray(obj, cached); - cached.destroy(); - } - - return obj; - } - - @Override - protected boolean handles(Class clazz) - { - return clazz.isArray(); - } - -} Copied: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/ArrayHa= ndler.java (from rev 6374, pojo/trunk/src/main/java/org/jboss/cache/pojo/im= pl/ArrayHandler.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/ArrayHandle= r.java (rev 0) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/ArrayHandle= r.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,91 @@ +/* +* JBoss, Home of Professional Open Source +* Copyright 2005, JBoss Inc., and individual contributors as indicated +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* This is free software; you can redistribute it and/or modify it +* under the terms of the GNU Lesser General Public License as +* published by the Free Software Foundation; either version 2.1 of +* the License, or (at your option) any later version. +* +* This software is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this software; if not, write to the Free +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ +package org.jboss.cache.pojo.impl; + +import org.jboss.cache.Fqn; +import org.jboss.cache.pojo.Reference; +import org.jboss.cache.pojo.collection.CachedArray; +import org.jboss.cache.pojo.collection.CachedArrayRegistry; + +/** + * Handles array types. + * + * @author Jason T. Greene + */ +public class ArrayHandler extends AbstractHandler +{ + private final PojoCacheImpl cache; + private final PojoUtil util =3D new PojoUtil(); + + ArrayHandler(PojoCacheImpl cache) + { + this.cache =3D cache; + } + + protected Fqn getFqn(Object array) + { + CachedArray cached =3D CachedArrayRegistry.lookup(array); + return cached !=3D null ? cached.getFqn() : null; + } + + @Override + protected void put(Fqn fqn, Reference reference, Object obj) + { + // Always initialize the ref count so that we can mark this as an Ao= pNode. + PojoInstance pojoInstance =3D InternalHelper.initializeAopInstance(r= eference); + pojoInstance.set(obj); + pojoInstance.setPojoClass(obj.getClass()); + cache.getCache().put(fqn, PojoInstance.KEY, pojoInstance); + + CachedArray cached =3D CachedArray.create(fqn, cache, obj); + util.attachArray(obj, cached); + } + + @Override + protected Object get(Fqn fqn, Class clazz, PojoInstance pojo) + { + CachedArray cached =3D CachedArray.load(fqn, cache, clazz); + Object array =3D cached.toArray(); + CachedArrayRegistry.register(array, cached); + + return array; + } + + @Override + protected Object remove(Fqn fqn, Reference referencingFqn, Object ob= j) + { + CachedArray cached =3D CachedArrayRegistry.lookup(obj); + if (cached !=3D null) { + util.detachArray(obj, cached); + cached.destroy(); + } + + return obj; + } + + @Override + protected boolean handles(Class clazz) + { + return clazz.isArray(); + } + +} Deleted: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Collec= tionClassHandler.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/CollectionClassHandl= er.java 2008-07-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/CollectionC= lassHandler.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,293 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ - -package org.jboss.cache.pojo.impl; - -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jboss.aop.proxy.ClassProxy; -import org.jboss.cache.Cache; -import org.jboss.cache.CacheException; -import org.jboss.cache.Fqn; -import org.jboss.cache.pojo.PojoCacheException; -import org.jboss.cache.pojo.collection.CollectionInterceptorUtil; -import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterce= ptor; -import org.jboss.cache.pojo.interceptors.dynamic.BaseInterceptor; - -/** - * Handling the Collection class management. Has no consideration of objec= t graph here. - * - * @author Ben Wang - * Date: Aug 4, 2005 - * @version $Id$ - */ -class CollectionClassHandler extends AbstractHandler -{ - private final Log log =3D LogFactory.getLog(CollectionClassHandler.clas= s); - private Cache cache_; - private PojoCacheImpl pCache_; - private InternalHelper internal_; - - public CollectionClassHandler(PojoCacheImpl pCache, InternalHelper inte= rnal) - { - pCache_ =3D pCache; - cache_ =3D pCache_.getCache(); - internal_ =3D internal; - } - - protected Fqn getFqn(Object collection) - { - if (! (collection instanceof ClassProxy)) - return null; - - BaseInterceptor interceptor =3D CollectionInterceptorUtil.getInterce= ptor((ClassProxy) collection); - return interceptor !=3D null ? interceptor.getFqn() : null; - } - - protected Object get(Fqn fqn, Class clazz, PojoInstance pojoInstance) - throws CacheException - { - Object obj =3D null; - try - { - if (Map.class.isAssignableFrom(clazz)) - { - Object map =3D clazz.newInstance(); - obj =3D CollectionInterceptorUtil.createMapProxy(pCache_, fqn,= clazz, (Map) map); - } - else if (List.class.isAssignableFrom(clazz)) - { - Object list =3D clazz.newInstance(); - obj =3D CollectionInterceptorUtil.createListProxy(pCache_, fqn= , clazz, (List) list); - } - else if (Set.class.isAssignableFrom(clazz)) - { - Object set =3D clazz.newInstance(); - obj =3D CollectionInterceptorUtil.createSetProxy(pCache_, fqn,= clazz, (Set) set); - } - } - catch (Exception e) - { - throw new CacheException("failure creating proxy", e); - } - - return obj; - } - - protected void put(Fqn fqn, Fqn referencingFqn, Object obj) throws Cach= eException - { - boolean isCollection =3D false; - - CachedType type =3D null; - if (obj instanceof ClassProxy) - { - throw new IllegalStateException("CollectionClassHandler.put(): ob= j is an ClassProxy instance " + obj); - } - - type =3D pCache_.getCachedType(obj.getClass()); - - //JBCACHE-760: for collection - put initialized aopInstance in fqn - if (!(obj instanceof Map || obj instanceof List || obj instanceof Se= t)) - { - return; - } - - // Always initialize the ref count so that we can mark this as an Ao= pNode. - PojoInstance pojoInstance =3D InternalHelper.initializeAopInstance(r= eferencingFqn); - pojoInstance.set(obj); - pojoInstance.setPojoClass(type.getType()); - cache_.put(fqn, PojoInstance.KEY, pojoInstance); - - if (obj instanceof Map) - { - if (log.isDebugEnabled()) - { - log.debug("collectionPutObject(): aspectized obj is a Map type= of size: " + ((Map) obj).size()); - } - - // Let's replace it with a proxy if necessary - Map map =3D (Map) obj; - if (!(obj instanceof ClassProxy)) - { - Class clazz =3D obj.getClass(); - try - { - obj =3D CollectionInterceptorUtil.createMapProxy(pCache_, f= qn, clazz, (Map) obj); - } - catch (Exception e) - { - throw new CacheException("failure creating proxy", e); - } - - checkMapRecursion(map, obj); - } - - isCollection =3D true; - // populate via the proxied collection - for (Iterator i =3D map.entrySet().iterator(); i.hasNext();) - { - Map.Entry entry =3D (Map.Entry) i.next(); - ((Map) obj).put(entry.getKey(), entry.getValue()); - } - - } - else if (obj instanceof List) - { - if (log.isDebugEnabled()) - { - log.debug("collectionPutObject(): aspectized obj is a List typ= e of size: " - + ((List) obj).size()); - } - - List list =3D (List) obj; - - // Let's replace it with a proxy if necessary - if (!(obj instanceof ClassProxy)) - { - Class clazz =3D obj.getClass(); - try - { - obj =3D CollectionInterceptorUtil.createListProxy(pCache_, = fqn, clazz, (List) obj); - } - catch (Exception e) - { - throw new CacheException("failure creating proxy", e); - } - - checkListRecursion(list, obj); - } - - isCollection =3D true; - // populate via the proxied collection - for (Iterator i =3D list.iterator(); i.hasNext();) - { - ((List) obj).add(i.next()); - } - - } - else if (obj instanceof Set) - { - if (log.isDebugEnabled()) - { - log.debug("collectionPutObject(): aspectized obj is a Set type= of size: " - + ((Set) obj).size()); - } - - Set set =3D (Set) obj; - - // Let's replace it with a proxy if necessary - if (!(obj instanceof ClassProxy)) - { - Class clazz =3D obj.getClass(); - try - { - obj =3D CollectionInterceptorUtil.createSetProxy(pCache_, f= qn, clazz, (Set) obj); - } - catch (Exception e) - { - throw new CacheException("failure creating proxy", e); - } - - checkSetRecursion(set, obj); - } - - isCollection =3D true; - // populate via the proxied collection - for (Iterator i =3D set.iterator(); i.hasNext();) - { - ((Set) obj).add(i.next()); - } - - } - - if (isCollection) - { - // Need to reset it here in case this is a new proxy instance - pojoInstance.set(obj); - // Attach pojoReference to that interceptor - BaseInterceptor baseInterceptor =3D (BaseInterceptor) CollectionI= nterceptorUtil.getInterceptor( - (ClassProxy) obj); - baseInterceptor.setAopInstance(pojoInstance); - } - } - - private void checkListRecursion(List list, Object obj) - { - while (true) - { - int i =3D list.indexOf(list); // check for recursion - if (i =3D=3D -1) break; - - list.remove(list); - list.add(i, obj); - } - } - - private void checkSetRecursion(Set set, Object obj) - { - if (set.remove(set)) - { - set.add(obj); // replace with proxy - throw new PojoCacheException("CollectionClassHandler.checkSetRecu= rsion(): " + - "detect a recursive set (e.g., set i= nside the same set). This will fail to " + - "replicate even outside of PojoCache= with HashSet. " + set); - } - } - - private void checkMapRecursion(Map map, Object obj) - { - Map m =3D java.util.Collections.unmodifiableMap(map); - - for (Object k : m.keySet()) - { - if (m =3D=3D k) - { - throw new PojoCacheException("CollectionClassHandler.checkMapR= ecursion(): " + - " Can't handle the recursion map = where it is nested in a constant key " + map); - } - - Object v =3D m.get(k); - if (v =3D=3D map) - { - throw new PojoCacheException("CollectionClassHandler.checkMapR= ecursion(): " + - "detect a recursive map (e.g., ma= p inside the same map). This will fail to " + - "replicate even outside of PojoCa= che with HashMap because of hashCode. " + map); - // recursion here, replace it with proxy -// map.put(k, obj); - } - } - } - - @Override - protected Object remove(Fqn fqn, Fqn referencingFqn, Object obj) = throws CacheException - { - if (!(obj instanceof ClassProxy)) - { - throw new PojoCacheException("CollectionClassHandler.collectionRe= moveObject(): object is not a proxy :" + obj); - } - - AbstractCollectionInterceptor interceptor =3D (AbstractCollectionInt= erceptor) CollectionInterceptorUtil.getInterceptor((ClassProxy) obj); - // detach the interceptor. This will trigger a copy and remove. - (new PojoUtil()).detachCollectionInterceptor(interceptor); - cache_.removeNode(fqn); - - return interceptor.getCurrentCopy(); - } - - - @Override - protected boolean handles(Class clazz) - { - return Collection.class.isAssignableFrom(clazz) || Map.class.isAssig= nableFrom(clazz); - } -} Copied: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Collect= ionClassHandler.java (from rev 6374, pojo/trunk/src/main/java/org/jboss/cac= he/pojo/impl/CollectionClassHandler.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/CollectionC= lassHandler.java (rev 0) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/CollectionC= lassHandler.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,290 @@ +/* + * JBoss, Home of Professional Open Source + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ + +package org.jboss.cache.pojo.impl; + +import java.util.*; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.aop.proxy.ClassProxy; +import org.jboss.cache.Cache; +import org.jboss.cache.CacheException; +import org.jboss.cache.Fqn; +import org.jboss.cache.pojo.PojoCacheException; +import org.jboss.cache.pojo.Reference; +import org.jboss.cache.pojo.collection.CollectionInterceptorUtil; +import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterce= ptor; +import org.jboss.cache.pojo.interceptors.dynamic.BaseInterceptor; + +/** + * Handling the Collection class management. Has no consideration of objec= t graph here. + * + * @author Ben Wang + * Date: Aug 4, 2005 + * @version $Id$ + */ +class CollectionClassHandler extends AbstractHandler +{ + private final Log log =3D LogFactory.getLog(CollectionClassHandler.clas= s); + private Cache cache_; + private PojoCacheImpl pCache_; + private InternalHelper internal_; + + public CollectionClassHandler(PojoCacheImpl pCache, InternalHelper inte= rnal) + { + pCache_ =3D pCache; + cache_ =3D pCache_.getCache(); + internal_ =3D internal; + } + + protected Fqn getFqn(Object collection) + { + if (! (collection instanceof ClassProxy)) + return null; + + BaseInterceptor interceptor =3D CollectionInterceptorUtil.getInterce= ptor((ClassProxy) collection); + return interceptor !=3D null ? interceptor.getFqn() : null; + } + + protected Object get(Fqn fqn, Class clazz, PojoInstance pojoInstance) + throws CacheException + { + Object obj =3D null; + try + { + if (Map.class.isAssignableFrom(clazz)) + { + Object map =3D clazz.newInstance(); + obj =3D CollectionInterceptorUtil.createMapProxy(pCache_, fqn,= clazz, (Map) map); + } + else if (List.class.isAssignableFrom(clazz)) + { + Object list =3D clazz.newInstance(); + obj =3D CollectionInterceptorUtil.createListProxy(pCache_, fqn= , clazz, (List) list); + } + else if (Set.class.isAssignableFrom(clazz)) + { + Object set =3D clazz.newInstance(); + obj =3D CollectionInterceptorUtil.createSetProxy(pCache_, fqn,= clazz, (Set) set); + } + } + catch (Exception e) + { + throw new CacheException("failure creating proxy", e); + } + + return obj; + } + + protected void put(Fqn fqn, Reference reference, Object obj) throws Cac= heException + { + boolean isCollection =3D false; + + CachedType type =3D null; + if (obj instanceof ClassProxy) + { + throw new IllegalStateException("CollectionClassHandler.put(): ob= j is an ClassProxy instance " + obj); + } + + type =3D pCache_.getCachedType(obj.getClass()); + + //JBCACHE-760: for collection - put initialized aopInstance in fqn + if (!(obj instanceof Map || obj instanceof List || obj instanceof Se= t)) + { + return; + } + + // Always initialize the ref count so that we can mark this as an Ao= pNode. + PojoInstance pojoInstance =3D InternalHelper.initializeAopInstance(r= eference); + pojoInstance.set(obj); + pojoInstance.setPojoClass(type.getType()); + cache_.put(fqn, PojoInstance.KEY, pojoInstance); + + if (obj instanceof Map) + { + if (log.isDebugEnabled()) + { + log.debug("collectionPutObject(): aspectized obj is a Map type= of size: " + ((Map) obj).size()); + } + + // Let's replace it with a proxy if necessary + Map map =3D (Map) obj; + if (!(obj instanceof ClassProxy)) + { + Class clazz =3D obj.getClass(); + try + { + obj =3D CollectionInterceptorUtil.createMapProxy(pCache_, f= qn, clazz, (Map) obj); + } + catch (Exception e) + { + throw new CacheException("failure creating proxy", e); + } + + checkMapRecursion(map, obj); + } + + isCollection =3D true; + // populate via the proxied collection + for (Iterator i =3D map.entrySet().iterator(); i.hasNext();) + { + Map.Entry entry =3D (Map.Entry) i.next(); + ((Map) obj).put(entry.getKey(), entry.getValue()); + } + + } + else if (obj instanceof List) + { + if (log.isDebugEnabled()) + { + log.debug("collectionPutObject(): aspectized obj is a List typ= e of size: " + + ((List) obj).size()); + } + + List list =3D (List) obj; + + // Let's replace it with a proxy if necessary + if (!(obj instanceof ClassProxy)) + { + Class clazz =3D obj.getClass(); + try + { + obj =3D CollectionInterceptorUtil.createListProxy(pCache_, = fqn, clazz, (List) obj); + } + catch (Exception e) + { + throw new CacheException("failure creating proxy", e); + } + + checkListRecursion(list, obj); + } + + isCollection =3D true; + // populate via the proxied collection + for (Iterator i =3D list.iterator(); i.hasNext();) + { + ((List) obj).add(i.next()); + } + + } + else if (obj instanceof Set) + { + if (log.isDebugEnabled()) + { + log.debug("collectionPutObject(): aspectized obj is a Set type= of size: " + + ((Set) obj).size()); + } + + Set set =3D (Set) obj; + + // Let's replace it with a proxy if necessary + if (!(obj instanceof ClassProxy)) + { + Class clazz =3D obj.getClass(); + try + { + obj =3D CollectionInterceptorUtil.createSetProxy(pCache_, f= qn, clazz, (Set) obj); + } + catch (Exception e) + { + throw new CacheException("failure creating proxy", e); + } + + checkSetRecursion(set, obj); + } + + isCollection =3D true; + // populate via the proxied collection + for (Iterator i =3D set.iterator(); i.hasNext();) + { + ((Set) obj).add(i.next()); + } + + } + + if (isCollection) + { + // Need to reset it here in case this is a new proxy instance + pojoInstance.set(obj); + // Attach pojoReference to that interceptor + BaseInterceptor baseInterceptor =3D (BaseInterceptor) CollectionI= nterceptorUtil.getInterceptor( + (ClassProxy) obj); + baseInterceptor.setAopInstance(pojoInstance); + } + } + + private void checkListRecursion(List list, Object obj) + { + while (true) + { + int i =3D list.indexOf(list); // check for recursion + if (i =3D=3D -1) break; + + list.remove(list); + list.add(i, obj); + } + } + + private void checkSetRecursion(Set set, Object obj) + { + if (set.remove(set)) + { + set.add(obj); // replace with proxy + throw new PojoCacheException("CollectionClassHandler.checkSetRecu= rsion(): " + + "detect a recursive set (e.g., set i= nside the same set). This will fail to " + + "replicate even outside of PojoCache= with HashSet. " + set); + } + } + + private void checkMapRecursion(Map map, Object obj) + { + Map m =3D java.util.Collections.unmodifiableMap(map); + + for (Object k : m.keySet()) + { + if (m =3D=3D k) + { + throw new PojoCacheException("CollectionClassHandler.checkMapR= ecursion(): " + + " Can't handle the recursion map = where it is nested in a constant key " + map); + } + + Object v =3D m.get(k); + if (v =3D=3D map) + { + throw new PojoCacheException("CollectionClassHandler.checkMapR= ecursion(): " + + "detect a recursive map (e.g., ma= p inside the same map). This will fail to " + + "replicate even outside of PojoCa= che with HashMap because of hashCode. " + map); + // recursion here, replace it with proxy +// map.put(k, obj); + } + } + } + + @Override + protected Object remove(Fqn fqn, Reference referencingFqn, Object ob= j) throws CacheException + { + if (!(obj instanceof ClassProxy)) + { + throw new PojoCacheException("CollectionClassHandler.collectionRe= moveObject(): object is not a proxy :" + obj); + } + + AbstractCollectionInterceptor interceptor =3D (AbstractCollectionInt= erceptor) CollectionInterceptorUtil.getInterceptor((ClassProxy) obj); + // detach the interceptor. This will trigger a copy and remove. + (new PojoUtil()).detachCollectionInterceptor(interceptor); + cache_.removeNode(fqn); + + return interceptor.getCurrentCopy(); + } + + + @Override + protected boolean handles(Class clazz) + { + return Collection.class.isAssignableFrom(clazz) || Map.class.isAssig= nableFrom(clazz); + } +} Deleted: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Intern= alHelper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalHelper.java = 2008-07-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/InternalHel= per.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,416 +0,0 @@ -/* - * JBoss, the OpenSource J2EE webOS - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package org.jboss.cache.pojo.impl; - -import java.util.Map; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jboss.cache.Cache; -import org.jboss.cache.CacheException; -import org.jboss.cache.Fqn; -import org.jboss.cache.lock.UpgradeException; -import org.jboss.cache.pojo.PojoCache; -import org.jboss.cache.pojo.PojoCacheException; -import org.jboss.cache.pojo.util.ObjectUtil; - -/** - * Internal helper class to handle internal cache sotre, that is, the port= ion that is not part of - * user's data. - * - * @author Ben Wang - */ -public class InternalHelper -{ - private static Log log =3D LogFactory.getLog(InternalHelper.class.getN= ame()); - - private Cache cache; - private PojoCache pcache; - - InternalHelper(PojoCache pcache) - { - this.cache =3D pcache.getCache(); - this.pcache =3D pcache; - } - - PojoInstance getPojoInstance(Fqn fqn) throws CacheException - { - return (PojoInstance) get(fqn, PojoInstance.KEY, true); - } - - PojoReference getPojoReference(Fqn fqn, String field) throws CacheExcep= tion - { - if (field =3D=3D null) - field =3D PojoReference.KEY; - - return (PojoReference) get(fqn, field, true); - } - - PojoReference getPojoReference(Fqn fqn) throws CacheException - { - return getPojoReference(fqn, null); - } - - - static PojoInstance initializeAopInstance(Fqn sourceFqn) - { - PojoInstance pojoInstance =3D new PojoInstance(); - - pojoInstance.incrementRefCount(sourceFqn); - return pojoInstance; - } - - /** - * Increment reference count for the pojo. Note that this is not thread= safe or atomic. - */ - int incrementRefCount(Fqn originalFqn, Fqn referencingFqn) throws Cache= Exception - { - PojoInstance pojoInstance =3D getPojoInstance(originalFqn); - if (pojoInstance =3D=3D null) - throw new PojoCacheException("InternalDelegate.incrementRefCount(= ): null pojoReference for fqn: " + originalFqn); - - int count =3D pojoInstance.incrementRefCount(referencingFqn); - // need to update it. - put(originalFqn, PojoInstance.KEY, pojoInstance); - return count; - } - - /** - * Has a delegate method so we can use the switch. - */ - - Object get(Fqn fqn, Object key) throws CacheException - { - return get(fqn, key, false); - } - - private Object get(Fqn fqn, Object key, boolean gravitate) throws Cache= Exception - { - // Only gravitate when we have to and only when the user has enabled= it - if (gravitate && pcache.getThreadContext().isGravitationEnabled()) - { - cache.getInvocationContext().getOptionOverrides().setForceDataGra= vitation(true); - Object obj =3D cache.get(fqn, key); - cache.getInvocationContext().getOptionOverrides().setForceDataGra= vitation(false); - return obj; - } - - return cache.get(fqn, key); - } - - private void put(Fqn fqn, Object key, Object value) throws CacheExcepti= on - { - cache.put(fqn, key, value); - } - - void put(Fqn fqn, Map map) throws CacheException - { - cache.put(fqn, map); - } - - - /** - * decrement reference count for the pojo. Note that this is not thread= safe or atomic. - */ - int decrementRefCount(Fqn originalFqn, Fqn referencingFqn) throws Cache= Exception - { - PojoInstance pojoInstance =3D getPojoInstance(originalFqn); - if (pojoInstance =3D=3D null) - throw new PojoCacheException("InternalDelegate.decrementRefCount(= ): null pojoReference."); - - int count =3D pojoInstance.decrementRefCount(referencingFqn); - - if (count < -1) // can't dip below -1 - throw new PojoCacheException("InternalDelegate.decrementRefCount(= ): null pojoReference."); - - // need to update it. - put(originalFqn, PojoInstance.KEY, pojoInstance); - return count; - } - - static boolean isReferenced(PojoInstance pojoInstance) - { - // If ref counter is greater than 0, we fqn is being referenced. - return (pojoInstance.getRefCount() > 0); - } - - int getRefCount(Fqn fqn) throws CacheException - { - return getPojoInstance(fqn).getRefCount(); - } - - String XgetRefFqn(Fqn fqn) throws CacheException - { - PojoInstance pojoInstance =3D getPojoInstance(fqn); - return getRefFqn(pojoInstance); - } - - String getRefFqn(PojoInstance pojoInstance) throws CacheException - { - if (pojoInstance =3D=3D null) - return null; - - String aliasFqn =3D pojoInstance.getInternalFqn(); - - if (aliasFqn =3D=3D null || aliasFqn.length() =3D=3D 0) return null; - - return getRefFqnFromAlias(aliasFqn); - } - - void setRefFqn(Fqn fqn, String internalFqn) throws CacheException - { - PojoInstance pojoInstance =3D getPojoInstance(fqn); - if (pojoInstance =3D=3D null) - pojoInstance =3D new PojoInstance(); - - pojoInstance.setInternalFqn(internalFqn); - put(fqn, PojoInstance.KEY, pojoInstance); - } - - void removeRefFqn(Fqn fqn) throws CacheException - { - PojoInstance pojoInstance =3D getPojoInstance(fqn); - if (pojoInstance =3D=3D null) - throw new PojoCacheException("InternalDelegate.getInternalFqn(): = null pojoReference."); - - pojoInstance.removeInternalFqn(); - put(fqn, PojoInstance.KEY, pojoInstance); - } - - Object getPojo(Fqn fqn, String field) throws CacheException - { - PojoReference pojoReference =3D getPojoReference(fqn, field); - Fqn realFqn =3D null; - if (pojoReference !=3D null) - { - // This is outward facing node - realFqn =3D pojoReference.getFqn(); - } - else - { - // If we are looking for a field then there must be a reference - if (field !=3D null) - return null; - - // This is the internal node. - realFqn =3D fqn; - } - - PojoInstance pojoInstance =3D getPojoInstance(realFqn); - if (pojoInstance =3D=3D null) - return null; - - return pojoInstance.get(); - } - - void setPojo(Fqn fqn, Object pojo) throws CacheException - { - PojoInstance pojoInstance =3D getPojoInstance(fqn); - if (pojoInstance =3D=3D null) - { - pojoInstance =3D new PojoInstance(); - put(fqn, PojoInstance.KEY, pojoInstance); - } - - pojoInstance.set(pojo); - // No need to do a cache put since pojo is transient anyway. - } - - static boolean isMultipleReferenced(PojoInstance pojoInstance) - { - if (pojoInstance.getRefCount() > (PojoInstance.INITIAL_COUNTER_VALUE= + 1)) return true; - - return false; - } - - static void setPojo(PojoInstance pojoInstance, Object pojo) - { - // No need to do a cache put since pojo is transient anyway. - pojoInstance.set(pojo); - } - - void setPojo(Fqn fqn, Object pojo, PojoInstance pojoInstance) throws Ca= cheException - { - if (pojoInstance =3D=3D null) - { - pojoInstance =3D new PojoInstance(); - put(fqn, PojoInstance.KEY, pojoInstance); - } - - pojoInstance.set(pojo); - // No need to do a cache put since pojo is transient anyway. - } - - void putPojoReference(Fqn fqn, PojoReference pojoReference) throws Cach= eException - { - putPojoReference(fqn, pojoReference, PojoReference.KEY); - } - - void putPojoReference(Fqn fqn, PojoReference pojoReference, String fiel= d) throws CacheException - { - if (field =3D=3D null) - field =3D PojoReference.KEY; - - put(fqn, field, pojoReference); - } - - void putAopClazz(Fqn fqn, Class clazz) throws CacheException - { - put(fqn, InternalConstant.CLASS_INTERNAL, clazz); - } - - /** - * We store the class name in string and put it in map instead of direc= tly putting - * it into cache for optimization. - */ - static void putAopClazz(Class clazz, Map map) - { - map.put(InternalConstant.CLASS_INTERNAL, clazz); - } - - Class peekAopClazz(Fqn fqn) throws CacheException - { - return (Class) get(fqn, InternalConstant.CLASS_INTERNAL); - } - - void removeInternalAttributes(Fqn fqn) throws CacheException - { - cache.remove(fqn, PojoInstance.KEY); - cache.remove(fqn, InternalConstant.CLASS_INTERNAL); - } - - void cleanUp(Fqn fqn, String field) throws CacheException - { - if (field !=3D null) - { - cache.remove(fqn, field); - return; - } - - // We can't do a brute force remove anymore? - if (cache.getRoot().getChild(fqn).getChildren().size() =3D=3D 0) - { - // remove everything - cache.removeNode(fqn); -// cache_.getRoot().getChild(fqn).clearData(); -// removeNodeWithoutInterceptor(fqn); - } - else - { - // Assume everything here is all PojoCache data for optimization - cache.getRoot().getChild(fqn).clearData(); - if (log.isTraceEnabled()) - { - log.trace("cleanup(): fqn: " + fqn + " is not empty. That mean= s it has sub-pojos. Will not remove node"); - } - } - } - - String createIndirectFqn(String fqn) throws CacheException - { - String indirectFqn =3D getIndirectFqn(fqn); - Fqn internalFqn =3D getInternalFqn(fqn); - put(internalFqn, indirectFqn, fqn); - return indirectFqn; - } - - private Fqn getInternalFqn(String fqn) - { - if (fqn =3D=3D null || fqn.length() =3D=3D 0) - throw new IllegalStateException("InternalDelegate.getInternalFqn(= ). fqn is either null or empty!"); - - String indirectFqn =3D getIndirectFqn(fqn); - return new Fqn(InternalConstant.JBOSS_INTERNAL_MAP, indirectFqn); -// return JBOSS_INTERNAL_MAP; - } - - static String getIndirectFqn(String fqn) - { - // TODO This is not unique. Will need to come up with a better one i= n the future. - return ObjectUtil.getIndirectFqn(fqn); - } - - void removeIndirectFqn(String oldFqn) throws CacheException - { - String indirectFqn =3D getIndirectFqn(oldFqn); - cache.remove(getInternalFqn(oldFqn), indirectFqn); - } - - void setIndirectFqn(String oldFqn, String newFqn) throws CacheException - { - String indirectFqn =3D getIndirectFqn(oldFqn); - Fqn tmpFqn =3D getInternalFqn(oldFqn); - put(tmpFqn, indirectFqn, newFqn); - } - - void updateIndirectFqn(Fqn originalFqn, Fqn newFqn) throws CacheExcepti= on - { - put(getInternalFqn(originalFqn.toString()), getIndirectFqn(originalF= qn.toString()), newFqn.toString()); - } - - private String getRefFqnFromAlias(String aliasFqn) throws CacheException - { - return (String) get(getInternalFqn(aliasFqn), aliasFqn, true); - } - - Fqn getNextFqnInLine(Fqn currentFqn) throws CacheException - { - PojoInstance ai =3D getPojoInstance(currentFqn); - return ai.getAndRemoveFirstFqnInList(); - } - - /** - * Test if this internal node. - * - * @param fqn - */ - public static boolean isInternalNode(Fqn fqn) - { - // we ignore all the node events corresponding to JBOSS_INTERNAL - if (fqn.isChildOrEquals(InternalConstant.JBOSS_INTERNAL)) return tru= e; - - return false; - } - - public boolean lockPojo(Fqn id) throws CacheException - { - final int RETRY =3D 5; - - if (log.isDebugEnabled()) - log.debug("lockPojo(): id:" + id); - - boolean isNeeded =3D true; - int retry =3D 0; - - while (isNeeded) - { - try - { - cache.put(id, InternalConstant.POJOCACHE_LOCK, "LOCK"); - isNeeded =3D false; - } - catch (UpgradeException upe) - { - log.warn("lockPojo(): can't upgrade the lock during lockPojo. = Will re-try. id: " + id - + " retry times: " + retry); - if (retry++ > RETRY) - return false; - - // try to sleep a little as well. - try - { - Thread.sleep(10); - } - catch (InterruptedException e) - { - } - } - } - - return true; - } -} \ No newline at end of file Copied: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Interna= lHelper.java (from rev 6374, pojo/trunk/src/main/java/org/jboss/cache/pojo/= impl/InternalHelper.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/InternalHel= per.java (rev 0) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/InternalHel= per.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,365 @@ +/* + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.cache.pojo.impl; + +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.cache.*; +import org.jboss.cache.lock.UpgradeException; +import org.jboss.cache.pojo.*; +import org.jboss.cache.pojo.util.ObjectUtil; + +/** + * Internal helper class to handle internal cache sotre, that is, the port= ion that is not part of + * user's data. + * + * @author Ben Wang + */ +public class InternalHelper +{ + private static Log log =3D LogFactory.getLog(InternalHelper.class.getN= ame()); + + private Cache cache; + private PojoCache pcache; + + InternalHelper(PojoCache pcache) + { + this.cache =3D pcache.getCache(); + this.pcache =3D pcache; + } + + PojoInstance getPojoInstance(Fqn fqn) throws CacheException + { + return (PojoInstance) get(fqn, PojoInstance.KEY, true); + } + + PojoReference getPojoReference(Fqn fqn, String field) throws CacheExcep= tion + { + if (field =3D=3D null) + field =3D PojoReference.KEY; + + return (PojoReference) get(fqn, field, true); + } + + PojoReference getPojoReference(Fqn fqn) throws CacheException + { + return getPojoReference(fqn, null); + } + + + static PojoInstance initializeAopInstance(Reference reference) + { + PojoInstance pojoInstance =3D new PojoInstance(); + + pojoInstance.incrementRefCount(reference); + return pojoInstance; + } + + /** + * Increment reference count for the pojo. Note that this is not thread= safe or atomic. + * @param reference TODO + */ + int incrementRefCount(Fqn originalFqn, Reference reference) throws Cach= eException + { + PojoInstance pojoInstance =3D getPojoInstance(originalFqn); + if (pojoInstance =3D=3D null) + throw new PojoCacheException("InternalDelegate.incrementRefCount(= ): null pojoReference for fqn: " + originalFqn); + + int count =3D pojoInstance.incrementRefCount(reference); + // need to update it. + put(originalFqn, PojoInstance.KEY, pojoInstance); + return count; + } + + /** + * Has a delegate method so we can use the switch. + */ + + Object get(Fqn fqn, Object key) throws CacheException + { + return get(fqn, key, false); + } + + private Object get(Fqn fqn, Object key, boolean gravitate) throws Cache= Exception + { + // Only gravitate when we have to and only when the user has enabled= it + if (gravitate && pcache.getThreadContext().isGravitationEnabled()) + { + cache.getInvocationContext().getOptionOverrides().setForceDataGra= vitation(true); + Object obj =3D cache.get(fqn, key); + cache.getInvocationContext().getOptionOverrides().setForceDataGra= vitation(false); + return obj; + } + + return cache.get(fqn, key); + } + + private void put(Fqn fqn, Object key, Object value) throws CacheExcepti= on + { + cache.put(fqn, key, value); + } + + void put(Fqn fqn, Map map) throws CacheException + { + cache.put(fqn, map); + } + + + /** + * decrement reference count for the pojo. Note that this is not thread= safe or atomic. + */ + int decrementRefCount(Fqn originalFqn, Reference reference) throws Cach= eException + { + PojoInstance pojoInstance =3D getPojoInstance(originalFqn); + if (pojoInstance =3D=3D null) + throw new PojoCacheException("InternalDelegate.decrementRefCount(= ): null pojoReference."); + + int count =3D pojoInstance.decrementRefCount(reference); + + if (count < -1) // can't dip below -1 + throw new PojoCacheException("InternalDelegate.decrementRefCount(= ): null pojoReference."); + + // need to update it. + put(originalFqn, PojoInstance.KEY, pojoInstance); + return count; + } + + static boolean isReferenced(PojoInstance pojoInstance) + { + // If ref counter is greater than 0, we fqn is being referenced. + return (pojoInstance.getRefCount() > 0); + } + + Object getPojo(Fqn fqn, String field) throws CacheException + { + PojoReference pojoReference =3D getPojoReference(fqn, field); + Fqn realFqn =3D null; + if (pojoReference !=3D null) + { + // This is outward facing node + realFqn =3D pojoReference.getFqn(); + } + else + { + // If we are looking for a field then there must be a reference + if (field !=3D null) + return null; + + // This is the internal node. + realFqn =3D fqn; + } + + PojoInstance pojoInstance =3D getPojoInstance(realFqn); + if (pojoInstance =3D=3D null) + return null; + + return pojoInstance.get(); + } + + void setPojo(Fqn fqn, Object pojo) throws CacheException + { + PojoInstance pojoInstance =3D getPojoInstance(fqn); + if (pojoInstance =3D=3D null) + { + pojoInstance =3D new PojoInstance(); + put(fqn, PojoInstance.KEY, pojoInstance); + } + + pojoInstance.set(pojo); + // No need to do a cache put since pojo is transient anyway. + } + + static boolean isMultipleReferenced(PojoInstance pojoInstance) + { + if (pojoInstance.getRefCount() > (PojoInstance.INITIAL_COUNTER_VALUE= + 1)) return true; + + return false; + } + + static void setPojo(PojoInstance pojoInstance, Object pojo) + { + // No need to do a cache put since pojo is transient anyway. + pojoInstance.set(pojo); + } + + void setPojo(Fqn fqn, Object pojo, PojoInstance pojoInstance) throws Ca= cheException + { + if (pojoInstance =3D=3D null) + { + pojoInstance =3D new PojoInstance(); + put(fqn, PojoInstance.KEY, pojoInstance); + } + + pojoInstance.set(pojo); + // No need to do a cache put since pojo is transient anyway. + } + + void putPojoReference(Fqn fqn, PojoReference pojoReference) throws Cach= eException + { + putPojoReference(fqn, pojoReference, PojoReference.KEY); + } + + void putPojoReference(Fqn fqn, PojoReference pojoReference, String fiel= d) throws CacheException + { + if (field =3D=3D null) + field =3D PojoReference.KEY; + + put(fqn, field, pojoReference); + } + + void putAopClazz(Fqn fqn, Class clazz) throws CacheException + { + put(fqn, InternalConstant.CLASS_INTERNAL, clazz); + } + + /** + * We store the class name in string and put it in map instead of direc= tly putting + * it into cache for optimization. + */ + static void putAopClazz(Class clazz, Map map) + { + map.put(InternalConstant.CLASS_INTERNAL, clazz); + } + + Class peekAopClazz(Fqn fqn) throws CacheException + { + return (Class) get(fqn, InternalConstant.CLASS_INTERNAL); + } + + void removeInternalAttributes(Fqn fqn) throws CacheException + { + cache.remove(fqn, PojoInstance.KEY); + cache.remove(fqn, InternalConstant.CLASS_INTERNAL); + } + + void cleanUp(Fqn fqn, String field) throws CacheException + { + if (field !=3D null) + { + cache.remove(fqn, field); + return; + } + + // We can't do a brute force remove anymore? + if (cache.getRoot().getChild(fqn).getChildren().size() =3D=3D 0) + { + // remove everything + cache.removeNode(fqn); +// cache_.getRoot().getChild(fqn).clearData(); +// removeNodeWithoutInterceptor(fqn); + } + else + { + // Assume everything here is all PojoCache data for optimization + cache.getRoot().getChild(fqn).clearData(); + if (log.isTraceEnabled()) + { + log.trace("cleanup(): fqn: " + fqn + " is not empty. That mean= s it has sub-pojos. Will not remove node"); + } + } + } + + String createIndirectFqn(String fqn) throws CacheException + { + String indirectFqn =3D getIndirectFqn(fqn); + Fqn internalFqn =3D getInternalFqn(fqn); + put(internalFqn, indirectFqn, fqn); + return indirectFqn; + } + + private Fqn getInternalFqn(String fqn) + { + if (fqn =3D=3D null || fqn.length() =3D=3D 0) + throw new IllegalStateException("InternalDelegate.getInternalFqn(= ). fqn is either null or empty!"); + + String indirectFqn =3D getIndirectFqn(fqn); + return new Fqn(InternalConstant.JBOSS_INTERNAL_MAP, indirectFqn); +// return JBOSS_INTERNAL_MAP; + } + + static String getIndirectFqn(String fqn) + { + // TODO This is not unique. Will need to come up with a better one i= n the future. + return ObjectUtil.getIndirectFqn(fqn); + } + + void removeIndirectFqn(String oldFqn) throws CacheException + { + String indirectFqn =3D getIndirectFqn(oldFqn); + cache.remove(getInternalFqn(oldFqn), indirectFqn); + } + + void setIndirectFqn(String oldFqn, String newFqn) throws CacheException + { + String indirectFqn =3D getIndirectFqn(oldFqn); + Fqn tmpFqn =3D getInternalFqn(oldFqn); + put(tmpFqn, indirectFqn, newFqn); + } + + void updateIndirectFqn(Fqn originalFqn, Fqn newFqn) throws CacheExcepti= on + { + put(getInternalFqn(originalFqn.toString()), getIndirectFqn(originalF= qn.toString()), newFqn.toString()); + } + + private String getRefFqnFromAlias(String aliasFqn) throws CacheException + { + return (String) get(getInternalFqn(aliasFqn), aliasFqn, true); + } + + /** + * Test if this internal node. + * + * @param fqn + */ + public static boolean isInternalNode(Fqn fqn) + { + // we ignore all the node events corresponding to JBOSS_INTERNAL + if (fqn.isChildOrEquals(InternalConstant.JBOSS_INTERNAL)) return tru= e; + + return false; + } + + public boolean lockPojo(Fqn id) throws CacheException + { + final int RETRY =3D 5; + + if (log.isDebugEnabled()) + log.debug("lockPojo(): id:" + id); + + boolean isNeeded =3D true; + int retry =3D 0; + + while (isNeeded) + { + try + { + cache.put(id, InternalConstant.POJOCACHE_LOCK, "LOCK"); + isNeeded =3D false; + } + catch (UpgradeException upe) + { + log.warn("lockPojo(): can't upgrade the lock during lockPojo. = Will re-try. id: " + id + + " retry times: " + retry); + if (retry++ > RETRY) + return false; + + // try to sleep a little as well. + try + { + Thread.sleep(10); + } + catch (InterruptedException e) + { + } + } + } + + return true; + } +} \ No newline at end of file Deleted: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Method= Declarations.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/MethodDeclarations.j= ava 2008-07-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/MethodDecla= rations.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,88 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ - -package org.jboss.cache.pojo.impl; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.List; - -import org.jboss.aop.InstanceAdvisor; -import org.jboss.aop.advice.Interceptor; -import org.jboss.cache.Fqn; -import org.jboss.cache.pojo.collection.CachedArray; -import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterce= ptor; - -/** - * Method declarations for rollback method mostly. - * - * @author Ben Wang - * @version $Revision$ - */ -public class MethodDeclarations -{ - public static final Method attachInterceptor; - public static final Method detachInterceptor; - public static final Method detachCollectionInterceptor; - public static final Method undoAttachInterceptor; - public static final Method undoDetachInterceptor; - public static final Method undoDetachCollectionInterceptor; - ; - public static final Method inMemorySubstitution; - ; - public static final Method undoInMemorySubstitution; - ; - public static final Method incrementReferenceCount; - public static final Method decrementReferenceCount; - public static final Method undoIncrementReferenceCount; - public static final Method undoDecrementReferenceCount; - public static final Method attachArray; - public static final Method detachArray; - public static final Method undoAttachArray; - public static final Method undoDetachArray; - - static - { - try - { - attachInterceptor =3D PojoUtil.class.getDeclaredMethod("attachInt= erceptor", - new Class[]{= Object.class, InstanceAdvisor.class, Interceptor.class}); - detachInterceptor =3D PojoUtil.class.getDeclaredMethod("detachInt= erceptor", - new Class[]{= InstanceAdvisor.class, Interceptor.class}); - detachCollectionInterceptor =3D PojoUtil.class.getDeclaredMethod(= "detachCollectionInterceptor", - new Class[]{AbstractCollectionInterceptor.class}); - - undoAttachInterceptor =3D PojoUtil.class.getDeclaredMethod("undoA= ttachInterceptor", - new Clas= s[]{Object.class, InstanceAdvisor.class, Interceptor.class}); - undoDetachInterceptor =3D PojoUtil.class.getDeclaredMethod("undoD= etachInterceptor", - new Clas= s[]{InstanceAdvisor.class, Interceptor.class}); - undoDetachCollectionInterceptor =3D PojoUtil.class.getDeclaredMet= hod("undoDetachCollectionInterceptor", - new Class[]{AbstractCollectionInterceptor.class}); - inMemorySubstitution =3D PojoUtil.class.getDeclaredMethod("inMemo= rySubstitution", - new Class= []{Object.class, Field.class, Object.class}); - undoInMemorySubstitution =3D PojoUtil.class.getDeclaredMethod("un= doInMemorySubstitution", - new C= lass[]{Object.class, Field.class, Object.class}); - incrementReferenceCount =3D PojoUtil.class.getDeclaredMethod("inc= rementReferenceCount", - new Cl= ass[]{Fqn.class, int.class, List.class}); - decrementReferenceCount =3D PojoUtil.class.getDeclaredMethod("dec= rementReferenceCount", - new Cl= ass[]{Fqn.class, int.class, List.class}); - undoIncrementReferenceCount =3D PojoUtil.class.getDeclaredMethod(= "undoIncrementReferenceCount", - ne= w Class[]{Fqn.class, int.class, List.class}); - undoDecrementReferenceCount =3D PojoUtil.class.getDeclaredMethod(= "undoDecrementReferenceCount", - ne= w Class[]{Fqn.class, int.class, List.class}); - - attachArray =3D PojoUtil.class.getDeclaredMethod("attachArray", n= ew Class[]{Object.class, CachedArray.class}); - detachArray =3D PojoUtil.class.getDeclaredMethod("detachArray", n= ew Class[]{Object.class, CachedArray.class}); - undoAttachArray =3D PojoUtil.class.getDeclaredMethod("undoAttachA= rray", new Class[]{Object.class, CachedArray.class}); - undoDetachArray =3D PojoUtil.class.getDeclaredMethod("undoDetachA= rray", new Class[]{Object.class, CachedArray.class}); - } - catch (NoSuchMethodException e) - { - throw new ExceptionInInitializerError(e); - } - } -} Copied: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/MethodD= eclarations.java (from rev 6374, pojo/trunk/src/main/java/org/jboss/cache/p= ojo/impl/MethodDeclarations.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/MethodDecla= rations.java (rev 0) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/MethodDecla= rations.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,88 @@ +/* + * JBoss, Home of Professional Open Source + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ + +package org.jboss.cache.pojo.impl; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.Set; + +import org.jboss.aop.InstanceAdvisor; +import org.jboss.aop.advice.Interceptor; +import org.jboss.cache.pojo.Reference; +import org.jboss.cache.pojo.collection.CachedArray; +import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterce= ptor; + +/** + * Method declarations for rollback method mostly. + * + * @author Ben Wang + * @version $Revision$ + */ +public class MethodDeclarations +{ + public static final Method attachInterceptor; + public static final Method detachInterceptor; + public static final Method detachCollectionInterceptor; + public static final Method undoAttachInterceptor; + public static final Method undoDetachInterceptor; + public static final Method undoDetachCollectionInterceptor; + ; + public static final Method inMemorySubstitution; + ; + public static final Method undoInMemorySubstitution; + ; + public static final Method incrementReferenceCount; + public static final Method decrementReferenceCount; + public static final Method undoIncrementReferenceCount; + public static final Method undoDecrementReferenceCount; + public static final Method attachArray; + public static final Method detachArray; + public static final Method undoAttachArray; + public static final Method undoDetachArray; + + static + { + try + { + attachInterceptor =3D PojoUtil.class.getDeclaredMethod("attachInt= erceptor", + new Class[]{= Object.class, InstanceAdvisor.class, Interceptor.class}); + detachInterceptor =3D PojoUtil.class.getDeclaredMethod("detachInt= erceptor", + new Class[]{= InstanceAdvisor.class, Interceptor.class}); + detachCollectionInterceptor =3D PojoUtil.class.getDeclaredMethod(= "detachCollectionInterceptor", + new Class[]{AbstractCollectionInterceptor.class}); + + undoAttachInterceptor =3D PojoUtil.class.getDeclaredMethod("undoA= ttachInterceptor", + new Clas= s[]{Object.class, InstanceAdvisor.class, Interceptor.class}); + undoDetachInterceptor =3D PojoUtil.class.getDeclaredMethod("undoD= etachInterceptor", + new Clas= s[]{InstanceAdvisor.class, Interceptor.class}); + undoDetachCollectionInterceptor =3D PojoUtil.class.getDeclaredMet= hod("undoDetachCollectionInterceptor", + new Class[]{AbstractCollectionInterceptor.class}); + inMemorySubstitution =3D PojoUtil.class.getDeclaredMethod("inMemo= rySubstitution", + new Class= []{Object.class, Field.class, Object.class}); + undoInMemorySubstitution =3D PojoUtil.class.getDeclaredMethod("un= doInMemorySubstitution", + new C= lass[]{Object.class, Field.class, Object.class}); + incrementReferenceCount =3D PojoUtil.class.getDeclaredMethod("inc= rementReferenceCount", + new Cl= ass[]{Reference.class, int.class, Set.class}); + decrementReferenceCount =3D PojoUtil.class.getDeclaredMethod("dec= rementReferenceCount", + new Cl= ass[]{Reference.class, int.class, Set.class}); + undoIncrementReferenceCount =3D PojoUtil.class.getDeclaredMethod(= "undoIncrementReferenceCount", + ne= w Class[]{Reference.class, int.class, Set.class}); + undoDecrementReferenceCount =3D PojoUtil.class.getDeclaredMethod(= "undoDecrementReferenceCount", + ne= w Class[]{Reference.class, int.class, Set.class}); + + attachArray =3D PojoUtil.class.getDeclaredMethod("attachArray", n= ew Class[]{Object.class, CachedArray.class}); + detachArray =3D PojoUtil.class.getDeclaredMethod("detachArray", n= ew Class[]{Object.class, CachedArray.class}); + undoAttachArray =3D PojoUtil.class.getDeclaredMethod("undoAttachA= rray", new Class[]{Object.class, CachedArray.class}); + undoDetachArray =3D PojoUtil.class.getDeclaredMethod("undoDetachA= rray", new Class[]{Object.class, CachedArray.class}); + } + catch (NoSuchMethodException e) + { + throw new ExceptionInInitializerError(e); + } + } +} Deleted: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Notifi= cationDispatcher.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/NotificationDispatch= er.java 2008-07-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Notificatio= nDispatcher.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,268 +0,0 @@ -/* -* JBoss, Home of Professional Open Source -* Copyright 2005, JBoss Inc., and individual contributors as indicated -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* This is free software; you can redistribute it and/or modify it -* under the terms of the GNU Lesser General Public License as -* published by the Free Software Foundation; either version 2.1 of -* the License, or (at your option) any later version. -* -* This software is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this software; if not, write to the Free -* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -* 02110-1301 USA, or see the FSF site: http://www.fsf.org. -*/ - -package org.jboss.cache.pojo.impl; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.CopyOnWriteArraySet; -import java.util.regex.Pattern; - -import org.jboss.cache.Fqn; -import org.jboss.cache.pojo.PojoCacheException; -import org.jboss.cache.pojo.notification.annotation.ArrayModified; -import org.jboss.cache.pojo.notification.annotation.Attached; -import org.jboss.cache.pojo.notification.annotation.Detached; -import org.jboss.cache.pojo.notification.annotation.FieldModified; -import org.jboss.cache.pojo.notification.annotation.ListModified; -import org.jboss.cache.pojo.notification.annotation.MapModified; -import org.jboss.cache.pojo.notification.annotation.PojoCacheListener; -import org.jboss.cache.pojo.notification.annotation.SetModified; -import org.jboss.cache.pojo.notification.annotation.TransactionCompleted; -import org.jboss.cache.pojo.notification.annotation.TransactionRegistered; -import org.jboss.cache.pojo.notification.event.ArrayModifiedEvent; -import org.jboss.cache.pojo.notification.event.AttachedEvent; -import org.jboss.cache.pojo.notification.event.DetachedEvent; -import org.jboss.cache.pojo.notification.event.Event; -import org.jboss.cache.pojo.notification.event.FieldModifiedEvent; -import org.jboss.cache.pojo.notification.event.ListModifiedEvent; -import org.jboss.cache.pojo.notification.event.MapModifiedEvent; -import org.jboss.cache.pojo.notification.event.SetModifiedEvent; -import org.jboss.cache.pojo.notification.event.TransactionCompletedEvent; -import org.jboss.cache.pojo.notification.event.TransactionRegisteredEvent; - -// $Id$ - -/** - * Dispatches notification events to POJO cache listeners. - * - * @author Jason T. Greene - * @revision $Id$ - */ -class NotificationDispatcher -{ - private final static Map, Class> annotations =3D new HashMap, Class>(); - private final Set listeners =3D new CopyOnWriteArraySet(); - private Set filteredListeners =3D new HashSet(); - private volatile boolean hasFilters; - - static - { - annotations.put(Attached.class, AttachedEvent.class); - annotations.put(Detached.class, DetachedEvent.class); - annotations.put(FieldModified.class, FieldModifiedEvent.class); - annotations.put(ListModified.class, ListModifiedEvent.class); - annotations.put(MapModified.class, MapModifiedEvent.class); - annotations.put(SetModified.class, SetModifiedEvent.class); - annotations.put(ArrayModified.class, ArrayModifiedEvent.class); - annotations.put(TransactionRegistered.class, TransactionRegisteredEv= ent.class); - annotations.put(TransactionCompleted.class, TransactionCompletedEven= t.class); - } - - final static class Entry - { - private final Object listener; - private final Pattern pattern; - private final Map, List> notifiers; - - private Entry(Object listener, boolean build) - { - this(listener, build, null); - } - - private Entry(Object listener, boolean build, Pattern pattern) - { - if (listener =3D=3D null) - throw new IllegalArgumentException("Listener can't be null"); - - this.listener =3D listener; - this.pattern =3D pattern; - - this.notifiers =3D build ? buildNotifiers(listener.getClass()) : = null; - } - - // equality is confined to listener - public int hashCode() - { - return listener.hashCode(); - } - - // equality is confined to listener - public boolean equals(Object o) - { - if (o =3D=3D this) - return true; - if (! (o instanceof Entry)) - return false; - - // Must be the same instance - return ((Entry)o).listener =3D=3D this.listener; - } - - private static Map, List> buildNotifiers(Class claz= z) - { - if (! Modifier.isPublic(clazz.getModifiers())) - throw new IllegalArgumentException("Listener must be public! C= lass:" + clazz.getName()); - - if (! clazz.isAnnotationPresent(PojoCacheListener.class)) - throw new IllegalArgumentException("Not a listener, class did = not contain @PojoCacheListener. Class: " + clazz.getName()); - - - Map, List> notifiers =3D new HashMap, L= ist>(); - for (Method method : clazz.getMethods()) - { - for (Annotation annotation : method.getAnnotations()) - { - Class event =3D annotations.get(annotation= .annotationType()); - if (event =3D=3D null) - continue; - - Class[] types =3D method.getParameterTypes(); - if (types.length !=3D 1 || !types[0].isAssignableFrom(event= )) - { - throw new IllegalArgumentException("Listener has invlaid= method signature for annotation. " + - "Method: \"" + method.getName() + "\" " + - "Annotation: \"" + annotation.annotationType().get= SimpleName() + "\" " + - "Expected Parameter: \"" + event.getSimpleName() += "\""); - } - - List list =3D notifiers.get(event); - if (list =3D=3D null) - { - list =3D new ArrayList(); - notifiers.put(event, list); - } - - list.add(method); - } - } - - return notifiers; - } - } - - void add(Object listener) - { - listeners.add(new Entry(listener, true)); - } - - // gaurds filteredListeners - synchronized void add(Object listener, Pattern pattern) - { - listeners.add(new Entry(listener, true, pattern)); - filteredListeners.add(listener); - hasFilters =3D true; - } - - // gaurds filteredListeners - synchronized void remove(Object listener) - { - filteredListeners.remove(listener); - if (filteredListeners.size() =3D=3D 0) - hasFilters =3D false; - listeners.remove(new Entry(listener, false)); - } - - boolean hasFilters() - { - return hasFilters; - } - - Set getListeners() - { - Set set =3D new HashSet(); - for (Entry entry : listeners) - set.add(entry.listener); - - return Collections.unmodifiableSet(set); - } - - Set getListenerEntries(List fqns) - { - Set set =3D new HashSet(); - for (Entry entry : listeners) - { - if (entry.pattern =3D=3D null) - { - set.add(entry); - continue; - } - - for (Fqn fqn : fqns) - { - if (entry.pattern.matcher(fqn.toString()).matches()) - { - set.add(entry); - break; - } - } - } - - return set; - } - - boolean isEmpty() - { - return listeners.size() =3D=3D 0; - } - - void dispatch(Event notification) - { - for (Entry entry : listeners) - { - // Prevent dispatch to filtered entries - if (entry.pattern =3D=3D null) - dispatch(notification, entry); - } - } - - void dispatch(Event notification, Set listeners) - { - for (Entry listener : listeners) - dispatch(notification, listener); - } - - private void dispatch(Event notification, Entry entry) - { - List methods =3D entry.notifiers.get(notification.getClass()= ); - if (methods =3D=3D null) - return; - - try - { - for (Method method : methods) - method.invoke(entry.listener, notification); - } - catch (Exception e) - { - throw new PojoCacheException(e); - } - } -} Copied: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Notific= ationDispatcher.java (from rev 6551, pojo/trunk/src/main/java/org/jboss/cac= he/pojo/impl/NotificationDispatcher.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Notificatio= nDispatcher.java (rev 0) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Notificatio= nDispatcher.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,263 @@ +/* +* JBoss, Home of Professional Open Source +* Copyright 2005, JBoss Inc., and individual contributors as indicated +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* This is free software; you can redistribute it and/or modify it +* under the terms of the GNU Lesser General Public License as +* published by the Free Software Foundation; either version 2.1 of +* the License, or (at your option) any later version. +* +* This software is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this software; if not, write to the Free +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jboss.cache.pojo.impl; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.*; +import java.util.concurrent.CopyOnWriteArraySet; +import java.util.regex.Pattern; + +import org.jboss.cache.Fqn; +import org.jboss.cache.pojo.PojoCacheException; +import org.jboss.cache.pojo.Reference; +import org.jboss.cache.pojo.notification.annotation.ArrayModified; +import org.jboss.cache.pojo.notification.annotation.Attached; +import org.jboss.cache.pojo.notification.annotation.Detached; +import org.jboss.cache.pojo.notification.annotation.FieldModified; +import org.jboss.cache.pojo.notification.annotation.ListModified; +import org.jboss.cache.pojo.notification.annotation.MapModified; +import org.jboss.cache.pojo.notification.annotation.PojoCacheListener; +import org.jboss.cache.pojo.notification.annotation.SetModified; +import org.jboss.cache.pojo.notification.annotation.TransactionCompleted; +import org.jboss.cache.pojo.notification.annotation.TransactionRegistered; +import org.jboss.cache.pojo.notification.event.ArrayModifiedEvent; +import org.jboss.cache.pojo.notification.event.AttachedEvent; +import org.jboss.cache.pojo.notification.event.DetachedEvent; +import org.jboss.cache.pojo.notification.event.Event; +import org.jboss.cache.pojo.notification.event.FieldModifiedEvent; +import org.jboss.cache.pojo.notification.event.ListModifiedEvent; +import org.jboss.cache.pojo.notification.event.MapModifiedEvent; +import org.jboss.cache.pojo.notification.event.SetModifiedEvent; +import org.jboss.cache.pojo.notification.event.TransactionCompletedEvent; +import org.jboss.cache.pojo.notification.event.TransactionRegisteredEvent; + +// $Id$ + +/** + * Dispatches notification events to POJO cache listeners. + * + * @author Jason T. Greene + * @revision $Id$ + */ +class NotificationDispatcher +{ + private final static Map, Class> annotations =3D new HashMap, Class>(); + private final Set listeners =3D new CopyOnWriteArraySet(); + private Set filteredListeners =3D new HashSet(); + private volatile boolean hasFilters; + + static + { + annotations.put(Attached.class, AttachedEvent.class); + annotations.put(Detached.class, DetachedEvent.class); + annotations.put(FieldModified.class, FieldModifiedEvent.class); + annotations.put(ListModified.class, ListModifiedEvent.class); + annotations.put(MapModified.class, MapModifiedEvent.class); + annotations.put(SetModified.class, SetModifiedEvent.class); + annotations.put(ArrayModified.class, ArrayModifiedEvent.class); + annotations.put(TransactionRegistered.class, TransactionRegisteredEv= ent.class); + annotations.put(TransactionCompleted.class, TransactionCompletedEven= t.class); + } + + final static class Entry + { + private final Object listener; + private final Pattern pattern; + private final Map, List> notifiers; + + private Entry(Object listener, boolean build) + { + this(listener, build, null); + } + + private Entry(Object listener, boolean build, Pattern pattern) + { + if (listener =3D=3D null) + throw new IllegalArgumentException("Listener can't be null"); + + this.listener =3D listener; + this.pattern =3D pattern; + + this.notifiers =3D build ? buildNotifiers(listener.getClass()) : = null; + } + + // equality is confined to listener + public int hashCode() + { + return listener.hashCode(); + } + + // equality is confined to listener + public boolean equals(Object o) + { + if (o =3D=3D this) + return true; + if (! (o instanceof Entry)) + return false; + + // Must be the same instance + return ((Entry)o).listener =3D=3D this.listener; + } + + private static Map, List> buildNotifiers(Class c= lazz) + { + if (! Modifier.isPublic(clazz.getModifiers())) + throw new IllegalArgumentException("Listener must be public! C= lass:" + clazz.getName()); + + if (! clazz.isAnnotationPresent(PojoCacheListener.class)) + throw new IllegalArgumentException("Not a listener, class did = not contain @PojoCacheListener. Class: " + clazz.getName()); + + + Map, List> notifiers =3D new HashMap, L= ist>(); + for (Method method : clazz.getMethods()) + { + for (Annotation annotation : method.getAnnotations()) + { + Class event =3D annotations.get(annotation= .annotationType()); + if (event =3D=3D null) + continue; + + Class[] types =3D method.getParameterTypes(); + if (types.length !=3D 1 || !types[0].isAssignableFrom(event= )) + { + throw new IllegalArgumentException("Listener has invlaid= method signature for annotation. " + + "Method: \"" + method.getName() + "\" " + + "Annotation: \"" + annotation.annotationType().get= SimpleName() + "\" " + + "Expected Parameter: \"" + event.getSimpleName() += "\""); + } + + List list =3D notifiers.get(event); + if (list =3D=3D null) + { + list =3D new ArrayList(); + notifiers.put(event, list); + } + + list.add(method); + } + } + + return notifiers; + } + } + + void add(Object listener) + { + listeners.add(new Entry(listener, true)); + } + + // gaurds filteredListeners + synchronized void add(Object listener, Pattern pattern) + { + listeners.add(new Entry(listener, true, pattern)); + filteredListeners.add(listener); + hasFilters =3D true; + } + + // gaurds filteredListeners + synchronized void remove(Object listener) + { + filteredListeners.remove(listener); + if (filteredListeners.size() =3D=3D 0) + hasFilters =3D false; + listeners.remove(new Entry(listener, false)); + } + + boolean hasFilters() + { + return hasFilters; + } + + Set getListeners() + { + Set set =3D new HashSet(); + for (Entry entry : listeners) + set.add(entry.listener); + + return Collections.unmodifiableSet(set); + } + + Set getListenerEntries(Collection references) + { + Set set =3D new HashSet(); + for (Entry entry : listeners) + { + if (entry.pattern =3D=3D null) + { + set.add(entry); + continue; + } + + for (Reference reference : references) + { + if (entry.pattern.matcher(reference.getFqn().toString()).match= es()) + { + set.add(entry); + break; + } + } + } + + return set; + } + + boolean isEmpty() + { + return listeners.size() =3D=3D 0; + } + + void dispatch(Event notification) + { + for (Entry entry : listeners) + { + // Prevent dispatch to filtered entries + if (entry.pattern =3D=3D null) + dispatch(notification, entry); + } + } + + void dispatch(Event notification, Set listeners) + { + for (Entry listener : listeners) + dispatch(notification, listener); + } + + private void dispatch(Event notification, Entry entry) + { + List methods =3D entry.notifiers.get(notification.getClass()= ); + if (methods =3D=3D null) + return; + + try + { + for (Method method : methods) + method.invoke(entry.listener, notification); + } + catch (Exception e) + { + throw new PojoCacheException(e); + } + } +} Deleted: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Object= GraphHandler.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ObjectGraphHandler.j= ava 2008-07-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/ObjectGraph= Handler.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,138 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ - -package org.jboss.cache.pojo.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jboss.cache.CacheException; -import org.jboss.cache.Fqn; -import org.jboss.cache.pojo.PojoCacheException; - -/** - * Handle the object graph management. - * - * @author Ben Wang - * Date: Aug 4, 2005 - * @version $Id$ - */ -class ObjectGraphHandler extends AbstractHandler -{ - private PojoCacheImpl cache; - private InternalHelper internal_; - private final static Log log =3D LogFactory.getLog(ObjectGraphHandler.c= lass); - - public ObjectGraphHandler(PojoCacheImpl cache, InternalHelper internal) - { - this.cache =3D cache; - internal_ =3D internal; - } - - protected Fqn getFqn(Object obj) - { - return null; - } - - protected boolean handles(Class clazz) - { - return false; - } - - @Override - protected Object get(Fqn fqn, Class clazz, PojoInstance pojoInsta= nce) throws CacheException - { - // Note this is actually the aliasFqn, not the real fqn! - Object obj; - - obj =3D cache.find(fqn); - if (obj =3D=3D null) - throw new PojoCacheException("ObjectGraphHandler.get(): null obje= ct from internal ref node." + - " Internal ref node: " + fqn); - - return obj; // No need to set the instance under fqn. It is located = in refFqn anyway. - } - - @Override - protected void put(Fqn fqn, Fqn referencingFqn, Object obj) throw= s CacheException - { - setupRefCounting(fqn, referencingFqn); - } - - boolean isMultipleReferenced(Fqn internalFqn) - { - // Note this is actually the aliasFqn, not the real fqn! - PojoInstance pojoInstance =3D null; - try - { - pojoInstance =3D internal_.getPojoInstance(internalFqn); - } - catch (CacheException e) - { - throw new PojoCacheException("Exception in isMultipleReferenced",= e); - } - // check if this is a refernce - return InternalHelper.isMultipleReferenced(pojoInstance); - - } - - @Override - protected Object remove(Fqn fqn, Fqn referencingFqn, Object pojo) - throws CacheException - { - if (log.isDebugEnabled()) - { - log.debug("remove(): removing object fqn: " + referencingFqn - + " Will just de-reference it."); - } - removeFromReference(fqn, referencingFqn); - - return null; - } - - /** - * Remove the object from the the reference fqn, meaning just decrement= the ref counter. - */ - private void removeFromReference(Fqn originalFqn, Fqn referencing= Fqn) throws CacheException - { - synchronized (originalFqn) - { // we lock the internal fqn here so no one else has access. - // Decrement ref counting on the internal node - if (decrementRefCount(originalFqn, referencingFqn) =3D=3D PojoIns= tance.INITIAL_COUNTER_VALUE) - { - // No one is referring it so it is safe to remove - // TODO we should make sure the parent nodes are also removed = they are empty as well. - cache.detach(originalFqn); - } - } - } - - /** - * 1. increment reference counter - * 2. put in refFqn so we can get it. - * - * @param fqn The original fqn node - * @param refFqn The new internal fqn node - */ - private void setupRefCounting(Fqn fqn, Fqn referencingFqn) throws= CacheException - { - synchronized (fqn) - { - // increment the reference counting - incrementRefCount(fqn, referencingFqn); - } - } - - private int incrementRefCount(Fqn originalFqn, Fqn referencingFqn= ) throws CacheException - { - return internal_.incrementRefCount(originalFqn, referencingFqn); - } - - private int decrementRefCount(Fqn originalFqn, Fqn referencingFqn= ) throws CacheException - { - return internal_.decrementRefCount(originalFqn, referencingFqn); - } -} Copied: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/ObjectG= raphHandler.java (from rev 6551, pojo/trunk/src/main/java/org/jboss/cache/p= ojo/impl/ObjectGraphHandler.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/ObjectGraph= Handler.java (rev 0) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/ObjectGraph= Handler.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,132 @@ +/* + * JBoss, Home of Professional Open Source + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ + +package org.jboss.cache.pojo.impl; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.cache.CacheException; +import org.jboss.cache.Fqn; +import org.jboss.cache.pojo.PojoCacheException; +import org.jboss.cache.pojo.Reference; + +/** + * Handle the object graph management. + * + * @author Ben Wang + * Date: Aug 4, 2005 + * @version $Id$ + */ +class ObjectGraphHandler extends AbstractHandler +{ + private PojoCacheImpl cache; + private InternalHelper internal_; + private final static Log log =3D LogFactory.getLog(ObjectGraphHandler.c= lass); + + public ObjectGraphHandler(PojoCacheImpl cache, InternalHelper internal) + { + this.cache =3D cache; + internal_ =3D internal; + } + + protected Fqn getFqn(Object obj) + { + return null; + } + + protected boolean handles(Class clazz) + { + return false; + } + + @Override + protected Object get(Fqn fqn, Class clazz, PojoInstance pojoInsta= nce) throws CacheException + { + // Note this is actually the aliasFqn, not the real fqn! + Object obj; + + obj =3D cache.find(fqn); + if (obj =3D=3D null) + throw new PojoCacheException("ObjectGraphHandler.get(): null obje= ct from internal ref node." + + " Internal ref node: " + fqn); + + return obj; // No need to set the instance under fqn. It is located = in refFqn anyway. + } + + @Override + protected void put(Fqn fqn, Reference reference, Object obj) throws = CacheException + { + setupRefCounting(fqn, reference); + } + + boolean isMultipleReferenced(Fqn internalFqn) + { + // Note this is actually the aliasFqn, not the real fqn! + PojoInstance pojoInstance =3D null; + try + { + pojoInstance =3D internal_.getPojoInstance(internalFqn); + } + catch (CacheException e) + { + throw new PojoCacheException("Exception in isMultipleReferenced",= e); + } + // check if this is a refernce + return InternalHelper.isMultipleReferenced(pojoInstance); + + } + + @Override + protected Object remove(Fqn fqn, Reference reference, Object pojo) + throws CacheException + { + if (log.isDebugEnabled()) + { + log.debug("remove(): removing object fqn: " + reference + + " Will just de-reference it."); + } + removeFromReference(fqn, reference); + + return null; + } + + /** + * Remove the object from the the reference fqn, meaning just decrement= the ref counter. + */ + private void removeFromReference(Fqn originalFqn, Reference referenc= e) throws CacheException + { + if (decrementRefCount(originalFqn, reference) =3D=3D PojoInstance.IN= ITIAL_COUNTER_VALUE) + { + // No one is referring it so it is safe to remove + // TODO we should make sure the parent nodes are also removed the= y are empty as well. + cache.detach(originalFqn); + } + } + + /** + * 1. increment reference counter + * 2. put in refFqn so we can get it. + * + * @param fqn The original fqn node + * @param refFqn The new internal fqn node + */ + private void setupRefCounting(Fqn fqn, Reference reference) throws C= acheException + { + // increment the reference counting + incrementRefCount(fqn, reference); + } + + private int incrementRefCount(Fqn originalFqn, Reference reference) = throws CacheException + { + return internal_.incrementRefCount(originalFqn, reference); + } + + private int decrementRefCount(Fqn originalFqn, Reference reference) = throws CacheException + { + return internal_.decrementRefCount(originalFqn, reference); + } +} Deleted: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoCa= cheDelegate.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDelegate.ja= va 2008-07-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDe= legate.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,349 +0,0 @@ -/* - * JBoss, the OpenSource J2EE webOS - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package org.jboss.cache.pojo.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jboss.aop.Advised; -import org.jboss.aop.Advisor; -import org.jboss.aop.InstanceAdvisor; -import org.jboss.aop.advice.Interceptor; -import org.jboss.aop.proxy.ClassProxy; -import org.jboss.cache.Cache; -import org.jboss.cache.CacheException; -import org.jboss.cache.CacheSPI; -import org.jboss.cache.Fqn; -import org.jboss.cache.Node; -import org.jboss.cache.Region; -import org.jboss.cache.pojo.PojoCacheException; -import org.jboss.cache.pojo.collection.CollectionInterceptorUtil; -import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterce= ptor; -import org.jboss.cache.pojo.interceptors.dynamic.BaseInterceptor; -import org.jboss.cache.pojo.memory.FieldPersistentReference; -import org.jboss.cache.pojo.util.AopUtil; - -import java.lang.reflect.Field; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * Delegate class for PojoCache, the real implementation code happens here. - * - * @author Ben Wang - */ -public class PojoCacheDelegate -{ - private PojoCacheImpl pojoCache; - private Cache cache; - private final static Log log =3D LogFactory.getLog(PojoCacheDelegate.cl= ass); - private InternalHelper internal_; - private AdvisedPojoHandler advisedHandler_; - private ObjectGraphHandler graphHandler_; - private CollectionClassHandler collectionHandler_; - private ArrayHandler arrayHandler; - private SerializableObjectHandler serializableHandler_; - // Use ThreadLocal to hold a boolean isBulkRemove - private PojoUtil util_ =3D new PojoUtil(); - - public PojoCacheDelegate(PojoCacheImpl cache) - { - pojoCache =3D cache; - this.cache =3D pojoCache.getCache(); - internal_ =3D new InternalHelper(cache); - graphHandler_ =3D new ObjectGraphHandler(pojoCache, internal_); - collectionHandler_ =3D new CollectionClassHandler(pojoCache, interna= l_); - serializableHandler_ =3D new SerializableObjectHandler(pojoCache, in= ternal_); - advisedHandler_ =3D new AdvisedPojoHandler(pojoCache, internal_, uti= l_); - arrayHandler =3D new ArrayHandler(pojoCache); - } - - public Object getObject(Fqn fqn, String field, Object source) throws Ca= cheException - { - // TODO Must we really to couple with BR? JBCACHE-669 - Object pojo =3D internal_.getPojo(fqn, field); - if (pojo !=3D null) - { - // we already have an advised instance - if (log.isDebugEnabled()) - { - log.debug("getObject(): id: " + fqn + " retrieved from existin= g instance directly. "); - } - return pojo; - } - - // OK. So we are here meaning that this is a failover or passivation= since the transient - // pojo instance is not around. Let's also make sure the right class= loader is used - // as well. - ClassLoader prevCL =3D Thread.currentThread().getContextClassLoader(= ); - try - { - Region region =3D cache.getRegion(fqn, false); - if (region !=3D null && region.getClassLoader() !=3D null) - Thread.currentThread().setContextClassLoader(region.getClassLo= ader()); - - return getObjectInternal(fqn, field, source); - } - finally - { - Thread.currentThread().setContextClassLoader(prevCL); - } - } - - /** - * Note that caller of this method will take care of synchronization wi= thin the fqn sub-tree. - */ - public Object putObject(Fqn fqn, Object obj, String field, Object sourc= e) throws CacheException - { - internal_.lockPojo(fqn); - - // Skip some un-necessary update if obj is the same class as the old= one - Object oldValue =3D internal_.getPojo(fqn, field); - boolean allowArray =3D source instanceof ArrayInterceptable; - if (oldValue =3D=3D obj && skipDuplicateAttach(obj, allowArray)) - { - if (log.isDebugEnabled()) - { - log.debug("putObject(): id: " + fqn + " pojo is already in the= cache. Return right away."); - } - return obj; - } - - // remove old value before overwriting it. This is necessary to deta= ch any interceptor. - // TODO Or can we simply walk thru that somewhere? Well, there is al= so implication of Collection though - pojoCache.detach(fqn, field, source); - - if (obj =3D=3D null) - return oldValue;// we are done - - AbstractHandler handler =3D getHandler(obj.getClass(), allowArray); - Fqn internalFqn =3D handler.getFqn(obj); - - if (internalFqn !=3D null) - { - graphHandler_.put(internalFqn, fqn, obj); - } - else - { - internalFqn =3D createInternalFqn(fqn, obj); - if (log.isDebugEnabled()) - log.debug("attach(): id: " + fqn + " will store the pojo in th= e internal area: " + internalFqn); - - handler.put(internalFqn, fqn, obj); - - // Used by notification sub-system - cache.put(internalFqn, InternalConstant.POJOCACHE_STATUS, "ATTACH= ED"); - } - - setPojoReference(fqn, obj, field, internalFqn); - - return oldValue; - } - - private boolean skipDuplicateAttach(Object obj, boolean allowArray) - { - return obj =3D=3D null || getHandler(obj.getClass(), allowArray) != =3D serializableHandler_; - } - - private AbstractHandler getHandler(Class clazz, boolean allowArray) - { - if (advisedHandler_.handles(clazz)) - return advisedHandler_; - - if (collectionHandler_.handles(clazz)) - return collectionHandler_; - - if (allowArray && arrayHandler.handles(clazz)) - return arrayHandler; - - if (serializableHandler_.handles(clazz)) - return serializableHandler_; - - throw new CacheException("Can not manage object. It must be either i= nstrumented, a collection, an array, or Serializable: " - + clazz.getName()); - } - - - private Fqn createInternalFqn(Fqn fqn, Object obj) throws CacheException - { - // Create an internal Fqn name - return AopUtil.createInternalFqn(fqn, cache); - } - - private Fqn setPojoReference(Fqn fqn, Object obj, String field, Fqn int= ernalFqn) throws CacheException - { - // Create PojoReference - CachedType type =3D pojoCache.getCachedType(obj.getClass()); - PojoReference pojoReference =3D new PojoReference(); - pojoReference.setPojoClass(type.getType()); - - // store PojoReference - pojoReference.setFqn(internalFqn); - internal_.putPojoReference(fqn, pojoReference, field); - if (log.isDebugEnabled()) - { - log.debug("put(): inserting PojoReference with id: " + fqn); - } - // store obj in the internal fqn - return internalFqn; - } - - private void createChildNodeFirstWithoutLocking(Fqn internalFqn) - { - int size =3D internalFqn.size(); - Fqn f =3D internalFqn.getSubFqn(0, size - 1); - Fqn child =3D internalFqn.getSubFqn(size - 1, size); - - Node base =3D cache.getRoot().getChild(f); - if (base =3D=3D null) - { - log.debug("The node retrieved is null from fqn: " + f); - return; - } - base.addChild(child); - } - - /** - * Note that caller of this method will take care of synchronization wi= thin the fqn sub-tree. - * - * @param fqn - * @return detached object - * @throws CacheException - */ - public Object removeObject(Fqn fqn, String field, Object source) throws= CacheException - { - internal_.lockPojo(fqn); - - // the class attribute is implicitly stored as an immutable read-onl= y attribute - PojoReference pojoReference =3D internal_.getPojoReference(fqn, fiel= d); - if (pojoReference =3D=3D null) - { - // clazz and pojoReference can be not null if this node is the r= eplicated brother node. - if (log.isTraceEnabled()) - { - log.trace("removeObject(): clazz is null. id: " + fqn + " No n= eed to remove."); - } - return null; - } - - Fqn internalFqn =3D pojoReference.getFqn(); - - if (log.isDebugEnabled()) - { - log.debug("removeObject(): removing object from id: " + fqn - + " with the corresponding internal id: " + internalFqn= ); - } - - Object result =3D pojoCache.find(internalFqn); - if (result =3D=3D null) - return null; - - if (graphHandler_.isMultipleReferenced(internalFqn)) - { - graphHandler_.remove(internalFqn, fqn, result); - } - else - { - cache.put(internalFqn, InternalConstant.POJOCACHE_STATUS, "DETACH= ING"); - boolean allowArray =3D source instanceof ArrayInterceptable; - result =3D getHandler(result.getClass(), allowArray).remove(inter= nalFqn, fqn, result); - } - - internal_.cleanUp(fqn, field); - return result; - } - - public Map findObjects(Fqn fqn) throws CacheException - { - - // Traverse from fqn to do getObject, if it return a pojo we then st= op. - Map map =3D new HashMap(); - Object pojo =3D getObject(fqn, null, null); - if (pojo !=3D null) - { - map.put(fqn, pojo);// we are done! - return map; - } - - findChildObjects(fqn, map); - if (log.isDebugEnabled()) - { - log.debug("_findObjects(): id: " + fqn + " size of pojos found: "= + map.size()); - } - return map; - } - - private Object getObjectInternal(Fqn fqn, String field, Object sourc= e) throws CacheException - { - Fqn internalFqn =3D fqn; - PojoReference pojoReference =3D internal_.getPojoReference(fqn, fiel= d); - if (pojoReference !=3D null) - { - internalFqn =3D pojoReference.getFqn(); - } - else if (field !=3D null) - { - return null; - } - - if (log.isDebugEnabled()) - log.debug("getObject(): id: " + fqn + " with a corresponding inte= rnal id: " + internalFqn); - - /** - * Reconstruct the managed POJO - */ - Object obj; - - PojoInstance pojoInstance =3D internal_.getPojoInstance(internalFqn); - - if (pojoInstance =3D=3D null) - return null; - //throw new PojoCacheException("PojoCacheDelegate.getObjectIntern= al(): null PojoInstance for fqn: " + internalFqn); - - Class clazz =3D pojoInstance.getPojoClass(); - boolean allowArray =3D source instanceof ArrayInterceptable; - obj =3D getHandler(clazz, allowArray).get(internalFqn, clazz, pojoIn= stance); - - InternalHelper.setPojo(pojoInstance, obj); - return obj; - } - - private void findChildObjects(Fqn fqn, Map map) throws CacheException - { - // We need to traverse then - Node root =3D cache.getRoot(); - Node current =3D root.getChild(fqn); - - if (current =3D=3D null) return; - - Collection col =3D current.getChildren(); - if (col =3D=3D null) return; - for (Node n : col) - { - Fqn newFqn =3D n.getFqn(); - if (InternalHelper.isInternalNode(newFqn)) continue;// skip - - Object pojo =3D getObject(newFqn, null, null); - if (pojo !=3D null) - { - map.put(newFqn, pojo); - } - else - { - findChildObjects(newFqn, map); - } - } - } - - public boolean exists(Fqn id) - { - return internal_.getPojoReference(id, null) !=3D null || internal_.g= etPojoInstance(id) !=3D null; - } -} Copied: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoCac= heDelegate.java (from rev 6551, pojo/trunk/src/main/java/org/jboss/cache/po= jo/impl/PojoCacheDelegate.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDe= legate.java (rev 0) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDe= legate.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,371 @@ +/* + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.cache.pojo.impl; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.aop.Advised; +import org.jboss.aop.Advisor; +import org.jboss.aop.InstanceAdvisor; +import org.jboss.aop.advice.Interceptor; +import org.jboss.aop.proxy.ClassProxy; +import org.jboss.cache.Cache; +import org.jboss.cache.CacheException; +import org.jboss.cache.CacheSPI; +import org.jboss.cache.Fqn; +import org.jboss.cache.Node; +import org.jboss.cache.Region; +import org.jboss.cache.pojo.PojoCacheException; +import org.jboss.cache.pojo.Reference; +import org.jboss.cache.pojo.collection.CollectionInterceptorUtil; +import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterce= ptor; +import org.jboss.cache.pojo.interceptors.dynamic.BaseInterceptor; +import org.jboss.cache.pojo.memory.FieldPersistentReference; +import org.jboss.cache.pojo.util.AopUtil; + +import java.lang.reflect.Field; +import java.util.*; + +/** + * Delegate class for PojoCache, the real implementation code happens here. + * + * @author Ben Wang + */ +public class PojoCacheDelegate +{ + private PojoCacheImpl pojoCache; + private Cache cache; + private final static Log log =3D LogFactory.getLog(PojoCacheDelegate.cl= ass); + private InternalHelper internal_; + private AdvisedPojoHandler advisedHandler_; + private ObjectGraphHandler graphHandler_; + private CollectionClassHandler collectionHandler_; + private ArrayHandler arrayHandler; + private SerializableObjectHandler serializableHandler_; + // Use ThreadLocal to hold a boolean isBulkRemove + private PojoUtil util_ =3D new PojoUtil(); + + public PojoCacheDelegate(PojoCacheImpl cache) + { + pojoCache =3D cache; + this.cache =3D pojoCache.getCache(); + internal_ =3D new InternalHelper(cache); + graphHandler_ =3D new ObjectGraphHandler(pojoCache, internal_); + collectionHandler_ =3D new CollectionClassHandler(pojoCache, interna= l_); + serializableHandler_ =3D new SerializableObjectHandler(pojoCache, in= ternal_); + advisedHandler_ =3D new AdvisedPojoHandler(pojoCache, internal_, uti= l_); + arrayHandler =3D new ArrayHandler(pojoCache); + } + + public Object getObject(Fqn fqn, String field, Object source) throws Ca= cheException + { + // TODO Must we really to couple with BR? JBCACHE-669 + Object pojo =3D internal_.getPojo(fqn, field); + if (pojo !=3D null) + { + // we already have an advised instance + if (log.isDebugEnabled()) + { + log.debug("getObject(): id: " + fqn + " retrieved from existin= g instance directly. "); + } + return pojo; + } + + // OK. So we are here meaning that this is a failover or passivation= since the transient + // pojo instance is not around. Let's also make sure the right class= loader is used + // as well. + ClassLoader prevCL =3D Thread.currentThread().getContextClassLoader(= ); + try + { + Region region =3D cache.getRegion(fqn, false); + if (region !=3D null && region.getClassLoader() !=3D null) + Thread.currentThread().setContextClassLoader(region.getClassLo= ader()); + + return getObjectInternal(fqn, field, source); + } + finally + { + Thread.currentThread().setContextClassLoader(prevCL); + } + } + + /** + * Note that caller of this method will take care of synchronization wi= thin the fqn sub-tree. + */ + public Object putObject(Fqn fqn, Object obj, String field, Object sourc= e) throws CacheException + { + internal_.lockPojo(fqn); + + // Skip some un-necessary update if obj is the same class as the old= one + Object oldValue =3D internal_.getPojo(fqn, field); + boolean allowArray =3D source instanceof ArrayInterceptable; + if (oldValue =3D=3D obj && skipDuplicateAttach(obj, allowArray)) + { + if (log.isDebugEnabled()) + { + log.debug("putObject(): id: " + fqn + " pojo is already in the= cache. Return right away."); + } + return obj; + } + + // remove old value before overwriting it. This is necessary to deta= ch any interceptor. + // TODO Or can we simply walk thru that somewhere? Well, there is al= so implication of Collection though + pojoCache.detach(fqn, field, source); + + if (obj =3D=3D null) + return oldValue;// we are done + + AbstractHandler handler =3D getHandler(obj.getClass(), allowArray); + Fqn internalFqn =3D handler.getFqn(obj); + + Reference reference =3D new ReferenceImpl(fqn, field); + if (internalFqn !=3D null) + { + // Lock the internal fqn, before the ref count is checked + internal_.lockPojo(internalFqn); + graphHandler_.put(internalFqn, reference , obj); + } + else + { + internalFqn =3D createInternalFqn(fqn, obj); + if (log.isDebugEnabled()) + log.debug("attach(): id: " + fqn + " will store the pojo in th= e internal area: " + internalFqn); + + handler.put(internalFqn, reference, obj); + + // Used by notification sub-system + cache.put(internalFqn, InternalConstant.POJOCACHE_STATUS, "ATTACH= ED"); + } + + setPojoReference(fqn, obj, field, internalFqn); + + return oldValue; + } + + private boolean skipDuplicateAttach(Object obj, boolean allowArray) + { + return obj =3D=3D null || getHandler(obj.getClass(), allowArray) != =3D serializableHandler_; + } + + private AbstractHandler getHandler(Class clazz, boolean allowArray) + { + if (advisedHandler_.handles(clazz)) + return advisedHandler_; + + if (collectionHandler_.handles(clazz)) + return collectionHandler_; + + if (allowArray && arrayHandler.handles(clazz)) + return arrayHandler; + + if (serializableHandler_.handles(clazz)) + return serializableHandler_; + + throw new CacheException("Can not manage object. It must be either i= nstrumented, a collection, an array, or Serializable: " + + clazz.getName()); + } + + + private Fqn createInternalFqn(Fqn fqn, Object obj) throws CacheException + { + // Create an internal Fqn name + return AopUtil.createInternalFqn(fqn, cache); + } + + private Fqn setPojoReference(Fqn fqn, Object obj, String field, Fqn int= ernalFqn) throws CacheException + { + // Create PojoReference + CachedType type =3D pojoCache.getCachedType(obj.getClass()); + PojoReference pojoReference =3D new PojoReference(); + pojoReference.setPojoClass(type.getType()); + + // store PojoReference + pojoReference.setFqn(internalFqn); + internal_.putPojoReference(fqn, pojoReference, field); + if (log.isDebugEnabled()) + { + log.debug("put(): inserting PojoReference with id: " + fqn); + } + // store obj in the internal fqn + return internalFqn; + } + + private void createChildNodeFirstWithoutLocking(Fqn internalFqn) + { + int size =3D internalFqn.size(); + Fqn f =3D internalFqn.getSubFqn(0, size - 1); + Fqn child =3D internalFqn.getSubFqn(size - 1, size); + + Node base =3D cache.getRoot().getChild(f); + if (base =3D=3D null) + { + log.debug("The node retrieved is null from fqn: " + f); + return; + } + base.addChild(child); + } + + /** + * Note that caller of this method will take care of synchronization wi= thin the fqn sub-tree. + * + * @param fqn + * @return detached object + * @throws CacheException + */ + public Object removeObject(Fqn fqn, String field, Object source) throws= CacheException + { + internal_.lockPojo(fqn); + + // the class attribute is implicitly stored as an immutable read-onl= y attribute + PojoReference pojoReference =3D internal_.getPojoReference(fqn, fiel= d); + if (pojoReference =3D=3D null) + { + // clazz and pojoReference can be not null if this node is the r= eplicated brother node. + if (log.isTraceEnabled()) + { + log.trace("removeObject(): clazz is null. id: " + fqn + " No n= eed to remove."); + } + return null; + } + + Fqn internalFqn =3D pojoReference.getFqn(); + + + + if (log.isDebugEnabled()) + { + log.debug("removeObject(): removing object from id: " + fqn + + " with the corresponding internal id: " + internalFqn= ); + } + + Object result =3D pojoCache.find(internalFqn); + if (result =3D=3D null) + return null; + + // Lock the internal fqn, before the ref count is checked + internal_.lockPojo(internalFqn); + + Reference reference =3D new ReferenceImpl(fqn, field); + if (graphHandler_.isMultipleReferenced(internalFqn)) + { + graphHandler_.remove(internalFqn, reference, result); + } + else + { + cache.put(internalFqn, InternalConstant.POJOCACHE_STATUS, "DETACH= ING"); + boolean allowArray =3D source instanceof ArrayInterceptable; + result =3D getHandler(result.getClass(), allowArray).remove(inter= nalFqn, reference, result); + } + + internal_.cleanUp(fqn, field); + return result; + } + + public Map findObjects(Fqn fqn) throws CacheException + { + + // Traverse from fqn to do getObject, if it return a pojo we then st= op. + Map map =3D new HashMap(); + Object pojo =3D getObject(fqn, null, null); + if (pojo !=3D null) + { + map.put(fqn, pojo);// we are done! + return map; + } + + findChildObjects(fqn, map); + if (log.isDebugEnabled()) + { + log.debug("_findObjects(): id: " + fqn + " size of pojos found: "= + map.size()); + } + return map; + } + + private Object getObjectInternal(Fqn fqn, String field, Object sourc= e) throws CacheException + { + Fqn internalFqn =3D fqn; + PojoReference pojoReference =3D internal_.getPojoReference(fqn, fiel= d); + if (pojoReference !=3D null) + { + internalFqn =3D pojoReference.getFqn(); + } + else if (field !=3D null) + { + return null; + } + + if (log.isDebugEnabled()) + log.debug("getObject(): id: " + fqn + " with a corresponding inte= rnal id: " + internalFqn); + + /** + * Reconstruct the managed POJO + */ + Object obj; + + PojoInstance pojoInstance =3D internal_.getPojoInstance(internalFqn); + + if (pojoInstance =3D=3D null) + return null; + //throw new PojoCacheException("PojoCacheDelegate.getObjectIntern= al(): null PojoInstance for fqn: " + internalFqn); + + Class clazz =3D pojoInstance.getPojoClass(); + boolean allowArray =3D source instanceof ArrayInterceptable; + obj =3D getHandler(clazz, allowArray).get(internalFqn, clazz, pojoIn= stance); + + InternalHelper.setPojo(pojoInstance, obj); + return obj; + } + + private void findChildObjects(Fqn fqn, Map map) throws CacheException + { + // We need to traverse then + Node root =3D cache.getRoot(); + Node current =3D root.getChild(fqn); + + if (current =3D=3D null) return; + + Collection col =3D current.getChildren(); + if (col =3D=3D null) return; + for (Node n : col) + { + Fqn newFqn =3D n.getFqn(); + if (InternalHelper.isInternalNode(newFqn)) continue;// skip + + Object pojo =3D getObject(newFqn, null, null); + if (pojo !=3D null) + { + map.put(newFqn, pojo); + } + else + { + findChildObjects(newFqn, map); + } + } + } + + public boolean exists(Fqn id) + { + return internal_.getPojoReference(id, null) !=3D null || internal_.g= etPojoInstance(id) !=3D null; + } + + public Fqn getInternalFqn(Object object) + { + AbstractHandler handler =3D getHandler(object.getClass(), true); + Fqn internalFqn =3D handler.getFqn(object); + return internalFqn; + } + + public Collection getReferences(Object object) + { + Fqn fqn =3D getInternalFqn(object); + if (fqn =3D=3D null) + return Collections.emptyList(); + + PojoInstance pojoInstance =3D internal_.getPojoInstance(fqn); + return pojoInstance.getReferences(); + } +} Deleted: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoCa= cheImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheImpl.java 2= 008-07-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoCacheIm= pl.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,411 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ - -package org.jboss.cache.pojo.impl; - -import java.util.Collection; -import java.util.Map; -import java.util.WeakHashMap; -import java.util.regex.Pattern; - -import javax.transaction.Status; -import javax.transaction.Transaction; -import javax.transaction.TransactionManager; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jboss.cache.Cache; -import org.jboss.cache.CacheException; -import org.jboss.cache.CacheSPI; -import org.jboss.cache.DefaultCacheFactory; -import org.jboss.cache.Fqn; -import org.jboss.cache.Version; -import org.jboss.cache.config.Configuration; -import org.jboss.cache.factories.XmlConfigurationParser; -import org.jboss.cache.pojo.PojoCache; -import org.jboss.cache.pojo.PojoCacheException; -import org.jboss.cache.pojo.PojoCacheThreadContext; -import org.jboss.cache.pojo.interceptors.PojoTxSynchronizationHandler; -import org.jboss.cache.transaction.BatchModeTransactionManager; - -/** - * Implementation class for PojoCache interface - * - * @author Ben Wang - * @version $Id$ - */ -public class PojoCacheImpl implements PojoCache -{ - private CacheSPI cache =3D null; - protected final Log log_ =3D LogFactory.getLog(PojoCacheImpl.this.getCl= ass()); - private PojoCacheDelegate delegate_; - // Class -> CachedType - // use WeakHashMap to allow class reloading - private Map cachedTypes_ =3D new WeakHashMap(); - private boolean hasCreate_ =3D false; - private CacheListenerAdaptor listenerAdaptor =3D new CacheListenerAdapt= or(this); - private PojoCacheThreadContext threadContext =3D new PojoCacheThreadCon= textImpl(); - - public PojoCacheImpl(String configStr, boolean toStart) - { - try - { - // cache_ =3D new PojoTreeCache(); - // cache_.setConfiguration(new XmlConfigurationParser().p= arseFile(configStr)); - - XmlConfigurationParser parser =3D new XmlConfigurationParser(); - Configuration expected =3D parser.parseFile(configStr); - - init(expected, toStart); - } - catch (Exception e) - { - throw new PojoCacheException("Failed to start " + configStr, e); - } - } - - public PojoCacheImpl(Configuration config, boolean toStart) - { - init(config, toStart); - } - - private void init(Configuration config, boolean toStart) - { - try - { - cache =3D (CacheSPI) DefaultCacheFactory.getInsta= nce().createCache(config, toStart); - } - catch (Exception e) - { - throw new PojoCacheException("init " + config + " failed", e); - } - - delegate_ =3D new PojoCacheDelegate(this); - } - - public CacheSPI getCacheSPI() - { - return cache; - } - - public Object attach(String id, Object pojo) throws PojoCacheException - { - return attach(Fqn.fromString(id), pojo); - } - - public Object attach(Fqn id, Object pojo) throws PojoCacheException - { - return attach(id, pojo, null, null); - } - - public Object attach(Fqn id, Object pojo, String field, Object sourc= e) throws PojoCacheException - { - TransactionManager tm =3D getTransactionManager(); - boolean createdTransaction =3D setupTransaction(tm); - try - { - Object obj =3D delegate_.putObject(id, pojo, field, source); - return obj; - } - catch (Throwable t) - { - setRollbackOnly(tm); - throw new PojoCacheException("attach failed " + id, t); - } - finally - { - if (createdTransaction) - endTransaction(tm, id); - } - } - - public Object detach(Fqn id, String field, Object source) throws Poj= oCacheException - { - TransactionManager tm =3D getTransactionManager(); - boolean createdTransaction =3D setupTransaction(tm); - try - { - Object obj =3D delegate_.removeObject(id, field, source); - return obj; - } - catch (Throwable t) - { - setRollbackOnly(tm); - throw new PojoCacheException("detach failed " + id, t); - } - finally - { - if (createdTransaction) - endTransaction(tm, id); - } - } - - private void endTransaction(TransactionManager tm, Fqn id) - { - try - { - switch (tm.getStatus()) - { - case Status.STATUS_PREPARING: - case Status.STATUS_PREPARED: - case Status.STATUS_ACTIVE: - tm.commit(); - break; - case Status.STATUS_MARKED_ROLLBACK: - tm.rollback(); - break; - } - } - catch (Throwable t) - { - if (log_.isWarnEnabled()) - log_.warn("Could not end transaction for operation on: " + id,= t); - } - } - - private void setRollbackOnly(TransactionManager tm) - { - try - { - if (tm.getStatus() !=3D Status.STATUS_MARKED_ROLLBACK) - tm.setRollbackOnly(); - } - catch (Throwable t) - { - if (log_.isWarnEnabled()) - log_.warn("Could not rollback transaction!", t); - } - } - - private boolean setupTransaction(TransactionManager tm) - { - boolean created =3D false; - try - { - Transaction transaction =3D tm.getTransaction(); - if (transaction =3D=3D null) - { - tm.begin(); - transaction =3D tm.getTransaction(); - created =3D true; - } - - transaction.registerSynchronization(PojoTxSynchronizationHandler.= create()); - } - catch (Exception e) - { - throw new PojoCacheException("Error creating transaction", e); - } - - return created; - } - - private TransactionManager getTransactionManager() - { - TransactionManager tm =3D cache.getConfiguration().getRuntimeConfig(= ).getTransactionManager(); - if (tm =3D=3D null) - tm =3D BatchModeTransactionManager.getInstance(); - - return tm; - } - - public Object detach(String id) throws PojoCacheException - { - return detach(Fqn.fromString(id)); - } - - - - public Object detach(Fqn id) throws PojoCacheException - { - return detach(id, null, null); - } - - public String getPojoID(Object pojo) - { - throw new PojoCacheException("getPojoID not yet implemented"); - } - - public boolean exists(Fqn id) - { - return delegate_.exists(id); - } - - public Object find(String id) throws PojoCacheException - { - return find(Fqn.fromString(id)); - } - - public Object find(Fqn id) throws PojoCacheException - { - try - { - return find(id, null, null); - } - catch (CacheException e) - { - throw new PojoCacheException("find " + id + " failed ", e); - } - } - - public Object find(Fqn id, String field, Object source) throws Cache= Exception - { - return delegate_.getObject(id, field, source); - } - - - public Map, Object> findAll(String id) throws PojoCacheException - { - return findAll(Fqn.fromString(id)); - } - - public Map, Object> findAll(Fqn id) throws PojoCacheException - { - // Should produce "/" - if (id =3D=3D null) id =3D Fqn.ROOT; - - try - { - return delegate_.findObjects(id); - } - catch (CacheException e) - { - throw new PojoCacheException("findAll " + id + " failed", e); - } - } - - public String getVersion() - { - return Version.printVersion(); - } - - public void create() throws PojoCacheException - { - log_.info("PojoCache version: " + getVersion()); - try - { - cache.create(); - } - catch (Exception e) - { - throw new PojoCacheException("PojoCache create exception", e); - } - - hasCreate_ =3D true; - } - - public void start() throws PojoCacheException - { - if (!hasCreate_) - { - create(); - } - - try - { - log_.info("PojoCache version: " + getVersion()); - cache.start(); - } - catch (Exception e) - { - throw new PojoCacheException("Failed starting " + e, e); - } - } - - public void stop() throws PojoCacheException - { - cache.stop(); - } - - public void destroy() throws PojoCacheException - { - cache.destroy(); - } - - public Collection getListeners() - { - return listenerAdaptor.getListeners(); - } - - public void addListener(Object listener) - { - addListener(listener, null); - } - - public void addListener(Object listener, Pattern pattern) - { - // Add and remove listner operations must be serialized to ensure th= at - // the adaptor is always present only once, when at least one listen= er - // is registered. - synchronized (listenerAdaptor) - { - try - { - boolean wasEmpty =3D listenerAdaptor.isEmpty(); - listenerAdaptor.addListener(listener, pattern); - if (wasEmpty) - cache.addCacheListener(listenerAdaptor); - } - catch (IllegalArgumentException e) - { - // simplify stack trace for user - e.fillInStackTrace(); - throw e; - } - } - } - - public void removeListener(Object listener) - { - synchronized (listenerAdaptor) - { - listenerAdaptor.removeListener(listener); - if (listenerAdaptor.isEmpty()) - cache.removeCacheListener(listenerAdaptor); - } - } - - public PojoCacheThreadContext getThreadContext() - { - return threadContext; - } - - public Cache getCache() - { - return cache; - } - - /** - * Obtain a cache aop type for user to traverse the defined "primitive"= types in aop. - * Note that this is not a synchronized call now for speed optimization. - * - * @param clazz The original pojo class - * @return CachedType - */ - public synchronized CachedType getCachedType(Class clazz) - { - CachedType type =3D (CachedType) cachedTypes_.get(clazz); - if (type =3D=3D null) - { - type =3D new CachedType(clazz); - cachedTypes_.put(clazz, type); - return type; - } - else - { - return type; - } - } - - public String toString() - { - return getClass().getName() + - " cache=3D" + cache + - " delegate=3D" + delegate_ + - " types=3D" + cachedTypes_.size(); - } -} Copied: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoCac= heImpl.java (from rev 6374, pojo/trunk/src/main/java/org/jboss/cache/pojo/i= mpl/PojoCacheImpl.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoCacheIm= pl.java (rev 0) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoCacheIm= pl.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,418 @@ +/* + * JBoss, Home of Professional Open Source + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ + +package org.jboss.cache.pojo.impl; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.WeakHashMap; +import java.util.regex.Pattern; + +import javax.transaction.Status; +import javax.transaction.Transaction; +import javax.transaction.TransactionManager; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.cache.Cache; +import org.jboss.cache.CacheException; +import org.jboss.cache.CacheSPI; +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.Fqn; +import org.jboss.cache.Version; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.factories.XmlConfigurationParser; +import org.jboss.cache.pojo.PojoCache; +import org.jboss.cache.pojo.PojoCacheException; +import org.jboss.cache.pojo.PojoCacheThreadContext; +import org.jboss.cache.pojo.Reference; +import org.jboss.cache.pojo.interceptors.PojoTxSynchronizationHandler; +import org.jboss.cache.transaction.BatchModeTransactionManager; + +/** + * Implementation class for PojoCache interface + * + * @author Ben Wang + * @version $Id$ + */ +public class PojoCacheImpl implements PojoCache +{ + private CacheSPI cache =3D null; + protected final Log log_ =3D LogFactory.getLog(PojoCacheImpl.this.getCl= ass()); + private PojoCacheDelegate delegate_; + // Class -> CachedType + // use WeakHashMap to allow class reloading + private Map cachedTypes_ =3D new WeakHashMap(); + private boolean hasCreate_ =3D false; + private CacheListenerAdaptor listenerAdaptor =3D new CacheListenerAdapt= or(this); + private PojoCacheThreadContext threadContext =3D new PojoCacheThreadCon= textImpl(); + + public PojoCacheImpl(String configStr, boolean toStart) + { + try + { + // cache_ =3D new PojoTreeCache(); + // cache_.setConfiguration(new XmlConfigurationParser().p= arseFile(configStr)); + + XmlConfigurationParser parser =3D new XmlConfigurationParser(); + Configuration expected =3D parser.parseFile(configStr); + + init(expected, toStart); + } + catch (Exception e) + { + throw new PojoCacheException("Failed to start " + configStr, e); + } + } + + public PojoCacheImpl(Configuration config, boolean toStart) + { + init(config, toStart); + } + + private void init(Configuration config, boolean toStart) + { + try + { + cache =3D (CacheSPI) DefaultCacheFactory.getInsta= nce().createCache(config, toStart); + } + catch (Exception e) + { + throw new PojoCacheException("init " + config + " failed", e); + } + + delegate_ =3D new PojoCacheDelegate(this); + } + + public CacheSPI getCacheSPI() + { + return cache; + } + + public Object attach(String id, Object pojo) throws PojoCacheException + { + return attach(Fqn.fromString(id), pojo); + } + + public Object attach(Fqn id, Object pojo) throws PojoCacheException + { + return attach(id, pojo, null, null); + } + + public Object attach(Fqn id, Object pojo, String field, Object sourc= e) throws PojoCacheException + { + TransactionManager tm =3D getTransactionManager(); + boolean createdTransaction =3D setupTransaction(tm); + try + { + Object obj =3D delegate_.putObject(id, pojo, field, source); + return obj; + } + catch (Throwable t) + { + setRollbackOnly(tm); + throw new PojoCacheException("attach failed " + id, t); + } + finally + { + if (createdTransaction) + endTransaction(tm, id); + } + } + + public Object detach(Fqn id, String field, Object source) throws Poj= oCacheException + { + TransactionManager tm =3D getTransactionManager(); + boolean createdTransaction =3D setupTransaction(tm); + try + { + Object obj =3D delegate_.removeObject(id, field, source); + return obj; + } + catch (Throwable t) + { + setRollbackOnly(tm); + throw new PojoCacheException("detach failed " + id, t); + } + finally + { + if (createdTransaction) + endTransaction(tm, id); + } + } + + private void endTransaction(TransactionManager tm, Fqn id) + { + try + { + switch (tm.getStatus()) + { + case Status.STATUS_PREPARING: + case Status.STATUS_PREPARED: + case Status.STATUS_ACTIVE: + tm.commit(); + break; + case Status.STATUS_MARKED_ROLLBACK: + tm.rollback(); + break; + } + } + catch (Throwable t) + { + if (log_.isWarnEnabled()) + log_.warn("Could not end transaction for operation on: " + id,= t); + } + } + + private void setRollbackOnly(TransactionManager tm) + { + try + { + if (tm.getStatus() !=3D Status.STATUS_MARKED_ROLLBACK) + tm.setRollbackOnly(); + } + catch (Throwable t) + { + if (log_.isWarnEnabled()) + log_.warn("Could not rollback transaction!", t); + } + } + + private boolean setupTransaction(TransactionManager tm) + { + boolean created =3D false; + try + { + Transaction transaction =3D tm.getTransaction(); + if (transaction =3D=3D null) + { + tm.begin(); + transaction =3D tm.getTransaction(); + created =3D true; + } + + transaction.registerSynchronization(PojoTxSynchronizationHandler.= create()); + } + catch (Exception e) + { + throw new PojoCacheException("Error creating transaction", e); + } + + return created; + } + + private TransactionManager getTransactionManager() + { + TransactionManager tm =3D cache.getConfiguration().getRuntimeConfig(= ).getTransactionManager(); + if (tm =3D=3D null) + tm =3D BatchModeTransactionManager.getInstance(); + + return tm; + } + + public Object detach(String id) throws PojoCacheException + { + return detach(Fqn.fromString(id)); + } + + + + public Object detach(Fqn id) throws PojoCacheException + { + return detach(id, null, null); + } + + public Fqn getInternalFqn(Object object) + { + return delegate_.getInternalFqn(object); + } + + public Collection getReferences(Object object) + { + return delegate_.getReferences(object); + } + + public boolean exists(Fqn id) + { + return delegate_.exists(id); + } + + public Object find(String id) throws PojoCacheException + { + return find(Fqn.fromString(id)); + } + + public Object find(Fqn id) throws PojoCacheException + { + try + { + return find(id, null, null); + } + catch (CacheException e) + { + throw new PojoCacheException("find " + id + " failed ", e); + } + } + + public Object find(Fqn id, String field, Object source) throws Cache= Exception + { + return delegate_.getObject(id, field, source); + } + + + public Map, Object> findAll(String id) throws PojoCacheException + { + return findAll(Fqn.fromString(id)); + } + + public Map, Object> findAll(Fqn id) throws PojoCacheException + { + // Should produce "/" + if (id =3D=3D null) id =3D Fqn.ROOT; + + try + { + return delegate_.findObjects(id); + } + catch (CacheException e) + { + throw new PojoCacheException("findAll " + id + " failed", e); + } + } + + public String getVersion() + { + return Version.printVersion(); + } + + public void create() throws PojoCacheException + { + log_.info("PojoCache version: " + getVersion()); + try + { + cache.create(); + } + catch (Exception e) + { + throw new PojoCacheException("PojoCache create exception", e); + } + + hasCreate_ =3D true; + } + + public void start() throws PojoCacheException + { + if (!hasCreate_) + { + create(); + } + + try + { + log_.info("PojoCache version: " + getVersion()); + cache.start(); + } + catch (Exception e) + { + throw new PojoCacheException("Failed starting " + e, e); + } + } + + public void stop() throws PojoCacheException + { + cache.stop(); + } + + public void destroy() throws PojoCacheException + { + cache.destroy(); + } + + public Collection getListeners() + { + return listenerAdaptor.getListeners(); + } + + public void addListener(Object listener) + { + addListener(listener, null); + } + + public void addListener(Object listener, Pattern pattern) + { + // Add and remove listner operations must be serialized to ensure th= at + // the adaptor is always present only once, when at least one listen= er + // is registered. + synchronized (listenerAdaptor) + { + try + { + boolean wasEmpty =3D listenerAdaptor.isEmpty(); + listenerAdaptor.addListener(listener, pattern); + if (wasEmpty) + cache.addCacheListener(listenerAdaptor); + } + catch (IllegalArgumentException e) + { + // simplify stack trace for user + e.fillInStackTrace(); + throw e; + } + } + } + + public void removeListener(Object listener) + { + synchronized (listenerAdaptor) + { + listenerAdaptor.removeListener(listener); + if (listenerAdaptor.isEmpty()) + cache.removeCacheListener(listenerAdaptor); + } + } + + public PojoCacheThreadContext getThreadContext() + { + return threadContext; + } + + public Cache getCache() + { + return cache; + } + + /** + * Obtain a cache aop type for user to traverse the defined "primitive"= types in aop. + * Note that this is not a synchronized call now for speed optimization. + * + * @param clazz The original pojo class + * @return CachedType + */ + public synchronized CachedType getCachedType(Class clazz) + { + CachedType type =3D (CachedType) cachedTypes_.get(clazz); + if (type =3D=3D null) + { + type =3D new CachedType(clazz); + cachedTypes_.put(clazz, type); + return type; + } + else + { + return type; + } + } + + public String toString() + { + return getClass().getName() + + " cache=3D" + cache + + " delegate=3D" + delegate_ + + " types=3D" + cachedTypes_.size(); + } +} Deleted: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoIn= stance.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoInstance.java 20= 08-07-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoInstanc= e.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,160 +0,0 @@ -/* - * JBoss, the OpenSource J2EE webOS - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package org.jboss.cache.pojo.impl; - -import org.jboss.cache.Fqn; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * POJO class metadata information. - * When an object is looked up or put in PojoCache, this object will be ad= vised with a CacheFieldInterceptor. - * The underlying cache stores a reference to this object (for example to = update the instance variables, etc.). - * Since this reference need to be transactional but never replicated (the= reference is only valid - * within the VM this reference is thus stored into an PojoReference (as a= transient field). - * In addition, this instance also serves as a metadata for PojoCache. E.g= ., it has a reference counting for - * multiple references and reference FQN. - * - * @author Ben Wang - */ -public class PojoInstance implements Serializable // Externalizable is no = more efficient -{ - // protected static Log log=3DLogFactory.getLog(PojoReference.class.= getLastElementAsString()); - public static final String KEY =3D InternalConstant.POJOCACHE_KEY_PREFI= X + "PojoInstance"; - public static final int INITIAL_COUNTER_VALUE =3D -1; - - static final long serialVersionUID =3D 6492134565825613209L; - - // The instance is transient to avoid replication outside the VM - private transient Object instance_; - - // If not null, it signifies that this is a reference that points to th= is fqn. - // Note that this will get replicated. - private String internalFqn_ =3D null; - - // Reference counting. THis will get replicated as well. This keep trac= k of number of - // other instances that referenced this fqn. - private int refCount_ =3D INITIAL_COUNTER_VALUE; - - // List of fqns that reference this fqn. Assume list size is not big si= nce it may not be efficient. - private List referencedBy_ =3D null; - private Class clazz_ =3D null; - private transient PojoUtil util_ =3D new PojoUtil(); - - public PojoInstance() - { - } - - public PojoInstance(Object instance) - { - set(instance); - } - - public void setPojoClass(Class clazz) - { - clazz_ =3D clazz; - } - - public Class getPojoClass() - { - return clazz_; - } - - public Object get() - { - return instance_; - } - - public void set(Object instance) - { - instance_ =3D instance; - } - - public String getInternalFqn() - { - return internalFqn_; - } - - public void setInternalFqn(String refFqn) - { - internalFqn_ =3D refFqn; - } - - public void removeInternalFqn() - { - internalFqn_ =3D null; - } - - synchronized public int incrementRefCount(Fqn sourceFqn) - { - if (sourceFqn =3D=3D null) - { - throw new IllegalStateException("PojoInstance.incrementRefCount()= : null sourceFqn"); - } - - if (referencedBy_ =3D=3D null) - { - referencedBy_ =3D new ArrayList(); - } - - if (util_ =3D=3D null) util_ =3D new PojoUtil(); - refCount_ =3D util_.incrementReferenceCount(sourceFqn, refCount_, re= ferencedBy_); -// referencedBy_.add(sourceFqn); - -// refCount_ +=3D 1; -//logger_.info("incrementRefCount(): current ref count " +refCount_); - return refCount_; - } - - synchronized public int decrementRefCount(Fqn sourceFqn) - { - if (sourceFqn =3D=3D null) - { - throw new IllegalStateException("PojoInstance.incrementRefCount()= : null sourceFqn"); - } - - if (!referencedBy_.contains(sourceFqn)) - throw new IllegalStateException("PojoReference.decrementRefCount(= ): source fqn: " + - sourceFqn + " is not present."); - - if (util_ =3D=3D null) util_ =3D new PojoUtil(); - refCount_ =3D util_.decrementReferenceCount(sourceFqn, refCount_, re= ferencedBy_); -// referencedBy_.remove(sourceFqn); - -// refCount_ -=3D 1; -//logger_.info("decrementRefCount(): current ref count " +refCount_); - return refCount_; - } - - synchronized public int getRefCount() - { - return refCount_; - } - - public List getReferences() - { - return Collections.unmodifiableList(referencedBy_); - } - - synchronized public Fqn getAndRemoveFirstFqnInList() - { - return (Fqn) referencedBy_.remove(0); - } - - synchronized public void addXFqnIntoList(Fqn fqn) - { - referencedBy_.add(0, fqn); - } - - public String toString() - { - return "PI[fqn=3D" + internalFqn_ + " ref=3D" + refCount_ + " class= =3D" + clazz_.getName() + "]"; - } -} Copied: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoIns= tance.java (from rev 6551, pojo/trunk/src/main/java/org/jboss/cache/pojo/im= pl/PojoInstance.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoInstanc= e.java (rev 0) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoInstanc= e.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,119 @@ +/* + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.cache.pojo.impl; + +import java.io.Serializable; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import org.jboss.cache.pojo.Reference; + +/** + * POJO class metadata information. + * When an object is looked up or put in PojoCache, this object will be ad= vised with a CacheFieldInterceptor. + * The underlying cache stores a reference to this object (for example to = update the instance variables, etc.). + * Since this reference need to be transactional but never replicated (the= reference is only valid + * within the VM this reference is thus stored into an PojoReference (as a= transient field). + * In addition, this instance also serves as a metadata for PojoCache. E.g= ., it has a reference counting for + * multiple references and reference FQN. + * + * @author Ben Wang + */ +public class PojoInstance implements Serializable // Externalizable is no = more efficient +{ + // protected static Log log=3DLogFactory.getLog(PojoReference.class.= getLastElementAsString()); + public static final String KEY =3D InternalConstant.POJOCACHE_KEY_PREFI= X + "PojoInstance"; + public static final int INITIAL_COUNTER_VALUE =3D -1; + + static final long serialVersionUID =3D 6492134565825613209L; + + // The instance is transient to avoid replication outside the VM + private transient Object instance_; + + // Reference counting. THis will get replicated as well. This keep trac= k of number of + // other instances that referenced this fqn. + private int refCount_ =3D INITIAL_COUNTER_VALUE; + + // List of fqns that reference this fqn. + private final Set referencedBy_ =3D new HashSet(4= ); + private Class clazz_ =3D null; + private transient PojoUtil util_ =3D new PojoUtil(); + + public PojoInstance() + { + } + + public PojoInstance(Object instance) + { + set(instance); + } + + public void setPojoClass(Class clazz) + { + clazz_ =3D clazz; + } + + public Class getPojoClass() + { + return clazz_; + } + + public Object get() + { + return instance_; + } + + public void set(Object instance) + { + instance_ =3D instance; + } + + synchronized public int incrementRefCount(Reference reference) + { + if (reference =3D=3D null || reference.getFqn() =3D=3D null) + { + throw new IllegalStateException("PojoInstance.incrementRefCount()= : null sourceFqn"); + } + + if (util_ =3D=3D null) util_ =3D new PojoUtil(); + refCount_ =3D util_.incrementReferenceCount(reference, refCount_, re= ferencedBy_); + return refCount_; + } + + synchronized public int decrementRefCount(Reference reference) + { + if (reference =3D=3D null || reference.getFqn() =3D=3D null) + { + throw new IllegalStateException("PojoInstance.incrementRefCount()= : null sourceFqn"); + } + + if (!referencedBy_.contains(reference)) + throw new IllegalStateException("PojoReference.decrementRefCount(= ): reference: " + + reference + " is not present."); + + if (util_ =3D=3D null) util_ =3D new PojoUtil(); + refCount_ =3D util_.decrementReferenceCount(reference, refCount_, re= ferencedBy_); + return refCount_; + } + + synchronized public int getRefCount() + { + return refCount_; + } + + public synchronized Collection getReferences() + { + return Collections.unmodifiableCollection(new HashSet(ref= erencedBy_)); + } + + public String toString() + { + return "PI[ref=3D" + refCount_ + " class=3D" + clazz_.getName() + "]= "; + } +} Deleted: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoUt= il.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoUtil.java 2008-0= 7-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoUtil.ja= va 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,201 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ - -package org.jboss.cache.pojo.impl; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.List; - -import org.jboss.aop.InstanceAdvisor; -import org.jboss.aop.advice.Interceptor; -import org.jboss.cache.Fqn; -import org.jboss.cache.pojo.PojoCacheException; -import org.jboss.cache.pojo.collection.CachedArray; -import org.jboss.cache.pojo.collection.CachedArrayRegistry; -import org.jboss.cache.pojo.interceptors.PojoTxSynchronizationHandler; -import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterce= ptor; -import org.jboss.cache.pojo.interceptors.dynamic.CacheFieldInterceptor; -import org.jboss.cache.pojo.util.MethodCall; - -/** - * Utility class for method wrappers that we are interested to rollback (i= .e., rollback). - * - * @author Ben Wang - * @version $Id$ - */ -public class PojoUtil -{ - public void attachInterceptor(Object pojo, InstanceAdvisor advisor, Int= erceptor interceptor) - { - _attachInterceptor(pojo, advisor, interceptor); - Method method =3D MethodDeclarations.undoAttachInterceptor; - MethodCall mc =3D new MethodCall(method, new Object[] {pojo, advisor= , interceptor}, this); - addUndo(mc); - } - - public void detachInterceptor(InstanceAdvisor advisor, Interceptor inte= rceptor) - { - _detachInterceptor(advisor, interceptor); - Method method =3D MethodDeclarations.undoDetachInterceptor; - MethodCall mc =3D new MethodCall(method, new Object[] {advisor, inte= rceptor}, this); - addUndo(mc); - } - - private void addUndo(MethodCall mc) - { - PojoTxSynchronizationHandler handler =3D PojoTxSynchronizationHandle= r.current(); - if (handler !=3D null) - handler.addToList(mc); - } - - public void detachCollectionInterceptor(AbstractCollectionInterceptor i= nterceptor) { - interceptor.detach(true); - Method method =3D MethodDeclarations.undoDetachCollectionInterceptor; - MethodCall mc =3D new MethodCall(method, new Object[] {interceptor},= this); - addUndo(mc); - } - - public void attachArray(Object array, CachedArray cached) { - CachedArrayRegistry.register(array, cached); - Method method =3D MethodDeclarations.undoAttachArray; - MethodCall mc =3D new MethodCall(method, new Object[] {array, cached= }, this); - addUndo(mc); - } - - public void detachArray(Object array, CachedArray cached) { - CachedArrayRegistry.unregister(array); - Method method =3D MethodDeclarations.undoDetachArray; - MethodCall mc =3D new MethodCall(method, new Object[] {array, cached= }, this); - addUndo(mc); - } - - public void undoAttachInterceptor(Object pojo, InstanceAdvisor advisor,= Interceptor interceptor) - { - _detachInterceptor(advisor, interceptor); - } - - public void undoDetachInterceptor(InstanceAdvisor advisor, Interceptor = interceptor) - { - Object pojo =3D ((CacheFieldInterceptor) interceptor).getAopInstance= ().get(); - if (pojo =3D=3D null) - { - throw new PojoCacheException("PojoUtil.detachInterceptor(): null = pojo"); - } - - _attachInterceptor(pojo, advisor, interceptor); - } - - public void undoDetachCollectionInterceptor(AbstractCollectionIntercept= or interceptor) { - interceptor.attach(null, false); - } - - public void undoAttachArray(Object array, CachedArray cached) { - CachedArrayRegistry.unregister(array); - } - - public void undoDetachArray(Object array, CachedArray cached) { - CachedArrayRegistry.register(array, cached); - } - - public void inMemorySubstitution(Object obj, Field field, Object newVal= ue) - { - Method method =3D MethodDeclarations.undoInMemorySubstitution; - Object[] args; - try - { - args =3D new Object[]{obj, field, field.get(obj)}; - } - catch (Throwable t) - { - throw new PojoCacheException("Severe error building undo list", t= ); - } - - _inMemorySubstitution(obj, field, newValue); - - MethodCall mc =3D new MethodCall(method, args, this); - addUndo(mc); - } - - public void undoInMemorySubstitution(Object obj, Field field, Object ol= dValue) - { - _inMemorySubstitution(obj, field, oldValue); - } - - private void _attachInterceptor(Object pojo, InstanceAdvisor advisor, I= nterceptor interceptor) - { - advisor.appendInterceptor(interceptor); - } - - private void _inMemorySubstitution(Object obj, Field field, Object newV= alue) - { - try - { - field.set(obj, newValue); - } - catch (IllegalAccessException e) - { - throw new PojoCacheException( - "PojoUtil.inMemorySubstitution(): Can't swap out the class = of field \" " + - "+field.getLastElementAsString()," + e); - } - } - - private void _detachInterceptor(InstanceAdvisor advisor, Interceptor in= terceptor) - { - advisor.removeInterceptor(interceptor.getName()); - // retrieve pojo - Object pojo =3D ((CacheFieldInterceptor) interceptor).getAopInstance= ().get(); - - if (pojo =3D=3D null) - { - throw new PojoCacheException("PojoUtil.detachInterceptor(): null = pojo"); - } - } - - public int incrementReferenceCount(Fqn sourceFqn, int count, List= refList) - { - int ret =3D _incrementReferenceCount(sourceFqn, count, refList); - Method method =3D MethodDeclarations.undoIncrementReferenceCount; - Object[] args =3D new Object[]{sourceFqn, count, refList}; - MethodCall mc =3D new MethodCall(method, args, this); - addUndo(mc); - return ret; - } - - public int undoIncrementReferenceCount(Fqn sourceFqn, int count, List r= efList) - { - return _decrementReferenceCount(sourceFqn, count, refList); - } - - private int _incrementReferenceCount(Fqn sourceFqn, int count, List ref= List) - { - refList.add(sourceFqn); - return count + 1; - } - - public int decrementReferenceCount(Fqn sourceFqn, int count, List= refList) - { - int ret =3D _decrementReferenceCount(sourceFqn, count, refList); - Method method =3D MethodDeclarations.undoDecrementReferenceCount; - Object[] args =3D new Object[]{sourceFqn, count, refList}; - MethodCall mc =3D new MethodCall(method, args, this); - addUndo(mc); - return ret; - } - - public int undoDecrementReferenceCount(Fqn sourceFqn, int count, List r= efList) - { - return _incrementReferenceCount(sourceFqn, count, refList); - } - - private int _decrementReferenceCount(Fqn sourceFqn, int count, List ref= List) - { - refList.remove(sourceFqn); - return count - 1; - } -} Copied: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoUti= l.java (from rev 6374, pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/P= ojoUtil.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoUtil.ja= va (rev 0) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/PojoUtil.ja= va 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,203 @@ +/* + * JBoss, Home of Professional Open Source + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ + +package org.jboss.cache.pojo.impl; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.List; +import java.util.Set; + +import org.jboss.aop.InstanceAdvisor; +import org.jboss.aop.advice.Interceptor; +import org.jboss.cache.Fqn; +import org.jboss.cache.pojo.PojoCacheException; +import org.jboss.cache.pojo.Reference; +import org.jboss.cache.pojo.collection.CachedArray; +import org.jboss.cache.pojo.collection.CachedArrayRegistry; +import org.jboss.cache.pojo.interceptors.PojoTxSynchronizationHandler; +import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterce= ptor; +import org.jboss.cache.pojo.interceptors.dynamic.CacheFieldInterceptor; +import org.jboss.cache.pojo.util.MethodCall; + +/** + * Utility class for method wrappers that we are interested to rollback (i= .e., rollback). + * + * @author Ben Wang + * @version $Id$ + */ +public class PojoUtil +{ + public void attachInterceptor(Object pojo, InstanceAdvisor advisor, Int= erceptor interceptor) + { + _attachInterceptor(pojo, advisor, interceptor); + Method method =3D MethodDeclarations.undoAttachInterceptor; + MethodCall mc =3D new MethodCall(method, new Object[] {pojo, advisor= , interceptor}, this); + addUndo(mc); + } + + public void detachInterceptor(InstanceAdvisor advisor, Interceptor inte= rceptor) + { + _detachInterceptor(advisor, interceptor); + Method method =3D MethodDeclarations.undoDetachInterceptor; + MethodCall mc =3D new MethodCall(method, new Object[] {advisor, inte= rceptor}, this); + addUndo(mc); + } + + private void addUndo(MethodCall mc) + { + PojoTxSynchronizationHandler handler =3D PojoTxSynchronizationHandle= r.current(); + if (handler !=3D null) + handler.addToList(mc); + } + + public void detachCollectionInterceptor(AbstractCollectionInterceptor i= nterceptor) { + interceptor.detach(true); + Method method =3D MethodDeclarations.undoDetachCollectionInterceptor; + MethodCall mc =3D new MethodCall(method, new Object[] {interceptor},= this); + addUndo(mc); + } + + public void attachArray(Object array, CachedArray cached) { + CachedArrayRegistry.register(array, cached); + Method method =3D MethodDeclarations.undoAttachArray; + MethodCall mc =3D new MethodCall(method, new Object[] {array, cached= }, this); + addUndo(mc); + } + + public void detachArray(Object array, CachedArray cached) { + CachedArrayRegistry.unregister(array); + Method method =3D MethodDeclarations.undoDetachArray; + MethodCall mc =3D new MethodCall(method, new Object[] {array, cached= }, this); + addUndo(mc); + } + + public void undoAttachInterceptor(Object pojo, InstanceAdvisor advisor,= Interceptor interceptor) + { + _detachInterceptor(advisor, interceptor); + } + + public void undoDetachInterceptor(InstanceAdvisor advisor, Interceptor = interceptor) + { + Object pojo =3D ((CacheFieldInterceptor) interceptor).getAopInstance= ().get(); + if (pojo =3D=3D null) + { + throw new PojoCacheException("PojoUtil.detachInterceptor(): null = pojo"); + } + + _attachInterceptor(pojo, advisor, interceptor); + } + + public void undoDetachCollectionInterceptor(AbstractCollectionIntercept= or interceptor) { + interceptor.attach(null, false); + } + + public void undoAttachArray(Object array, CachedArray cached) { + CachedArrayRegistry.unregister(array); + } + + public void undoDetachArray(Object array, CachedArray cached) { + CachedArrayRegistry.register(array, cached); + } + + public void inMemorySubstitution(Object obj, Field field, Object newVal= ue) + { + Method method =3D MethodDeclarations.undoInMemorySubstitution; + Object[] args; + try + { + args =3D new Object[]{obj, field, field.get(obj)}; + } + catch (Throwable t) + { + throw new PojoCacheException("Severe error building undo list", t= ); + } + + _inMemorySubstitution(obj, field, newValue); + + MethodCall mc =3D new MethodCall(method, args, this); + addUndo(mc); + } + + public void undoInMemorySubstitution(Object obj, Field field, Object ol= dValue) + { + _inMemorySubstitution(obj, field, oldValue); + } + + private void _attachInterceptor(Object pojo, InstanceAdvisor advisor, I= nterceptor interceptor) + { + advisor.appendInterceptor(interceptor); + } + + private void _inMemorySubstitution(Object obj, Field field, Object newV= alue) + { + try + { + field.set(obj, newValue); + } + catch (IllegalAccessException e) + { + throw new PojoCacheException( + "PojoUtil.inMemorySubstitution(): Can't swap out the class = of field \" " + + "+field.getLastElementAsString()," + e); + } + } + + private void _detachInterceptor(InstanceAdvisor advisor, Interceptor in= terceptor) + { + advisor.removeInterceptor(interceptor.getName()); + // retrieve pojo + Object pojo =3D ((CacheFieldInterceptor) interceptor).getAopInstance= ().get(); + + if (pojo =3D=3D null) + { + throw new PojoCacheException("PojoUtil.detachInterceptor(): null = pojo"); + } + } + + public int incrementReferenceCount(Reference reference, int count, Set<= Reference> referencedBy_) + { + int ret =3D _incrementReferenceCount(reference, count, referencedBy_= ); + Method method =3D MethodDeclarations.undoIncrementReferenceCount; + Object[] args =3D new Object[]{reference, count, referencedBy_}; + MethodCall mc =3D new MethodCall(method, args, this); + addUndo(mc); + return ret; + } + + public int undoIncrementReferenceCount(Reference reference, int count, = Set refList) + { + return _decrementReferenceCount(reference, count, refList); + } + + private int _incrementReferenceCount(Reference reference, int count, Se= t referencedBy_) + { + referencedBy_.add(reference); + return count + 1; + } + + public int decrementReferenceCount(Reference reference, int count, Set<= Reference> referencedBy_) + { + int ret =3D _decrementReferenceCount(reference, count, referencedBy_= ); + Method method =3D MethodDeclarations.undoDecrementReferenceCount; + Object[] args =3D new Object[]{reference, count, referencedBy_}; + MethodCall mc =3D new MethodCall(method, args, this); + addUndo(mc); + return ret; + } + + public int undoDecrementReferenceCount(Reference reference, int count, = Set refList) + { + return _incrementReferenceCount(reference, count, refList); + } + + private int _decrementReferenceCount(Reference reference, int count, Se= t referencedBy_) + { + referencedBy_.remove(reference); + return count - 1; + } +} Copied: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Referen= ceImpl.java (from rev 6374, pojo/trunk/src/main/java/org/jboss/cache/pojo/i= mpl/ReferenceImpl.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/ReferenceIm= pl.java (rev 0) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/ReferenceIm= pl.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,110 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.cache.pojo.impl; + +import java.io.Serializable; + +import net.jcip.annotations.Immutable; + +import org.jboss.cache.Fqn; +import org.jboss.cache.pojo.Reference; + +/** + * A reference from an attached object to another attached object. This cl= ass also contains the name + * of the field that contains the reference. + * + * @author Dan Berindei + */ +(a)Immutable +public final class ReferenceImpl implements Reference, Serializable +{ + private static final long serialVersionUID =3D 2647262858847953704L; + + private Fqn fqn; + private String key; + + public ReferenceImpl(Fqn fqn) + { + this(fqn, null); + } + + /** + * @param fqn Fqn of the referring node. Cannot be n= ull. + * @param key Name of the field, index in the field or key in the colle= ction that is containing the reference. + */ + public ReferenceImpl(Fqn fqn, String key) + { + if (fqn =3D=3D null) + throw new IllegalArgumentException("Fqn can not be null!!"); + + this.fqn =3D fqn; + this.key =3D key; + } + + public String getKey() + { + return key; + } + + public Fqn getFqn() + { + return fqn; + } + + private boolean equals(Object o1, Object o2) + { + if (o1 =3D=3D o2) + return true; + + if (o1 !=3D null && o1.equals(o2)) + return true; + + return false; + } + + @Override + public int hashCode() + { + int result =3D 629 * fqn.hashCode(); + + if (key !=3D null) + result =3D 37 * result + key.hashCode(); + + return result; + } + + @Override + public boolean equals(Object o) + { + if (o instanceof Reference) + return equals(((ReferenceImpl) o).fqn, fqn) && equals(((Reference= Impl) o).key, key); + + return false; + } + + @Override + public String toString() + { + return "Reference[fqn=3D" + fqn + " field=3D" + key + "]"; + } +} \ No newline at end of file Deleted: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Referr= er.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/Referrer.java 2008-0= 7-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Referrer.ja= va 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,89 +0,0 @@ -/* -* JBoss, Home of Professional Open Source -* Copyright 2005, JBoss Inc., and individual contributors as indicated -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* This is free software; you can redistribute it and/or modify it -* under the terms of the GNU Lesser General Public License as -* published by the Free Software Foundation; either version 2.1 of -* the License, or (at your option) any later version. -* -* This software is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this software; if not, write to the Free -* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -* 02110-1301 USA, or see the FSF site: http://www.fsf.org. -*/ - -package org.jboss.cache.pojo.impl; - -import org.jboss.cache.Fqn; - -/** - * A referrer node refers to an internal node. - * = - * @author Jason T. Greene - */ -final class Referrer -{ - private Fqn fqn; - private String field; - - Referrer(Fqn fqn) - { - this(fqn, null); - } - = - Referrer(Fqn fqn, String field) - { - if (fqn =3D=3D null) - throw new IllegalArgumentException("Fqn can not be null!!"); - = - this.fqn =3D fqn; - this.field =3D field; - } - - public String getField() - { - return field; - } - - public Fqn getFqn() - { - return fqn; - } - = - private boolean equals(Object o1, Object o2) - { - if (o1 =3D=3D o2) - return true; - = - if (o1 !=3D null && o1.equals(o2)) - return true; - = - return false; - } - = - public int hashCode() - { - int result =3D 629 * fqn.hashCode(); - - if (field !=3D null) - result =3D 37 * result + field.hashCode(); - = - return result; - } - = - public boolean equals(Object o) - { - if (o instanceof Referrer) - return equals(((Referrer)o).fqn, fqn) && equals(((Referrer)o).fie= ld, field); - = - return false; - } -} \ No newline at end of file Deleted: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Serial= izableObjectHandler.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/SerializableObjectHa= ndler.java 2008-07-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Serializabl= eObjectHandler.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,95 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ - -package org.jboss.cache.pojo.impl; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jboss.cache.Cache; -import org.jboss.cache.CacheException; -import org.jboss.cache.CacheSPI; -import org.jboss.cache.Fqn; - -/** - * Handle Serializable object cache management. - * - * @author Ben Wang - * @version $Id$ - */ -class SerializableObjectHandler extends AbstractHandler -{ - private Cache cache; - private PojoCacheImpl pojoCache; - private InternalHelper internal_; - private final Log log_ =3D LogFactory.getLog(SerializableObjectHandler.= class); - - public SerializableObjectHandler(PojoCacheImpl cache, InternalHelper in= ternal) - { - pojoCache =3D cache; - this.cache =3D pojoCache.getCache(); - internal_ =3D internal; - } - = - protected Fqn getFqn(Object obj) - { - // Not supported - return null; - } - = - @Override - protected boolean handles(Class clazz) - { - return Serializable.class.isAssignableFrom(clazz); - } - - @Override - protected Object get(Fqn fqn, Class clazz, PojoInstance pojoInstance) t= hrows CacheException - { - Object obj =3D internal_.get(fqn, InternalConstant.SERIALIZED); - return obj; - } - - - @Override - protected void put(Fqn fqn, Fqn referencingFqn, Object obj) throw= s CacheException - { - // Note that JBoss Serialization can serialize any type now. - if (log_.isDebugEnabled()) - { - log_.debug("put(): obj (" + obj.getClass() + ") is non-advisable = but serialize it anyway. " - + "Note that if it is non-serializable we require to u= se JBoss Serialization."); - } - - putIntoCache(fqn, obj); - } - - private void putIntoCache(Fqn fqn, Object obj) - throws CacheException - { - Map map =3D new HashMap(); - - // Special optimization here. - PojoInstance pojoInstance =3D new PojoInstance(); - pojoInstance.set(obj); - pojoInstance.setPojoClass(obj.getClass()); - map.put(PojoInstance.KEY, pojoInstance); - // Note that we will only have one key in this fqn. - map.put(InternalConstant.SERIALIZED, obj); - internal_.put(fqn, map); - } - - @Override - protected Object remove(Fqn fqn, Fqn referenceingFqn, Object resu= lt) throws CacheException - { - cache.removeNode(fqn); - return result; - } -} \ No newline at end of file Copied: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Seriali= zableObjectHandler.java (from rev 6374, pojo/trunk/src/main/java/org/jboss/= cache/pojo/impl/SerializableObjectHandler.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Serializabl= eObjectHandler.java (rev 0) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/impl/Serializabl= eObjectHandler.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,95 @@ +/* + * JBoss, Home of Professional Open Source + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ + +package org.jboss.cache.pojo.impl; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.cache.Cache; +import org.jboss.cache.CacheException; +import org.jboss.cache.Fqn; +import org.jboss.cache.pojo.Reference; + +/** + * Handle Serializable object cache management. + * + * @author Ben Wang + * @version $Id$ + */ +class SerializableObjectHandler extends AbstractHandler +{ + private Cache cache; + private PojoCacheImpl pojoCache; + private InternalHelper internal_; + private final Log log_ =3D LogFactory.getLog(SerializableObjectHandler.= class); + + public SerializableObjectHandler(PojoCacheImpl cache, InternalHelper in= ternal) + { + pojoCache =3D cache; + this.cache =3D pojoCache.getCache(); + internal_ =3D internal; + } + + protected Fqn getFqn(Object obj) + { + // Not supported + return null; + } + + @Override + protected boolean handles(Class clazz) + { + return Serializable.class.isAssignableFrom(clazz); + } + + @Override + protected Object get(Fqn fqn, Class clazz, PojoInstance pojoInstance) t= hrows CacheException + { + Object obj =3D internal_.get(fqn, InternalConstant.SERIALIZED); + return obj; + } + + + @Override + protected void put(Fqn fqn, Reference reference, Object obj) throws = CacheException + { + // Note that JBoss Serialization can serialize any type now. + if (log_.isDebugEnabled()) + { + log_.debug("put(): obj (" + obj.getClass() + ") is non-advisable = but serialize it anyway. " + + "Note that if it is non-serializable we require to u= se JBoss Serialization."); + } + + putIntoCache(fqn, obj); + } + + private void putIntoCache(Fqn fqn, Object obj) + throws CacheException + { + Map map =3D new HashMap(); + + // Special optimization here. + PojoInstance pojoInstance =3D new PojoInstance(); + pojoInstance.set(obj); + pojoInstance.setPojoClass(obj.getClass()); + map.put(PojoInstance.KEY, pojoInstance); + // Note that we will only have one key in this fqn. + map.put(InternalConstant.SERIALIZED, obj); + internal_.put(fqn, map); + } + + @Override + protected Object remove(Fqn fqn, Reference reference, Object result)= throws CacheException + { + cache.removeNode(fqn); + return result; + } +} \ No newline at end of file Deleted: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/jmx/PojoCac= heJmxWrapper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/jmx/PojoCacheJmxWrapper.j= ava 2008-07-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/jmx/PojoCacheJmx= Wrapper.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,1033 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2006, Red Hat Middleware LLC, and individual contributors - * as indicated by the @author tags. See the copyright.txt file in the - * distribution for a full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.jboss.cache.pojo.jmx; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jboss.cache.CacheException; -import org.jboss.cache.CacheStatus; -import org.jboss.cache.config.BuddyReplicationConfig; -import org.jboss.cache.config.CacheLoaderConfig; -import org.jboss.cache.config.Configuration; -import org.jboss.cache.config.ConfigurationException; -import org.jboss.cache.config.EvictionConfig; -import org.jboss.cache.config.RuntimeConfig; -import org.jboss.cache.factories.XmlConfigurationParser; -import org.jboss.cache.jmx.CacheJmxWrapper; -import org.jboss.cache.jmx.CacheNotificationListener; -import org.jboss.cache.pojo.PojoCache; -import org.jboss.cache.pojo.PojoCacheAlreadyDetachedException; -import org.jboss.cache.pojo.PojoCacheException; -import org.jboss.cache.pojo.PojoCacheFactory; -import org.jboss.cache.pojo.impl.PojoCacheImpl; -import org.jgroups.Channel; -import org.jgroups.ChannelFactory; -import org.jgroups.jmx.JChannelFactoryMBean; -import org.w3c.dom.Element; - -import javax.management.AttributeChangeNotification; -import javax.management.JMException; -import javax.management.ListenerNotFoundException; -import javax.management.MBeanNotificationInfo; -import javax.management.MBeanRegistration; -import javax.management.MBeanServer; -import javax.management.NotificationEmitter; -import javax.management.NotificationFilter; -import javax.management.NotificationListener; -import javax.management.ObjectName; -import javax.transaction.TransactionManager; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -public class PojoCacheJmxWrapper - implements PojoCacheJmxWrapperMBean, MBeanRegistration, Notificati= onEmitter -{ - private Log log =3D LogFactory.getLog(getClass().getName()); - - private boolean registerInterceptors =3D true; - private Configuration config; - private MBeanServer server; - private String cacheObjectName; - private PojoCache pojoCache; - private CacheJmxWrapper plainCacheWrapper; - private boolean registerPlainCache =3D true; - private boolean plainCacheRegistered; - private CacheStatus cacheStatus; - private boolean registered; - private final Set pendingListeners =3D - new HashSet(); - - // Legacy config support - - private Element buddyReplConfig; - private Element evictionConfig; - private Element cacheLoaderConfig; - private Element clusterConfig; - private JChannelFactoryMBean multiplexerService; - - /** - * Default constructor. - */ - public PojoCacheJmxWrapper() - { - cacheStatus =3D CacheStatus.INSTANTIATED; - } - - /** - * Creates a PojoCacheJmxWrapper that wraps the given PojoCache. - * - * @param toWrap the cache - */ - public PojoCacheJmxWrapper(PojoCache toWrap) - { - this(); - setPojoCache(toWrap); - } - - // PojoCacheMBean - - public PojoCache getPojoCache() - { - return pojoCache; - } - - public Configuration getConfiguration() - { - Configuration cfg =3D (pojoCache =3D=3D null ? config : pojoCache.ge= tCache().getConfiguration()); - if (cfg =3D=3D null) - { - cfg =3D config =3D new Configuration(); - } - return cfg; - } - - public String getInternalLocation(Object pojo) throws PojoCacheAlreadyD= etachedException - { - return pojoCache.getPojoID(pojo); - } - - public String getUnderlyingCacheObjectName() - { - return plainCacheWrapper =3D=3D null ? null : plainCacheWrapper.getC= acheObjectName(); - } - - public void create() throws PojoCacheException - { - if (cacheStatus.createAllowed() =3D=3D false) - { - if (cacheStatus.needToDestroyFailedCache()) - destroy(); - else - return; - } - - try - { - cacheStatus =3D CacheStatus.CREATING; - - if (pojoCache =3D=3D null) - { - if (config =3D=3D null) - { - throw new ConfigurationException("Must call setConfiguratio= n() " + - "or setPojoCache() before call to create()"); - } - - constructCache(); - } - - pojoCache.create(); - - registerPlainCache(); - - plainCacheWrapper.create(); - - cacheStatus =3D CacheStatus.CREATED; - } - catch (Throwable t) - { - handleLifecycleTransitionFailure(t); - } - } - - public void start() throws PojoCacheException - { - if (cacheStatus.startAllowed() =3D=3D false) - { - if (cacheStatus.needToDestroyFailedCache()) - destroy(); - if (cacheStatus.needCreateBeforeStart()) - create(); - else - return; - } - - try - { - int oldState =3D getState(); - cacheStatus =3D CacheStatus.STARTING; - int startingState =3D getState(); - sendStateChangeNotification(oldState, startingState, getClass().g= etSimpleName() + " starting", null); - - pojoCache.start(); - - plainCacheWrapper.start(); - cacheStatus =3D CacheStatus.STARTED; - sendStateChangeNotification(startingState, getState(), getClass()= .getSimpleName() + " started", null); - } - catch (Throwable t) - { - handleLifecycleTransitionFailure(t); - } - } - - public void stop() - { - if (cacheStatus.stopAllowed() =3D=3D false) - { - return; - } - - // Trying to stop() from FAILED is valid, but may not work - boolean failed =3D cacheStatus =3D=3D CacheStatus.FAILED; - - try - { - int oldState =3D getState(); - cacheStatus =3D CacheStatus.STOPPING; - int stoppingState =3D getState(); - sendStateChangeNotification(oldState, stoppingState, getClass().g= etSimpleName() + " stopping", null); - - cacheStatus =3D CacheStatus.STOPPING; - - pojoCache.stop(); - - plainCacheWrapper.stop(); - cacheStatus =3D CacheStatus.STOPPED; - sendStateChangeNotification(stoppingState, getState(), getClass()= .getSimpleName() + " stopped", null); - } - catch (Throwable t) - { - if (failed) - { - log.warn("Attempted to stop() from FAILED state, " + - "but caught exception; try calling destroy()", t); - } - handleLifecycleTransitionFailure(t); - } - } - - public void destroy() - { - if (cacheStatus.destroyAllowed() =3D=3D false) - { - if (cacheStatus.needStopBeforeDestroy()) - stop(); - else - return; - } - - try - { - cacheStatus =3D CacheStatus.DESTROYING; - - if (pojoCache !=3D null) - pojoCache.destroy(); - - // The cache is destroyed, so we shouldn't leave it registered - // in JMX even if we didn't register it in create() - unregisterPlainCache(); - - if (plainCacheWrapper !=3D null) - plainCacheWrapper.destroy(); - } - finally - { - // We always proceed to DESTROYED - cacheStatus =3D CacheStatus.DESTROYED; - } - } - - public CacheStatus getCacheStatus() - { - return cacheStatus; - } - - public int getState() - { - switch (cacheStatus) - { - case INSTANTIATED: - case CREATING: - return registered ? REGISTERED : UNREGISTERED; - case CREATED: - return CREATED; - case STARTING: - return STARTING; - case STARTED: - return STARTED; - case STOPPING: - return STOPPING; - case STOPPED: - case DESTROYING: - return STOPPED; - case DESTROYED: - return registered ? DESTROYED : UNREGISTERED; - case FAILED: - default: - return FAILED; - } - } - - public boolean getRegisterPlainCache() - { - return registerPlainCache; - } - - public void setRegisterPlainCache(boolean registerPlainCache) - { - this.registerPlainCache =3D registerPlainCache; - } - - public boolean getRegisterInterceptors() - { - return registerInterceptors; - } - - public void setRegisterInterceptors(boolean register) - { - this.registerInterceptors =3D register; - } - - // ---------------------------------------------------- LegacyConfigur= ation - - public Element getBuddyReplicationConfig() - { - return buddyReplConfig; - } - - public Element getCacheLoaderConfig() - { - return cacheLoaderConfig; - } - - public Element getCacheLoaderConfiguration() - { - return getCacheLoaderConfig(); - } - - public String getCacheMode() - { - return getConfiguration().getCacheModeString(); - } - - public String getClusterName() - { - return getConfiguration().getClusterName(); - } - - public String getClusterProperties() - { - return getConfiguration().getClusterConfig(); - } - - public Element getClusterConfig() - { - return clusterConfig; - } - - public Element getEvictionPolicyConfig() - { - return evictionConfig; - } - - public boolean getExposeManagementStatistics() - { - return getConfiguration().getExposeManagementStatistics(); - } - - public boolean getUseInterceptorMbeans() - { - return getExposeManagementStatistics(); - } - - public boolean getFetchInMemoryState() - { - return getConfiguration().isFetchInMemoryState(); - } - - public long getStateRetrievalTimeout() - { - return getConfiguration().getStateRetrievalTimeout(); - } - - @Deprecated - public void setInitialStateRetrievalTimeout(long timeout) - { - setStateRetrievalTimeout(timeout); - } - - public String getIsolationLevel() - { - return getConfiguration().getIsolationLevelString(); - } - - public long getLockAcquisitionTimeout() - { - return getConfiguration().getLockAcquisitionTimeout(); - } - - public JChannelFactoryMBean getMultiplexerService() - { - return multiplexerService; - } - - public String getMultiplexerStack() - { - return getConfiguration().getMultiplexerStack(); - } - - public ChannelFactory getMuxChannelFactory() - { - return getConfiguration().getRuntimeConfig().getMuxChannelFactory(); - } - - public String getNodeLockingScheme() - { - return getConfiguration().getNodeLockingSchemeString(); - } - - public long getReplQueueInterval() - { - return getConfiguration().getReplQueueInterval(); - } - - public int getReplQueueMaxElements() - { - return getConfiguration().getReplQueueMaxElements(); - } - - public String getReplicationVersion() - { - return getConfiguration().getReplVersionString(); - } - - public boolean getSyncCommitPhase() - { - return getConfiguration().isSyncCommitPhase(); - } - - public long getSyncReplTimeout() - { - return getConfiguration().getSyncReplTimeout(); - } - - public boolean getSyncRollbackPhase() - { - return getConfiguration().isSyncRollbackPhase(); - } - - public TransactionManager getTransactionManager() - { - return getConfiguration().getRuntimeConfig().getTransactionManager(); - } - - public String getTransactionManagerLookupClass() - { - return getConfiguration().getTransactionManagerLookupClass(); - } - - public boolean getUseRegionBasedMarshalling() - { - return getConfiguration().isUseRegionBasedMarshalling(); - } - - public boolean getUseReplQueue() - { - return getConfiguration().isUseReplQueue(); - } - - public boolean isInactiveOnStartup() - { - return getConfiguration().isInactiveOnStartup(); - } - - public void setBuddyReplicationConfig(Element config) - { - BuddyReplicationConfig brc =3D null; - if (config !=3D null) - { - brc =3D XmlConfigurationParser.parseBuddyReplicationConfig(config= ); - } - getConfiguration().setBuddyReplicationConfig(brc); - this.buddyReplConfig =3D config; - } - - public void setCacheLoaderConfig(Element cache_loader_config) - { - CacheLoaderConfig clc =3D null; - if (cache_loader_config !=3D null) - { - clc =3D XmlConfigurationParser.parseCacheLoaderConfig(cache_loade= r_config); - } - getConfiguration().setCacheLoaderConfig(clc); - this.cacheLoaderConfig =3D cache_loader_config; - } - - public void setCacheLoaderConfiguration(Element config) - { - log.warn("MBean attribute 'CacheLoaderConfiguration' is deprecated; = " + - "use 'CacheLoaderConfig'"); - setCacheLoaderConfig(config); - } - - public void setCacheMode(String mode) throws Exception - { - getConfiguration().setCacheModeString(mode); - } - - public void setClusterConfig(Element config) - { - String props =3D null; - if (config !=3D null) - { - props =3D XmlConfigurationParser.parseClusterConfigXml(config); - } - getConfiguration().setClusterConfig(props); - this.clusterConfig =3D config; - } - - @Deprecated - public long getInitialStateRetrievalTimeout() - { - return getStateRetrievalTimeout(); - } - - public void setClusterName(String name) - { - getConfiguration().setClusterName(name); - } - - public void setClusterProperties(String cluster_props) - { - getConfiguration().setClusterConfig(cluster_props); - } - - public void setEvictionPolicyConfig(Element config) - { - EvictionConfig ec =3D null; - if (config !=3D null) - { - ec =3D XmlConfigurationParser.parseEvictionConfig(config); - } - getConfiguration().setEvictionConfig(ec); - this.evictionConfig =3D config; - } - - public void setExposeManagementStatistics(boolean expose) - { - getConfiguration().setExposeManagementStatistics(expose); - } - - public void setUseInterceptorMbeans(boolean use) - { - log.warn("MBean attribute 'UseInterceptorMbeans' is deprecated; " + - "use 'ExposeManagementStatistics'"); - setExposeManagementStatistics(use); - } - - public void setFetchInMemoryState(boolean flag) - { - getConfiguration().setFetchInMemoryState(flag); - } - - public void setInactiveOnStartup(boolean inactiveOnStartup) - { - getConfiguration().setInactiveOnStartup(inactiveOnStartup); - } - - public void setStateRetrievalTimeout(long timeout) - { - getConfiguration().setStateRetrievalTimeout(timeout); - } - - public void setIsolationLevel(String level) - { - getConfiguration().setIsolationLevelString(level); - } - - public void setLockAcquisitionTimeout(long timeout) - { - getConfiguration().setLockAcquisitionTimeout(timeout); - } - - public void setMultiplexerService(JChannelFactoryMBean muxService) - { - this.multiplexerService =3D muxService; - } - - public void setMultiplexerStack(String stackName) - { - getConfiguration().setMultiplexerStack(stackName); - } - - public void setMuxChannelFactory(ChannelFactory factory) - { - getConfiguration().getRuntimeConfig().setMuxChannelFactory(factory); - } - - public void setNodeLockingScheme(String nodeLockingScheme) - { - getConfiguration().setNodeLockingSchemeString(nodeLockingScheme); - } - - public void setReplQueueInterval(long interval) - { - getConfiguration().setReplQueueInterval(interval); - } - - public void setReplQueueMaxElements(int max_elements) - { - getConfiguration().setReplQueueMaxElements(max_elements); - } - - public void setReplicationVersion(String version) - { - getConfiguration().setReplVersionString(version); - } - - public void setSyncCommitPhase(boolean sync_commit_phase) - { - getConfiguration().setSyncCommitPhase(sync_commit_phase); - } - - public void setSyncReplTimeout(long timeout) - { - getConfiguration().setSyncReplTimeout(timeout); - } - - public void setSyncRollbackPhase(boolean sync_rollback_phase) - { - getConfiguration().setSyncRollbackPhase(sync_rollback_phase); - } - - public void setTransactionManager(TransactionManager manager) - { - getConfiguration().getRuntimeConfig().setTransactionManager(manager); - } - - public void setTransactionManagerLookupClass(String cl) throws Exception - { - getConfiguration().setTransactionManagerLookupClass(cl); - } - - public void setUseRegionBasedMarshalling(boolean isTrue) - { - getConfiguration().setUseRegionBasedMarshalling(isTrue); - } - - public void setUseReplQueue(boolean flag) - { - getConfiguration().setUseReplQueue(flag); - } - - // ------------------------------------------------------ MBeanRegistr= ation - - /** - * Caches the provided server and objName. - */ - public ObjectName preRegister(MBeanServer server, ObjectName objName) - throws Exception - { - this.server =3D server; - - if (cacheObjectName =3D=3D null) - { - cacheObjectName =3D objName.getCanonicalName(); - } - - if (plainCacheWrapper !=3D null) - plainCacheWrapper.setNotificationServiceName(cacheObjectName); - - return new ObjectName(cacheObjectName); - } - - /** - * Registers the CacheJmxWrapperMBean, - * if {@link #getRegisterPlainCache()} is true. - */ - public void postRegister(Boolean registrationDone) - { - if (Boolean.TRUE.equals(registrationDone) && registerPlainCache) - { - log.debug("Registered in JMX under " + cacheObjectName); - - if (plainCacheWrapper !=3D null) - { - try - { - registerPlainCache(); - } - catch (Exception e) - { - log.error("Caught exception registering plain cache with JM= X", e); - } - } - - registered =3D true; - } - } - - /** - * No-op. - */ - public void preDeregister() throws Exception - { - } - - /** - * Unregisters the CacheJmxWrapper, if {@link #getRegisterPlainCache()}= is - * true. - */ - public void postDeregister() - { - if (plainCacheWrapper !=3D null) - { - unregisterPlainCache(); - } - - registered =3D false; - } - - // ---------------------------------------------------- NotificationEm= itter = - - public void removeNotificationListener(NotificationListener listener, - NotificationFilter filter, - Object handback) - throws ListenerNotFoundException - { - synchronized (pendingListeners) - { - boolean found =3D pendingListeners.remove(new NotificationListene= rArgs(listener, filter, handback)); - - if (plainCacheWrapper !=3D null) - { - plainCacheWrapper.removeNotificationListener(listener, filter,= handback); - } - else if (!found) - { - throw new ListenerNotFoundException(); - } - } - } - - public void addNotificationListener(NotificationListener listener, - NotificationFilter filter, - Object handback) - throws IllegalArgumentException - { - synchronized (pendingListeners) - { - if (plainCacheWrapper !=3D null) - { - plainCacheWrapper.addNotificationListener(listener, filter, ha= ndback); - } - else - { - // Add it for addition to the plainCacheWrapper when it's crea= ted - pendingListeners.add(new NotificationListenerArgs(listener, fi= lter, handback)); - } - } - - } - - public MBeanNotificationInfo[] getNotificationInfo() - { - return CacheNotificationListener.getNotificationInfo(); - } - - public void removeNotificationListener(NotificationListener listener) - throws ListenerNotFoundException - { - synchronized (pendingListeners) - { - boolean found =3D false; - for (Iterator iter =3D pendingListeners= .iterator(); - iter.hasNext();) - { - NotificationListenerArgs args =3D iter.next(); - if (safeEquals(listener, args.listener)) - { - found =3D true; - iter.remove(); - } - } - - if (plainCacheWrapper !=3D null) - { - plainCacheWrapper.removeNotificationListener(listener); - } - else if (!found) - { - throw new ListenerNotFoundException(); - } - - } - } - - // --------------------------------------------------------- Public me= thods - - public MBeanServer getMBeanServer() - { - return server; - } - - /** - * Sets the configuration that the underlying cache should use. - * - * @param config the configuration - */ - public void setConfiguration(Configuration config) - { - this.config =3D config; - } - - public void setPojoCache(PojoCache cache) - { - if (cacheStatus !=3D CacheStatus.INSTANTIATED - && cacheStatus !=3D CacheStatus.DESTROYED) - throw new IllegalStateException("Cannot set underlying cache afte= r call to create()"); - - this.pojoCache =3D cache; - if (pojoCache =3D=3D null) - { - this.config =3D null; - this.plainCacheWrapper =3D null; - } - else - { - this.config =3D cache.getCache().getConfiguration(); - this.plainCacheWrapper =3D buildPlainCacheWrapper(pojoCache); - } - } - - // --------------------------------------------------------------- Pri= vate methods - - private void constructCache() throws ConfigurationException - { - pojoCache =3D (PojoCacheImpl) PojoCacheFactory.createCache(config, f= alse); - - plainCacheWrapper =3D buildPlainCacheWrapper(pojoCache); - if (multiplexerService !=3D null) - { - injectMuxChannel(); - } - } - - private CacheJmxWrapper buildPlainCacheWrapper(PojoCache pojoCache) - { - CacheJmxWrapper plainCache =3D new CacheJmxWrapper(); - plainCache.setRegisterInterceptors(getRegisterInterceptors()); - plainCache.setCache(pojoCache.getCache()); - // It shouldn't send out lifecycle state change notifications for it= self; = - // we do it - plainCache.setDisableStateChangeNotifications(true); - - if (server !=3D null) - { - plainCache.setNotificationServiceName(cacheObjectName); - } - - // Add any NotificationListeners we registered before creating - // the CacheJmxWrapper - synchronized (pendingListeners) - { - for (NotificationListenerArgs args : pendingListeners) - { - plainCache.addNotificationListener(args.listener, args.filter,= args.handback); - } - } - return plainCache; - } - - private boolean registerPlainCache() throws CacheException - { - if (registerPlainCache && !plainCacheRegistered && server !=3D null) - { - try - { - ObjectName ourName =3D new ObjectName(cacheObjectName); - ObjectName plainName =3D JmxUtil.getPlainCacheObjectName(ourNa= me); - log.debug("Registering plain cache under name " + plainName.ge= tCanonicalName()); - org.jboss.cache.jmx.JmxUtil.registerCacheMBean(server, plainCa= cheWrapper, plainName.getCanonicalName()); - plainCacheRegistered =3D true; - return true; - } - catch (JMException e) - { - throw new CacheException("Failed to register plain cache", e); - } - } - - return false; - } - - private void unregisterPlainCache() - { - if (registerPlainCache && plainCacheRegistered && server !=3D null) - { - log.debug("Unregistering plain cache"); - try - { - org.jboss.cache.jmx.JmxUtil.unregisterCacheMBean(server, plain= CacheWrapper.getCacheObjectName()); - } - catch (Exception e) - { - log.error("Could not unregister plain cache", e); - } - plainCacheRegistered =3D false; - } - } - - private void injectMuxChannel() throws CacheException - { - Configuration cfg =3D getConfiguration(); - RuntimeConfig rtcfg =3D cfg.getRuntimeConfig(); - - // Only inject if there isn't already a channel or factory - if (rtcfg.getMuxChannelFactory() !=3D null && rtcfg.getChannel() != =3D null) - { - Channel ch; - try - { - ch =3D multiplexerService.createMultiplexerChannel(cfg.getMult= iplexerStack(), cfg.getClusterName()); - } - catch (Exception e) - { - throw new CacheException("Exception creating multiplexed chann= el", e); - } - rtcfg.setChannel(ch); - } - - } - - /** - * Helper for sending out state change notifications - */ - private void sendStateChangeNotification(int oldState, int newState, St= ring msg, Throwable t) - { - if (plainCacheWrapper !=3D null) - { - long now =3D System.currentTimeMillis(); - = - AttributeChangeNotification stateChangeNotification =3D new Attri= buteChangeNotification( - this, - plainCacheWrapper.getNextNotificationSequenceNumber(), no= w, msg, - "State", "java.lang.Integer", - new Integer(oldState), new Integer(newState) - ); - stateChangeNotification.setUserData(t); - = - plainCacheWrapper.sendNotification(stateChangeNotification); - } - } - - /** - * Sets the cacheStatus to FAILED and rethrows the problem as one - * of the declared types. Converts any non-RuntimeException Exception - * to CacheException. - * - * @param t - * @throws PojoCacheException - * @throws RuntimeException - * @throws Error - */ - private void handleLifecycleTransitionFailure(Throwable t) - throws PojoCacheException, RuntimeException, Error - { - int oldState =3D getState(); - cacheStatus =3D CacheStatus.FAILED; - sendStateChangeNotification(oldState, getState(), getClass().getSimp= leName() + " failed", t); - - if (t instanceof PojoCacheException) - throw (PojoCacheException) t; - if (t instanceof CacheException) - throw (CacheException) t; - else if (t instanceof RuntimeException) - throw (RuntimeException) t; - else if (t instanceof Error) - throw (Error) t; - else - throw new PojoCacheException(t); - } - - private static boolean safeEquals(Object us, Object them) - { - return (us =3D=3D null ? them =3D=3D null : us.equals(them)); - } - - private static class NotificationListenerArgs - { - NotificationListener listener; - NotificationFilter filter; - Object handback; - - NotificationListenerArgs(NotificationListener listener, - NotificationFilter filter, - Object handback) - { - this.listener =3D listener; - this.filter =3D filter; - this.handback =3D handback; - } - - @Override - public boolean equals(Object obj) - { - if (this =3D=3D obj) return true; - - if (obj instanceof NotificationListenerArgs) - { - NotificationListenerArgs other =3D (NotificationListenerArgs) = obj; - if (safeEquals(listener, other.listener) - && safeEquals(filter, other.filter) - && safeEquals(handback, other.handback)) - { - return true; - } - } - return false; - } - - @Override - public int hashCode() - { - int result =3D 17; - result =3D 29 * result + (listener !=3D null ? listener.hashCode(= ) : 0); - result =3D 29 * result + (filter !=3D null ? filter.hashCode() : = 0); - result =3D 29 * result + (handback !=3D null ? handback.hashCode(= ) : 0); - return result; - } - } - -} Copied: pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/jmx/PojoCach= eJmxWrapper.java (from rev 6374, pojo/trunk/src/main/java/org/jboss/cache/p= ojo/jmx/PojoCacheJmxWrapper.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/jmx/PojoCacheJmx= Wrapper.java (rev 0) +++ pojo/tags/2.2.0.CR7/src/main/java/org/jboss/cache/pojo/jmx/PojoCacheJmx= Wrapper.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,1033 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2006, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.cache.pojo.jmx; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.cache.CacheException; +import org.jboss.cache.CacheStatus; +import org.jboss.cache.config.BuddyReplicationConfig; +import org.jboss.cache.config.CacheLoaderConfig; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.ConfigurationException; +import org.jboss.cache.config.EvictionConfig; +import org.jboss.cache.config.RuntimeConfig; +import org.jboss.cache.factories.XmlConfigurationParser; +import org.jboss.cache.jmx.CacheJmxWrapper; +import org.jboss.cache.jmx.CacheNotificationListener; +import org.jboss.cache.pojo.PojoCache; +import org.jboss.cache.pojo.PojoCacheAlreadyDetachedException; +import org.jboss.cache.pojo.PojoCacheException; +import org.jboss.cache.pojo.PojoCacheFactory; +import org.jboss.cache.pojo.impl.PojoCacheImpl; +import org.jgroups.Channel; +import org.jgroups.ChannelFactory; +import org.jgroups.jmx.JChannelFactoryMBean; +import org.w3c.dom.Element; + +import javax.management.AttributeChangeNotification; +import javax.management.JMException; +import javax.management.ListenerNotFoundException; +import javax.management.MBeanNotificationInfo; +import javax.management.MBeanRegistration; +import javax.management.MBeanServer; +import javax.management.NotificationEmitter; +import javax.management.NotificationFilter; +import javax.management.NotificationListener; +import javax.management.ObjectName; +import javax.transaction.TransactionManager; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +public class PojoCacheJmxWrapper + implements PojoCacheJmxWrapperMBean, MBeanRegistration, Notificati= onEmitter +{ + private Log log =3D LogFactory.getLog(getClass().getName()); + + private boolean registerInterceptors =3D true; + private Configuration config; + private MBeanServer server; + private String cacheObjectName; + private PojoCache pojoCache; + private CacheJmxWrapper plainCacheWrapper; + private boolean registerPlainCache =3D true; + private boolean plainCacheRegistered; + private CacheStatus cacheStatus; + private boolean registered; + private final Set pendingListeners =3D + new HashSet(); + + // Legacy config support + + private Element buddyReplConfig; + private Element evictionConfig; + private Element cacheLoaderConfig; + private Element clusterConfig; + private JChannelFactoryMBean multiplexerService; + + /** + * Default constructor. + */ + public PojoCacheJmxWrapper() + { + cacheStatus =3D CacheStatus.INSTANTIATED; + } + + /** + * Creates a PojoCacheJmxWrapper that wraps the given PojoCache. + * + * @param toWrap the cache + */ + public PojoCacheJmxWrapper(PojoCache toWrap) + { + this(); + setPojoCache(toWrap); + } + + // PojoCacheMBean + + public PojoCache getPojoCache() + { + return pojoCache; + } + + public Configuration getConfiguration() + { + Configuration cfg =3D (pojoCache =3D=3D null ? config : pojoCache.ge= tCache().getConfiguration()); + if (cfg =3D=3D null) + { + cfg =3D config =3D new Configuration(); + } + return cfg; + } + + public String getInternalLocation(Object pojo) throws PojoCacheAlreadyD= etachedException + { + return pojoCache.getInternalFqn(pojo).toString(); + } + + public String getUnderlyingCacheObjectName() + { + return plainCacheWrapper =3D=3D null ? null : plainCacheWrapper.getC= acheObjectName(); + } + + public void create() throws PojoCacheException + { + if (cacheStatus.createAllowed() =3D=3D false) + { + if (cacheStatus.needToDestroyFailedCache()) + destroy(); + else + return; + } + + try + { + cacheStatus =3D CacheStatus.CREATING; + + if (pojoCache =3D=3D null) + { + if (config =3D=3D null) + { + throw new ConfigurationException("Must call setConfiguratio= n() " + + "or setPojoCache() before call to create()"); + } + + constructCache(); + } + + pojoCache.create(); + + registerPlainCache(); + + plainCacheWrapper.create(); + + cacheStatus =3D CacheStatus.CREATED; + } + catch (Throwable t) + { + handleLifecycleTransitionFailure(t); + } + } + + public void start() throws PojoCacheException + { + if (cacheStatus.startAllowed() =3D=3D false) + { + if (cacheStatus.needToDestroyFailedCache()) + destroy(); + if (cacheStatus.needCreateBeforeStart()) + create(); + else + return; + } + + try + { + int oldState =3D getState(); + cacheStatus =3D CacheStatus.STARTING; + int startingState =3D getState(); + sendStateChangeNotification(oldState, startingState, getClass().g= etSimpleName() + " starting", null); + + pojoCache.start(); + + plainCacheWrapper.start(); + cacheStatus =3D CacheStatus.STARTED; + sendStateChangeNotification(startingState, getState(), getClass()= .getSimpleName() + " started", null); + } + catch (Throwable t) + { + handleLifecycleTransitionFailure(t); + } + } + + public void stop() + { + if (cacheStatus.stopAllowed() =3D=3D false) + { + return; + } + + // Trying to stop() from FAILED is valid, but may not work + boolean failed =3D cacheStatus =3D=3D CacheStatus.FAILED; + + try + { + int oldState =3D getState(); + cacheStatus =3D CacheStatus.STOPPING; + int stoppingState =3D getState(); + sendStateChangeNotification(oldState, stoppingState, getClass().g= etSimpleName() + " stopping", null); + + cacheStatus =3D CacheStatus.STOPPING; + + pojoCache.stop(); + + plainCacheWrapper.stop(); + cacheStatus =3D CacheStatus.STOPPED; + sendStateChangeNotification(stoppingState, getState(), getClass()= .getSimpleName() + " stopped", null); + } + catch (Throwable t) + { + if (failed) + { + log.warn("Attempted to stop() from FAILED state, " + + "but caught exception; try calling destroy()", t); + } + handleLifecycleTransitionFailure(t); + } + } + + public void destroy() + { + if (cacheStatus.destroyAllowed() =3D=3D false) + { + if (cacheStatus.needStopBeforeDestroy()) + stop(); + else + return; + } + + try + { + cacheStatus =3D CacheStatus.DESTROYING; + + if (pojoCache !=3D null) + pojoCache.destroy(); + + // The cache is destroyed, so we shouldn't leave it registered + // in JMX even if we didn't register it in create() + unregisterPlainCache(); + + if (plainCacheWrapper !=3D null) + plainCacheWrapper.destroy(); + } + finally + { + // We always proceed to DESTROYED + cacheStatus =3D CacheStatus.DESTROYED; + } + } + + public CacheStatus getCacheStatus() + { + return cacheStatus; + } + + public int getState() + { + switch (cacheStatus) + { + case INSTANTIATED: + case CREATING: + return registered ? REGISTERED : UNREGISTERED; + case CREATED: + return CREATED; + case STARTING: + return STARTING; + case STARTED: + return STARTED; + case STOPPING: + return STOPPING; + case STOPPED: + case DESTROYING: + return STOPPED; + case DESTROYED: + return registered ? DESTROYED : UNREGISTERED; + case FAILED: + default: + return FAILED; + } + } + + public boolean getRegisterPlainCache() + { + return registerPlainCache; + } + + public void setRegisterPlainCache(boolean registerPlainCache) + { + this.registerPlainCache =3D registerPlainCache; + } + + public boolean getRegisterInterceptors() + { + return registerInterceptors; + } + + public void setRegisterInterceptors(boolean register) + { + this.registerInterceptors =3D register; + } + + // ---------------------------------------------------- LegacyConfigur= ation + + public Element getBuddyReplicationConfig() + { + return buddyReplConfig; + } + + public Element getCacheLoaderConfig() + { + return cacheLoaderConfig; + } + + public Element getCacheLoaderConfiguration() + { + return getCacheLoaderConfig(); + } + + public String getCacheMode() + { + return getConfiguration().getCacheModeString(); + } + + public String getClusterName() + { + return getConfiguration().getClusterName(); + } + + public String getClusterProperties() + { + return getConfiguration().getClusterConfig(); + } + + public Element getClusterConfig() + { + return clusterConfig; + } + + public Element getEvictionPolicyConfig() + { + return evictionConfig; + } + + public boolean getExposeManagementStatistics() + { + return getConfiguration().getExposeManagementStatistics(); + } + + public boolean getUseInterceptorMbeans() + { + return getExposeManagementStatistics(); + } + + public boolean getFetchInMemoryState() + { + return getConfiguration().isFetchInMemoryState(); + } + + public long getStateRetrievalTimeout() + { + return getConfiguration().getStateRetrievalTimeout(); + } + + @Deprecated + public void setInitialStateRetrievalTimeout(long timeout) + { + setStateRetrievalTimeout(timeout); + } + + public String getIsolationLevel() + { + return getConfiguration().getIsolationLevelString(); + } + + public long getLockAcquisitionTimeout() + { + return getConfiguration().getLockAcquisitionTimeout(); + } + + public JChannelFactoryMBean getMultiplexerService() + { + return multiplexerService; + } + + public String getMultiplexerStack() + { + return getConfiguration().getMultiplexerStack(); + } + + public ChannelFactory getMuxChannelFactory() + { + return getConfiguration().getRuntimeConfig().getMuxChannelFactory(); + } + + public String getNodeLockingScheme() + { + return getConfiguration().getNodeLockingSchemeString(); + } + + public long getReplQueueInterval() + { + return getConfiguration().getReplQueueInterval(); + } + + public int getReplQueueMaxElements() + { + return getConfiguration().getReplQueueMaxElements(); + } + + public String getReplicationVersion() + { + return getConfiguration().getReplVersionString(); + } + + public boolean getSyncCommitPhase() + { + return getConfiguration().isSyncCommitPhase(); + } + + public long getSyncReplTimeout() + { + return getConfiguration().getSyncReplTimeout(); + } + + public boolean getSyncRollbackPhase() + { + return getConfiguration().isSyncRollbackPhase(); + } + + public TransactionManager getTransactionManager() + { + return getConfiguration().getRuntimeConfig().getTransactionManager(); + } + + public String getTransactionManagerLookupClass() + { + return getConfiguration().getTransactionManagerLookupClass(); + } + + public boolean getUseRegionBasedMarshalling() + { + return getConfiguration().isUseRegionBasedMarshalling(); + } + + public boolean getUseReplQueue() + { + return getConfiguration().isUseReplQueue(); + } + + public boolean isInactiveOnStartup() + { + return getConfiguration().isInactiveOnStartup(); + } + + public void setBuddyReplicationConfig(Element config) + { + BuddyReplicationConfig brc =3D null; + if (config !=3D null) + { + brc =3D XmlConfigurationParser.parseBuddyReplicationConfig(config= ); + } + getConfiguration().setBuddyReplicationConfig(brc); + this.buddyReplConfig =3D config; + } + + public void setCacheLoaderConfig(Element cache_loader_config) + { + CacheLoaderConfig clc =3D null; + if (cache_loader_config !=3D null) + { + clc =3D XmlConfigurationParser.parseCacheLoaderConfig(cache_loade= r_config); + } + getConfiguration().setCacheLoaderConfig(clc); + this.cacheLoaderConfig =3D cache_loader_config; + } + + public void setCacheLoaderConfiguration(Element config) + { + log.warn("MBean attribute 'CacheLoaderConfiguration' is deprecated; = " + + "use 'CacheLoaderConfig'"); + setCacheLoaderConfig(config); + } + + public void setCacheMode(String mode) throws Exception + { + getConfiguration().setCacheModeString(mode); + } + + public void setClusterConfig(Element config) + { + String props =3D null; + if (config !=3D null) + { + props =3D XmlConfigurationParser.parseClusterConfigXml(config); + } + getConfiguration().setClusterConfig(props); + this.clusterConfig =3D config; + } + + @Deprecated + public long getInitialStateRetrievalTimeout() + { + return getStateRetrievalTimeout(); + } + + public void setClusterName(String name) + { + getConfiguration().setClusterName(name); + } + + public void setClusterProperties(String cluster_props) + { + getConfiguration().setClusterConfig(cluster_props); + } + + public void setEvictionPolicyConfig(Element config) + { + EvictionConfig ec =3D null; + if (config !=3D null) + { + ec =3D XmlConfigurationParser.parseEvictionConfig(config); + } + getConfiguration().setEvictionConfig(ec); + this.evictionConfig =3D config; + } + + public void setExposeManagementStatistics(boolean expose) + { + getConfiguration().setExposeManagementStatistics(expose); + } + + public void setUseInterceptorMbeans(boolean use) + { + log.warn("MBean attribute 'UseInterceptorMbeans' is deprecated; " + + "use 'ExposeManagementStatistics'"); + setExposeManagementStatistics(use); + } + + public void setFetchInMemoryState(boolean flag) + { + getConfiguration().setFetchInMemoryState(flag); + } + + public void setInactiveOnStartup(boolean inactiveOnStartup) + { + getConfiguration().setInactiveOnStartup(inactiveOnStartup); + } + + public void setStateRetrievalTimeout(long timeout) + { + getConfiguration().setStateRetrievalTimeout(timeout); + } + + public void setIsolationLevel(String level) + { + getConfiguration().setIsolationLevelString(level); + } + + public void setLockAcquisitionTimeout(long timeout) + { + getConfiguration().setLockAcquisitionTimeout(timeout); + } + + public void setMultiplexerService(JChannelFactoryMBean muxService) + { + this.multiplexerService =3D muxService; + } + + public void setMultiplexerStack(String stackName) + { + getConfiguration().setMultiplexerStack(stackName); + } + + public void setMuxChannelFactory(ChannelFactory factory) + { + getConfiguration().getRuntimeConfig().setMuxChannelFactory(factory); + } + + public void setNodeLockingScheme(String nodeLockingScheme) + { + getConfiguration().setNodeLockingSchemeString(nodeLockingScheme); + } + + public void setReplQueueInterval(long interval) + { + getConfiguration().setReplQueueInterval(interval); + } + + public void setReplQueueMaxElements(int max_elements) + { + getConfiguration().setReplQueueMaxElements(max_elements); + } + + public void setReplicationVersion(String version) + { + getConfiguration().setReplVersionString(version); + } + + public void setSyncCommitPhase(boolean sync_commit_phase) + { + getConfiguration().setSyncCommitPhase(sync_commit_phase); + } + + public void setSyncReplTimeout(long timeout) + { + getConfiguration().setSyncReplTimeout(timeout); + } + + public void setSyncRollbackPhase(boolean sync_rollback_phase) + { + getConfiguration().setSyncRollbackPhase(sync_rollback_phase); + } + + public void setTransactionManager(TransactionManager manager) + { + getConfiguration().getRuntimeConfig().setTransactionManager(manager); + } + + public void setTransactionManagerLookupClass(String cl) throws Exception + { + getConfiguration().setTransactionManagerLookupClass(cl); + } + + public void setUseRegionBasedMarshalling(boolean isTrue) + { + getConfiguration().setUseRegionBasedMarshalling(isTrue); + } + + public void setUseReplQueue(boolean flag) + { + getConfiguration().setUseReplQueue(flag); + } + + // ------------------------------------------------------ MBeanRegistr= ation + + /** + * Caches the provided server and objName. + */ + public ObjectName preRegister(MBeanServer server, ObjectName objName) + throws Exception + { + this.server =3D server; + + if (cacheObjectName =3D=3D null) + { + cacheObjectName =3D objName.getCanonicalName(); + } + + if (plainCacheWrapper !=3D null) + plainCacheWrapper.setNotificationServiceName(cacheObjectName); + + return new ObjectName(cacheObjectName); + } + + /** + * Registers the CacheJmxWrapperMBean, + * if {@link #getRegisterPlainCache()} is true. + */ + public void postRegister(Boolean registrationDone) + { + if (Boolean.TRUE.equals(registrationDone) && registerPlainCache) + { + log.debug("Registered in JMX under " + cacheObjectName); + + if (plainCacheWrapper !=3D null) + { + try + { + registerPlainCache(); + } + catch (Exception e) + { + log.error("Caught exception registering plain cache with JM= X", e); + } + } + + registered =3D true; + } + } + + /** + * No-op. + */ + public void preDeregister() throws Exception + { + } + + /** + * Unregisters the CacheJmxWrapper, if {@link #getRegisterPlainCache()}= is + * true. + */ + public void postDeregister() + { + if (plainCacheWrapper !=3D null) + { + unregisterPlainCache(); + } + + registered =3D false; + } + + // ---------------------------------------------------- NotificationEm= itter = + + public void removeNotificationListener(NotificationListener listener, + NotificationFilter filter, + Object handback) + throws ListenerNotFoundException + { + synchronized (pendingListeners) + { + boolean found =3D pendingListeners.remove(new NotificationListene= rArgs(listener, filter, handback)); + + if (plainCacheWrapper !=3D null) + { + plainCacheWrapper.removeNotificationListener(listener, filter,= handback); + } + else if (!found) + { + throw new ListenerNotFoundException(); + } + } + } + + public void addNotificationListener(NotificationListener listener, + NotificationFilter filter, + Object handback) + throws IllegalArgumentException + { + synchronized (pendingListeners) + { + if (plainCacheWrapper !=3D null) + { + plainCacheWrapper.addNotificationListener(listener, filter, ha= ndback); + } + else + { + // Add it for addition to the plainCacheWrapper when it's crea= ted + pendingListeners.add(new NotificationListenerArgs(listener, fi= lter, handback)); + } + } + + } + + public MBeanNotificationInfo[] getNotificationInfo() + { + return CacheNotificationListener.getNotificationInfo(); + } + + public void removeNotificationListener(NotificationListener listener) + throws ListenerNotFoundException + { + synchronized (pendingListeners) + { + boolean found =3D false; + for (Iterator iter =3D pendingListeners= .iterator(); + iter.hasNext();) + { + NotificationListenerArgs args =3D iter.next(); + if (safeEquals(listener, args.listener)) + { + found =3D true; + iter.remove(); + } + } + + if (plainCacheWrapper !=3D null) + { + plainCacheWrapper.removeNotificationListener(listener); + } + else if (!found) + { + throw new ListenerNotFoundException(); + } + + } + } + + // --------------------------------------------------------- Public me= thods + + public MBeanServer getMBeanServer() + { + return server; + } + + /** + * Sets the configuration that the underlying cache should use. + * + * @param config the configuration + */ + public void setConfiguration(Configuration config) + { + this.config =3D config; + } + + public void setPojoCache(PojoCache cache) + { + if (cacheStatus !=3D CacheStatus.INSTANTIATED + && cacheStatus !=3D CacheStatus.DESTROYED) + throw new IllegalStateException("Cannot set underlying cache afte= r call to create()"); + + this.pojoCache =3D cache; + if (pojoCache =3D=3D null) + { + this.config =3D null; + this.plainCacheWrapper =3D null; + } + else + { + this.config =3D cache.getCache().getConfiguration(); + this.plainCacheWrapper =3D buildPlainCacheWrapper(pojoCache); + } + } + + // --------------------------------------------------------------- Pri= vate methods + + private void constructCache() throws ConfigurationException + { + pojoCache =3D (PojoCacheImpl) PojoCacheFactory.createCache(config, f= alse); + + plainCacheWrapper =3D buildPlainCacheWrapper(pojoCache); + if (multiplexerService !=3D null) + { + injectMuxChannel(); + } + } + + private CacheJmxWrapper buildPlainCacheWrapper(PojoCache pojoCache) + { + CacheJmxWrapper plainCache =3D new CacheJmxWrapper(); + plainCache.setRegisterInterceptors(getRegisterInterceptors()); + plainCache.setCache(pojoCache.getCache()); + // It shouldn't send out lifecycle state change notifications for it= self; = + // we do it + plainCache.setDisableStateChangeNotifications(true); + + if (server !=3D null) + { + plainCache.setNotificationServiceName(cacheObjectName); + } + + // Add any NotificationListeners we registered before creating + // the CacheJmxWrapper + synchronized (pendingListeners) + { + for (NotificationListenerArgs args : pendingListeners) + { + plainCache.addNotificationListener(args.listener, args.filter,= args.handback); + } + } + return plainCache; + } + + private boolean registerPlainCache() throws CacheException + { + if (registerPlainCache && !plainCacheRegistered && server !=3D null) + { + try + { + ObjectName ourName =3D new ObjectName(cacheObjectName); + ObjectName plainName =3D JmxUtil.getPlainCacheObjectName(ourNa= me); + log.debug("Registering plain cache under name " + plainName.ge= tCanonicalName()); + org.jboss.cache.jmx.JmxUtil.registerCacheMBean(server, plainCa= cheWrapper, plainName.getCanonicalName()); + plainCacheRegistered =3D true; + return true; + } + catch (JMException e) + { + throw new CacheException("Failed to register plain cache", e); + } + } + + return false; + } + + private void unregisterPlainCache() + { + if (registerPlainCache && plainCacheRegistered && server !=3D null) + { + log.debug("Unregistering plain cache"); + try + { + org.jboss.cache.jmx.JmxUtil.unregisterCacheMBean(server, plain= CacheWrapper.getCacheObjectName()); + } + catch (Exception e) + { + log.error("Could not unregister plain cache", e); + } + plainCacheRegistered =3D false; + } + } + + private void injectMuxChannel() throws CacheException + { + Configuration cfg =3D getConfiguration(); + RuntimeConfig rtcfg =3D cfg.getRuntimeConfig(); + + // Only inject if there isn't already a channel or factory + if (rtcfg.getMuxChannelFactory() !=3D null && rtcfg.getChannel() != =3D null) + { + Channel ch; + try + { + ch =3D multiplexerService.createMultiplexerChannel(cfg.getMult= iplexerStack(), cfg.getClusterName()); + } + catch (Exception e) + { + throw new CacheException("Exception creating multiplexed chann= el", e); + } + rtcfg.setChannel(ch); + } + + } + + /** + * Helper for sending out state change notifications + */ + private void sendStateChangeNotification(int oldState, int newState, St= ring msg, Throwable t) + { + if (plainCacheWrapper !=3D null) + { + long now =3D System.currentTimeMillis(); + = + AttributeChangeNotification stateChangeNotification =3D new Attri= buteChangeNotification( + this, + plainCacheWrapper.getNextNotificationSequenceNumber(), no= w, msg, + "State", "java.lang.Integer", + new Integer(oldState), new Integer(newState) + ); + stateChangeNotification.setUserData(t); + = + plainCacheWrapper.sendNotification(stateChangeNotification); + } + } + + /** + * Sets the cacheStatus to FAILED and rethrows the problem as one + * of the declared types. Converts any non-RuntimeException Exception + * to CacheException. + * + * @param t + * @throws PojoCacheException + * @throws RuntimeException + * @throws Error + */ + private void handleLifecycleTransitionFailure(Throwable t) + throws PojoCacheException, RuntimeException, Error + { + int oldState =3D getState(); + cacheStatus =3D CacheStatus.FAILED; + sendStateChangeNotification(oldState, getState(), getClass().getSimp= leName() + " failed", t); + + if (t instanceof PojoCacheException) + throw (PojoCacheException) t; + if (t instanceof CacheException) + throw (CacheException) t; + else if (t instanceof RuntimeException) + throw (RuntimeException) t; + else if (t instanceof Error) + throw (Error) t; + else + throw new PojoCacheException(t); + } + + private static boolean safeEquals(Object us, Object them) + { + return (us =3D=3D null ? them =3D=3D null : us.equals(them)); + } + + private static class NotificationListenerArgs + { + NotificationListener listener; + NotificationFilter filter; + Object handback; + + NotificationListenerArgs(NotificationListener listener, + NotificationFilter filter, + Object handback) + { + this.listener =3D listener; + this.filter =3D filter; + this.handback =3D handback; + } + + @Override + public boolean equals(Object obj) + { + if (this =3D=3D obj) return true; + + if (obj instanceof NotificationListenerArgs) + { + NotificationListenerArgs other =3D (NotificationListenerArgs) = obj; + if (safeEquals(listener, other.listener) + && safeEquals(filter, other.filter) + && safeEquals(handback, other.handback)) + { + return true; + } + } + return false; + } + + @Override + public int hashCode() + { + int result =3D 17; + result =3D 29 * result + (listener !=3D null ? listener.hashCode(= ) : 0); + result =3D 29 * result + (filter !=3D null ? filter.hashCode() : = 0); + result =3D 29 * result + (handback !=3D null ? handback.hashCode(= ) : 0); + return result; + } + } + +} Copied: pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/FindReferenc= esTest.java (from rev 6374, pojo/trunk/src/test/java/org/jboss/cache/pojo/F= indReferencesTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/FindReferencesTe= st.java (rev 0) +++ pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/FindReferencesTe= st.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,155 @@ +package org.jboss.cache.pojo; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; + +import java.util.*; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.cache.Fqn; +import org.jboss.cache.pojo.impl.ReferenceImpl; +import org.jboss.cache.pojo.test.*; +import org.testng.annotations.*; + +/** + * Test case for finding back-references. + * + * @author Dan Berindei + */ + +(a)Test(groups =3D { "functional" }) +public class FindReferencesTest +{ + Log log =3D LogFactory.getLog(FindReferencesTest.class); + PojoCache cache_; + + @BeforeMethod(alwaysRun =3D true) + protected void setUp() throws Exception + { + log.info("setUp() ...."); + String configFile =3D "META-INF/local-service.xml"; + boolean toStart =3D false; + cache_ =3D PojoCacheFactory.createCache(configFile, toStart); + cache_.start(); + } + + @AfterMethod(alwaysRun =3D true) + protected void tearDown() throws Exception + { + cache_.stop(); + } + + private Person createPerson(String id, String name, int age, Address ad= dress) + { + Person p =3D new Person(null); + p.setName(name); + p.setAge(age); + p.setAddress(address); + cache_.attach(id, p); + return p; + } + + private Address createAddress() + { + Address add =3D new Address(); + add.setZip(95123); + add.setCity("San Jose"); + return add; + } + + public void testImmediateType() throws Exception + { + log.info("testImmediateType() ...."); + String test =3D "This is a test"; + cache_.attach("/test", test); + + assertEquals("Fqn", null, cache_.getInternalFqn(test)); + assertEquals("List", Collections.EMPTY_LIST, cache_.getReferences(te= st)); + } + + public void testNotAttached() throws Exception + { + log.info("testImmediateType() ...."); + Address address =3D createAddress(); + + assertEquals("Fqn", null, cache_.getInternalFqn(address)); + assertEquals("List", Collections.EMPTY_LIST, cache_.getReferences(ad= dress)); + } + + public void testSingleExternalReference() throws Exception + { + log.info("testNoReferences() ...."); + Person joe =3D createPerson("/person/joe", "Joe Black", 32, null); + + Fqn joesInternalFqn =3D cache_.getInternalFqn(joe); + assertTrue("Internal Fqn not null", joesInternalFqn !=3D null); + + Collection addressReferences =3D cache_.getReferences(joe= ); + assertEquals("Size", 1, addressReferences.size()); + assertEquals("Reference", new ReferenceImpl(Fqn.fromString("/person/= joe"), null), + addressReferences.iterator().next()); + } + + public void testSingleInternalReference() throws Exception + { + log.info("testSingleReference() ...."); + Address address =3D createAddress(); + Person joe =3D createPerson("/person/joe", "Joe Black", 32, address); + + Fqn joesInternalFqn =3D cache_.getInternalFqn(joe); + Collection addressReferences =3D cache_.getReferences(add= ress); + + assertEquals("Size", 1, addressReferences.size()); + assertEquals("Reference", new ReferenceImpl(joesInternalFqn, "addres= s"), + addressReferences.iterator().next()); + } + + public void testMultipleInternalReferences() throws Exception + { + log.info("testMultipleReferences() ...."); + Address address =3D createAddress(); + Person joe =3D createPerson("/person/joe", "Joe Black", 32, address); + Person jane =3D createPerson("/person/jane", "Jane Black", 32, addre= ss); + + Fqn joesInternalFqn =3D cache_.getInternalFqn(joe); + Fqn janesInternalFqn =3D cache_.getInternalFqn(jane); + HashSet expectedReferences =3D new HashSet(Arr= ays. asList( + new ReferenceImpl(joesInternalFqn, "address"), new ReferenceIm= pl(janesInternalFqn, "address"))); + + Set addressReferences =3D new HashSet(cache_.g= etReferences(address)); + + assertEquals("Reference Fqns", expectedReferences, addressReferences= ); + } + + public void testDoubleReferenceFromSameObject() + { + log.info("testDoubleReferenceFromSameObject() ..."); + + DoubleRef doubleRef =3D new DoubleRef(); + cache_.attach("/doubleref", doubleRef); + + Fqn sourceFqn =3D cache_.getInternalFqn(doubleRef); + HashSet expectedReferences =3D new HashSet(Arr= ays. asList( + new ReferenceImpl(sourceFqn, "one"), new ReferenceImpl(sourceF= qn, "two"))); + + Student student =3D doubleRef.getOne(); + Set references =3D new HashSet(cache_.getRefer= ences(student)); + + assertEquals("Reference Fqns", expectedReferences, references); + + // removing one of the references + doubleRef.setOne(null); + Collection references2 =3D cache_.getReferences(student); + + assertEquals("Size", 1, references2.size()); + assertEquals("Reference Fqn", new ReferenceImpl(sourceFqn, "two"), r= eferences2.iterator().next()); + + // removing the last reference + doubleRef.setTwo(null); + Collection references3 =3D cache_.getReferences(student); + + assertEquals("Size", 0, references3.size()); + } + +} \ No newline at end of file Deleted: pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notificatio= n/ListTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ListTest.jav= a 2008-07-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Lis= tTest.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,260 +0,0 @@ -/* -* JBoss, Home of Professional Open Source -* Copyright 2005, JBoss Inc., and individual contributors as indicated -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* This is free software; you can redistribute it and/or modify it -* under the terms of the GNU Lesser General Public License as -* published by the Free Software Foundation; either version 2.1 of -* the License, or (at your option) any later version. -* -* This software is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this software; if not, write to the Free -* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -* 02110-1301 USA, or see the FSF site: http://www.fsf.org. -*/ -package org.jboss.cache.pojo.notification; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertSame; - -import java.util.ArrayList; -import java.util.List; - -import org.jboss.cache.pojo.PojoCache; -import org.jboss.cache.pojo.PojoCacheFactory; -import org.jboss.cache.pojo.notification.event.AttachedEvent; -import org.jboss.cache.pojo.notification.event.DetachedEvent; -import org.jboss.cache.pojo.notification.event.Event; -import org.jboss.cache.pojo.notification.event.ListModifiedEvent; -import org.jboss.cache.pojo.test.Person; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -//$Id$ - -/** - * Tests list notifications - * - * @author Jason T. Greene - */ -(a)Test(groups =3D {"functional"}) -public class ListTest -{ - protected PojoCache cache; - protected Listener listener =3D new Listener(); - - - @BeforeMethod(alwaysRun =3D true) - protected void setUp() throws Exception - { - String configFile =3D "META-INF/local-service.xml"; - boolean toStart =3D false; - cache =3D PojoCacheFactory.createCache(configFile, toStart); - cache.start(); - cache.addListener(listener); - } - - @AfterMethod(alwaysRun =3D true) - protected void tearDown() throws Exception - { - cache.stop(); - listener.clear(); - } - - private T takeNotification(Class clazz) - { - T notification =3D listener.take(clazz); - verifyNotification(notification); - - return notification; - } - - protected void verifyNotification(Event notification) - { - assertSame(cache, notification.getContext().getPojoCache()); - assertEquals(true, notification.isLocal()); - } - - @SuppressWarnings("unchecked") - public void testListAddNotification() throws Exception - { - final String test1 =3D "test1"; - final String test2 =3D "test2"; - - List list =3D new ArrayList(); - list.add(test1); - list.add(test2); - cache.attach("a", list); - list =3D (List) cache.find("a"); - - // String attach - AttachedEvent attach =3D (AttachedEvent) takeNotification(AttachedEv= ent.class); - assertEquals(test1, attach.getSource()); - - // List add - ListModifiedEvent modify =3D takeNotification(ListModifiedEvent.clas= s); - assertEquals(ListModifiedEvent.Operation.ADD, modify.getOperation()); - assertEquals(test1, modify.getValue()); - assertEquals(0, modify.getIndex()); - - // String attach - attach =3D takeNotification(AttachedEvent.class); - assertEquals(test2, attach.getSource()); - - // List add - modify =3D takeNotification(ListModifiedEvent.class); - assertEquals(ListModifiedEvent.Operation.ADD, modify.getOperation()); - assertEquals(test2, modify.getValue()); - assertEquals(1, modify.getIndex()); - - // List Attach - attach =3D takeNotification(AttachedEvent.class); - assertEquals(list, attach.getSource()); - - } - - @SuppressWarnings("unchecked") - public void testListSetNotification() throws Exception - { - final String test1 =3D "test1"; - final String test2 =3D "test2"; - - List list =3D new ArrayList(); - list.add(test1); - cache.attach("a", list); - list =3D (List) cache.find("a"); - list.set(0, test2); - - // String attach - AttachedEvent attach =3D takeNotification(AttachedEvent.class); - assertEquals(test1, attach.getSource()); - - // List add - ListModifiedEvent modify =3D takeNotification(ListModifiedEvent.clas= s); - assertEquals(ListModifiedEvent.Operation.ADD, modify.getOperation()); - assertEquals(test1, modify.getValue()); - assertEquals(0, modify.getIndex()); - - // List Attach - attach =3D takeNotification(AttachedEvent.class); - assertEquals(list, attach.getSource()); - - // String detach - DetachedEvent detach =3D takeNotification(DetachedEvent.class); - assertEquals(test1, detach.getSource()); - - // String attach - attach =3D takeNotification(AttachedEvent.class); - assertEquals(test2, attach.getSource()); - - // List set - modify =3D takeNotification(ListModifiedEvent.class); - assertEquals(ListModifiedEvent.Operation.SET, modify.getOperation()); - assertEquals(test2, modify.getValue()); - assertEquals(0, modify.getIndex()); - } - - @SuppressWarnings("unchecked") - public void testListRemoveNotification() throws Exception - { - final String test1 =3D "test1"; - final String test2 =3D "test2"; - - List list =3D new ArrayList(); - list.add(test1); - list.add(test2); - cache.attach("a", list); - list =3D (List) cache.find("a"); - list.remove(1); - - // String attach - AttachedEvent attach =3D takeNotification(AttachedEvent.class); - assertEquals(test1, attach.getSource()); - - // List add - ListModifiedEvent modify =3D takeNotification(ListModifiedEvent.clas= s); - assertEquals(ListModifiedEvent.Operation.ADD, modify.getOperation()); - assertEquals(test1, modify.getValue()); - assertEquals(0, modify.getIndex()); - - // String attach - attach =3D takeNotification(AttachedEvent.class); - assertEquals(test2, attach.getSource()); - - // List add - modify =3D takeNotification(ListModifiedEvent.class); - assertEquals(ListModifiedEvent.Operation.ADD, modify.getOperation()); - assertEquals(test2, modify.getValue()); - assertEquals(1, modify.getIndex()); - - // List Attach - attach =3D takeNotification(AttachedEvent.class); - assertEquals(list, attach.getSource()); - - // List remove - modify =3D takeNotification(ListModifiedEvent.class); - assertEquals(ListModifiedEvent.Operation.REMOVE, modify.getOperation= ()); - assertEquals(test2, modify.getValue()); - assertEquals(1, modify.getIndex()); - - // String detach - DetachedEvent detach =3D takeNotification(DetachedEvent.class); - assertEquals(test2, detach.getSource()); - } - - public void testObjectListAdd() throws Exception - { - final String english =3D "English"; - final String taiwanese =3D "Taiwanese"; - - Person test =3D new Person(); - test.setName("Ben"); - test.setAge(10); - - ArrayList list =3D new ArrayList(); - - list.add(english); - list.add(taiwanese); - test.setLanguages(list); - - cache.attach("a", test); - - // String attach - AttachedEvent attach =3D takeNotification(AttachedEvent.class); - assertEquals(english, attach.getSource()); - - // List add - ListModifiedEvent modify =3D takeNotification(ListModifiedEvent.clas= s); - assertEquals(ListModifiedEvent.Operation.ADD, modify.getOperation()); - assertEquals(english, modify.getValue()); - assertEquals(0, modify.getIndex()); - - // String attach - attach =3D takeNotification(AttachedEvent.class); - assertEquals(taiwanese, attach.getSource()); - - // List add - modify =3D takeNotification(ListModifiedEvent.class); - assertEquals(ListModifiedEvent.Operation.ADD, modify.getOperation()); - assertEquals(taiwanese, modify.getValue()); - assertEquals(1, modify.getIndex()); - - // List Attach - attach =3D takeNotification(AttachedEvent.class); - assertEquals(test.getLanguages(), attach.getSource()); - - // Person Attach - attach =3D takeNotification(AttachedEvent.class); - assertEquals(test, attach.getSource()); - } - - -} Copied: pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification= /ListTest.java (from rev 6323, pojo/trunk/src/test/java/org/jboss/cache/poj= o/notification/ListTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Lis= tTest.java (rev 0) +++ pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Lis= tTest.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,264 @@ +/* +* JBoss, Home of Professional Open Source +* Copyright 2005, JBoss Inc., and individual contributors as indicated +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* This is free software; you can redistribute it and/or modify it +* under the terms of the GNU Lesser General Public License as +* published by the Free Software Foundation; either version 2.1 of +* the License, or (at your option) any later version. +* +* This software is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this software; if not, write to the Free +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ +package org.jboss.cache.pojo.notification; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertSame; + +import java.util.ArrayList; +import java.util.List; + +import org.jboss.cache.pojo.PojoCache; +import org.jboss.cache.pojo.PojoCacheFactory; +import org.jboss.cache.pojo.notification.event.AttachedEvent; +import org.jboss.cache.pojo.notification.event.DetachedEvent; +import org.jboss.cache.pojo.notification.event.Event; +import org.jboss.cache.pojo.notification.event.ListModifiedEvent; +import org.jboss.cache.pojo.test.Person; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +//$Id$ + +/** + * Tests list notifications + * + * @author Jason T. Greene + */ +(a)Test(groups =3D {"functional"}) +public class ListTest +{ + protected PojoCache cache; + protected Listener listener =3D new Listener(); + + + @BeforeMethod(alwaysRun =3D true) + protected void setUp() throws Exception + { + String configFile =3D "META-INF/local-service.xml"; + boolean toStart =3D false; + cache =3D PojoCacheFactory.createCache(configFile, toStart); + cache.start(); + cache.addListener(listener); + } + + @AfterMethod(alwaysRun =3D true) + protected void tearDown() throws Exception + { + cache.stop(); + listener.clear(); + } + + private T takeNotification(Class clazz) + { + T notification =3D listener.take(clazz); + verifyNotification(notification); + + return notification; + } + + protected void verifyNotification(Event notification) + { + assertSame(cache, notification.getContext().getPojoCache()); + assertEquals(true, notification.isLocal()); + } + + @SuppressWarnings("unchecked") + public void testListAddNotification() throws Exception + { + final String test1 =3D "test1"; + final String test2 =3D "test2"; + + List list =3D new ArrayList(); + list.add(test1); + list.add(test2); + cache.attach("a", list); + list =3D (List) cache.find("a"); + + // String attach + AttachedEvent attach =3D (AttachedEvent) takeNotification(AttachedEv= ent.class); + assertEquals(test1, attach.getSource()); + + // List add + ListModifiedEvent modify =3D takeNotification(ListModifiedEvent.clas= s); + assertEquals(ListModifiedEvent.Operation.ADD, modify.getOperation()); + assertEquals(test1, modify.getValue()); + assertEquals(0, modify.getIndex()); + + // String attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(test2, attach.getSource()); + + // List add + modify =3D takeNotification(ListModifiedEvent.class); + assertEquals(ListModifiedEvent.Operation.ADD, modify.getOperation()); + assertEquals(test2, modify.getValue()); + assertEquals(1, modify.getIndex()); + + // List Attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(list, attach.getSource()); + //cache.detach("a"); + } + + @SuppressWarnings("unchecked") + public void testListSetNotification() throws Exception + { + final String test1 =3D "test1"; + final String test2 =3D "test2"; + + List list =3D new ArrayList(); + list.add(test1); + cache.attach("b", list); + list =3D (List) cache.find("b"); + list.set(0, test2); + + // String attach + AttachedEvent attach =3D takeNotification(AttachedEvent.class); + assertEquals(test1, attach.getSource()); + + // List add + ListModifiedEvent modify =3D takeNotification(ListModifiedEvent.clas= s); + assertEquals(ListModifiedEvent.Operation.ADD, modify.getOperation()); + assertEquals(test1, modify.getValue()); + assertEquals(0, modify.getIndex()); + + // List Attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(list, attach.getSource()); + + // String detach + DetachedEvent detach =3D takeNotification(DetachedEvent.class); + assertEquals(test1, detach.getSource()); + + // String attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(test2, attach.getSource()); + + // List set + modify =3D takeNotification(ListModifiedEvent.class); + assertEquals(ListModifiedEvent.Operation.SET, modify.getOperation()); + assertEquals(test2, modify.getValue()); + assertEquals(0, modify.getIndex()); + //cache.detach("b"); + } + + @SuppressWarnings("unchecked") + public void testListRemoveNotification() throws Exception + { + final String test1 =3D "test1"; + final String test2 =3D "test2"; + + List list =3D new ArrayList(); + list.add(test1); + list.add(test2); + cache.attach("c", list); + list =3D (List) cache.find("c"); + list.remove(1); + + // String attach + AttachedEvent attach =3D takeNotification(AttachedEvent.class); + assertEquals(test1, attach.getSource()); + + // List add + ListModifiedEvent modify =3D takeNotification(ListModifiedEvent.clas= s); + assertEquals(ListModifiedEvent.Operation.ADD, modify.getOperation()); + assertEquals(test1, modify.getValue()); + assertEquals(0, modify.getIndex()); + + // String attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(test2, attach.getSource()); + + // List add + modify =3D takeNotification(ListModifiedEvent.class); + assertEquals(ListModifiedEvent.Operation.ADD, modify.getOperation()); + assertEquals(test2, modify.getValue()); + assertEquals(1, modify.getIndex()); + + // List Attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(list, attach.getSource()); + + // List remove + modify =3D takeNotification(ListModifiedEvent.class); + assertEquals(ListModifiedEvent.Operation.REMOVE, modify.getOperation= ()); + assertEquals(test2, modify.getValue()); + assertEquals(1, modify.getIndex()); + + // String detach + DetachedEvent detach =3D takeNotification(DetachedEvent.class); + assertEquals(test2, detach.getSource()); + //cache.detach("c"); + } + + public void testObjectListAdd() throws Exception + { + final String english =3D "English"; + final String taiwanese =3D "Taiwanese"; + + Person test =3D new Person(); + test.setName("Ben"); + test.setAge(10); + + ArrayList list =3D new ArrayList(); + + list.add(english); + list.add(taiwanese); + test.setLanguages(list); + + cache.attach("d", test); + + // String attach + AttachedEvent attach =3D takeNotification(AttachedEvent.class); + assertEquals(english, attach.getSource()); + + // List add + ListModifiedEvent modify =3D takeNotification(ListModifiedEvent.clas= s); + assertEquals(ListModifiedEvent.Operation.ADD, modify.getOperation()); + assertEquals(english, modify.getValue()); + assertEquals(0, modify.getIndex()); + + // String attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(taiwanese, attach.getSource()); + + // List add + modify =3D takeNotification(ListModifiedEvent.class); + assertEquals(ListModifiedEvent.Operation.ADD, modify.getOperation()); + assertEquals(taiwanese, modify.getValue()); + assertEquals(1, modify.getIndex()); + + // List Attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(test.getLanguages(), attach.getSource()); + + // Person Attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(test, attach.getSource()); + + //cache.detach("d"); + } + + +} Deleted: pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notificatio= n/Listener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/Listener.jav= a 2008-07-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Lis= tener.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,77 +0,0 @@ -/* -* JBoss, Home of Professional Open Source -* Copyright 2005, JBoss Inc., and individual contributors as indicated -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* This is free software; you can redistribute it and/or modify it -* under the terms of the GNU Lesser General Public License as -* published by the Free Software Foundation; either version 2.1 of -* the License, or (at your option) any later version. -* -* This software is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this software; if not, write to the Free -* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -* 02110-1301 USA, or see the FSF site: http://www.fsf.org. -*/ - -package org.jboss.cache.pojo.notification; - -import java.util.LinkedList; -import java.util.Queue; - -import net.jcip.annotations.NotThreadSafe; - -import org.jboss.cache.pojo.notification.annotation.Attached; -import org.jboss.cache.pojo.notification.annotation.Detached; -import org.jboss.cache.pojo.notification.annotation.FieldModified; -import org.jboss.cache.pojo.notification.annotation.ListModified; -import org.jboss.cache.pojo.notification.annotation.MapModified; -import org.jboss.cache.pojo.notification.annotation.PojoCacheListener; -import org.jboss.cache.pojo.notification.annotation.SetModified; -import org.jboss.cache.pojo.notification.event.Event; - -// $Id$ - -/** - * A recoding Listener for notification test package. This is not thread s= afe, just for testing. - * - * @author Jason T. Greene - */ -(a)PojoCacheListener -(a)NotThreadSafe -public class Listener -{ - private Queue events =3D new LinkedList(); - - @SuppressWarnings("unchecked") - public T take(Class t) - { - Event notification =3D events.remove(); - if (!t.isInstance(notification)) - throw new IllegalStateException("Expected notification type: " + = t.getSimpleName() + " but was: " + notification.getClass().getSimpleName()); - - return (T) notification; - } - - public void clear() - { - events.clear(); - } - - @Attached - @Detached - @FieldModified - @ListModified - @SetModified - @MapModified - public void handle(Event event) - { - events.offer(event); - } -} \ No newline at end of file Copied: pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification= /Listener.java (from rev 6323, pojo/trunk/src/test/java/org/jboss/cache/poj= o/notification/Listener.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Lis= tener.java (rev 0) +++ pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Lis= tener.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,82 @@ +/* +* JBoss, Home of Professional Open Source +* Copyright 2005, JBoss Inc., and individual contributors as indicated +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* This is free software; you can redistribute it and/or modify it +* under the terms of the GNU Lesser General Public License as +* published by the Free Software Foundation; either version 2.1 of +* the License, or (at your option) any later version. +* +* This software is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this software; if not, write to the Free +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jboss.cache.pojo.notification; + +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; + +import org.jboss.cache.pojo.notification.annotation.Attached; +import org.jboss.cache.pojo.notification.annotation.Detached; +import org.jboss.cache.pojo.notification.annotation.FieldModified; +import org.jboss.cache.pojo.notification.annotation.ListModified; +import org.jboss.cache.pojo.notification.annotation.MapModified; +import org.jboss.cache.pojo.notification.annotation.PojoCacheListener; +import org.jboss.cache.pojo.notification.annotation.SetModified; +import org.jboss.cache.pojo.notification.event.Event; + +// $Id$ + +/** + * A recoding Listener for notification test package. + * + * @author Jason T. Greene + */ +(a)PojoCacheListener +public class Listener +{ + private BlockingQueue events =3D new LinkedBlockingQueue(= ); + + @SuppressWarnings("unchecked") + public T take(Class t) + { + Event notification; + try + { + notification =3D events.take(); + } + catch (InterruptedException e) + { + throw new RuntimeException(e); + } + if (!t.isInstance(notification)) + throw new IllegalStateException("Expected notification type: " + = t.getSimpleName() + " but was: " + notification.getClass().getSimpleName()); + + return (T) notification; + } + + public void clear() + { + events.clear(); + } + + @Attached + @Detached + @FieldModified + @ListModified + @SetModified + @MapModified + public void handle(Event event) + { + events.offer(event); + } +} \ No newline at end of file Deleted: pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notificatio= n/MapTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/MapTest.java= 2008-07-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Map= Test.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,224 +0,0 @@ -/* -* JBoss, Home of Professional Open Source -* Copyright 2005, JBoss Inc., and individual contributors as indicated -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* This is free software; you can redistribute it and/or modify it -* under the terms of the GNU Lesser General Public License as -* published by the Free Software Foundation; either version 2.1 of -* the License, or (at your option) any later version. -* -* This software is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this software; if not, write to the Free -* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -* 02110-1301 USA, or see the FSF site: http://www.fsf.org. -*/ -package org.jboss.cache.pojo.notification; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertSame; - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.jboss.cache.pojo.PojoCache; -import org.jboss.cache.pojo.PojoCacheFactory; -import org.jboss.cache.pojo.notification.event.AttachedEvent; -import org.jboss.cache.pojo.notification.event.DetachedEvent; -import org.jboss.cache.pojo.notification.event.Event; -import org.jboss.cache.pojo.notification.event.MapModifiedEvent; -import org.jboss.cache.pojo.test.Person; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -//$Id$ - -/** - * Tests map notifications - * - * @author Jason T. Greene - */ -(a)Test(groups =3D {"functional"}) -public class MapTest -{ - protected PojoCache cache; - protected Listener listener =3D new Listener(); - - - @BeforeMethod(alwaysRun =3D true) - protected void setUp() throws Exception - { - String configFile =3D "META-INF/local-service.xml"; - boolean toStart =3D false; - cache =3D PojoCacheFactory.createCache(configFile, toStart); - cache.start(); - cache.addListener(listener); - } - - - @AfterMethod(alwaysRun =3D true) - protected void tearDown() throws Exception - { - cache.stop(); - listener.clear(); - } - - private T takeNotification(Class clazz) - { - T notification =3D listener.take(clazz); - verifyNotification(notification); - - return notification; - } - - protected void verifyNotification(Event notification) - { - assertSame(cache, notification.getContext().getPojoCache()); - assertEquals(true, notification.isLocal()); - } - - @SuppressWarnings("unchecked") - public void testMapAddNotification() throws Exception - { - final String key1 =3D "key1"; - final String key2 =3D "key2"; - final String test1 =3D "test1"; - final String test2 =3D "test2"; - - Map map =3D new LinkedHashMap(); - map.put(key1, test1); - map.put(key2, test2); - cache.attach("a", map); - map =3D (Map) cache.find("a"); - - // String attach - AttachedEvent attach =3D takeNotification(AttachedEvent.class); - assertEquals(test1, attach.getSource()); - - // Map put - MapModifiedEvent modify =3D takeNotification(MapModifiedEvent.class); - assertEquals(MapModifiedEvent.Operation.PUT, modify.getOperation()); - assertEquals(key1, modify.getKey()); - assertEquals(test1, modify.getValue()); - - // String attach - attach =3D takeNotification(AttachedEvent.class); - assertEquals(test2, attach.getSource()); - - // Map put - modify =3D takeNotification(MapModifiedEvent.class); - assertEquals(MapModifiedEvent.Operation.PUT, modify.getOperation()); - assertEquals(key2, modify.getKey()); - assertEquals(test2, modify.getValue()); - - // Map Attach - attach =3D takeNotification(AttachedEvent.class); - assertEquals(map, attach.getSource()); - - } - - @SuppressWarnings("unchecked") - public void testMapRemoveNotification() throws Exception - { - final String key1 =3D "key1"; - final String key2 =3D "key2"; - final String test1 =3D "test1"; - final String test2 =3D "test2"; - - Map map =3D new LinkedHashMap(); - map.put(key1, test1); - map.put(key2, test2); - cache.attach("a", map); - map =3D (Map) cache.find("a"); - map.remove(key2); - - // String attach - AttachedEvent attach =3D takeNotification(AttachedEvent.class); - assertEquals(test1, attach.getSource()); - - // Map put - MapModifiedEvent modify =3D takeNotification(MapModifiedEvent.class); - assertEquals(MapModifiedEvent.Operation.PUT, modify.getOperation()); - assertEquals(key1, modify.getKey()); - assertEquals(test1, modify.getValue()); - - // String attach - attach =3D takeNotification(AttachedEvent.class); - assertEquals(test2, attach.getSource()); - - // Map put - modify =3D takeNotification(MapModifiedEvent.class); - assertEquals(MapModifiedEvent.Operation.PUT, modify.getOperation()); - assertEquals(key2, modify.getKey()); - assertEquals(test2, modify.getValue()); - - // Map Attach - attach =3D takeNotification(AttachedEvent.class); - assertEquals(map, attach.getSource()); - - // Map remove - modify =3D takeNotification(MapModifiedEvent.class); - assertEquals(MapModifiedEvent.Operation.REMOVE, modify.getOperation(= )); - assertEquals(key2, modify.getKey()); - assertEquals(test2, modify.getValue()); - - // String detach - DetachedEvent detach =3D takeNotification(DetachedEvent.class); - assertEquals(test2, detach.getSource()); - } - - public void testObjectMapAdd() throws Exception - { - final String key1 =3D "key1"; - final String key2 =3D "key2"; - final String drumming =3D "druming"; - final String engineering =3D "engineering"; - - Person test =3D new Person(); - test.setName("Joe"); - test.setAge(30); - - Map map =3D new LinkedHashMap(); - map.put(key1, drumming); - map.put(key2, engineering); - test.setHobbies(map); - cache.attach("a", test); - - // String attach - AttachedEvent attach =3D takeNotification(AttachedEvent.class); - assertEquals(drumming, attach.getSource()); - - // Map put - MapModifiedEvent modify =3D takeNotification(MapModifiedEvent.class); - assertEquals(MapModifiedEvent.Operation.PUT, modify.getOperation()); - assertEquals(key1, modify.getKey()); - assertEquals(drumming, modify.getValue()); - - // String attach - attach =3D takeNotification(AttachedEvent.class); - assertEquals(engineering, attach.getSource()); - - // Map put - modify =3D takeNotification(MapModifiedEvent.class); - assertEquals(key2, modify.getKey()); - assertEquals(MapModifiedEvent.Operation.PUT, modify.getOperation()); - assertEquals(engineering, modify.getValue()); - - // Map Attach - attach =3D takeNotification(AttachedEvent.class); - assertEquals(test.getHobbies(), attach.getSource()); - - // Person Attach - attach =3D takeNotification(AttachedEvent.class); - assertEquals(test, attach.getSource()); - } - - -} Copied: pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification= /MapTest.java (from rev 6323, pojo/trunk/src/test/java/org/jboss/cache/pojo= /notification/MapTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Map= Test.java (rev 0) +++ pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Map= Test.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,229 @@ +/* +* JBoss, Home of Professional Open Source +* Copyright 2005, JBoss Inc., and individual contributors as indicated +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* This is free software; you can redistribute it and/or modify it +* under the terms of the GNU Lesser General Public License as +* published by the Free Software Foundation; either version 2.1 of +* the License, or (at your option) any later version. +* +* This software is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this software; if not, write to the Free +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ +package org.jboss.cache.pojo.notification; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertSame; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.jboss.cache.pojo.PojoCache; +import org.jboss.cache.pojo.PojoCacheFactory; +import org.jboss.cache.pojo.notification.event.AttachedEvent; +import org.jboss.cache.pojo.notification.event.DetachedEvent; +import org.jboss.cache.pojo.notification.event.Event; +import org.jboss.cache.pojo.notification.event.MapModifiedEvent; +import org.jboss.cache.pojo.test.Person; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +//$Id$ + +/** + * Tests map notifications + * + * @author Jason T. Greene + */ +(a)Test(groups =3D {"functional"}) +public class MapTest +{ + protected PojoCache cache; + protected Listener listener =3D new Listener(); + + @BeforeMethod(alwaysRun =3D true) + protected void setUp() throws Exception + { + String configFile =3D "META-INF/local-service.xml"; + boolean toStart =3D false; + cache =3D PojoCacheFactory.createCache(configFile, toStart); + cache.start(); + cache.addListener(listener); + } + + + @AfterMethod(alwaysRun =3D true) + protected void tearDown() throws Exception + { + cache.stop(); + listener.clear(); + } + + private T takeNotification(Class clazz) + { + T notification =3D listener.take(clazz); + verifyNotification(notification); + + return notification; + } + + protected void verifyNotification(Event notification) + { + assertSame(cache, notification.getContext().getPojoCache()); + assertEquals(true, notification.isLocal()); + } + + @SuppressWarnings("unchecked") + public void testMapAddNotification() throws Exception + { + final String key1 =3D "key1"; + final String key2 =3D "key2"; + final String test1 =3D "test1"; + final String test2 =3D "test2"; + + Map map =3D new LinkedHashMap(); + map.put(key1, test1); + map.put(key2, test2); + cache.attach("a", map); + map =3D (Map) cache.find("a"); + + // String attach + AttachedEvent attach =3D takeNotification(AttachedEvent.class); + assertEquals(test1, attach.getSource()); + + // Map put + MapModifiedEvent modify =3D takeNotification(MapModifiedEvent.class); + assertEquals(MapModifiedEvent.Operation.PUT, modify.getOperation()); + assertEquals(key1, modify.getKey()); + assertEquals(test1, modify.getValue()); + + // String attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(test2, attach.getSource()); + + // Map put + modify =3D takeNotification(MapModifiedEvent.class); + assertEquals(MapModifiedEvent.Operation.PUT, modify.getOperation()); + assertEquals(key2, modify.getKey()); + assertEquals(test2, modify.getValue()); + + // Map Attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(map, attach.getSource()); + + //cache.detach("a"); + + } + + @SuppressWarnings("unchecked") + public void testMapRemoveNotification() throws Exception + { + final String key1 =3D "key1"; + final String key2 =3D "key2"; + final String test1 =3D "test1"; + final String test2 =3D "test2"; + + Map map =3D new LinkedHashMap(); + map.put(key1, test1); + map.put(key2, test2); + cache.attach("b", map); + map =3D (Map) cache.find("b"); + map.remove(key2); + + // String attach + AttachedEvent attach =3D takeNotification(AttachedEvent.class); + assertEquals(test1, attach.getSource()); + + // Map put + MapModifiedEvent modify =3D takeNotification(MapModifiedEvent.class); + assertEquals(MapModifiedEvent.Operation.PUT, modify.getOperation()); + assertEquals(key1, modify.getKey()); + assertEquals(test1, modify.getValue()); + + // String attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(test2, attach.getSource()); + + // Map put + modify =3D takeNotification(MapModifiedEvent.class); + assertEquals(MapModifiedEvent.Operation.PUT, modify.getOperation()); + assertEquals(key2, modify.getKey()); + assertEquals(test2, modify.getValue()); + + // Map Attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(map, attach.getSource()); + + // Map remove + modify =3D takeNotification(MapModifiedEvent.class); + assertEquals(MapModifiedEvent.Operation.REMOVE, modify.getOperation(= )); + assertEquals(key2, modify.getKey()); + assertEquals(test2, modify.getValue()); + + // String detach + DetachedEvent detach =3D takeNotification(DetachedEvent.class); + assertEquals(test2, detach.getSource()); + + //cache.detach("b"); + } + + public void testObjectMapAdd() throws Exception + { + final String key1 =3D "key1"; + final String key2 =3D "key2"; + final String drumming =3D "druming"; + final String engineering =3D "engineering"; + + Person test =3D new Person(); + test.setName("Joe"); + test.setAge(30); + + Map map =3D new LinkedHashMap(); + map.put(key1, drumming); + map.put(key2, engineering); + test.setHobbies(map); + cache.attach("c", test); + + // String attach + AttachedEvent attach =3D takeNotification(AttachedEvent.class); + assertEquals(drumming, attach.getSource()); + + // Map put + MapModifiedEvent modify =3D takeNotification(MapModifiedEvent.class); + assertEquals(MapModifiedEvent.Operation.PUT, modify.getOperation()); + assertEquals(key1, modify.getKey()); + assertEquals(drumming, modify.getValue()); + + // String attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(engineering, attach.getSource()); + + // Map put + modify =3D takeNotification(MapModifiedEvent.class); + assertEquals(key2, modify.getKey()); + assertEquals(MapModifiedEvent.Operation.PUT, modify.getOperation()); + assertEquals(engineering, modify.getValue()); + + // Map Attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(test.getHobbies(), attach.getSource()); + + // Person Attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(test, attach.getSource()); + + //cache.detach("c"); + } + + +} Deleted: pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notificatio= n/ObjectTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ObjectTest.j= ava 2008-07-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Obj= ectTest.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,156 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ - -package org.jboss.cache.pojo.notification; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertSame; -import static org.testng.AssertJUnit.assertTrue; - -import org.jboss.cache.pojo.PojoCache; -import org.jboss.cache.pojo.PojoCacheFactory; -import org.jboss.cache.pojo.notification.event.AttachedEvent; -import org.jboss.cache.pojo.notification.event.DetachedEvent; -import org.jboss.cache.pojo.notification.event.Event; -import org.jboss.cache.pojo.notification.event.FieldModifiedEvent; -import org.jboss.cache.pojo.test.Address; -import org.jboss.cache.pojo.test.Person; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -// $Id$ - -/** - * Tests attach, detach, and field modify notifications - * - * @author Jason T. Greene - */ -(a)Test(groups =3D {"functional"}) -public class ObjectTest -{ - protected PojoCache cache; - protected Listener listener; - - - @BeforeMethod(alwaysRun =3D true) - protected void setUp() throws Exception - { - String configFile =3D "META-INF/local-service.xml"; - boolean toStart =3D false; - cache =3D PojoCacheFactory.createCache(configFile, toStart); - cache.start(); - - listener =3D new Listener(); - cache.addListener(listener); - } - - private T takeNotification(Class clazz) - { - T notification =3D listener.take(clazz); - verifyNotification(notification); - - return notification; - } - - protected void verifyNotification(Event notification) - { - assertSame(cache, notification.getContext().getPojoCache()); - assertEquals(true, notification.isLocal()); - } - - - - @AfterMethod(alwaysRun =3D true) - protected void tearDown() throws Exception - { - cache.stop(); - } - - public void testAttachNotification() throws Exception - { - Person test =3D new Person(); - test.setName("Ben"); - test.setAge(10); - cache.attach("/a", test); - AttachedEvent attach =3D takeNotification(AttachedEvent.class); - assertEquals(test, attach.getSource()); - } - - public void testAttachNotification2() throws Exception - { - Person test =3D new Person(); - test.setName("Ben"); - test.setAge(10); - Address addr =3D new Address(); - test.setAddress(addr); - cache.attach("/a", test); - - // Address Attach - AttachedEvent attach =3D takeNotification(AttachedEvent.class); - assertEquals(addr, attach.getSource()); - - // Person Attach - attach =3D takeNotification(AttachedEvent.class); - assertEquals(test, attach.getSource()); - } - - public void testDetachNotification() throws Exception - { - Person test =3D new Person(); - test.setName("Ben"); - test.setAge(10); - cache.attach("/a", test); - - // Person Attach - AttachedEvent attach =3D takeNotification(AttachedEvent.class); - Object attached =3D attach.getSource(); - assertEquals(test, attached); - - cache.detach("/a"); - - // Person Detach - DetachedEvent detach =3D takeNotification(DetachedEvent.class); - assertSame(attached, detach.getSource()); - } - - public void testFieldNotification() throws Exception - { - Person test =3D new Person(); - test.setName("Ben"); - test.setAge(10); - cache.attach("/a", test); - - // Person Attach - AttachedEvent attach =3D takeNotification(AttachedEvent.class); - assertEquals(test, attach.getSource()); - - // Field modification - test.setAge(20); - FieldModifiedEvent modify =3D takeNotification(FieldModifiedEvent.cl= ass); - assertEquals(test, modify.getSource()); - assertEquals(test.getClass().getDeclaredField("age"), modify.getFiel= d()); - assertEquals(20, modify.getValue()); - - // Object Field Modification - Address addr =3D new Address(); - addr.setCity("Madison"); - addr.setStreet("State St."); - addr.setZip(53703); - test.setAddress(addr); - - // First Attach - attach =3D takeNotification(AttachedEvent.class); - assertEquals(addr, attach.getSource()); - - // Then Modify - modify =3D takeNotification(FieldModifiedEvent.class); - assertEquals(test, modify.getSource()); - assertEquals(test.getClass().getDeclaredField("address"), modify.get= Field()); - assertEquals(addr, modify.getValue()); - } -} \ No newline at end of file Copied: pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification= /ObjectTest.java (from rev 6323, pojo/trunk/src/test/java/org/jboss/cache/p= ojo/notification/ObjectTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Obj= ectTest.java (rev 0) +++ pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Obj= ectTest.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,160 @@ +/* + * JBoss, Home of Professional Open Source + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ + +package org.jboss.cache.pojo.notification; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertSame; +import static org.testng.AssertJUnit.assertTrue; + +import org.jboss.cache.pojo.PojoCache; +import org.jboss.cache.pojo.PojoCacheFactory; +import org.jboss.cache.pojo.notification.event.AttachedEvent; +import org.jboss.cache.pojo.notification.event.DetachedEvent; +import org.jboss.cache.pojo.notification.event.Event; +import org.jboss.cache.pojo.notification.event.FieldModifiedEvent; +import org.jboss.cache.pojo.test.Address; +import org.jboss.cache.pojo.test.Person; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +// $Id$ + +/** + * Tests attach, detach, and field modify notifications + * + * @author Jason T. Greene + */ +(a)Test(groups =3D {"functional"}) +public class ObjectTest +{ + protected PojoCache cache; + protected Listener listener =3D new Listener(); + + + @BeforeMethod(alwaysRun =3D true) + protected void setUp() throws Exception + { + String configFile =3D "META-INF/local-service.xml"; + boolean toStart =3D false; + cache =3D PojoCacheFactory.createCache(configFile, toStart); + cache.start(); + + cache.addListener(listener); + } + + private T takeNotification(Class clazz) + { + T notification =3D listener.take(clazz); + verifyNotification(notification); + + return notification; + } + + protected void verifyNotification(Event notification) + { + assertSame(cache, notification.getContext().getPojoCache()); + assertEquals(true, notification.isLocal()); + } + + + + @AfterMethod(alwaysRun =3D true) + protected void tearDown() throws Exception + { + cache.stop(); + listener.clear(); + } + + public void testAttachNotification() throws Exception + { + Person test =3D new Person(); + test.setName("Ben"); + test.setAge(10); + cache.attach("/a", test); + AttachedEvent attach =3D takeNotification(AttachedEvent.class); + assertEquals(test, attach.getSource()); + //cache.detach("/a"); + } + + public void testAttachNotification2() throws Exception + { + Person test =3D new Person(); + test.setName("Ben"); + test.setAge(10); + Address addr =3D new Address(); + test.setAddress(addr); + cache.attach("/b", test); + + // Address Attach + AttachedEvent attach =3D takeNotification(AttachedEvent.class); + assertEquals(addr, attach.getSource()); + + // Person Attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(test, attach.getSource()); + //cache.detach("/b"); + } + + public void testDetachNotification() throws Exception + { + Person test =3D new Person(); + test.setName("Ben"); + test.setAge(10); + cache.attach("/c", test); + + // Person Attach + AttachedEvent attach =3D takeNotification(AttachedEvent.class); + Object attached =3D attach.getSource(); + assertEquals(test, attached); + + cache.detach("/c"); + + // Person Detach + DetachedEvent detach =3D takeNotification(DetachedEvent.class); + assertSame(attached, detach.getSource()); + } + + public void testFieldNotification() throws Exception + { + Person test =3D new Person(); + test.setName("Ben"); + test.setAge(10); + cache.attach("/d", test); + + // Person Attach + AttachedEvent attach =3D takeNotification(AttachedEvent.class); + assertEquals(test, attach.getSource()); + + // Field modification + test.setAge(20); + FieldModifiedEvent modify =3D takeNotification(FieldModifiedEvent.cl= ass); + assertEquals(test, modify.getSource()); + assertEquals(test.getClass().getDeclaredField("age"), modify.getFiel= d()); + assertEquals(20, modify.getValue()); + + // Object Field Modification + Address addr =3D new Address(); + addr.setCity("Madison"); + addr.setStreet("State St."); + addr.setZip(53703); + test.setAddress(addr); + + // First Attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(addr, attach.getSource()); + + // Then Modify + modify =3D takeNotification(FieldModifiedEvent.class); + assertEquals(test, modify.getSource()); + assertEquals(test.getClass().getDeclaredField("address"), modify.get= Field()); + assertEquals(addr, modify.getValue()); + + //cache.detach("/d"); + } +} \ No newline at end of file Deleted: pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notificatio= n/ReplicatedListTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ReplicatedLi= stTest.java 2008-07-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Rep= licatedListTest.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,72 +0,0 @@ -/* -* JBoss, Home of Professional Open Source -* Copyright 2005, JBoss Inc., and individual contributors as indicated -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* This is free software; you can redistribute it and/or modify it -* under the terms of the GNU Lesser General Public License as -* published by the Free Software Foundation; either version 2.1 of -* the License, or (at your option) any later version. -* -* This software is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this software; if not, write to the Free -* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -* 02110-1301 USA, or see the FSF site: http://www.fsf.org. -*/ -package org.jboss.cache.pojo.notification; - - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertSame; - -import org.jboss.cache.config.Configuration.CacheMode; -import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; -import org.jboss.cache.pojo.PojoCache; -import org.jboss.cache.pojo.PojoCacheFactory; -import org.jboss.cache.pojo.notification.event.Event; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -//$Id$ - -/** - * Tests replicated list notifications - * - * @author Jason T. Greene - */ -(a)Test(groups =3D {"functional"}) -public class ReplicatedListTest extends ListTest -{ - private PojoCache listenerCache; - - @BeforeMethod(alwaysRun =3D true) - protected void setUp() throws Exception - { - cache =3D PojoCacheFactory.createCache(UnitTestCacheConfigurationFac= tory.createConfiguration(CacheMode.REPL_SYNC), false); - cache.start(); - listenerCache =3D PojoCacheFactory.createCache(UnitTestCacheConfigur= ationFactory.createConfiguration(CacheMode.REPL_SYNC), false); - listenerCache.start(); - listenerCache.addListener(listener); - } - - @AfterMethod(alwaysRun =3D true) - protected void tearDown() throws Exception - { - cache.stop(); - listenerCache.stop(); - listener.clear(); - } - - protected void verifyNotification(Event notification) - { - assertSame(listenerCache, notification.getContext().getPojoCache()); - assertEquals(false, notification.isLocal()); - } -} Copied: pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification= /ReplicatedListTest.java (from rev 6323, pojo/trunk/src/test/java/org/jboss= /cache/pojo/notification/ReplicatedListTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Rep= licatedListTest.java (rev 0) +++ pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Rep= licatedListTest.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,77 @@ +/* +* JBoss, Home of Professional Open Source +* Copyright 2005, JBoss Inc., and individual contributors as indicated +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* This is free software; you can redistribute it and/or modify it +* under the terms of the GNU Lesser General Public License as +* published by the Free Software Foundation; either version 2.1 of +* the License, or (at your option) any later version. +* +* This software is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this software; if not, write to the Free +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ +package org.jboss.cache.pojo.notification; + + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertSame; + +import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.Configuration.CacheMode; +import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; +import org.jboss.cache.pojo.PojoCache; +import org.jboss.cache.pojo.PojoCacheFactory; +import org.jboss.cache.pojo.notification.event.Event; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +//$Id$ + +/** + * Tests replicated list notifications + * + * @author Jason T. Greene + */ +(a)Test(groups =3D {"functional"}) +public class ReplicatedListTest extends ListTest +{ + private PojoCache listenerCache; + + @BeforeMethod(alwaysRun =3D true) + protected void setUp() throws Exception + { + Configuration config =3D UnitTestCacheConfigurationFactory.createCon= figuration(CacheMode.REPL_SYNC); + config.setFetchInMemoryState(false); + Configuration config2 =3D UnitTestCacheConfigurationFactory.createCo= nfiguration(CacheMode.REPL_SYNC); + config2.setFetchInMemoryState(false); + cache =3D PojoCacheFactory.createCache(config, false); + cache.start(); + listenerCache =3D PojoCacheFactory.createCache(config2, false); + listenerCache.start(); + listenerCache.addListener(listener); + } + + @AfterMethod(alwaysRun =3D true) + protected void tearDown() throws Exception + { + cache.stop(); + listenerCache.stop(); + listener.clear(); + } + + protected void verifyNotification(Event notification) + { + assertSame(listenerCache, notification.getContext().getPojoCache()); + assertEquals(false, notification.isLocal()); + } +} Deleted: pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notificatio= n/ReplicatedMapTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ReplicatedMa= pTest.java 2008-07-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Rep= licatedMapTest.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,76 +0,0 @@ -/* -* JBoss, Home of Professional Open Source -* Copyright 2005, JBoss Inc., and individual contributors as indicated -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* This is free software; you can redistribute it and/or modify it -* under the terms of the GNU Lesser General Public License as -* published by the Free Software Foundation; either version 2.1 of -* the License, or (at your option) any later version. -* -* This software is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this software; if not, write to the Free -* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -* 02110-1301 USA, or see the FSF site: http://www.fsf.org. -*/ -package org.jboss.cache.pojo.notification; - - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertSame; - -import org.jboss.cache.config.Configuration.CacheMode; -import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; -import org.jboss.cache.pojo.PojoCache; -import org.jboss.cache.pojo.PojoCacheFactory; -import org.jboss.cache.pojo.notification.event.Event; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -//$Id$ - -/** - * Tests replicated map notifications - * - * @author Jason T. Greene - */ -(a)Test(groups =3D {"functional"}) -public class ReplicatedMapTest extends MapTest -{ - private PojoCache listenerCache; - - @BeforeMethod(alwaysRun =3D true) - protected void setUp() throws Exception - { - super.setUp(); - - cache =3D PojoCacheFactory.createCache(UnitTestCacheConfigurationFac= tory.createConfiguration(CacheMode.REPL_SYNC), false); - cache.start(); - listenerCache =3D PojoCacheFactory.createCache(UnitTestCacheConfigur= ationFactory.createConfiguration(CacheMode.REPL_SYNC), false); - listenerCache.start(); - listenerCache.addListener(listener); - } - - @AfterMethod(alwaysRun =3D true) - protected void tearDown() throws Exception - { - super.tearDown(); - cache.stop(); - listenerCache.stop(); - } - - protected void verifyNotification(Event notification) - { - assertSame(listenerCache, notification.getContext().getPojoCache()); - assertEquals(false, notification.isLocal()); - } - - -} Copied: pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification= /ReplicatedMapTest.java (from rev 6323, pojo/trunk/src/test/java/org/jboss/= cache/pojo/notification/ReplicatedMapTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Rep= licatedMapTest.java (rev 0) +++ pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Rep= licatedMapTest.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,79 @@ +/* +* JBoss, Home of Professional Open Source +* Copyright 2005, JBoss Inc., and individual contributors as indicated +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* This is free software; you can redistribute it and/or modify it +* under the terms of the GNU Lesser General Public License as +* published by the Free Software Foundation; either version 2.1 of +* the License, or (at your option) any later version. +* +* This software is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this software; if not, write to the Free +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ +package org.jboss.cache.pojo.notification; + + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertSame; + +import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.Configuration.CacheMode; +import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; +import org.jboss.cache.pojo.PojoCache; +import org.jboss.cache.pojo.PojoCacheFactory; +import org.jboss.cache.pojo.notification.event.Event; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +//$Id$ + +/** + * Tests replicated map notifications + * + * @author Jason T. Greene + */ +(a)Test(groups =3D {"functional"}) +public class ReplicatedMapTest extends MapTest +{ + private PojoCache listenerCache; + + @BeforeMethod(alwaysRun =3D true) + protected void setUp() throws Exception + { + Configuration config =3D UnitTestCacheConfigurationFactory.createCon= figuration(CacheMode.REPL_SYNC); + config.setFetchInMemoryState(false); + Configuration config2 =3D UnitTestCacheConfigurationFactory.createCo= nfiguration(CacheMode.REPL_SYNC); + config2.setFetchInMemoryState(false); + cache =3D PojoCacheFactory.createCache(config, false); + cache.start(); + listenerCache =3D PojoCacheFactory.createCache(config2, false); + listenerCache.start(); + listenerCache.addListener(listener); + } + + @AfterMethod(alwaysRun =3D true) + protected void tearDown() throws Exception + { + cache.stop(); + listenerCache.stop(); + listener.clear(); + } + + protected void verifyNotification(Event notification) + { + assertSame(listenerCache, notification.getContext().getPojoCache()); + assertEquals(false, notification.isLocal()); + } + + +} Deleted: pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notificatio= n/ReplicatedObjectTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ReplicatedOb= jectTest.java 2008-07-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Rep= licatedObjectTest.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,73 +0,0 @@ -/* -* JBoss, Home of Professional Open Source -* Copyright 2005, JBoss Inc., and individual contributors as indicated -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* This is free software; you can redistribute it and/or modify it -* under the terms of the GNU Lesser General Public License as -* published by the Free Software Foundation; either version 2.1 of -* the License, or (at your option) any later version. -* -* This software is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this software; if not, write to the Free -* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -* 02110-1301 USA, or see the FSF site: http://www.fsf.org. -*/ -package org.jboss.cache.pojo.notification; - - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertSame; - -import org.jboss.cache.config.Configuration.CacheMode; -import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; -import org.jboss.cache.pojo.PojoCache; -import org.jboss.cache.pojo.PojoCacheFactory; -import org.jboss.cache.pojo.notification.event.Event; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -//$Id$ - -/** - * Tests replicated set notifications - * - * @author Jason T. Greene - */ -(a)Test(groups =3D {"functional"}) -public class ReplicatedObjectTest extends ObjectTest -{ - private PojoCache listenerCache; - - @BeforeMethod(alwaysRun =3D true) - protected void setUp() throws Exception - { - cache =3D PojoCacheFactory.createCache(UnitTestCacheConfigurationFac= tory.createConfiguration(CacheMode.REPL_SYNC), false); - cache.start(); - listenerCache =3D PojoCacheFactory.createCache(UnitTestCacheConfigur= ationFactory.createConfiguration(CacheMode.REPL_SYNC), false); - listenerCache.start(); - listener =3D new Listener(); - listenerCache.addListener(listener); - } - @AfterMethod(alwaysRun =3D true) - protected void tearDown() throws Exception - { - cache.stop(); - listenerCache.stop(); - } - - protected void verifyNotification(Event notification) - { - assertSame(listenerCache, notification.getContext().getPojoCache()); - assertEquals(false, notification.isLocal()); - } - - -} Copied: pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification= /ReplicatedObjectTest.java (from rev 6323, pojo/trunk/src/test/java/org/jbo= ss/cache/pojo/notification/ReplicatedObjectTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Rep= licatedObjectTest.java (rev 0) +++ pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Rep= licatedObjectTest.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,78 @@ +/* +* JBoss, Home of Professional Open Source +* Copyright 2005, JBoss Inc., and individual contributors as indicated +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* This is free software; you can redistribute it and/or modify it +* under the terms of the GNU Lesser General Public License as +* published by the Free Software Foundation; either version 2.1 of +* the License, or (at your option) any later version. +* +* This software is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this software; if not, write to the Free +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ +package org.jboss.cache.pojo.notification; + + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertSame; + +import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.Configuration.CacheMode; +import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; +import org.jboss.cache.pojo.PojoCache; +import org.jboss.cache.pojo.PojoCacheFactory; +import org.jboss.cache.pojo.notification.event.Event; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +//$Id$ + +/** + * Tests replicated set notifications + * + * @author Jason T. Greene + */ +(a)Test(groups =3D {"functional"}) +public class ReplicatedObjectTest extends ObjectTest +{ + private PojoCache listenerCache; + + @BeforeMethod(alwaysRun =3D true) + protected void setUp() throws Exception + { + Configuration config =3D UnitTestCacheConfigurationFactory.createCon= figuration(CacheMode.REPL_SYNC); + config.setFetchInMemoryState(false); + Configuration config2 =3D UnitTestCacheConfigurationFactory.createCo= nfiguration(CacheMode.REPL_SYNC); + config2.setFetchInMemoryState(false); + cache =3D PojoCacheFactory.createCache(config, false); + cache.start(); + listenerCache =3D PojoCacheFactory.createCache(config2, false); + listenerCache.start(); + listenerCache.addListener(listener); + } + @AfterMethod(alwaysRun =3D true) + protected void tearDown() throws Exception + { + cache.stop(); + listenerCache.stop(); + listener.clear(); + } + + protected void verifyNotification(Event notification) + { + assertSame(listenerCache, notification.getContext().getPojoCache()); + assertEquals(false, notification.isLocal()); + } + + +} Deleted: pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notificatio= n/ReplicatedSetTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ReplicatedSe= tTest.java 2008-07-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Rep= licatedSetTest.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,76 +0,0 @@ -/* -* JBoss, Home of Professional Open Source -* Copyright 2005, JBoss Inc., and individual contributors as indicated -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* This is free software; you can redistribute it and/or modify it -* under the terms of the GNU Lesser General Public License as -* published by the Free Software Foundation; either version 2.1 of -* the License, or (at your option) any later version. -* -* This software is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this software; if not, write to the Free -* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -* 02110-1301 USA, or see the FSF site: http://www.fsf.org. -*/ -package org.jboss.cache.pojo.notification; - - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertSame; - -import org.jboss.cache.config.Configuration.CacheMode; -import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; -import org.jboss.cache.pojo.PojoCache; -import org.jboss.cache.pojo.PojoCacheFactory; -import org.jboss.cache.pojo.notification.event.Event; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -//$Id$ - -/** - * Tests replicated set notifications - * - * @author Jason T. Greene - */ -(a)Test(groups =3D {"functional"}) -public class ReplicatedSetTest extends ListTest -{ - private PojoCache listenerCache; - - @BeforeMethod(alwaysRun =3D true) - protected void setUp() throws Exception - { - super.setUp(); - - cache =3D PojoCacheFactory.createCache(UnitTestCacheConfigurationFac= tory.createConfiguration(CacheMode.REPL_SYNC), false); - cache.start(); - listenerCache =3D PojoCacheFactory.createCache(UnitTestCacheConfigur= ationFactory.createConfiguration(CacheMode.REPL_SYNC), false); - listenerCache.start(); - listenerCache.addListener(listener); - } - - @AfterMethod(alwaysRun =3D true) - protected void tearDown() throws Exception - { - super.tearDown(); - cache.stop(); - listenerCache.stop(); - } - - protected void verifyNotification(Event notification) - { - assertSame(listenerCache, notification.getContext().getPojoCache()); - assertEquals(false, notification.isLocal()); - } - - -} Copied: pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification= /ReplicatedSetTest.java (from rev 6323, pojo/trunk/src/test/java/org/jboss/= cache/pojo/notification/ReplicatedSetTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Rep= licatedSetTest.java (rev 0) +++ pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Rep= licatedSetTest.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,79 @@ +/* +* JBoss, Home of Professional Open Source +* Copyright 2005, JBoss Inc., and individual contributors as indicated +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* This is free software; you can redistribute it and/or modify it +* under the terms of the GNU Lesser General Public License as +* published by the Free Software Foundation; either version 2.1 of +* the License, or (at your option) any later version. +* +* This software is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this software; if not, write to the Free +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ +package org.jboss.cache.pojo.notification; + + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertSame; + +import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.Configuration.CacheMode; +import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; +import org.jboss.cache.pojo.PojoCache; +import org.jboss.cache.pojo.PojoCacheFactory; +import org.jboss.cache.pojo.notification.event.Event; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +//$Id$ + +/** + * Tests replicated set notifications + * + * @author Jason T. Greene + */ +(a)Test(groups =3D {"functional"}) +public class ReplicatedSetTest extends SetTest +{ + private PojoCache listenerCache; + + @BeforeMethod(alwaysRun =3D true) + protected void setUp() throws Exception + { + Configuration config =3D UnitTestCacheConfigurationFactory.createCon= figuration(CacheMode.REPL_SYNC); + config.setFetchInMemoryState(false); + Configuration config2 =3D UnitTestCacheConfigurationFactory.createCo= nfiguration(CacheMode.REPL_SYNC); + config2.setFetchInMemoryState(false); + cache =3D PojoCacheFactory.createCache(config, false); + cache.start(); + listenerCache =3D PojoCacheFactory.createCache(config2, false); + listenerCache.start(); + listenerCache.addListener(listener); + } + + @AfterMethod(alwaysRun =3D true) + protected void tearDown() throws Exception + { + cache.stop(); + listenerCache.stop(); + listener.clear(); + } + + protected void verifyNotification(Event notification) + { + assertSame(listenerCache, notification.getContext().getPojoCache()); + assertEquals(false, notification.isLocal()); + } + + +} Deleted: pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notificatio= n/SetTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/SetTest.java= 2008-07-16 17:30:08 UTC (rev 6310) +++ pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Set= Test.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -1,210 +0,0 @@ -/* -* JBoss, Home of Professional Open Source -* Copyright 2005, JBoss Inc., and individual contributors as indicated -* by the @authors tag. See the copyright.txt in the distribution for a -* full listing of individual contributors. -* -* This is free software; you can redistribute it and/or modify it -* under the terms of the GNU Lesser General Public License as -* published by the Free Software Foundation; either version 2.1 of -* the License, or (at your option) any later version. -* -* This software is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this software; if not, write to the Free -* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -* 02110-1301 USA, or see the FSF site: http://www.fsf.org. -*/ -package org.jboss.cache.pojo.notification; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertSame; - -import java.util.LinkedHashSet; -import java.util.Set; - -import org.jboss.cache.pojo.PojoCache; -import org.jboss.cache.pojo.PojoCacheFactory; -import org.jboss.cache.pojo.notification.event.AttachedEvent; -import org.jboss.cache.pojo.notification.event.DetachedEvent; -import org.jboss.cache.pojo.notification.event.Event; -import org.jboss.cache.pojo.notification.event.SetModifiedEvent; -import org.jboss.cache.pojo.test.Person; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -//$Id$ - -/** - * Tests set notifications - * - * @author Jason T. Greene - */ -(a)Test(groups =3D {"functional"}) -public class SetTest = -{ - private PojoCache cache; - private Listener listener =3D new Listener(); - - - @BeforeMethod(alwaysRun =3D true) - protected void setUp() throws Exception - { - String configFile =3D "META-INF/local-service.xml"; - boolean toStart =3D false; - cache =3D PojoCacheFactory.createCache(configFile, toStart); - cache.start(); - cache.addListener(listener); - } - - @AfterMethod(alwaysRun =3D true) - protected void tearDown() throws Exception - { - cache.stop(); - } - - private T takeNotification(Class clazz) - { - T notification =3D listener.take(clazz); - verifyNotification(notification); - - return notification; - } - - protected void verifyNotification(Event notification) - { - assertSame(cache, notification.getContext().getPojoCache()); - assertEquals(true, notification.isLocal()); - } - - @SuppressWarnings("unchecked") - public void testSetAddNotification() throws Exception - { - final String test1 =3D "test1"; - final String test2 =3D "test2"; - - Set set =3D new LinkedHashSet(); - set.add(test1); - set.add(test2); - cache.attach("a", set); - set =3D (Set) cache.find("a"); - - // String attach - AttachedEvent attach =3D takeNotification(AttachedEvent.class); - assertEquals(test1, attach.getSource()); - - // Set add - SetModifiedEvent modify =3D takeNotification(SetModifiedEvent.class); - assertEquals(SetModifiedEvent.Operation.ADD, modify.getOperation()); - assertEquals(test1, modify.getValue()); - - // String attach - attach =3D takeNotification(AttachedEvent.class); - assertEquals(test2, attach.getSource()); - - // Set add - modify =3D takeNotification(SetModifiedEvent.class); - assertEquals(SetModifiedEvent.Operation.ADD, modify.getOperation()); - assertEquals(test2, modify.getValue()); - - // Set Attach - attach =3D takeNotification(AttachedEvent.class); - assertSame(set, attach.getSource()); - - } - - @SuppressWarnings("unchecked") - public void testSetRemoveNotification() throws Exception - { - final String test1 =3D "test1"; - final String test2 =3D "test2"; - - Set set =3D new LinkedHashSet(); - set.add(test1); - set.add(test2); - cache.attach("a", set); - - set =3D (Set) cache.find("a"); - set.remove(test2); - - // String attach - AttachedEvent attach =3D takeNotification(AttachedEvent.class); - assertEquals(test1, attach.getSource()); - - // Set add - SetModifiedEvent modify =3D takeNotification(SetModifiedEvent.class); - assertEquals(SetModifiedEvent.Operation.ADD, modify.getOperation()); - assertEquals(test1, modify.getValue()); - - // String attach - attach =3D takeNotification(AttachedEvent.class); - assertEquals(test2, attach.getSource()); - - // Set add - modify =3D takeNotification(SetModifiedEvent.class); - assertEquals(SetModifiedEvent.Operation.ADD, modify.getOperation()); - assertEquals(test2, modify.getValue()); - - // Set Attach - attach =3D takeNotification(AttachedEvent.class); - assertSame(set, attach.getSource()); - - // Set remove - modify =3D takeNotification(SetModifiedEvent.class); - assertEquals(SetModifiedEvent.Operation.REMOVE, modify.getOperation(= )); - assertEquals(test2, modify.getValue()); - - // String detach - DetachedEvent detach =3D takeNotification(DetachedEvent.class); - assertEquals(test2, detach.getSource()); - } - - public void testObjectSetAdd() throws Exception - { - final String drumming =3D "druming"; - final String engineering =3D "engineering"; - - Person test =3D new Person(); - test.setName("Joe"); - test.setAge(30); - - Set set =3D new LinkedHashSet(); - set.add(drumming); - set.add(engineering); - test.setSkills(set); - cache.attach("a", test); - - // String attach - AttachedEvent attach =3D takeNotification(AttachedEvent.class); - assertEquals(drumming, attach.getSource()); - - // List add - SetModifiedEvent modify =3D takeNotification(SetModifiedEvent.class); - assertEquals(SetModifiedEvent.Operation.ADD, modify.getOperation()); - assertEquals(drumming, modify.getValue()); - - // String attach - attach =3D takeNotification(AttachedEvent.class); - assertEquals(engineering, attach.getSource()); - - // List add - modify =3D takeNotification(SetModifiedEvent.class); - assertEquals(SetModifiedEvent.Operation.ADD, modify.getOperation()); - assertEquals(engineering, modify.getValue()); - - // List Attach - attach =3D takeNotification(AttachedEvent.class); - assertEquals(test.getSkills(), attach.getSource()); - - // Person Attach - attach =3D takeNotification(AttachedEvent.class); - assertEquals(test, attach.getSource()); - } - - -} Copied: pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification= /SetTest.java (from rev 6323, pojo/trunk/src/test/java/org/jboss/cache/pojo= /notification/SetTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Set= Test.java (rev 0) +++ pojo/tags/2.2.0.CR7/src/test/java/org/jboss/cache/pojo/notification/Set= Test.java 2008-08-12 04:16:02 UTC (rev 6554) @@ -0,0 +1,214 @@ +/* +* JBoss, Home of Professional Open Source +* Copyright 2005, JBoss Inc., and individual contributors as indicated +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* This is free software; you can redistribute it and/or modify it +* under the terms of the GNU Lesser General Public License as +* published by the Free Software Foundation; either version 2.1 of +* the License, or (at your option) any later version. +* +* This software is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this software; if not, write to the Free +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ +package org.jboss.cache.pojo.notification; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertSame; + +import java.util.LinkedHashSet; +import java.util.Set; + +import org.jboss.cache.pojo.PojoCache; +import org.jboss.cache.pojo.PojoCacheFactory; +import org.jboss.cache.pojo.notification.event.AttachedEvent; +import org.jboss.cache.pojo.notification.event.DetachedEvent; +import org.jboss.cache.pojo.notification.event.Event; +import org.jboss.cache.pojo.notification.event.SetModifiedEvent; +import org.jboss.cache.pojo.test.Person; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +//$Id$ + +/** + * Tests set notifications + * + * @author Jason T. Greene + */ +(a)Test(groups =3D {"functional"}) +public class SetTest +{ + protected PojoCache cache; + protected Listener listener =3D new Listener(); + + + @BeforeMethod(alwaysRun =3D true) + protected void setUp() throws Exception + { + String configFile =3D "META-INF/local-service.xml"; + boolean toStart =3D false; + cache =3D PojoCacheFactory.createCache(configFile, toStart); + cache.start(); + cache.addListener(listener); + } + + @AfterMethod(alwaysRun =3D true) + protected void tearDown() throws Exception + { + cache.stop(); + listener.clear(); + } + + private T takeNotification(Class clazz) + { + T notification =3D listener.take(clazz); + verifyNotification(notification); + + return notification; + } + + protected void verifyNotification(Event notification) + { + assertSame(cache, notification.getContext().getPojoCache()); + assertEquals(true, notification.isLocal()); + } + + @SuppressWarnings("unchecked") + public void testSetAddNotification() throws Exception + { + final String test1 =3D "test1"; + final String test2 =3D "test2"; + + Set set =3D new LinkedHashSet(); + set.add(test1); + set.add(test2); + cache.attach("a", set); + set =3D (Set) cache.find("a"); + + // String attach + AttachedEvent attach =3D takeNotification(AttachedEvent.class); + assertEquals(test1, attach.getSource()); + + // Set add + SetModifiedEvent modify =3D takeNotification(SetModifiedEvent.class); + assertEquals(SetModifiedEvent.Operation.ADD, modify.getOperation()); + assertEquals(test1, modify.getValue()); + + // String attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(test2, attach.getSource()); + + // Set add + modify =3D takeNotification(SetModifiedEvent.class); + assertEquals(SetModifiedEvent.Operation.ADD, modify.getOperation()); + assertEquals(test2, modify.getValue()); + + // Set Attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(set, attach.getSource()); + + //cache.detach("a"); + } + + @SuppressWarnings("unchecked") + public void testSetRemoveNotification() throws Exception + { + final String test1 =3D "test1"; + final String test2 =3D "test2"; + + Set set =3D new LinkedHashSet(); + set.add(test1); + set.add(test2); + cache.attach("b", set); + + set =3D (Set) cache.find("b"); + set.remove(test2); + + // String attach + AttachedEvent attach =3D takeNotification(AttachedEvent.class); + assertEquals(test1, attach.getSource()); + + // Set add + SetModifiedEvent modify =3D takeNotification(SetModifiedEvent.class); + assertEquals(SetModifiedEvent.Operation.ADD, modify.getOperation()); + assertEquals(test1, modify.getValue()); + + // String attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(test2, attach.getSource()); + + // Set add + modify =3D takeNotification(SetModifiedEvent.class); + assertEquals(SetModifiedEvent.Operation.ADD, modify.getOperation()); + assertEquals(test2, modify.getValue()); + + // Set Attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(set, attach.getSource()); + + // Set remove + modify =3D takeNotification(SetModifiedEvent.class); + assertEquals(SetModifiedEvent.Operation.REMOVE, modify.getOperation(= )); + assertEquals(test2, modify.getValue()); + + // String detach + DetachedEvent detach =3D takeNotification(DetachedEvent.class); + assertEquals(test2, detach.getSource()); + + //cache.detach("b"); + } + + public void testObjectSetAdd() throws Exception + { + final String drumming =3D "druming"; + final String engineering =3D "engineering"; + + Person test =3D new Person(); + test.setName("Joe"); + test.setAge(30); + + Set set =3D new LinkedHashSet(); + set.add(drumming); + set.add(engineering); + test.setSkills(set); + cache.attach("c", test); + + // String attach + AttachedEvent attach =3D takeNotification(AttachedEvent.class); + assertEquals(drumming, attach.getSource()); + + // List add + SetModifiedEvent modify =3D takeNotification(SetModifiedEvent.class); + assertEquals(SetModifiedEvent.Operation.ADD, modify.getOperation()); + assertEquals(drumming, modify.getValue()); + + // String attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(engineering, attach.getSource()); + + // List add + modify =3D takeNotification(SetModifiedEvent.class); + assertEquals(SetModifiedEvent.Operation.ADD, modify.getOperation()); + assertEquals(engineering, modify.getValue()); + + // List Attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(test.getSkills(), attach.getSource()); + + // Person Attach + attach =3D takeNotification(AttachedEvent.class); + assertEquals(test, attach.getSource()); + + //cache.detach("c"); + } +} --===============4591295585551508619==-- From jbosscache-commits at lists.jboss.org Tue Aug 12 21:47:14 2008 Content-Type: multipart/mixed; boundary="===============1055043231246116572==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6555 - pojo/branches. Date: Tue, 12 Aug 2008 21:47:13 -0400 Message-ID: --===============1055043231246116572== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: jason.greene(a)jboss.com Date: 2008-08-12 21:47:13 -0400 (Tue, 12 Aug 2008) New Revision: 6555 Added: pojo/branches/2.2/ Log: Create 2.2 branch Copied: pojo/branches/2.2 (from rev 6554, pojo/tags/2.2.0.CR7) --===============1055043231246116572==-- From jbosscache-commits at lists.jboss.org Wed Aug 13 16:29:59 2008 Content-Type: multipart/mixed; boundary="===============1391748953470240497==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6556 - core/trunk/src/main/java/org/jboss/cache. Date: Wed, 13 Aug 2008 16:29:59 -0400 Message-ID: --===============1391748953470240497== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: jason.greene(a)jboss.com Date: 2008-08-13 16:29:58 -0400 (Wed, 13 Aug 2008) New Revision: 6556 Modified: core/trunk/src/main/java/org/jboss/cache/Fqn.java Log: Make Fqn API friendlier Modified: core/trunk/src/main/java/org/jboss/cache/Fqn.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/Fqn.java 2008-08-13 01:47:13 U= TC (rev 6555) +++ core/trunk/src/main/java/org/jboss/cache/Fqn.java 2008-08-13 20:29:58 U= TC (rev 6556) @@ -125,7 +125,7 @@ } } = - protected Fqn(Fqn base, List relative) + protected Fqn(Fqn base, List relative) { elements =3D Immutables.immutableListMerge(base.elements, relative); size =3D elements.size(); @@ -140,9 +140,10 @@ * @return an Fqn * @since 2.2.0 */ - public static Fqn fromList(List names) + @SuppressWarnings("unchecked") + public static Fqn fromList(List names) { - return new Fqn(names, false); + return new Fqn((List)names, false); } = /** @@ -155,9 +156,10 @@ * an appropriare List implementation is used, which works= well with Fqn operations. * @return an Fqn */ - public static Fqn fromList(List names, boolean safe) + @SuppressWarnings("unchecked") + public static Fqn fromList(List names, boolean safe) { - return new Fqn(names, safe); + return new Fqn((List)names, safe); } = /** @@ -193,7 +195,7 @@ * @return an Fqn * @since 2.2.0 */ - public static Fqn fromRelativeList(Fqn base, List relativeEleme= nts) + public static Fqn fromRelativeList(Fqn base, List relativeElements) { return new Fqn(base, relativeElements); } --===============1391748953470240497==-- From jbosscache-commits at lists.jboss.org Wed Aug 13 22:46:04 2008 Content-Type: multipart/mixed; boundary="===============3554652024633349806==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6557 - in pojo/trunk: src/main/java/org/jboss/cache/pojo and 17 other directories. Date: Wed, 13 Aug 2008 22:46:04 -0400 Message-ID: --===============3554652024633349806== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: jason.greene(a)jboss.com Date: 2008-08-13 22:46:03 -0400 (Wed, 13 Aug 2008) New Revision: 6557 Removed: pojo/trunk/src/test/java/org/jboss/cache/pojo/statetransfer/StateTransfe= r200AopTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/statetransfer/StateTransfe= rAopTestBase.java Modified: pojo/trunk/pom.xml pojo/trunk/src/main/java/org/jboss/cache/pojo/PojoCache.java pojo/trunk/src/main/java/org/jboss/cache/pojo/Reference.java pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedArray.java pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedMapImpl.j= ava pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedObjectArr= ay.java pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedPrimitive= Array.java pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AbstractHandler.java pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojoHandler.ja= va pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ArrayHandler.java pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/CollectionClassHandle= r.java pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalConstant.java pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalHelper.java pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ObjectGraphHandler.ja= va pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDelegate.java pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheImpl.java pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ReferenceImpl.java pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/SerializableObjectHan= dler.java pojo/trunk/src/main/java/org/jboss/cache/pojo/interceptors/AbstractInter= ceptor.java pojo/trunk/src/main/java/org/jboss/cache/pojo/jmx/PojoCacheJmxWrapper.ja= va pojo/trunk/src/main/java/org/jboss/cache/pojo/util/AopUtil.java pojo/trunk/src/test/java/org/jboss/cache/pojo/ArrayTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/CircularGraphTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/FindReferencesTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalConcurrentTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTxTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/NewLocalTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/NewReplicatedTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/NonAspectizedTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/ObjectGraphTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/RecursiveRefTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/TxUndoTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedListTest.= java pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedMapNullTe= st.java pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedMapTest.j= ava pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedSetTest.j= ava pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CollectionTest.= java pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/ObjectGraphTest= .java pojo/trunk/src/test/java/org/jboss/cache/pojo/demo/JBossCacheGUI.java pojo/trunk/src/test/java/org/jboss/cache/pojo/jmx/LegacyConfigurationTes= t.java pojo/trunk/src/test/java/org/jboss/cache/pojo/memory/ReplicatedTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ListTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ListenerCount= Test.java pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/MapTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ObjectTest.ja= va pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/SetTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/TxObjectTest.= java pojo/trunk/src/test/java/org/jboss/cache/pojo/optimistic/AbstractOptimis= ticTestCase.java pojo/trunk/src/test/java/org/jboss/cache/pojo/optimistic/LocalTxTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/passivation/LocalTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/region/LocalConcurrentTest= .java pojo/trunk/src/test/java/org/jboss/cache/pojo/region/LocalTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/region/NewLocalTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/InMemoryTxUndoTes= t.java pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ListTxUndoTest.ja= va pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ListUndoTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalExceptionUnd= oTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalTxUndoTest.j= ava pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalUndoTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/MapTxUndoTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/MapUndoTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/PojoCollectionRol= lbackTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/SetTxUndoTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/SetUndoTest.java pojo/trunk/src/test/java/org/jboss/cache/pojo/util/ObjectUtilTest.java Log: Update to be compatible with core API changes Update to commons logging 1.1.1 Drop two old out-of-date tests Modified: pojo/trunk/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/pom.xml 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/pom.xml 2008-08-14 02:46:03 UTC (rev 6557) @@ -4,9 +4,9 @@ xsi:schemaLocation=3D"http://maven.apache.org/POM/4.0.0 http://maven.apa= che.org/xsd/maven-4.0.0.xsd"> 4.0.0 - 2.2.0-SNAPSHOT - 2.2.0.CR6 - 2.0.0.CR14 + 3.0.0-SNAPSHOT + 3.0.0.ALPHA2 + 2.0.0.CR15 org.jboss.cache @@ -40,7 +40,7 @@ commons-logging commons-logging - 1.0.4 + 1.1.1 net.jcip @@ -115,7 +115,7 @@ functional always - -Djboss.aop.path=3D${basedir}/src/main/resources/META-I= NF/pojocache-aop.xml -javaagent:${settings.localRepository}/org/jboss/aop/j= boss-aop/${jboss.aop.version}/jboss-aop-${jboss.aop.version}.jar + -Djbosscache.config.validate=3Dfalse -Djboss.aop.path= =3D${basedir}/src/main/resources/META-INF/pojocache-aop.xml -javaagent:${se= ttings.localRepository}/org/jboss/aop/jboss-aop/${jboss.aop.version}/jboss-= aop-${jboss.aop.version}.jar true Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/PojoCache.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/PojoCache.java 2008-08-13= 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/PojoCache.java 2008-08-14= 02:46:03 UTC (rev 6557) @@ -83,7 +83,7 @@ * @return Existing POJO or null if there is none. * @throws PojoCacheException Throws if there is an error related to th= e cache operation. */ - Object attach(Fqn id, Object pojo) throws PojoCacheException; + Object attach(Fqn id, Object pojo) throws PojoCacheException; = /** * Remove POJO object from the cache. @@ -102,7 +102,7 @@ * @return Original value object from this node. * @throws PojoCacheException Throws if there is an error related to th= e cache operation. */ - Object detach(Fqn id) throws PojoCacheException; + Object detach(Fqn id) throws PojoCacheException; = /** * Return the Fqn of the internal node containing the data = of this attached object. @@ -116,7 +116,7 @@ * @return Fqn of the internal data node. null= if the object is * immediate, serializable, or not in the cache. */ - Fqn getInternalFqn(Object object); + Fqn getInternalFqn(Object object); = /** * Return a list of the references from attached objects to this object.= For each reference it @@ -147,7 +147,7 @@ * @param id the location in the cache to examine * @return true if an attached object exists, false if not */ - boolean exists(Fqn id); + boolean exists(Fqn id); = /** * Retrieve POJO from the cache system. Return null if object does not = exist in the cache. @@ -168,7 +168,7 @@ * @return Current content value. Null if does not exist. * @throws PojoCacheException Throws if there is an error related to th= e cache operation. */ - Object find(Fqn id) throws PojoCacheException; + Object find(Fqn id) throws PojoCacheException; = /** * Query all managed POJO objects under the id recursively. Note that t= his will not return @@ -181,7 +181,7 @@ * @return Map of all POJOs found with (id, POJO) pair. Return size of = 0, if not found. * @throws PojoCacheException Throws if there is an error related to th= e cache operation. */ - Map, Object> findAll(String id) throws PojoCacheException; + Map findAll(String id) throws PojoCacheException; = /** * Query all managed POJO objects under the id recursively. Note that t= his will not return @@ -195,7 +195,7 @@ * @return Map of all POJOs found with (id, POJO) pair. Return size of = 0, if not found. * @throws PojoCacheException Throws if there is an error related to th= e cache operation. */ - Map, Object> findAll(Fqn id) throws PojoCacheException; + Map findAll(Fqn id) throws PojoCacheException; = /** * Lifecycle method to start PojoCache. Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/Reference.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/Reference.java 2008-08-13= 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/Reference.java 2008-08-14= 02:46:03 UTC (rev 6557) @@ -37,7 +37,7 @@ * * @return Fqn of the referring node. */ - public Fqn getFqn(); + public Fqn getFqn(); = /** * Returns the name of the node key which references the attached objec= t, or null Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedAr= ray.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedArray.ja= va 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedArray.ja= va 2008-08-14 02:46:03 UTC (rev 6557) @@ -37,18 +37,18 @@ { private static final String LENGTH =3D "ARRAY.LENGTH"; protected PojoCacheImpl cache; - protected Fqn fqn; + protected Fqn fqn; private int length =3D -1; private Class type; = - public static CachedArray load(Fqn fqn, PojoCacheImpl cache, Class type) + public static CachedArray load(Fqn fqn, PojoCacheImpl cache, Class t= ype) { boolean primitive =3D CachedType.isImmediate(type.getComponentType()= ); CachedArray array =3D primitive ? new CachedPrimitiveArray(fqn, type= , cache) : new CachedObjectArray(fqn, type, cache); return array; } = - public static CachedArray create(Fqn fqn, PojoCacheImpl cache, Objec= t originalArray) + public static CachedArray create(Fqn fqn, PojoCacheImpl cache, Object o= riginalArray) { Class type =3D originalArray.getClass(); assert type.isArray(); @@ -67,14 +67,14 @@ return array; } = - protected CachedArray(Fqn fqn, Class type, PojoCacheImpl cache) + protected CachedArray(Fqn fqn, Class type, PojoCacheImpl cache) { this.fqn =3D fqn; this.type =3D type; this.cache =3D cache; } = - public Fqn getFqn() + public Fqn getFqn() { return fqn; } Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedMa= pImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedMapImpl.= java 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedMapImpl.= java 2008-08-14 02:46:03 UTC (rev 6557) @@ -54,7 +54,7 @@ throw new PojoCacheException("Non-serializable for " + relative.g= etClass().getName()); } = - return new Fqn(baseFqn, relative); + return Fqn.fromRelativeElements(baseFqn, relative); } = private Fqn getFqn() Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedOb= jectArray.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedObjectAr= ray.java 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedObjectAr= ray.java 2008-08-14 02:46:03 UTC (rev 6557) @@ -40,14 +40,14 @@ // so that multi-dimensional arrays can be handled properly private static ArrayInterceptable arraySource =3D new ArrayInterceptabl= e() {}; = - protected CachedObjectArray(Fqn fqn, Class type, PojoCacheImpl ca= che) + protected CachedObjectArray(Fqn fqn, Class type, PojoCacheImpl cache) { super(fqn, type, cache); } = public void set(int index, Object element) { - Fqn fqn =3D AopUtil.constructFqn(this.fqn, IntegerCache.toString(= index)); + Fqn fqn =3D AopUtil.constructFqn(this.fqn, IntegerCache.toString(ind= ex)); = cache.attach(fqn, Null.toNullObject(element), null, arraySource); cache.getCache().put(fqn, InternalConstant.POJOCACHE_OPERATION, "SET= "); @@ -55,7 +55,7 @@ = public Object get(int index) { - Fqn fqn =3D AopUtil.constructFqn(this.fqn, IntegerCache.toString(= index)); + Fqn fqn =3D AopUtil.constructFqn(this.fqn, IntegerCache.toString(ind= ex)); = return Null.toNullValue(cache.find(fqn, null, arraySource)); } Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedPr= imitiveArray.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedPrimitiv= eArray.java 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedPrimitiv= eArray.java 2008-08-14 02:46:03 UTC (rev 6557) @@ -34,7 +34,7 @@ { private static final String ELEMENT =3D "ARRAY.PELEMENT."; = - protected CachedPrimitiveArray(Fqn fqn, Class type, PojoCacheImpl= cache) + protected CachedPrimitiveArray(Fqn fqn, Class type, PojoCacheImpl ca= che) { super(fqn, type, cache); } Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AbstractHandle= r.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AbstractHandler.java= 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AbstractHandler.java= 2008-08-14 02:46:03 UTC (rev 6557) @@ -34,11 +34,11 @@ = protected abstract boolean handles(Class clazz); = - protected abstract Object remove(Fqn fqn, Reference reference, Objec= t result); + protected abstract Object remove(Fqn fqn, Reference reference, Object r= esult); = - protected abstract void put(Fqn fqn, Reference reference, Object obj= ); + protected abstract void put(Fqn fqn, Reference reference, Object obj); = - protected abstract Object get(Fqn fqn, Class clazz, PojoInstance = pojoInstance); + protected abstract Object get(Fqn fqn, Class clazz, PojoInstance poj= oInstance); = - protected abstract Fqn getFqn(Object obj); + protected abstract Fqn getFqn(Object obj); } Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojoHan= dler.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojoHandler.j= ava 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojoHandler.j= ava 2008-08-14 02:46:03 UTC (rev 6557) @@ -64,7 +64,7 @@ } = @Override - protected Fqn getFqn(Object obj) + protected Fqn getFqn(Object obj) { if (obj instanceof Advised) { @@ -82,7 +82,7 @@ } = @Override - protected Object get(Fqn fqn, Class clazz, PojoInstance pojoInsta= nce) throws CacheException + protected Object get(Fqn fqn, Class clazz, PojoInstance pojoInstance= ) throws CacheException { CachedType type =3D pCache_.getCachedType(clazz); Object obj =3D Instantiator.newInstance(clazz); @@ -117,7 +117,7 @@ } = @Override - protected void put(Fqn fqn, Reference reference, Object obj) throws = CacheException + protected void put(Fqn fqn, Reference reference, Object obj) throws Cac= heException { CachedType type =3D pCache_.getCachedType(obj.getClass()); // We have a clean slate then. @@ -202,7 +202,7 @@ } = @Override - protected Object remove(Fqn fqn, Reference referencingFqn, Object re= sult) throws CacheException + protected Object remove(Fqn fqn, Reference referencingFqn, Object resul= t) throws CacheException { CachedType type =3D pCache_.getCachedType(result.getClass()); InstanceAdvisor advisor =3D ((Advised) result)._getInstanceAdvisor(); Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ArrayHandler.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ArrayHandler.java 20= 08-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ArrayHandler.java 20= 08-08-14 02:46:03 UTC (rev 6557) @@ -41,14 +41,14 @@ this.cache =3D cache; } = - protected Fqn getFqn(Object array) + protected Fqn getFqn(Object array) { CachedArray cached =3D CachedArrayRegistry.lookup(array); return cached !=3D null ? cached.getFqn() : null; } = @Override - protected void put(Fqn fqn, Reference reference, Object obj) + protected void put(Fqn fqn, Reference reference, Object obj) { // Always initialize the ref count so that we can mark this as an Ao= pNode. PojoInstance pojoInstance =3D InternalHelper.initializeAopInstance(r= eference); @@ -61,7 +61,7 @@ } = @Override - protected Object get(Fqn fqn, Class clazz, PojoInstance pojo) + protected Object get(Fqn fqn, Class clazz, PojoInstance pojo) { CachedArray cached =3D CachedArray.load(fqn, cache, clazz); Object array =3D cached.toArray(); @@ -71,7 +71,7 @@ } = @Override - protected Object remove(Fqn fqn, Reference referencingFqn, Object ob= j) + protected Object remove(Fqn fqn, Reference referencingFqn, Object obj) { CachedArray cached =3D CachedArrayRegistry.lookup(obj); if (cached !=3D null) { Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/CollectionClas= sHandler.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/CollectionClassHandl= er.java 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/CollectionClassHandl= er.java 2008-08-14 02:46:03 UTC (rev 6557) @@ -42,7 +42,7 @@ internal_ =3D internal; } = - protected Fqn getFqn(Object collection) + protected Fqn getFqn(Object collection) { if (! (collection instanceof ClassProxy)) return null; @@ -266,7 +266,7 @@ } = @Override - protected Object remove(Fqn fqn, Reference referencingFqn, Object ob= j) throws CacheException + protected Object remove(Fqn fqn, Reference referencingFqn, Object obj) = throws CacheException { if (!(obj instanceof ClassProxy)) { Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalConsta= nt.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalConstant.jav= a 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalConstant.jav= a 2008-08-14 02:46:03 UTC (rev 6557) @@ -21,9 +21,9 @@ public static final String SERIALIZED =3D "__SERIALIZED__"; public static final String JBOSS_INTERNAL_STRING =3D "__JBossInternal__= "; public static final String JBOSS_INTERNAL_ID_SEP_STRING =3D "_ID_"; - public static final Fqn JBOSS_INTERNAL =3D new Fqn(JBOS= S_INTERNAL_STRING); - public static final Fqn JBOSS_INTERNAL_ID_SEP =3D new Fqn(JBOSS_INTERNAL_ID_SEP_STRING); - public static final Fqn JBOSS_INTERNAL_MAP =3D new Fqn(= InternalConstant.JBOSS_INTERNAL, "__RefMap__"); + public static final Fqn JBOSS_INTERNAL =3D Fqn.fromString(JBOSS_INTERNA= L_STRING); + public static final Fqn JBOSS_INTERNAL_ID_SEP =3D Fqn.fromString(JBOSS_= INTERNAL_ID_SEP_STRING); + public static final Fqn JBOSS_INTERNAL_MAP =3D Fqn.fromRelativeElements= (InternalConstant.JBOSS_INTERNAL, "__RefMap__"); public static final String JBOSS_INTERNAL_STATIC =3D "__jboss:static__"; public static final String POJOCACHE_KEY_PREFIX =3D "POJOCache."; public static final String POJOCACHE_STATUS =3D POJOCACHE_KEY_PREFIX + = "Status"; Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalHelper= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalHelper.java = 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/InternalHelper.java = 2008-08-14 02:46:03 UTC (rev 6557) @@ -279,7 +279,7 @@ throw new IllegalStateException("InternalDelegate.getInternalFqn(= ). fqn is either null or empty!"); = String indirectFqn =3D getIndirectFqn(fqn); - return new Fqn(InternalConstant.JBOSS_INTERNAL_MAP, indirectFqn); + return Fqn.fromRelativeElements(InternalConstant.JBOSS_INTERNAL_MAP,= indirectFqn); // return JBOSS_INTERNAL_MAP; } = Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ObjectGraphHan= dler.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ObjectGraphHandler.j= ava 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ObjectGraphHandler.j= ava 2008-08-14 02:46:03 UTC (rev 6557) @@ -33,7 +33,7 @@ internal_ =3D internal; } = - protected Fqn getFqn(Object obj) + protected Fqn getFqn(Object obj) { return null; } @@ -44,7 +44,7 @@ } = @Override - protected Object get(Fqn fqn, Class clazz, PojoInstance pojoInsta= nce) throws CacheException + protected Object get(Fqn fqn, Class clazz, PojoInstance pojoInstance= ) throws CacheException { // Note this is actually the aliasFqn, not the real fqn! Object obj; @@ -58,12 +58,12 @@ } = @Override - protected void put(Fqn fqn, Reference reference, Object obj) throws = CacheException + protected void put(Fqn fqn, Reference reference, Object obj) throws Cac= heException { setupRefCounting(fqn, reference); } = - boolean isMultipleReferenced(Fqn internalFqn) + boolean isMultipleReferenced(Fqn internalFqn) { // Note this is actually the aliasFqn, not the real fqn! PojoInstance pojoInstance =3D null; @@ -81,7 +81,7 @@ } = @Override - protected Object remove(Fqn fqn, Reference reference, Object pojo) + protected Object remove(Fqn fqn, Reference reference, Object pojo) throws CacheException { if (log.isDebugEnabled()) @@ -97,7 +97,7 @@ /** * Remove the object from the the reference fqn, meaning just decrement= the ref counter. */ - private void removeFromReference(Fqn originalFqn, Reference referenc= e) throws CacheException + private void removeFromReference(Fqn originalFqn, Reference reference) = throws CacheException { if (decrementRefCount(originalFqn, reference) =3D=3D PojoInstance.IN= ITIAL_COUNTER_VALUE) { @@ -114,18 +114,18 @@ * @param fqn The original fqn node * @param refFqn The new internal fqn node */ - private void setupRefCounting(Fqn fqn, Reference reference) throws C= acheException + private void setupRefCounting(Fqn fqn, Reference reference) throws Cach= eException { // increment the reference counting incrementRefCount(fqn, reference); } = - private int incrementRefCount(Fqn originalFqn, Reference reference) = throws CacheException + private int incrementRefCount(Fqn originalFqn, Reference reference) thr= ows CacheException { return internal_.incrementRefCount(originalFqn, reference); } = - private int decrementRefCount(Fqn originalFqn, Reference reference) = throws CacheException + private int decrementRefCount(Fqn originalFqn, Reference reference) thr= ows CacheException { return internal_.decrementRefCount(originalFqn, reference); } Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDeleg= ate.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDelegate.ja= va 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDelegate.ja= va 2008-08-14 02:46:03 UTC (rev 6557) @@ -120,7 +120,7 @@ return oldValue;// we are done = AbstractHandler handler =3D getHandler(obj.getClass(), allowArray); - Fqn internalFqn =3D handler.getFqn(obj); + Fqn internalFqn =3D handler.getFqn(obj); = Reference reference =3D new ReferenceImpl(fqn, field); if (internalFqn !=3D null) @@ -232,7 +232,7 @@ return null; } = - Fqn internalFqn =3D pojoReference.getFqn(); + Fqn internalFqn =3D pojoReference.getFqn(); = = = @@ -285,9 +285,9 @@ return map; } = - private Object getObjectInternal(Fqn fqn, String field, Object sourc= e) throws CacheException + private Object getObjectInternal(Fqn fqn, String field, Object source) = throws CacheException { - Fqn internalFqn =3D fqn; + Fqn internalFqn =3D fqn; PojoReference pojoReference =3D internal_.getPojoReference(fqn, fiel= d); if (pojoReference !=3D null) { @@ -347,21 +347,21 @@ } } = - public boolean exists(Fqn id) + public boolean exists(Fqn id) { return internal_.getPojoReference(id, null) !=3D null || internal_.g= etPojoInstance(id) !=3D null; } = - public Fqn getInternalFqn(Object object) + public Fqn getInternalFqn(Object object) { AbstractHandler handler =3D getHandler(object.getClass(), true); - Fqn internalFqn =3D handler.getFqn(object); + Fqn internalFqn =3D handler.getFqn(object); return internalFqn; } = public Collection getReferences(Object object) { - Fqn fqn =3D getInternalFqn(object); + Fqn fqn =3D getInternalFqn(object); if (fqn =3D=3D null) return Collections.emptyList(); = Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheImpl.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheImpl.java 2= 008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheImpl.java 2= 008-08-14 02:46:03 UTC (rev 6557) @@ -8,7 +8,6 @@ package org.jboss.cache.pojo.impl; = import java.util.Collection; -import java.util.List; import java.util.Map; import java.util.WeakHashMap; import java.util.regex.Pattern; @@ -26,7 +25,9 @@ import org.jboss.cache.Fqn; import org.jboss.cache.Version; import org.jboss.cache.config.Configuration; -import org.jboss.cache.factories.XmlConfigurationParser; +import org.jboss.cache.config.OldFileFormatException; +import org.jboss.cache.config.parsing.XmlConfigurationParser; +import org.jboss.cache.config.parsing.XmlConfigurationParser2x; import org.jboss.cache.pojo.PojoCache; import org.jboss.cache.pojo.PojoCacheException; import org.jboss.cache.pojo.PojoCacheThreadContext; @@ -64,6 +65,12 @@ = init(expected, toStart); } + catch (OldFileFormatException e) + { + log_.warn("Detected legacy configuration file format when parsing= [" + configStr + "]. Migrating to the new (3.x) file format is recommende= d. See FAQs for details."); + XmlConfigurationParser2x oldParser =3D new XmlConfigurationParser= 2x(); + init(oldParser.parseFile(configStr), toStart); + } catch (Exception e) { throw new PojoCacheException("Failed to start " + configStr, e); @@ -79,7 +86,7 @@ { try { - cache =3D (CacheSPI) DefaultCacheFactory.getInsta= nce().createCache(config, toStart); + cache =3D (CacheSPI) (new DefaultCacheFactory()).= createCache(config, toStart); } catch (Exception e) { @@ -99,12 +106,12 @@ return attach(Fqn.fromString(id), pojo); } = - public Object attach(Fqn id, Object pojo) throws PojoCacheException + public Object attach(Fqn id, Object pojo) throws PojoCacheException { return attach(id, pojo, null, null); } = - public Object attach(Fqn id, Object pojo, String field, Object sourc= e) throws PojoCacheException + public Object attach(Fqn id, Object pojo, String field, Object source) = throws PojoCacheException { TransactionManager tm =3D getTransactionManager(); boolean createdTransaction =3D setupTransaction(tm); @@ -125,7 +132,7 @@ } } = - public Object detach(Fqn id, String field, Object source) throws Poj= oCacheException + public Object detach(Fqn id, String field, Object source) throws PojoCa= cheException { TransactionManager tm =3D getTransactionManager(); boolean createdTransaction =3D setupTransaction(tm); @@ -146,7 +153,7 @@ } } = - private void endTransaction(TransactionManager tm, Fqn id) + private void endTransaction(TransactionManager tm, Fqn id) { try { @@ -222,12 +229,12 @@ = = = - public Object detach(Fqn id) throws PojoCacheException + public Object detach(Fqn id) throws PojoCacheException { return detach(id, null, null); } = - public Fqn getInternalFqn(Object object) + public Fqn getInternalFqn(Object object) { return delegate_.getInternalFqn(object); } @@ -237,7 +244,7 @@ return delegate_.getReferences(object); } = - public boolean exists(Fqn id) + public boolean exists(Fqn id) { return delegate_.exists(id); } @@ -247,7 +254,7 @@ return find(Fqn.fromString(id)); } = - public Object find(Fqn id) throws PojoCacheException + public Object find(Fqn id) throws PojoCacheException { try { @@ -259,18 +266,18 @@ } } = - public Object find(Fqn id, String field, Object source) throws Cache= Exception + public Object find(Fqn id, String field, Object source) throws CacheExc= eption { return delegate_.getObject(id, field, source); } = = - public Map, Object> findAll(String id) throws PojoCacheException + public Map findAll(String id) throws PojoCacheException { return findAll(Fqn.fromString(id)); } = - public Map, Object> findAll(Fqn id) throws PojoCacheException + public Map findAll(Fqn id) throws PojoCacheException { // Should produce "/" if (id =3D=3D null) id =3D Fqn.ROOT; Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ReferenceImpl.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ReferenceImpl.java 2= 008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/ReferenceImpl.java 2= 008-08-14 02:46:03 UTC (rev 6557) @@ -40,10 +40,10 @@ { private static final long serialVersionUID =3D 2647262858847953704L; = - private Fqn fqn; + private Fqn fqn; private String key; = - public ReferenceImpl(Fqn fqn) + public ReferenceImpl(Fqn fqn) { this(fqn, null); } @@ -52,7 +52,7 @@ * @param fqn Fqn of the referring node. Cannot be n= ull. * @param key Name of the field, index in the field or key in the colle= ction that is containing the reference. */ - public ReferenceImpl(Fqn fqn, String key) + public ReferenceImpl(Fqn fqn, String key) { if (fqn =3D=3D null) throw new IllegalArgumentException("Fqn can not be null!!"); @@ -66,7 +66,7 @@ return key; } = - public Fqn getFqn() + public Fqn getFqn() { return fqn; } Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/SerializableOb= jectHandler.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/SerializableObjectHa= ndler.java 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/SerializableObjectHa= ndler.java 2008-08-14 02:46:03 UTC (rev 6557) @@ -38,7 +38,7 @@ internal_ =3D internal; } = - protected Fqn getFqn(Object obj) + protected Fqn getFqn(Object obj) { // Not supported return null; @@ -59,7 +59,7 @@ = = @Override - protected void put(Fqn fqn, Reference reference, Object obj) throws = CacheException + protected void put(Fqn fqn, Reference reference, Object obj) throws Cac= heException { // Note that JBoss Serialization can serialize any type now. if (log_.isDebugEnabled()) @@ -87,7 +87,7 @@ } = @Override - protected Object remove(Fqn fqn, Reference reference, Object result)= throws CacheException + protected Object remove(Fqn fqn, Reference reference, Object result) th= rows CacheException { cache.removeNode(fqn); return result; Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/interceptors/Abstra= ctInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/interceptors/AbstractInte= rceptor.java 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/interceptors/AbstractInte= rceptor.java 2008-08-14 02:46:03 UTC (rev 6557) @@ -12,7 +12,7 @@ import org.jboss.aop.advice.Interceptor; import org.jboss.aop.joinpoint.MethodInvocation; import org.jboss.cache.CacheSPI; -import org.jboss.cache.InvocationContext; +import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.pojo.impl.PojoCacheImpl; = /** Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/jmx/PojoCacheJmxWra= pper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/jmx/PojoCacheJmxWrapper.j= ava 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/jmx/PojoCacheJmxWrapper.j= ava 2008-08-14 02:46:03 UTC (rev 6557) @@ -21,6 +21,22 @@ */ package org.jboss.cache.pojo.jmx; = +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +import javax.management.AttributeChangeNotification; +import javax.management.JMException; +import javax.management.ListenerNotFoundException; +import javax.management.MBeanNotificationInfo; +import javax.management.MBeanRegistration; +import javax.management.MBeanServer; +import javax.management.NotificationEmitter; +import javax.management.NotificationFilter; +import javax.management.NotificationListener; +import javax.management.ObjectName; +import javax.transaction.TransactionManager; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.CacheException; @@ -31,7 +47,10 @@ import org.jboss.cache.config.ConfigurationException; import org.jboss.cache.config.EvictionConfig; import org.jboss.cache.config.RuntimeConfig; -import org.jboss.cache.factories.XmlConfigurationParser; +import org.jboss.cache.config.parsing.JGroupsStackParser; +import org.jboss.cache.config.parsing.element.BuddyElementParser; +import org.jboss.cache.config.parsing.element.EvictionElementParser; +import org.jboss.cache.config.parsing.element.LoadersElementParser; import org.jboss.cache.jmx.CacheJmxWrapper; import org.jboss.cache.jmx.CacheNotificationListener; import org.jboss.cache.pojo.PojoCache; @@ -44,21 +63,9 @@ import org.jgroups.jmx.JChannelFactoryMBean; import org.w3c.dom.Element; = -import javax.management.AttributeChangeNotification; -import javax.management.JMException; -import javax.management.ListenerNotFoundException; -import javax.management.MBeanNotificationInfo; -import javax.management.MBeanRegistration; -import javax.management.MBeanServer; -import javax.management.NotificationEmitter; -import javax.management.NotificationFilter; -import javax.management.NotificationListener; -import javax.management.ObjectName; -import javax.transaction.TransactionManager; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; = + + public class PojoCacheJmxWrapper implements PojoCacheJmxWrapperMBean, MBeanRegistration, Notificati= onEmitter { @@ -85,6 +92,11 @@ private Element clusterConfig; private JChannelFactoryMBean multiplexerService; = + private BuddyElementParser buddyElementParser =3D new BuddyElementParse= r(); + private LoadersElementParser loadersElementParser =3D new LoadersElemen= tParser(); + private EvictionElementParser evictionElementParser =3D new EvictionEle= mentParser(); + private JGroupsStackParser stackParser =3D new JGroupsStackParser(); + /** * Default constructor. */ @@ -477,7 +489,7 @@ BuddyReplicationConfig brc =3D null; if (config !=3D null) { - brc =3D XmlConfigurationParser.parseBuddyReplicationConfig(config= ); + brc =3D buddyElementParser.parseBuddyElement(config); } getConfiguration().setBuddyReplicationConfig(brc); this.buddyReplConfig =3D config; @@ -488,7 +500,7 @@ CacheLoaderConfig clc =3D null; if (cache_loader_config !=3D null) { - clc =3D XmlConfigurationParser.parseCacheLoaderConfig(cache_loade= r_config); + clc =3D loadersElementParser.parseLoadersElement(cache_loader_con= fig); } getConfiguration().setCacheLoaderConfig(clc); this.cacheLoaderConfig =3D cache_loader_config; @@ -511,7 +523,7 @@ String props =3D null; if (config !=3D null) { - props =3D XmlConfigurationParser.parseClusterConfigXml(config); + props =3D stackParser.parseClusterConfigXml(config); } getConfiguration().setClusterConfig(props); this.clusterConfig =3D config; @@ -538,7 +550,7 @@ EvictionConfig ec =3D null; if (config !=3D null) { - ec =3D XmlConfigurationParser.parseEvictionConfig(config); + ec =3D evictionElementParser.parseEvictionElement(config); } getConfiguration().setEvictionConfig(ec); this.evictionConfig =3D config; @@ -719,7 +731,7 @@ registered =3D false; } = - // ---------------------------------------------------- NotificationEm= itter = + // ---------------------------------------------------- NotificationEm= itter = public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, @@ -849,7 +861,7 @@ CacheJmxWrapper plainCache =3D new CacheJmxWrapper(); plainCache.setRegisterInterceptors(getRegisterInterceptors()); plainCache.setCache(pojoCache.getCache()); - // It shouldn't send out lifecycle state change notifications for it= self; = + // It shouldn't send out lifecycle state change notifications for it= self; // we do it plainCache.setDisableStateChangeNotifications(true); = @@ -939,7 +951,7 @@ if (plainCacheWrapper !=3D null) { long now =3D System.currentTimeMillis(); - = + AttributeChangeNotification stateChangeNotification =3D new Attri= buteChangeNotification( this, plainCacheWrapper.getNextNotificationSequenceNumber(), no= w, msg, @@ -947,7 +959,7 @@ new Integer(oldState), new Integer(newState) ); stateChangeNotification.setUserData(t); - = + plainCacheWrapper.sendNotification(stateChangeNotification); } } Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/util/AopUtil.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/util/AopUtil.java 2008-08= -13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/util/AopUtil.java 2008-08= -14 02:46:03 UTC (rev 6557) @@ -134,7 +134,7 @@ // TODO Don't know why. But this will fail the CachedSetAopTest clea= r() method since look up is always // Null at the last index. But why? // TODO also see JBCACHE-282 - return new Fqn(baseFqn, relative.toString()); + return Fqn.fromRelativeElements(baseFqn, relative.toString()); = // String tmp =3D baseFqn.toString() +"/" + relative.toString(); // return Fqn.fromString(tmp); @@ -154,7 +154,7 @@ Fqn trueId =3D null; if (fqn.hasElement(InternalConstant.JBOSS_INTERNAL_ID_SEP_STRING)) { - List list =3D new ArrayList(); + List list =3D new ArrayList(); for (int i =3D 0; i < fqn.size(); i++) { if (fqn.get(i).equals(InternalConstant.JBOSS_INTERNAL_STRING)) @@ -168,7 +168,7 @@ } list.add(fqn.get(i)); } - trueId =3D new Fqn(list); + trueId =3D Fqn.fromList(list); } else { @@ -183,9 +183,9 @@ if (region =3D=3D null || region.getFqn().equals(Fqn.ROOT)) { // Move id under JBInternal to promote concurrency - Fqn f0 =3D new Fqn(InternalConstant.JBOSS_INTERNAL, trueId); - Fqn f =3D new Fqn(f0, InternalConstant.JBOSS_INTERNAL_ID_SEP); - return new Fqn(f, Fqn.fromString(guid.toString())); + Fqn f0 =3D Fqn.fromRelativeFqn(InternalConstant.JBOSS_INTERNAL, t= rueId); + Fqn f =3D Fqn.fromRelativeFqn(f0, InternalConstant.JBOSS_INTERNAL= _ID_SEP); + return Fqn.fromRelativeElements(f, guid.toString()); } else { @@ -193,10 +193,10 @@ Fqn rf =3D region.getFqn(); // Extract rest of fqn id Fqn childf =3D trueId.getSubFqn(rf.size(), trueId.size()); - Fqn f0 =3D new Fqn(InternalConstant.JBOSS_INTERNAL, childf); - Fqn f =3D new Fqn(f0, InternalConstant.JBOSS_INTERNAL_ID_SEP); - Fqn f1 =3D new Fqn(rf, f); - return new Fqn(f1, Fqn.fromString(guid.toString())); + Fqn f0 =3D Fqn.fromRelativeFqn(InternalConstant.JBOSS_INTERNAL, c= hildf); + Fqn f =3D Fqn.fromRelativeFqn(f0, InternalConstant.JBOSS_INTERNAL= _ID_SEP); + Fqn f1 =3D Fqn.fromRelativeFqn(rf, f); + return Fqn.fromRelativeElements(f1, guid.toString()); } } = Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/ArrayTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/ArrayTest.java 2008-08-13= 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/ArrayTest.java 2008-08-14= 02:46:03 UTC (rev 6557) @@ -56,7 +56,7 @@ cache1.start(); = cache2 =3D PojoCacheFactory.createCache(UnitTestCacheConfigurationFa= ctory.createConfiguration(CacheMode.REPL_SYNC), false); - //cache2.getCache().addCacheListener(new MyCacheListener(false)); + cache2.getCache().addCacheListener(new MyCacheListener(false)); cache2.start(); = } Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/CircularGraphTest.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/CircularGraphTest.java 20= 08-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/CircularGraphTest.java 20= 08-08-14 02:46:03 UTC (rev 6557) @@ -40,7 +40,7 @@ protected void setUp() throws Exception { log.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/FindReferencesTest.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/FindReferencesTest.java 2= 008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/FindReferencesTest.java 2= 008-08-14 02:46:03 UTC (rev 6557) @@ -28,7 +28,7 @@ protected void setUp() throws Exception { log.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); @@ -82,7 +82,7 @@ log.info("testNoReferences() ...."); Person joe =3D createPerson("/person/joe", "Joe Black", 32, null); = - Fqn joesInternalFqn =3D cache_.getInternalFqn(joe); + Fqn joesInternalFqn =3D cache_.getInternalFqn(joe); assertTrue("Internal Fqn not null", joesInternalFqn !=3D null); = Collection addressReferences =3D cache_.getReferences(joe= ); @@ -97,7 +97,7 @@ Address address =3D createAddress(); Person joe =3D createPerson("/person/joe", "Joe Black", 32, address); = - Fqn joesInternalFqn =3D cache_.getInternalFqn(joe); + Fqn joesInternalFqn =3D cache_.getInternalFqn(joe); Collection addressReferences =3D cache_.getReferences(add= ress); = assertEquals("Size", 1, addressReferences.size()); @@ -112,8 +112,8 @@ Person joe =3D createPerson("/person/joe", "Joe Black", 32, address); Person jane =3D createPerson("/person/jane", "Jane Black", 32, addre= ss); = - Fqn joesInternalFqn =3D cache_.getInternalFqn(joe); - Fqn janesInternalFqn =3D cache_.getInternalFqn(jane); + Fqn joesInternalFqn =3D cache_.getInternalFqn(joe); + Fqn janesInternalFqn =3D cache_.getInternalFqn(jane); HashSet expectedReferences =3D new HashSet(Arr= ays. asList( new ReferenceImpl(joesInternalFqn, "address"), new ReferenceIm= pl(janesInternalFqn, "address"))); = @@ -129,7 +129,7 @@ DoubleRef doubleRef =3D new DoubleRef(); cache_.attach("/doubleref", doubleRef); = - Fqn sourceFqn =3D cache_.getInternalFqn(doubleRef); + Fqn sourceFqn =3D cache_.getInternalFqn(doubleRef); HashSet expectedReferences =3D new HashSet(Arr= ays. asList( new ReferenceImpl(sourceFqn, "one"), new ReferenceImpl(sourceF= qn, "two"))); = Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalConcurrentTest= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalConcurrentTest.java = 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalConcurrentTest.java = 2008-08-14 02:46:03 UTC (rev 6557) @@ -89,7 +89,7 @@ { cachingMode_ =3D caching_mode; boolean toStart =3D false; - cache_ =3D PojoCacheFactory.createCache("META-INF/local-service.xml"= , toStart); + cache_ =3D PojoCacheFactory.createCache("configs/local-tx.xml", toSt= art); cache_.start(); } = Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java 2008-08-13= 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java 2008-08-14= 02:46:03 UTC (rev 6557) @@ -44,7 +44,7 @@ protected void setUp() throws Exception { log.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); @@ -400,7 +400,7 @@ = public void testExists() throws Exception { - Fqn fqn =3D Fqn.fromString("/person/test1"); + Fqn fqn =3D Fqn.fromString("/person/test1"); createPerson(fqn.toString(), "Joe Black", 32); assertTrue(cache_.exists(fqn)); assertFalse(cache_.exists(Fqn.fromString("/blah"))); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTxTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTxTest.java 2008-08-= 13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTxTest.java 2008-08-= 14 02:46:03 UTC (rev 6557) @@ -51,7 +51,7 @@ protected void setUp() throws Exception { log.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache =3D PojoCacheFactory.createCache(configFile, toStart); cache.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/NewLocalTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/NewLocalTest.java 2008-08= -13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/NewLocalTest.java 2008-08= -14 02:46:03 UTC (rev 6557) @@ -38,7 +38,7 @@ protected void setUp() throws Exception { log_.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/NewReplicatedTest.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/NewReplicatedTest.java 20= 08-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/NewReplicatedTest.java 20= 08-08-14 02:46:03 UTC (rev 6557) @@ -177,7 +177,7 @@ addr.addResidents("Ben"); addr.addResidents("Joe"); // Test serialization first - Fqn fqn =3D Fqn.fromString("/plain"); + Fqn fqn =3D Fqn.fromString("/plain"); cache_.getCache().put(fqn, "test", addr); cache_.getCache().remove(fqn, "test"); = Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/NonAspectizedTest.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/NonAspectizedTest.java 20= 08-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/NonAspectizedTest.java 20= 08-08-14 02:46:03 UTC (rev 6557) @@ -28,7 +28,7 @@ protected void setUp() throws Exception { log_.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/ObjectGraphTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/ObjectGraphTest.java 2008= -08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/ObjectGraphTest.java 2008= -08-14 02:46:03 UTC (rev 6557) @@ -27,7 +27,7 @@ protected void setUp() throws Exception { log.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/RecursiveRefTest.ja= va =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/RecursiveRefTest.java 200= 8-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/RecursiveRefTest.java 200= 8-08-14 02:46:03 UTC (rev 6557) @@ -13,7 +13,7 @@ @Test(groups =3D {"functional"}) public class RecursiveRefTest = { - private static final String CONFIG_FILENAME =3D "META-INF/local-service= .xml"; + private static final String CONFIG_FILENAME =3D "configs/local-tx.xml"; private PojoCache cache; Log log =3D LogFactory.getLog(RecursiveRefTest.class); = Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/TxUndoTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/TxUndoTest.java 2008-08-1= 3 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/TxUndoTest.java 2008-08-1= 4 02:46:03 UTC (rev 6557) @@ -47,7 +47,7 @@ protected void setUp() throws Exception { log_.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedLi= stTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedListTest= .java 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedListTest= .java 2008-08-14 02:46:03 UTC (rev 6557) @@ -42,7 +42,7 @@ public void setUp() throws Exception { log.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedMa= pNullTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedMapNullT= est.java 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedMapNullT= est.java 2008-08-14 02:46:03 UTC (rev 6557) @@ -40,7 +40,7 @@ protected void setUp() throws Exception { log.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedMa= pTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedMapTest.= java 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedMapTest.= java 2008-08-14 02:46:03 UTC (rev 6557) @@ -48,7 +48,7 @@ protected void setUp() throws Exception { log.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedSe= tTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedSetTest.= java 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CachedSetTest.= java 2008-08-14 02:46:03 UTC (rev 6557) @@ -50,7 +50,7 @@ protected void setUp() throws Exception { log.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/Collecti= onTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CollectionTest= .java 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/CollectionTest= .java 2008-08-14 02:46:03 UTC (rev 6557) @@ -34,7 +34,7 @@ protected void setUp() throws Exception { log_.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/ObjectGr= aphTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/ObjectGraphTes= t.java 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/collection/ObjectGraphTes= t.java 2008-08-14 02:46:03 UTC (rev 6557) @@ -39,7 +39,7 @@ protected void setUp() throws Exception { log.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/demo/JBossCacheGUI.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/demo/JBossCacheGUI.java 2= 008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/demo/JBossCacheGUI.java 2= 008-08-14 02:46:03 UTC (rev 6557) @@ -595,9 +595,9 @@ = private Node getNode(Object[] path) { - Fqn fqnToPath; + Fqn fqnToPath; if (path.length =3D=3D 0) fqnToPath =3D Fqn.ROOT; - List elements =3D convertMyNodeArrayToStringArray(path); + List elements =3D convertMyNodeArrayToStringArray(path); fqnToPath =3D Fqn.fromList(elements); if (root.hasChild(fqnToPath)) { @@ -610,9 +610,9 @@ } } = - private List convertMyNodeArrayToStringArray(Object[] path) + private List convertMyNodeArrayToStringArray(Object[] path) { - List list =3D new LinkedList(); + List list =3D new LinkedList(); for (Object o : path) { JBossCacheGUI.DisplayNode n =3D (JBossCacheGUI.DisplayNode) o; @@ -741,7 +741,7 @@ } } = - private void load(Fqn fqn) + private void load(Fqn fqn) { try { @@ -1153,19 +1153,19 @@ * Adds a new node to the view. Intermediary nodes will be created i= f they don't yet exist. * Returns the first node that was created or null if node already e= xisted */ - public JBossCacheGUI.DisplayNode add(Fqn fqn) + public JBossCacheGUI.DisplayNode add(Fqn fqn) { JBossCacheGUI.DisplayNode curr, n, ret =3D null; = if (fqn =3D=3D null) return null; curr =3D this; = - for (String child_name : fqn.peekElements()) + for (Object child_name : fqn.peekElements()) { - n =3D curr.findChild(child_name); + n =3D curr.findChild(child_name.toString()); if (n =3D=3D null) { - n =3D new JBossCacheGUI.DisplayNode(child_name); + n =3D new JBossCacheGUI.DisplayNode(child_name.toString()); if (ret =3D=3D null) ret =3D n; curr.add(n); } @@ -1184,16 +1184,16 @@ } = = - private JBossCacheGUI.DisplayNode findNode(Fqn fqn) + private JBossCacheGUI.DisplayNode findNode(Fqn fqn) { JBossCacheGUI.DisplayNode curr, n; = if (fqn =3D=3D null) return null; curr =3D this; = - for (String child_name : fqn.peekElements()) + for (Object child_name : fqn.peekElements()) { - n =3D curr.findChild(child_name); + n =3D curr.findChild(child_name.toString()); if (n =3D=3D null) { return null; Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/jmx/LegacyConfigura= tionTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/jmx/LegacyConfigurationTe= st.java 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/jmx/LegacyConfigurationTe= st.java 2008-08-14 02:46:03 UTC (rev 6557) @@ -45,6 +45,7 @@ import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfi= g; import org.jboss.cache.config.Configuration.CacheMode; import org.jboss.cache.config.Configuration.NodeLockingScheme; +import org.jboss.cache.config.parsing.XmlConfigHelper; import org.jboss.cache.eviction.FIFOConfiguration; import org.jboss.cache.eviction.FIFOPolicy; import org.jboss.cache.eviction.LRUConfiguration; @@ -56,7 +57,6 @@ import org.jboss.cache.loader.jdbm.JdbmCacheLoader; import org.jboss.cache.lock.IsolationLevel; import org.jboss.cache.transaction.BatchModeTransactionManagerLookup; -import org.jboss.cache.xml.XmlHelper; import org.jgroups.ChannelFactory; import org.jgroups.JChannelFactory; import org.testng.annotations.Test; @@ -239,134 +239,120 @@ = protected static Element getBuddyReplicationConfig() throws Exception { - String xmlString =3D "true\n" + - " 600000\n" + - " org.jboss.cache.bud= dyreplication.TestBuddyLocator\n" + - " numBuddies =3D= 2\n" + - " testpool" + - " false\n" + - " false\n" + - " fals= e" + - ""; - return XmlHelper.stringToElement(xmlString); + String xmlStr =3D + " \n" + + " \n" + + " \n" + + " \n" + + " numBuddies =3D 2\n" + + " \n" + + " \n" + + " "; + return XmlConfigHelper.stringToElement(xmlStr); } = protected static Element getCacheLoaderConfig() throws Exception { - String xml =3D "\n" + - "false\n" + - "/foo\n" + - "true\n" + - "\n" + - "org.jboss.cache.loader.FileCacheLoader\= n" + - "" + - " location=3D/tmp\n" + - "\n" + - "false\n" + - "true\n" + - "true\n" + - "true\n" + - "" + - "true" + - "" + - "\n" + - "\n" + - "org.jboss.cache.loader.jdbm.JdbmCacheLoader\n" + - "" + - " location=3D/home/bstansberry\n" + - "\n" + - "true\n" + - "false\n" + - "false\n" + - "false\n" + - "" + - "false" + - "" + - "\n" + - ""; - return XmlHelper.stringToElement(xml); + String xmlStr =3D + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " location=3D/tmp\n " + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " location=3D/home/bstansberry\n" + + " \n" + + " \n" + + " \n" + + " "; + return XmlConfigHelper.stringToElement(xmlStr); } = protected static Element getEvictionPolicyConfig() throws Exception { - String xml =3D "\n" + - "5\n" + - "20000= \n" + - "org.jboss.cache.evic= tion.LRUPolicy\n" + - "\n" + - " 5000\n" + - " 1000\n" + - "\n" + - "\n" + - " 5000\n" + - "\n" + - "\n" + - " 10000\n"= + - "\n" + - "\n" + - " 10000\n"= + - " 8\n" + - " 10\= n" + - "\n" + - " \n"; - return XmlHelper.stringToElement(xml); + String xmlStr =3D + " \n" + + " \n" + + " 5000\n= " + + " 1000000\n" + + " \n" + + "\n" + + " 5000\n" + + "\n" + + "\n" + + " 10000\n" + + "\n" + + "\n" + + " 10000\n" + + " 8\n= " + + " 10\n" + + "\n" + + " "; + return XmlConfigHelper.stringToElement(xmlStr); } = protected static Element getClusterConfig() throws Exception - { - String xml =3D - "\n" + - " \n" + - " \= n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; - return XmlHelper.stringToElement(xml); + {String xml =3D + "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + ""; +return XmlConfigHelper.stringToElement(xml); } = class MockInvocationHandler implements InvocationHandler Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/memory/ReplicatedTe= st.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/memory/ReplicatedTest.jav= a 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/memory/ReplicatedTest.jav= a 2008-08-14 02:46:03 UTC (rev 6557) @@ -72,13 +72,13 @@ = ClassLoader cla =3D getClassLoader(); WeakReference refa =3D new WeakReference(c= la); - cache_.getCache().getRegion(new Fqn("/aop"), true).registerC= ontextClassLoader(cla); + cache_.getCache().getRegion(Fqn.fromString("/aop"), true).registerCo= ntextClassLoader(cla); ClassLoader clb =3D getClassLoader(); WeakReference refb =3D new WeakReference(c= lb); - cache_.getCache().getRegion(new Fqn("/aop"), true).registerC= ontextClassLoader(clb); + cache_.getCache().getRegion(Fqn.fromString("/aop"), true).registerCo= ntextClassLoader(clb); = - Fqn fqn =3D new Fqn("/aop"); - cache_.getCache().put(new Fqn("/aop"), "add", add); + Fqn fqn =3D Fqn.fromString("/aop"); + cache_.getCache().put(Fqn.fromString("/aop"), "add", add); = TestingUtil.sleepThread(100); try @@ -97,8 +97,8 @@ ClassLoader clc =3D getClassLoader(); cla =3D null; clb =3D null; - cache_.getCache().getRegion(new Fqn("/aop"), true).registerC= ontextClassLoader(clc); - cache1_.getCache().getRegion(new Fqn("/aop"), true).register= ContextClassLoader(clc); + cache_.getCache().getRegion(Fqn.fromString("/aop"), true).registerCo= ntextClassLoader(clc); + cache1_.getCache().getRegion(Fqn.fromString("/aop"), true).registerC= ontextClassLoader(clc); System.gc(); // force gc Thread.sleep(1000); assertNull("Classloader should be gced ", refa.get()); @@ -140,9 +140,9 @@ = ClassLoader cla =3D getClassLoader(); WeakReference refa =3D new WeakReference(c= la); - cache_.getCache().getRegion(new Fqn("/aop"), true).registerC= ontextClassLoader(cla); + cache_.getCache().getRegion(Fqn.fromString("/aop"), true).registerCo= ntextClassLoader(cla); ClassLoader clb =3D getClassLoader(); - cache1_.getCache().getRegion(new Fqn("/aop"), true).register= ContextClassLoader(clb); + cache1_.getCache().getRegion(Fqn.fromString("/aop"), true).registerC= ontextClassLoader(clb); WeakReference refb =3D new WeakReference(c= lb); = cache_.attach("/aop", p); @@ -161,8 +161,8 @@ = cache_.detach("/aop"); ClassLoader clc =3D getClassLoader(); - cache_.getCache().getRegion(new Fqn("/aop"), true).registerC= ontextClassLoader(clc); - cache1_.getCache().getRegion(new Fqn("/aop"), true).register= ContextClassLoader(clc); + cache_.getCache().getRegion(Fqn.fromString("/aop"), true).registerCo= ntextClassLoader(clc); + cache1_.getCache().getRegion(Fqn.fromString("/aop"), true).registerC= ontextClassLoader(clc); cla =3D null; clb =3D null; forceOutOfMemoryError(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ListTe= st.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ListTest.jav= a 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ListTest.jav= a 2008-08-14 02:46:03 UTC (rev 6557) @@ -55,7 +55,7 @@ @BeforeMethod(alwaysRun =3D true) protected void setUp() throws Exception { - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache =3D PojoCacheFactory.createCache(configFile, toStart); cache.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/Listen= erCountTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ListenerCoun= tTest.java 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ListenerCoun= tTest.java 2008-08-14 02:46:03 UTC (rev 6557) @@ -31,7 +31,7 @@ @BeforeMethod(alwaysRun =3D true) protected void setUp() throws Exception { - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache =3D PojoCacheFactory.createCache(configFile, toStart); cache.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/MapTes= t.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/MapTest.java= 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/MapTest.java= 2008-08-14 02:46:03 UTC (rev 6557) @@ -54,7 +54,7 @@ @BeforeMethod(alwaysRun =3D true) protected void setUp() throws Exception { - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache =3D PojoCacheFactory.createCache(configFile, toStart); cache.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/Object= Test.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ObjectTest.j= ava 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/ObjectTest.j= ava 2008-08-14 02:46:03 UTC (rev 6557) @@ -40,7 +40,7 @@ @BeforeMethod(alwaysRun =3D true) protected void setUp() throws Exception { - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache =3D PojoCacheFactory.createCache(configFile, toStart); cache.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/SetTes= t.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/SetTest.java= 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/SetTest.java= 2008-08-14 02:46:03 UTC (rev 6557) @@ -55,7 +55,7 @@ @BeforeMethod(alwaysRun =3D true) protected void setUp() throws Exception { - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache =3D PojoCacheFactory.createCache(configFile, toStart); cache.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/TxObje= ctTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/TxObjectTest= .java 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/notification/TxObjectTest= .java 2008-08-14 02:46:03 UTC (rev 6557) @@ -58,7 +58,7 @@ @BeforeMethod(alwaysRun =3D true) protected void setUp() throws Exception { - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache =3D PojoCacheFactory.createCache(configFile, toStart); cache.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/optimistic/Abstract= OptimisticTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/optimistic/AbstractOptimi= sticTestCase.java 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/optimistic/AbstractOptimi= sticTestCase.java 2008-08-14 02:46:03 UTC (rev 6557) @@ -31,11 +31,14 @@ import javax.transaction.TransactionManager; = import org.jboss.cache.Fqn; -import org.jboss.cache.commands.ReversibleCommand; import org.jboss.cache.commands.VersionedDataCommand; +import org.jboss.cache.commands.legacy.ReversibleCommand; import org.jboss.cache.config.CacheLoaderConfig; import org.jboss.cache.config.Configuration; -import org.jboss.cache.factories.XmlConfigurationParser; +import org.jboss.cache.config.parsing.XmlConfigurationParser; +import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; +import org.jboss.cache.loader.DummyInMemoryCacheLoader; +import org.jboss.cache.loader.DummySharedInMemoryCacheLoader; import org.jboss.cache.lock.IsolationLevel; import org.jboss.cache.marshall.MethodCall; import org.jboss.cache.optimistic.DefaultDataVersion; @@ -44,7 +47,6 @@ import org.jboss.cache.pojo.PojoCacheFactory; import org.jboss.cache.transaction.DummyTransactionManager; import org.jboss.cache.util.TestingUtil; -import org.jboss.cache.xml.XmlHelper; import org.testng.annotations.AfterMethod; import org.w3c.dom.Element; = @@ -56,7 +58,7 @@ private int instanceNumber; = // some test data shared among all the test cases - protected Fqn fqn =3D Fqn.fromString("/blah"); + protected Fqn fqn =3D Fqn.fromString("/blah"); protected String key =3D "myKey", value =3D "myValue"; = protected String getTempDir() @@ -119,30 +121,17 @@ return createCacheWithLoader(false); } = - protected CacheLoaderConfig getCacheLoaderConfig(boolean shared, String= filename, boolean passivation) throws Exception + protected CacheLoaderConfig getCacheLoaderConfig(boolean shared, boolea= n passivation) throws Exception { - String xml =3D " \n" + - " " + passivation + "\n" + - " \n" + - " " + shared + "\n" + - " \n" + - " org.jboss.cache.loader.FileCache= Loader\n" + - " \n" + - " \n" + - " false\n" + - " " + (!shared) + "= \n" + - " false\n" + - " \n" + - " "; - Element element =3D XmlHelper.stringToElement(xml); - return XmlConfigurationParser.parseCacheLoaderConfig(element); + String cacheLoaderClass =3D shared ? DummySharedInMemoryCacheLoader.= class.getName() : DummyInMemoryCacheLoader.class.getName(); + return UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfi= g(passivation, null, cacheLoaderClass, "", false, (!shared), shared, false,= false); } = protected PojoCache createCacheWithLoader(boolean passivationEnabled) t= hrows Exception { PojoCache cache =3D createCacheUnstarted(); Configuration c =3D cache.getCache().getConfiguration(); - c.setCacheLoaderConfig(getCacheLoaderConfig(true, getTempDir(), pass= ivationEnabled)); + c.setCacheLoaderConfig(getCacheLoaderConfig(true, passivationEnabled= )); cache.create(); cache.start(); return cache; @@ -270,7 +259,7 @@ c.setSyncRollbackPhase(true); c.setNodeLockingScheme("OPTIMISTIC"); c.setTransactionManagerLookupClass("org.jboss.cache.transaction.Dumm= yTransactionManagerLookup"); - c.setCacheLoaderConfig(getCacheLoaderConfig(shared, shared ? getTemp= Dir(name + "-shared") : getTempDir(name + instanceNumber++), false)); + c.setCacheLoaderConfig(getCacheLoaderConfig(shared, false)); = PojoCache cache =3D PojoCacheFactory.createCache(c, false); cache.create(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/optimistic/LocalTxT= est.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/optimistic/LocalTxTest.ja= va 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/optimistic/LocalTxTest.ja= va 2008-08-14 02:46:03 UTC (rev 6557) @@ -142,7 +142,7 @@ { log.info("testFailure1() ...."); UserTransaction tx =3D getTransaction(); - Fqn f =3D Fqn.fromString("/person/test2"); + Fqn f =3D Fqn.fromString("/person/test2"); tx.begin(); cache.getCache().put(f, "test", "test"); tx.commit(); @@ -155,9 +155,9 @@ = public void testFailure2() throws Exception { - Fqn f0 =3D Fqn.fromString("/person/test"); - Fqn f1 =3D new Fqn(f0, "1"); - Fqn f2 =3D new Fqn(f0, "2"); + Fqn f0 =3D Fqn.fromString("/person/test"); + Fqn f1 =3D Fqn.fromRelativeElements(f0, "1"); + Fqn f2 =3D Fqn.fromRelativeElements(f0, "2"); = cache.getCache().put(f1, "test", "test"); cache.getCache().put(f2, "test", "test"); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/passivation/LocalTe= st.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/passivation/LocalTest.jav= a 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/passivation/LocalTest.jav= a 2008-08-14 02:46:03 UTC (rev 6557) @@ -47,7 +47,7 @@ protected void setUp() throws Exception { log.info("setUp() ...."); - String configFile =3D "META-INF/pojocache-passivation-service.xml"; + String configFile =3D "configs/local-passivation.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.getCache().getConfiguration().setTransactionManagerLookupClas= s("org.jboss.cache.transaction.BatchModeTransactionManagerLookup"); @@ -101,7 +101,7 @@ cache_.attach(id, joe); Thread.sleep(9100);// default is 3 seconds so joe should have been p= assivated. = - assertNull("Node should be evicted ", ((CacheSPI) ca= che_.getCache()).peek(new Fqn(id), false)); + assertNull("Node should be evicted ", ((CacheSPI) ca= che_.getCache()).peek(Fqn.fromString(id), false)); = assertEquals("age ", 20, joe.getAge()); joe.setAge(30); @@ -118,7 +118,7 @@ cache_.attach(id, joe); Thread.sleep(9100);// default is 3 seconds so joe should have been p= assivated. = - assertNull("Node should be evicted ", ((CacheSPI) ca= che_.getCache()).peek(new Fqn(id), false)); + assertNull("Node should be evicted ", ((CacheSPI) ca= che_.getCache()).peek(Fqn.fromString(id), false)); = Address addr =3D new Address(); addr.setCity("Taipei"); @@ -137,7 +137,7 @@ cache_.attach(id, joe); Thread.sleep(9100);// default is 3 seconds so joe should have been p= assivated. = - assertNull("Node should be evicted ", ((CacheSPI) ca= che_.getCache()).peek(new Fqn(id), false)); + assertNull("Node should be evicted ", ((CacheSPI) ca= che_.getCache()).peek(Fqn.fromString(id), false)); = Person p =3D (Person) cache_.find(id); = @@ -182,7 +182,7 @@ = Thread.sleep(9100);// default is 3 seconds so joe should have been p= assivated. = - assertNull("Node should be evicted ", ((CacheSPI) ca= che_.getCache()).peek(new Fqn(id), false)); + assertNull("Node should be evicted ", ((CacheSPI) ca= che_.getCache()).peek(Fqn.fromString(id), false)); = assertEquals("City is ", "Santa Clara", add2.getCity()); = @@ -268,7 +268,7 @@ @NodeActivated public void nodeActivated(NodeEvent ne) { - Fqn fqn =3D ne.getFqn(); + Fqn fqn =3D ne.getFqn(); if (!ne.isPre()) { System.out.println("nodeActivated: " + fqn); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/region/LocalConcurr= entTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/region/LocalConcurrentTes= t.java 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/region/LocalConcurrentTes= t.java 2008-08-14 02:46:03 UTC (rev 6557) @@ -87,7 +87,7 @@ void initCaches() throws Exception { boolean toStart =3D false; - cache_ =3D PojoCacheFactory.createCache("META-INF/local-service.xml"= , toStart); + cache_ =3D PojoCacheFactory.createCache("configs/local-tx.xml", toSt= art); cache_.start(); } = Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/region/LocalTest.ja= va =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/region/LocalTest.java 200= 8-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/region/LocalTest.java 200= 8-08-14 02:46:03 UTC (rev 6557) @@ -52,7 +52,7 @@ protected void setUp() throws Exception { log.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); @@ -102,8 +102,8 @@ assertEquals((Object) "Joe Black", p.getName()); = assertTrue("Region node should exist ", - cache_.getCache().getRoot().hasChild(new Fqn(REGION)= )); - Fqn fqn =3D new Fqn(Fqn.fromString(REGION), Internal= Constant.JBOSS_INTERNAL); + cache_.getCache().getRoot().hasChild(Fqn.fromString(REGION))= ); + Fqn fqn =3D Fqn.fromRelativeFqn(Fqn.fromString(REGION), InternalCons= tant.JBOSS_INTERNAL); assertTrue("Internal region node should exist ", cache_.getCache().getRoot().hasChild(fqn)); //System.out.println("Cache content: " +((org.jboss.cache.CacheImpl<= Object, Object>)cache_.getCache()).printDetails()); @@ -125,7 +125,7 @@ //String str =3D ((CacheImpl) cache_.getCache()).pri= ntDetails(); //System.out.println("**** Details ***/n" + str); = - Fqn fqn =3D new Fqn(Fqn.fromString(REGION), Internal= Constant.JBOSS_INTERNAL); + Fqn fqn =3D Fqn.fromRelativeFqn(Fqn.fromString(REGION), InternalCons= tant.JBOSS_INTERNAL); Node n =3D cache_.getCache().getRoot().getChild(fqn); assertTrue("Internal region node should not exist ", n.getChildren() !=3D null); @@ -200,7 +200,7 @@ = cache_.detach("person/test1"); = - Fqn fqn =3D new Fqn(Fqn.fromString(REGION), Internal= Constant.JBOSS_INTERNAL); + Fqn fqn =3D Fqn.fromRelativeFqn(Fqn.fromString(REGION), InternalCons= tant.JBOSS_INTERNAL); Node n =3D cache_.getCache().getRoot().getChild(fqn); assertTrue("Internal region node should not exist ", n.getChildren() !=3D null); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/region/NewLocalTest= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/region/NewLocalTest.java = 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/region/NewLocalTest.java = 2008-08-14 02:46:03 UTC (rev 6557) @@ -41,7 +41,7 @@ protected void setUp() throws Exception { log_.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/InMemoryTx= UndoTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/InMemoryTxUndoTe= st.java 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/InMemoryTxUndoTe= st.java 2008-08-14 02:46:03 UTC (rev 6557) @@ -47,7 +47,7 @@ protected void setUp() throws Exception { log_.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ListTxUndo= Test.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ListTxUndoTest.j= ava 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ListTxUndoTest.j= ava 2008-08-14 02:46:03 UTC (rev 6557) @@ -43,7 +43,7 @@ protected void setUp() throws Exception { log_.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ListUndoTe= st.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ListUndoTest.jav= a 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/ListUndoTest.jav= a 2008-08-14 02:46:03 UTC (rev 6557) @@ -43,7 +43,7 @@ protected void setUp() throws Exception { log_.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalExcep= tionUndoTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalExceptionUn= doTest.java 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalExceptionUn= doTest.java 2008-08-14 02:46:03 UTC (rev 6557) @@ -64,7 +64,7 @@ public void setUp() throws Exception { log_.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.getCache().getConfiguration().setLockAcquisitionTimeout(500);= // timeout to 500 ms @@ -173,11 +173,11 @@ { try { - Fqn f =3D new Fqn(InternalConstant.JBOSS_INTER= NAL_STRING); - cache_.getCache().put(new Fqn(f, "123"), "key", "test"= ); - cache_.getCache().put(new Fqn("a"), "key", "test"); + Fqn f =3D Fqn.fromString(InternalConstant.JBOSS_INTERNAL_STRIN= G); + cache_.getCache().put(Fqn.fromRelativeElements(f, "123"), "key= ", "test"); + cache_.getCache().put(Fqn.fromString("a"), "key", "test"); tx_mgr.begin(); - cache_.getCache().put(new Fqn(f, "124"), "key", "test"= ); + cache_.getCache().put(Fqn.fromRelativeElements(f, "124"), "key= ", "test"); = while (!isTrue) { Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalTxUnd= oTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalTxUndoTest.= java 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalTxUndoTest.= java 2008-08-14 02:46:03 UTC (rev 6557) @@ -43,7 +43,7 @@ protected void setUp() throws Exception { log_.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalUndoT= est.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalUndoTest.ja= va 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/LocalUndoTest.ja= va 2008-08-14 02:46:03 UTC (rev 6557) @@ -43,7 +43,7 @@ protected void setUp() throws Exception { log_.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/MapTxUndoT= est.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/MapTxUndoTest.ja= va 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/MapTxUndoTest.ja= va 2008-08-14 02:46:03 UTC (rev 6557) @@ -45,7 +45,7 @@ protected void setUp() throws Exception { log_.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/MapUndoTes= t.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/MapUndoTest.java= 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/MapUndoTest.java= 2008-08-14 02:46:03 UTC (rev 6557) @@ -43,7 +43,7 @@ protected void setUp() throws Exception { log_.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/PojoCollec= tionRollbackTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/PojoCollectionRo= llbackTest.java 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/PojoCollectionRo= llbackTest.java 2008-08-14 02:46:03 UTC (rev 6557) @@ -58,7 +58,7 @@ = private void startTest() throws Exception { - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/SetTxUndoT= est.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/SetTxUndoTest.ja= va 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/SetTxUndoTest.ja= va 2008-08-14 02:46:03 UTC (rev 6557) @@ -43,7 +43,7 @@ protected void setUp() throws Exception { log_.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/SetUndoTes= t.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/SetUndoTest.java= 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/rollback/SetUndoTest.java= 2008-08-14 02:46:03 UTC (rev 6557) @@ -43,7 +43,7 @@ protected void setUp() throws Exception { log_.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); Deleted: pojo/trunk/src/test/java/org/jboss/cache/pojo/statetransfer/StateT= ransfer200AopTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/statetransfer/StateTransf= er200AopTest.java 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/statetransfer/StateTransf= er200AopTest.java 2008-08-14 02:46:03 UTC (rev 6557) @@ -1,27 +0,0 @@ -/* - * JBoss, the OpenSource J2EE webOS - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ - -package org.jboss.cache.pojo.statetransfer; - -import org.testng.annotations.Test; - -/** - * Tests that PojoCache state transfer works properly if the version is 2.= 0.0. - * - * @author Brian Stansbe= rry - * @version $Revision$ - */ -(a)Test(groups =3D {"functional"}) -public class StateTransfer200AopTest extends StateTransferAopTestBase -{ - - protected String getReplicationVersion() - { - return "2.0.0.GA"; - } - -} Deleted: pojo/trunk/src/test/java/org/jboss/cache/pojo/statetransfer/StateT= ransferAopTestBase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/statetransfer/StateTransf= erAopTestBase.java 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/statetransfer/StateTransf= erAopTestBase.java 2008-08-14 02:46:03 UTC (rev 6557) @@ -1,1091 +0,0 @@ -/* - * JBoss, the OpenSource J2EE webOS - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ - -package org.jboss.cache.pojo.statetransfer; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.fail; - -import java.io.File; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Random; -import java.util.Set; -import java.util.concurrent.Semaphore; -import java.util.concurrent.TimeUnit; - -import javax.transaction.TransactionManager; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jboss.cache.Cache; -import org.jboss.cache.CacheException; -import org.jboss.cache.CacheSPI; -import org.jboss.cache.Fqn; -import org.jboss.cache.Region; -import org.jboss.cache.config.CacheLoaderConfig; -import org.jboss.cache.config.Configuration; -import org.jboss.cache.config.Configuration.CacheMode; -import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; -import org.jboss.cache.factories.XmlConfigurationParser; -import org.jboss.cache.loader.CacheLoader; -import org.jboss.cache.util.TestingUtil; -import org.jboss.cache.pojo.PojoCache; -import org.jboss.cache.pojo.PojoCacheFactory; -import org.jboss.cache.pojo.test.Address; -import org.jboss.cache.pojo.test.Person; -import org.jboss.cache.xml.XmlHelper; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.w3c.dom.Element; - -/** - * Tests state transfer in PojoCache. - * - * @author Brian Stansbe= rry - * @version $Revision$ - */ -public abstract class StateTransferAopTestBase -{ - private Map caches; - - public static final String A_B_1 =3D "/a/b/1"; - public static final String A_B_2 =3D "/a/b/2"; - public static final String A_C_1 =3D "/a/c/1"; - public static final String A_C_2 =3D "/a/c/2"; - - public static final Fqn A_B_1_f =3D Fqn.fromString("/a/b/1"); - public static final Fqn A_B_2_f =3D Fqn.fromString("/a/b/2"); - public static final Fqn A_C_1_f =3D Fqn.fromString("/a/c/1"); - public static final Fqn A_C_2_f =3D Fqn.fromString("/a/c/2"); - - private static final int SUBTREE_SIZE =3D 10; - - private Person joe; - private Person bob; - private Person jane; - private Person jill; - private Address addr1; - private Address addr2; - - public static final Integer TWENTY =3D 20; - public static final Integer TWENTYFIVE =3D 25; - public static final Integer FORTY =3D 40; - - private Log log =3D LogFactory.getLog(StateTransferAopTestBase.class); - - public void testInitialStateTransfer() throws Exception - { - log.info("Enter testInitialStateTransfer"); - - PojoCache cache1 =3D createCache("cache1", true, false, false); - - cache1.attach(A_B_1, joe); - cache1.attach(A_B_2, jane); - cache1.attach(A_C_1, bob); - cache1.attach(A_C_2, jill); - - PojoCache cache2 =3D createCache("cache2", true, false, false); - - // Pause to give caches time to see each other -// TestingUtil.blockUntilViewsReceived(new Cache[] -// {cache1.getCache(), cache2.getCache()}, 60000); - - Person ab1 =3D (Person) cache2.find(A_B_1); - Person ab2 =3D (Person) cache2.find(A_B_2); - Person ac1 =3D (Person) cache2.find(A_C_1); - Person ac2 =3D (Person) cache2.find(A_C_2); - assertEquals("Name for /a/b/1 is Joe", joe.getName(), ab1.getName()); - assertEquals("City for /a/b/1 is Anytown", addr1.getCity(), ab1.getA= ddress().getCity()); - assertEquals("Name for /a/b/2 is Jane", jane.getName(), ab2.getName(= )); - assertEquals("City for /a/b/2 is Anytown", addr1.getCity(), ab2.getA= ddress().getCity()); - assertTrue("Joe and Jane have same Address", ab1.getAddress() =3D=3D= ab2.getAddress()); - assertEquals("Name for /a/c/1 is Bob", bob.getName(), ac1.getName()); - assertEquals("City for /a/c/1 is Fremont", addr2.getCity(), ac1.getA= ddress().getCity()); - assertEquals("Name for /a/c/2 is Jill", jill.getName(), ac2.getName(= )); - assertEquals("City for /a/c/2 is Fremont", addr2.getCity(), ac2.getA= ddress().getCity()); - assertTrue("Bob and Jill have same Address", ac1.getAddress() =3D=3D= ac2.getAddress()); - } - - public void testInitialStateTferWithLoader() throws Exception - { - log.info("Enter testInitialStateTferWithLoader"); - - PojoCache cache1 =3D createCache("cache1", false, false, true); - - cache1.attach(A_B_1, joe); - cache1.attach(A_B_2, jane); - cache1.attach(A_C_1, bob); - cache1.attach(A_C_2, jill); - - PojoCache cache2 =3D createCache("cache2", false, false, true); - - // Pause to give caches time to see each other - TestingUtil.blockUntilViewsReceived(new Cache[] - {cache1.getCache(), cache2.getCache()}, 60000); - - Person ab1 =3D (Person) cache2.find(A_B_1); - Person ab2 =3D (Person) cache2.find(A_B_2); - Person ac1 =3D (Person) cache2.find(A_C_1); - Person ac2 =3D (Person) cache2.find(A_C_2); - assertEquals("Name for /a/b/1 is Joe", joe.getName(), ab1.getName()); - assertEquals("City for /a/b/1 is Anytown", addr1.getCity(), ab1.getA= ddress().getCity()); - assertEquals("Name for /a/b/2 is Jane", jane.getName(), ab2.getName(= )); - assertEquals("City for /a/b/2 is Anytown", addr1.getCity(), ab2.getA= ddress().getCity()); - assertTrue("Joe and Jane have same Address", ab1.getAddress() =3D=3D= ab2.getAddress()); - assertEquals("Name for /a/c/1 is Bob", bob.getName(), ac1.getName()); - assertEquals("City for /a/c/1 is Fremont", addr2.getCity(), ac1.getA= ddress().getCity()); - assertEquals("Name for /a/c/2 is Jill", jill.getName(), ac2.getName(= )); - assertEquals("City for /a/c/2 is Fremont", addr2.getCity(), ac2.getA= ddress().getCity()); - assertTrue("Bob and Jill have same Address", ac1.getAddress() =3D=3D= ac2.getAddress()); - } - - private void createAndActivateRegion(Cache c, Fqn f) - { - Region r =3D c.getRegion(f, true); - r.registerContextClassLoader(getClass().getClassLoader()); - r.activate(); - } - - public void testPartialStateTransfer() throws Exception - { - log.info("Enter testPartialStateTransfer"); - - PojoCache cache1 =3D createCache("cache1", false, true, false); - - createAndActivateRegion(cache1.getCache(), Fqn.fromString("/a")); - createAndActivateRegion(cache1.getCache(), Fqn.fromString("/__JBossI= nternal__")); - - cache1.attach(A_B_1, joe); - cache1.attach(A_B_2, jane); - - PojoCache cache2 =3D createCache("cache2", false, true, false); - - // Pause to give caches time to see each other - TestingUtil.blockUntilViewsReceived(new Cache[] - {cache1.getCache(), cache2.getCache()}, 60000); - - assertNull("/a/b/1 not transferred per policy", cache2.find(A_B_1)); - assertNull("/a/b/2 not transferred per policy", cache2.find(A_B_2)); - - createAndActivateRegion(cache2.getCache(), Fqn.fromString("/a")); - createAndActivateRegion(cache2.getCache(), Fqn.fromString("/__JBossI= nternal__")); - - Person ab1 =3D (Person) cache2.find(A_B_1); - Person ab2 =3D (Person) cache2.find(A_B_2); - assertEquals("Name for /a/b/1 is Joe", joe.getName(), ab1.getName()); - assertEquals("City for /a/b/1 is Anytown", joe.getAddress().getCity(= ), ab1.getAddress().getCity()); - assertEquals("Name for /a/b/2 is Jane", jane.getName(), ab2.getName(= )); - assertEquals("City for /a/b/2 is Anytown", jane.getAddress().getCity= (), ab2.getAddress().getCity()); - assertTrue("Address for Joe and Jane is the same object", ab1.getAdd= ress() =3D=3D ab2.getAddress()); - - cache1.attach(A_C_1, bob); - cache1.attach(A_C_2, jill); - - assertNotNull("/a/c/1 should be transferred per policy", cache2.find= (A_C_1)); - - cache1.getCache().getRegion(Fqn.fromString("/a"), true).deactivate(); - - cache1.getCache().getRegion(Fqn.fromString("/a"), true).activate(); - - ab1 =3D (Person) cache1.find(A_B_1); - assertEquals("Name for /a/b/1 is Joe", joe.getName(), ab1.getName()); - assertEquals("City for /a/b/1 is Anytown", addr1.getCity(), ab1.getA= ddress().getCity()); - ab2 =3D (Person) cache1.find(A_B_2); - assertEquals("Name for /a/b/1 is Jane", jane.getName(), ab2.getName(= )); - assertEquals("City for /a/b/1 is Anytown", addr1.getCity(), ab2.getA= ddress().getCity()); - assertTrue("Address for Joe and Jane is the same object", ab1.getAdd= ress() =3D=3D ab2.getAddress()); - } - - public void testPartialStateTransferWithLoader() throws Exception - { - log.info("Enter testPartialStateTransferWithLoader"); - - PojoCache cache1 =3D createCache("cache1", false, true, true); - createAndActivateRegion(cache1.getCache(), Fqn.fromString("/a")); - createAndActivateRegion(cache1.getCache(), Fqn.fromString("/__JBossI= nternal__")); - - cache1.attach(A_B_1, joe); - cache1.attach(A_B_2, jane); - - PojoCache cache2 =3D createCache("cache2", false, true, true); - - // Pause to give caches time to see each other - TestingUtil.blockUntilViewsReceived(new Cache[] - {cache1.getCache(), cache2.getCache()}, 60000); - - CacheLoader loader =3D ((CacheSPI) cache2.getCache()= ).getCacheLoaderManager().getCacheLoader(); - - Map map =3D loader.get(A_B_1_f); - if (map !=3D null) - { - assertNull("/a/b/1 name not transferred per policy", map.get("nam= e")); - assertNull("/a/b/1 age not transferred per policy", map.get("age"= )); - } - map =3D loader.get(A_B_2_f); - if (map !=3D null) - { - assertNull("/a/b/1 name not transferred per policy", map.get("nam= e")); - assertNull("/a/b/1 age not transferred per policy", map.get("age"= )); - } - assertNull("/a/b/1 not transferred per policy", cache2.find(A_B_1)); - assertNull("/a/b/2 not transferred per policy", cache2.find(A_B_2)); - - createAndActivateRegion(cache2.getCache(), Fqn.fromString("/a")); - createAndActivateRegion(cache2.getCache(), Fqn.fromString("/__JBossI= nternal__")); - -// assertEquals("Correct name from loader for /a/b/1", joe.getName(),= loader.get(A_B_1_f).get("name")); -// assertEquals("Correct age from loader for /a/b/1", TWENTY, loader.= get(A_B_1_f).get("age")); -// assertEquals("Correct name from loader for /a/b/2", jane.getName()= , loader.get(A_B_2_f).get("name")); -// assertEquals("Correct age from loader for /a/b/2", TWENTYFIVE, loa= der.get(A_B_2_f).get("age")); - - - Person ab1 =3D (Person) cache2.find(A_B_1); - Person ab2 =3D (Person) cache2.find(A_B_2); - assertEquals("Name for /a/b/1 is Joe", joe.getName(), ab1.getName()); - assertEquals("City for /a/b/1 is Anytown", addr1.getCity(), ab1.getA= ddress().getCity()); - assertEquals("Name for /a/b/1 is Jane", jane.getName(), ab2.getName(= )); - assertEquals("City for /a/b/1 is Anytown", addr1.getCity(), ab2.getA= ddress().getCity()); - assertTrue("Address for Joe and Jane is the same object", ab1.getAdd= ress() =3D=3D ab2.getAddress()); - - cache1.attach(A_C_1, bob); - cache1.attach(A_C_2, jill); - Thread.sleep(200); - - assertNotNull("/a/c/1 transferred per policy", cache2.find(A_C_1)); - assertNotNull("/a/c/1 transferred per policy", cache2.find(A_C_2)); - - Person ac1 =3D (Person) cache2.find(A_C_1); - Person ac2 =3D (Person) cache2.find(A_C_2); - assertEquals("Name for /a/c/1 is Bob", bob.getName(), ac1.getName()); - assertEquals("City for /a/c/1 is Fremont", addr2.getCity(), ac1.getA= ddress().getCity()); - assertEquals("Name for /a/c/2 is Jill", jill.getName(), ac2.getName(= )); - assertEquals("City for /a/c/2 is Fremont", addr2.getCity(), ac2.getA= ddress().getCity()); - assertTrue("Bob and Jill have same Address", ac1.getAddress() =3D=3D= ac2.getAddress()); - - cache1.getCache().getRegion(Fqn.fromString("/a"), true).deactivate(); - - ab1 =3D (Person) cache1.find(A_B_1); - assertEquals("Name for /a/b/1 is Joe", joe.getName(), ab1.getName()); - assertEquals("City for /a/b/1 is Anytown", addr1.getCity(), ab1.getA= ddress().getCity()); - ab2 =3D (Person) cache1.find(A_B_2); - assertEquals("Name for /a/b/1 is Jane", jane.getName(), ab2.getName(= )); - assertEquals("City for /a/b/1 is Anytown", addr1.getCity(), ab2.getA= ddress().getCity()); - assertTrue("Address for Joe and Jane is the same object", ab1.getAdd= ress() =3D=3D ab2.getAddress()); - ac1 =3D (Person) cache1.find(A_C_1); - assertEquals("Name for /a/c/1 is Bob", bob.getName(), ac1.getName()); - assertEquals("City for /a/c/1 is Fremont", addr2.getCity(), ac1.getA= ddress().getCity()); - ac2 =3D (Person) cache1.find(A_C_2); - assertEquals("Name for /a/c/2 is Jill", jill.getName(), ac2.getName(= )); - assertEquals("City for /a/c/2 is Fremont", addr2.getCity(), ac2.getA= ddress().getCity()); - assertTrue("Address for Bob and Jill is the same object", ac1.getAdd= ress() =3D=3D ac2.getAddress()); - } - - - /** - * Tests concurrent activation of the same subtree by multiple nodes in= a - * REPL_SYNC environment. The idea is to see what would happen with a - * farmed deployment. See concurrentActivationTest for det= ails. - * - * @throws Exception - */ - public void testConcurrentActivationSync() throws Exception - { - log.info("Enter testConcurrentActivationSync"); - - concurrentActivationTest(true); - } - - /** - * Tests concurrent activation of the same subtree by multiple nodes in= a - * REPL_ASYNC environment. The idea is to see what would happen with a - * farmed deployment. See concurrentActivationTest for det= ails. - * - * @throws Exception - */ - public void testConcurrentActivationAsync() throws Exception - { - log.info("Enter testConcurrentActivationAsync"); - - concurrentActivationTest(false); - } - - /** - * Starts 5 caches and then concurrently activates the same region under - * all 5, causing each to attempt a partial state transfer from the oth= ers. - * As soon as each cache has activated its region, it does a put to a n= ode - * in the region, thus complicating the lives of the other caches trying - * to get partial state. - *

    - * Failure condition is if any node sees an exception or if the final s= tate - * of all caches is not consistent. - * - * @param sync use REPL_SYNC or REPL_ASYNC - * @throws Exception - */ - @SuppressWarnings("unchecked") - private void concurrentActivationTest(boolean sync) throws Exception - { - String[] names =3D {"A", "B", "C", "D", "E"}; - int count =3D names.length; - CacheActivator[] activators =3D new CacheActivator[count]; - - - try - { - // Create a semaphore and take all its tickets - Semaphore semaphore =3D new Semaphore(count); - for (int i =3D 0; i < count; i++) - { - semaphore.acquire(); - } - - // Create activation threads that will block on the semaphore - Cache[] caches =3D new Cache[count]; - for (int i =3D 0; i < count; i++) - { - activators[i] =3D new CacheActivator(semaphore, names[i], sync= ); - caches[i] =3D activators[i].getCache(); - activators[i].start(); - } - - // Make sure everyone is in sync - TestingUtil.blockUntilViewsReceived(caches, 60000); - - // Release the semaphore to allow the threads to start work - semaphore.release(count); - - // Sleep to ensure the threads get all the semaphore tickets - TestingUtil.sleepThread(1000); - - // Reacquire the semaphore tickets; when we have them all - // we know the threads are done - for (int i =3D 0; i < count; i++) - { - boolean acquired =3D semaphore.tryAcquire(60, TimeUnit.SECONDS= ); - if (!acquired) - fail("failed to acquire semaphore " + i); - } - - // Sleep to allow any async calls to clear - if (!sync) - TestingUtil.sleepThread(500); - - // Ensure the caches held by the activators see all the values - for (int i =3D 0; i < count; i++) - { - assertNull("Activator " + names[i] + " caught an exception", - activators[i].getException()); - - for (int j =3D 0; j < count; j++) - { - String fqn =3D "/a/b/" + names[j]; - Person p =3D (Person) activators[i].getCacheValue(fqn); - assertNotNull(names[i] + ":" + fqn + " is not null", p); - assertEquals("Correct name for " + names[i] + ":" + fqn, - "Person " + names[j], p.getName()); - assertEquals("Correct street for " + names[i] + ":" + fqn, - names[j] + " Test Street", p.getAddress().getS= treet()); -// System.out.println(names[i] + ":" + fqn + " =3D " + activ= ators[i].getCacheValue(fqn)); - } - - } - } - catch (Exception ex) - { - fail(ex.getLocalizedMessage()); - } - finally - { - for (int i =3D 0; i < count; i++) - activators[i].cleanup(); - } - - } - - /** - * Tests partial state transfer under heavy concurrent load and REPL_SY= NC. - * See concurrentUseTest for details. - * - * @throws Exception - */ - public void testConcurrentUseSync() throws Exception - { - log.info("Enter testConcurrentUseSync"); - -// concurrentUseTest(true); - } - - /** - * Tests partial state transfer under heavy concurrent load and REPL_AS= YNC. - * See concurrentUseTest for details. - * - * @throws Exception - */ - public void testConcurrentUseAsync() throws Exception - { - log.info("Enter testConcurrentUseAsync"); - -// concurrentUseTest(false); - } - - /* - * Initiates 5 caches, 4 with active trees and one with an inactive tre= e. - * Each of the active caches begins rapidly generating puts against nod= es - * in a subtree for which it is responsible. The 5th cache activates - * each subtree, and at the end confirms no node saw any exceptions and - * that each node has consistent state. - * - * @param sync whether to use REPL_SYNC or REPL_ASYNCE - * @throws Exception - */ -// private void XconcurrentUseTest(boolean sync) throws Exception -// { -// String[] names =3D {"B", "C", "D", "E"}; -// int count =3D names.length; -// CacheStressor[] stressors =3D new CacheStressor[count]; -// -// try -// { -// -// PojoCache cacheA =3D createCache("cacheA", sync, true, false, f= alse); -// -// Cache[] caches =3D new Cache[count + 1]; -// caches[0] =3D cacheA.getCache(); -// -// // Create a semaphore and take all its tickets -// Semaphore semaphore =3D new Semaphore(count); -// for (int i =3D 0; i < count; i++) -// { -// semaphore.acquire(); -// } -// -// // Create stressor threads that will block on the semaphore -// -// for (int i =3D 0; i < count; i++) -// { -// stressors[i] =3D new CacheStressor(semaphore, names[i], sync= ); -// caches[i + 1] =3D stressors[i].getCache(); -// stressors[i].start(); -// // Give each one a chance to stabilize -// TestingUtil.sleepThread(100); -// } -// -// // Make sure everyone's views are in sync -// TestingUtil.blockUntilViewsReceived(caches, 60000); -// -// // Repeat the basic test two times in order to involve inactiva= tion -// for (int x =3D 0; x < 2; x++) -// { -//// if (x > 0) -//// { -// // Reset things by inactivating the region -// // and enabling the stressors -// for (int i =3D 0; i < count; i++) -// { -// cacheA.getCache().getRegion(Fqn.fromString("/" + names[i]= ), true).deactivate(); -// log.info("TEST: Run " + x + "-- /" + names[i] + " inactiv= ated on A"); -// stressors[i].startPuts(); -// } -//// } -// -// // Release the semaphore to allow the threads to start work -// semaphore.release(count); -// -// // Sleep to ensure the threads get all the semaphore tickets -// // and to ensure puts are actively in progress -// TestingUtil.sleepThread(300); -// -// // Activate cacheA -// for (int i =3D 0; i < count; i++) -// { -// log.info("TEST: Activating /" + names[i] + " on A"); -// cacheA.getCache().getRegion(Fqn.fromString("/" + names[i]= ), true).activate(); -// // Stop the stressor so we don't pollute cacheA's state -// // with too many messages sent after activation -- we want -// // to compare transferred state with the sender -// stressors[i].stopPuts(); -// log.info("TEST: Run " + x + "-- /" + names[i] + " activat= ed on A"); -// // Reacquire one semaphore ticket -// boolean acquired =3D semaphore.tryAcquire(60, TimeUnit.SE= CONDS); -// if (!acquired) -// fail("failed to acquire semaphore " + names[i]); -// log.info("TEST: Run " + x + "-- acquired semaphore from "= + names[i]); -// -// // Pause to allow other work to proceed -// TestingUtil.sleepThread(100); -// } -// -// // Sleep to allow any in transit msgs to clear -// if (!sync) -// TestingUtil.sleepThread(2000); -// -// // Ensure the stressors saw no exceptions -// for (int i =3D 0; i < count; i++) -// { -// Exception e =3D stressors[i].getException(); -// if (e !=3D null) -// { -// log.error("Stressor " + names[i] + " caught an excepti= on", -// e); -// throw e; -// } -// } -// -//// log.info("Cache A details:\n" + cacheA.printDetails()); -// -// // Compare cache contents -// Person p1 =3D null; -// Person p2 =3D null; -// for (int i =3D 0; i < count; i++) -// { -//// log.info("Cache " + names[i] + " details:\n" + -//// stressors[i].getTreeCache().printDetails()); -// -// for (int j =3D 0; j < SUBTREE_SIZE; j++) -// { -// -// String fqn =3D "/" + names[i] + "/" + j; -// log.info("TEST: Getting A:" + fqn); -// p1 =3D (Person) cacheA.find(fqn); -// boolean p1Null =3D p1 =3D=3D null; -// log.info("TEST: Getting " + names[i] + ":" + fqn); -//// p2 =3D (Person) stressors[i].getCache().find(fqn); -// boolean p2Null =3D p2 =3D=3D null; -// assertEquals("Run " + x + ": " + fqn + -// " null status matches", p1Null, p2Null); -// if (!p1Null) -// { -// assertEquals("Run " + x + ": A:" + fqn + " age matc= hes " + names[i] + ":" + fqn, -// p1.getAge(), p2.getAge()); -// assertEquals("Run " + x + ": A:" + fqn + " name mat= ches " + names[i] + ":" + fqn, -// p1.getName(), p2.getName()); -// assertEquals("Run " + x + ": A:" + fqn + " address = matches " + names[i] + ":" + fqn, -// p1.getAddress().getStreet(), -// p2.getAddress().getStreet()); -// } -// } -// } -// } -// -// for (int i =3D 0; i < count; i++) -// stressors[i].stopThread(); -// -// } -// finally -// { -// for (int i =3D 0; i < count; i++) -// { -// if (stressors[i] !=3D null) -// stressors[i].cleanup(); -// } -// } -// -// } - - protected PojoCache createCache(String cacheID, boolean sync, boolean u= seMarshalling, boolean useCacheLoader) - throws Exception - { - return createCache(cacheID, sync, useMarshalling, useCacheLoader, tr= ue); - } - - protected PojoCache createCache(String cacheID, boolean sync, - boolean useMarshalling, - boolean useCacheLoader, - boolean inactiveOnStartup) - throws Exception - { - if (caches.get(cacheID) !=3D null) - throw new IllegalStateException(cacheID + " already created"); - - CacheMode mode =3D sync ? CacheMode.REPL_SYNC : CacheMode.REPL_ASYNC; - Configuration c =3D UnitTestCacheConfigurationFactory.createConfigur= ation(mode); - c.setClusterName("StateTransferTestBase"); - c.setReplVersionString(getReplicationVersion()); - // Use a long timeout to facilitate setting debugger breakpoints - c.setStateRetrievalTimeout(60000); - c.setLockParentForChildInsertRemove(true); - if (useMarshalling) - { - c.setUseRegionBasedMarshalling(true); - c.setInactiveOnStartup(inactiveOnStartup); - } - if (useCacheLoader) - { - configureCacheLoader(c, cacheID); - } - - PojoCache cache =3D PojoCacheFactory.createCache(c, true); - // Put the cache in the map before starting, so if it fails in - // start it can still be destroyed later - caches.put(cacheID, cache); - - return cache; - } - - protected void configureCacheLoader(Configuration c, String cacheID) th= rows Exception - { - String tmp_location =3D getTempLocation(cacheID); - - // Do cleanup in case it failed before - File file =3D new File(tmp_location); - cleanFile(file); - file.mkdir(); - tmp_location =3D escapeWindowsPath(tmp_location); - c.setCacheLoaderConfig(getCacheLoaderConfig("org.jboss.cache.loader.= FileCacheLoader", tmp_location)); - } - - - protected CacheLoaderConfig getCacheLoaderConfig(String cl, String loc)= throws Exception - { - String xml =3D " \n" + - " \n" + - " false\n" + - " \n" + - "\n" + - " \n" + - " " + cl + "\n" + - " \n" + - " location=3D" + loc + "\n" + - " \n" + - " false\n" + - " true\n" + - " false\n" + - " \n" + - " \n" + - " "; - Element element =3D XmlHelper.stringToElement(xml); - return XmlConfigurationParser.parseCacheLoaderConfig(element); - } - - protected String getTempLocation(String cacheID) - { - String tmp_location =3D System.getProperty("java.io.tmpdir", "c:\\tm= p"); - File file =3D new File(tmp_location); - file =3D new File(file, cacheID); - return file.getAbsolutePath(); - } - - protected String escapeWindowsPath(String path) - { - if ('/' =3D=3D File.separatorChar) - return path; - - char[] chars =3D path.toCharArray(); - StringBuffer sb =3D new StringBuffer(); - for (int i =3D 0; i < chars.length; i++) - { - if (chars[i] =3D=3D '\\') - sb.append('\\'); - sb.append(chars[i]); - } - return sb.toString(); - } - - protected abstract String getReplicationVersion(); - - @BeforeMethod(alwaysRun =3D true) - protected void setUp() throws Exception - { - caches =3D new HashMap(); - - addr1 =3D new Address(); - addr1.setStreet("101 Oakview Dr"); - addr1.setCity("Anytown"); - addr1.setZip(11111); - - addr2 =3D new Address(); - addr2.setStreet("222 Happy Dr"); - addr2.setCity("Fremont"); - addr2.setZip(22222); - - joe =3D new Person(); - joe.setName("Joe"); - joe.setAge(TWENTY); - joe.setAddress(addr1); - Set skills =3D new HashSet(); - skills.add("TENNIS"); - skills.add("CARPENTRY"); - joe.setSkills(skills); - - jane =3D new Person(); - jane.setName("Jane"); - jane.setAge(TWENTYFIVE); - jane.setAddress(addr1); - skills =3D new HashSet(); - skills.add("JUJITSU"); - skills.add("MACRAME"); - jane.setSkills(skills); - - bob =3D new Person(); - bob.setName("Bob"); - bob.setAge(FORTY); - bob.setAddress(addr2); - skills =3D new HashSet(); - skills.add("LANGUAGES"); - skills.add("LAWN BOWLING"); - bob.setSkills(skills); - - jill =3D new Person(); - jill.setName("Jill"); - jill.setAge(TWENTYFIVE); - jill.setAddress(addr2); - skills =3D new HashSet(); - skills.add("FORTRAN"); - skills.add("COBOL"); - jane.setSkills(skills); - } - - @AfterMethod(alwaysRun =3D true) - protected void tearDown() throws Exception - { - Set keys =3D caches.keySet(); - if (!keys.isEmpty()) - { - String[] cacheIDs =3D new String[keys.size()]; - cacheIDs =3D keys.toArray(cacheIDs); - PojoCache cache =3D caches.get(cacheIDs[0]); - cache.getCache().removeNode(new Fqn("/")); - Thread.sleep(200); - - for (int i =3D 0; i < cacheIDs.length; i++) - { - stopCache(caches.get(cacheIDs[i])); - File file =3D new File(getTempLocation(cacheIDs[i])); - cleanFile(file); - } - } - } - - protected void stopCache(PojoCache cache) - { - if (cache !=3D null) - { - try - { - cache.stop(); - cache.destroy(); - } - catch (Exception e) - { - log.error("Exception stopping cache " + e.getMessage(), e); - } - } - } - - protected void cleanFile(File file) - { - File[] children =3D file.listFiles(); - if (children !=3D null) - { - for (int i =3D 0; i < children.length; i++) - { - cleanFile(children[i]); - } - } - - if (file.exists()) - file.delete(); - if (file.exists()) - file.deleteOnExit(); - } - - private class CacheActivator extends CacheUser - { - - CacheActivator(Semaphore semaphore, - String name, - boolean sync) - throws Exception - { - super(semaphore, name, sync, false); - } - - void useCache() throws Exception - { - Region region =3D cache.getCache().getRegion(Fqn.fromString("/a/b= "), true); - region.registerContextClassLoader(getClass().getClassLoader()); - region.activate(); - log.info("TEST: " + name + " activated region" + " " + System.cur= rentTimeMillis()); - String childFqn =3D "/a/b/" + name; - - Person p =3D new Person(); - p.setName("Person " + name); - - Address addr =3D new Address(); - addr.setStreet(name + " Test Street"); - addr.setCity(name + ", CA"); - p.setAddress(addr); - - TestingUtil.sleepThread(1); - -// tm.begin(); -// try -// { - cache.attach(childFqn, p); - log.info("TEST: " + name + " put fqn " + childFqn + " " + System.= currentTimeMillis()); -// } -// catch (Exception e) -// { -// tm.setRollbackOnly(); -// throw e; -// } -// finally -// { -// tm.commit(); -// } - - } - - public Object getCacheValue(String fqn) throws CacheException - { - return cache.find(fqn); - } - } - - @SuppressWarnings("unused") - private class CacheStressor extends CacheUser - { - private Random random; - private boolean putsStopped =3D false; - private boolean stopped =3D false; - - CacheStressor(Semaphore semaphore, - String name, - boolean sync) - throws Exception - { - super(semaphore, name, sync, true); - - random =3D new Random(System.currentTimeMillis() + name.hashCode(= )); - } - - void useCache() throws Exception - { - // Do lots of puts into the cache. Use our own nodes, - // as we're not testing conflicts between writer nodes, - // just whether activation causes problems - int factor =3D 0; - int i =3D 0; - String fqn =3D null; - - Address addr1 =3D new Address(); - addr1.setStreet("1 Test Street"); - addr1.setCity("TestOne, CA"); - - Address addr2 =3D new Address(); - addr2.setStreet("2 Test Street"); - addr2.setCity("TestTwo, CA"); - - Person[] people =3D new Person[SUBTREE_SIZE]; - boolean[] loaded =3D new boolean[SUBTREE_SIZE]; - for (int j =3D 0; j < SUBTREE_SIZE; j++) - { - Person p =3D new Person(); - p.setName("Person " + j); - p.setAge(j); - p.setAddress((j % 2 =3D=3D 0) ? addr1 : addr2); - people[j] =3D p; - } - - boolean acquired =3D true; - try - { - while (!stopped) - { - if (i > 0) - { - acquired =3D semaphore.tryAcquire(60, TimeUnit.SECONDS); - if (!acquired) - throw new Exception(name + " cannot acquire semaphore= "); - log.info("TEST: " + name + " reacquired semaphore"); - System.out.println("TEST: " + name + " reacquired semaph= ore"); - } - - int lastIndex =3D -1; - int index =3D -1; - while (!putsStopped) - { - // Ensure we don't operate on the same address twice in = a row - // otherwise deadlock detection sometimes causes - // the _put for the second call to precede the commit - // for the first, leading to deadlock. This seems like a - // JGroups bug, but the purpose of this test isn't to ex= pose it - while (index % 2 =3D=3D lastIndex % 2) - { - factor =3D random.nextInt(50); - index =3D factor % SUBTREE_SIZE; - } - - lastIndex =3D index; - - TestingUtil.sleepThread(factor); - - fqn =3D "/" + name + "/" + String.valueOf(index); - -// tm.begin(); -// try -// { - if (loaded[index] =3D=3D false) - { - cache.attach(fqn, people[index]); - loaded[index] =3D true; - log.info("TEST: " + name + " put Person at " + fqn); - } - else if (i % 2 =3D=3D 0) - { - int newAge =3D factor / SUBTREE_SIZE; - people[index].setAge(newAge); - } - else - { - people[index].getAddress().setStreet(factor + " Test = Street"); - } -// } -// catch (Exception e) -// { -// tm.setRollbackOnly(); -// throw e; -// } -// finally -// { -// tm.commit(); -// } - - i++; - } - - log.info("TEST: " + name + ": last put [#" + i + "] -- " + = fqn + " =3D " + (factor / SUBTREE_SIZE)); - - semaphore.release(); - acquired =3D false; - - // Go to sleep until directed otherwise - while (!stopped && putsStopped) - TestingUtil.sleepThread(100); - } - } - finally - { - if (acquired) - semaphore.release(); - } - } - -// public void start() throws Exception -// { -// super.start(); -// cache.activateRegion("/" + name); -// } - - public void stopPuts() - { - putsStopped =3D true; - log.info("TEST: " + name + " putsStopped"); - } - - public void startPuts() - { - putsStopped =3D false; - } - - public void stopThread() - { - stopped =3D true; - if (thread.isAlive()) - thread.interrupt(); - } - - - } - - private abstract class CacheUser implements Runnable - { - protected Semaphore semaphore; - protected PojoCache cache; - protected TransactionManager tm; - protected String name; - protected Exception exception; - protected Thread thread; - - CacheUser(Semaphore semaphore, - String name, - boolean sync, - boolean activateRoot) - throws Exception - { - this.cache =3D createCache(name, sync, true, false, !activateRoot= ); - tm =3D ((CacheSPI) cache.getCache()).getTransacti= onManager(); - if (tm =3D=3D null) - throw new IllegalStateException("TransactionManager required"); - this.semaphore =3D semaphore; - this.name =3D name; - - log.info("TEST: Cache " + name + " started"); - System.out.println("TEST: Cache " + name + " started"); - } - - public void run() - { - log.info("TEST: " + name + " started"); - System.out.println("TEST: " + name + " started"); - - boolean acquired =3D false; - try - { - acquired =3D semaphore.tryAcquire(60, TimeUnit.SECONDS); - if (!acquired) - throw new Exception(name + " cannot acquire semaphore"); - log.info("TEST: " + name + " acquired semaphore"); - System.out.println("TEST: " + name + " acquired semaphore"); - useCache(); - - } - catch (Exception e) - { - log.error("TEST: " + name + ": " + e.getLocalizedMessage(), e); - - // Save it for the test to check - exception =3D e; - } - finally - { - if (acquired) - semaphore.release(); - } - - } - - abstract void useCache() throws Exception; - - public Exception getException() - { - return exception; - } - - public Cache getCache() - { - return cache.getCache(); - } - - public void start() throws Exception - { - thread =3D new Thread(this); - thread.start(); - } - - public void cleanup() - { - if (thread !=3D null && thread.isAlive()) - thread.interrupt(); - } - } -} Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/util/ObjectUtilTest= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/util/ObjectUtilTest.java = 2008-08-13 20:29:58 UTC (rev 6556) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/util/ObjectUtilTest.java = 2008-08-14 02:46:03 UTC (rev 6557) @@ -32,7 +32,7 @@ protected void setUp() throws Exception { log_.info("setUp() ...."); - String configFile =3D "META-INF/local-service.xml"; + String configFile =3D "configs/local-tx.xml"; boolean toStart =3D false; cache_ =3D PojoCacheFactory.createCache(configFile, toStart); cache_.start(); --===============3554652024633349806==-- From jbosscache-commits at lists.jboss.org Wed Aug 13 22:46:40 2008 Content-Type: multipart/mixed; boundary="===============7894454136724239150==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6558 - core/trunk. Date: Wed, 13 Aug 2008 22:46:40 -0400 Message-ID: --===============7894454136724239150== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: jason.greene(a)jboss.com Date: 2008-08-13 22:46:39 -0400 (Wed, 13 Aug 2008) New Revision: 6558 Modified: core/trunk/pom.xml Log: Use a version of commons-logging that is not completely broken Modified: core/trunk/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/pom.xml 2008-08-14 02:46:03 UTC (rev 6557) +++ core/trunk/pom.xml 2008-08-14 02:46:39 UTC (rev 6558) @@ -41,7 +41,7 @@ commons-logging commons-logging - 1.0.4 + 1.1.1 = --===============7894454136724239150==-- From jbosscache-commits at lists.jboss.org Thu Aug 14 03:40:56 2008 Content-Type: multipart/mixed; boundary="===============7131707200350497249==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6559 - core/trunk/src/main/java/org/jboss/cache/invocation. Date: Thu, 14 Aug 2008 03:40:56 -0400 Message-ID: --===============7131707200350497249== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-14 03:40:56 -0400 (Thu, 14 Aug 2008) New Revision: 6559 Modified: core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContex= t.java Log: Construct looked up nodes lazily. Modified: core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocatio= nContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationConte= xt.java 2008-08-14 02:46:39 UTC (rev 6558) +++ core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationConte= xt.java 2008-08-14 07:40:56 UTC (rev 6559) @@ -5,6 +5,7 @@ import org.jboss.cache.transaction.MVCCTransactionContext; import org.jboss.cache.transaction.TransactionContext; = +import java.util.Collections; import java.util.HashMap; import java.util.Map; = @@ -16,7 +17,7 @@ */ public class MVCCInvocationContext extends AbstractInvocationContext { - private final Map lookedUpNodes =3D new HashMap(4); + private Map lookedUpNodes =3D null; private MVCCTransactionContext mvccTCtx; = @Override @@ -38,7 +39,7 @@ public NodeSPI lookUpNode(Fqn fqn) { if (mvccTCtx !=3D null) return mvccTCtx.lookUpNode(fqn); - return lookedUpNodes.get(fqn); + return lookedUpNodes =3D=3D null ? null : lookedUpNodes.get(fqn); } = /** @@ -55,7 +56,10 @@ if (mvccTCtx !=3D null) mvccTCtx.putLookedUpNode(f, n); else + { + if (lookedUpNodes =3D=3D null) lookedUpNodes =3D new HashMap(4); lookedUpNodes.put(f, n); + } } = /** @@ -69,7 +73,8 @@ // if (mvccTCtx !=3D null) // mvccTCtx.clearLookedUpNodes(); // else - lookedUpNodes.clear(); + + if (lookedUpNodes !=3D null) lookedUpNodes.clear(); } = /** @@ -80,10 +85,11 @@ * * @return a map of looked up nodes. */ + @SuppressWarnings("unchecked") public Map getLookedUpNodes() { if (mvccTCtx !=3D null) return mvccTCtx.getLookedUpNodes(); - return lookedUpNodes; + return (Map) (lookedUpNodes =3D=3D null ? Collections.= emptyMap() : lookedUpNodes); } = @Override --===============7131707200350497249==-- From jboss-qa-internal at redhat.com Thu Aug 14 05:29:28 2008 Content-Type: multipart/mixed; boundary="===============6876869805194334185==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23416?= Date: Thu, 14 Aug 2008 05:29:26 -0400 Message-ID: <692134303.4931218706166056.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1465896475.631218480996008.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============6876869805194334185== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/416/changes --===============6876869805194334185==-- From jboss-qa-internal at redhat.com Thu Aug 14 06:40:51 2008 Content-Type: multipart/mixed; boundary="===============2382397505899015703==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23549?= Date: Thu, 14 Aug 2008 06:40:30 -0400 Message-ID: <674549342.5051218710430933.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 30697197.601218479359006.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============2382397505899015703== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/549/changes --===============2382397505899015703==-- From jbosscache-commits at lists.jboss.org Thu Aug 14 06:54:29 2008 Content-Type: multipart/mixed; boundary="===============4061431365188746393==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6560 - core/trunk/src/main/resources/config-samples. Date: Thu, 14 Aug 2008 06:54:27 -0400 Message-ID: --===============4061431365188746393== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-14 06:54:25 -0400 (Thu, 14 Aug 2008) New Revision: 6560 Modified: core/trunk/src/main/resources/config-samples/invalidation-async.xml Log: enabled bundling for async replication Modified: core/trunk/src/main/resources/config-samples/invalidation-async.x= ml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/resources/config-samples/invalidation-async.xml 200= 8-08-14 07:40:56 UTC (rev 6559) +++ core/trunk/src/main/resources/config-samples/invalidation-async.xml 200= 8-08-14 10:54:25 UTC (rev 6560) @@ -29,7 +29,7 @@ - In-Reply-To: 692134303.4931218706166056.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============3215318823696689633== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/417/changes --===============3215318823696689633==-- From jboss-qa-internal at redhat.com Thu Aug 14 14:26:30 2008 Content-Type: multipart/mixed; boundary="===============8648868789746714221==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23550?= Date: Thu, 14 Aug 2008 14:26:27 -0400 Message-ID: <1587862325.5751218738387368.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 674549342.5051218710430933.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============8648868789746714221== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/550/changes --===============8648868789746714221==-- From jbosscache-commits at lists.jboss.org Thu Aug 14 15:16:22 2008 Content-Type: multipart/mixed; boundary="===============1277679132104391157==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6561 - in pojo/trunk/src: test/java/org/jboss/cache/pojo and 1 other directory. Date: Thu, 14 Aug 2008 15:16:16 -0400 Message-ID: --===============1277679132104391157== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: jason.greene(a)jboss.com Date: 2008-08-14 15:16:15 -0400 (Thu, 14 Aug 2008) New Revision: 6561 Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedSetImpl.j= ava pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java Log: Rmove SPI use from Set Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedSe= tImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedSetImpl.= java 2008-08-14 10:54:25 UTC (rev 6560) +++ pojo/trunk/src/main/java/org/jboss/cache/pojo/collection/CachedSetImpl.= java 2008-08-14 19:16:15 UTC (rev 6561) @@ -116,9 +116,9 @@ return false; } = - public Iterator iterator() + public Iterator iterator() { - Node node =3D cache.getRoot().getChild(getFqn()); + Node node =3D cache.getRoot().getChild(getFqn()); if (node =3D=3D null) { return Collections.EMPTY_SET.iterator(); @@ -253,16 +253,16 @@ } } = - private class IteratorImpl implements Iterator + private class IteratorImpl implements Iterator { - private Iterator iterator; + private Iterator> iterator; = - private Node node; + private Node node; private Object o; = - private IteratorImpl(Node node) + private IteratorImpl(Node node) { - Collection children =3D new HashSet(((NodeSPI) = node).getChildrenDirect()); + Collection> children =3D new HashSet>(node.getChildren()); iterator =3D children.iterator(); } = Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java 2008-08-14= 10:54:25 UTC (rev 6560) +++ pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java 2008-08-14= 19:16:15 UTC (rev 6561) @@ -17,6 +17,9 @@ import org.apache.commons.logging.LogFactory; import org.jboss.aop.proxy.ClassProxy; import org.jboss.cache.Fqn; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.Configuration.NodeLockingScheme; +import org.jboss.cache.config.parsing.XmlConfigurationParser; import org.jboss.cache.pojo.impl.PojoReference; import org.jboss.cache.pojo.test.Address; import org.jboss.cache.pojo.test.DoubleRef; @@ -45,8 +48,11 @@ { log.info("setUp() ...."); String configFile =3D "configs/local-tx.xml"; + XmlConfigurationParser parser =3D new XmlConfigurationParser(); + Configuration expected =3D parser.parseFile(configFile); + //expected.setNodeLockingScheme(NodeLockingScheme.MVCC); boolean toStart =3D false; - cache_ =3D PojoCacheFactory.createCache(configFile, toStart); + cache_ =3D PojoCacheFactory.createCache(expected, toStart); cache_.start(); } = @@ -62,7 +68,7 @@ { return createPerson(id, name, age, null); } - = + private Person createPerson(String id, String name, int age, Map finalMap) { Person p =3D new Person(finalMap); @@ -196,7 +202,7 @@ { fail("Final map is not an instance of ClassProxy"); } - = + map.put("test1", "testa"); map.put("test2", "testb"); = @@ -408,14 +414,14 @@ PojoReference ref =3D (PojoReference) cache_.getCache().get(fqn, Po= joReference.KEY); assertTrue(cache_.exists(ref.getFqn())); } - = + public void testDoubleRef() throws Exception { DoubleRef ref =3D new DoubleRef(); cache_.attach("/test", ref); = AssertJUnit.assertSame(ref.getOne(), ref.getTwo()); - = + ref.setOne(null); ref.setTwo(null); } --===============1277679132104391157==-- From jbosscache-commits at lists.jboss.org Fri Aug 15 06:59:43 2008 Content-Type: multipart/mixed; boundary="===============8145851995119243193==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6562 - in core/trunk/src: main/java/org/jboss/cache/config and 21 other directories. Date: Fri, 15 Aug 2008 06:59:41 -0400 Message-ID: --===============8145851995119243193== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-15 06:59:40 -0400 (Fri, 15 Aug 2008) New Revision: 6562 Added: core/trunk/src/main/java/org/jboss/cache/config/CloneableConfigurationCo= mponent.java core/trunk/src/main/java/org/jboss/cache/config/EvictionAlgorithmConfig.= java core/trunk/src/main/java/org/jboss/cache/eviction/DefaultEvictionActionP= olicy.java core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgorithmCo= nfig.java core/trunk/src/main/java/org/jboss/cache/eviction/EvictionActionPolicy.j= ava core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithmConfi= gBase.java core/trunk/src/main/java/org/jboss/cache/eviction/EvictionEvent.java core/trunk/src/main/java/org/jboss/cache/eviction/EvictionEventType.java core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithmCon= fig.java core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithmConfig.ja= va core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithmConfig.java core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithmConfig.java core/trunk/src/main/java/org/jboss/cache/eviction/MRUAlgorithmConfig.java core/trunk/src/main/java/org/jboss/cache/eviction/Modernizable.java core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionAlgorithmC= onfig.java core/trunk/src/main/java/org/jboss/cache/eviction/RemoveOnEvictActionPol= icy.java Removed: core/trunk/src/main/java/org/jboss/cache/eviction/EvictedEventNode.java core/trunk/src/main/java/org/jboss/cache/eviction/NodeEventType.java core/trunk/src/test/java/org/jboss/cache/eviction/DummyEvictionConfigura= tion.java core/trunk/src/test/java/org/jboss/cache/eviction/DummyEvictionPolicy.ja= va core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionIntercepto= rTest.java Modified: core/trunk/src/main/java/org/jboss/cache/Region.java core/trunk/src/main/java/org/jboss/cache/RegionImpl.java core/trunk/src/main/java/org/jboss/cache/RegionManager.java core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java core/trunk/src/main/java/org/jboss/cache/config/ConfigurationComponent.j= ava core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java core/trunk/src/main/java/org/jboss/cache/config/EvictionPolicyConfig.java core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.java core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.= java core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguration= Parser2x.java core/trunk/src/main/java/org/jboss/cache/config/parsing/element/Eviction= ElementParser.java core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.= java core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionPolicy.java core/trunk/src/main/java/org/jboss/cache/eviction/BaseSortedEvictionAlgo= rithm.java core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgorithm.j= ava core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeConfigurati= on.java core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizePolicy.java core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithm.java core/trunk/src/main/java/org/jboss/cache/eviction/EvictionException.java core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicy.java core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicyConfigBa= se.java core/trunk/src/main/java/org/jboss/cache/eviction/EvictionTimerTask.java core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithm.ja= va core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationConfiguratio= n.java core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationPolicy.java core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithm.java core/trunk/src/main/java/org/jboss/cache/eviction/FIFOConfiguration.java core/trunk/src/main/java/org/jboss/cache/eviction/FIFOPolicy.java core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithm.java core/trunk/src/main/java/org/jboss/cache/eviction/LFUConfiguration.java core/trunk/src/main/java/org/jboss/cache/eviction/LFUPolicy.java core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithm.java core/trunk/src/main/java/org/jboss/cache/eviction/LRUConfiguration.java core/trunk/src/main/java/org/jboss/cache/eviction/LRUPolicy.java core/trunk/src/main/java/org/jboss/cache/eviction/MRUAlgorithm.java core/trunk/src/main/java/org/jboss/cache/eviction/MRUConfiguration.java core/trunk/src/main/java/org/jboss/cache/eviction/MRUPolicy.java core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionAlgorithm.= java core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicy.java core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicyConf= ig.java core/trunk/src/main/java/org/jboss/cache/interceptors/BuddyRegionAwareEv= ictionInterceptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionIntercepto= r.java core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransf= erIntegrator.java core/trunk/src/main/java/org/jboss/cache/util/Util.java core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicati= onWithCacheLoaderTest.java core/trunk/src/test/java/org/jboss/cache/buddyreplication/EvictionOfBudd= yBackupsTest.java core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTest= .java core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementP= arserTest.java core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguration= ParserTest.java core/trunk/src/test/java/org/jboss/cache/eviction/BaseEvictionAlgorithmT= est.java core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTest= .java core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeAlgorithmTe= st.java core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConfigurati= onTest.java core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizePolicyTest.= java core/trunk/src/test/java/org/jboss/cache/eviction/EvictionConfigurationT= est.java core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.j= ava core/trunk/src/test/java/org/jboss/cache/eviction/FIFOAlgorithmTest.java core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurationTest.= java core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java core/trunk/src/test/java/org/jboss/cache/eviction/LFUAlgorithmTest.java core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfigurationTest.j= ava core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.j= ava core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java core/trunk/src/test/java/org/jboss/cache/eviction/MRUAlgorithmTest.java core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.j= ava core/trunk/src/test/java/org/jboss/cache/eviction/MRUPolicyTest.java core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest= .java core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionPolicyTest= .java core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest= .java core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyT= est.java core/trunk/src/test/java/org/jboss/cache/eviction/RegionManagerTest.java core/trunk/src/test/java/org/jboss/cache/eviction/RegionTest.java core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTes= t.java core/trunk/src/test/java/org/jboss/cache/eviction/minttl/FIFOMinTTLTest.= java core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LFUMinTTLTest.j= ava core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LRUMinTTLTest.j= ava core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MRUMinTTLTest.j= ava core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MinTTLTestBase.= java core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigur= ationFactory.java core/trunk/src/test/java/org/jboss/cache/invalidation/TombstoneEvictionT= est.java core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigurat= ionTest.java core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshalling= JDBCTest.java core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshalling= Test.java core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivati= onCallbacksTestCase.java core/trunk/src/test/java/org/jboss/cache/passivation/ReplicatedPassivati= onIntegrationTest.java core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConc= urrencyTest.java core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionControll= er.java core/trunk/src/test/resources/unit-test-cache-service.xml Log: Changes to eviction interfaces Modified: core/trunk/src/main/java/org/jboss/cache/Region.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/Region.java 2008-08-14 19:16:1= 5 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/Region.java 2008-08-15 10:59:4= 0 UTC (rev 6562) @@ -7,11 +7,8 @@ package org.jboss.cache; = import org.jboss.cache.config.Configuration; -import org.jboss.cache.config.EvictionPolicyConfig; import org.jboss.cache.config.EvictionRegionConfig; -import org.jboss.cache.eviction.EvictedEventNode; -import org.jboss.cache.eviction.EvictionPolicy; -import org.jboss.cache.eviction.LRUPolicy; +import org.jboss.cache.eviction.EvictionEvent; = /** * Defines characteristics such as class loading and eviction of {@link or= g.jboss.cache.Node}s belonging to a Region in a {@link Cache}. @@ -19,7 +16,7 @@ * All nodes and child nodes of this Fqn belong to this region. *

    * If a region is to be recognised as an eviction region (region of type {= @link Type#EVICTION} then - * it must have an {@link org.jboss.cache.config.EvictionPolicyConf= ig} set using {@link #setEvictionPolicy(org.jboss.cache.config.EvictionPoli= cyConfig)}. + * it must have an {@link org.jboss.cache.config.EvictionRegionConf= ig} set using {@link #setEvictionRegionConfig(org.jboss.cache.config.Evicti= onRegionConfig)}. *

    * Similarly, to be recognised as a marshalling region (region of type {@l= ink Type#MARSHALLING} then it must have a * {@link ClassLoader} registered using {@link #registerContextClassLoader= (ClassLoader)}. @@ -33,7 +30,6 @@ */ public interface Region extends Comparable { - /** * Types of regions. */ @@ -114,67 +110,52 @@ ClassLoader getClassLoader(); = /** - * Configures an eviction policy for this region. - * - * @param evictionPolicyConfig configuration to set + * Processes the eviction queues (primary and recycle queues) associate= d with this region. A no-op if this is not an eviction region. */ - void setEvictionPolicy(EvictionPolicyConfig evictionPolicyConfig); + void processEvictionQueues(); = /** - * Returns an eviction policy configuration. - * - * @return an eviction policy configuration + * Clears the node event queue used for processing eviction. */ - EvictionPolicyConfig getEvictionPolicyConfig(); + void resetEvictionQueues(); = /** - * Returns an eviction policy. + * Configures this region for eviction. * - * @return an eviction policy + * @param evictionRegionConfig configuration to set */ - EvictionPolicy getEvictionPolicy(); + void setEvictionRegionConfig(EvictionRegionConfig evictionRegionConfig); = /** - * Returns an eviction region configuration for this region. - * - * @return an eviction region configuration + * @return the eviction region config, if any, set on the current regio= n. */ EvictionRegionConfig getEvictionRegionConfig(); = /** - * Clears the node event queue used for processing eviction. + * Registers an eviction event on the region's eviction event queue for= later processing by + * {@link #processEvictionQueues()}. * - * @see #nodeEventQueueSize() + * @param fqn passed in to the constructor of {@link org.= jboss.cache.eviction.EvictionEvent} + * @param eventType passed in to the constructor of {@link org.= jboss.cache.eviction.EvictionEvent} + * @param elementDifference passed in to the constructor of {@link org.= jboss.cache.eviction.EvictionEvent} + * @return an EvictedEventNode that has been created for this queue */ - void resetEvictionQueues(); + EvictionEvent registerEvictionEvent(Fqn fqn, EvictionEvent.Type eventTy= pe, int elementDifference); = /** - * Returns the size of the node event queue, used by the eviction threa= d. + * An overloaded version of {@link #registerEvictionEvent(Fqn, org.jbos= s.cache.eviction.EvictionEvent.Type, int)} which + * uses a default elementDifference value. * - * @return number of events + * @param fqn passed in to the constructor of {@link org.jboss.ca= che.eviction.EvictionEvent} + * @param eventType passed in to the constructor of {@link org.jboss.ca= che.eviction.EvictionEvent} + * @return an EvictedEventNode that has been created for this queue */ - int nodeEventQueueSize(); + EvictionEvent registerEvictionEvent(Fqn fqn, EvictionEvent.Type eventTy= pe); = /** - * Returns the most recent {@link org.jboss.cache.eviction.EvictedEvent= Node} added to the event queue by - * {@link #putNodeEvent(EvictedEventNode)}. - * - * @return the last {@link org.jboss.cache.eviction.EvictedEventNode}, = or null if no more events exist - */ - EvictedEventNode takeLastEventNode(); - - /** - * Adds an {@link org.jboss.cache.eviction.EvictedEventNode} to the int= ernal queue for processing - * by the eviction thread. - * - * @param event event to add - */ - void putNodeEvent(EvictedEventNode event); - - /** * Marks a {@link org.jboss.cache.Node} as currently in use, by adding = an event to the eviction queue. - * If there is an {@link EvictionPolicy} associated with this region, a= nd - * it respects this event (e.g., {@link LRUPolicy} does), then the {@li= nk org.jboss.cache.Node} will not + * If there is an {@link org.jboss.cache.config.EvictionRegionConfig} a= ssociated with this region, and + * it respects this event (e.g., {@link org.jboss.cache.eviction.LRUAlg= orithm} does), then the {@link org.jboss.cache.Node} will not * be evicted until {@link #unmarkNodeCurrentlyInUse(Fqn)} is invoked. *

    * This mechanism can be used to prevent eviction of data that the appl= ication Modified: core/trunk/src/main/java/org/jboss/cache/RegionImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/RegionImpl.java 2008-08-14 19:= 16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/RegionImpl.java 2008-08-15 10:= 59:40 UTC (rev 6562) @@ -9,16 +9,15 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.config.Configuration; -import org.jboss.cache.config.EvictionPolicyConfig; +import org.jboss.cache.config.EvictionAlgorithmConfig; import org.jboss.cache.config.EvictionRegionConfig; -import org.jboss.cache.eviction.EvictedEventNode; -import org.jboss.cache.eviction.EvictionPolicy; -import org.jboss.cache.eviction.NodeEventType; +import org.jboss.cache.eviction.EvictionActionPolicy; +import org.jboss.cache.eviction.EvictionAlgorithm; +import org.jboss.cache.eviction.EvictionEvent; import org.jboss.cache.util.Util; = import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; = /** * Default implementation of a {@link Region} @@ -28,16 +27,17 @@ public class RegionImpl implements Region { private static final Log log =3D LogFactory.getLog(RegionImpl.class); - + private static final boolean trace =3D log.isTraceEnabled(); private final RegionManager regionManager; private Fqn fqn; private Status status; private ClassLoader classLoader; - private BlockingQueue nodeEventQueue =3D null; + private BlockingQueue evictionEventQueue =3D null; private int capacityWarnThreshold =3D 0; - private EvictionRegionConfig configuration =3D new EvictionRegionConfig= (); - private EvictionPolicy policy; + private EvictionRegionConfig evictionRegionConfig; + private EvictionAlgorithm evictionAlgorithm; = + /** * Constructs a marshalling region from an fqn and region manager. */ @@ -51,11 +51,10 @@ /** * Constructs an eviction region from a policy and configuration, defin= ed by an fqn and region manager. */ - public RegionImpl(EvictionPolicy policy, EvictionRegionConfig config, F= qn fqn, RegionManager regionManager) + public RegionImpl(EvictionRegionConfig config, Fqn fqn, RegionManager r= egionManager) { this(fqn, regionManager); - this.configuration =3D config; - this.policy =3D policy; + this.evictionRegionConfig =3D config; createQueue(); } = @@ -105,6 +104,11 @@ return classLoader; } = + public void processEvictionQueues() + { + evictionAlgorithm.process(evictionEventQueue); + } + public Fqn getFqn() { return fqn; @@ -127,17 +131,19 @@ = // -------- eviction stuff ----- = + public BlockingQueue getEvictionEventQueue() + { + return evictionEventQueue; + } + public void markNodeCurrentlyInUse(Fqn fqn, long timeout) { - EvictedEventNode markUse =3D new EvictedEventNode(fqn, NodeEventType= .MARK_IN_USE_EVENT); - markUse.setInUseTimeout(timeout); - putNodeEvent(markUse); + registerEvictionEvent(fqn, EvictionEvent.Type.MARK_IN_USE_EVENT, 0).= setInUseTimeout(timeout); } = public void unmarkNodeCurrentlyInUse(Fqn fqn) { - EvictedEventNode markNoUse =3D new EvictedEventNode(fqn, NodeEventTy= pe.UNMARK_USE_EVENT); - putNodeEvent(markNoUse); + registerEvictionEvent(fqn, EvictionEvent.Type.UNMARK_USE_EVENT, 0); } = @Override @@ -147,8 +153,8 @@ "fqn=3D" + fqn + "; classloader=3D" + classLoader + "; status=3D" + status + - "; eviction=3D" + (getEvictionPolicy() !=3D null) + - "; timerThreadRegistered=3D" + (getEvictionPolicy() !=3D null = && regionManager.getEvictionTimerTask().isRegionRegisteredForProcessing(thi= s)) + + "; eviction=3D" + (evictionAlgorithm !=3D null) + + "; timerThreadRegistered=3D" + (evictionAlgorithm !=3D null &&= regionManager.getEvictionTimerTask().isRegionRegisteredForProcessing(this)= ) + '}'; } = @@ -176,105 +182,97 @@ return (fqn !=3D null ? fqn.hashCode() : 0); } = - public void putNodeEvent(EvictedEventNode event) + public void resetEvictionQueues() { - try - { - if (nodeEventQueue =3D=3D null) createQueue();// in case the queu= e does not exist yet. - if (nodeEventQueue.size() > capacityWarnThreshold) - { - log.warn("putNodeEvent(): eviction node event queue size is at= 98% threshold value of capacity: " + configuration.getEventQueueSize() + - " Region: " + fqn + - " You will need to reduce the wakeUpIntervalSeconds para= meter."); - } - nodeEventQueue.put(event); - } - catch (InterruptedException e) - { - log.debug("give up put", e); - } + evictionEventQueue.clear(); } = - public EvictedEventNode takeLastEventNode() + public void setEvictionRegionConfig(EvictionRegionConfig evictionRegion= Config) { + this.evictionRegionConfig =3D evictionRegionConfig; + evictionAlgorithm =3D createEvictionAlgorithm(evictionRegionConfig.g= etEvictionAlgorithmConfig(), evictionRegionConfig.getEvictionActionPolicyCl= assName()); + regionManager.getEvictionTimerTask().addRegionToProcess(this); + if (evictionEventQueue =3D=3D null) createQueue(); + evictionAlgorithm.initialize(); + } + + public EvictionRegionConfig getEvictionRegionConfig() + { + return evictionRegionConfig; + } + + public EvictionEvent registerEvictionEvent(Fqn fqn, EvictionEvent.Type = eventType) + { + return registerEvictionEvent(fqn, eventType, 0); + } + + public EvictionEvent registerEvictionEvent(Fqn fqn, EvictionEvent.Type = eventType, int elementDifference) + { + if (evictionAlgorithm.canIgnoreEvent(eventType)) return null; + + EvictionEvent event =3D new EvictionEvent(fqn, eventType, elementDif= ference); try { - return nodeEventQueue.poll(0, TimeUnit.SECONDS); + if (evictionEventQueue =3D=3D null) createQueue();// in case the = queue does not exist yet. + if (evictionEventQueue.size() > capacityWarnThreshold) + { + if (log.isWarnEnabled()) + log.warn("putNodeEvent(): eviction node event queue size is= at 98% threshold value of capacity: " + evictionRegionConfig.getEventQueue= Size() + + " Region: " + fqn + + " You will need to reduce the wakeUpIntervalSeconds p= arameter."); + } + evictionEventQueue.put(event); } catch (InterruptedException e) { + if (log.isDebugEnabled()) log.debug("Interrupted on adding event"= , e); + // reinstate interrupt flag Thread.currentThread().interrupt(); } - return null; + return event; } = - public int nodeEventQueueSize() - { - return nodeEventQueue.size(); - } - - public void resetEvictionQueues() - { - nodeEventQueue.clear(); - } - private void createQueue() { - if (nodeEventQueue =3D=3D null) + if (evictionEventQueue =3D=3D null) { - if (configuration =3D=3D null) + if (evictionRegionConfig =3D=3D null) { throw new IllegalArgumentException("null eviction configuratio= n"); } - int size =3D configuration.getEventQueueSize(); + int size =3D evictionRegionConfig.getEventQueueSize(); capacityWarnThreshold =3D (98 * size) / 100 - 100; if (capacityWarnThreshold <=3D 0) { throw new RuntimeException("Capacity warn threshold used in ev= iction is smaller than 1."); } - nodeEventQueue =3D new LinkedBlockingQueue(size= ); + evictionEventQueue =3D new LinkedBlockingQueue(siz= e); } } = - public EvictionRegionConfig getEvictionRegionConfig() + private EvictionAlgorithm createEvictionAlgorithm(EvictionAlgorithmConf= ig algoConfig, String evictionActionPolicyClass) { - return this.configuration; - } + if (algoConfig =3D=3D null) + throw new IllegalArgumentException("Eviction algorithm class must= not be null!"); = - public EvictionPolicyConfig getEvictionPolicyConfig() - { - return configuration =3D=3D null ? null : configuration.getEvictionP= olicyConfig(); - } + if (evictionActionPolicyClass =3D=3D null) + throw new IllegalArgumentException("Eviction action policy class = must not be null!"); = - public EvictionPolicy getEvictionPolicy() - { - return policy; - } - - public void setEvictionPolicy(EvictionPolicyConfig evictionPolicyConfig) - { - configuration.setEvictionPolicyConfig(evictionPolicyConfig); - policy =3D createPolicy(evictionPolicyConfig.getEvictionPolicyClass(= )); - regionManager.getEvictionTimerTask().addRegionToProcess(this); - if (nodeEventQueue =3D=3D null) createQueue(); - } - - private EvictionPolicy createPolicy(String className) - { - if (className =3D=3D null) - { - throw new IllegalArgumentException("null className"); - } try { - if (log.isTraceEnabled()) log.trace("Instantiating " + className); - EvictionPolicy ep =3D (EvictionPolicy) Util.loadClass(className).= newInstance(); - ep.setCache(regionManager.getCache()); - return ep; + if (trace) log.trace("Instantiating " + evictionActionPolicyClass= ); + EvictionActionPolicy actionPolicy =3D (EvictionActionPolicy) Util= .getInstance(evictionActionPolicyClass); + actionPolicy.setCache(regionManager.getCache()); + + if (trace) log.trace("Instantiating " + algoConfig.getEvictionAlg= orithmClassName()); + EvictionAlgorithm algorithm =3D (EvictionAlgorithm) Util.getInsta= nce(algoConfig.getEvictionAlgorithmClassName()); + algorithm.setEvictionActionPolicy(actionPolicy); + algorithm.assignToRegion(fqn, regionManager.getCache(), algoConfi= g, regionManager.getConfiguration()); + return algorithm; } catch (Exception e) { - log.fatal("Unable to instantiate eviction policy class " + classN= ame, e); + log.fatal("Unable to instantiate eviction algorithm " + algoConfi= g.getEvictionAlgorithmClassName(), e); throw new IllegalStateException(e); } } @@ -282,14 +280,13 @@ public Region copy(Fqn newRoot) { RegionImpl clone; - clone =3D new RegionImpl(policy, configuration, Fqn.fromRelativeFqn(= newRoot, fqn), regionManager); + clone =3D new RegionImpl(evictionRegionConfig, Fqn.fromRelativeFqn(n= ewRoot, fqn), regionManager); clone.status =3D status; // we also need to copy all of the eviction event nodes to the clone= 's queue clone.createQueue(); - for (EvictedEventNode een : this.nodeEventQueue) + for (EvictionEvent een : this.evictionEventQueue) { - EvictedEventNode cloneEEN =3D een.copy(newRoot); - clone.putNodeEvent(cloneEEN); + clone.registerEvictionEvent(een.getFqn(), een.getEventType(), een= .getElementDifference()); } return clone; } Modified: core/trunk/src/main/java/org/jboss/cache/RegionManager.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/RegionManager.java 2008-08-14 = 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/RegionManager.java 2008-08-15 = 10:59:40 UTC (rev 6562) @@ -1,5 +1,6 @@ package org.jboss.cache; = +import org.jboss.cache.config.Configuration; import org.jboss.cache.config.EvictionConfig; import org.jboss.cache.eviction.EvictionTimerTask; = @@ -176,4 +177,9 @@ * @return the eviction timer task attached to the region manager */ EvictionTimerTask getEvictionTimerTask(); + + /** + * @return the configuration + */ + Configuration getConfiguration(); } Modified: core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-08= -14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-08= -15 10:59:40 UTC (rev 6562) @@ -8,8 +8,8 @@ import org.jboss.cache.buddyreplication.BuddyManager; import org.jboss.cache.config.Configuration; import org.jboss.cache.config.ConfigurationException; +import org.jboss.cache.config.EvictionAlgorithmConfig; import org.jboss.cache.config.EvictionConfig; -import org.jboss.cache.config.EvictionPolicyConfig; import org.jboss.cache.config.EvictionRegionConfig; import org.jboss.cache.eviction.EvictionTimerTask; import org.jboss.cache.factories.annotations.Destroy; @@ -92,16 +92,21 @@ @Start public void start() { - log.trace("Starting region manager"); + if (trace) log.trace("Starting region manager"); isUsingBR =3D configuration.getBuddyReplicationConfig() !=3D null &&= configuration.getBuddyReplicationConfig().isEnabled(); if (configuration.getEvictionConfig() !=3D null && configuration.getEvictionConfig().isValidConfig()) { + // start with the default region + EvictionRegionConfig defaultRegion =3D configuration.getEvictionC= onfig().getDefaultEvictionRegionConfig(); + defaultRegion.getEvictionAlgorithmConfig().validate(); + // validate individual region configs now for (EvictionRegionConfig erc : configuration.getEvictionConfig()= .getEvictionRegionConfigs()) { - EvictionPolicyConfig epc =3D erc.getEvictionPolicyConfig(); - if (epc !=3D null) epc.validate(); + evictionConfig.applyDefaults(erc); + EvictionAlgorithmConfig eac =3D erc.getEvictionAlgorithmConfig= (); + if (eac !=3D null) eac.validate(); } = setEvictionConfig(configuration.getEvictionConfig()); @@ -200,7 +205,7 @@ // mandates that class loaders be registered for marshalling regi= ons. if (type =3D=3D ANY || (type =3D=3D MARSHALLING && r.getClassLoader() !=3D null) - || (type =3D=3D EVICTION && r.getEvictionPolicyConfig() != =3D null)) + || (type =3D=3D EVICTION && r.getEvictionRegionConfig() != =3D null)) { return r; } @@ -235,7 +240,7 @@ // mandates that class loaders be registered for marshalling r= egions. if (type =3D=3D ANY || (type =3D=3D MARSHALLING && r.getClassLoader() !=3D n= ull) - || (type =3D=3D EVICTION && r.getEvictionPolicyConfig() = !=3D null)) + || (type =3D=3D EVICTION && r.getEvictionRegionConfig() = !=3D null)) { nextBestThing =3D r; } @@ -264,7 +269,7 @@ Region r =3D regionsRegistry.remove(fqn); if (r =3D=3D null) return false; = - if (isUsingEvictions() && r.getEvictionPolicy() !=3D null) + if (isUsingEvictions() && r.getEvictionRegionConfig() !=3D null) { evictionTimerTask.removeRegionToProcess(r); } @@ -276,6 +281,11 @@ return evictionTimerTask; } = + public Configuration getConfiguration() + { + return configuration; + } + public void activate(Fqn fqn) throws RegionNotEmptyException { activate(fqn, false); @@ -600,7 +610,7 @@ case ANY: return true; case EVICTION: - return r.getEvictionPolicy() !=3D null && evictionTimerTask.is= RegionRegisteredForProcessing(r); + return r.getEvictionRegionConfig() !=3D null && evictionTimerT= ask.isRegionRegisteredForProcessing(r); case MARSHALLING: return r.isActive() && r.getClassLoader() !=3D null; } @@ -671,7 +681,7 @@ // we need to loop thru the regions and only select specific regi= ons to rtn. for (Region r : regionsRegistry.values()) { - if ((type =3D=3D EVICTION && r.getEvictionPolicy() !=3D null &= & evictionTimerTask.isRegionRegisteredForProcessing(r)) || + if ((type =3D=3D EVICTION && r.getEvictionRegionConfig() !=3D = null && evictionTimerTask.isRegionRegisteredForProcessing(r)) || (type =3D=3D MARSHALLING && r.isActive() && r.getClassLo= ader() !=3D null)) regions.add(r); } @@ -698,24 +708,24 @@ = // JBAS-1288 // Try to establish a default region if there isn't one already - boolean needDefault; +// boolean needDefault; List ercs =3D evictionConfig.getEvictionRegion= Configs(); // Only add a default region if there are no regions. This is // contrary to the idea that there *must* be a default region, but s= ome // unit tests fail w/ APPROACH 1, so for now we go with this approac= h. - needDefault =3D ercs.size() =3D=3D 0; +// needDefault =3D ercs.size() =3D=3D 0; + ercs.add(0, evictionConfig.getDefaultEvictionRegionConfig()); +// if (needDefault) +// { +// // This may throw ConfigurationException if there is no default +// // eviction policy class +// EvictionRegionConfig dflt =3D evictionConfig.createDefaultEvict= ionRegionConfig(); +// ercs.add(0, dflt); // put it first +// // Need to pass this back into the evictionConfig so it knows +// // about the new region +// evictionConfig.setEvictionRegionConfigs(ercs); +// } = - if (needDefault) - { - // This may throw ConfigurationException if there is no default - // eviction policy class - EvictionRegionConfig dflt =3D evictionConfig.createDefaultEvictio= nRegionConfig(); - ercs.add(0, dflt); // put it first - // Need to pass this back into the evictionConfig so it knows - // about the new region - evictionConfig.setEvictionRegionConfigs(ercs); - } - // create regions for the regions defined in the evictionConfig. // scan to be sure the _default_ region isn't added twice boolean setDefault =3D false; @@ -724,18 +734,19 @@ Fqn fqn =3D erc.getRegionFqn(); if (trace) log.trace("Creating eviction region " + fqn); = - if (fqn.equals(DEFAULT_REGION)) + if (fqn.equals(DEFAULT_REGION) || fqn.isRoot()) { if (setDefault) { throw new ConfigurationException("A default region for evic= tions has already been set for this cache"); } - if (trace) log.trace("Applying settings for " + DEFAULT_REGION= + " to Fqn.ROOT"); + if (trace) log.trace("Applying settings for default region to = Fqn.ROOT"); fqn =3D Fqn.ROOT; setDefault =3D true; } Region r =3D getRegion(fqn, true); - r.setEvictionPolicy(erc.getEvictionPolicyConfig()); + evictionConfig.applyDefaults(erc); + r.setEvictionRegionConfig(erc); } } = Added: core/trunk/src/main/java/org/jboss/cache/config/CloneableConfigurati= onComponent.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/CloneableConfigurationC= omponent.java (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/config/CloneableConfigurationC= omponent.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -0,0 +1,14 @@ +package org.jboss.cache.config; + +import java.io.Serializable; + +/** + * Interface for all configurable components + * + * @author Manik Surtani (manik(a)jbo= ss.org) + * @since 3.0 + */ +public interface CloneableConfigurationComponent extends Serializable, Clo= neable +{ + CloneableConfigurationComponent clone() throws CloneNotSupportedExcepti= on; +} Modified: core/trunk/src/main/java/org/jboss/cache/config/ConfigurationComp= onent.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/ConfigurationComponent.= java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/config/ConfigurationComponent.= java 2008-08-15 10:59:40 UTC (rev 6562) @@ -14,7 +14,6 @@ import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; = -import java.io.Serializable; import java.util.Collection; import java.util.Collections; import java.util.HashSet; @@ -28,7 +27,7 @@ * @version $Revision$ * @see #testImmutability(String) */ -public abstract class ConfigurationComponent implements Serializable, Clon= eable +public abstract class ConfigurationComponent implements CloneableConfigura= tionComponent { private static final long serialVersionUID =3D 4879873994727821938L; = @@ -120,11 +119,6 @@ } } = - /** - * Sets a back-reference to the cache associated with this configuration - * - * @param cache - */ public void setCache(CacheSPI cache) { this.cache =3D cache; @@ -150,7 +144,7 @@ } = @Override - public ConfigurationComponent clone() throws CloneNotSupportedException + public CloneableConfigurationComponent clone() throws CloneNotSupported= Exception { ConfigurationComponent c =3D (ConfigurationComponent) super.clone(); c.setCache(null); Added: core/trunk/src/main/java/org/jboss/cache/config/EvictionAlgorithmCon= fig.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/EvictionAlgorithmConfig= .java (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/config/EvictionAlgorithmConfig= .java 2008-08-15 10:59:40 UTC (rev 6562) @@ -0,0 +1,41 @@ +package org.jboss.cache.config; + +/** + * An interface used to configure an eviction algorithm. Replaces the dep= recated {@link org.jboss.cache.config.EvictionPolicyConfig}. + *

    + * In it's most basic form, it is implemented by {@link org.jboss.cache.ev= iction.EvictionAlgorithmConfigBase}, but + * more specific eviction policies may subclass {@link org.jboss.cache.evi= ction.EvictionAlgorithmConfigBase} or re-implement + * this interface to provide access to more config variables. + * + * @author Manik Surtani (manik(a)jbo= ss.org) + * @since 3.0 + */ +public interface EvictionAlgorithmConfig extends CloneableConfigurationCom= ponent +{ + /** + * Gets the class name of the {@link org.jboss.cache.eviction.EvictionA= lgorithm} implementation + * this object will configure. + * + * @return fully qualified class name + */ + String getEvictionAlgorithmClassName(); + + /** + * Validate the configuration. Will be called after any configuration + * properties are set. + * + * @throws ConfigurationException if any values for the configuration + * properties are invalid + */ + void validate() throws ConfigurationException; + + /** + * Resets the values to their defaults. + */ + void reset(); + + /** + * @return a clone of the EvictionAlgorithmConfig. + */ + EvictionAlgorithmConfig clone() throws CloneNotSupportedException; +} Modified: core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.ja= va =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java 200= 8-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java 200= 8-08-15 10:59:40 UTC (rev 6562) @@ -22,11 +22,11 @@ package org.jboss.cache.config; = import org.jboss.cache.Fqn; -import org.jboss.cache.RegionManagerImpl; -import org.jboss.cache.eviction.EvictionPolicy; +import org.jboss.cache.eviction.DefaultEvictionActionPolicy; = -import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; +import java.util.concurrent.TimeUnit; = public class EvictionConfig extends ConfigurationComponent { @@ -35,51 +35,96 @@ */ private static final long serialVersionUID =3D -7979639000026975201L; = - public static final int WAKEUP_DEFAULT =3D 5; - + public static final int WAKEUP_DEFAULT =3D 5000; public static final int EVENT_QUEUE_SIZE_DEFAULT =3D 200000; + public static final String EVICTION_ACTION_POLICY_CLASS_DEFAULT =3D Def= aultEvictionActionPolicy.class.getName(); = - private String defaultEvictionPolicyClass; - - @Deprecated - private int wakeupIntervalSeconds =3D WAKEUP_DEFAULT; - /** * value expressed in millis */ @Dynamic - private long wakeupInterval =3D WAKEUP_DEFAULT * 1000; + private long wakeupInterval =3D WAKEUP_DEFAULT; = private int defaultEventQueueSize =3D EVENT_QUEUE_SIZE_DEFAULT; = // Dynamic to support runtime adds/removes of regions @Dynamic private List evictionRegionConfigs; + private EvictionRegionConfig defaultEvictionRegionConfig; = public EvictionConfig() { + evictionRegionConfigs =3D new LinkedList(); + defaultEvictionRegionConfig =3D new EvictionRegionConfig(Fqn.ROOT); + defaultEvictionRegionConfig.setEventQueueSize(EVENT_QUEUE_SIZE_DEFAU= LT); + defaultEvictionRegionConfig.setEvictionActionPolicyClassName(Default= EvictionActionPolicy.class.getName()); } = - public EvictionConfig(String defaultEvictionClass) + /** + * @deprecated Use {@link #EvictionConfig(EvictionRegionConfig)} instea= d. + */ + @Deprecated + public EvictionConfig(String defaultEvictionPolicyClass) { - setDefaultEvictionPolicyClass(defaultEvictionClass); + this(); + setDefaultEvictionPolicyClass(defaultEvictionPolicyClass); } = + public EvictionConfig(EvictionRegionConfig defaultEvictionRegionConfig) + { + evictionRegionConfigs =3D new LinkedList(); + try + { + this.defaultEvictionRegionConfig =3D defaultEvictionRegionConfig.= clone(); + } + catch (CloneNotSupportedException e) + { + throw new ConfigurationException(e); + } + this.defaultEvictionRegionConfig.setEventQueueSize(EVENT_QUEUE_SIZE_= DEFAULT); + if (this.defaultEvictionRegionConfig.getEvictionActionPolicyClassNam= e() =3D=3D null) + this.defaultEvictionRegionConfig.setEvictionActionPolicyClassName= (DefaultEvictionActionPolicy.class.getName()); + } + + public EvictionConfig(EvictionRegionConfig defaultEvictionRegionConfig,= int wakeupInterval) + { + this(defaultEvictionRegionConfig); + this.wakeupInterval =3D wakeupInterval; + } + public boolean isValidConfig() { - return (defaultEvictionPolicyClass !=3D null && defaultEvictionPolic= yClass.length() > 0) + return (defaultEvictionRegionConfig !=3D null && defaultEvictionRegi= onConfig.getEvictionActionPolicyClassName() !=3D null && defaultEvictionReg= ionConfig.getEvictionAlgorithmConfig() !=3D null) || (evictionRegionConfigs !=3D null && evictionRegionConfigs.s= ize() > 0); } = + public EvictionRegionConfig getDefaultEvictionRegionConfig() + { + return defaultEvictionRegionConfig; + } + + public void setDefaultEvictionRegionConfig(EvictionRegionConfig default= EvictionRegionConfig) + { + this.defaultEvictionRegionConfig =3D defaultEvictionRegionConfig; + this.defaultEvictionRegionConfig.setEventQueueSizeIfUnset(EVENT_QUEU= E_SIZE_DEFAULT); + } + + /** + * @deprecated use {@link #getDefaultEvictionRegionConfig()} instead. + */ + @Deprecated public String getDefaultEvictionPolicyClass() { - return defaultEvictionPolicyClass; + throw new ConfigurationException("Please use getDefaultEvictionRegio= nConfig() instead."); } = + /** + * @deprecated use {@link #setDefaultEvictionRegionConfig(EvictionRegio= nConfig)} instead. + */ + @Deprecated public void setDefaultEvictionPolicyClass(String defaultEvictionPolicyC= lass) { - testImmutability("defaultEvictionPolicyClass"); - this.defaultEvictionPolicyClass =3D defaultEvictionPolicyClass; + throw new ConfigurationException("Please use setDefaultEvictionRegio= nConfig() instead."); } = /** @@ -96,70 +141,33 @@ * @throws ConfigurationException if a * {@link #setDefaultEvictionPolicyClass= (String) a default eviction policy class} * has not been set or there is a proble= m instantiating the configuration. + * @deprecated the default region is now created when this instance is = constructed. Use {@link #getDefaultEvictionRegionConfig()} instead. */ + @Deprecated public EvictionRegionConfig createDefaultEvictionRegionConfig() { - if (defaultEvictionPolicyClass !=3D null) - { - try - { - Class cpolicy =3D Class.forName(defaultEvictionPolicyClass); - EvictionPolicy policy =3D (EvictionPolicy) cpolicy.newInstance= (); - EvictionRegionConfig erc =3D new EvictionRegionConfig(); - EvictionPolicyConfig epc =3D policy.getEvictionConfigurationCl= ass().newInstance(); - erc.setEvictionPolicyConfig(epc); - erc.setRegionFqn(RegionManagerImpl.DEFAULT_REGION); - return erc; - } - catch (Exception e) - { - log.error("Unable to create EvictionRegionConfig for default r= egion", e); - throw new ConfigurationException("Unable to create EvictionReg= ionConfig for default region", e); - } - } - else - { - throw new ConfigurationException("Cannot create EvictionRegionCon= fig for default region; no defaultEvictionPolicyClass configured"); - } + return getDefaultEvictionRegionConfig(); } = public List getEvictionRegionConfigs() { - if (evictionRegionConfigs =3D=3D null) - { - evictionRegionConfigs =3D new ArrayList(1); - } return evictionRegionConfigs; } = - public int getDefaultEventQueueSize() + public void setEvictionRegionConfigs(List evictio= nRegionConfigs) { - return defaultEventQueueSize; + testImmutability("evictionRegionConfigs"); + this.evictionRegionConfigs =3D evictionRegionConfigs; } = - public void setDefaultEventQueueSize(int eventQueueSize) + public void addEvictionRegionConfig(EvictionRegionConfig evictionRegion= Config) { - this.defaultEventQueueSize =3D eventQueueSize; - } - - public void setEvictionRegionConfigs(List evictio= nRegionConfigs) - { testImmutability("evictionRegionConfigs"); - - // Make sure region configs built by MC have the event queue size - if (evictionRegionConfigs !=3D null) - { - for (EvictionRegionConfig cfg : evictionRegionConfigs) - { - cfg.setDefaultEventQueueSize(getDefaultEventQueueSize()); - } - } - replaceChildConfigs(this.evictionRegionConfigs, evictionRegionConfig= s); - this.evictionRegionConfigs =3D evictionRegionConfigs; + evictionRegionConfigs.add(evictionRegionConfig); } = /** - * value expressed in millis + * @return the wake up interval of the eviction thread, in milliseconds. */ public long getWakeupInterval() { @@ -167,22 +175,35 @@ } = /** - * value expressed in millis + * Set the wake up interval for the eviction thread. 0 or a negative nu= mber disables the eviction thread. + * + * @param wakeupInterval interval, in milliseconds. */ public void setWakeupInterval(long wakeupInterval) { - testImmutability("WakeupInterval"); + testImmutability("wakeupInterval"); this.wakeupInterval =3D wakeupInterval; - this.wakeupIntervalSeconds =3D (int) wakeupInterval / 1000; } = /** + * Set the wake up interval for the eviction thread. 0 or a negative nu= mber disables the eviction thread. + * + * @param wakeupInterval interval + * @param timeUnit for the interval provided + */ + public void setWakeupInterval(long wakeupInterval, TimeUnit timeUnit) + { + testImmutability("wakeupInterval"); + this.wakeupInterval =3D timeUnit.toMillis(wakeupInterval); + } + + /** * @deprecated Use {@link #getWakeupIntervalSeconds()}. */ @Deprecated public int getWakeupIntervalSeconds() { - return wakeupIntervalSeconds; + return (int) TimeUnit.MILLISECONDS.toSeconds(wakeupInterval); } = /** @@ -191,9 +212,7 @@ @Deprecated public void setWakeupIntervalSeconds(int wakeupIntervalSeconds) { - testImmutability("wakeupIntervalSeconds"); - this.wakeupIntervalSeconds =3D wakeupIntervalSeconds; - this.wakeupInterval =3D wakeupIntervalSeconds * 1000; + setWakeupInterval(wakeupIntervalSeconds, TimeUnit.SECONDS); } = public boolean equals(Object o) @@ -205,9 +224,6 @@ = if (defaultEventQueueSize !=3D that.defaultEventQueueSize) return fa= lse; if (wakeupInterval !=3D that.wakeupInterval) return false; - if (wakeupIntervalSeconds !=3D that.wakeupIntervalSeconds) return fa= lse; - if (defaultEvictionPolicyClass !=3D null ? !defaultEvictionPolicyCla= ss.equals(that.defaultEvictionPolicyClass) : that.defaultEvictionPolicyClas= s !=3D null) - return false; if (evictionRegionConfigs !=3D null ? !evictionRegionConfigs.equals(= that.evictionRegionConfigs) : that.evictionRegionConfigs !=3D null) return false; = @@ -217,9 +233,7 @@ public int hashCode() { int result; - result =3D (defaultEvictionPolicyClass !=3D null ? defaultEvictionPo= licyClass.hashCode() : 0); - result =3D 31 * result + wakeupIntervalSeconds; - result =3D 31 * result + (int) (wakeupInterval ^ (wakeupInterval >>>= 32)); + result =3D 31 + (int) (wakeupInterval ^ (wakeupInterval >>> 32)); result =3D 31 * result + defaultEventQueueSize; result =3D 31 * result + (evictionRegionConfigs !=3D null ? eviction= RegionConfigs.hashCode() : 0); return result; @@ -231,12 +245,8 @@ EvictionConfig clone =3D (EvictionConfig) super.clone(); if (evictionRegionConfigs !=3D null) { - List ercs =3D new ArrayList(evictionRegionConfigs.size()); - for (EvictionRegionConfig erc : evictionRegionConfigs) - { - ercs.add(erc.clone()); - } - clone.setEvictionRegionConfigs(ercs); + // needs to be a deep copy + for (EvictionRegionConfig erc : evictionRegionConfigs) clone.addE= victionRegionConfig(erc.clone()); } return clone; } @@ -258,4 +268,24 @@ } return null; } + + /** + * Applies defaults to a config passed in + * + * @param config config to apply defaults to + */ + public void applyDefaults(EvictionRegionConfig config) + { + if (config =3D=3D null) return; // no op + config.setDefaults(defaultEvictionRegionConfig); + } + + /** + * @deprecated set these attributes on the default eviction region conf= ig. + */ + @Deprecated + public void setDefaultEventQueueSize(int queueSize) + { + defaultEvictionRegionConfig.setEventQueueSize(queueSize); + } } Modified: core/trunk/src/main/java/org/jboss/cache/config/EvictionPolicyCon= fig.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/EvictionPolicyConfig.ja= va 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/config/EvictionPolicyConfig.ja= va 2008-08-15 10:59:40 UTC (rev 6562) @@ -17,7 +17,9 @@ * to provide access to more config variables. * * @author Manik Surtani (manik(a)jbo= ss.org) + * @deprecated see {@link org.jboss.cache.config.EvictionAlgorithmConfig} */ +(a)Deprecated public interface EvictionPolicyConfig { /** Modified: core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionCon= fig.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.ja= va 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.ja= va 2008-08-15 10:59:40 UTC (rev 6562) @@ -22,7 +22,9 @@ package org.jboss.cache.config; = import org.apache.commons.logging.LogFactory; +import org.jboss.cache.CacheException; import org.jboss.cache.Fqn; +import org.jboss.cache.eviction.Modernizable; import org.jboss.cache.util.Util; = import java.lang.reflect.Method; @@ -40,38 +42,88 @@ private Fqn regionFqn; @Dynamic private Integer eventQueueSize; - private EvictionPolicyConfig evictionPolicyConfig; + private EvictionAlgorithmConfig evictionAlgorithmConfig; + @Deprecated + private EvictionPolicyConfig deprecatedConfig; + private String evictionActionPolicyClassName; = public EvictionRegionConfig() { } = + /** + * @deprecated use {@link #EvictionRegionConfig(org.jboss.cache.Fqn, Ev= ictionAlgorithmConfig)} instead. + */ + @Deprecated + @SuppressWarnings("deprecation") public EvictionRegionConfig(Fqn regionFqn, EvictionPolicyConfig evictio= nPolicyConfig) { this.regionFqn =3D regionFqn; - this.evictionPolicyConfig =3D evictionPolicyConfig; + if (evictionPolicyConfig instanceof Modernizable) + { + this.evictionAlgorithmConfig =3D ((Modernizable) evictionPolicyCo= nfig).modernize(); + deprecatedConfig =3D evictionPolicyConfig; + } + else + { + throw new ConfigurationException("Unable to convert " + evictionP= olicyConfig.getClass().getName() + + " to a more modern format, implementing " + EvictionAlgorit= hmConfig.class.getSimpleName() + ". Please use " + + EvictionAlgorithmConfig.class.getSimpleName() + " which rep= laces the deprecated " + EvictionPolicyConfig.class.getSimpleName()); + } } = + public EvictionRegionConfig(Fqn regionFqn, EvictionAlgorithmConfig evic= tionAlgorithmConfig) + { + this.regionFqn =3D regionFqn; + this.evictionAlgorithmConfig =3D evictionAlgorithmConfig; + } + + public EvictionRegionConfig(Fqn fqn) + { + this.regionFqn =3D fqn; + } + + /** + * @deprecated use {@link #getEvictionAlgorithmConfig()} instead. + */ + @Deprecated public EvictionPolicyConfig getEvictionPolicyConfig() { - return evictionPolicyConfig; + if (deprecatedConfig !=3D null) + return deprecatedConfig; + else + throw new CacheException("Not supported. Please use " + Eviction= AlgorithmConfig.class.getSimpleName() + + " instead of " + EvictionPolicyConfig.class.getSimpleName()= ); } = - public void setEvictionPolicyConfig(EvictionPolicyConfig config) + public EvictionAlgorithmConfig getEvictionAlgorithmConfig() { - testImmutability("evictionPolicyConfig"); - if (this.evictionPolicyConfig instanceof ConfigurationComponent) + return evictionAlgorithmConfig; + } + + /** + * @deprecated see {@link #setEvictionAlgorithmConfig(EvictionAlgorithm= Config)} + */ + @Deprecated + public void setEvictionPolicyConfig(EvictionPolicyConfig evictionPolicy= Config) + { + if (evictionPolicyConfig instanceof Modernizable) { - removeChildConfig((ConfigurationComponent) this.evictionPolicyCon= fig); + deprecatedConfig =3D evictionPolicyConfig; + setEvictionAlgorithmConfig(((Modernizable) evictionPolicyConfig).= modernize()); } - if (config instanceof ConfigurationComponent) + else { - addChildConfig((ConfigurationComponent) config); + throw new ConfigurationException("Unable to convert " + evictionP= olicyConfig.getClass().getName() + + " to a more modern format, implementing " + EvictionAlgorit= hmConfig.class.getSimpleName() + ". Please use " + + EvictionAlgorithmConfig.class.getSimpleName() + " which rep= laces the deprecated " + EvictionPolicyConfig.class.getSimpleName()); } + } = - // don't validate here - instead validate when we start things up. = See RegionManager.start() - - this.evictionPolicyConfig =3D config; + public void setEvictionAlgorithmConfig(EvictionAlgorithmConfig config) + { + testImmutability("evictionAlgorithmConfig"); + this.evictionAlgorithmConfig =3D config; } = public Fqn getRegionFqn() @@ -113,13 +165,15 @@ this.eventQueueSize =3D queueSize; } = - public void setDefaultEventQueueSize(int queueSize) + public void setDefaults(EvictionRegionConfig defaults) { - if (eventQueueSize =3D=3D null) - setEventQueueSize(queueSize); + // go thru each element that is unset here and copy from "defaults" + if (eventQueueSize =3D=3D null) eventQueueSize =3D defaults.getEvent= QueueSize(); + if (evictionAlgorithmConfig =3D=3D null) evictionAlgorithmConfig =3D= defaults.getEvictionAlgorithmConfig(); + if (evictionActionPolicyClassName =3D=3D null) + evictionActionPolicyClassName =3D defaults.getEvictionActionPolic= yClassName(); } = - @Override public boolean equals(Object obj) { @@ -130,9 +184,9 @@ { EvictionRegionConfig other =3D (EvictionRegionConfig) obj; boolean equalRegions =3D Util.safeEquals(this.regionFqn, other.re= gionFqn); - boolean equalConfigurations =3D Util.safeEquals(this.evictionPoli= cyConfig, other.evictionPolicyConfig); + boolean equalConfigurations =3D Util.safeEquals(this.evictionAlgo= rithmConfig, other.evictionAlgorithmConfig); boolean equalEventQueuSizes =3D this.getEventQueueSize() =3D=3D o= ther.getEventQueueSize(); - return equalRegions && equalConfigurations && equalConfigurations; + return equalRegions && equalConfigurations && equalConfigurations= && equalEventQueuSizes; } return false; } @@ -150,36 +204,84 @@ public EvictionRegionConfig clone() throws CloneNotSupportedException { EvictionRegionConfig clone =3D (EvictionRegionConfig) super.clone(); - if (evictionPolicyConfig !=3D null) + if (evictionAlgorithmConfig !=3D null) { - if (!(evictionPolicyConfig instanceof Cloneable)) + if (!(evictionAlgorithmConfig instanceof Cloneable)) { - throw new CloneNotSupportedException(evictionPolicyConfig + " = is not Cloneable"); + throw new CloneNotSupportedException(evictionAlgorithmConfig += " is not Cloneable"); } = - if (evictionPolicyConfig instanceof ConfigurationComponent) + if (evictionAlgorithmConfig instanceof ConfigurationComponent) { - clone.setEvictionPolicyConfig((EvictionPolicyConfig) ((Configu= rationComponent) evictionPolicyConfig).clone()); + clone.setEvictionAlgorithmConfig((EvictionAlgorithmConfig) ((C= onfigurationComponent) evictionAlgorithmConfig).clone()); } else { try { - Method cloneMethod =3D evictionPolicyConfig.getClass().getD= eclaredMethod("clone"); - EvictionPolicyConfig epc =3D (EvictionPolicyConfig) cloneMe= thod.invoke(evictionPolicyConfig); - clone.setEvictionPolicyConfig(epc); + Method cloneMethod =3D this.evictionAlgorithmConfig.getClas= s().getDeclaredMethod("clone"); + EvictionAlgorithmConfig evictionAlgorithmConfig =3D (Evicti= onAlgorithmConfig) cloneMethod.invoke(this.evictionAlgorithmConfig); + clone.setEvictionAlgorithmConfig(evictionAlgorithmConfig); } catch (Exception e) { - CloneNotSupportedException cnse =3D new CloneNotSupportedEx= ception("Cannot invoke clone() on " + evictionPolicyConfig); + CloneNotSupportedException cnse =3D new CloneNotSupportedEx= ception("Cannot invoke clone() on " + evictionAlgorithmConfig); cnse.initCause(e); throw cnse; } } } = + if (deprecatedConfig !=3D null) + { + if (!(deprecatedConfig instanceof Cloneable)) + { + throw new CloneNotSupportedException(deprecatedConfig + " is n= ot Cloneable"); + } + + if (deprecatedConfig instanceof ConfigurationComponent) + { + clone.setEvictionAlgorithmConfig((EvictionAlgorithmConfig) ((C= onfigurationComponent) deprecatedConfig).clone()); + } + else + { + try + { + Method cloneMethod =3D this.deprecatedConfig.getClass().get= DeclaredMethod("clone"); + EvictionAlgorithmConfig evictionAlgorithmConfig =3D (Evicti= onAlgorithmConfig) cloneMethod.invoke(this.deprecatedConfig); + clone.setEvictionAlgorithmConfig(evictionAlgorithmConfig); + } + catch (Exception e) + { + CloneNotSupportedException cnse =3D new CloneNotSupportedEx= ception("Cannot invoke clone() on " + deprecatedConfig); + cnse.initCause(e); + throw cnse; + } + } + } + + clone.evictionActionPolicyClassName =3D evictionActionPolicyClassNam= e; + return clone; } = + public boolean isDefaultRegion() + { + return regionFqn.isRoot(); + } = + public String getEvictionActionPolicyClassName() + { + return evictionActionPolicyClassName =3D=3D null ? EvictionConfig.EV= ICTION_ACTION_POLICY_CLASS_DEFAULT : evictionActionPolicyClassName; + } + + public void setEvictionActionPolicyClassName(String evictionActionPolic= yClassName) + { + this.evictionActionPolicyClassName =3D evictionActionPolicyClassName; + } + + public void setEventQueueSizeIfUnset(int eventQueueSize) + { + if (this.eventQueueSize =3D=3D null) this.eventQueueSize =3D eventQu= eueSize; + } } \ No newline at end of file Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfig= Helper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper= .java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper= .java 2008-08-15 10:59:40 UTC (rev 6562) @@ -22,11 +22,17 @@ = import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; import java.beans.PropertyEditor; import java.beans.PropertyEditorManager; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; +import java.io.StringWriter; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; @@ -472,7 +478,9 @@ Class paramTypes[] =3D m.getParameterTypes(); if (paramTypes.length !=3D 1) { - throw new ConfigurationException("Setter " + setter + " = does not contain the expected number of params. Has " + paramTypes.length = + " instead of just 1."); + if (log.isTraceEnabled()) + log.trace("Rejecting setter " + m + " on class " + ob= jectClass + " due to incorrect number of parameters"); + continue; // try another param with the same name. = = } = Class parameterType =3D paramTypes[0]; @@ -499,7 +507,8 @@ } } } - if (!setterFound && failOnMissingSetter) throw new ConfigurationE= xception("Couldn't find a setter method for parameter " + propName); + if (!setterFound && failOnMissingSetter) + throw new ConfigurationException("Couldn't find a setter named= [" + setter + "] which takes a single parameter, for parameter " + propNam= e); } } = @@ -535,4 +544,22 @@ } return new ParsedAttributes(stringAttribs, xmlAttribs); } + + public static String toString(Element e) + { + try + { + TransformerFactory tfactory =3D TransformerFactory.newInstance(); + Transformer xform =3D tfactory.newTransformer(); + Source src =3D new DOMSource(e); + java.io.StringWriter writer =3D new StringWriter(); + Result result =3D new javax.xml.transform.stream.StreamResult(wri= ter); + xform.transform(src, result); + return writer.toString(); + } + catch (Exception ex) + { + return "Unable to convert to string: " + ex.toString(); + } + } } Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfig= urationParser2x.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParser2x.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParser2x.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -19,10 +19,9 @@ import org.jboss.cache.config.EvictionPolicyConfig; import org.jboss.cache.config.EvictionRegionConfig; import org.jboss.cache.config.MissingPolicyException; -import org.jboss.cache.config.parsing.element.EvictionElementParser; import org.jboss.cache.eviction.EvictionPolicy; +import org.jboss.cache.util.FileLookup; import org.jboss.cache.util.Util; -import org.jboss.cache.util.FileLookup; import org.w3c.dom.Attr; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; @@ -383,7 +382,7 @@ eventQueueSize =3D EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT; } = - ec.setDefaultEventQueueSize(eventQueueSize); + ec.getDefaultEvictionRegionConfig().setEventQueueSize(eventQueueS= ize); = NodeList list =3D element.getElementsByTagName(EvictionRegionConf= ig.REGION); if (list !=3D null && list.getLength() > 0) @@ -474,7 +473,8 @@ policy.getEvictionConfigurationClass(), e); } = - EvictionElementParser.parseEvictionPolicyConfig(element, epc); + // TODO FIX this!!! +// EvictionElementParser.parseEvictionPolicyConfig(element, epc); = erc.setEvictionPolicyConfig(epc); return erc; Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/E= victionElementParser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/element/Evictio= nElementParser.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/Evictio= nElementParser.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -1,16 +1,21 @@ package org.jboss.cache.config.parsing.element; = -import org.jboss.cache.RegionManagerImpl; -import org.jboss.cache.config.*; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.cache.config.ConfigurationException; +import org.jboss.cache.config.EvictionAlgorithmConfig; +import org.jboss.cache.config.EvictionConfig; +import org.jboss.cache.config.EvictionRegionConfig; +import org.jboss.cache.config.MissingPolicyException; import org.jboss.cache.config.parsing.ParsedAttributes; import org.jboss.cache.config.parsing.XmlConfigHelper; import org.jboss.cache.config.parsing.XmlParserBase; -import org.jboss.cache.eviction.EvictionPolicy; +import org.jboss.cache.eviction.EvictionAlgorithm; import org.jboss.cache.util.Util; import org.w3c.dom.Element; import org.w3c.dom.NodeList; = -import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; = /** @@ -25,8 +30,11 @@ */ public class EvictionElementParser extends XmlParserBase { + private static final Log log =3D LogFactory.getLog(EvictionElementParse= r.class); + public EvictionConfig parseEvictionElement(Element evictionElement) { + if (log.isTraceEnabled()) log.trace("Parsing eviction element " + Xm= lConfigHelper.toString(evictionElement)); EvictionConfig evictionConfig =3D new EvictionConfig(); String wakeUpInterval =3D getAttributeValue(evictionElement, "wakeUp= Interval"); if (existsAttribute(wakeUpInterval)) @@ -35,37 +43,39 @@ } else { - throw new ConfigurationException("Missing mandatory attribute wakeU= pInterval"); = + throw new ConfigurationException("Missing mandatory attribute wak= eUpInterval"); } = - String defaultPolicyClassStr =3D getAttributeValue(evictionElement, = "defaultPolicyClass"); - if (existsAttribute(defaultPolicyClassStr)) evictionConfig.setDefaul= tEvictionPolicyClass(defaultPolicyClassStr); - String defaultEventQueueSize =3D getAttributeValue(evictionElement, = "defaultEventQueueSize"); - if (existsAttribute(defaultEventQueueSize)) evictionConfig.setDefaul= tEventQueueSize(getInt(defaultEventQueueSize)); +// String defaultPolicyClassStr =3D getAttributeValue(evictionElement= , "defaultPolicyClass"); +// if (existsAttribute(defaultPolicyClassStr)) evictionConfig.setDefa= ultEvictionPolicyClass(defaultPolicyClassStr); +// String defaultEventQueueSize =3D getAttributeValue(evictionElement= , "defaultEventQueueSize"); +// if (existsAttribute(defaultEventQueueSize)) evictionConfig.setDefa= ultEventQueueSize(getInt(defaultEventQueueSize)); = - List evictionRegionConfigs =3D new ArrayList(3); - Element rootRegion =3D getSingleElement("default", evictionElement); - String defaultPolicyClass =3D evictionConfig.getDefaultEvictionPolic= yClass(); - int defaultEvQueueSize =3D evictionConfig.getDefaultEventQueueSize(); - if (rootRegion !=3D null) + List evictionRegionConfigs =3D new LinkedList<= EvictionRegionConfig>(); + Element defaultRegion =3D getSingleElement("default", evictionElemen= t); + + if (defaultRegion !=3D null) { - EvictionRegionConfig erc =3D getEvictionRegionConfig(rootRegion, = defaultPolicyClass, defaultEvQueueSize); - erc.setRegionName(RegionManagerImpl.DEFAULT_REGION.toString()); - evictionRegionConfigs.add(erc); + EvictionRegionConfig defaultRegionConfig =3D getEvictionRegionCon= fig(defaultRegion, null, true); + if (defaultRegionConfig.getEvictionAlgorithmConfig() =3D=3D null) + throw new ConfigurationException("Default eviction region shou= ld have an evictionAlgorithmClass defined."); + evictionConfig.setDefaultEvictionRegionConfig(defaultRegionConfig= ); } = NodeList regions =3D evictionElement.getElementsByTagName("region"); for (int i =3D 0; i < regions.getLength(); i++) { Element regionConfig =3D (Element) regions.item(i); - EvictionRegionConfig erc =3D getEvictionRegionConfig(regionConfig= , defaultPolicyClass, defaultEvQueueSize); + EvictionRegionConfig erc =3D getEvictionRegionConfig(regionConfig= , evictionConfig.getDefaultEvictionRegionConfig(), false); + evictionConfig.applyDefaults(erc); evictionRegionConfigs.add(erc); } evictionConfig.setEvictionRegionConfigs(evictionRegionConfigs); return evictionConfig; } = - private EvictionRegionConfig getEvictionRegionConfig(Element element, S= tring defaultPolicyClass, int defaultEventQueueSize) + @SuppressWarnings("unchecked") + private EvictionRegionConfig getEvictionRegionConfig(Element element, E= victionRegionConfig defaultRegion, boolean isDefault) { EvictionRegionConfig erc =3D new EvictionRegionConfig(); erc.setRegionName(getAttributeValue(element, "name")); @@ -74,53 +84,99 @@ { erc.setEventQueueSize(getInt(queueSize)); } - else + else if (defaultRegion =3D=3D null) { - erc.setEventQueueSize(defaultEventQueueSize); + erc.setEventQueueSize(EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT); } - String policyClass =3D getAttributeValue(element, "policyClass"); - if (!existsAttribute(policyClass)) + + String algorithmClassName =3D getAttributeValue(element, "algorithmC= lass"); + EvictionAlgorithmConfig eac =3D null; // every eviction region confi= g needs an algorithm config. + + if (existsAttribute(algorithmClassName)) { - if (defaultPolicyClass =3D=3D null) + EvictionAlgorithm algorithm; + Class algorithmClass; + // try using a 'getInstance()' factory. + + try { - throw new MissingPolicyException("There is no Eviction Policy = Class specified on the region or for the entire cache!"); + algorithmClass =3D Util.loadClass(algorithmClassName); } - else + catch (Exception e) { - policyClass =3D defaultPolicyClass; + throw new RuntimeException("Unable to load eviction algorithm = class [" + algorithmClassName + "]", e); } + + + try + { + algorithm =3D Util.getInstance(algorithmClass); + } + catch (Exception e) + { + throw new ConfigurationException("Unable to construct eviction= algorithm class [" + algorithmClassName + "]", e); + } + + try + { + eac =3D Util.getInstance(algorithm.getConfigurationClass()); + } + catch (Exception e) + { + throw new RuntimeException("Failed to instantiate eviction alg= orithm configuration class [" + + algorithm.getConfigurationClass() + "]", e); + } } - EvictionPolicy policy; - try + else { - policy =3D (EvictionPolicy) Util.loadClass(policyClass).newInstan= ce(); + if (!isDefault) + { + if (defaultRegion =3D=3D null || defaultRegion.getEvictionAlgo= rithmConfig() =3D=3D null) + { + throw new MissingPolicyException("There is no Eviction Algo= rithm Class specified on the region or for the entire cache!"); + } + else + { + try + { + eac =3D defaultRegion.getEvictionAlgorithmConfig().clone= (); + } + catch (CloneNotSupportedException e) + { + throw new ConfigurationException("Unable to clone evicti= on algorithm configuration from default", e); + } + } + } } - catch (Exception e) + + if (eac !=3D null) { - throw new RuntimeException("Eviction class is not properly loaded= in classloader", e); + parseEvictionPolicyConfig(element, eac, defaultRegion !=3D null); + + erc.setEvictionAlgorithmConfig(eac); } = - EvictionPolicyConfig epc; - try + String actionPolicyClass =3D getAttributeValue(element, "actionPolic= yClass"); + if (existsAttribute(actionPolicyClass)) { - epc =3D policy.getEvictionConfigurationClass().newInstance(); + erc.setEvictionActionPolicyClassName(actionPolicyClass); } - catch (Exception e) + else if (defaultRegion =3D=3D null) { - throw new RuntimeException("Failed to instantiate eviction config= uration of class " + - policy.getEvictionConfigurationClass(), e); + // this is the default region. Make sure we set the default Evict= ionActionPolicyClass. + erc.setEvictionActionPolicyClassName(EvictionConfig.EVICTION_ACTI= ON_POLICY_CLASS_DEFAULT); } - parseEvictionPolicyConfig(element, epc); - erc.setEvictionPolicyConfig(epc); + + return erc; } = - public static void parseEvictionPolicyConfig(Element element, EvictionP= olicyConfig target) + public static void parseEvictionPolicyConfig(Element element, EvictionA= lgorithmConfig target, boolean validate) { target.reset(); ParsedAttributes attributes =3D XmlConfigHelper.extractAttributes(el= ement); XmlConfigHelper.setValues(target, attributes.stringAttribs, false, t= rue); XmlConfigHelper.setValues(target, attributes.xmlAttribs, true, true); - target.validate(); + if (validate) target.validate(); } } Modified: core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlg= orithm.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm= .java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm= .java 2008-08-15 10:59:40 UTC (rev 6562) @@ -8,10 +8,12 @@ = import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.jboss.cache.CacheSPI; import org.jboss.cache.Fqn; -import org.jboss.cache.Region; import org.jboss.cache.config.Configuration; import org.jboss.cache.config.Configuration.NodeLockingScheme; +import org.jboss.cache.config.EvictionAlgorithmConfig; +import org.jboss.cache.eviction.EvictionEvent.Type; import org.jboss.cache.lock.TimeoutException; = import java.util.concurrent.BlockingQueue; @@ -32,33 +34,29 @@ { private static final Log log =3D LogFactory.getLog(BaseEvictionAlgorith= m.class); private static final boolean trace =3D log.isTraceEnabled(); - + protected EvictionActionPolicy evictionActionPolicy; + protected EvictionAlgorithmConfig evictionAlgorithmConfig; /** - * Mapped region. - */ - protected Region region; - - /** * Contains Fqn instances. */ protected BlockingQueue recycleQueue; - /** * Contains NodeEntry instances. */ protected EvictionQueue evictionQueue; - protected boolean allowTombstones =3D false; + protected Configuration configuration; + protected Fqn regionFqn; + protected CacheSPI cache; = /** * This method will create an EvictionQueue implementation and prepare = it for use. * - * @param region MarshRegion to setup an eviction queue for. * @return The created EvictionQueue to be used as the eviction queue f= or this algorithm. - * @throws EvictionException + * @throws EvictionException if there are problems * @see EvictionQueue */ - protected abstract EvictionQueue setupEvictionQueue(Region region) thro= ws EvictionException; + protected abstract EvictionQueue setupEvictionQueue() throws EvictionEx= ception; = /** * This method will check whether the given node should be evicted or n= ot. @@ -73,52 +71,64 @@ recycleQueue =3D new LinkedBlockingQueue(500000); } = - protected void initialize(Region region) throws EvictionException + public void initialize() { - if (region =3D=3D null) - throw new IllegalArgumentException("region"); - this.region =3D region; - evictionQueue =3D setupEvictionQueue(region); - log.debug("initialized: " + this); - // hacky temp solution till we have an ioc fwk to inject configurati= on elements as needed - Configuration c =3D region.getCacheConfiguration(); - Configuration.CacheMode cm =3D c !=3D null ? c.getCacheMode() : Conf= iguration.CacheMode.LOCAL; - allowTombstones =3D c !=3D null && c.getNodeLockingScheme() =3D=3D N= odeLockingScheme.OPTIMISTIC && + evictionQueue =3D setupEvictionQueue(); + if (log.isDebugEnabled()) log.debug("Initialized: " + this); + Configuration.CacheMode cm =3D configuration !=3D null ? configurati= on.getCacheMode() : Configuration.CacheMode.LOCAL; + allowTombstones =3D configuration !=3D null && configuration.getNode= LockingScheme() =3D=3D NodeLockingScheme.OPTIMISTIC && (cm =3D=3D Configuration.CacheMode.INVALIDATION_ASYNC || cm = =3D=3D Configuration.CacheMode.INVALIDATION_SYNC); + } = + public EvictionActionPolicy getEvictionActionPolicy() + { + return evictionActionPolicy; } = + public void setEvictionActionPolicy(EvictionActionPolicy evictionAction= Policy) + { + this.evictionActionPolicy =3D evictionActionPolicy; + } + + public EvictionAlgorithmConfig getEvictionAlgorithmConfig() + { + return evictionAlgorithmConfig; + } + + public void assignToRegion(Fqn fqn, CacheSPI cache, EvictionAlgor= ithmConfig evictionAlgorithmConfig, Configuration configuration) + { + this.regionFqn =3D fqn; + this.cache =3D cache; + this.evictionAlgorithmConfig =3D evictionAlgorithmConfig; + this.configuration =3D configuration; + } + + public boolean canIgnoreEvent(Type eventType) + { + return false; // don't ignore anything! + } + /** - * Process the given region. + * Process the given eviction event queue. Eviction Processing encompa= sses the following: *

    - * Eviction Processing encompasses the following: - *

    * - Add/Remove/Visit Nodes * - Prune according to Eviction Algorithm * - Empty/Retry the recycle queue of previously evicted but locked (du= ring actual cache eviction) nodes. * - * @param region Cache region to process for eviction. + * @param eventQueue queue containing eviction events * @throws EvictionException */ - public void process(Region region) throws EvictionException + public void process(BlockingQueue eventQueue) throws Evi= ctionException { - if (this.region =3D=3D null) - { - this.initialize(region); - } - - if (trace) - { - log.trace("process(): region: " + region.getFqn()); - } - - this.processQueues(region); + if (trace) log.trace("process(): region: " + regionFqn); + this.processQueues(eventQueue); this.emptyRecycleQueue(); this.prune(); } = - public void resetEvictionQueue(Region region) + public void resetEvictionQueue() { + // a no-op } = /** @@ -132,6 +142,19 @@ return this.evictionQueue; } = + protected EvictionEvent getNextInQueue(BlockingQueue que= ue) + { + try + { + return queue.poll(0, TimeUnit.SECONDS); + } + catch (InterruptedException e) + { + Thread.currentThread().interrupt(); + } + return null; + } + /** * Event processing for Evict/Add/Visiting of nodes. *

    @@ -139,17 +162,15 @@ * - On RemoveEvents, the removed element is removed from the eviction = queue. * - On VisitEvents, the visited node has its eviction statistics updat= ed (idleTime, numberOfNodeVisists, etc..) * - * @param region Cache region to process for eviction. - * @throws EvictionException + * @param queue queue to inspect + * @throws EvictionException in the event of problems */ - protected void processQueues(Region region) throws EvictionException + protected void processQueues(BlockingQueue queue) throws= EvictionException { - EvictedEventNode node; + EvictionEvent node; int count =3D 0; - while ((node =3D region.takeLastEventNode()) !=3D null) + while ((node =3D getNextInQueue(queue)) !=3D null) { -// Fqn fqn =3D node.getFqn(); - count++; switch (node.getEventType()) { @@ -179,11 +200,7 @@ } } = - if (trace) - { - log.trace("processed " + count + " node events in region: " + reg= ion.getFqn()); - } - + if (trace) log.trace("processed " + count + " node events"); } = protected void evict(NodeEntry ne) @@ -221,15 +238,11 @@ */ protected boolean evictCacheNode(Fqn fqn) { - if (trace) - { - log.trace("Attempting to evict cache node with fqn of " + fqn); - } + if (trace) log.trace("Attempting to evict cache node with fqn of " += fqn); = - EvictionPolicy policy =3D region.getEvictionPolicy(); try { - policy.evict(fqn); + evictionActionPolicy.evict(fqn); } catch (TimeoutException e) { @@ -280,18 +293,18 @@ } = /** - * Convenience method, which calls {@link #processAddedNodes(EvictedEve= ntNode, int, boolean)} using values in the + * Convenience method, which calls {@link #processAddedNodes(EvictionEv= ent, int)} using values in the * evictedEventNode for number of added elements and the resetElementCo= unt flag. * * @param evictedEventNode an evictedEventNode to process * @throws EvictionException on problems */ - protected void processAddedNodes(EvictedEventNode evictedEventNode) thr= ows EvictionException + protected void processAddedNodes(EvictionEvent evictedEventNode) throws= EvictionException { processAddedNodes(evictedEventNode, evictedEventNode.getElementDiffe= rence()); } = - protected void processAddedNodes(EvictedEventNode evictedEventNode, int= numAddedElements) throws EvictionException + protected void processAddedNodes(EvictionEvent evictedEventNode, int nu= mAddedElements) throws EvictionException { Fqn fqn =3D evictedEventNode.getFqn(); = @@ -342,7 +355,7 @@ * * @throws EvictionException */ - protected void processRemovedNodes(EvictedEventNode evictedEventNode) t= hrows EvictionException + protected void processRemovedNodes(EvictionEvent evictedEventNode) thro= ws EvictionException { Fqn fqn =3D evictedEventNode.getFqn(); = @@ -394,7 +407,7 @@ * * @throws EvictionException */ - protected void processVisitedNodes(EvictedEventNode evictedEventNode) t= hrows EvictionException + protected void processVisitedNodes(EvictionEvent evictedEventNode) thro= ws EvictionException { Fqn fqn =3D evictedEventNode.getFqn(); NodeEntry ne =3D evictionQueue.getNodeEntry(fqn); @@ -414,7 +427,7 @@ ne.setModifiedTimeStamp(evictedEventNode.getCreationTimestamp()); } = - protected void processRemovedElement(EvictedEventNode evictedEventNode)= throws EvictionException + protected void processRemovedElement(EvictionEvent evictedEventNode) th= rows EvictionException { Fqn fqn =3D evictedEventNode.getFqn(); NodeEntry ne =3D evictionQueue.getNodeEntry(fqn); @@ -435,7 +448,7 @@ ne.setModifiedTimeStamp(evictedEventNode.getCreationTimestamp()); } = - protected void processAddedElement(EvictedEventNode evictedEventNode) t= hrows EvictionException + protected void processAddedElement(EvictionEvent evictedEventNode) thro= ws EvictionException { Fqn fqn =3D evictedEventNode.getFqn(); NodeEntry ne =3D evictionQueue.getNodeEntry(fqn); @@ -552,7 +565,6 @@ public String toString() { return super.toString() + - " reqion=3D" + region.getFqn() + " recycle=3D" + recycleQueue.size() + " evict=3D" + evictionQueue.getNumberOfNodes(); } @@ -565,9 +577,9 @@ */ protected boolean isYoungerThanMinimumTimeToLive(NodeEntry entry) { - if (region.getEvictionPolicyConfig() instanceof EvictionPolicyConfig= Base) + if (evictionAlgorithmConfig instanceof EvictionAlgorithmConfigBase) { - EvictionPolicyConfigBase cfg =3D (EvictionPolicyConfigBase) regio= n.getEvictionPolicyConfig(); + EvictionAlgorithmConfigBase cfg =3D (EvictionAlgorithmConfigBase)= evictionAlgorithmConfig; long minTTL =3D cfg.getMinTimeToLive(); return minTTL >=3D 1 && (entry.getModifiedTimeStamp() + minTTL > = System.currentTimeMillis()); } @@ -577,5 +589,4 @@ return false; } } - } Modified: core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionPol= icy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionPolicy.ja= va 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionPolicy.ja= va 2008-08-15 10:59:40 UTC (rev 6562) @@ -9,7 +9,9 @@ * @author Ben Wang 2-2004 * @author Daniel Huang - dhuang(a)jboss.org * @version $Revision$ + * @deprecated see {@link org.jboss.cache.eviction.EvictionActionPolicy} */ +(a)Deprecated public abstract class BaseEvictionPolicy implements EvictionPolicy { protected CacheSPI cache_; @@ -42,7 +44,7 @@ * @see org.jboss.cache.eviction.EvictionPolicy#canIgnoreEvent(org.jboss= .cache.Fqn) * */ - public boolean canIgnoreEvent(Fqn fqn, NodeEventType eventType) + public boolean canIgnoreEvent(Fqn fqn, EvictionEventType eventType) { return false; } Modified: core/trunk/src/main/java/org/jboss/cache/eviction/BaseSortedEvict= ionAlgorithm.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/BaseSortedEvictionAlg= orithm.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/BaseSortedEvictionAlg= orithm.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -8,9 +8,10 @@ = import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.jboss.cache.Region; = +import java.util.concurrent.BlockingQueue; = + /** * An abstract SortedEvictionAlgorithm. *

    @@ -28,19 +29,13 @@ private static final boolean trace =3D log.isTraceEnabled(); = @Override - public void process(Region region) throws EvictionException + protected void processQueues(BlockingQueue queue) throws= EvictionException { - super.process(region); - } - - @Override - protected void processQueues(Region region) throws EvictionException - { boolean evictionNodesModified =3D false; = - EvictedEventNode node; + EvictionEvent node; int count =3D 0; - while ((node =3D region.takeLastEventNode()) !=3D null) + while ((node =3D getNextInQueue(queue)) !=3D null) { count++; switch (node.getEventType()) Added: core/trunk/src/main/java/org/jboss/cache/eviction/DefaultEvictionAct= ionPolicy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/DefaultEvictionAction= Policy.java (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/eviction/DefaultEvictionAction= Policy.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -0,0 +1,37 @@ +package org.jboss.cache.eviction; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.cache.Cache; +import org.jboss.cache.Fqn; + +/** + * Default eviction action policy that calls {@link org.jboss.cache.Cache#= evict(org.jboss.cache.Fqn)} to evict a node. + * + * @author Manik Surtani (manik(a)jbo= ss.org) + * @since 3.0 + */ +public class DefaultEvictionActionPolicy implements EvictionActionPolicy +{ + Cache cache; + private static final Log log =3D LogFactory.getLog(DefaultEvictionActio= nPolicy.class); + + public void setCache(Cache cache) + { + this.cache =3D cache; + } + + public boolean evict(Fqn fqn) + { + try + { + cache.evict(fqn); + return true; + } + catch (Exception e) + { + if (log.isDebugEnabled()) log.debug("Unable to evict " + fqn, e); + return false; + } + } +} Modified: core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgo= rithm.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgorithm.= java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgorithm.= java 2008-08-15 10:59:40 UTC (rev 6562) @@ -6,9 +6,8 @@ */ package org.jboss.cache.eviction; = -import org.jboss.cache.Region; +import org.jboss.cache.config.EvictionAlgorithmConfig; = - /** * @author Daniel Huang * @version $Revision$ @@ -16,7 +15,7 @@ public class ElementSizeAlgorithm extends BaseSortedEvictionAlgorithm { @Override - protected EvictionQueue setupEvictionQueue(Region region) throws Evicti= onException + protected EvictionQueue setupEvictionQueue() throws EvictionException { return new ElementSizeQueue(); } @@ -27,10 +26,8 @@ // check the minimum time to live and see if we should not evict the= node. This check will // ensure that, if configured, nodes are kept alive for at least a m= inimum period of time. if (isYoungerThanMinimumTimeToLive(ne)) return false; - - ElementSizeConfiguration config =3D (ElementSizeConfiguration) regio= n.getEvictionPolicyConfig(); - int size =3D this.getEvictionQueue().getNumberOfNodes(); + ElementSizeAlgorithmConfig config =3D (ElementSizeAlgorithmConfig) e= victionAlgorithmConfig; return config.getMaxNodes() !=3D 0 && size > config.getMaxNodes() ||= ne.getNumberOfElements() > config.getMaxElementsPerNode(); } = @@ -43,4 +40,8 @@ ((ElementSizeQueue) this.evictionQueue).prune(); } = + public Class getConfigurationClass() + { + return ElementSizeAlgorithmConfig.class; + } } Copied: core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgori= thmConfig.java (from rev 6544, core/trunk/src/main/java/org/jboss/cache/evi= ction/ElementSizeConfiguration.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgorithmC= onfig.java (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgorithmC= onfig.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -0,0 +1,110 @@ +/* + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.cache.eviction; + +import org.jboss.cache.config.ConfigurationException; +import org.jboss.cache.config.Dynamic; + +/** + * Configuration for {@link ElementSizeAlgorithm}. + *

    + * Requires a positive "maxElementsPerNode" value otherwise a Configuratio= nException is thrown. + * + * @author Manik Surtani + * @since 3.0 + */ +public class ElementSizeAlgorithmConfig extends EvictionAlgorithmConfigBase +{ + /** + * The serialVersionUID + */ + private static final long serialVersionUID =3D 2510593544656833758L; + + @Dynamic + private int maxElementsPerNode; + + public ElementSizeAlgorithmConfig() + { + evictionAlgorithmClassName =3D ElementSizeAlgorithm.class.getName(); + // Force configuration of maxElementsPerNode + setMaxElementsPerNode(-1); + } + + public ElementSizeAlgorithmConfig(int maxNodes, int maxElementsPerNode) + { + this(); + setMaxNodes(maxNodes); + setMaxElementsPerNode(maxElementsPerNode); + } + + public int getMaxElementsPerNode() + { + return maxElementsPerNode; + } + + public void setMaxElementsPerNode(int maxElementsPerNode) + { + testImmutability("maxElementsPerNode"); + this.maxElementsPerNode =3D maxElementsPerNode; + } + + /** + * Requires a positive maxElementsPerNode value or ConfigurationExcepti= on + * is thrown. + */ + @Override + public void validate() throws ConfigurationException + { + if (maxElementsPerNode < 0) + { + throw new ConfigurationException("maxElementsPerNode must be must= be " + + "configured to a value greater than or equal to 0"); + } + } + + @Override + public String toString() + { + StringBuilder str =3D new StringBuilder(); + str.append("ElementSizeConfiguration: maxElementsPerNode =3D"); + str.append(getMaxElementsPerNode()).append(" maxNodes =3D").append(g= etMaxNodes()); + return str.toString(); + } + + @Override + public boolean equals(Object obj) + { + if (this =3D=3D obj) + return true; + if (obj instanceof ElementSizeAlgorithmConfig && super.equals(obj)) + { + return this.maxElementsPerNode =3D=3D ((ElementSizeAlgorithmConfi= g) obj).maxElementsPerNode; + } + return false; + } + + @Override + public int hashCode() + { + int result =3D super.hashCode(); + result =3D 31 * result + maxElementsPerNode; + return result; + } + + @Override + public void reset() + { + super.reset(); + setMaxElementsPerNode(-1); + } + + @Override + public ElementSizeAlgorithmConfig clone() throws CloneNotSupportedExcep= tion + { + return (ElementSizeAlgorithmConfig) super.clone(); + } +} \ No newline at end of file Modified: core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeConf= iguration.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeConfigurat= ion.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeConfigurat= ion.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -8,7 +8,10 @@ = import org.jboss.cache.config.ConfigurationException; import org.jboss.cache.config.Dynamic; +import org.jboss.cache.config.EvictionAlgorithmConfig; = +import java.util.concurrent.TimeUnit; + /** * Configuration for {@link ElementSizePolicy}. *

    @@ -26,7 +29,9 @@ * @author Daniel Huang * @author Brian Stansberry * @version $Revision$ + * @deprecated see {@link org.jboss.cache.eviction.ElementSizeAlgorithmCon= fig} */ +(a)Deprecated public class ElementSizeConfiguration extends EvictionPolicyConfigBase { /** @@ -50,6 +55,16 @@ setEvictionPolicyClass(ElementSizePolicy.class.getName()); } = + @Override + public EvictionAlgorithmConfig modernize() + { + ElementSizeAlgorithmConfig modernCfg =3D new ElementSizeAlgorithmCon= fig(); + modernCfg.setMaxElementsPerNode(getMaxElementsPerNode()); + modernCfg.setMaxNodes(getMaxNodes()); + modernCfg.setMinTimeToLive(getMinTimeToLiveSeconds(), TimeUnit.SECON= DS); + return modernCfg; + } + public int getMaxElementsPerNode() { return maxElementsPerNode; @@ -116,6 +131,4 @@ { return (ElementSizeConfiguration) super.clone(); } - - } Modified: core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizePoli= cy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizePolicy.jav= a 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizePolicy.jav= a 2008-08-15 10:59:40 UTC (rev 6562) @@ -9,7 +9,9 @@ /** * @author Daniel Huang * @version $Revison: $ + * @deprecated see ElementSizeAlgorithm */ +(a)Deprecated public class ElementSizePolicy extends BaseEvictionPolicy { private ElementSizeAlgorithm algorithm; Deleted: core/trunk/src/main/java/org/jboss/cache/eviction/EvictedEventNode= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/EvictedEventNode.java= 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictedEventNode.java= 2008-08-15 10:59:40 UTC (rev 6562) @@ -1,102 +0,0 @@ -/* - * JBoss, the OpenSource J2EE webOS - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package org.jboss.cache.eviction; - -import org.jboss.cache.Fqn; - -/** - * Value object used in evicted event node queue. - * - * @author Ben Wang 2-2004 - * @author Daniel Huang (dhuang(a)jboss.org) - * @see org.jboss.cache.Region - */ -public class EvictedEventNode -{ - private Fqn fqn; - private NodeEventType type; - private int elementDifference; - - private long inUseTimeout; - private long creationTimestamp; - - public EvictedEventNode(Fqn fqn, NodeEventType type, int elementDiffere= nce) - { - this(fqn, type); - setElementDifference(elementDifference); - } - - public EvictedEventNode(Fqn fqn, NodeEventType event) - { - setFqn(fqn); - setEventType(event); - creationTimestamp =3D System.currentTimeMillis(); - } - - public long getCreationTimestamp() - { - return creationTimestamp; - } - - public long getInUseTimeout() - { - return inUseTimeout; - } - - public void setInUseTimeout(long inUseTimeout) - { - this.inUseTimeout =3D inUseTimeout; - } - - public int getElementDifference() - { - return elementDifference; - } - - public void setElementDifference(int elementDifference_) - { - this.elementDifference =3D elementDifference_; - } - - public Fqn getFqn() - { - return fqn; - } - - public void setFqn(Fqn fqn) - { - this.fqn =3D fqn; - } - - public void setEventType(NodeEventType event) - { - type =3D event; - } - - public NodeEventType getEventType() - { - return type; - } - - @Override - public String toString() - { - return "EvictedEventNode[fqn=3D" + fqn + " event=3D" + type + " diff= =3D" + elementDifference + "]"; - } - - /** - * Copies this evicted event node to create a new one with the same val= ues, except with a new Fqn root. - * - * @param newRoot new Fqn root to use - * @return a new EvictedEventNode instance - * @see org.jboss.cache.Region#copy(org.jboss.cache.Fqn) - */ - public EvictedEventNode copy(Fqn newRoot) - { - return new EvictedEventNode(Fqn.fromRelativeFqn(newRoot, fqn), type,= elementDifference); - } -} Added: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionActionPoli= cy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionActionPolicy.= java (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionActionPolicy.= java 2008-08-15 10:59:40 UTC (rev 6562) @@ -0,0 +1,28 @@ +package org.jboss.cache.eviction; + +import org.jboss.cache.Cache; +import org.jboss.cache.Fqn; + +/** + * Performs an eviction on a given Fqn. + * + * @author Manik Surtani (manik(a)jbo= ss.org) + * @since 3.0 + */ +public interface EvictionActionPolicy +{ + /** + * Sets a reference to the cache. + * + * @param cache cache + */ + void setCache(Cache cache); + + /** + * Performs an eviction on a given node. + * + * @param fqn fqn to evict + * @return true if the eviction was successful, false if not. + */ + boolean evict(Fqn fqn); +} Modified: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorit= hm.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithm.jav= a 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithm.jav= a 2008-08-15 10:59:40 UTC (rev 6562) @@ -1,7 +1,13 @@ package org.jboss.cache.eviction; = -import org.jboss.cache.Region; +import org.jboss.cache.CacheSPI; +import org.jboss.cache.Fqn; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.EvictionAlgorithmConfig; +import org.jboss.cache.eviction.EvictionEvent.Type; = +import java.util.concurrent.BlockingQueue; + /** * Interface for all eviction algorithms. *

    @@ -15,19 +21,17 @@ public interface EvictionAlgorithm { /** - * Entry point for evictin algorithm. This is an api called by the Evic= tionTimerTask - * to process the node events in waiting and actual pruning, if necessa= ry. + * Entry point for eviction algorithm. Invoking this will cause the al= gorithm to process the queue of {@link org.jboss.cache.eviction.EvictionEve= nt} + * passed in. * - * @param region MarshRegion that this algorithm will operate on. + * @param queue to process */ - void process(Region region) throws EvictionException; + void process(BlockingQueue queue) throws EvictionExcepti= on; = /** - * Reset the whole eviction queue. Queue may needs to be reset due to c= orrupted state, for example. - * - * @param region MarshRegion that this algorithm will operate on. + * Reset the whole eviction queue. The queue may need to be reset due t= o corrupted state, for example. */ - void resetEvictionQueue(Region region); + void resetEvictionQueue(); = /** * Get the EvictionQueue implementation used by this algorithm. @@ -36,4 +40,41 @@ */ EvictionQueue getEvictionQueue(); = + /** + * Sets the eviction action policy, so the algorithm knows what to do w= hen a node is to be evicted. + * + * @param evictionActionPolicy to set + */ + void setEvictionActionPolicy(EvictionActionPolicy evictionActionPolicy); + + /** + * Assigns the algorithm instance to a specific region. + * + * @param fqn of the region to be assigned to + * @param cache cache reference + * @param evictionAlgorithmConfig configuration for the current algorit= hm instance. + * @param configuration for the entire cache. + */ + void assignToRegion(Fqn fqn, CacheSPI cache, EvictionAlgorithmCon= fig evictionAlgorithmConfig, Configuration configuration); + + /** + * Tests whether the algorithm would ignore certain event types on cert= ain Fqns. + * + * @param eventType event type to test for + * @return true if the event representing the parameters would be ignor= ed by this algorithm or not. + */ + boolean canIgnoreEvent(Type eventType); + + /** + * Invoked by the region manager when the enclosing region is initializ= ed. + */ + void initialize(); + + /** + * This is a helper so that the XML parser will be able to select and u= se the correct {@link org.jboss.cache.config.EvictionAlgorithmConfig} imple= mentation + * class corresponding to this EvictionAlgorithm. E.g., the {@link FIF= OAlgorithm} would return {@link org.jboss.cache.eviction.FIFOAlgorithmConfi= g}.class. + * + * @return a class that is used to configure this EvictionAlgorithm. + */ + Class getConfigurationClass(); } Added: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithmC= onfigBase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithmConf= igBase.java (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithmConf= igBase.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -0,0 +1,113 @@ +package org.jboss.cache.eviction; + +import org.jboss.cache.config.ConfigurationComponent; +import org.jboss.cache.config.ConfigurationException; +import org.jboss.cache.config.Dynamic; +import org.jboss.cache.config.EvictionAlgorithmConfig; + +import java.util.concurrent.TimeUnit; + +/** + * A base class used for configuring eviction algorithms. + * + * @author Manik Surtani (manik(a)jbo= ss.org) + * @since 3.0 + */ +public abstract class EvictionAlgorithmConfigBase extends ConfigurationCom= ponent implements EvictionAlgorithmConfig +{ + private static final long serialVersionUID =3D 4591691674370188932L; + + protected String evictionAlgorithmClassName; + @Dynamic + protected int maxNodes =3D 0; + @Dynamic + protected long minTimeToLive; + + /** + * Can only be instantiated by a subclass. + */ + protected EvictionAlgorithmConfigBase() + { + } + + public String getEvictionAlgorithmClassName() + { + return evictionAlgorithmClassName; + } + + public int getMaxNodes() + { + return maxNodes; + } + + public void setMaxNodes(int maxNodes) + { + testImmutability("maxNodes"); + this.maxNodes =3D maxNodes; + } + + /** + * @return The minimum time to live, in milliseconds. + */ + public long getMinTimeToLive() + { + return minTimeToLive; + } + + /** + * @param minTimeToLive time to live, in milliseconds + */ + public void setMinTimeToLive(long minTimeToLive) + { + testImmutability("minTimeToLive"); + this.minTimeToLive =3D minTimeToLive; + } + + public void setMinTimeToLive(long time, TimeUnit timeUnit) + { + testImmutability("minTimeToLive"); + minTimeToLive =3D timeUnit.toMillis(time); + } + + public void validate() throws ConfigurationException + { + // no-op + } + + public boolean equals(Object o) + { + if (this =3D=3D o) return true; + if (!(o instanceof EvictionAlgorithmConfigBase)) return false; + + EvictionAlgorithmConfigBase that =3D (EvictionAlgorithmConfigBase) o; + + if (maxNodes !=3D that.maxNodes) return false; + if (minTimeToLive !=3D that.minTimeToLive) return false; + if (evictionAlgorithmClassName !=3D null ? !evictionAlgorithmClassNa= me.equals(that.evictionAlgorithmClassName) : that.evictionAlgorithmClassNam= e !=3D null) + return false; + + return true; + } + + public int hashCode() + { + int result; + result =3D (evictionAlgorithmClassName !=3D null ? evictionAlgorithm= ClassName.hashCode() : 0); + result =3D 31 * result + maxNodes; + result =3D (int) (31 * result + minTimeToLive); + result =3D 31 * result + (int) (minTimeToLive ^ (minTimeToLive >>> 3= 2)); + return result; + } + + public void reset() + { + evictionAlgorithmClassName =3D null; + maxNodes =3D 0; + minTimeToLive =3D 0; + } + + public EvictionAlgorithmConfig clone() throws CloneNotSupportedException + { + return (EvictionAlgorithmConfig) super.clone(); + } +} Copied: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionEvent.jav= a (from rev 6553, core/trunk/src/main/java/org/jboss/cache/eviction/Evicted= EventNode.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionEvent.java = (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionEvent.java 20= 08-08-15 10:59:40 UTC (rev 6562) @@ -0,0 +1,108 @@ +/* + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.cache.eviction; + +import org.jboss.cache.Fqn; + +/** + * An eviction event records activity on nodes in the cache. These are re= corded on a {@link org.jboss.cache.Region} for processing + * later by calls to {@link org.jboss.cache.Region#processEvictionQueues()= }. + *

    + * + * @see org.jboss.cache.Region + */ +public class EvictionEvent +{ + private Fqn fqn; + private Type type; + private int elementDifference; + + private long inUseTimeout; + private long creationTimestamp; + + public static enum Type + { + ADD_NODE_EVENT, + REMOVE_NODE_EVENT, + VISIT_NODE_EVENT, + ADD_ELEMENT_EVENT, + REMOVE_ELEMENT_EVENT, + MARK_IN_USE_EVENT, + UNMARK_USE_EVENT + } + + public EvictionEvent(Fqn fqn, Type type, int elementDifference) + { + this.fqn =3D fqn; + this.type =3D type; + this.elementDifference =3D elementDifference; + this.creationTimestamp =3D System.currentTimeMillis(); + } + + public long getCreationTimestamp() + { + return creationTimestamp; + } + + public long getInUseTimeout() + { + return inUseTimeout; + } + + public void setInUseTimeout(long inUseTimeout) + { + this.inUseTimeout =3D inUseTimeout; + } + + public int getElementDifference() + { + return elementDifference; + } + + public void setElementDifference(int elementDifference) + { + this.elementDifference =3D elementDifference; + } + + public Fqn getFqn() + { + return fqn; + } + + public void setFqn(Fqn fqn) + { + this.fqn =3D fqn; + } + + public void setEventType(Type event) + { + type =3D event; + } + + public Type getEventType() + { + return type; + } + + @Override + public String toString() + { + return "EvictedEventNode[fqn=3D" + fqn + " event=3D" + type + " diff= =3D" + elementDifference + "]"; + } + + /** + * Copies this evicted event node to create a new one with the same val= ues, except with a new Fqn root. + * + * @param newRoot new Fqn root to use + * @return a new EvictedEventNode instance + * @see org.jboss.cache.Region#copy(org.jboss.cache.Fqn) + */ + public EvictionEvent copy(Fqn newRoot) + { + return new EvictionEvent(Fqn.fromRelativeFqn(newRoot, fqn), type, el= ementDifference); + } +} Property changes on: core/trunk/src/main/java/org/jboss/cache/eviction/Evic= tionEvent.java ___________________________________________________________________ Name: svn:executable + * Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Added: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionEventType.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionEventType.jav= a (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionEventType.jav= a 2008-08-15 10:59:40 UTC (rev 6562) @@ -0,0 +1,16 @@ +package org.jboss.cache.eviction; + +/** + * @deprecated left here for old interfaces. Use {@link org.jboss.cache.e= viction.EvictionEvent.Type} instead. + */ +(a)Deprecated +public enum EvictionEventType +{ + @Deprecated ADD_NODE_EVENT, + @Deprecated REMOVE_NODE_EVENT, + @Deprecated VISIT_NODE_EVENT, + @Deprecated ADD_ELEMENT_EVENT, + @Deprecated REMOVE_ELEMENT_EVENT, + @Deprecated MARK_IN_USE_EVENT, + @Deprecated UNMARK_USE_EVENT +} \ No newline at end of file Modified: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionExcepti= on.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionException.jav= a 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionException.jav= a 2008-08-15 10:59:40 UTC (rev 6562) @@ -1,11 +1,13 @@ package org.jboss.cache.eviction; = +import org.jboss.cache.CacheException; + /** * @author Ben Wang, Feb 11, 2004 */ -public class EvictionException extends Exception +public class EvictionException extends CacheException { - = + private static final long serialVersionUID =3D 4006783737166646935L; = public EvictionException() Modified: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicy.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicy.java 2= 008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicy.java 2= 008-08-15 10:59:40 UTC (rev 6562) @@ -18,7 +18,9 @@ * * @author Ben Wang 2-2004 * @author Daniel Huang - dhuang(a)jboss.org - 10/2005 + * @deprecated please use {@link EvictionActionPolicy} instead. */ +(a)Deprecated public interface EvictionPolicy { /** @@ -64,7 +66,7 @@ * This method provides a way to optimize the performance of eviction by * signalling that the node associated with the specified Fqn should no= t be * subject to normal eviction processing. It can also be used to filter - * out certain {@link NodeEventType event types} in which the particular + * out certain {@link EvictionEventType event types} in which the parti= cular * eviction algorithm has no interest. *

    *

    @@ -84,5 +86,5 @@ * @return true to ignore events of this type for this Fqn, * false to process events normally. */ - boolean canIgnoreEvent(Fqn fqn, NodeEventType eventType); + boolean canIgnoreEvent(Fqn fqn, EvictionEventType eventType); } Modified: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicyC= onfigBase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicyConfigB= ase.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicyConfigB= ase.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -3,18 +3,20 @@ import org.jboss.cache.config.ConfigurationComponent; import org.jboss.cache.config.ConfigurationException; import org.jboss.cache.config.Dynamic; +import org.jboss.cache.config.EvictionAlgorithmConfig; import org.jboss.cache.config.EvictionPolicyConfig; -import org.jboss.cache.util.Util; = /** * Base implementation of {@link EvictionPolicyConfig}. Adds properties * for the most commonly used config elements. * * @author Manik Surtani + * @deprecated See {@link org.jboss.cache.eviction.EvictionAlgorithmConfig= Base}. */ +(a)Deprecated public abstract class EvictionPolicyConfigBase extends ConfigurationComponent - implements EvictionPolicyConfig + implements EvictionPolicyConfig, Modernizable { /** * The serialVersionUID @@ -25,15 +27,9 @@ @Dynamic private int maxNodes =3D 0; = - @Deprecated @Dynamic private int minTimeToLiveSeconds =3D 0; = - - /** value expressed in millis */ - @Dynamic - private long minTimeToLive; - /** * Can only be instantiated by a subclass. *

    @@ -66,36 +62,14 @@ this.maxNodes =3D maxNodes; } = - /** value expressed in millis */ - public long getMinTimeToLive() - { - return minTimeToLive; - } - - /** value expressed in millis */ - public void setMinTimeToLive(long minTimeToLive) - { - this.minTimeToLive =3D minTimeToLive; - this.minTimeToLiveSeconds =3D (int)(minTimeToLive / 1000); - } - - /** - * Use {@link #getMinTimeToLive()} - */ - @Deprecated public int getMinTimeToLiveSeconds() { return this.minTimeToLiveSeconds; } = - /** - * Use {@link #setMinTimeToLive(long)} - */ - @Deprecated public void setMinTimeToLiveSeconds(int minTimeToLiveSeconds) { this.minTimeToLiveSeconds =3D minTimeToLiveSeconds; - minTimeToLive =3D minTimeToLiveSeconds * 1000; } = public void validate() throws ConfigurationException @@ -111,7 +85,7 @@ EvictionPolicyConfigBase that =3D (EvictionPolicyConfigBase) o; = if (maxNodes !=3D that.maxNodes) return false; - if (minTimeToLive !=3D that.minTimeToLive) return false; + if (minTimeToLiveSeconds !=3D that.minTimeToLiveSeconds) return fals= e; if (evictionPolicyClass !=3D null ? !evictionPolicyClass.equals(that= .evictionPolicyClass) : that.evictionPolicyClass !=3D null) return false; = @@ -124,7 +98,7 @@ result =3D (evictionPolicyClass !=3D null ? evictionPolicyClass.hash= Code() : 0); result =3D 31 * result + maxNodes; result =3D 31 * result + minTimeToLiveSeconds; - result =3D 31 * result + (int) (minTimeToLive ^ (minTimeToLive >>> 3= 2)); + result =3D 31 * result + (minTimeToLiveSeconds ^ (minTimeToLiveSecon= ds >>> 3)); return result; } = @@ -133,7 +107,7 @@ setEvictionPolicyClass(null); setMaxNodes(0); setMinTimeToLiveSeconds(0); - setMinTimeToLive(0); + setMinTimeToLiveSeconds(0); setEvictionPolicyClassName(); } = @@ -144,4 +118,16 @@ * called in {@link #reset()}. */ abstract protected void setEvictionPolicyClassName(); + + /** + * A factory method that returns a more modernized {@link org.jboss.cac= he.eviction.ExpirationAlgorithmConfig} instance + * corresponding to this deprecated configuration element. It is expec= ted that subclasses of this abstract class + * implement this method as needed, copying elements across accordingly. + * + * @return a new ElementSizeAlgorithmConfig instance with values identi= cal to this current deprecated config. + */ + public EvictionAlgorithmConfig modernize() + { + throw new UnsupportedOperationException("Not supported in this imple= mentation (" + getClass().getName() + ")"); + } } Modified: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionTimerTa= sk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionTimerTask.jav= a 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionTimerTask.jav= a 2008-08-15 10:59:40 UTC (rev 6562) @@ -133,13 +133,9 @@ { synchronized (region) { - final EvictionPolicy policy =3D region.getEvictionPolicy(); - final EvictionAlgorithm algo =3D policy.getEvictionAlgorithm(); - if (algo =3D=3D null) - throw new NullPointerException("algorithm null"); try { - algo.process(region); + region.processEvictionQueues(); } catch (EvictionException e) { Modified: core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgor= ithm.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithm.j= ava 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithm.j= ava 2008-08-15 10:59:40 UTC (rev 6562) @@ -4,11 +4,13 @@ import org.apache.commons.logging.LogFactory; import org.jboss.cache.Fqn; import org.jboss.cache.NodeSPI; -import org.jboss.cache.Region; +import org.jboss.cache.config.EvictionAlgorithmConfig; +import org.jboss.cache.eviction.EvictionEvent.Type; = import java.util.Iterator; import java.util.SortedSet; import java.util.TreeSet; +import java.util.concurrent.BlockingQueue; = /** * Eviction algorithm that uses a key in the Node data that indicates the = time @@ -18,19 +20,19 @@ * java.lang.System#currentTimeMillis()}). *

    * This algorithm also obeys the configuration key {@link - * ExpirationConfiguration#getMaxNodes()}, and will evict the soonest to + * ExpirationAlgorithmConfig#getMaxNodes()}, and will evict the soonest to * expire entires first to reduce the region size. If there are not enough * nodes with expiration keys set, a warning is logged. *

    * If a node in the eviction region does not have an expiration value, then - * {@link org.jboss.cache.eviction.ExpirationConfiguration#getTimeToLive()= } (if set) will be used. + * {@link ExpirationAlgorithmConfig#getTimeToLive()} (if set) will be used. * The expiration is updated when a node is added or updated. *

    * If there is no time-to-live set, and a node in the eviction region does= not * have an expiration value, then that node will never be evicted. As * forgetting to indicate an expiration value is likely a mistake, a warni= ng * message is logged by this class. This warning, however, can be disabled - * through {@link ExpirationConfiguration#setWarnNoExpirationKey(boolean)}. + * through {@link ExpirationAlgorithmConfig#setWarnNoExpirationKey(boolean= )}. *

    * A node's expiration time can be changed by setting a new value in the n= ode. *

    @@ -54,22 +56,19 @@ private static final Log log =3D LogFactory.getLog(ExpirationAlgorithm.= class); private static final boolean trace =3D log.isTraceEnabled(); = - private ExpirationConfiguration config; + private ExpirationAlgorithmConfig config; = - private ExpirationPolicy policy; - private SortedSet set; = /** * Constructs a new algorithm with a policy. */ - public ExpirationAlgorithm(ExpirationPolicy policy) + public ExpirationAlgorithm() { - this.policy =3D policy; this.set =3D new TreeSet(); } = - private void addEvictionEntry(EvictedEventNode node) + private void addEvictionEntry(EvictionEvent node) { Fqn fqn =3D node.getFqn(); addEvictionEntry(fqn); @@ -80,7 +79,7 @@ Long l =3D getExpiration(fqn); if (l =3D=3D null) { - if (config.getWarnNoExpirationKey()) + if (config.isWarnNoExpirationKey() && log.isWarnEnabled()) log.warn("No expiration key '" + config.getExpirationKeyName()= + "' for Node: " + fqn); else if (log.isDebugEnabled()) log.debug("No expiration key for Node: " + fqn); @@ -102,18 +101,18 @@ @SuppressWarnings("unchecked") private Long getExpiration(Fqn fqn) { - NodeSPI n =3D policy.getCache().peek(fqn, false); + NodeSPI n =3D cache.peek(fqn, false); if (n =3D=3D null) return null; - return n.getDirect(config.getExpirationKeyName()); + return (Long) n.getDirect(config.getExpirationKeyName()); } = @Override - protected void processQueues(Region region) throws EvictionException + protected void processQueues(BlockingQueue queue) throws= EvictionException { - EvictedEventNode node; + EvictionEvent node; int count =3D 0; - while ((node =3D region.takeLastEventNode()) !=3D null) + while ((node =3D getNextInQueue(queue)) !=3D null) { count++; switch (node.getEventType()) @@ -139,13 +138,10 @@ } } = - if (trace) - { - log.trace("processed " + count + " node events in region: " + reg= ion.getFqn()); - } + if (trace) log.trace("processed " + count + " node events in region:= " + regionFqn); } = - private void markInUse(EvictedEventNode node) + private void markInUse(EvictionEvent node) { long expiration =3D node.getInUseTimeout() + System.currentTimeMilli= s(); setExpiration(node.getFqn(), expiration); @@ -185,7 +181,7 @@ } = @Override - public void resetEvictionQueue(Region region) + public void resetEvictionQueue() { for (ExpirationEntry ee : set) { @@ -194,10 +190,9 @@ } = @Override - protected EvictionQueue setupEvictionQueue(Region region) throws Evicti= onException + protected EvictionQueue setupEvictionQueue() throws EvictionException { - this.region =3D region; - this.config =3D (ExpirationConfiguration) region.getEvictionPolicyCo= nfig(); + this.config =3D (ExpirationAlgorithmConfig) evictionAlgorithmConfig; return new DummyEvictionQueue(); } = @@ -207,6 +202,17 @@ throw new UnsupportedOperationException(); } = + @Override + public boolean canIgnoreEvent(Type eventType) + { + return (eventType =3D=3D EvictionEvent.Type.VISIT_NODE_EVENT); + } + + public Class getConfigurationClass() + { + return ExpirationAlgorithmConfig.class; + } + /** * Ordered list of FQN, with the expiration taken from the Map at the t= ime * of processing. @@ -345,7 +351,6 @@ { throw new UnsupportedOperationException(); } - } = } Copied: core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorit= hmConfig.java (from rev 6544, core/trunk/src/main/java/org/jboss/cache/evic= tion/ExpirationConfiguration.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithmCo= nfig.java (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithmCo= nfig.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -0,0 +1,123 @@ +package org.jboss.cache.eviction; + +import org.jboss.cache.config.Dynamic; + +import java.util.concurrent.TimeUnit; + +/** + * Configuration for indicating the Node key for setting a specific evicti= on time. + */ +public class ExpirationAlgorithmConfig extends EvictionAlgorithmConfigBase +{ + + private static final long serialVersionUID =3D 47338798734219507L; + + /** + * Default key name for indicating expiration time. + */ + public static final String EXPIRATION_KEY =3D "expiration"; + + /** + * Node key name used to indicate the expiration of a node. + */ + @Dynamic + private String expirationKeyName =3D EXPIRATION_KEY; + + @Dynamic + private boolean warnNoExpirationKey =3D true; + + @Dynamic + private long timeToLive =3D 0; + + public ExpirationAlgorithmConfig() + { + evictionAlgorithmClassName =3D ExpirationAlgorithm.class.getName(); + } + + /** + * Returns the expirationKeyName. + * This key should point to a java.lang.Long value in the Node data. + */ + public String getExpirationKeyName() + { + return expirationKeyName; + } + + /** + * Sets the expirationKeyName. + */ + public void setExpirationKeyName(String expirationKeyName) + { + this.expirationKeyName =3D expirationKeyName; + } + + /** + * Returns true if the algorithm should warn if a expiration key is mis= sing for a node. + */ + public boolean isWarnNoExpirationKey() + { + return warnNoExpirationKey; + } + + /** + * Sets if the algorithm should warn if a expiration key is missing for= a node. + */ + public void setWarnNoExpirationKey(boolean warnNoExpirationKey) + { + this.warnNoExpirationKey =3D warnNoExpirationKey; + } + + /** + * @return time to live, in milliseconds + */ + public long getTimeToLive() + { + return timeToLive; + } + + /** + * Sets the time to live + * + * @param timeToLive value in milliseconds + */ + public void setTimeToLive(long timeToLive) + { + this.timeToLive =3D timeToLive; + } + + public void setTimeToLive(long timeToLive, TimeUnit timeUnit) + { + this.timeToLive =3D timeUnit.toMillis(timeToLive); + } + + @Override + public ExpirationAlgorithmConfig clone() throws CloneNotSupportedExcept= ion + { + return (ExpirationAlgorithmConfig) super.clone(); + } + + public boolean equals(Object o) + { + if (this =3D=3D o) return true; + if (o =3D=3D null || getClass() !=3D o.getClass()) return false; + if (!super.equals(o)) return false; + + ExpirationAlgorithmConfig that =3D (ExpirationAlgorithmConfig) o; + + if (timeToLive !=3D that.timeToLive) return false; + if (warnNoExpirationKey !=3D that.warnNoExpirationKey) return false; + if (expirationKeyName !=3D null ? !expirationKeyName.equals(that.exp= irationKeyName) : that.expirationKeyName !=3D null) + return false; + + return true; + } + + public int hashCode() + { + int result =3D super.hashCode(); + result =3D 31 * result + (expirationKeyName !=3D null ? expirationKe= yName.hashCode() : 0); + result =3D 31 * result + (warnNoExpirationKey ? 1 : 0); + result =3D 31 * result + (int) (timeToLive ^ (timeToLive >>> 32)); + return result; + } +} \ No newline at end of file Modified: core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationConfi= guration.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationConfigurati= on.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationConfigurati= on.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -1,10 +1,16 @@ package org.jboss.cache.eviction; = import org.jboss.cache.config.Dynamic; +import org.jboss.cache.config.EvictionAlgorithmConfig; = +import java.util.concurrent.TimeUnit; + /** * Configuration for indicating the Node key for setting a specific evicti= on time. + * + * @deprecated see {@link org.jboss.cache.eviction.ExpirationAlgorithmConf= ig} */ +(a)Deprecated public class ExpirationConfiguration extends EvictionPolicyConfigBase { = @@ -24,19 +30,27 @@ @Dynamic private boolean warnNoExpirationKey =3D true; = - @Deprecated @Dynamic private int timeToLiveSeconds =3D 0; = - @Dynamic - private long timeToLive =3D 0; - @Override protected void setEvictionPolicyClassName() { setEvictionPolicyClass(ExpirationPolicy.class.getName()); } = + @Override + public EvictionAlgorithmConfig modernize() + { + ExpirationAlgorithmConfig modernCfg =3D new ExpirationAlgorithmConfi= g(); + modernCfg.setExpirationKeyName(getExpirationKeyName()); + modernCfg.setTimeToLive(getTimeToLiveSeconds(), TimeUnit.SECONDS); + modernCfg.setWarnNoExpirationKey(getWarnNoExpirationKey()); + modernCfg.setMaxNodes(getMaxNodes()); + modernCfg.setMinTimeToLive(getMinTimeToLiveSeconds(), TimeUnit.SECON= DS); + return modernCfg; + } + /** * Returns the expirationKeyName. * This key should point to a java.lang.Long value in the Node data. @@ -70,36 +84,14 @@ this.warnNoExpirationKey =3D warnNoExpirationKey; } = - /** value expressed in millis */ - public long getTimeToLive() - { - return timeToLive; - } - - /** value expressed in millis */ - public void setTimeToLive(long timeToLive) - { - this.timeToLive =3D timeToLive; - this.timeToLiveSeconds =3D (int) (timeToLive * 1000); - } - - /** - * Use {@link #getTimeToLive()}. - */ - @Deprecated public int getTimeToLiveSeconds() { return timeToLiveSeconds; } = - /** - * use {@link #setTimeToLive(long)}. - */ - @Deprecated public void setTimeToLiveSeconds(int timeToLiveSeconds) { this.timeToLiveSeconds =3D timeToLiveSeconds; - timeToLive =3D timeToLiveSeconds * 1000; } = @Override @@ -107,6 +99,4 @@ { return (ExpirationConfiguration) super.clone(); } - - } Modified: core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationPolic= y.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationPolicy.java= 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationPolicy.java= 2008-08-15 10:59:40 UTC (rev 6562) @@ -6,7 +6,9 @@ * Returns the {@link ExpirationAlgorithm} as the policy's algorithm. * * @author rosse + * @deprecated see ExpirationAlgorithm */ +(a)Deprecated public class ExpirationPolicy extends BaseEvictionPolicy { = @@ -14,7 +16,7 @@ = public ExpirationPolicy() { - algorithm =3D new ExpirationAlgorithm(this); + algorithm =3D new ExpirationAlgorithm(); } = public EvictionAlgorithm getEvictionAlgorithm() @@ -31,8 +33,8 @@ * Returns true if it's a visit node event. */ @Override - public boolean canIgnoreEvent(Fqn fqn, NodeEventType eventType) + public boolean canIgnoreEvent(Fqn fqn, EvictionEventType eventType) { - return (eventType =3D=3D NodeEventType.VISIT_NODE_EVENT); + return (eventType =3D=3D EvictionEventType.VISIT_NODE_EVENT); } } Modified: core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithm.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithm.java 20= 08-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithm.java 20= 08-08-15 10:59:40 UTC (rev 6562) @@ -8,7 +8,7 @@ = import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.jboss.cache.Region; +import org.jboss.cache.config.EvictionAlgorithmConfig; = /** * First-in-first-out algorithm used to evict nodes. @@ -24,7 +24,7 @@ = = @Override - protected EvictionQueue setupEvictionQueue(Region region) throws Evicti= onException + protected EvictionQueue setupEvictionQueue() throws EvictionException { return new FIFOQueue(); } @@ -39,7 +39,7 @@ // ensure that, if configured, nodes are kept alive for at least a m= inimum period of time. if (isYoungerThanMinimumTimeToLive(ne)) return false; = - FIFOConfiguration config =3D (FIFOConfiguration) region.getEvictionP= olicyConfig(); + FIFOAlgorithmConfig config =3D (FIFOAlgorithmConfig) evictionAlgorit= hmConfig; if (trace) { log.trace("Deciding whether node in queue " + ne.getFqn() + " req= uires eviction."); @@ -48,5 +48,10 @@ int size =3D this.getEvictionQueue().getNumberOfNodes(); return config.getMaxNodes() !=3D 0 && size > config.getMaxNodes(); } + + public Class getConfigurationClass() + { + return FIFOAlgorithmConfig.class; + } } = Copied: core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithmConf= ig.java (from rev 6544, core/trunk/src/main/java/org/jboss/cache/eviction/F= IFOConfiguration.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithmConfig.j= ava (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithmConfig.j= ava 2008-08-15 10:59:40 UTC (rev 6562) @@ -0,0 +1,79 @@ +/* + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.cache.eviction; + +import org.jboss.cache.config.ConfigurationException; + +/** + * Configuration for {@link FIFOAlgorithm}. + *

    + * Requires a "maxNodes" attribute otherwise a ConfigurationException is t= hrown. + * + * @author Manik Surtani + * @since 3.0 + */ +public class FIFOAlgorithmConfig extends EvictionAlgorithmConfigBase +{ + /** + * The serialVersionUID + */ + private static final long serialVersionUID =3D -7229715009546277313L; + + public FIFOAlgorithmConfig() + { + evictionAlgorithmClassName =3D FIFOAlgorithm.class.getName(); + // We require that maxNodes is set + setMaxNodes(-1); + } + + public FIFOAlgorithmConfig(int maxNodes) + { + evictionAlgorithmClassName =3D FIFOAlgorithm.class.getName(); + // We require that maxNodes is set + setMaxNodes(maxNodes); + } + + /** + * Requires a positive maxNodes value or ConfigurationException + * is thrown. + */ + @Override + public void validate() throws ConfigurationException + { + if (getMaxNodes() < 0) + { + throw new ConfigurationException("maxNodes must be must be " + + "configured to a value greater than or equal to 0"); + } + } + + @Override + public String toString() + { + StringBuilder ret =3D new StringBuilder(); + ret.append("FIFOAlgorithmConfig: maxNodes =3D ").append(getMaxNodes(= )); + return ret.toString(); + } + + @Override + public boolean equals(Object obj) + { + return (obj instanceof FIFOAlgorithmConfig && super.equals(obj)); + } + + @Override + public void reset() + { + setMaxNodes(-1); + } + + @Override + public FIFOAlgorithmConfig clone() throws CloneNotSupportedException + { + return (FIFOAlgorithmConfig) super.clone(); + } +} \ No newline at end of file Modified: core/trunk/src/main/java/org/jboss/cache/eviction/FIFOConfigurati= on.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/FIFOConfiguration.jav= a 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/FIFOConfiguration.jav= a 2008-08-15 10:59:40 UTC (rev 6562) @@ -7,7 +7,10 @@ package org.jboss.cache.eviction; = import org.jboss.cache.config.ConfigurationException; +import org.jboss.cache.config.EvictionAlgorithmConfig; = +import java.util.concurrent.TimeUnit; + /** * Configuration for {@link FIFOPolicy}. *

    @@ -23,7 +26,9 @@ * * @author Daniel Huang (dhuang(a)jboss.org) * @version $Revision$ + * @deprecated see {@link org.jboss.cache.eviction.FIFOAlgorithmConfig} */ +(a)Deprecated public class FIFOConfiguration extends EvictionPolicyConfigBase { /** @@ -38,6 +43,15 @@ setMaxNodes(-1); } = + @Override + public EvictionAlgorithmConfig modernize() + { + FIFOAlgorithmConfig modernCfg =3D new FIFOAlgorithmConfig(); + modernCfg.setMaxNodes(getMaxNodes()); + modernCfg.setMinTimeToLive(getMinTimeToLiveSeconds(), TimeUnit.SECON= DS); + return modernCfg; + } + /** * Requires a positive maxNodes value or ConfigurationException * is thrown. Modified: core/trunk/src/main/java/org/jboss/cache/eviction/FIFOPolicy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/FIFOPolicy.java 2008-= 08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/FIFOPolicy.java 2008-= 08-15 10:59:40 UTC (rev 6562) @@ -13,7 +13,9 @@ * @author Daniel Huang (dhuang(a)jboss.org) * @author Morten Kvistgaard * @version $Revision$ + * @deprecated see FIFOAlgorithm */ +(a)Deprecated public class FIFOPolicy extends BaseEvictionPolicy { private FIFOAlgorithm algorithm; Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithm.ja= va =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithm.java 200= 8-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithm.java 200= 8-08-15 10:59:40 UTC (rev 6562) @@ -8,7 +8,7 @@ = import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.jboss.cache.Region; +import org.jboss.cache.config.EvictionAlgorithmConfig; = /** * Least Frequently Used algorithm for cache eviction. @@ -49,7 +49,7 @@ // ensure that, if configured, nodes are kept alive for at least a m= inimum period of time. if (isYoungerThanMinimumTimeToLive(ne)) return false; = - LFUConfiguration config =3D (LFUConfiguration) region.getEvictionPol= icyConfig(); + LFUAlgorithmConfig config =3D (LFUAlgorithmConfig) evictionAlgorithm= Config; int size =3D this.getEvictionQueue().getNumberOfNodes(); if (config.getMaxNodes() !=3D 0 && size > config.getMaxNodes()) { @@ -66,12 +66,11 @@ /** * Will create a LFUQueue to be used as the underlying eviction queue. * - * @param region MarshRegion to create the eviction queue for. * @return The created LFUQueue. * @throws EvictionException */ @Override - protected EvictionQueue setupEvictionQueue(Region region) throws Evicti= onException + protected EvictionQueue setupEvictionQueue() throws EvictionException { return new LFUQueue(); } @@ -84,4 +83,9 @@ // clean up the Queue's eviction removals ((LFUQueue) this.evictionQueue).prune(); } + + public Class getConfigurationClass() + { + return LFUAlgorithmConfig.class; + } } Copied: core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithmConfi= g.java (from rev 6544, core/trunk/src/main/java/org/jboss/cache/eviction/LF= UConfiguration.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithmConfig.ja= va (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithmConfig.ja= va 2008-08-15 10:59:40 UTC (rev 6562) @@ -0,0 +1,81 @@ +/* + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.cache.eviction; + +import org.jboss.cache.config.Dynamic; + +/** + * Configuration implementation for {@link LFUAlgorithm}. + * + * @author Manik Surtani + * @since 3.0 + */ +public class LFUAlgorithmConfig extends EvictionAlgorithmConfigBase +{ + /** + * The serialVersionUID + */ + private static final long serialVersionUID =3D 1865801530398969179L; + + @Dynamic + private int minNodes; + + public LFUAlgorithmConfig() + { + evictionAlgorithmClassName =3D LFUAlgorithm.class.getName(); + } + + public LFUAlgorithmConfig(int maxNodes, int minNodes) + { + this(); + setMaxNodes(maxNodes); + setMinNodes(minNodes); + } + + public int getMinNodes() + { + return minNodes; + } + + public void setMinNodes(int minNodes) + { + testImmutability("minNodes"); + this.minNodes =3D minNodes; + } + + @Override + public String toString() + { + StringBuilder ret =3D new StringBuilder(); + ret.append("LFUAlgorithmConfig: maxNodes =3D ").append(getMaxNodes()= ).append(" minNodes =3D ").append(getMinNodes()); + return ret.toString(); + } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof LFUAlgorithmConfig && super.equals(obj)) + { + return (this.minNodes =3D=3D ((LFUAlgorithmConfig) obj).minNodes); + } + return false; + } + + @Override + public int hashCode() + { + int result =3D super.hashCode(); + result =3D 31 * result + minNodes; + return result; + } + + @Override + public LFUAlgorithmConfig clone() throws CloneNotSupportedException + { + return (LFUAlgorithmConfig) super.clone(); + } +} \ No newline at end of file Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LFUConfiguratio= n.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/LFUConfiguration.java= 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/LFUConfiguration.java= 2008-08-15 10:59:40 UTC (rev 6562) @@ -7,7 +7,10 @@ package org.jboss.cache.eviction; = import org.jboss.cache.config.Dynamic; +import org.jboss.cache.config.EvictionAlgorithmConfig; = +import java.util.concurrent.TimeUnit; + /** * Configuration implementation for {@link LFUPolicy}. *

    @@ -22,7 +25,9 @@ * * @author Daniel Huang (dhuang(a)jboss.org) * @version $Revision$ + * @deprecated see {@link org.jboss.cache.eviction.LFUAlgorithmConfig} */ +(a)Deprecated public class LFUConfiguration extends EvictionPolicyConfigBase { /** @@ -51,6 +56,16 @@ } = @Override + public EvictionAlgorithmConfig modernize() + { + LFUAlgorithmConfig modernCfg =3D new LFUAlgorithmConfig(); + modernCfg.setMaxNodes(getMaxNodes()); + modernCfg.setMinTimeToLive(getMinTimeToLiveSeconds(), TimeUnit.SECON= DS); + modernCfg.setMinNodes(getMinNodes()); + return modernCfg; + } + + @Override public String toString() { StringBuilder ret =3D new StringBuilder(); Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LFUPolicy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/LFUPolicy.java 2008-0= 8-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/LFUPolicy.java 2008-0= 8-15 10:59:40 UTC (rev 6562) @@ -11,7 +11,9 @@ * * @author Daniel Huang - dhuang(a)jboss.org - 10/2005 * @version $Revision$ + * @deprecated see LFUAlgorithm */ +(a)Deprecated public class LFUPolicy extends BaseEvictionPolicy { private LFUAlgorithm algorithm; Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithm.ja= va =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithm.java 200= 8-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithm.java 200= 8-08-15 10:59:40 UTC (rev 6562) @@ -9,7 +9,7 @@ = import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.jboss.cache.Region; +import org.jboss.cache.config.EvictionAlgorithmConfig; = import java.util.Iterator; = @@ -26,7 +26,7 @@ private static final boolean trace =3D log.isTraceEnabled(); = @Override - protected EvictionQueue setupEvictionQueue(Region region) throws Evicti= onException + protected EvictionQueue setupEvictionQueue() throws EvictionException { return new LRUQueue(); } @@ -38,7 +38,7 @@ // ensure that, if configured, nodes are kept alive for at least a m= inimum period of time. if (isYoungerThanMinimumTimeToLive(entry)) return false; = - LRUConfiguration config =3D (LRUConfiguration) region.getEvictionPol= icyConfig(); + LRUAlgorithmConfig config =3D (LRUAlgorithmConfig) evictionAlgorithm= Config; // no idle or max time limit if (config.getTimeToLive() =3D=3D 0 && config.getMaxAge() =3D=3D 0) = return false; = @@ -152,7 +152,7 @@ } } = - int maxNodes =3D this.getConfiguration().getMaxNodes(); + int maxNodes =3D ((LRUAlgorithmConfig) evictionAlgorithmConfig).getM= axNodes(); if (maxNodes <=3D 0) { return; @@ -177,9 +177,8 @@ } } = - protected LRUConfiguration getConfiguration() + public Class getConfigurationClass() { - return (LRUConfiguration) region.getEvictionPolicyConfig(); + return LRUAlgorithmConfig.class; } - } Copied: core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithmConfi= g.java (from rev 6544, core/trunk/src/main/java/org/jboss/cache/eviction/LR= UConfiguration.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithmConfig.ja= va (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithmConfig.ja= va 2008-08-15 10:59:40 UTC (rev 6562) @@ -0,0 +1,166 @@ +/* + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.cache.eviction; + +import org.jboss.cache.config.ConfigurationException; +import org.jboss.cache.config.Dynamic; + +import java.util.concurrent.TimeUnit; + +/** + * Configuration implementation for {@link LRUAlgorithm}. + *

    + * + * @author Manik Surtani + * @since 3.0 + */ +public class LRUAlgorithmConfig extends EvictionAlgorithmConfigBase +{ + /** + * The serialVersionUID + */ + private static final long serialVersionUID =3D -3426716488271559729L; + + /** + * value expressed in millis + */ + @Dynamic + private long timeToLive; + + /** + * value expressed in millis + */ + @Dynamic + private long maxAge; + + public LRUAlgorithmConfig() + { + evictionAlgorithmClassName =3D LRUAlgorithm.class.getName(); + // Force config of ttls + setTimeToLive(-1); + } + + public LRUAlgorithmConfig(long timeToLive, long maxAge) + { + this(); + this.timeToLive =3D timeToLive; + this.maxAge =3D maxAge; + } + + public LRUAlgorithmConfig(int timeToLive, int maxAge, int maxNodes) + { + this(timeToLive, maxAge); + this.maxNodes =3D maxNodes; + } + + /** + * @return the time to live, in milliseconds + */ + public long getTimeToLive() + { + return timeToLive; + } + + /** + * Sets the time to live + * + * @param timeToLive the time to live, in milliseconds + */ + public void setTimeToLive(long timeToLive) + { + testImmutability("timeToLive"); + this.timeToLive =3D timeToLive; + } + + public void setTimeToLive(long timeToLive, TimeUnit timeUnit) + { + testImmutability("timeToLive"); + this.timeToLive =3D timeUnit.toMillis(timeToLive); + } + + /** + * @return the max age per element, in milliseconds + */ + public long getMaxAge() + { + return maxAge; + } + + /** + * Sets the max age per element + * + * @param maxAge value in milliseconds + */ + public void setMaxAge(long maxAge) + { + testImmutability("maxAge"); + this.maxAge =3D maxAge; + } + + public void setMaxAge(long maxAge, TimeUnit timeUnit) + { + testImmutability("maxAge"); + this.maxAge =3D timeUnit.toMillis(maxAge); + } + + /** + * Requires a positive timeToLive value or ConfigurationException + * is thrown. + */ + @Override + public void validate() throws ConfigurationException + { + if (timeToLive < 0) + { + throw new ConfigurationException("timeToLive must be " + + "configured to a value greater than or equal to 0 for " + g= etEvictionAlgorithmClassName()); + } + } + + public String toString() + { + return "LRUAlgorithmConfig {" + + ", timeToLive=3D" + timeToLive + + ", maxAge=3D" + maxAge + + '}'; + } + + public boolean equals(Object o) + { + if (this =3D=3D o) return true; + if (!(o instanceof LRUAlgorithmConfig)) return false; + if (!super.equals(o)) return false; + + LRUAlgorithmConfig that =3D (LRUAlgorithmConfig) o; + + if (maxAge !=3D that.maxAge) return false; + if (timeToLive !=3D that.timeToLive) return false; + + return true; + } + + public int hashCode() + { + int result =3D super.hashCode(); + result =3D 31 * result + (int) (timeToLive ^ (timeToLive >>> 32)); + result =3D 31 * result + (int) (maxAge ^ (maxAge >>> 32)); + return result; + } + + @Override + public void reset() + { + super.reset(); + setTimeToLive(-1); + } + + @Override + public LRUAlgorithmConfig clone() throws CloneNotSupportedException + { + return (LRUAlgorithmConfig) super.clone(); + } +} \ No newline at end of file Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LRUConfiguratio= n.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/LRUConfiguration.java= 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/LRUConfiguration.java= 2008-08-15 10:59:40 UTC (rev 6562) @@ -8,7 +8,10 @@ = import org.jboss.cache.config.ConfigurationException; import org.jboss.cache.config.Dynamic; +import org.jboss.cache.config.EvictionAlgorithmConfig; = +import java.util.concurrent.TimeUnit; + /** * Configuration implementation for {@link LRUPolicy}. *

    @@ -24,7 +27,9 @@ * * @author Daniel Huang (dhuang(a)jboss.org) * @version $Revision$ + * @deprecated see {@link org.jboss.cache.eviction.LRUAlgorithmConfig} */ +(a)Deprecated public class LRUConfiguration extends EvictionPolicyConfigBase { /** @@ -33,33 +38,26 @@ private static final long serialVersionUID =3D -3426716488271559729L; = @Dynamic - @Deprecated private int timeToLiveSeconds; @Dynamic - @Deprecated private int maxAgeSeconds; = - - /** value expressed in millis*/ - @Dynamic - private long timeToLive; - - /** value expressed in millis*/ - @Dynamic - private long maxAge; - public LRUConfiguration() { super(); // Force config of ttls - setTimeToLive(-1); + setTimeToLiveSeconds(-1); } = - public LRUConfiguration(long timeToLive, long maxAge) + @Override + public EvictionAlgorithmConfig modernize() { - super(); - setTimeToLive(timeToLive); - setMaxAge(maxAge); + LRUAlgorithmConfig modernCfg =3D new LRUAlgorithmConfig(); + modernCfg.setMaxNodes(getMaxNodes()); + modernCfg.setMinTimeToLive(getMinTimeToLiveSeconds(), TimeUnit.SECON= DS); + modernCfg.setTimeToLive(getTimeToLiveSeconds(), TimeUnit.SECONDS); + modernCfg.setMaxAge(getMaxAgeSeconds(), TimeUnit.SECONDS); + return modernCfg; } = @Override @@ -68,75 +66,26 @@ setEvictionPolicyClass(LRUPolicy.class.getName()); } = - /** value expressed in millis*/ - public long getTimeToLive() - { - return timeToLive; - } - - /** value expressed in millis*/ - public void setTimeToLive(long timeToLive) - { - testImmutability("timeToLive"); - this.timeToLive =3D timeToLive; - this.timeToLiveSeconds =3D (int)(timeToLive/1000); - } - - /** value expressed in millis*/ - public long getMaxAge() - { - return maxAge; - } - - /** value expressed in millis*/ - public void setMaxAge(long maxAge) - { - testImmutability("maxAge"); - this.maxAge =3D maxAge; - this.maxAgeSeconds =3D (int) (maxAge/1000); - } - - /** - * use {@link #getTimeToLive()} - * @return - */ - @Deprecated public int getTimeToLiveSeconds() { return timeToLiveSeconds; } = - /** - * Use {@link #setTimeToLive(long)} - */ - @Deprecated public void setTimeToLiveSeconds(int timeToLiveSeconds) { testImmutability("timeToLiveSeconds"); this.timeToLiveSeconds =3D timeToLiveSeconds; - timeToLive =3D timeToLiveSeconds * 1000; } = - /** - * Use {@link #getMaxAge()} - * @deprecated = - */ - @Deprecated public int getMaxAgeSeconds() { return maxAgeSeconds; } = - /** - * Use {@link #getMaxAge()} - * @param maxAgeSeconds - */ - @Deprecated public void setMaxAgeSeconds(int maxAgeSeconds) { testImmutability("maxAgeSeconds"); this.maxAgeSeconds =3D maxAgeSeconds; - this.maxAge =3D maxAgeSeconds * 1000; } = /** @@ -146,7 +95,7 @@ @Override public void validate() throws ConfigurationException { - if (timeToLive < 0) + if (timeToLiveSeconds < 0) { throw new ConfigurationException("timeToLive must be " + "configured to a value greater than or equal to 0 for " + g= etEvictionPolicyClass()); @@ -158,8 +107,8 @@ { return "LRUConfiguration{" + "timeToLiveSeconds=3D" + timeToLiveSeconds + - ", timeToLive=3D" + timeToLive + - ", maxAge=3D" + maxAge + + ", timeToLiveSeconds=3D" + timeToLiveSeconds + + ", maxAgeSeconds=3D" + maxAgeSeconds + '}'; } = @@ -171,10 +120,10 @@ = LRUConfiguration that =3D (LRUConfiguration) o; = - if (maxAge !=3D that.maxAge) return false; if (maxAgeSeconds !=3D that.maxAgeSeconds) return false; - if (timeToLive !=3D that.timeToLive) return false; + if (maxAgeSeconds !=3D that.maxAgeSeconds) return false; if (timeToLiveSeconds !=3D that.timeToLiveSeconds) return false; + if (timeToLiveSeconds !=3D that.timeToLiveSeconds) return false; = return true; } @@ -184,8 +133,8 @@ int result =3D super.hashCode(); result =3D 31 * result + timeToLiveSeconds; result =3D 31 * result + maxAgeSeconds; - result =3D 31 * result + (int) (timeToLive ^ (timeToLive >>> 32)); - result =3D 31 * result + (int) (maxAge ^ (maxAge >>> 32)); + result =3D 31 * result + (timeToLiveSeconds ^ (timeToLiveSeconds >>>= 7)); + result =3D 31 * result + (maxAgeSeconds ^ (maxAgeSeconds >>> 7)); return result; } = @@ -193,7 +142,7 @@ public void reset() { super.reset(); - setTimeToLive(-1); + setTimeToLiveSeconds(-1); } = @Override Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LRUPolicy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/LRUPolicy.java 2008-0= 8-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/LRUPolicy.java 2008-0= 8-15 10:59:40 UTC (rev 6562) @@ -17,7 +17,9 @@ * @author Ben Wang 02-2004 * @author Daniel Huang - dhuang(a)jboss.org * @version $Revision$ + * @deprecated see LRUAlgorithm */ +(a)Deprecated public class LRUPolicy extends BaseEvictionPolicy { protected RegionManager regionManager_; Modified: core/trunk/src/main/java/org/jboss/cache/eviction/MRUAlgorithm.ja= va =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/MRUAlgorithm.java 200= 8-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/MRUAlgorithm.java 200= 8-08-15 10:59:40 UTC (rev 6562) @@ -6,7 +6,7 @@ */ package org.jboss.cache.eviction; = -import org.jboss.cache.Region; +import org.jboss.cache.config.EvictionAlgorithmConfig; = /** * Most Recently Used Algorithm. @@ -22,7 +22,7 @@ public class MRUAlgorithm extends BaseEvictionAlgorithm { @Override - protected EvictionQueue setupEvictionQueue(Region region) throws Evicti= onException + protected EvictionQueue setupEvictionQueue() throws EvictionException { return new MRUQueue(); } @@ -34,14 +34,19 @@ // ensure that, if configured, nodes are kept alive for at least a m= inimum period of time. if (isYoungerThanMinimumTimeToLive(ne)) return false; = - MRUConfiguration config =3D (MRUConfiguration) region.getEvictionPol= icyConfig(); + MRUAlgorithmConfig config =3D (MRUAlgorithmConfig) evictionAlgorithm= Config; return evictionQueue.getNumberOfNodes() > config.getMaxNodes(); } = @Override - protected void processVisitedNodes(EvictedEventNode evictedEventNode) t= hrows EvictionException + protected void processVisitedNodes(EvictionEvent evictedEventNode) thro= ws EvictionException { super.processVisitedNodes(evictedEventNode); ((MRUQueue) evictionQueue).moveToTopOfStack(evictedEventNode.getFqn(= )); } + + public Class getConfigurationClass() + { + return MRUAlgorithmConfig.class; + } } Copied: core/trunk/src/main/java/org/jboss/cache/eviction/MRUAlgorithmConfi= g.java (from rev 6552, core/trunk/src/main/java/org/jboss/cache/eviction/MR= UConfiguration.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/MRUAlgorithmConfig.ja= va (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/eviction/MRUAlgorithmConfig.ja= va 2008-08-15 10:59:40 UTC (rev 6562) @@ -0,0 +1,77 @@ +/* + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.cache.eviction; + +import org.jboss.cache.config.ConfigurationException; + +/** + * Configuration for {@link MRUAlgorithm}. + *

    + * Requires a "maxNodes" attribute otherwise a ConfigurationException is t= hrown. + * + * @author Manik Surtani + * @since 3.0 + */ +public class MRUAlgorithmConfig extends EvictionAlgorithmConfigBase +{ + /** + * The serialVersionUID + */ + private static final long serialVersionUID =3D -8734577898966155218L; + + public MRUAlgorithmConfig() + { + evictionAlgorithmClassName =3D MRUAlgorithm.class.getName(); + // We require that maxNodes is set + setMaxNodes(-1); + } + + public MRUAlgorithmConfig(int maxNodes) + { + evictionAlgorithmClassName =3D MRUAlgorithm.class.getName(); + setMaxNodes(maxNodes); + } + + /** + * Requires a positive maxNodes value or ConfigurationException + * is thrown. + */ + @Override + public void validate() throws ConfigurationException + { + if (getMaxNodes() < 0) + throw new ConfigurationException("maxNodes not configured"); + } + + @Override + public String toString() + { + StringBuilder str =3D new StringBuilder(); + str.append("MRUAlgorithmConfig: "). + append(" maxNodes =3D").append(getMaxNodes()); + return str.toString(); + } + + @Override + public boolean equals(Object obj) + { + return (obj instanceof MRUAlgorithmConfig && super.equals(obj)); + } + + @Override + public void reset() + { + setMaxNodes(-1); + } + + @Override + public MRUAlgorithmConfig clone() throws CloneNotSupportedException + { + return (MRUAlgorithmConfig) super.clone(); + } + +} \ No newline at end of file Modified: core/trunk/src/main/java/org/jboss/cache/eviction/MRUConfiguratio= n.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/MRUConfiguration.java= 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/MRUConfiguration.java= 2008-08-15 10:59:40 UTC (rev 6562) @@ -7,7 +7,10 @@ package org.jboss.cache.eviction; = import org.jboss.cache.config.ConfigurationException; +import org.jboss.cache.config.EvictionAlgorithmConfig; = +import java.util.concurrent.TimeUnit; + /** * Configuration for {@link MRUPolicy}. *

    @@ -23,7 +26,9 @@ * * @author Daniel Huang (dhuang(a)jboss.org) * @version $Revision$ + * @deprecated see {@link org.jboss.cache.eviction.MRUAlgorithmConfig} */ +(a)Deprecated public class MRUConfiguration extends EvictionPolicyConfigBase { /** @@ -44,7 +49,16 @@ setEvictionPolicyClass(MRUPolicy.class.getName()); } = + @Override + public EvictionAlgorithmConfig modernize() + { + MRUAlgorithmConfig modernCfg =3D new MRUAlgorithmConfig(); + modernCfg.setMaxNodes(getMaxNodes()); + modernCfg.setMinTimeToLive(getMinTimeToLiveSeconds(), TimeUnit.SECON= DS); + return modernCfg; + } = + /** * Requires a positive maxNodes value or ConfigurationException * is thrown. Modified: core/trunk/src/main/java/org/jboss/cache/eviction/MRUPolicy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/MRUPolicy.java 2008-0= 8-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/MRUPolicy.java 2008-0= 8-15 10:59:40 UTC (rev 6562) @@ -13,7 +13,9 @@ * * @author Daniel Huang (dhuang(a)jboss.org) * @version $Revision$ + * @deprecated see MRUAlgorithm */ +(a)Deprecated public class MRUPolicy extends BaseEvictionPolicy { private MRUAlgorithm algorithm; Added: core/trunk/src/main/java/org/jboss/cache/eviction/Modernizable.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/Modernizable.java = (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/eviction/Modernizable.java 200= 8-08-15 10:59:40 UTC (rev 6562) @@ -0,0 +1,17 @@ +package org.jboss.cache.eviction; + +import org.jboss.cache.config.EvictionAlgorithmConfig; + +/** + * Attached to deprecated eviction configuration elements that know how to= map to modern counterparts. This interface + * is itself deprecated and is only used to bridge deprecated configuratio= ns. + * + * @author Manik Surtani (manik(a)jbo= ss.org) + * @since 3.0 + * @deprecated + */ +(a)Deprecated +public interface Modernizable +{ + EvictionAlgorithmConfig modernize(); +} Deleted: core/trunk/src/main/java/org/jboss/cache/eviction/NodeEventType.ja= va =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/NodeEventType.java 20= 08-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/NodeEventType.java 20= 08-08-15 10:59:40 UTC (rev 6562) @@ -1,40 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2006, Red Hat Middleware LLC, and individual contributors - * as indicated by the @author tags. See the copyright.txt file in the - * distribution for a full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.jboss.cache.eviction; - -/** - * Enumeration of the valid event types used to create an - * {@link org.jboss.cache.eviction.EvictedEventNode}. - * - * @author Brian Stansberry - * @version $Revision$ - */ -public enum NodeEventType -{ - ADD_NODE_EVENT, - REMOVE_NODE_EVENT, - VISIT_NODE_EVENT, - ADD_ELEMENT_EVENT, - REMOVE_ELEMENT_EVENT, - MARK_IN_USE_EVENT, - UNMARK_USE_EVENT -} Modified: core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionAlg= orithm.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionAlgorithm= .java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionAlgorithm= .java 2008-08-15 10:59:40 UTC (rev 6562) @@ -1,27 +1,40 @@ /** - * = + * */ package org.jboss.cache.eviction; = -import org.jboss.cache.Region; +import org.jboss.cache.CacheSPI; +import org.jboss.cache.Fqn; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.EvictionAlgorithmConfig; +import org.jboss.cache.eviction.EvictionEvent.Type; = +import java.util.concurrent.BlockingQueue; + /** - * Algorithm for {@link NullEvictionPolicy}. - * = + * An eviction algorithm that does nothing - a no-op for everything. + * * @author Brian Stansberry */ public class NullEvictionAlgorithm implements EvictionAlgorithm { - /** Singleton instance of this class. */ - public static final NullEvictionAlgorithm INSTANCE =3D new NullEviction= Algorithm(); - = /** + * Singleton instance of this class. + */ + private static final NullEvictionAlgorithm INSTANCE =3D new NullEvictio= nAlgorithm(); + + /** * Constructs a new NullEvictionAlgorithm. */ private NullEvictionAlgorithm() { } = + public static NullEvictionAlgorithm getInstance() + { + return INSTANCE; + } + /** * Returns {@link NullEvictionQueue#INSTANCE}. */ @@ -30,16 +43,38 @@ return NullEvictionQueue.INSTANCE; } = - /** No-op */ - public void process(Region region) throws EvictionException + public void setEvictionActionPolicy(EvictionActionPolicy evictionAction= Policy) { // no-op } = - /** No-op */ - public void resetEvictionQueue(Region region) + public void assignToRegion(Fqn fqn, CacheSPI cache, EvictionAlgor= ithmConfig evictionAlgorithmConfig, Configuration configuration) { // no-op } = + public void process(BlockingQueue queue) throws Eviction= Exception + { + // no-op + } + + public void resetEvictionQueue() + { + // no-op + } + + public boolean canIgnoreEvent(Type eventType) + { + return true; // always ignore everything! + } + + public void initialize() + { + // no-op + } + + public Class getConfigurationClass() + { + return NullEvictionAlgorithmConfig.class; + } } Copied: core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionAlgor= ithmConfig.java (from rev 6552, core/trunk/src/main/java/org/jboss/cache/ev= iction/NullEvictionPolicyConfig.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionAlgorithm= Config.java (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionAlgorithm= Config.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -0,0 +1,45 @@ +/** + * + */ +package org.jboss.cache.eviction; + +import org.jboss.cache.config.ConfigurationComponent; +import org.jboss.cache.config.ConfigurationException; +import org.jboss.cache.config.EvictionAlgorithmConfig; + +/** + * Configuration class for {@link NullEvictionAlgorithm}. + * + * @author Manik Surtani + * @since 3.0 + */ +public class NullEvictionAlgorithmConfig extends ConfigurationComponent im= plements EvictionAlgorithmConfig +{ + private static final long serialVersionUID =3D -6591180473728241737L; + + /** + * No-op + */ + public void reset() + { + // no-op + } + + public String getEvictionAlgorithmClassName() + { + return NullEvictionAlgorithm.class.getName(); + } + + /** + * No-op + */ + public void validate() throws ConfigurationException + { + // no-op + } + + public NullEvictionAlgorithmConfig clone() throws CloneNotSupportedExce= ption + { + return (NullEvictionAlgorithmConfig) super.clone(); + } +} \ No newline at end of file Property changes on: core/trunk/src/main/java/org/jboss/cache/eviction/Null= EvictionAlgorithmConfig.java ___________________________________________________________________ Name: svn:executable + * Modified: core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPol= icy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicy.ja= va 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicy.ja= va 2008-08-15 10:59:40 UTC (rev 6562) @@ -18,7 +18,9 @@ * want eviction. * * @author Brian Stansberry + * @deprecated see NullEvictionAlgorithm */ +(a)Deprecated public class NullEvictionPolicy implements EvictionPolicy { private static final Log log =3D LogFactory.getLog(NullEvictionPolicy.c= lass); @@ -28,7 +30,7 @@ /** * Returns true */ - public boolean canIgnoreEvent(Fqn fqn, NodeEventType eventType) + public boolean canIgnoreEvent(Fqn fqn, EvictionEventType eventType) { return true; } @@ -46,7 +48,7 @@ */ public EvictionAlgorithm getEvictionAlgorithm() { - return NullEvictionAlgorithm.INSTANCE; + return NullEvictionAlgorithm.getInstance(); } = /** Modified: core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPol= icyConfig.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicyCon= fig.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicyCon= fig.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -5,16 +5,19 @@ = import org.jboss.cache.config.ConfigurationComponent; import org.jboss.cache.config.ConfigurationException; +import org.jboss.cache.config.EvictionAlgorithmConfig; import org.jboss.cache.config.EvictionPolicyConfig; = /** * Configuration class for {@link NullEvictionPolicy}. * * @author Brian Stansberry + * @deprecated see {@link NullEvictionAlgorithmConfig} */ +(a)Deprecated public class NullEvictionPolicyConfig extends ConfigurationComponent - implements EvictionPolicyConfig + implements EvictionPolicyConfig, Modernizable { = private static final long serialVersionUID =3D -6591180473728241737L; @@ -27,6 +30,11 @@ return NullEvictionPolicy.class.getName(); } = + public EvictionAlgorithmConfig modernize() + { + return new NullEvictionAlgorithmConfig(); + } + /** * No-op */ @@ -42,5 +50,4 @@ { // no-op } - } Added: core/trunk/src/main/java/org/jboss/cache/eviction/RemoveOnEvictActio= nPolicy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/RemoveOnEvictActionPo= licy.java (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/eviction/RemoveOnEvictActionPo= licy.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -0,0 +1,36 @@ +package org.jboss.cache.eviction; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.cache.Cache; +import org.jboss.cache.Fqn; + +/** + * An eviction action policy that calls {@link org.jboss.cache.Cache#remov= eNode(org.jboss.cache.Fqn)} to evict a node. + * + * @author Manik Surtani (manik(a)jbo= ss.org) + * @since 3.0 + */ +public class RemoveOnEvictActionPolicy implements EvictionActionPolicy +{ + Cache cache; + private static final Log log =3D LogFactory.getLog(DefaultEvictionActio= nPolicy.class); + + public void setCache(Cache cache) + { + this.cache =3D cache; + } + + public boolean evict(Fqn fqn) + { + try + { + return cache.removeNode(fqn); + } + catch (Exception e) + { + if (log.isDebugEnabled()) log.debug("Unable to evict " + fqn, e); + return false; + } + } +} \ No newline at end of file Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/BuddyRegion= AwareEvictionInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/BuddyRegionAwareE= victionInterceptor.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/BuddyRegionAwareE= victionInterceptor.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -2,9 +2,8 @@ = import org.jboss.cache.Fqn; import org.jboss.cache.Region; -import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.buddyreplication.BuddyFqnTransformer; -import org.jboss.cache.eviction.NodeEventType; +import org.jboss.cache.factories.annotations.Inject; = /** * A subclass of EvictionInterceptor that is aware of and able to deal wit= h buddy regions. @@ -23,9 +22,9 @@ } = @Override - protected Region getRegion(Fqn fqn, NodeEventType type) + protected Region getRegion(Fqn fqn) { - Region r =3D super.getRegion(fqn, type); + Region r =3D super.getRegion(fqn); if (r !=3D null) return r; else if (buddyFqnTransformer.isBackupFqn(fqn)) @@ -41,7 +40,7 @@ = //create a new region for this backup Region newRegion =3D regionManager.getRegion(Fqn.fromRelativeFqn(= backupRoot, actualRegion.getFqn()), Region.Type.EVICTION, true); - newRegion.setEvictionPolicy(actualRegion.getEvictionPolicyConfig(= )); + newRegion.setEvictionRegionConfig(actualRegion.getEvictionRegionC= onfig()); = return newRegion; } Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInt= erceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionIntercept= or.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionIntercept= or.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -21,8 +21,8 @@ import org.jboss.cache.commands.write.PutKeyValueCommand; import org.jboss.cache.commands.write.RemoveKeyCommand; import org.jboss.cache.commands.write.RemoveNodeCommand; -import org.jboss.cache.eviction.EvictedEventNode; -import org.jboss.cache.eviction.NodeEventType; +import org.jboss.cache.eviction.EvictionEvent; +import static org.jboss.cache.eviction.EvictionEvent.Type.*; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.interceptors.base.CommandInterceptor; import org.jboss.cache.invocation.InvocationContext; @@ -71,9 +71,9 @@ if (!complete) { Region r; - if (fqn !=3D null && (r =3D getRegion(fqn, NodeEventType.ADD_NODE= _EVENT)) !=3D null) + if (fqn !=3D null && (r =3D getRegion(fqn)) !=3D null) { - registerEvictionEventToRegionManager(new EvictedEventNode(fqn,= NodeEventType.ADD_NODE_EVENT, 0), r); + registerEvictionEventToRegionManager(fqn, ADD_NODE_EVENT, 0, r= ); } } return retVal; @@ -90,9 +90,9 @@ { Object retVal =3D invokeNextInterceptor(ctx, command); Region r; - if (command.getFqn() !=3D null && command.getKey() !=3D null && (r = =3D getRegion(command.getFqn(), NodeEventType.ADD_ELEMENT_EVENT)) !=3D null) + if (command.getFqn() !=3D null && command.getKey() !=3D null && (r = =3D getRegion(command.getFqn())) !=3D null) { - registerEvictionEventToRegionManager(new EvictedEventNode(command= .getFqn(), NodeEventType.ADD_ELEMENT_EVENT, 1), r); + registerEvictionEventToRegionManager(command.getFqn(), ADD_ELEMEN= T_EVENT, 1, r); } return retVal; } @@ -103,7 +103,7 @@ Object retVal =3D invokeNextInterceptor(ctx, command); Fqn fqn =3D command.getFqn(); Region r; - if (fqn !=3D null && (r =3D getRegion(fqn, NodeEventType.ADD_NODE_EV= ENT)) !=3D null) + if (fqn !=3D null && (r =3D getRegion(fqn)) !=3D null) { if (command.getData() =3D=3D null) { @@ -119,8 +119,7 @@ { size =3D command.getData().size(); } - EvictedEventNode event =3D new EvictedEventNode(fqn, NodeEvent= Type.ADD_NODE_EVENT, size); - registerEvictionEventToRegionManager(event, r); + registerEvictionEventToRegionManager(fqn, ADD_NODE_EVENT, size= , r); } } return retVal; @@ -142,9 +141,9 @@ { Fqn fqn =3D command.getFqn(); Region r; - if (fqn !=3D null && command.getKey() !=3D null && (r =3D getRegi= on(fqn, NodeEventType.REMOVE_ELEMENT_EVENT)) !=3D null) + if (fqn !=3D null && command.getKey() !=3D null && (r =3D getRegi= on(fqn)) !=3D null) { - registerEvictionEventToRegionManager(new EvictedEventNode(fqn,= NodeEventType.REMOVE_ELEMENT_EVENT, 1), r); + registerEvictionEventToRegionManager(fqn, REMOVE_ELEMENT_EVENT= , 1, r); } } return retVal; @@ -169,9 +168,9 @@ else { Region r; - if (fqn !=3D null && (r =3D getRegion(fqn, NodeEventType.VISIT_NO= DE_EVENT)) !=3D null) + if (fqn !=3D null && (r =3D getRegion(fqn)) !=3D null) { - registerEvictionEventToRegionManager(new EvictedEventNode(fqn,= NodeEventType.VISIT_NODE_EVENT), r); + registerEvictionEventToRegionManager(fqn, VISIT_NODE_EVENT, 0,= r); } } return retVal; @@ -197,9 +196,9 @@ log.trace("No event added. Element does not exist"); } } - else if (fqn !=3D null && command.getKey() !=3D null && (r =3D getRe= gion(fqn, NodeEventType.VISIT_NODE_EVENT)) !=3D null) + else if (fqn !=3D null && command.getKey() !=3D null && (r =3D getRe= gion(fqn)) !=3D null) { - registerEvictionEventToRegionManager(new EvictedEventNode(fqn, No= deEventType.VISIT_NODE_EVENT), r); + registerEvictionEventToRegionManager(fqn, VISIT_NODE_EVENT, 0, r); } return retVal; } @@ -209,9 +208,9 @@ { Object retVal =3D invokeNextInterceptor(ctx, command); Region r; - if (command.getFqn() !=3D null && (r =3D getRegion(command.getFqn(),= NodeEventType.REMOVE_NODE_EVENT)) !=3D null) + if (command.getFqn() !=3D null && (r =3D getRegion(command.getFqn())= ) !=3D null) { - registerEvictionEventToRegionManager(new EvictedEventNode(command= .getFqn(), NodeEventType.REMOVE_NODE_EVENT), r); + registerEvictionEventToRegionManager(command.getFqn(), REMOVE_NOD= E_EVENT, 0, r); } return retVal; } @@ -221,41 +220,25 @@ { Object retVal =3D invokeNextInterceptor(ctx, command); Region r; - if (command.getFqn() !=3D null && (r =3D getRegion(command.getFqn(),= NodeEventType.REMOVE_NODE_EVENT)) !=3D null) + if (command.getFqn() !=3D null && (r =3D getRegion(command.getFqn())= ) !=3D null) { - registerEvictionEventToRegionManager(new EvictedEventNode(command= .getFqn(), NodeEventType.REMOVE_NODE_EVENT), r); + registerEvictionEventToRegionManager(command.getFqn(), REMOVE_NOD= E_EVENT, 0, r); } return retVal; } = - private void registerEvictionEventToRegionManager(EvictedEventNode even= t, Region region) + private void registerEvictionEventToRegionManager(Fqn fqn, EvictionEven= t.Type type, int elementDifference, Region region) { - if (event =3D=3D null) - { - // no node modifications. - return; - } - //we do not trigger eviction events for resident nodes - if (dataContainer.isResident(event.getFqn())) return; + if (dataContainer.isResident(fqn)) return; = - region.putNodeEvent(event); + region.registerEvictionEvent(fqn, type, elementDifference); = - if (trace) - { - log.trace("Adding event " + event + " to region at " + region.get= Fqn()); - } - - if (trace) - { - log.trace("Finished updating node"); - } + if (trace) log.trace("Registering event " + type + " on node " + fqn= ); } = - protected Region getRegion(Fqn fqn, NodeEventType type) + protected Region getRegion(Fqn fqn) { - Region r =3D regionManager.getRegion(fqn, Region.Type.EVICTION, fals= e); - if (r !=3D null && r.getEvictionPolicy().canIgnoreEvent(fqn, type)) = return null; - return r; + return regionManager.getRegion(fqn, Region.Type.EVICTION, false); } } Modified: core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStat= eTransferIntegrator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStateTrans= ferIntegrator.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStateTrans= ferIntegrator.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -17,8 +17,7 @@ import org.jboss.cache.Region; import org.jboss.cache.buddyreplication.BuddyManager; import org.jboss.cache.config.Configuration; -import org.jboss.cache.eviction.EvictedEventNode; -import org.jboss.cache.eviction.NodeEventType; +import org.jboss.cache.eviction.EvictionEvent; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; import org.jboss.cache.invocation.InvocationContext; @@ -307,10 +306,9 @@ parent.addChild(fqn.getLastElement(), target); // JBCACHE-913 Region region =3D cache.getRegion(fqn, false); - if (region !=3D null && region.getEvictionPolicy() !=3D null) + if (region !=3D null && region.getEvictionRegionConfig() !=3D = null) { - region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType= .ADD_NODE_EVENT, - attrs =3D=3D null ? 0 : attrs.size())); + region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NO= DE_EVENT, attrs =3D=3D null ? 0 : attrs.size()); } } = Modified: core/trunk/src/main/java/org/jboss/cache/util/Util.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/util/Util.java 2008-08-14 19:1= 6:15 UTC (rev 6561) +++ core/trunk/src/main/java/org/jboss/cache/util/Util.java 2008-08-15 10:5= 9:40 UTC (rev 6562) @@ -21,6 +21,7 @@ */ package org.jboss.cache.util; = +import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; = @@ -52,6 +53,32 @@ return cl.loadClass(classname); } = + @SuppressWarnings("unchecked") + public static T getInstance(Class clazz) throws Exception + { + // first look for a getInstance() constructor + T instance; + try + { + Method factoryMethod =3D clazz.getMethod("getInstance", new Class= []{}); + instance =3D (T) factoryMethod.invoke(null); + } + catch (Exception e) + { + // no factory method or factory method failed. Try a constructor. + instance =3D clazz.newInstance(); + } + return instance; + } + + @SuppressWarnings("unchecked") + public static Object getInstance(String classname) throws Exception + { + if (classname =3D=3D null) throw new IllegalArgumentException("Canno= t load null class!"); + Class clazz =3D loadClass(classname); + return getInstance(clazz); + } + /** * Prevent instantiation */ @@ -158,5 +185,4 @@ return "Added Entries " + addedEntries + " Removeed Entries " + r= emovedEntries + " Modified Entries " + modifiedEntries; } } - } Modified: core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.ja= va =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java 200= 8-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java 200= 8-08-15 10:59:40 UTC (rev 6562) @@ -7,7 +7,7 @@ import org.jboss.cache.config.Configuration; import org.jboss.cache.config.EvictionConfig; import org.jboss.cache.config.EvictionRegionConfig; -import org.jboss.cache.eviction.LRUConfiguration; +import org.jboss.cache.eviction.LRUAlgorithmConfig; import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; import org.jboss.cache.util.internals.EvictionController; import static org.testng.Assert.*; @@ -53,12 +53,12 @@ EvictionRegionConfig evRegConfig =3D new EvictionRegionConfig(); evRegConfig.setRegionFqn(Fqn.fromString("/" + TEST_NODES_ROOT)); evRegConfig.setEventQueueSize(100); - LRUConfiguration lruConfig =3D new LRUConfiguration(); + LRUAlgorithmConfig lruConfig =3D new LRUAlgorithmConfig(); lruConfig.setMaxAge(100000000); lruConfig.setTimeToLive(100000000); lruConfig.setMaxNodes(3); - evRegConfig.setEvictionPolicyConfig(lruConfig); - evConfig.getEvictionRegionConfigs().add(evRegConfig); + evRegConfig.setEvictionAlgorithmConfig(lruConfig); + evConfig.addEvictionRegionConfig(evRegConfig); //end setting up region stuff } = Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyRe= plicationWithCacheLoaderTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicat= ionWithCacheLoaderTest.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicat= ionWithCacheLoaderTest.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -13,7 +13,7 @@ import org.jboss.cache.config.Configuration; import org.jboss.cache.config.EvictionConfig; import org.jboss.cache.config.EvictionRegionConfig; -import org.jboss.cache.eviction.LRUConfiguration; +import org.jboss.cache.eviction.LRUAlgorithmConfig; import org.jboss.cache.loader.CacheLoader; import org.jboss.cache.util.TestingUtil; import static org.jboss.cache.util.TestingUtil.dumpCacheContents; @@ -345,15 +345,13 @@ EvictionConfig ec =3D new EvictionConfig(); ec.setWakeupInterval(1000); EvictionRegionConfig erc =3D new EvictionRegionConfig(); - erc.setRegionName("/_default_"); - LRUConfiguration epc =3D new LRUConfiguration(); - epc.setMaxAge(2000); - epc.setTimeToLive(1000); - epc.setMaxNodes(1); - erc.setEvictionPolicyConfig(epc); - List ercs =3D new ArrayList(); - ercs.add(erc); - ec.setEvictionRegionConfigs(ercs); + erc.setRegionFqn(Fqn.ROOT); + LRUAlgorithmConfig lruAlgorithmConfig =3D new LRUAlgorithmConfig(); + lruAlgorithmConfig.setMaxAge(2000); + lruAlgorithmConfig.setTimeToLive(1000); + lruAlgorithmConfig.setMaxNodes(1); + erc.setEvictionAlgorithmConfig(lruAlgorithmConfig); + ec.setDefaultEvictionRegionConfig(erc); cfg.setEvictionConfig(ec); } = Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/Evictio= nOfBuddyBackupsTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/buddyreplication/EvictionOfBud= dyBackupsTest.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/EvictionOfBud= dyBackupsTest.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -5,15 +5,13 @@ import org.jboss.cache.Fqn; import org.jboss.cache.config.EvictionConfig; import org.jboss.cache.config.EvictionRegionConfig; -import org.jboss.cache.eviction.LRUConfiguration; -import org.jboss.cache.eviction.NullEvictionPolicy; +import org.jboss.cache.eviction.LRUAlgorithmConfig; +import org.jboss.cache.eviction.NullEvictionAlgorithmConfig; import org.jboss.cache.util.TestingUtil; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; = -import java.util.Collections; - /** * Tests the eviction of buddy backup regions * @@ -47,13 +45,13 @@ private EvictionConfig getEvictionConfig() { EvictionConfig c =3D new EvictionConfig(); - c.setDefaultEvictionPolicyClass(NullEvictionPolicy.class.getName()); + EvictionRegionConfig defaultRegion =3D new EvictionRegionConfig(Fqn.= ROOT, new NullEvictionAlgorithmConfig()); + c.setDefaultEvictionRegionConfig(defaultRegion); c.setWakeupInterval(1000); - LRUConfiguration epc =3D new LRUConfiguration(); - epc.setMaxAge(1000); - epc.setTimeToLive(1000); - EvictionRegionConfig erc =3D new EvictionRegionConfig(fqn, epc); - c.setEvictionRegionConfigs(Collections.singletonList(erc)); + + LRUAlgorithmConfig lru =3D new LRUAlgorithmConfig(1000, 1000); + EvictionRegionConfig subregion =3D new EvictionRegionConfig(fqn, lru= ); + c.addEvictionRegionConfig(subregion); return c; } = Modified: core/trunk/src/test/java/org/jboss/cache/config/ConfigurationClon= ingTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTes= t.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTes= t.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -24,42 +24,45 @@ /** * Tests the ability to clone Configuration elements and end up with * independently modifiable configurations. - * = + * * @author Brian Stansberry */ @Test(groups =3D {"functional"}) public class ConfigurationCloningTest { - /** A file that includes every configuration element I could think of */ + /** + * A file that includes every configuration element I could think of + */ public static final String DEFAULT_CONFIGURATION_FILE =3D "configs/clon= able-config.xml"; - = + private static final Log log =3D LogFactory.getLog(ConfigurationCloning= Test.class); - = + public void testClone() throws Exception { XmlConfigurationParser parser =3D new XmlConfigurationParser(); Configuration c =3D parser.parseFile(DEFAULT_CONFIGURATION_FILE); - = - try { - Configuration clone =3D c.clone(); = - = + + try + { + Configuration clone =3D c.clone(); + // Test a few simple properties = - assertEquals(NodeLockingScheme.OPTIMISTIC, clone.getNodeLockingSc= heme()); = + assertEquals(NodeLockingScheme.OPTIMISTIC, clone.getNodeLockingSc= heme()); assertEquals(CacheMode.REPL_SYNC, clone.getCacheMode()); - assertEquals("CloneCluster", clone.getClusterName()); = - assertEquals(c.getClusterConfig(), clone.getClusterConfig()); = + assertEquals("CloneCluster", clone.getClusterName()); + assertEquals(c.getClusterConfig(), clone.getClusterConfig()); assertEquals(3, clone.getStateRetrievalTimeout()); - = + // Eviction EvictionConfig ec1 =3D c.getEvictionConfig(); EvictionConfig ec2 =3D clone.getEvictionConfig(); - = + assertFalse(ec1 =3D=3D ec2); - = - assertEquals(4, ec2.getDefaultEventQueueSize()); + + assertEquals(4, ec2.getDefaultEvictionRegionConfig().getEventQueu= eSize()); assertEquals(45000, ec2.getWakeupInterval()); assertEquals(LRUPolicy.class.getName(), ec2.getDefaultEvictionPol= icyClass()); - = + List ercs1 =3D ec1.getEvictionRegionConfigs= (); List ercs2 =3D ec2.getEvictionRegionConfigs= (); assertEquals(ercs1.size(), ercs2.size()); @@ -67,16 +70,16 @@ { compareEvictionRegionConfigs(ercs1.get(i), ercs2.get(i)); } - = + // Cache loading CacheLoaderConfig clc1 =3D c.getCacheLoaderConfig(); CacheLoaderConfig clc2 =3D clone.getCacheLoaderConfig(); - = + assertFalse(clc1 =3D=3D clc2); - = + assertFalse(clc2.isPassivation()); assertTrue(clc2.isShared()); - = + List clcs1 =3D clc1.getIndividualCac= heLoaderConfigs(); List clcs2 =3D clc2.getIndividualCac= heLoaderConfigs(); assertEquals(clcs1.size(), clcs2.size()); @@ -84,12 +87,12 @@ { compareCacheLoaderConfigs(clcs1.get(i), clcs2.get(i)); } - = + RuntimeConfig rc1 =3D c.getRuntimeConfig(); RuntimeConfig rc2 =3D clone.getRuntimeConfig(); assertFalse(rc1 =3D=3D rc2); assertEquals(rc1, rc2); - = + } catch (CloneNotSupportedException e) { @@ -99,31 +102,31 @@ } = private void compareEvictionRegionConfigs(EvictionRegionConfig erc1, - EvictionRegionConfig erc2) + EvictionRegionConfig erc2) { assertEquals(erc1.getRegionName(), erc2.getRegionName()); assertEquals(erc1.getRegionFqn(), erc2.getRegionFqn()); assertEquals(erc1.getEventQueueSize(), erc2.getEventQueueSize()); - = + EvictionPolicyConfig epc1 =3D erc1.getEvictionPolicyConfig(); EvictionPolicyConfig epc2 =3D erc2.getEvictionPolicyConfig(); - = + assertFalse(epc1 =3D=3D epc2); assertEquals(epc1, epc2); } = private void compareCacheLoaderConfigs(IndividualCacheLoaderConfig clc1, - IndividualCacheLoaderConfig clc2) + IndividualCacheLoaderConfig clc2) { assertFalse(clc1 =3D=3D clc2); assertEquals(clc1, clc2); - = - Properties p1 =3D clc1.getProperties(); = + + Properties p1 =3D clc1.getProperties(); Properties p2 =3D clc2.getProperties(); assertFalse(p1 =3D=3D p2); assertEquals(p1, p2); - = - SingletonStoreConfig ssc1 =3D clc1.getSingletonStoreConfig(); = + + SingletonStoreConfig ssc1 =3D clc1.getSingletonStoreConfig(); SingletonStoreConfig ssc2 =3D clc2.getSingletonStoreConfig(); assertFalse(ssc1 =3D=3D ssc2); assertEquals(ssc1, ssc2); Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionE= lementParserTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElement= ParserTest.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElement= ParserTest.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -1,14 +1,18 @@ package org.jboss.cache.config.parsing; = import org.jboss.cache.Fqn; -import org.jboss.cache.RegionManagerImpl; import org.jboss.cache.config.ConfigurationException; import org.jboss.cache.config.EvictionConfig; import org.jboss.cache.config.EvictionRegionConfig; import org.jboss.cache.config.MissingPolicyException; import org.jboss.cache.config.parsing.element.EvictionElementParser; -import org.jboss.cache.eviction.LRUConfiguration; -import org.jboss.cache.eviction.MRUConfiguration; +import org.jboss.cache.eviction.DefaultEvictionActionPolicy; +import org.jboss.cache.eviction.LFUAlgorithmConfig; +import org.jboss.cache.eviction.LRUAlgorithmConfig; +import org.jboss.cache.eviction.MRUAlgorithmConfig; +import org.jboss.cache.eviction.NullEvictionAlgorithm; +import org.jboss.cache.eviction.NullEvictionAlgorithmConfig; +import org.jboss.cache.eviction.RemoveOnEvictActionPolicy; import org.testng.annotations.Test; import org.w3c.dom.Element; = @@ -30,20 +34,21 @@ { String xml =3D " \n" + - " \n" + - " \n" + + " \n" + + " \n" + " 2103\n" + " 22\n" + " \n" + " "; EvictionConfig evictionConfig =3D getEvictionConfig(xml); - assert evictionConfig.getDefaultEventQueueSize() =3D=3D EvictionConf= ig.EVENT_QUEUE_SIZE_DEFAULT; + assert evictionConfig.getDefaultEvictionRegionConfig().getEventQueue= Size() =3D=3D EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT; + assert evictionConfig.getDefaultEvictionRegionConfig().getEvictionAc= tionPolicyClassName().equals(DefaultEvictionActionPolicy.class.getName()); } = /** - * test an happy flow. + * test unnecessary attributes */ - public void testNormalConfig() + public void testUnnecessaryAttributes() { String xml =3D " \n" + @@ -51,11 +56,35 @@ " 6\n= " + " 7\n" + " \n" + + " "; + try + { + EvictionConfig config =3D getEvictionConfig(xml); + assert false : "Should throw ConfigurationException!"; + } + catch (ConfigurationException good) + { + // expected + } + } + + + /** + * test an happy flow. + */ + public void testNormalConfig() + { + String xml =3D + " \n" + + " \n" + + " 6\n= " + + " 7\n" + + " \n" + " \n" + " 1002\n" + " 2021\n" + " \n" + - " \n" + + " \n" + " 2103\n" + " 22\n" + " \n" + @@ -63,39 +92,41 @@ EvictionConfig config =3D getEvictionConfig(xml); //tests the defaults assert config.getWakeupInterval() =3D=3D 5; - assert config.getDefaultEvictionPolicyClass().equals("org.jboss.cach= e.eviction.MRUPolicy"); - assert config.getDefaultEventQueueSize() =3D=3D 123456; - assert config.getEvictionRegionConfigs().size() =3D=3D 3; + assert config.getDefaultEvictionRegionConfig().getEvictionAlgorithmC= onfig() instanceof MRUAlgorithmConfig; + assert config.getDefaultEvictionRegionConfig().getEventQueueSize() = =3D=3D 123456; + assert config.getEvictionRegionConfigs().size() =3D=3D 2; = //test first region config - EvictionRegionConfig erConfig1 =3D config.getEvictionRegionConfigs()= .get(0); + EvictionRegionConfig erConfig1 =3D config.getDefaultEvictionRegionCo= nfig(); erConfig1.getRegionFqn().equals(Fqn.ROOT); - MRUConfiguration defaultPolicyonfig =3D (MRUConfiguration) erConfig1= .getEvictionPolicyConfig(); - assert defaultPolicyonfig.getMaxNodes() =3D=3D 6; - assert defaultPolicyonfig.getMinTimeToLive() =3D=3D 7; + MRUAlgorithmConfig defaultPolicyConfig =3D (MRUAlgorithmConfig) erCo= nfig1.getEvictionAlgorithmConfig(); + assert defaultPolicyConfig.getMaxNodes() =3D=3D 6; + assert defaultPolicyConfig.getMinTimeToLive() =3D=3D 7; = //test second region config - EvictionRegionConfig erConfig2 =3D config.getEvictionRegionConfigs()= .get(1); - assert erConfig2.getEventQueueSize() =3D=3D 123456; + EvictionRegionConfig erConfig2 =3D config.getEvictionRegionConfigs()= .get(0); + assert erConfig2.getEventQueueSize() =3D=3D 123456 : "Got " + erConf= ig2.getEventQueueSize(); assert erConfig2.getRegionFqn().equals(Fqn.fromString("/org/jboss/da= ta")); - MRUConfiguration mruConfiguration =3D (MRUConfiguration) erConfig2.g= etEvictionPolicyConfig(); + MRUAlgorithmConfig mruConfiguration =3D (MRUAlgorithmConfig) erConfi= g2.getEvictionAlgorithmConfig(); assert mruConfiguration.getMinTimeToLive() =3D=3D 1002; assert mruConfiguration.getMaxNodes() =3D=3D 2021; = //test 3rd region config - EvictionRegionConfig erConfig3 =3D config.getEvictionRegionConfigs()= .get(2); + EvictionRegionConfig erConfig3 =3D config.getEvictionRegionConfigs()= .get(1); assert erConfig3.getEventQueueSize() =3D=3D 21; assert erConfig3.getRegionFqn().equals(Fqn.fromString("/org/jboss/xy= z")); - LRUConfiguration lruConfiguration =3D (LRUConfiguration) erConfig3.g= etEvictionPolicyConfig(); + LRUAlgorithmConfig lruConfiguration =3D (LRUAlgorithmConfig) erConfi= g3.getEvictionAlgorithmConfig(); assert lruConfiguration.getTimeToLive() =3D=3D 22; assert lruConfiguration.getMaxNodes() =3D=3D 2103; + + assert config.getDefaultEvictionRegionConfig().getEvictionActionPoli= cyClassName().equals(DefaultEvictionActionPolicy.class.getName()); } = public void testLruConfig() { String xml =3D - " \n" + - " \n" + + " \n" + + " \n" + " 5000\n" + " 1000000\n" + " 15000= \n" + @@ -114,10 +145,11 @@ " \n" + " "; EvictionConfig evConfig =3D getEvictionConfig(xml); - EvictionRegionConfig evictionRegionConfig =3D evConfig.getEvictionRe= gionConfigs().get(0); - assert evictionRegionConfig.getRegionName().equals(RegionManagerImpl= .DEFAULT_REGION.toString()); - assert evictionRegionConfig.getRegionName().equals(RegionManagerImpl= .DEFAULT_REGION.toString()); - assert ((LRUConfiguration) evictionRegionConfig.getEvictionPolicyCon= fig()).getTimeToLive() =3D=3D 1000000; + EvictionRegionConfig evictionRegionConfig =3D evConfig.getDefaultEvi= ctionRegionConfig(); + assert evictionRegionConfig.getRegionName().equals(Fqn.ROOT.toString= ()) : "Was " + evictionRegionConfig.getRegionName(); + assert ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorit= hmConfig()).getTimeToLive() =3D=3D 1000000; + + assert evConfig.getDefaultEvictionRegionConfig().getEvictionActionPo= licyClassName().equals(DefaultEvictionActionPolicy.class.getName()); } = /** @@ -126,8 +158,8 @@ public void testMissingWakeUpInterval() throws Exception { String xml =3D - " \n" + - " \n" + + " \n" + + " \n" + " 5000\n" + " 1000\n" + " \n" + @@ -153,8 +185,8 @@ public void testMissingPolicyOnRegion() { String xml =3D - " \n" + - " \n" + + " \n" + + " \n" + " 1002\n" + " \n" + " "; @@ -169,6 +201,22 @@ } } = + /** + * Same as above, except no queue size is specified. SHould NOT fail. + */ + public void testMissingQueueSizeOnRegion() + { + String xml =3D + " \n" + + " \n" + + " 1002\n" + + " \n" + + " "; + EvictionConfig ec =3D getEvictionConfig(xml); + assert ec.getEvictionRegionConfigs().get(0).getEventQueueSize() =3D= =3D EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT; + } + + private EvictionConfig getEvictionConfig(String xml) { Element el; @@ -191,7 +239,7 @@ " 5000\n" + " 1000\n" + " \n" + - " \n" + + " \n" + " 5000\n" + " 1000\n" + " \n" + @@ -199,11 +247,49 @@ try { getEvictionConfig(xml); - assert false : " excewption expectecd as root does not have a evi= ction policy defined"; + assert false : " exception expected as default element does not h= ave a eviction policy defined"; } catch (MissingPolicyException e) { //expected } } + + public void testDifferentEvictionActionPolicyClasses() throws Exception + { + String xml =3D + " \n" + + " \n" + + " \n" + + " \n" + + " 5000\n" + + " 1000\n" + + " \n" + + " \n" + + " \n" + + " "; + EvictionConfig config =3D getEvictionConfig(xml); + + // default region + assert config.getDefaultEvictionRegionConfig().getEvictionAlgorithmC= onfig() instanceof NullEvictionAlgorithmConfig; + assert config.getDefaultEvictionRegionConfig().getEvictionActionPoli= cyClassName().equals(RemoveOnEvictActionPolicy.class.getName()); + + // region /one + assert findRegionConfig(config, "/one").getEvictionAlgorithmConfig()= instanceof LFUAlgorithmConfig; + assert findRegionConfig(config, "/one").getEvictionActionPolicyClass= Name().equals(RemoveOnEvictActionPolicy.class.getName()); + + // region /two + assert findRegionConfig(config, "/two").getEvictionAlgorithmConfig()= instanceof NullEvictionAlgorithmConfig; + assert findRegionConfig(config, "/two").getEvictionActionPolicyClass= Name().equals(DefaultEvictionActionPolicy.class.getName()); + } + + private EvictionRegionConfig findRegionConfig(EvictionConfig evictionCo= nfig, String fqn) + { + for (EvictionRegionConfig erc : evictionConfig.getEvictionRegionConf= igs()) + { + if (erc.getRegionFqn().equals(Fqn.fromString(fqn))) return erc; + } + + return null; + } } Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfig= urationParserTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParserTest.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParserTest.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -9,8 +9,8 @@ import org.jboss.cache.config.OldFileFormatException; import org.jboss.cache.config.parsing.custominterceptors.AaaCustomIntercep= tor; import org.jboss.cache.config.parsing.custominterceptors.BbbCustomIntercep= tor; -import org.jboss.cache.eviction.LRUConfiguration; -import org.jboss.cache.eviction.MRUConfiguration; +import org.jboss.cache.eviction.LRUAlgorithmConfig; +import org.jboss.cache.eviction.MRUAlgorithmConfig; import org.jboss.cache.lock.IsolationLevel; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -202,7 +202,7 @@ { EvictionConfig evictionConfig =3D config.getEvictionConfig(); assert "org.jboss.cache.eviction.LRUPolicy".equals(evictionConfig.ge= tDefaultEvictionPolicyClass()); - assert 200000 =3D=3D evictionConfig.getDefaultEventQueueSize(); + assert 200000 =3D=3D evictionConfig.getDefaultEvictionRegionConfig()= .getEventQueueSize(); assert 5 =3D=3D evictionConfig.getWakeupInterval(); = List regionConfigs =3D evictionConfig.getEvict= ionRegionConfigs(); @@ -210,20 +210,20 @@ = EvictionRegionConfig first =3D regionConfigs.get(0); assert first.getRegionName().equals("/_default_"); - assert first.getEvictionPolicyConfig() instanceof LRUConfiguration; - LRUConfiguration firstConfiguration =3D (LRUConfiguration) first.get= EvictionPolicyConfig(); + assert first.getEvictionAlgorithmConfig() instanceof LRUAlgorithmCon= fig; + LRUAlgorithmConfig firstConfiguration =3D (LRUAlgorithmConfig) first= .getEvictionAlgorithmConfig(); assert firstConfiguration.getMaxAge() <=3D 0; assert firstConfiguration.getTimeToLive() =3D=3D 1000; assert firstConfiguration.getMaxNodes() =3D=3D 5000; = EvictionRegionConfig second =3D regionConfigs.get(1); - LRUConfiguration secondConfiguration =3D (LRUConfiguration) second.g= etEvictionPolicyConfig(); + LRUAlgorithmConfig secondConfiguration =3D (LRUAlgorithmConfig) seco= nd.getEvictionAlgorithmConfig(); assert secondConfiguration.getMaxAge() =3D=3D 0; assert secondConfiguration.getTimeToLive() =3D=3D 1002; assert secondConfiguration.getMaxNodes() =3D=3D 0; = EvictionRegionConfig third =3D regionConfigs.get(2); - MRUConfiguration thirdConfiguration =3D (MRUConfiguration) third.get= EvictionPolicyConfig(); + MRUAlgorithmConfig thirdConfiguration =3D (MRUAlgorithmConfig) third= .getEvictionAlgorithmConfig(); assert thirdConfiguration.getMaxNodes() =3D=3D 2103; assert thirdConfiguration.getMinTimeToLive() =3D=3D 22; assert third.getEventQueueSize() =3D=3D 21; Modified: core/trunk/src/test/java/org/jboss/cache/eviction/BaseEvictionAlg= orithmTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/BaseEvictionAlgorithm= Test.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/BaseEvictionAlgorithm= Test.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -23,14 +23,16 @@ = import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.jboss.cache.CacheSPI; import org.jboss.cache.Fqn; import org.jboss.cache.Region; +import org.jboss.cache.RegionImpl; import org.jboss.cache.RegionManager; import org.jboss.cache.RegionManagerImpl; import org.jboss.cache.RegionRegistry; +import org.jboss.cache.config.Configuration; import org.jboss.cache.config.ConfigurationException; -import org.jboss.cache.config.EvictionPolicyConfig; +import org.jboss.cache.config.EvictionAlgorithmConfig; +import org.jboss.cache.config.EvictionRegionConfig; import static org.testng.AssertJUnit.fail; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -59,7 +61,7 @@ public void setUp() throws Exception { RegionManagerImpl rmi =3D new RegionManagerImpl(); - rmi.injectDependencies(null, null, null, null, null, new RegionRegis= try()); + rmi.injectDependencies(null, new Configuration(), null, null, null, = new RegionRegistry()); regionManager =3D rmi; } = @@ -71,16 +73,16 @@ BaseEvictionAlgorithm algorithm =3D new MockEvictionAlgorithm(recycl= eQueueCapacity); = Region region =3D regionManager.getRegion("/a/b/c", true); - region.setEvictionPolicy(new MockEvictionPolicyConfig()); + region.setEvictionRegionConfig(new EvictionRegionConfig(region.getFq= n(), new MockEvictionAlgorithmConfig())); = for (int i =3D 0; i < (recycleQueueCapacity + 1); i++) { Fqn fqn =3D Fqn.fromString("/a/b/c/" + Integer.toString(i + 1)); - region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_N= ODE_EVENT)); + region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NODE_EVE= NT); } = ExecutorService executor =3D Executors.newSingleThreadExecutor(); - Future future =3D executor.submit(new ProcessEvictionRegion(re= gion, algorithm)); + Future future =3D executor.submit(new ProcessEvictionRegion((R= egionImpl) region, algorithm)); = try { @@ -103,13 +105,21 @@ = public static class MockEvictionAlgorithm extends BaseEvictionAlgorithm { - public MockEvictionAlgorithm(int recycleQueueCapacity) + private static MockEvictionAlgorithm singleton; + + private MockEvictionAlgorithm(int recycleQueueCapacity) { recycleQueue =3D new LinkedBlockingQueue(recycleQueueCapacit= y); + singleton =3D this; } = + public static MockEvictionAlgorithm getInstance() + { + return singleton; + } + @Override - protected EvictionQueue setupEvictionQueue(Region region) throws Evi= ctionException + protected EvictionQueue setupEvictionQueue() throws EvictionException { return new LRUQueue(); } @@ -121,60 +131,42 @@ return true; } = - } - - public static class MockEvictionPolicy extends BaseEvictionPolicy - { - - @Override - public void evict(Fqn fqn) throws Exception + public Class getConfigurationClas= s() { - throw new Exception("Unable to evict"); - } - - @Override - public void setCache(CacheSPI cache) - { - /* no op */ - } - - public EvictionAlgorithm getEvictionAlgorithm() - { return null; } - - public Class getEvictionConfiguratio= nClass() - { - return MockEvictionPolicyConfig.class; - } } = - public static class MockEvictionPolicyConfig implements EvictionPolicyC= onfig + public static class MockEvictionAlgorithmConfig implements EvictionAlgo= rithmConfig { - - public String getEvictionPolicyClass() + public void reset() { - return MockEvictionPolicy.class.getName(); + /* no op */ } = - public void reset() + public String getEvictionAlgorithmClassName() { - /* no op */ + return MockEvictionAlgorithm.class.getName(); } = public void validate() throws ConfigurationException { /* no op */ } + + public EvictionAlgorithmConfig clone() throws CloneNotSupportedExcep= tion + { + return (EvictionAlgorithmConfig) super.clone(); + } } = public class ProcessEvictionRegion implements Callable { - private Region region; + private RegionImpl region; = private EvictionAlgorithm algorithm; = - public ProcessEvictionRegion(Region region, EvictionAlgorithm algori= thm) + public ProcessEvictionRegion(RegionImpl region, EvictionAlgorithm al= gorithm) { this.region =3D region; this.algorithm =3D algorithm; @@ -184,7 +176,7 @@ { try { - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); } catch (EvictionException e) { Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvict= ionTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTes= t.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTes= t.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -16,6 +16,7 @@ import org.jboss.cache.config.EvictionConfig; import org.jboss.cache.config.EvictionRegionConfig; import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; +import org.jboss.cache.transaction.DummyTransactionManagerLookup; import org.jboss.cache.util.TestingUtil; import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.fail; @@ -24,8 +25,6 @@ import org.testng.annotations.Test; = import java.io.IOException; -import java.util.ArrayList; -import java.util.List; import java.util.Properties; = /** @@ -37,8 +36,8 @@ @Test(groups =3D {"functional"}) public class ConcurrentEvictionTest { - private Cache cache_; - private long wakeupIntervalMillis_ =3D 0; + private Cache cache; + private long wakeupIntervalMillis =3D 0; private String tmpDir =3D System.getProperty("java.io.tmpdir", "/tmp"); private String cacheLoaderDir =3D "/JBossCacheFileCacheLoader"; = @@ -46,10 +45,10 @@ public void setUp() throws Exception { initCaches(); - wakeupIntervalMillis_ =3D cache_.getConfiguration().getEvictionConfi= g().getWakeupInterval(); - if (wakeupIntervalMillis_ < 0) + wakeupIntervalMillis =3D cache.getConfiguration().getEvictionConfig(= ).getWakeupInterval(); + if (wakeupIntervalMillis < 0) { - fail("testEviction(): eviction thread wake up interval is illegal= " + wakeupIntervalMillis_); + fail("testEviction(): eviction thread wake up interval is illegal= " + wakeupIntervalMillis); } = } @@ -61,8 +60,8 @@ Configuration conf =3D UnitTestCacheConfigurationFactory.createConfi= guration(Configuration.CacheMode.LOCAL, true); conf.setEvictionConfig(buildEvictionConfig()); conf.setCacheLoaderConfig(buildCacheLoaderConfig()); - conf.setTransactionManagerLookupClass("org.jboss.cache.transaction.D= ummyTransactionManagerLookup"); - cache_ =3D factory.createCache(conf, true);// read in generic local = xml + conf.setTransactionManagerLookupClass(DummyTransactionManagerLookup.= class.getName()); + cache =3D factory.createCache(conf, true);// read in generic local x= ml } = private CacheLoaderConfig buildCacheLoaderConfig() @@ -86,23 +85,19 @@ = private EvictionConfig buildEvictionConfig() { - EvictionConfig ec =3D new EvictionConfig("org.jboss.cache.eviction.L= RUPolicy"); - ec.setDefaultEvictionPolicyClass("org.jboss.cache.eviction.LRUPolicy= "); - ec.setWakeupInterval(5000); - - EvictionRegionConfig erc =3D UnitTestCacheConfigurationFactory.build= LruEvictionRegionConfig("_default_", 5000, 1000000); - List erConfigs =3D new ArrayList(); - erConfigs.add(erc); - ec.setEvictionRegionConfigs(erConfigs); - return ec; + return new EvictionConfig( + new EvictionRegionConfig( + Fqn.ROOT, + new LRUAlgorithmConfig(1000000, 5000) + ), + 5000); } = @AfterMethod(alwaysRun =3D true) public void tearDown() throws Exception { TestingUtil.recursiveFileRemove(tmpDir + cacheLoaderDir); - cache_.stop(); - cache_ =3D null; + TestingUtil.killCaches(cache); } = public void testConcurrentEviction() throws Exception @@ -113,11 +108,11 @@ // region's maxNodes so we know eviction will kick in for (int i =3D 0; i < 1000; i++) { - cache_.put(Fqn.fromRelativeElements(base, i / 100), i, "value"); + cache.put(Fqn.fromRelativeElements(base, i / 100), i, "value"); } = // Loop for long enough to have 5 runs of the eviction thread - long loopDone =3D System.currentTimeMillis() + (5 * wakeupIntervalMi= llis_); + long loopDone =3D System.currentTimeMillis() + (5 * wakeupIntervalMi= llis); while (System.currentTimeMillis() < loopDone) { // If any get returns null, that's a failure @@ -126,7 +121,7 @@ Fqn fqn =3D Fqn.fromRelativeElements(base, i / 100); Integer key =3D i; assertNotNull("found value under Fqn " + fqn + " and key " + k= ey, - cache_.get(fqn, key)); + cache.get(fqn, key)); } } } Deleted: core/trunk/src/test/java/org/jboss/cache/eviction/DummyEvictionCon= figuration.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/DummyEvictionConfigur= ation.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/DummyEvictionConfigur= ation.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -1,41 +0,0 @@ -/* - * JBoss, the OpenSource J2EE webOS - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package org.jboss.cache.eviction; - -import org.jboss.cache.config.ConfigurationException; -import org.jboss.cache.config.EvictionPolicyConfig; - - -/** - * @author Daniel Huang (dhuang(a)jboss.org) - * @version $Revision$ - */ -public class DummyEvictionConfiguration implements EvictionPolicyConfig, C= loneable -{ - public String getEvictionPolicyClass() - { - return DummyEvictionPolicy.class.getName(); - } - - public void validate() throws ConfigurationException - { - // no-op = - } - = - public void reset() - { - // no-op - } - - @Override - public DummyEvictionConfiguration clone() throws CloneNotSupportedExcep= tion - { - return (DummyEvictionConfiguration) super.clone(); - } = - = - = -} Deleted: core/trunk/src/test/java/org/jboss/cache/eviction/DummyEvictionPol= icy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/DummyEvictionPolicy.j= ava 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/DummyEvictionPolicy.j= ava 2008-08-15 10:59:40 UTC (rev 6562) @@ -1,40 +0,0 @@ -package org.jboss.cache.eviction; - -import org.jboss.cache.CacheSPI; -import org.jboss.cache.Fqn; -import org.jboss.cache.config.EvictionPolicyConfig; - -/** - * @author Ben Feb 13, 2004 - */ -public class DummyEvictionPolicy extends BaseEvictionPolicy -{ - public void evict(Fqn fqn) throws Exception - { - // no-op -// throw new RuntimeException("Testing only"); - } - - public int getWakeupIntervalSeconds() - { - return 0; //To change body of implemented methods use File | Settin= gs | File Templates. - } - - public void setCache(CacheSPI cache) - { - // no op - } - - public EvictionAlgorithm getEvictionAlgorithm() - { - // no op - return null; - } - - public Class getEvictionConfigurationCl= ass() - { - return null; - } - - -} Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeAlgo= rithmTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeAlgorithmT= est.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeAlgorithmT= est.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -1,16 +1,12 @@ -/* - * JBoss, the OpenSource J2EE webOS - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ package org.jboss.cache.eviction; = import org.jboss.cache.Fqn; import org.jboss.cache.Region; +import org.jboss.cache.RegionImpl; import org.jboss.cache.RegionManager; import org.jboss.cache.RegionManagerImpl; import org.jboss.cache.RegionRegistry; +import org.jboss.cache.config.EvictionRegionConfig; import static org.testng.AssertJUnit.assertEquals; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -33,34 +29,35 @@ algo =3D new ElementSizeAlgorithm(); regionManager =3D new RegionManagerImpl(); ((RegionManagerImpl) regionManager).injectDependencies(null, null, n= ull, null, null, new RegionRegistry()); - ElementSizeConfiguration config =3D new ElementSizeConfiguration(); + ElementSizeAlgorithmConfig config =3D new ElementSizeAlgorithmConfig= (); // We have to setCache maxElementsPerNode!! config.setMaxElementsPerNode(0); - config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName()); - regionManager.getRegion("/a/b", true).setEvictionPolicy(config); +// config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName()); + Region r =3D regionManager.getRegion("/a/b", true); + r.setEvictionRegionConfig(new EvictionRegionConfig(r.getFqn(), confi= g)); } = public void testMaxElements() throws Exception { - Region region =3D regionManager.getRegion("/a/b", true); - ElementSizeConfiguration config =3D (ElementSizeConfiguration) regio= n.getEvictionPolicyConfig(); + RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); + ElementSizeAlgorithmConfig config =3D (ElementSizeAlgorithmConfig) r= egion.getEvictionRegionConfig().getEvictionAlgorithmConfig(); config.setMaxNodes(10); config.setMaxElementsPerNode(6); = for (int i =3D 0; i < 10; i++) { Fqn fqn =3D Fqn.fromString("/a/b/" + Integer.toString(i)); - region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_N= ODE_EVENT)); + region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NODE_EVE= NT); if (i % 2 =3D=3D 0) { for (int k =3D 0; k < i; k++) { - region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType= .ADD_ELEMENT_EVENT)); + region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_EL= EMENT_EVENT); } } } = - algo.process(region); + algo.process(region.getEvictionEventQueue()); = ElementSizeQueue queue =3D (ElementSizeQueue) algo.evictionQueue; assertEquals(9, algo.getEvictionQueue().getNumberOfNodes()); @@ -86,34 +83,34 @@ = for (int i =3D 0; i < 7; i++) { - region.putNodeEvent(new EvictedEventNode(Fqn.fromString("/a/b/9")= , NodeEventType.ADD_ELEMENT_EVENT)); - region.putNodeEvent(new EvictedEventNode(Fqn.fromString("/a/b/7")= , NodeEventType.ADD_ELEMENT_EVENT)); + region.registerEvictionEvent(Fqn.fromString("/a/b/9"), EvictionEv= ent.Type.ADD_ELEMENT_EVENT); + region.registerEvictionEvent(Fqn.fromString("/a/b/7"), EvictionEv= ent.Type.ADD_ELEMENT_EVENT); } = - algo.process(region); + algo.process(region.getEvictionEventQueue()); = assertEquals(7, queue.getNumberOfNodes()); } = public void testMaxNodesAndMaxElements() throws Exception { - Region region =3D regionManager.getRegion("/a/b", true); - ElementSizeConfiguration config =3D (ElementSizeConfiguration) regio= n.getEvictionPolicyConfig(); + RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); + ElementSizeAlgorithmConfig config =3D (ElementSizeAlgorithmConfig) r= egion.getEvictionRegionConfig().getEvictionAlgorithmConfig(); config.setMaxNodes(10); config.setMaxElementsPerNode(100); = for (int i =3D 0; i < 20; i++) { Fqn fqn =3D Fqn.fromString("/a/b/" + Integer.toString(i)); - region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_N= ODE_EVENT)); + region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NODE_EVE= NT); for (int k =3D 0; k < i; k++) { - region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.AD= D_ELEMENT_EVENT)); + region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_ELEME= NT_EVENT); = } } = - algo.process(region); + algo.process(region.getEvictionEventQueue()); = ElementSizeQueue queue =3D (ElementSizeQueue) algo.evictionQueue; assertEquals(10, algo.getEvictionQueue().getNumberOfNodes()); Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConf= igurationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConfigurat= ionTest.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConfigurat= ionTest.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -6,32 +6,30 @@ */ package org.jboss.cache.eviction; = -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.fail; - import org.jboss.cache.config.ConfigurationException; -import org.jboss.cache.config.parsing.element.EvictionElementParser; import org.jboss.cache.config.parsing.XmlConfigHelper; +import org.jboss.cache.config.parsing.element.EvictionElementParser; +import static org.testng.AssertJUnit.*; import org.testng.annotations.Test; import org.w3c.dom.Element; + /** * @author Daniel Huang * @version $Revision$ */ -(a)Test(groups =3D {"functional"}) +(a)Test(groups =3D "unit", sequential =3D false) public class ElementSizeConfigurationTest { public void testXMLParse1() throws Exception { - ElementSizeConfiguration config =3D new ElementSizeConfiguration(); + ElementSizeAlgorithmConfig config =3D new ElementSizeAlgorithmConfig= (); String xml =3D "" + - "1000" + - "100" + - ""; + "1000" + + "100" + + ""; = Element element =3D XmlConfigHelper.stringToElement(xml); - EvictionElementParser.parseEvictionPolicyConfig(element, config); + EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); = assertEquals(100, config.getMaxElementsPerNode()); assertEquals(1000, config.getMaxNodes()); @@ -40,15 +38,15 @@ = public void testXMLParse2() throws Exception { - ElementSizeConfiguration config =3D new ElementSizeConfiguration(); + ElementSizeAlgorithmConfig config =3D new ElementSizeAlgorithmConfig= (); String xml =3D "" + - "1000" + - ""; + "1000" + + ""; = Element element =3D XmlConfigHelper.stringToElement(xml); try { - EvictionElementParser.parseEvictionPolicyConfig(element, config); + EvictionElementParser.parseEvictionPolicyConfig(element, config, = true); } catch (ConfigurationException ce) { @@ -62,14 +60,14 @@ = public void testXMLParse3() throws Exception { - ElementSizeConfiguration config =3D new ElementSizeConfiguration(); + ElementSizeAlgorithmConfig config =3D new ElementSizeAlgorithmConfig= (); String xml =3D "" + - "100" + - ""; + "100" + + ""; = Element element =3D XmlConfigHelper.stringToElement(xml); = - EvictionElementParser.parseEvictionPolicyConfig(element, config); + EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); = assertEquals(100, config.getMaxElementsPerNode()); assertEquals(0, config.getMaxNodes()); Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizePoli= cyTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizePolicyTest= .java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizePolicyTest= .java 2008-08-15 10:59:40 UTC (rev 6562) @@ -16,14 +16,12 @@ import org.jboss.cache.config.EvictionRegionConfig; import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; import org.jboss.cache.lock.IsolationLevel; +import org.jboss.cache.transaction.DummyTransactionManagerLookup; import static org.testng.AssertJUnit.*; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = -import java.util.ArrayList; -import java.util.List; - /** * @author Daniel Huang * @version $Revison: $ @@ -56,36 +54,18 @@ void initCaches() throws Exception { Configuration conf =3D UnitTestCacheConfigurationFactory.createConfi= guration(Configuration.CacheMode.LOCAL, true); - EvictionConfig evConfig =3D conf.getEvictionConfig(); - evConfig.setDefaultEvictionPolicyClass("org.jboss.cache.eviction.Ele= mentSizePolicy"); - evConfig.setWakeupInterval(3000); + EvictionConfig evConfig =3D new EvictionConfig(new EvictionRegionCon= fig(Fqn.ROOT, new ElementSizeAlgorithmConfig(5000, 100)), 3000); evConfig.setDefaultEventQueueSize(200000); - - List regionConfigs =3D new ArrayList(); - regionConfigs.add(createEvictionRegionConfig("_default_", 5000, 100)= ); - regionConfigs.add(createEvictionRegionConfig("/org/jboss/data", 10, = 20)); - regionConfigs.add(createEvictionRegionConfig("/org/jboss/test/data",= -1, 5)); - regionConfigs.add(createEvictionRegionConfig("/test/", 5000, 1)); - - evConfig.setEvictionRegionConfigs(regionConfigs); - + evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromSt= ring("/org/jboss/data"), new ElementSizeAlgorithmConfig(10, 20))); + evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromSt= ring("/org/jboss/test/data"), new ElementSizeAlgorithmConfig(-1, 5))); + evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromSt= ring("/test/"), new ElementSizeAlgorithmConfig(5000, 1))); + conf.setEvictionConfig(evConfig); cache =3D (CacheSPI) new DefaultCacheFactory().createCache(conf, false); - cache.getConfiguration().setTransactionManagerLookupClass("org.jboss= .cache.transaction.DummyTransactionManagerLookup"); + cache.getConfiguration().setTransactionManagerLookupClass(DummyTrans= actionManagerLookup.class.getName()); cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZAB= LE); cache.start(); } = - private EvictionRegionConfig createEvictionRegionConfig(String regionNa= me, int maxNodes, int maxElementsPerNode) - { - EvictionRegionConfig ercDefault =3D new EvictionRegionConfig(); - ercDefault.setRegionName(regionName); - ElementSizeConfiguration esConfig =3D new ElementSizeConfiguration(); - if (maxNodes >=3D 0) esConfig.setMaxNodes(maxNodes); - if (maxElementsPerNode >=3D 0) esConfig.setMaxElementsPerNode(maxEle= mentsPerNode); - ercDefault.setEvictionPolicyConfig(esConfig); - return ercDefault; - } - @AfterMethod(alwaysRun =3D true) public void tearDown() throws Exception { Modified: core/trunk/src/test/java/org/jboss/cache/eviction/EvictionConfigu= rationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/EvictionConfiguration= Test.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/EvictionConfiguration= Test.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -11,8 +11,9 @@ import org.jboss.cache.Fqn; import org.jboss.cache.Region; import org.jboss.cache.RegionManager; -import org.jboss.cache.config.EvictionPolicyConfig; +import org.jboss.cache.config.EvictionRegionConfig; import org.jboss.cache.lock.IsolationLevel; +import org.jboss.cache.util.TestingUtil; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertTrue; import org.testng.annotations.Test; @@ -23,166 +24,163 @@ * @author Daniel Huang (dhuang(a)jboss.org) * @version $Revision$ */ -(a)Test(groups =3D {"functional"}) +(a)Test(groups =3D "unit", sequential =3D false) public class EvictionConfigurationTest { - CacheSPI cache; - RegionManager regionManager; - public void testPolicyPerRegion() throws Exception { - this.setupCache("configs/policyPerRegion-eviction.xml"); - assertEquals(5000, cache.getConfiguration().getEvictionConfig().getW= akeupInterval()); + CacheSPI cache =3D null; + RegionManager regionManager =3D null; + try + { + cache =3D setupCache("configs/policyPerRegion-eviction.xml"); + regionManager =3D cache.getRegionManager(); + assertEquals(5000, cache.getConfiguration().getEvictionConfig().g= etWakeupInterval()); = - Region region =3D regionManager.getRegion("/org/jboss/data", true); - EvictionPolicy policy =3D region.getEvictionPolicy(); - EvictionPolicyConfig configuration =3D region.getEvictionPolicyConfi= g(); - assertEquals(Fqn.fromString("/org/jboss/data"), region.getFqn()); - assertTrue(policy instanceof LFUPolicy); - assertTrue(configuration instanceof LFUConfiguration); - assertEquals(5000, ((LFUConfiguration) configuration).getMaxNodes()); - assertEquals(1000, ((LFUConfiguration) configuration).getMinNodes()); + Region region =3D regionManager.getRegion("/org/jboss/data", true= ); + EvictionRegionConfig evictionRegionConfig =3D region.getEvictionR= egionConfig(); + assertEquals(Fqn.fromString("/org/jboss/data"), region.getFqn()); + assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() inst= anceof LFUAlgorithmConfig); + assertEquals(5000, ((LFUAlgorithmConfig) evictionRegionConfig.get= EvictionAlgorithmConfig()).getMaxNodes()); + assertEquals(1000, ((LFUAlgorithmConfig) evictionRegionConfig.get= EvictionAlgorithmConfig()).getMinNodes()); = - region =3D regionManager.getRegion("/org/jboss/test/data", true); - policy =3D region.getEvictionPolicy(); - configuration =3D region.getEvictionPolicyConfig(); - assertEquals(Fqn.fromString("/org/jboss/test/data"), region.getFqn()= ); - assertTrue(policy instanceof FIFOPolicy); - assertTrue(configuration instanceof FIFOConfiguration); - assertEquals(5, ((FIFOConfiguration) configuration).getMaxNodes()); + region =3D regionManager.getRegion("/org/jboss/test/data", true); + evictionRegionConfig =3D region.getEvictionRegionConfig(); + assertEquals(Fqn.fromString("/org/jboss/test/data"), region.getFq= n()); + assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() inst= anceof FIFOAlgorithmConfig); + assertEquals(5, ((FIFOAlgorithmConfig) evictionRegionConfig.getEv= ictionAlgorithmConfig()).getMaxNodes()); = - region =3D regionManager.getRegion("/test", true); - policy =3D region.getEvictionPolicy(); - configuration =3D region.getEvictionPolicyConfig(); - assertEquals(Fqn.fromString("/test"), region.getFqn()); - assertTrue(policy instanceof MRUPolicy); - assertTrue(configuration instanceof MRUConfiguration); - assertEquals(10000, ((MRUConfiguration) configuration).getMaxNodes()= ); + region =3D regionManager.getRegion("/test", true); + evictionRegionConfig =3D region.getEvictionRegionConfig(); + assertEquals(Fqn.fromString("/test"), region.getFqn()); + assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() inst= anceof MRUAlgorithmConfig); + assertEquals(10000, ((MRUAlgorithmConfig) evictionRegionConfig.ge= tEvictionAlgorithmConfig()).getMaxNodes()); = - region =3D regionManager.getRegion("/maxAgeTest", true); - policy =3D region.getEvictionPolicy(); - configuration =3D region.getEvictionPolicyConfig(); - assertEquals(Fqn.fromString("/maxAgeTest"), region.getFqn()); - assertTrue(policy instanceof LRUPolicy); - assertTrue(configuration instanceof LRUConfiguration); - assertEquals(10000, ((LRUConfiguration) configuration).getMaxNodes()= ); - assertEquals(8000, ((LRUConfiguration) configuration).getTimeToLive(= )); - assertEquals(10000, ((LRUConfiguration) configuration).getMaxAge()); + region =3D regionManager.getRegion("/maxAgeTest", true); + evictionRegionConfig =3D region.getEvictionRegionConfig(); + assertEquals(Fqn.fromString("/maxAgeTest"), region.getFqn()); + assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() inst= anceof LRUAlgorithmConfig); + assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.ge= tEvictionAlgorithmConfig()).getMaxNodes()); + assertEquals(8000, ((LRUAlgorithmConfig) evictionRegionConfig.get= EvictionAlgorithmConfig()).getTimeToLive()); + assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.ge= tEvictionAlgorithmConfig()).getMaxAge()); = - // test the default region. use a region name that isn't defined exp= licitly in conf file. - region =3D regionManager.getRegion("/a/b/c", false); - policy =3D region.getEvictionPolicy(); - configuration =3D region.getEvictionPolicyConfig(); - assertEquals(Fqn.ROOT, region.getFqn()); - assertTrue(policy instanceof LRUPolicy); - assertTrue(configuration instanceof LRUConfiguration); - assertEquals(5000, ((LRUConfiguration) configuration).getMaxNodes()); - assertEquals(1000000, ((LRUConfiguration) configuration).getTimeToLi= ve()); - assertEquals(0, ((LRUConfiguration) configuration).getMaxAge()); + // test the default region. use a region name that isn't defined = explicitly in conf file. + region =3D regionManager.getRegion("/a/b/c", false); + evictionRegionConfig =3D region.getEvictionRegionConfig(); + assertEquals(Fqn.ROOT, region.getFqn()); + assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() inst= anceof LRUAlgorithmConfig); + assertEquals(5000, ((LRUAlgorithmConfig) evictionRegionConfig.get= EvictionAlgorithmConfig()).getMaxNodes()); + assertEquals(1000000, ((LRUAlgorithmConfig) evictionRegionConfig.= getEvictionAlgorithmConfig()).getTimeToLive()); + assertEquals(0, ((LRUAlgorithmConfig) evictionRegionConfig.getEvi= ctionAlgorithmConfig()).getMaxAge()); = - cache.stop(); + } + finally + { + TestingUtil.killCaches(cache); + } } = public void testMixedPolicies() throws Exception { - this.setupCache("configs/mixedPolicy-eviction.xml"); - assertEquals(5000, cache.getConfiguration().getEvictionConfig().getW= akeupInterval()); + CacheSPI cache =3D null; + RegionManager regionManager =3D null; = - Region region =3D regionManager.getRegion("/org/jboss/data", true); - EvictionPolicy policy =3D region.getEvictionPolicy(); - EvictionPolicyConfig configuration =3D region.getEvictionPolicyConfi= g(); - assertEquals(Fqn.fromString("/org/jboss/data/"), region.getFqn()); - assertTrue(policy instanceof FIFOPolicy); - assertTrue(configuration instanceof FIFOConfiguration); - assertEquals(5000, ((FIFOConfiguration) configuration).getMaxNodes()= ); + try + { + cache =3D setupCache("configs/mixedPolicy-eviction.xml"); + regionManager =3D cache.getRegionManager(); + assertEquals(5000, cache.getConfiguration().getEvictionConfig().g= etWakeupInterval()); = - region =3D regionManager.getRegion("/test", true); - policy =3D region.getEvictionPolicy(); - configuration =3D region.getEvictionPolicyConfig(); - assertEquals(Fqn.fromString("/test/"), region.getFqn()); - assertTrue(policy instanceof MRUPolicy); - assertTrue(configuration instanceof MRUConfiguration); - assertEquals(10000, ((MRUConfiguration) configuration).getMaxNodes()= ); + Region region =3D regionManager.getRegion("/org/jboss/data", true= ); + EvictionRegionConfig evictionRegionConfig =3D region.getEvictionR= egionConfig(); + assertEquals(Fqn.fromString("/org/jboss/data/"), region.getFqn()); + assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() inst= anceof FIFOAlgorithmConfig); + assertEquals(5000, ((FIFOAlgorithmConfig) evictionRegionConfig.ge= tEvictionAlgorithmConfig()).getMaxNodes()); = - // test the default region. use a region name that isn't defined exp= licitly in conf file. - region =3D regionManager.getRegion("/a/b/c", false); - policy =3D region.getEvictionPolicy(); - configuration =3D region.getEvictionPolicyConfig(); - assertEquals(Fqn.ROOT, region.getFqn()); - assertTrue(policy instanceof LRUPolicy); - assertTrue(configuration instanceof LRUConfiguration); - assertEquals(5000, ((LRUConfiguration) configuration).getMaxNodes()); - assertEquals(1000000, ((LRUConfiguration) configuration).getTimeToLi= ve()); - assertEquals(0, ((LRUConfiguration) configuration).getMaxAge()); + region =3D regionManager.getRegion("/test", true); + evictionRegionConfig =3D region.getEvictionRegionConfig(); + assertEquals(Fqn.fromString("/test/"), region.getFqn()); + assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() inst= anceof MRUAlgorithmConfig); + assertEquals(10000, ((MRUAlgorithmConfig) evictionRegionConfig.ge= tEvictionAlgorithmConfig()).getMaxNodes()); = - region =3D regionManager.getRegion("/maxAgeTest", false); - policy =3D region.getEvictionPolicy(); - configuration =3D region.getEvictionPolicyConfig(); - assertEquals(Fqn.fromString("/maxAgeTest/"), region.getFqn()); - assertTrue(policy instanceof LRUPolicy); - assertTrue(configuration instanceof LRUConfiguration); - assertEquals(10000, ((LRUConfiguration) configuration).getMaxNodes()= ); - assertEquals(8000, ((LRUConfiguration) configuration).getTimeToLive(= )); - assertEquals(10000, ((LRUConfiguration) configuration).getMaxAge()); + // test the default region. use a region name that isn't defined = explicitly in conf file. + region =3D regionManager.getRegion("/a/b/c", false); + evictionRegionConfig =3D region.getEvictionRegionConfig(); + assertEquals(Fqn.ROOT, region.getFqn()); + assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() inst= anceof LRUAlgorithmConfig); + assertEquals(5000, ((LRUAlgorithmConfig) evictionRegionConfig.get= EvictionAlgorithmConfig()).getMaxNodes()); + assertEquals(1000000, ((LRUAlgorithmConfig) evictionRegionConfig.= getEvictionAlgorithmConfig()).getTimeToLive()); + assertEquals(0, ((LRUAlgorithmConfig) evictionRegionConfig.getEvi= ctionAlgorithmConfig()).getMaxAge()); = - cache.stop(); + region =3D regionManager.getRegion("/maxAgeTest", false); + evictionRegionConfig =3D region.getEvictionRegionConfig(); + assertEquals(Fqn.fromString("/maxAgeTest/"), region.getFqn()); + assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() inst= anceof LRUAlgorithmConfig); + assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.ge= tEvictionAlgorithmConfig()).getMaxNodes()); + assertEquals(8000, ((LRUAlgorithmConfig) evictionRegionConfig.get= EvictionAlgorithmConfig()).getTimeToLive()); + assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.ge= tEvictionAlgorithmConfig()).getMaxAge()); + + } + finally + { + TestingUtil.killCaches(cache); + } } = public void testLegacyPolicyConfiguration() throws Exception { - this.setupCache("configs/local-lru-eviction.xml"); - assertEquals(5000, cache.getConfiguration().getEvictionConfig().getW= akeupInterval()); + CacheSPI cache =3D null; + RegionManager regionManager =3D null; = - Region region =3D regionManager.getRegion("/org/jboss/data", false); - EvictionPolicy policy =3D region.getEvictionPolicy(); - EvictionPolicyConfig configuration =3D region.getEvictionPolicyConfi= g(); - assertEquals(Fqn.fromString("/org/jboss/data/"), region.getFqn()); - assertTrue(policy instanceof LRUPolicy); - assertTrue(configuration instanceof LRUConfiguration); - assertEquals(5000, ((LRUConfiguration) configuration).getMaxNodes()); - assertEquals(1000000, ((LRUConfiguration) configuration).getTimeToLi= ve()); + try + { + cache =3D setupCache("configs/local-lru-eviction.xml"); + regionManager =3D cache.getRegionManager(); + assertEquals(5000, cache.getConfiguration().getEvictionConfig().g= etWakeupInterval()); = - region =3D regionManager.getRegion("/org/jboss/test/data", false); - policy =3D region.getEvictionPolicy(); - configuration =3D region.getEvictionPolicyConfig(); - assertEquals(Fqn.fromString("/org/jboss/test/data/"), region.getFqn(= )); - assertTrue(policy instanceof LRUPolicy); - assertTrue(configuration instanceof LRUConfiguration); - assertEquals(5, ((LRUConfiguration) configuration).getMaxNodes()); - assertEquals(4000, ((LRUConfiguration) configuration).getTimeToLive(= )); + Region region =3D regionManager.getRegion("/org/jboss/data", fals= e); + EvictionRegionConfig evictionRegionConfig =3D region.getEvictionR= egionConfig(); + assertEquals(Fqn.fromString("/org/jboss/data/"), region.getFqn()); + assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() inst= anceof LRUAlgorithmConfig); + assertEquals(5000, ((LRUAlgorithmConfig) evictionRegionConfig.get= EvictionAlgorithmConfig()).getMaxNodes()); + assertEquals(1000000, ((LRUAlgorithmConfig) evictionRegionConfig.= getEvictionAlgorithmConfig()).getTimeToLive()); = - region =3D regionManager.getRegion("/test", true); - policy =3D region.getEvictionPolicy(); - configuration =3D region.getEvictionPolicyConfig(); - assertEquals(Fqn.fromString("/test/"), region.getFqn()); - assertTrue(policy instanceof LRUPolicy); - assertTrue(configuration instanceof LRUConfiguration); - assertEquals(10000, ((LRUConfiguration) configuration).getMaxNodes()= ); - assertEquals(4000, ((LRUConfiguration) configuration).getTimeToLive(= )); + region =3D regionManager.getRegion("/org/jboss/test/data", false); + evictionRegionConfig =3D region.getEvictionRegionConfig(); + assertEquals(Fqn.fromString("/org/jboss/test/data/"), region.getF= qn()); + assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() inst= anceof LRUAlgorithmConfig); + assertEquals(5, ((LRUAlgorithmConfig) evictionRegionConfig.getEvi= ctionAlgorithmConfig()).getMaxNodes()); + assertEquals(4000, ((LRUAlgorithmConfig) evictionRegionConfig.get= EvictionAlgorithmConfig()).getTimeToLive()); = - region =3D regionManager.getRegion("/maxAgeTest", true); - policy =3D region.getEvictionPolicy(); - configuration =3D region.getEvictionPolicyConfig(); - assertEquals(Fqn.fromString("/maxAgeTest/"), region.getFqn()); - assertTrue(policy instanceof LRUPolicy); - assertTrue(configuration instanceof LRUConfiguration); - assertEquals(10000, ((LRUConfiguration) configuration).getMaxNodes()= ); - assertEquals(8000, ((LRUConfiguration) configuration).getTimeToLive(= )); - assertEquals(10000, ((LRUConfiguration) configuration).getMaxAge()); + region =3D regionManager.getRegion("/test", true); + evictionRegionConfig =3D region.getEvictionRegionConfig(); + assertEquals(Fqn.fromString("/test/"), region.getFqn()); + assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() inst= anceof LRUAlgorithmConfig); + assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.ge= tEvictionAlgorithmConfig()).getMaxNodes()); + assertEquals(4000, ((LRUAlgorithmConfig) evictionRegionConfig.get= EvictionAlgorithmConfig()).getTimeToLive()); = - // test the default region. use a region name that isn't defined exp= licitly in conf file. - region =3D regionManager.getRegion("/a/b/c", false); - policy =3D region.getEvictionPolicy(); - configuration =3D region.getEvictionPolicyConfig(); - assertEquals(Fqn.ROOT, region.getFqn()); - assertTrue(policy instanceof LRUPolicy); - assertTrue(configuration instanceof LRUConfiguration); - assertEquals(5000, ((LRUConfiguration) configuration).getMaxNodes()); - assertEquals(1000000, ((LRUConfiguration) configuration).getTimeToLi= ve()); - assertEquals(0, ((LRUConfiguration) configuration).getMaxAge()); + region =3D regionManager.getRegion("/maxAgeTest", true); + evictionRegionConfig =3D region.getEvictionRegionConfig(); + assertEquals(Fqn.fromString("/maxAgeTest/"), region.getFqn()); + assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() inst= anceof LRUAlgorithmConfig); + assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.ge= tEvictionAlgorithmConfig()).getMaxNodes()); + assertEquals(8000, ((LRUAlgorithmConfig) evictionRegionConfig.get= EvictionAlgorithmConfig()).getTimeToLive()); + assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.ge= tEvictionAlgorithmConfig()).getMaxAge()); = - cache.stop(); + // test the default region. use a region name that isn't defined = explicitly in conf file. + region =3D regionManager.getRegion("/a/b/c", false); + evictionRegionConfig =3D region.getEvictionRegionConfig(); + assertEquals(Fqn.ROOT, region.getFqn()); + assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() inst= anceof LRUAlgorithmConfig); + assertEquals(5000, ((LRUAlgorithmConfig) evictionRegionConfig.get= EvictionAlgorithmConfig()).getMaxNodes()); + assertEquals(1000000, ((LRUAlgorithmConfig) evictionRegionConfig.= getEvictionAlgorithmConfig()).getTimeToLive()); + assertEquals(0, ((LRUAlgorithmConfig) evictionRegionConfig.getEvi= ctionAlgorithmConfig()).getMaxAge()); = + } + finally + { + TestingUtil.killCaches(cache); + } } = public void testTwoCacheInstanceConfiguration() throws Exception @@ -193,17 +191,27 @@ = public void testNoEviction() throws Exception { - cache =3D (CacheSPI) new DefaultCacheFactory().createCache(); - regionManager =3D cache.getRegionManager(); - assertEquals(0, regionManager.getAllRegions(Region.Type.ANY).size()); + CacheSPI cache =3D null; + RegionManager regionManager =3D null; + + try + { + cache =3D (CacheSPI) new DefaultCacheFactory().createCache(); + regionManager =3D cache.getRegionManager(); + assertEquals(0, regionManager.getAllRegions(Region.Type.ANY).size= ()); + } + finally + { + TestingUtil.killCaches(cache); + } } = - private void setupCache(String configurationName) + private CacheSPI setupCache(String configurationName) { - cache =3D (CacheSPI) new DefaultCacheFactory().createCache(configurationName, false); + CacheSPI cache =3D (CacheSPI) new De= faultCacheFactory().createCache(configurationName, false); cache.getConfiguration().setTransactionManagerLookupClass("org.jboss= .cache.transaction.DummyTransactionManagerLookup"); cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZAB= LE); cache.start(); - regionManager =3D cache.getRegionManager(); + return cache; } } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolic= yTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.= java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.= java 2008-08-15 10:59:40 UTC (rev 6562) @@ -14,7 +14,7 @@ import org.jboss.cache.Region; import org.jboss.cache.config.Configuration; import org.jboss.cache.config.EvictionConfig; -import org.jboss.cache.config.EvictionPolicyConfig; +import org.jboss.cache.config.EvictionRegionConfig; import org.jboss.cache.util.TestingUtil; import static org.testng.AssertJUnit.*; import org.testng.annotations.AfterMethod; @@ -22,7 +22,7 @@ import org.testng.annotations.Test; = /** - * Unit tests for {@link ExpirationPolicy}. + * Unit tests for {@link org.jboss.cache.eviction.ExpirationAlgorithm}. * * @author Elias Ross * @version $Revision$ @@ -46,7 +46,9 @@ public void setUp() throws Exception { Configuration conf =3D new Configuration(); - EvictionConfig econf =3D new EvictionConfig(ExpirationPolicy.class.g= etName()); + ExpirationAlgorithmConfig eAC =3D new ExpirationAlgorithmConfig(); + EvictionRegionConfig eRC =3D new EvictionRegionConfig(Fqn.ROOT, eAC); + EvictionConfig econf =3D new EvictionConfig(eRC); econf.setWakeupInterval(1000); conf.setEvictionConfig(econf); cache =3D (CacheSPI) new DefaultCacheFactory().createCache(conf, false); @@ -64,9 +66,9 @@ = public void testEviction() throws Exception { - cache.put(fqn1, ExpirationConfiguration.EXPIRATION_KEY, future); - cache.put(fqn2, ExpirationConfiguration.EXPIRATION_KEY, past); - cache.put(fqn3, ExpirationConfiguration.EXPIRATION_KEY, future); + cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future); + cache.put(fqn2, ExpirationAlgorithmConfig.EXPIRATION_KEY, past); + cache.put(fqn3, ExpirationAlgorithmConfig.EXPIRATION_KEY, future); cache.put(fqn4, "foo", "bar"); TestingUtil.sleepThread(2000); assertNotNull(cache.getNode(fqn1)); @@ -83,10 +85,10 @@ public void testUpdate() throws Exception { log.info("update 1 from future to past"); - cache.put(fqn1, ExpirationConfiguration.EXPIRATION_KEY, future); + cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future); assertNotNull(cache.getNode(fqn1)); TestingUtil.sleepThread(1500); - cache.put(fqn1, ExpirationConfiguration.EXPIRATION_KEY, past); + cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, past); TestingUtil.sleepThread(1500); assertNull(cache.getNode(fqn1)); cache.removeNode(Fqn.ROOT); @@ -97,10 +99,10 @@ { log.info("update 1 from future to past"); Long future2 =3D future + 2000; - cache.put(fqn1, ExpirationConfiguration.EXPIRATION_KEY, future); + cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future); TestingUtil.sleepThread(2000); assertNotNull(cache.getNode(fqn1)); - cache.put(fqn1, ExpirationConfiguration.EXPIRATION_KEY, future2); + cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future2); TestingUtil.sleepThread(3000); assertNotNull(cache.getNode(fqn1)); TestingUtil.sleepThread(3000); @@ -111,14 +113,14 @@ public void testMaxNodes() throws Exception { log.info("set max nodes to 2, expire soonest to expire first"); - EvictionPolicyConfig epc =3D cache.getRegionManager().getAllRegions(= Region.Type.EVICTION).get(0).getEvictionPolicyConfig(); - ExpirationConfiguration ec =3D (ExpirationConfiguration) epc; + EvictionRegionConfig regionConfig =3D cache.getRegionManager().getAl= lRegions(Region.Type.EVICTION).get(0).getEvictionRegionConfig(); + ExpirationAlgorithmConfig ec =3D (ExpirationAlgorithmConfig) regionC= onfig.getEvictionAlgorithmConfig(); ec.setMaxNodes(2); Long future2 =3D future + 500; - cache.put(fqn1, ExpirationConfiguration.EXPIRATION_KEY, future2); - cache.put(fqn2, ExpirationConfiguration.EXPIRATION_KEY, future2); - cache.put(fqn3, ExpirationConfiguration.EXPIRATION_KEY, future); - cache.put(fqn4, ExpirationConfiguration.EXPIRATION_KEY, past); + cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future2); + cache.put(fqn2, ExpirationAlgorithmConfig.EXPIRATION_KEY, future2); + cache.put(fqn3, ExpirationAlgorithmConfig.EXPIRATION_KEY, future); + cache.put(fqn4, ExpirationAlgorithmConfig.EXPIRATION_KEY, past); assertEquals(5, cache.getNumberOfNodes()); Thread.sleep(2000); assertNotNull(cache.getNode(fqn1)); Modified: core/trunk/src/test/java/org/jboss/cache/eviction/FIFOAlgorithmTe= st.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/FIFOAlgorithmTest.jav= a 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/FIFOAlgorithmTest.jav= a 2008-08-15 10:59:40 UTC (rev 6562) @@ -8,9 +8,11 @@ = import org.jboss.cache.Fqn; import org.jboss.cache.Region; +import org.jboss.cache.RegionImpl; import org.jboss.cache.RegionManager; import org.jboss.cache.RegionManagerImpl; import org.jboss.cache.RegionRegistry; +import org.jboss.cache.config.EvictionRegionConfig; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertTrue; import org.testng.annotations.BeforeMethod; @@ -35,28 +37,29 @@ public void setUp() throws Exception { algo =3D new FIFOAlgorithm(); - FIFOConfiguration config =3D new FIFOConfiguration(); + FIFOAlgorithmConfig config =3D new FIFOAlgorithmConfig(); // We have to setCache maxNodes!! config.setMaxNodes(0); regionManager =3D new RegionManagerImpl(); ((RegionManagerImpl) regionManager).injectDependencies(null, null, n= ull, null, null, new RegionRegistry()); - config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName()); - regionManager.getRegion("/a/b", true).setEvictionPolicy(config); +// config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName()); + Region r =3D regionManager.getRegion("/a/b", true); + r.setEvictionRegionConfig(new EvictionRegionConfig(r.getFqn(), confi= g)); } = public void testMaxNodes1() throws Exception { - Region region =3D regionManager.getRegion("/a/b", true); - FIFOConfiguration config =3D (FIFOConfiguration) region.getEvictionP= olicyConfig(); + RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); + FIFOAlgorithmConfig config =3D (FIFOAlgorithmConfig) region.getEvict= ionRegionConfig().getEvictionAlgorithmConfig(); config.setMaxNodes(5); = for (int i =3D 0; i < 8; i++) { Fqn fqn =3D Fqn.fromString("/a/b/" + Integer.toString(i)); - region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_N= ODE_EVENT)); + region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NODE_EVE= NT); } = - algo.process(region); + algo.process(region.getEvictionEventQueue()); FIFOQueue queue =3D (FIFOQueue) algo.evictionQueue; assertEquals(5, algo.getEvictionQueue().getNumberOfNodes()); = @@ -75,15 +78,15 @@ for (int i =3D 3; i < 8; i++) { Fqn fqn =3D Fqn.fromString("/a/b/" + Integer.toString(i)); - region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.VISIT= _NODE_EVENT)); + region.registerEvictionEvent(fqn, EvictionEvent.Type.VISIT_NODE_E= VENT); } for (int i =3D 3; i < 5; i++) { Fqn fqn =3D Fqn.fromString("/a/b/" + Integer.toString(i)); - region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.VISIT= _NODE_EVENT)); + region.registerEvictionEvent(fqn, EvictionEvent.Type.VISIT_NODE_E= VENT); } = - algo.process(region); + algo.process(region.getEvictionEventQueue()); = assertEquals(5, algo.getEvictionQueue().getNumberOfNodes()); = @@ -100,17 +103,17 @@ = public void testMaxNodes2() throws Exception { - Region region =3D regionManager.getRegion("/a/b", true); - FIFOConfiguration config =3D (FIFOConfiguration) region.getEvictionP= olicyConfig(); + RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); + FIFOAlgorithmConfig config =3D (FIFOAlgorithmConfig) region.getEvict= ionRegionConfig().getEvictionAlgorithmConfig(); config.setMaxNodes(50000); = for (int i =3D 0; i < 50000; i++) { Fqn fqn =3D Fqn.fromString("/a/b/" + Integer.toString(i)); - region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_N= ODE_EVENT)); + region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NODE_EVE= NT); } = - algo.process(region); + algo.process(region.getEvictionEventQueue()); FIFOQueue queue =3D (FIFOQueue) algo.evictionQueue; assertEquals(50000, algo.getEvictionQueue().getNumberOfNodes()); = @@ -126,10 +129,10 @@ for (int i =3D 50000; i < 60000; i++) { Fqn fqn =3D Fqn.fromString("/a/b/" + Integer.toString(i)); - region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_N= ODE_EVENT)); + region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NODE_EVE= NT); } = - algo.process(region); + algo.process(region.getEvictionEventQueue()); = it =3D queue.iterate(); index =3D 10000; Modified: core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurati= onTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurationTest= .java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurationTest= .java 2008-08-15 10:59:40 UTC (rev 6562) @@ -6,13 +6,10 @@ */ package org.jboss.cache.eviction; = -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.fail; - import org.jboss.cache.config.ConfigurationException; -import org.jboss.cache.config.parsing.element.EvictionElementParser; import org.jboss.cache.config.parsing.XmlConfigHelper; +import org.jboss.cache.config.parsing.element.EvictionElementParser; +import static org.testng.AssertJUnit.*; import org.testng.annotations.Test; import org.w3c.dom.Element; = @@ -22,20 +19,19 @@ * @author Daniel Huang (dhuang(a)jboss.org) * @version $Revision$ */ -(a)Test(groups =3D {"functional"}) +(a)Test(groups =3D "unit", sequential =3D false) public class FIFOConfigurationTest { - public void testXMLParse() throws Exception { - FIFOConfiguration config =3D new FIFOConfiguration(); + FIFOAlgorithmConfig config =3D new FIFOAlgorithmConfig(); String xml =3D "" + "1000" + ""; = Element element =3D XmlConfigHelper.stringToElement(xml); = - EvictionElementParser.parseEvictionPolicyConfig(element, config); + EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); = assertEquals(1000, config.getMaxNodes()); = @@ -43,7 +39,7 @@ = public void testXMLParse2() throws Exception { - FIFOConfiguration config =3D new FIFOConfiguration(); + FIFOAlgorithmConfig config =3D new FIFOAlgorithmConfig(); String xml =3D "" + ""; = @@ -51,7 +47,7 @@ = try { - EvictionElementParser.parseEvictionPolicyConfig(element, config); + EvictionElementParser.parseEvictionPolicyConfig(element, config, = true); } catch (ConfigurationException ce) { @@ -63,7 +59,7 @@ = public void testXMLParse3() throws Exception { - FIFOConfiguration config =3D new FIFOConfiguration(); + FIFOAlgorithmConfig config =3D new FIFOAlgorithmConfig(); String xml =3D "" + "1000" + ""; @@ -72,7 +68,7 @@ = try { - EvictionElementParser.parseEvictionPolicyConfig(element, config); + EvictionElementParser.parseEvictionPolicyConfig(element, config, = true); } catch (ConfigurationException ce) { Modified: core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java 2= 008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java 2= 008-08-15 10:59:40 UTC (rev 6562) @@ -14,6 +14,7 @@ import org.jboss.cache.config.EvictionRegionConfig; import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; import org.jboss.cache.lock.IsolationLevel; +import org.jboss.cache.transaction.DummyTransactionManagerLookup; import org.jboss.cache.util.TestingUtil; import org.jboss.cache.util.internals.EvictionController; import static org.testng.AssertJUnit.*; @@ -21,9 +22,6 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = -import java.util.ArrayList; -import java.util.List; - /** * Unit tests for FIFOPolicy. * @@ -58,31 +56,15 @@ void initCaches() throws Exception { Configuration config =3D UnitTestCacheConfigurationFactory.createCon= figuration(Configuration.CacheMode.LOCAL, true); - EvictionConfig evConfig =3D config.getEvictionConfig(); - evConfig.setWakeupInterval(3000); + EvictionConfig evConfig =3D new EvictionConfig(new EvictionRegionCon= fig(Fqn.ROOT, new FIFOAlgorithmConfig(5000)), 3000); evConfig.setDefaultEventQueueSize(20000); - evConfig.setDefaultEvictionPolicyClass("org.jboss.cache.eviction.FIF= OPolicy"); - List erConfigs =3D new ArrayList(); - erConfigs.add(createEvictionRegionConfig("/_default_", 5000)); - erConfigs.add(createEvictionRegionConfig("/org/jboss/test/data", 5)); - evConfig.setEvictionRegionConfigs(erConfigs); - config.setTransactionManagerLookupClass("org.jboss.cache.transaction= .DummyTransactionManagerLookup"); + evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromSt= ring("/org/jboss/test/data"), new FIFOAlgorithmConfig(5))); + config.setEvictionConfig(evConfig); + config.setTransactionManagerLookupClass(DummyTransactionManagerLooku= p.class.getName()); config.setIsolationLevel(IsolationLevel.SERIALIZABLE); cache =3D (CacheSPI) new DefaultCacheFactory().createCache(config, true);// read in generic local xml } = - - private EvictionRegionConfig createEvictionRegionConfig(String regionNa= me, int maxNodes) - { - EvictionRegionConfig ercDefault =3D new EvictionRegionConfig(); - ercDefault.setRegionName(regionName); - FIFOConfiguration esConfig =3D new FIFOConfiguration(); - if (maxNodes >=3D 0) esConfig.setMaxNodes(maxNodes); - ercDefault.setEvictionPolicyConfig(esConfig); - return ercDefault; - } - - @AfterMethod(alwaysRun =3D true) public void tearDown() throws Exception { Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LFUAlgorithmTes= t.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/LFUAlgorithmTest.java= 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/LFUAlgorithmTest.java= 2008-08-15 10:59:40 UTC (rev 6562) @@ -7,10 +7,12 @@ package org.jboss.cache.eviction; = import org.jboss.cache.Fqn; -import org.jboss.cache.Region; +import org.jboss.cache.RegionImpl; import org.jboss.cache.RegionManager; import org.jboss.cache.RegionManagerImpl; import org.jboss.cache.RegionRegistry; +import org.jboss.cache.config.EvictionRegionConfig; +import static org.jboss.cache.eviction.EvictionEvent.Type.*; import static org.testng.AssertJUnit.*; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -33,11 +35,10 @@ public void setUp() throws Exception { algo =3D new LFUAlgorithm(); - LFUConfiguration config =3D new LFUConfiguration(); + LFUAlgorithmConfig config =3D new LFUAlgorithmConfig(); regionManager =3D new RegionManagerImpl(); ((RegionManagerImpl) regionManager).injectDependencies(null, null, n= ull, null, null, new RegionRegistry()); - config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName()); - regionManager.getRegion("/a/b", true).setEvictionPolicy(config); + regionManager.getRegion("/a/b", true).setEvictionRegionConfig(new Ev= ictionRegionConfig(Fqn.fromString("/a/b"), config)); // doesn't this need a cache?!?? :-/ } = @@ -45,16 +46,16 @@ { Fqn fqn1 =3D Fqn.fromString("/a/b/c"); Fqn fqn2 =3D Fqn.fromString("/a/b/d"); - Region region =3D regionManager.getRegion("/a/b", true); - LFUConfiguration config =3D new LFUConfiguration(); + RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); + LFUAlgorithmConfig config =3D new LFUAlgorithmConfig(); config.setMaxNodes(0); config.setMinNodes(20); - region.setEvictionPolicy(config); - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NOD= E_EVENT)); + region.setEvictionRegionConfig(new EvictionRegionConfig(region.getFq= n(), config)); + region.registerEvictionEvent(fqn1, ADD_NODE_EVENT); + region.registerEvictionEvent(fqn2, ADD_NODE_EVENT); try { - algo.process(region); + algo.process(region.getEvictionEventQueue()); } catch (EvictionException e) { @@ -70,17 +71,17 @@ Fqn fqn1 =3D Fqn.fromString("/a/b/c"); Fqn fqn2 =3D Fqn.fromString("/a/b/d"); Fqn fqn3 =3D Fqn.fromString("/a/b/e"); - Region region =3D regionManager.getRegion("/a/b", true); - LFUConfiguration config =3D new LFUConfiguration(); + RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); + LFUAlgorithmConfig config =3D new LFUAlgorithmConfig(); config.setMaxNodes(1); config.setMinNodes(20); - region.setEvictionPolicy(config); - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NOD= E_EVENT)); + region.setEvictionRegionConfig(new EvictionRegionConfig(region.getFq= n(), config)); + region.registerEvictionEvent(fqn1, ADD_NODE_EVENT); + region.registerEvictionEvent(fqn2, ADD_NODE_EVENT); = try { - algo.process(region); + algo.process(region.getEvictionEventQueue()); } catch (EvictionException e) { @@ -89,13 +90,13 @@ } assertEquals("Queue size should be ", 1, algo.getEvictionQueue().get= NumberOfNodes()); = - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NOD= E_EVENT)); + region.registerEvictionEvent(fqn2, ADD_NODE_EVENT); + region.registerEvictionEvent(fqn3, ADD_NODE_EVENT); = = try { - algo.process(region); + algo.process(region.getEvictionEventQueue()); } catch (EvictionException e) { @@ -105,35 +106,6 @@ assertEquals("Queue size should be ", 1, algo.getEvictionQueue().get= NumberOfNodes()); } = - // What's this doing here? This should be a stress test, not a functio= nal test. There are no assertions, for - // example. :S - Manik, Nov 06 - - // public void testMaxNode3() throws Exception - // { - // Region region =3D regionManager.getRegion("/a/b", true); - // LFUConfiguration config =3D new LFUConfiguration(); - // - // config.setMaxNodes(15000); - // config.setMinNodes(15000); - // - // region.setEvictionPolicy(config); - // for (int i =3D 0; i < 20000; i++) - // { - // Fqn fqn =3D Fqn.fromString("/a/b/" + Integer.toString(i)); - // region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.= ADD_NODE_EVENT)); - // - // if ((i % 2) =3D=3D 0) - // { - // region.putNodeEvent(new EvictedEventNode(fqn, NodeEventTy= pe.VISIT_NODE_EVENT)); - // } - // } - // - // algo.invokeRemote(region); - //// LFUQueue queue =3D (LFUQueue) algo.evictionQueue; - //// Iterator it =3D queue.iterate(); - // - // } - public void testMinNode1() throws Exception { Fqn fqn1 =3D Fqn.fromString("/a/b/c"); @@ -141,18 +113,18 @@ Fqn fqn3 =3D Fqn.fromString("/a/b/c/d/e"); Fqn fqn4 =3D Fqn.fromString("/a/b/c/d/e/f"); = - Region region =3D regionManager.getRegion("/a/b", true); - LFUConfiguration config =3D (LFUConfiguration) region.getEvictionPol= icyConfig(); + RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); + LFUAlgorithmConfig config =3D (LFUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); = config.setMaxNodes(0); config.setMinNodes(2); = - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn4, NodeEventType.ADD_NOD= E_EVENT)); + region.registerEvictionEvent(fqn1, ADD_NODE_EVENT); + region.registerEvictionEvent(fqn2, ADD_NODE_EVENT); + region.registerEvictionEvent(fqn3, ADD_NODE_EVENT); + region.registerEvictionEvent(fqn4, ADD_NODE_EVENT); = - algo.process(region); + algo.process(region.getEvictionEventQueue()); = assertEquals("Queue size should be ", 2, algo.getEvictionQueue().get= NumberOfNodes()); } @@ -162,16 +134,16 @@ Fqn fqn1 =3D Fqn.fromString("/a/b/c"); Fqn fqn2 =3D Fqn.fromString("/a/b/d"); = - Region region =3D regionManager.getRegion("/a/b", true); - LFUConfiguration config =3D (LFUConfiguration) region.getEvictionPol= icyConfig(); + RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); + LFUAlgorithmConfig config =3D (LFUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); = config.setMaxNodes(0); config.setMinNodes(0); = - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NOD= E_EVENT)); + region.registerEvictionEvent(fqn1, ADD_NODE_EVENT); + region.registerEvictionEvent(fqn2, ADD_NODE_EVENT); = - algo.process(region); + algo.process(region.getEvictionEventQueue()); = assertEquals("Queue size should be ", 0, algo.getEvictionQueue().get= NumberOfNodes()); } @@ -190,23 +162,23 @@ Fqn fqn10 =3D Fqn.fromString("/a/b/c/d/e/f/g/h/i/j/k/l/m"); = = - Region region =3D regionManager.getRegion("/a/b", true); - LFUConfiguration config =3D (LFUConfiguration) region.getEvictionPol= icyConfig(); + RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); + LFUAlgorithmConfig config =3D (LFUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); config.setMaxNodes(0); config.setMinNodes(100); = - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn4, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn5, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn6, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn7, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn8, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn9, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn10, NodeEventType.ADD_NO= DE_EVENT)); + region.registerEvictionEvent(fqn1, ADD_NODE_EVENT); + region.registerEvictionEvent(fqn2, ADD_NODE_EVENT); + region.registerEvictionEvent(fqn3, ADD_NODE_EVENT); + region.registerEvictionEvent(fqn4, ADD_NODE_EVENT); + region.registerEvictionEvent(fqn5, ADD_NODE_EVENT); + region.registerEvictionEvent(fqn6, ADD_NODE_EVENT); + region.registerEvictionEvent(fqn7, ADD_NODE_EVENT); + region.registerEvictionEvent(fqn8, ADD_NODE_EVENT); + region.registerEvictionEvent(fqn9, ADD_NODE_EVENT); + region.registerEvictionEvent(fqn10, ADD_NODE_EVENT); = - algo.process(region); + algo.process(region.getEvictionEventQueue()); LFUQueue queue =3D (LFUQueue) algo.evictionQueue; assertEquals(10, algo.getEvictionQueue().getNumberOfNodes()); Iterator it =3D queue.iterate(); @@ -219,31 +191,31 @@ } = // fqn1 visited 4 additional times. - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.VISIT_N= ODE_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.VISIT_N= ODE_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.VISIT_N= ODE_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.VISIT_N= ODE_EVENT)); + region.registerEvictionEvent(fqn1, VISIT_NODE_EVENT); + region.registerEvictionEvent(fqn1, VISIT_NODE_EVENT); + region.registerEvictionEvent(fqn1, VISIT_NODE_EVENT); + region.registerEvictionEvent(fqn1, VISIT_NODE_EVENT); = // fqn2 visited 3 additional times. - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.VISIT_N= ODE_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.VISIT_N= ODE_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.VISIT_N= ODE_EVENT)); + region.registerEvictionEvent(fqn2, VISIT_NODE_EVENT); + region.registerEvictionEvent(fqn2, VISIT_NODE_EVENT); + region.registerEvictionEvent(fqn2, VISIT_NODE_EVENT); = // fqn3 visited 1 additional time. - region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.VISIT_N= ODE_EVENT)); + region.registerEvictionEvent(fqn3, VISIT_NODE_EVENT); = // fqn4 visited 2 additional times. - region.putNodeEvent(new EvictedEventNode(fqn4, NodeEventType.VISIT_N= ODE_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn4, NodeEventType.VISIT_N= ODE_EVENT)); + region.registerEvictionEvent(fqn4, VISIT_NODE_EVENT); + region.registerEvictionEvent(fqn4, VISIT_NODE_EVENT); = // fqn9 visited 1 additional time. - region.putNodeEvent(new EvictedEventNode(fqn9, NodeEventType.VISIT_N= ODE_EVENT)); + region.registerEvictionEvent(fqn9, VISIT_NODE_EVENT); = // fqn10 visited 2 additional times. - region.putNodeEvent(new EvictedEventNode(fqn10, NodeEventType.VISIT_= NODE_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn10, NodeEventType.VISIT_= NODE_EVENT)); + region.registerEvictionEvent(fqn10, VISIT_NODE_EVENT); + region.registerEvictionEvent(fqn10, VISIT_NODE_EVENT); = - algo.process(region); + algo.process(region.getEvictionEventQueue()); System.out.println(); System.out.println(); = @@ -282,10 +254,10 @@ Fqn fqn11 =3D Fqn.fromString("/a"); Fqn fqn12 =3D Fqn.fromString("/a/b"); = - region.putNodeEvent(new EvictedEventNode(fqn11, NodeEventType.ADD_NO= DE_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn12, NodeEventType.ADD_NO= DE_EVENT)); + region.registerEvictionEvent(fqn11, ADD_NODE_EVENT); + region.registerEvictionEvent(fqn12, ADD_NODE_EVENT); = - algo.process(region); + algo.process(region.getEvictionEventQueue()); System.out.println(); System.out.println(); = @@ -320,12 +292,12 @@ = assertEquals(12, algo.getEvictionQueue().getNumberOfNodes()); = - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.REMOVE_= NODE_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn11, NodeEventType.REMOVE= _NODE_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn12, NodeEventType.REMOVE= _NODE_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn10, NodeEventType.REMOVE= _NODE_EVENT)); + region.registerEvictionEvent(fqn1, REMOVE_NODE_EVENT); + region.registerEvictionEvent(fqn11, REMOVE_NODE_EVENT); + region.registerEvictionEvent(fqn12, REMOVE_NODE_EVENT); + region.registerEvictionEvent(fqn10, REMOVE_NODE_EVENT); = - algo.process(region); + algo.process(region.getEvictionEventQueue()); = System.out.println(); System.out.println(); @@ -357,22 +329,22 @@ assertEquals(8, algo.getEvictionQueue().getNumberOfNodes()); = //test add/visit/remove combination - region.putNodeEvent(new EvictedEventNode(fqn11, NodeEventType.ADD_NO= DE_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn11, NodeEventType.VISIT_= NODE_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn11, NodeEventType.VISIT_= NODE_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn11, NodeEventType.VISIT_= NODE_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn11, NodeEventType.VISIT_= NODE_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn11, NodeEventType.VISIT_= NODE_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn4, NodeEventType.VISIT_N= ODE_EVENT)); + region.registerEvictionEvent(fqn11, ADD_NODE_EVENT); + region.registerEvictionEvent(fqn11, VISIT_NODE_EVENT); + region.registerEvictionEvent(fqn11, VISIT_NODE_EVENT); + region.registerEvictionEvent(fqn11, VISIT_NODE_EVENT); + region.registerEvictionEvent(fqn11, VISIT_NODE_EVENT); + region.registerEvictionEvent(fqn11, VISIT_NODE_EVENT); + region.registerEvictionEvent(fqn4, VISIT_NODE_EVENT); = // purposefully revisit a node that has been removed. assert that it= is readded. - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.VISIT_N= ODE_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.VISIT_N= ODE_EVENT)); + region.registerEvictionEvent(fqn1, VISIT_NODE_EVENT); + region.registerEvictionEvent(fqn1, VISIT_NODE_EVENT); = - region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.REMOVE_= NODE_EVENT)); + region.registerEvictionEvent(fqn3, REMOVE_NODE_EVENT); = = - algo.process(region); + algo.process(region.getEvictionEventQueue()); = System.out.println(); System.out.println(); @@ -405,18 +377,18 @@ = public void testEvictionQueueSortOrder2() throws Exception { - Region region =3D regionManager.getRegion("/a/b", true); - LFUConfiguration config =3D (LFUConfiguration) region.getEvictionPol= icyConfig(); + RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); + EvictionRegionConfig config =3D region.getEvictionRegionConfig(); = - config.setMaxNodes(0); - config.setMinNodes(10000); + ((LFUAlgorithmConfig) config.getEvictionAlgorithmConfig()).setMaxNod= es(0); + ((LFUAlgorithmConfig) config.getEvictionAlgorithmConfig()).setMinNod= es(10000); for (int i =3D 0; i < 10000; i++) { Fqn fqn =3D Fqn.fromString("/a/b/" + Integer.toString(i)); - region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_N= ODE_EVENT)); + region.registerEvictionEvent(fqn, ADD_NODE_EVENT); } = - algo.process(region); + algo.process(region.getEvictionEventQueue()); LFUQueue queue =3D (LFUQueue) algo.evictionQueue; Iterator it =3D queue.iterate(); = @@ -433,11 +405,11 @@ if ((i % 2) =3D=3D 0) { Fqn fqn =3D Fqn.fromString("/a/b/" + Integer.toString(i)); - region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.VI= SIT_NODE_EVENT)); + region.registerEvictionEvent(fqn, VISIT_NODE_EVENT); } } = - algo.process(region); + algo.process(region.getEvictionEventQueue()); = it =3D queue.iterate(); int count =3D 0; Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfiguratio= nTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfigurationTest.= java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfigurationTest.= java 2008-08-15 10:59:40 UTC (rev 6562) @@ -6,10 +6,9 @@ */ package org.jboss.cache.eviction; = -import static org.testng.AssertJUnit.assertEquals; - -import org.jboss.cache.config.parsing.element.EvictionElementParser; import org.jboss.cache.config.parsing.XmlConfigHelper; +import org.jboss.cache.config.parsing.element.EvictionElementParser; +import static org.testng.AssertJUnit.assertEquals; import org.testng.annotations.Test; import org.w3c.dom.Element; = @@ -19,22 +18,22 @@ * @author Daniel Huang (dhuang(a)jboss.org) * @version $Revision$ */ -(a)Test(groups =3D {"functional"}) +(a)Test(groups =3D "unit", sequential =3D false) public class LFUConfigurationTest { = public void testXMLParsing() throws Exception { - LFUConfiguration config =3D new LFUConfiguration(); + LFUAlgorithmConfig config =3D new LFUAlgorithmConfig(); String xml =3D "" + - "10" + - "20" + - ""; + "10" + + "20" + + ""; = Element element =3D XmlConfigHelper.stringToElement(xml); = - EvictionElementParser.parseEvictionPolicyConfig(element, config); + EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); = assertEquals(10, config.getMinNodes()); assertEquals(20, config.getMaxNodes()); @@ -42,14 +41,14 @@ = public void testXMLParsing2() throws Exception { - LFUConfiguration config =3D new LFUConfiguration(); + LFUAlgorithmConfig config =3D new LFUAlgorithmConfig(); String xml =3D "" + - "10" + - ""; + "10" + + ""; Element element =3D XmlConfigHelper.stringToElement(xml); = - EvictionElementParser.parseEvictionPolicyConfig(element, config); + EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); = assertEquals(10, config.getMinNodes()); assertEquals(0, config.getMaxNodes()); @@ -57,14 +56,14 @@ = public void testXMLParsing3() throws Exception { - LFUConfiguration config =3D new LFUConfiguration(); + LFUAlgorithmConfig config =3D new LFUAlgorithmConfig(); String xml =3D "" + - "20" + - ""; + "20" + + ""; Element element =3D XmlConfigHelper.stringToElement(xml); = - EvictionElementParser.parseEvictionPolicyConfig(element, config); + EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); = assertEquals(0, config.getMinNodes()); assertEquals(20, config.getMaxNodes()); Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java 20= 08-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java 20= 08-08-15 10:59:40 UTC (rev 6562) @@ -20,9 +20,6 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = -import java.util.ArrayList; -import java.util.List; - /** * Unit tests for LFU Policy. * @@ -57,31 +54,16 @@ void initCaches() throws Exception { Configuration config =3D UnitTestCacheConfigurationFactory.createCon= figuration(Configuration.CacheMode.LOCAL, true); - EvictionConfig evConfig =3D config.getEvictionConfig(); - evConfig.setWakeupInterval(3000); + EvictionConfig evConfig =3D new EvictionConfig(new EvictionRegionCon= fig(Fqn.ROOT, new LFUAlgorithmConfig(500, 10)), 3000); evConfig.setDefaultEventQueueSize(200000); - List erConfigs =3D new ArrayList(); - erConfigs.add(createEvictionRegionConfig("/_default_", 500, 10)); - erConfigs.add(createEvictionRegionConfig("/org/jboss/data", 5000, 40= 00)); - erConfigs.add(createEvictionRegionConfig("/org/jboss/test/data", -1,= 5)); - evConfig.setEvictionRegionConfigs(erConfigs); + evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromSt= ring("/org/jboss/data"), new LFUAlgorithmConfig(5000, 4000))); + evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromSt= ring("/org/jboss/test/data"), new LFUAlgorithmConfig(-1, 5))); + config.setEvictionConfig(evConfig); config.setTransactionManagerLookupClass("org.jboss.cache.transaction= .DummyTransactionManagerLookup"); config.setIsolationLevel(IsolationLevel.SERIALIZABLE); cache =3D (CacheSPI) new DefaultCacheFactory().createCache(config, true); } = - private EvictionRegionConfig createEvictionRegionConfig(String regionNa= me, int maxNodes, int minNodes) - { - EvictionRegionConfig ercDefault =3D new EvictionRegionConfig(); - ercDefault.setRegionName(regionName); - LFUConfiguration esConfig =3D new LFUConfiguration(); - if (maxNodes >=3D 0) esConfig.setMaxNodes(maxNodes); - if (minNodes >=3D 0) esConfig.setMinNodes(minNodes); - ercDefault.setEvictionPolicyConfig(esConfig); - esConfig.setEvictionPolicyClassName(); - return ercDefault; - } - @AfterMethod(alwaysRun =3D true) public void tearDown() throws Exception { Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTes= t.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java= 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java= 2008-08-15 10:59:40 UTC (rev 6562) @@ -4,9 +4,11 @@ import org.apache.commons.logging.LogFactory; import org.jboss.cache.Fqn; import org.jboss.cache.Region; +import org.jboss.cache.RegionImpl; import org.jboss.cache.RegionManager; import org.jboss.cache.RegionManagerImpl; import org.jboss.cache.RegionRegistry; +import org.jboss.cache.config.EvictionRegionConfig; import org.jboss.cache.util.TestingUtil; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertTrue; @@ -24,21 +26,22 @@ { RegionManager regionManager; LRUAlgorithm algorithm; - LRUConfiguration config; + LRUAlgorithmConfig config; Log log =3D LogFactory.getLog(LRUAlgorithm.class); = @BeforeMethod(alwaysRun =3D true) public void setUp() throws Exception { algorithm =3D new LRUAlgorithm(); - config =3D new LRUConfiguration(); - config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName()); + config =3D new LRUAlgorithmConfig(); +// config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName()); // We have to setCache timeToLiveSeconds!! config.setTimeToLive(0); = regionManager =3D new RegionManagerImpl(); ((RegionManagerImpl) regionManager).injectDependencies(null, null, n= ull, null, null, new RegionRegistry()); - regionManager.getRegion("/a/b", true).setEvictionPolicy(config); + Region r =3D regionManager.getRegion("/a/b", true); + r.setEvictionRegionConfig(new EvictionRegionConfig(r.getFqn(), confi= g)); } = /** @@ -49,20 +52,20 @@ Fqn fqn1 =3D Fqn.fromString("/a/b/c"); Fqn fqn2 =3D Fqn.fromString("/a/b/d"); Fqn fqn3 =3D Fqn.fromString("/a/b/e"); - Region region =3D regionManager.getRegion("/a/b", true); - LRUConfiguration config =3D (LRUConfiguration) region.getEvictionPol= icyConfig(); + RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); + LRUAlgorithmConfig config =3D (LRUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); config.setMaxNodes(1); - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NOD= E_EVENT)); + region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); = - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); = assertEquals("Queue size should be ", 1, algorithm.getEvictionQueue(= ).getNumberOfNodes()); = - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NOD= E_EVENT)); + region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT= ); = - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); = assertEquals("Queue size should be ", 1, algorithm.getEvictionQueue(= ).getNumberOfNodes()); } @@ -75,13 +78,13 @@ { Fqn fqn1 =3D Fqn.fromString("/a/b/c"); Fqn fqn2 =3D Fqn.fromString("/a/b/d"); - Region region =3D regionManager.getRegion("/a/b", true); - LRUConfiguration config =3D (LRUConfiguration) region.getEvictionPol= icyConfig(); + RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); + LRUAlgorithmConfig config =3D (LRUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); config.setMaxNodes(0); - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NOD= E_EVENT)); + region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); = - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); = assertEquals("Queue size should be ", 2, algorithm.getEvictionQueue(= ).getNumberOfNodes()); } @@ -94,21 +97,21 @@ Fqn fqn1 =3D Fqn.fromString("/a/b/c"); Fqn fqn2 =3D Fqn.fromString("/a/b/d"); Fqn fqn3 =3D Fqn.fromString("/a/b/e"); - Region region =3D regionManager.getRegion("/a/b", true); - LRUConfiguration config =3D (LRUConfiguration) region.getEvictionPol= icyConfig(); + RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); + LRUAlgorithmConfig config =3D (LRUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); config.setMaxNodes(1); - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NOD= E_EVENT)); + region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); = - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); = assertEquals("Queue size should be ", 1, algorithm.getEvictionQueue(= ).getNumberOfNodes()); = - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NOD= E_EVENT)); + region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT= ); = = - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); = assertEquals("Queue size should be ", 1, algorithm.getEvictionQueue(= ).getNumberOfNodes()); } @@ -120,16 +123,16 @@ { Fqn fqn1 =3D Fqn.fromString("/a/b/c"); Fqn fqn2 =3D Fqn.fromString("/a/b/d"); - Region region =3D regionManager.getRegion("/a/b", true); - LRUConfiguration config =3D (LRUConfiguration) region.getEvictionPol= icyConfig(); + RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); + LRUAlgorithmConfig config =3D (LRUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); config.setMaxNodes(0); config.setTimeToLive(0); - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NOD= E_EVENT)); + region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); = TestingUtil.sleepThread(500); = - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); = assertEquals("Queue size should be ", 2, algorithm.getEvictionQueue(= ).getNumberOfNodes()); } @@ -142,20 +145,20 @@ Fqn fqn1 =3D Fqn.fromString("/a/b/c"); Fqn fqn2 =3D Fqn.fromString("/a/b/d"); Fqn fqn3 =3D Fqn.fromString("/a/b/e"); - Region region =3D regionManager.getRegion("/a/b", true); - LRUConfiguration config =3D (LRUConfiguration) region.getEvictionPol= icyConfig(); + RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); + LRUAlgorithmConfig config =3D (LRUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); config.setMaxNodes(0); config.setTimeToLive(1000); - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NOD= E_EVENT)); + region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT= ); = - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); = assertEquals("Queue size #1: ", 3, algorithm.getEvictionQueue().getN= umberOfNodes()); TestingUtil.sleepThread(1100); = - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); = assertEquals("Queue size #2: ", 0, algorithm.getEvictionQueue().getN= umberOfNodes()); } @@ -168,21 +171,21 @@ Fqn fqn1 =3D Fqn.fromString("/a/b/c"); Fqn fqn2 =3D Fqn.fromString("/a/b/d"); Fqn fqn3 =3D Fqn.fromString("/a/b/e"); - Region region =3D regionManager.getRegion("/a/b", true); - LRUConfiguration config =3D (LRUConfiguration) region.getEvictionPol= icyConfig(); + RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); + LRUAlgorithmConfig config =3D (LRUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); config.setMaxNodes(0); config.setTimeToLive(1000); - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NOD= E_EVENT)); + region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT= ); = - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); = assertEquals("Queue size #1: ", 3, algorithm.getEvictionQueue().getN= umberOfNodes()); TestingUtil.sleepThread(1100); - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.VISIT_N= ODE_EVENT)); + region.registerEvictionEvent(fqn2, EvictionEvent.Type.VISIT_NODE_EVE= NT); = - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); assertEquals("Queue size #2: ", 1, algorithm.getEvictionQueue().getN= umberOfNodes()); } = @@ -196,19 +199,19 @@ Fqn fqn1 =3D Fqn.fromString("/a/b/c"); Fqn fqn2 =3D Fqn.fromString("/a/b/d"); Fqn fqn3 =3D Fqn.fromString("/a/b/e"); - Region region =3D regionManager.getRegion("/a/b", true); - LRUConfiguration config =3D (LRUConfiguration) region.getEvictionPol= icyConfig(); + RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); + LRUAlgorithmConfig config =3D (LRUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); config.setMaxNodes(0); config.setTimeToLive(0); config.setMaxAge(1000); - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NOD= E_EVENT)); + region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT= ); = - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); assertEquals("Queue size #1: ", 3, algorithm.getEvictionQueue().getN= umberOfNodes()); TestingUtil.sleepThread(1100); - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); assertEquals("Queue size #2: ", 0, algorithm.getEvictionQueue().getN= umberOfNodes()); } = @@ -222,23 +225,23 @@ Fqn fqn1 =3D Fqn.fromString("/a/b/c"); Fqn fqn2 =3D Fqn.fromString("/a/b/d"); Fqn fqn3 =3D Fqn.fromString("/a/b/e"); - Region region =3D regionManager.getRegion("/a/b", true); - LRUConfiguration config =3D (LRUConfiguration) region.getEvictionPol= icyConfig(); + RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); + LRUAlgorithmConfig config =3D (LRUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); = config.setMaxNodes(0); config.setTimeToLive(0); config.setMaxAge(1000); - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NOD= E_EVENT)); + region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT= ); = - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); assertEquals("Queue size #1: ", 3, algorithm.getEvictionQueue().getN= umberOfNodes()); TestingUtil.sleepThread(500); - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); assertEquals("Queue size #2: ", 3, algorithm.getEvictionQueue().getN= umberOfNodes()); TestingUtil.sleepThread(600); - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); assertEquals("Queue size #3: ", 0, algorithm.getEvictionQueue().getN= umberOfNodes()); } = @@ -251,18 +254,18 @@ Fqn fqn2 =3D Fqn.fromString("/a/b/d"); Fqn fqn3 =3D Fqn.fromString("/a/b/e"); Fqn fqn4 =3D Fqn.fromString("/a/b/f"); - Region region =3D regionManager.getRegion("/a/b", true); - LRUConfiguration config =3D (LRUConfiguration) region.getEvictionPol= icyConfig(); + RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); + LRUAlgorithmConfig config =3D (LRUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); = // Should have a maximum of 2 nodes. config.setMaxNodes(2); config.setTimeToLive(1000); config.setMaxAge(3000); - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn4, NodeEventType.ADD_NOD= E_EVENT)); + region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn4, EvictionEvent.Type.ADD_NODE_EVENT= ); = - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); EvictionQueue eq =3D algorithm.getEvictionQueue(); = int numNodesInQueue =3D eq.getNumberOfNodes(); @@ -271,9 +274,9 @@ // make sure all nodes now expire TestingUtil.sleepThread(1100); = - region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NOD= E_EVENT)); + region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT= ); = - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); = numNodesInQueue =3D eq.getNumberOfNodes(); assert 1 =3D=3D numNodesInQueue : "Queue size #2: expected 1 but was= " + numNodesInQueue; @@ -281,9 +284,9 @@ TestingUtil.sleepThread(3100); // visit the node now to prevent the idle time from doing the prunin= g - node still gets pruned but by // max age. - region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.VISIT_N= ODE_EVENT)); + region.registerEvictionEvent(fqn3, EvictionEvent.Type.VISIT_NODE_EVE= NT); = - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); = numNodesInQueue =3D eq.getNumberOfNodes(); assert 0 =3D=3D numNodesInQueue : "Queue size #3: expected 0 but was= " + numNodesInQueue; @@ -297,17 +300,17 @@ Fqn fqn1 =3D Fqn.fromString("/a/b/c"); Fqn fqn2 =3D Fqn.fromString("/a/b/d"); Fqn fqn3 =3D Fqn.fromString("/a/b/e"); - Region region =3D regionManager.getRegion("/a/b", true); - LRUConfiguration config =3D (LRUConfiguration) region.getEvictionPol= icyConfig(); + RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); + LRUAlgorithmConfig config =3D (LRUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); = config.setMaxNodes(2); config.setTimeToLive(1000); config.setMaxAge(3000); - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.REMOVE_= NODE_EVENT)); + region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn2, EvictionEvent.Type.REMOVE_NODE_EV= ENT); = - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); = EvictionQueue eq =3D algorithm.getEvictionQueue(); int numNodesInQueue =3D eq.getNumberOfNodes(); @@ -315,17 +318,17 @@ = // make sure existing events all time out TestingUtil.sleepThread(1100); - region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NOD= E_EVENT)); + region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT= ); = - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); = numNodesInQueue =3D eq.getNumberOfNodes(); assert 1 =3D=3D numNodesInQueue : "Queue size #2: expected 1 but was= " + numNodesInQueue; = TestingUtil.sleepThread(3100); - region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.VISIT_N= ODE_EVENT)); + region.registerEvictionEvent(fqn3, EvictionEvent.Type.VISIT_NODE_EVE= NT); = - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); = numNodesInQueue =3D eq.getNumberOfNodes(); assert 0 =3D=3D numNodesInQueue : "Queue size #3: expected 0 but was= " + numNodesInQueue; @@ -333,8 +336,8 @@ = public void testEvictionSortOrder() throws EvictionException { - Region region =3D regionManager.getRegion("/a/b", true); - LRUConfiguration config =3D (LRUConfiguration) region.getEvictionPol= icyConfig(); + RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); + LRUAlgorithmConfig config =3D (LRUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); = config.setMaxAge(1000000); config.setMaxNodes(0); @@ -343,21 +346,21 @@ for (int i =3D 0; i < 100; i++) { Fqn fqn =3D Fqn.fromString("/a/b/" + Integer.toString(i)); - region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_N= ODE_EVENT)); + region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NODE_EVE= NT); } = - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); = for (int i =3D 0; i < 100; i++) { Fqn fqn =3D Fqn.fromString("/a/b/" + Integer.toString(i)); if (i % 2 =3D=3D 0) { - region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.VI= SIT_NODE_EVENT)); + region.registerEvictionEvent(fqn, EvictionEvent.Type.VISIT_NOD= E_EVENT); } } = - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); = LRUQueue queue =3D (LRUQueue) algorithm.getEvictionQueue(); = @@ -380,10 +383,10 @@ for (int i =3D 0; i < 100; i++) { Fqn fqn =3D Fqn.fromString("/a/b/" + Integer.toString(i)); - region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_N= ODE_EVENT)); + region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NODE_EVE= NT); } = - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); long lastCreateTimestamp =3D 0; while ((ne =3D queue.getFirstMaxAgeNodeEntry()) !=3D null) { Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfiguratio= nTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.= java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.= java 2008-08-15 10:59:40 UTC (rev 6562) @@ -6,12 +6,11 @@ */ package org.jboss.cache.eviction; = -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; - import org.jboss.cache.config.ConfigurationException; -import org.jboss.cache.config.parsing.element.EvictionElementParser; import org.jboss.cache.config.parsing.XmlConfigHelper; +import org.jboss.cache.config.parsing.element.EvictionElementParser; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; import org.testng.annotations.Test; import org.w3c.dom.Element; = @@ -21,13 +20,13 @@ * @author Daniel Huang (dhuang(a)jboss.org) * @version $Revision$ */ -(a)Test(groups =3D {"functional"}) +(a)Test(groups =3D "unit", sequential =3D false) public class LRUConfigurationTest { = public void testXMLParsing() throws Exception { - LRUConfiguration config =3D new LRUConfiguration(); + LRUAlgorithmConfig config =3D new LRUAlgorithmConfig(); String xml =3D "\n" + "5000\n" + @@ -36,7 +35,7 @@ = Element element =3D XmlConfigHelper.stringToElement(xml); = - EvictionElementParser.parseEvictionPolicyConfig(element, config); + EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); = assertEquals(5000, config.getMaxNodes()); assertEquals(1000000, config.getTimeToLive()); @@ -44,7 +43,7 @@ = public void testXMLParsing2() throws Exception { - LRUConfiguration config =3D new LRUConfiguration(); + LRUAlgorithmConfig config =3D new LRUAlgorithmConfig(); String xml =3D "\n" + "10000\n" + "8\n" + @@ -52,7 +51,7 @@ ""; Element element =3D XmlConfigHelper.stringToElement(xml); = - EvictionElementParser.parseEvictionPolicyConfig(element, config); + EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); = assertEquals(10000, config.getMaxNodes()); assertEquals(8000, config.getTimeToLive()); @@ -61,7 +60,7 @@ = public void testXMLParsing3() throws Exception { - LRUConfiguration config =3D new LRUConfiguration(); + LRUAlgorithmConfig config =3D new LRUAlgorithmConfig(); String xml =3D "\n" + "10000\n" + "10\n" + @@ -70,7 +69,7 @@ boolean caught =3D false; try { - EvictionElementParser.parseEvictionPolicyConfig(element, config); + EvictionElementParser.parseEvictionPolicyConfig(element, config, = true); } catch (ConfigurationException ce) { @@ -85,7 +84,7 @@ = element =3D XmlConfigHelper.stringToElement(xml); = - EvictionElementParser.parseEvictionPolicyConfig(element, config); + EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); = assertEquals(0, config.getMaxNodes()); } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java 20= 08-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java 20= 08-08-15 10:59:40 UTC (rev 6562) @@ -47,8 +47,8 @@ EvictionConfig evConfig =3D conf.getEvictionConfig(); evConfig.setWakeupInterval(1000); List regionConfigs =3D new ArrayList(); - regionConfigs.add(UnitTestCacheConfigurationFactory.buildLruEviction= RegionConfig("/org/jboss/test/data", 5, dataRegionTTLMillis)); - regionConfigs.add(UnitTestCacheConfigurationFactory.buildLruEviction= RegionConfig("/test", 10000, testRegionTTLMillis)); + regionConfigs.add(new EvictionRegionConfig(Fqn.fromString("/org/jbos= s/test/data"), new LRUAlgorithmConfig(dataRegionTTLMillis, 5))); + regionConfigs.add(new EvictionRegionConfig(Fqn.fromString("/test"), = new LRUAlgorithmConfig(testRegionTTLMillis, 10000))); evConfig.setEvictionRegionConfigs(regionConfigs); conf.setTransactionManagerLookupClass("org.jboss.cache.transaction.D= ummyTransactionManagerLookup"); conf.setIsolationLevel(IsolationLevel.SERIALIZABLE); Modified: core/trunk/src/test/java/org/jboss/cache/eviction/MRUAlgorithmTes= t.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/MRUAlgorithmTest.java= 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/MRUAlgorithmTest.java= 2008-08-15 10:59:40 UTC (rev 6562) @@ -8,9 +8,11 @@ = import org.jboss.cache.Fqn; import org.jboss.cache.Region; +import org.jboss.cache.RegionImpl; import org.jboss.cache.RegionManager; import org.jboss.cache.RegionManagerImpl; import org.jboss.cache.RegionRegistry; +import org.jboss.cache.config.EvictionRegionConfig; import static org.testng.AssertJUnit.*; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -31,13 +33,14 @@ public void setUp() throws Exception { algorithm =3D new MRUAlgorithm(); - MRUConfiguration config =3D new MRUConfiguration(); - // We have to setCache maxNodes!! + MRUAlgorithmConfig config =3D new MRUAlgorithmConfig(); + // We have to set maxNodes explicitly!! config.setMaxNodes(0); - config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName()); +// config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName()); regionManager =3D new RegionManagerImpl(); ((RegionManagerImpl) regionManager).injectDependencies(null, null, n= ull, null, null, new RegionRegistry()); - regionManager.getRegion("/a/b", true).setEvictionPolicy(config); + Region r =3D regionManager.getRegion("/a/b", true); + r.setEvictionRegionConfig(new EvictionRegionConfig(r.getFqn(), confi= g)); } = public void testMaxNodes() throws Exception @@ -45,13 +48,13 @@ Fqn fqn1 =3D Fqn.fromString("/a/b/c"); Fqn fqn2 =3D Fqn.fromString("/a/b/d"); Fqn fqn3 =3D Fqn.fromString("/a/b/e"); - Region region =3D regionManager.getRegion("/a/b", true); - MRUConfiguration config =3D (MRUConfiguration) region.getEvictionPol= icyConfig(); + RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); + MRUAlgorithmConfig config =3D (MRUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); config.setMaxNodes(1); - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NOD= E_EVENT)); - algorithm.process(region); + region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT= ); + algorithm.process(region.getEvictionEventQueue()); = assertEquals(1, algorithm.getEvictionQueue().getNumberOfNodes()); = @@ -59,10 +62,10 @@ for (int i =3D 0; i < 150; i++) { Fqn fqn =3D Fqn.fromString("/a/b/c/" + Integer.toString(i)); - region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_N= ODE_EVENT)); + region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NODE_EVE= NT); } = - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); = assertEquals(100, algorithm.getEvictionQueue().getNumberOfNodes()); } @@ -79,32 +82,32 @@ Fqn fqn8 =3D Fqn.fromString("/a/b/j"); Fqn fqn9 =3D Fqn.fromString("/a/b/k"); Fqn fqn10 =3D Fqn.fromString("/a/b/l"); - Region region =3D regionManager.getRegion("/a/b", true); - MRUConfiguration config =3D (MRUConfiguration) region.getEvictionPol= icyConfig(); + RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); + MRUAlgorithmConfig config =3D (MRUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); config.setMaxNodes(8); - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn4, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn5, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn6, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn7, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn8, NodeEventType.ADD_NOD= E_EVENT)); + region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn4, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn5, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn6, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn7, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn8, EvictionEvent.Type.ADD_NODE_EVENT= ); = - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); = assertEquals(8, algorithm.getEvictionQueue().getNumberOfNodes()); = - region.putNodeEvent(new EvictedEventNode(fqn9, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn10, NodeEventType.ADD_NO= DE_EVENT)); + region.registerEvictionEvent(fqn9, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn10, EvictionEvent.Type.ADD_NODE_EVEN= T); = Thread.sleep(5000); assertEquals(8, algorithm.getEvictionQueue().getNumberOfNodes()); = - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn4, NodeEventType.ADD_NOD= E_EVENT)); + region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn4, EvictionEvent.Type.ADD_NODE_EVENT= ); = - algorithm.process(region); + algorithm.process(region.getEvictionEventQueue()); = assertEquals(8, algorithm.getEvictionQueue().getNumberOfNodes()); = Modified: core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfiguratio= nTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.= java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.= java 2008-08-15 10:59:40 UTC (rev 6562) @@ -6,12 +6,11 @@ */ package org.jboss.cache.eviction; = -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; - import org.jboss.cache.config.ConfigurationException; -import org.jboss.cache.config.parsing.element.EvictionElementParser; import org.jboss.cache.config.parsing.XmlConfigHelper; +import org.jboss.cache.config.parsing.element.EvictionElementParser; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.w3c.dom.Element; @@ -22,15 +21,15 @@ * @author Daniel Huang (dhuang(a)jboss.org) * @version $Revision$ */ -(a)Test(groups =3D {"functional"}) +(a)Test(groups =3D "unit", sequential =3D false) public class MRUConfigurationTest { - MRUConfiguration config =3D null; + MRUAlgorithmConfig config =3D null; = @BeforeMethod(alwaysRun =3D true) public void setUp() throws Exception { - config =3D new MRUConfiguration(); + config =3D new MRUAlgorithmConfig(); } = public void testXMLParsing() throws Exception @@ -41,7 +40,7 @@ ""; Element element =3D XmlConfigHelper.stringToElement(xml); = - EvictionElementParser.parseEvictionPolicyConfig(element, config); + EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); = assertEquals(5000, config.getMaxNodes()); } @@ -53,7 +52,7 @@ ""; Element element =3D XmlConfigHelper.stringToElement(xml); = - EvictionElementParser.parseEvictionPolicyConfig(element, config); + EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); = assertEquals(10000, config.getMaxNodes()); } @@ -66,7 +65,7 @@ boolean caught =3D false; try { - EvictionElementParser.parseEvictionPolicyConfig(element, config); + EvictionElementParser.parseEvictionPolicyConfig(element, config, = true); } catch (ConfigurationException ce) { @@ -80,7 +79,7 @@ = element =3D XmlConfigHelper.stringToElement(xml); = - EvictionElementParser.parseEvictionPolicyConfig(element, config); + EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); = assertEquals(10000, config.getMaxNodes()); } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/MRUPolicyTest.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/MRUPolicyTest.java 20= 08-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/MRUPolicyTest.java 20= 08-08-15 10:59:40 UTC (rev 6562) @@ -8,20 +8,19 @@ = import org.jboss.cache.CacheSPI; import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.Fqn; import org.jboss.cache.config.Configuration; import org.jboss.cache.config.EvictionConfig; import org.jboss.cache.config.EvictionRegionConfig; import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; import org.jboss.cache.lock.IsolationLevel; +import org.jboss.cache.transaction.DummyTransactionManagerLookup; import org.jboss.cache.util.TestingUtil; import static org.testng.AssertJUnit.*; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = -import java.util.ArrayList; -import java.util.List; - /** * Unit tests for MRUPolicy. * @@ -65,27 +64,17 @@ EvictionConfig evConfig =3D config.getEvictionConfig(); evConfig.setWakeupInterval(3000); evConfig.setDefaultEventQueueSize(200000); - evConfig.setDefaultEvictionPolicyClass("org.jboss.cache.eviction.MRU= Policy"); - List evictionRegionConfigs =3D new ArrayList(); - evictionRegionConfigs.add(buildEvictionRegionConfig("_default_", 100= )); - evictionRegionConfigs.add(buildEvictionRegionConfig("/org/jboss/test= /data", 6)); - evConfig.setEvictionRegionConfigs(evictionRegionConfigs); + // root ERC + evConfig.setDefaultEvictionRegionConfig(new EvictionRegionConfig(Fqn= .ROOT, new MRUAlgorithmConfig(100))); + // new region ERC + evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromSt= ring("/org/jboss/test/data"), new MRUAlgorithmConfig(6))); = - config.setTransactionManagerLookupClass("org.jboss.cache.transaction= .DummyTransactionManagerLookup"); + + config.setTransactionManagerLookupClass(DummyTransactionManagerLooku= p.class.getName()); config.setIsolationLevel(IsolationLevel.SERIALIZABLE); - cache =3D (CacheSPI) new DefaultCacheFactory().creat= eCache(config); + cache =3D (CacheSPI) new DefaultCacheFactory().createCache(config); } = - private EvictionRegionConfig buildEvictionRegionConfig(String regionNam= e, int maxNodes) - { - EvictionRegionConfig erc =3D new EvictionRegionConfig(); - erc.setRegionName(regionName); - MRUConfiguration mruConfiguration =3D new MRUConfiguration(); - mruConfiguration.setMaxNodes(maxNodes); - erc.setEvictionPolicyConfig(mruConfiguration); - return erc; - } - public void testEviction() throws Exception { cache.put("/org/jboss/test/data/a", "/org/jboss/test/data/a", "/org/= jboss/test/data/a"); Modified: core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionCon= figTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTes= t.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTes= t.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -8,7 +8,6 @@ = import org.jboss.cache.config.parsing.XmlConfigHelper; import org.jboss.cache.config.parsing.element.EvictionElementParser; -import static org.testng.AssertJUnit.fail; import org.testng.annotations.Test; import org.w3c.dom.Element; = @@ -18,7 +17,7 @@ * @author Daniel Huang (dhuang(a)jboss.org) * @version $Revision: 4444 $ */ -(a)Test(groups =3D {"functional"}) +(a)Test(groups =3D "unit", sequential =3D false) public class NullEvictionConfigTest { /** @@ -43,14 +42,7 @@ private void testConfigBlock(String xml) throws Exception { Element element =3D XmlConfigHelper.stringToElement(xml); - NullEvictionPolicyConfig config =3D new NullEvictionPolicyConfig(); - try - { - EvictionElementParser.parseEvictionPolicyConfig(element, config); - } - catch (Exception e) - { - fail(e.getMessage()); - } + NullEvictionAlgorithmConfig config =3D new NullEvictionAlgorithmConf= ig(); + EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); } } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionPol= icyTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionPolicyTes= t.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionPolicyTes= t.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -9,6 +9,7 @@ import org.jboss.cache.config.EvictionRegionConfig; import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; import org.jboss.cache.lock.IsolationLevel; +import org.jboss.cache.transaction.DummyTransactionManagerLookup; import org.jboss.cache.util.TestingUtil; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNull; @@ -16,34 +17,24 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = -import java.util.ArrayList; -import java.util.List; - -/** - * Unit tests for LRU Policy. - * - * @author Ben Wang, Feb 11, 2004 - * @author Daniel Huang - dhuang(a)jboss.org - * @version $Revision: 4880 $ - */ @Test(groups =3D {"functional"}) public class NullEvictionPolicyTest { - CacheSPI cache_; + CacheSPI cache; = @BeforeMethod(alwaysRun =3D true) public void setUp() throws Exception { - cache_ =3D null; + cache =3D null; } = @AfterMethod(alwaysRun =3D true) public void tearDown() throws Exception { - if (cache_ !=3D null) + if (cache !=3D null) { - cache_.stop(); - cache_.destroy(); + cache.stop(); + cache.destroy(); } } = @@ -57,18 +48,14 @@ public void testEviction() { Configuration config =3D UnitTestCacheConfigurationFactory.createCon= figuration(Configuration.CacheMode.LOCAL, true); - EvictionConfig evConfig =3D config.getEvictionConfig(); - evConfig.setWakeupInterval(1000); + EvictionConfig evConfig =3D new EvictionConfig(new EvictionRegionCon= fig(Fqn.ROOT, new NullEvictionAlgorithmConfig()), 1000); evConfig.setDefaultEventQueueSize(200000); - evConfig.setDefaultEvictionPolicyClass("org.jboss.cache.eviction.Nul= lEvictionPolicy"); - List regionConfigs =3D new ArrayList(); - regionConfigs.add(buildEvictionRegionConfig("/_default_")); - regionConfigs.add(buildEvictionRegionConfig("/test")); - regionConfigs.add(UnitTestCacheConfigurationFactory.buildLruEviction= RegionConfig("/lru", 10000, 1000)); - evConfig.setEvictionRegionConfigs(regionConfigs); - config.setTransactionManagerLookupClass("org.jboss.cache.transaction= .DummyTransactionManagerLookup"); + evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromSt= ring("/test"), new NullEvictionAlgorithmConfig())); + evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromSt= ring("/lru"), new LRUAlgorithmConfig(1000, 10000))); + config.setEvictionConfig(evConfig); + config.setTransactionManagerLookupClass(DummyTransactionManagerLooku= p.class.getName()); config.setIsolationLevel(IsolationLevel.SERIALIZABLE); - cache_ =3D (CacheSPI) new DefaultCacheFactory().crea= teCache(config); + cache =3D (CacheSPI) new DefaultCacheFactory().createCache(config); = String dfltRootStr =3D "/a/"; String testRootStr =3D "/test/"; @@ -79,9 +66,9 @@ Fqn dflt =3D Fqn.fromString(dfltRootStr + i); Fqn test =3D Fqn.fromString(testRootStr + i); Fqn lru =3D Fqn.fromString(lruRootStr + i); - cache_.put(dflt, "key", "value"); - cache_.put(test, "key", "value"); - cache_.put(lru, "key", "value"); + cache.put(dflt, "key", "value"); + cache.put(test, "key", "value"); + cache.put(lru, "key", "value"); } TestingUtil.sleepThread(3500); for (int i =3D 0; i < 20; i++) @@ -90,19 +77,9 @@ Fqn test =3D Fqn.fromString(testRootStr + i); Fqn lru =3D Fqn.fromString(lruRootStr + i); = - assertEquals("value", cache_.get(dflt, "key")); - assertEquals("value", cache_.get(test, "key")); - assertNull(cache_.get(lru, "key")); + assertEquals("value", cache.get(dflt, "key")); + assertEquals("value", cache.get(test, "key")); + assertNull(cache.get(lru, "key")); } } - - private EvictionRegionConfig buildEvictionRegionConfig(String regionNam= e) - { - EvictionRegionConfig evRegConfig =3D new EvictionRegionConfig(); - evRegConfig.setRegionName(regionName); - NullEvictionPolicyConfig nullEvictionPolicyConfig =3D new NullEvicti= onPolicyConfig(); - evRegConfig.setEvictionPolicyConfig(nullEvictionPolicyConfig); - return evRegConfig; - } - } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvict= ionTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTes= t.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTes= t.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -3,7 +3,6 @@ import org.jboss.cache.CacheSPI; import org.jboss.cache.DefaultCacheFactory; import org.jboss.cache.Fqn; -import org.jboss.cache.RegionManagerImpl; import org.jboss.cache.config.Configuration; import org.jboss.cache.config.EvictionConfig; import org.jboss.cache.config.EvictionRegionConfig; @@ -54,30 +53,9 @@ = private EvictionConfig buildEvictionConfig() throws Exception { - EvictionConfig result =3D new EvictionConfig("org.jboss.cache.evicti= on.LRUPolicy"); - result.setWakeupInterval(1000); - - LRUConfiguration lruConfiguration =3D new LRUConfiguration(); - lruConfiguration.setMaxNodes(10); - lruConfiguration.setTimeToLive(0); - lruConfiguration.setMaxAge(0); - EvictionRegionConfig erConfig1 =3D new EvictionRegionConfig(RegionMa= nagerImpl.DEFAULT_REGION, lruConfiguration); - - LRUConfiguration lruConfiguration2 =3D new LRUConfiguration(); - lruConfiguration2.setMaxNodes(10); - lruConfiguration2.setTimeToLive(0); - lruConfiguration2.setMaxAge(0); - EvictionRegionConfig erConfig2 =3D new EvictionRegionConfig(Fqn.from= String("/testingRegion"), lruConfiguration2); - - LRUConfiguration lruConfiguration3 =3D new LRUConfiguration(); - lruConfiguration3.setMaxNodes(10); - lruConfiguration3.setTimeToLive(1000); - lruConfiguration3.setMaxAge(1000); - EvictionRegionConfig erConfig3 =3D new EvictionRegionConfig(Fqn.from= String("/timeBased"), lruConfiguration3); - - result.getEvictionRegionConfigs().add(erConfig1); - result.getEvictionRegionConfigs().add(erConfig2); - result.getEvictionRegionConfigs().add(erConfig3); + EvictionConfig result =3D new EvictionConfig(new EvictionRegionConfi= g(Fqn.ROOT, new LRUAlgorithmConfig(0, 0, 10)), 1000); + result.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromStri= ng("/testingRegion"), new LRUAlgorithmConfig(0, 0, 10))); + result.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromStri= ng("/timeBased"), new LRUAlgorithmConfig(1000, 1000, 10))); return result; } = Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRU= PolicyTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicy= Test.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicy= Test.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -33,6 +33,7 @@ import org.jboss.cache.config.EvictionRegionConfig; import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; import org.jboss.cache.lock.IsolationLevel; +import org.jboss.cache.transaction.DummyTransactionManagerLookup; import org.jboss.cache.util.TestingUtil; import static org.testng.AssertJUnit.*; import org.testng.annotations.AfterMethod; @@ -69,8 +70,9 @@ Configuration conf =3D UnitTestCacheConfigurationFactory.createConfi= guration(Configuration.CacheMode.LOCAL, true); CacheFactory instance =3D new DefaultCacheFactory(); cache =3D (CacheSPI) instance.createCache(conf, fals= e); - conf.getEvictionConfig().setWakeupInterval(5000); - cache.getConfiguration().setTransactionManagerLookupClass("org.jboss= .cache.transaction.DummyTransactionManagerLookup"); + EvictionConfig erc =3D new EvictionConfig(new EvictionRegionConfig(F= qn.ROOT, new LRUAlgorithmConfig(0, 0, 10)), 5000); + conf.setEvictionConfig(erc); + cache.getConfiguration().setTransactionManagerLookupClass(DummyTrans= actionManagerLookup.class.getName()); cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZAB= LE); = cache.create(); @@ -85,16 +87,15 @@ = private void addStringBasedRegion() throws Exception { - LRUConfiguration lruConfig =3D new LRUConfiguration(); - lruConfig.setMaxNodes(1000); - lruConfig.setTimeToLive(4000); - EvictionRegionConfig regConfig =3D new EvictionRegionConfig(Fqn.from= String("/dummy"), lruConfig); + LRUAlgorithmConfig lru =3D new LRUAlgorithmConfig(4000, 0, 1000); + EvictionRegionConfig regConfig =3D new EvictionRegionConfig(Fqn.from= String("/dummy"), lru); = RegionManager regionManager =3D cache.getRegionManager(); EvictionConfig topConfig =3D cache.getConfiguration().getEvictionCon= fig(); + topConfig.addEvictionRegionConfig(regConfig); regionManager.setEvictionConfig(topConfig); // Fqn is the region name - regionManager.getRegion("/programmatic", true).setEvictionPolicy(reg= Config.getEvictionPolicyConfig()); + regionManager.getRegion("/programmatic", true).setEvictionRegionConf= ig(regConfig); } = public void testStringBasedFqnEviction() throws Exception @@ -121,9 +122,14 @@ = private void addObjectBasedRegion() throws Exception { - LRUConfiguration lruConfig =3D new LRUConfiguration(4000, 1000); + LRUAlgorithmConfig lru =3D new LRUAlgorithmConfig(4000, 1000); + EvictionRegionConfig regConfig =3D new EvictionRegionConfig(Fqn.from= Elements(1), lru); + RegionManager regionManager =3D cache.getRegionManager(); - regionManager.getRegion(Fqn.fromElements(1), true).setEvictionPolicy= (lruConfig); + EvictionConfig topConfig =3D cache.getConfiguration().getEvictionCon= fig(); + topConfig.addEvictionRegionConfig(regConfig); + regionManager.setEvictionConfig(topConfig); + regionManager.getRegion(Fqn.fromElements(1), true).setEvictionRegion= Config(regConfig); } = public void testObjectBasedFqnEviction1() throws Exception Modified: core/trunk/src/test/java/org/jboss/cache/eviction/RegionManagerTe= st.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/RegionManagerTest.jav= a 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/RegionManagerTest.jav= a 2008-08-15 10:59:40 UTC (rev 6562) @@ -5,9 +5,8 @@ import org.jboss.cache.RegionManager; import org.jboss.cache.RegionManagerImpl; import org.jboss.cache.RegionRegistry; -import org.jboss.cache.config.EvictionPolicyConfig; +import org.jboss.cache.config.EvictionRegionConfig; import static org.testng.AssertJUnit.*; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = import java.util.List; @@ -28,26 +27,17 @@ Fqn A_BC =3D Fqn.fromString("/a/bc"); Fqn AOP =3D Fqn.fromString("/aop"); = + EvictionRegionConfig config =3D new EvictionRegionConfig(null, new Null= EvictionAlgorithmConfig()); = - EvictionPolicy policy; - EvictionPolicyConfig config; - - @BeforeMethod(alwaysRun =3D true) - public void setUp() throws Exception - { - policy =3D new DummyEvictionPolicy(); - config =3D new DummyEvictionConfiguration(); - } - public void testCreateRegion() { RegionManager regionManager =3D new RegionManagerImpl(); ((RegionManagerImpl) regionManager).injectDependencies(null, null, n= ull, null, null, new RegionRegistry()); regionManager.setUsingEvictions(true); - regionManager.getRegion(DEFAULT_REGION, true).setEvictionPolicy(conf= ig); - regionManager.getRegion(A_B_C, true).setEvictionPolicy(config); - regionManager.getRegion(A_B, true).setEvictionPolicy(config); - regionManager.getRegion(AOP, true).setEvictionPolicy(config); + regionManager.getRegion(DEFAULT_REGION, true).setEvictionRegionConfi= g(config); + regionManager.getRegion(A_B_C, true).setEvictionRegionConfig(config); + regionManager.getRegion(A_B, true).setEvictionRegionConfig(config); + regionManager.getRegion(AOP, true).setEvictionRegionConfig(config); = List regions =3D regionManager.getAllRegions(Region.Type.ANY= ); assertEquals("Region size ", 4, regions.size()); @@ -59,9 +49,9 @@ RegionManager regionManager =3D new RegionManagerImpl(); ((RegionManagerImpl) regionManager).injectDependencies(null, null, n= ull, null, null, new RegionRegistry()); regionManager.setUsingEvictions(true); - regionManager.getRegion(A_B_C, true).setEvictionPolicy(config); - regionManager.getRegion(A_B, true).setEvictionPolicy(config); - regionManager.getRegion(DEFAULT_REGION, true).setEvictionPolicy(conf= ig); + regionManager.getRegion(A_B_C, true).setEvictionRegionConfig(config); + regionManager.getRegion(A_B, true).setEvictionRegionConfig(config); + regionManager.getRegion(DEFAULT_REGION, true).setEvictionRegionConfi= g(config); = List regions =3D regionManager.getAllRegions(Region.Type.ANY= ); assertEquals("Region size ", 3, regions.size()); @@ -85,8 +75,8 @@ RegionManager regionManager =3D new RegionManagerImpl(); ((RegionManagerImpl) regionManager).injectDependencies(null, null, n= ull, null, null, new RegionRegistry()); regionManager.setUsingEvictions(true); - regionManager.getRegion(A_B_C, true).setEvictionPolicy(config); - regionManager.getRegion(A_B, true).setEvictionPolicy(config); + regionManager.getRegion(A_B_C, true).setEvictionRegionConfig(config); + regionManager.getRegion(A_B, true).setEvictionRegionConfig(config); = regionManager.getRegion(Fqn.fromString("/a"), Region.Type.EVICTION, = false); } @@ -96,9 +86,9 @@ RegionManager regionManager =3D new RegionManagerImpl(); ((RegionManagerImpl) regionManager).injectDependencies(null, null, n= ull, null, null, new RegionRegistry()); regionManager.setUsingEvictions(true); - regionManager.getRegion(DEFAULT_REGION, true).setEvictionPolicy(conf= ig); - regionManager.getRegion(A_BC, true).setEvictionPolicy(config); - regionManager.getRegion(A_B, true).setEvictionPolicy(config); + regionManager.getRegion(DEFAULT_REGION, true).setEvictionRegionConfi= g(config); + regionManager.getRegion(A_BC, true).setEvictionRegionConfig(config); + regionManager.getRegion(A_B, true).setEvictionRegionConfig(config); = Region region =3D regionManager.getRegion(A_BC, true); assertNotSame("Region ", DEFAULT_REGION, region.getFqn()); @@ -112,10 +102,10 @@ RegionManager rm =3D new RegionManagerImpl(); ((RegionManagerImpl) rm).injectDependencies(null, null, null, null, = null, new RegionRegistry()); rm.setUsingEvictions(true); - rm.getRegion(DEFAULT_REGION, true).setEvictionPolicy(config); - rm.getRegion(A_B_C_D_E, true).setEvictionPolicy(config); - rm.getRegion(A_B_C_D, true).setEvictionPolicy(config); - rm.getRegion(A_B_C, true).setEvictionPolicy(config); + rm.getRegion(DEFAULT_REGION, true).setEvictionRegionConfig(config); + rm.getRegion(A_B_C_D_E, true).setEvictionRegionConfig(config); + rm.getRegion(A_B_C_D, true).setEvictionRegionConfig(config); + rm.getRegion(A_B_C, true).setEvictionRegionConfig(config); = Region region =3D rm.getRegion("/a/b/c/d/e/f", false); Region region2 =3D rm.getRegion("/e/f/g", false); Modified: core/trunk/src/test/java/org/jboss/cache/eviction/RegionTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/RegionTest.java 2008-= 08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/RegionTest.java 2008-= 08-15 10:59:40 UTC (rev 6562) @@ -2,15 +2,19 @@ = import org.jboss.cache.Fqn; import org.jboss.cache.Region; +import org.jboss.cache.RegionImpl; import org.jboss.cache.RegionManager; import org.jboss.cache.RegionManagerImpl; import org.jboss.cache.RegionRegistry; import org.jboss.cache.config.EvictionConfig; +import org.jboss.cache.config.EvictionRegionConfig; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNull; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = +import java.util.concurrent.TimeUnit; + /** * @author Ben Wang, Feb 11, 2004 * @author Daniel Huang (dhuang(a)jboss.org) @@ -27,48 +31,49 @@ algorithm =3D new LRUAlgorithm(); regionManager =3D new RegionManagerImpl(); ((RegionManagerImpl) regionManager).injectDependencies(null, null, n= ull, null, null, new RegionRegistry()); - regionManager.getRegion("/a/b", true).setEvictionPolicy(new DummyEvi= ctionConfiguration()); + Region r =3D regionManager.getRegion("/a/b", true);//.setEvictionPol= icy(new DummyEvictionConfiguration()); + r.setEvictionRegionConfig(new EvictionRegionConfig(r.getFqn(), new N= ullEvictionAlgorithmConfig())); } = - public void testAddedQueue() + public void testAddedQueue() throws InterruptedException { Fqn fqn1 =3D Fqn.fromString("/a/b/c"); Fqn fqn2 =3D Fqn.fromString("/a/b/d"); Fqn fqn3 =3D Fqn.fromString("/a/b/e"); = Region region =3D regionManager.getRegion("/a/b", true); - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NOD= E_EVENT)); + region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT= ); = - assertEquals("AddedNode queue size ", 3, region.nodeEventQueueSize()= ); - EvictedEventNode node =3D region.takeLastEventNode(); + assertEquals("AddedNode queue size ", 3, getQueueSize((RegionImpl) r= egion)); + EvictionEvent node =3D takeLastEvent((RegionImpl) region); Fqn fqn =3D node.getFqn(); assertEquals("DataNode retrieved should be FILO ", fqn, fqn1); - assertEquals("AddedNode queue size ", 2, region.nodeEventQueueSize()= ); - fqn =3D region.takeLastEventNode().getFqn(); - fqn =3D region.takeLastEventNode().getFqn(); - node =3D region.takeLastEventNode(); + assertEquals("AddedNode queue size ", 2, getQueueSize((RegionImpl) r= egion)); + fqn =3D takeLastEvent((RegionImpl) region).getFqn(); + fqn =3D takeLastEvent((RegionImpl) region).getFqn(); + node =3D takeLastEvent((RegionImpl) region); assertNull("DataNode should be null", node); } = - public void testEventQueue() + public void testEventQueue() throws InterruptedException { Fqn fqn1 =3D Fqn.fromString("/a/b/c"); Fqn fqn2 =3D Fqn.fromString("/a/b/d"); Fqn fqn3 =3D Fqn.fromString("/a/b/e"); = Region region =3D regionManager.getRegion("/a/b", true); - region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.REMOVE_= NODE_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NOD= E_EVENT)); - region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.VISIT_N= ODE_EVENT)); + region.registerEvictionEvent(fqn1, EvictionEvent.Type.REMOVE_NODE_EV= ENT); + region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); + region.registerEvictionEvent(fqn3, EvictionEvent.Type.VISIT_NODE_EVE= NT); = - assertEquals("RemovedNode queue size ", 3, region.nodeEventQueueSize= ()); - NodeEventType event =3D region.takeLastEventNode().getEventType(); - assertEquals("DataNode retrieved should be: ", NodeEventType.REMOVE_= NODE_EVENT, event); - region.takeLastEventNode(); - region.takeLastEventNode(); - EvictedEventNode node =3D region.takeLastEventNode(); + assertEquals("RemovedNode queue size ", 3, getQueueSize((RegionImpl)= region)); + EvictionEvent.Type event =3D takeLastEvent((RegionImpl) region).getE= ventType(); + assertEquals("DataNode retrieved should be: ", EvictionEvent.Type.RE= MOVE_NODE_EVENT, event); + takeLastEvent((RegionImpl) region); + takeLastEvent((RegionImpl) region); + EvictionEvent node =3D takeLastEvent((RegionImpl) region); assertNull("DataNode should be null", node); } = @@ -80,7 +85,7 @@ // This should succeed, alhtough it will produce warning over the th= reshold. for (int i =3D 0; i < EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT - 1; i= ++) { - region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_= NODE_EVENT)); + region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EV= ENT); } = } @@ -90,4 +95,14 @@ System.out.println("-- " + msg); } = + EvictionEvent takeLastEvent(RegionImpl r) throws InterruptedException + { + return r.getEvictionEventQueue().poll(0, TimeUnit.MILLISECONDS); + } + + int getQueueSize(RegionImpl r) + { + return r.getEvictionEventQueue().size(); + } + } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPo= licyTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTe= st.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTe= st.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -23,7 +23,7 @@ { CacheSPI cache1, cache2, cache3; long wakeupIntervalMillis =3D 0; - EvictionListener listener_ =3D new EvictionListener(); + EvictionListener listener =3D new EvictionListener(); = @BeforeMethod(alwaysRun =3D true) public void setUp() throws Exception @@ -32,8 +32,8 @@ cache1.getConfiguration().setTransactionManagerLookupClass(DummyTran= sactionManagerLookup.class.getName()); cache1.getConfiguration().setUseRegionBasedMarshalling(true); cache1.start(); - cache1.getNotifier().addCacheListener(listener_); - listener_.resetCounter(); + cache1.getNotifier().addCacheListener(listener); + listener.resetCounter(); = cache3 =3D (CacheSPI) new DefaultCacheFactory().createCache(UnitTestCacheConfigurationFactory.createConfigurati= on(CacheMode.REPL_SYNC), false); cache3.getConfiguration().setTransactionManagerLookupClass("org.jbos= s.cache.transaction.DummyTransactionManagerLookup"); @@ -66,10 +66,10 @@ TestingUtil.sleepThread(30000); Object node =3D cache1.peek(Fqn.fromString(str), false); assertNull("DataNode should be evicted already ", node); - assertEquals("Eviction counter ", 1, listener_.getCounter()); + assertEquals("Eviction counter ", 1, listener.getCounter()); String val =3D (String) cache3.get(str, str); assertNotNull("DataNode should not be evicted here ", val); - assertEquals("Eviction counter ", 1, listener_.getCounter()); + assertEquals("Eviction counter ", 1, listener.getCounter()); } = public void testEviction() throws Exception Modified: core/trunk/src/test/java/org/jboss/cache/eviction/minttl/FIFOMinT= TLTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/minttl/FIFOMinTTLTest= .java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/minttl/FIFOMinTTLTest= .java 2008-08-15 10:59:40 UTC (rev 6562) @@ -1,9 +1,9 @@ package org.jboss.cache.eviction.minttl; = import org.jboss.cache.Fqn; +import org.jboss.cache.eviction.EvictionAlgorithmConfigBase; +import org.jboss.cache.eviction.FIFOAlgorithmConfig; import org.jboss.cache.util.TestingUtil; -import org.jboss.cache.eviction.EvictionPolicyConfigBase; -import org.jboss.cache.eviction.FIFOConfiguration; import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; = @@ -19,10 +19,10 @@ private boolean busyThreadRunning =3D true; = @Override - protected EvictionPolicyConfigBase getEvictionPolicyConfig() + protected EvictionAlgorithmConfigBase getEvictionPolicyConfig() { startBusyThread(); - FIFOConfiguration cfg =3D new FIFOConfiguration(); + FIFOAlgorithmConfig cfg =3D new FIFOAlgorithmConfig(); cfg.setMaxNodes(1); return cfg; } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LFUMinTT= LTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LFUMinTTLTest.= java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LFUMinTTLTest.= java 2008-08-15 10:59:40 UTC (rev 6562) @@ -1,12 +1,10 @@ package org.jboss.cache.eviction.minttl; = +import org.jboss.cache.eviction.EvictionAlgorithmConfigBase; +import org.jboss.cache.eviction.LFUAlgorithmConfig; import org.testng.annotations.Test; -import org.jboss.cache.eviction.EvictionPolicyConfigBase; -import org.jboss.cache.eviction.LRUConfiguration; -import org.jboss.cache.eviction.LFUConfiguration; = /** - * * @author Manik Surtani * @since 2.1.0 */ @@ -14,9 +12,8 @@ public class LFUMinTTLTest extends MinTTLTestBase { @Override - protected EvictionPolicyConfigBase getEvictionPolicyConfig() + protected EvictionAlgorithmConfigBase getEvictionPolicyConfig() { - LFUConfiguration cfg =3D new LFUConfiguration(); - return cfg; + return new LFUAlgorithmConfig(); } } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LRUMinTT= LTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LRUMinTTLTest.= java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LRUMinTTLTest.= java 2008-08-15 10:59:40 UTC (rev 6562) @@ -1,11 +1,10 @@ package org.jboss.cache.eviction.minttl; = +import org.jboss.cache.eviction.EvictionAlgorithmConfigBase; +import org.jboss.cache.eviction.LRUAlgorithmConfig; import org.testng.annotations.Test; -import org.jboss.cache.eviction.EvictionPolicyConfigBase; -import org.jboss.cache.eviction.LRUConfiguration; = /** - * * @author Manik Surtani * @since 2.1.0 */ @@ -13,9 +12,9 @@ public class LRUMinTTLTest extends MinTTLTestBase { @Override - protected EvictionPolicyConfigBase getEvictionPolicyConfig() + protected EvictionAlgorithmConfigBase getEvictionPolicyConfig() { - LRUConfiguration cfg =3D new LRUConfiguration(); + LRUAlgorithmConfig cfg =3D new LRUAlgorithmConfig(); cfg.setTimeToLive(1000); return cfg; } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MRUMinTT= LTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MRUMinTTLTest.= java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MRUMinTTLTest.= java 2008-08-15 10:59:40 UTC (rev 6562) @@ -2,9 +2,9 @@ = import org.jboss.cache.CacheStatus; import org.jboss.cache.Fqn; +import org.jboss.cache.eviction.EvictionAlgorithmConfigBase; +import org.jboss.cache.eviction.MRUAlgorithmConfig; import org.jboss.cache.util.TestingUtil; -import org.jboss.cache.eviction.EvictionPolicyConfigBase; -import org.jboss.cache.eviction.MRUConfiguration; import org.testng.annotations.Test; = /** @@ -17,9 +17,9 @@ private Fqn fqn2 =3D Fqn.fromRelativeElements(region, "b"); = @Override - protected EvictionPolicyConfigBase getEvictionPolicyConfig() + protected EvictionAlgorithmConfigBase getEvictionPolicyConfig() { - MRUConfiguration cfg =3D new MRUConfiguration(); + MRUAlgorithmConfig cfg =3D new MRUAlgorithmConfig(); cfg.setMaxNodes(1); startBusyThread(); return cfg; Modified: core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MinTTLTe= stBase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MinTTLTestBase= .java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MinTTLTestBase= .java 2008-08-15 10:59:40 UTC (rev 6562) @@ -5,14 +5,12 @@ import org.jboss.cache.Fqn; import org.jboss.cache.config.EvictionConfig; import org.jboss.cache.config.EvictionRegionConfig; -import org.jboss.cache.eviction.EvictionPolicyConfigBase; +import org.jboss.cache.eviction.EvictionAlgorithmConfigBase; import org.jboss.cache.util.TestingUtil; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = -import java.util.ArrayList; -import java.util.List; import java.util.concurrent.CountDownLatch; = /** @@ -32,7 +30,7 @@ // allows the test methods to notify any support threads in subclasses = that data is in the cache and the test is about to begin protected CountDownLatch cacheInitialisedLatch; = - protected abstract EvictionPolicyConfigBase getEvictionPolicyConfig(); + protected abstract EvictionAlgorithmConfigBase getEvictionPolicyConfig(= ); = @BeforeMethod public void setUp() @@ -40,22 +38,17 @@ cacheInitialisedLatch =3D new CountDownLatch(1); = // the LRU policy cfg - EvictionPolicyConfigBase cfg =3D getEvictionPolicyConfig(); + EvictionAlgorithmConfigBase cfg =3D getEvictionPolicyConfig(); = // the region configuration EvictionRegionConfig regionCfg =3D new EvictionRegionConfig(); regionCfg.setRegionFqn(region); regionCfg.setRegionName(region.toString()); - regionCfg.setEvictionPolicyConfig(cfg); - - // set regions in a list - List evictionRegionConfigs =3D new ArrayList(); - evictionRegionConfigs.add(regionCfg); - + regionCfg.setEvictionAlgorithmConfig(cfg); // cache-wide EvictionConfig ec =3D new EvictionConfig(); ec.setWakeupInterval(1000); - ec.setEvictionRegionConfigs(evictionRegionConfigs); + ec.addEvictionRegionConfig(regionCfg); = cache =3D new DefaultCacheFactory().createCache(fals= e); cache.getConfiguration().setEvictionConfig(ec); @@ -83,7 +76,7 @@ = public void testWithMinimumTTL() { - ((EvictionPolicyConfigBase) cache.getConfiguration().getEvictionConf= ig().getEvictionRegionConfigs().get(0).getEvictionPolicyConfig()).setMinTim= eToLive(3000); + ((EvictionAlgorithmConfigBase) cache.getConfiguration().getEvictionC= onfig().getEvictionRegionConfigs().get(0).getEvictionAlgorithmConfig()).set= MinTimeToLive(3000); = cache.start(); cache.put(fqn, "k", "v"); Modified: core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheC= onfigurationFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigu= rationFactory.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigu= rationFactory.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -11,12 +11,10 @@ import org.jboss.cache.config.Configuration; import org.jboss.cache.config.Configuration.CacheMode; import org.jboss.cache.config.ConfigurationException; -import org.jboss.cache.config.EvictionRegionConfig; import org.jboss.cache.config.parsing.XmlConfigHelper; import org.jboss.cache.config.parsing.XmlConfigurationParser; -import org.jboss.cache.util.FileLookup; -import org.jboss.cache.eviction.LRUConfiguration; import org.jboss.cache.transaction.TransactionSetup; +import org.jboss.cache.util.FileLookup; import org.jgroups.conf.XmlConfigurator; import org.w3c.dom.Element; import org.w3c.dom.NodeList; @@ -159,19 +157,6 @@ return jgroupsConfigString.substring(0, jgroupsConfigString.indexOf(= ":")) + delay + jgroupsConfigString.substring(jgroupsConfigString.indexOf("= :")); } = - - public static EvictionRegionConfig buildLruEvictionRegionConfig(String = regionNaame, int maxNodes, long timeToLive) - { - EvictionRegionConfig erc =3D new EvictionRegionConfig(); - erc.setRegionName(regionNaame); - LRUConfiguration lruConfig =3D new LRUConfiguration(); - lruConfig.setEvictionPolicyClass("org.jboss.cache.eviction.LRUPolicy= "); - if (maxNodes >=3D 0) lruConfig.setMaxNodes(maxNodes); - if (timeToLive >=3D 0) lruConfig.setTimeToLive(timeToLive); - erc.setEvictionPolicyConfig(lruConfig); - return erc; - } - private static class UnitTestXmlConfigurationParser extends XmlConfigur= ationParser { = Deleted: core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInte= rceptorTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionIntercept= orTest.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionIntercept= orTest.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -1,538 +0,0 @@ -/* - * JBoss, the OpenSource J2EE webOS - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package org.jboss.cache.interceptors; - -import org.jboss.cache.CacheSPI; -import org.jboss.cache.DefaultCacheFactory; -import org.jboss.cache.Fqn; -import org.jboss.cache.Node; -import org.jboss.cache.NodeSPI; -import org.jboss.cache.Region; -import org.jboss.cache.RegionManager; -import org.jboss.cache.commands.CommandsFactory; -import org.jboss.cache.commands.VisitableCommand; -import org.jboss.cache.commands.read.GetKeyValueCommand; -import org.jboss.cache.commands.read.GetNodeCommand; -import org.jboss.cache.commands.write.ClearDataCommand; -import org.jboss.cache.commands.write.PutDataMapCommand; -import org.jboss.cache.commands.write.PutKeyValueCommand; -import org.jboss.cache.commands.write.RemoveKeyCommand; -import org.jboss.cache.commands.write.RemoveNodeCommand; -import org.jboss.cache.config.EvictionConfig; -import org.jboss.cache.config.EvictionRegionConfig; -import org.jboss.cache.eviction.DummyEvictionConfiguration; -import org.jboss.cache.eviction.EvictedEventNode; -import org.jboss.cache.eviction.NodeEventType; -import org.jboss.cache.lock.IsolationLevel; -import org.jboss.cache.util.TestingUtil; -import static org.testng.AssertJUnit.*; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -/** - * @author Daniel Huang (dhuang(a)jboss.org) - * @version $Revision: $ - */ -(a)Test(groups =3D "functional") -public class EvictionInterceptorTest -{ - private static final String fqn1 =3D "/a/b/c"; - private static final String fqn2 =3D "/a/b"; - private static final String fqn3 =3D "/a/b/d"; - private static final String fqn4 =3D "/d/e/f"; - - private CacheSPI cache; - private InterceptorChain invoker; - private RegionManager regionManager; - private CommandsFactory commandsFactory; - - @BeforeMethod(alwaysRun =3D true) - public void setUp() throws Exception - { - cache =3D (CacheSPI) new DefaultCacheFactory().createCache(false); - cache.getConfiguration().setTransactionManagerLookupClass("org.jboss= .cache.transaction.DummyTransactionManagerLookup"); - cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZAB= LE); - cache.getConfiguration().setCacheMode("LOCAL"); - EvictionConfig ec =3D new EvictionConfig(); - - List ercs =3D new LinkedList(); - ercs.add(new EvictionRegionConfig(Fqn.ROOT, new DummyEvictionConfigu= ration())); - ercs.add(new EvictionRegionConfig(Fqn.fromString("/a/b/c"), new Dumm= yEvictionConfiguration())); - ercs.add(new EvictionRegionConfig(Fqn.fromString("/a/b/c/d"), new Du= mmyEvictionConfiguration())); - ercs.add(new EvictionRegionConfig(Fqn.fromString("/a/b"), new DummyE= victionConfiguration())); - ercs.add(new EvictionRegionConfig(Fqn.fromString("/d/e/f"), new Dumm= yEvictionConfiguration())); - ercs.add(new EvictionRegionConfig(Fqn.fromString("/d/e/g"), new Dumm= yEvictionConfiguration())); - ercs.add(new EvictionRegionConfig(Fqn.fromString("/d/e"), new DummyE= victionConfiguration())); - - ec.setEvictionRegionConfigs(ercs); - cache.getConfiguration().setEvictionConfig(ec); - cache.start(); - - invoker =3D TestingUtil.extractComponentRegistry(cache).getComponent= (InterceptorChain.class); - commandsFactory =3D TestingUtil.extractCommandsFactory(cache); - regionManager =3D cache.getRegionManager(); - } - - @AfterMethod(alwaysRun =3D true) - public void tearDown() throws Exception - { - TestingUtil.killCaches(cache); - } - - private NodeSPI cast(Node node) - { - return (NodeSPI) node; - } - - public void testVisitNode() throws Throwable - { - // make sure node that doesn't exist does not result in a node visit= event. - - VisitableCommand command =3D commandsFactory.buildGetNodeCommand(Fqn= .fromString(fqn1)); - invoker.invoke(command); - Region regionABC =3D regionManager.getRegion(fqn1, false); - assertNull(regionABC.takeLastEventNode()); - - putQuietly(fqn1, "key", "value"); - NodeSPI node =3D cast(cache.peek(Fqn.fromString(fqn1= ), false, false)); - assertNotNull(node); - assertEquals("value", node.getDirect("key")); - - putQuietly(fqn3, "key", "value"); - node =3D cast(cache.peek(Fqn.fromString(fqn3), false, false)); - assertNotNull(node); - assertEquals("value", node.getDirect("key")); - - - command =3D commandsFactory.buildGetNodeCommand(Fqn.fromString(fqn1)= ); - invoker.invoke(command); - - regionABC =3D regionManager.getRegion(fqn1, false); - EvictedEventNode event =3D regionABC.takeLastEventNode(); - assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType()); - assertEquals(fqn1, event.getFqn().toString()); - assertNull(regionABC.takeLastEventNode()); - - command =3D commandsFactory.buildGetNodeCommand(Fqn.fromString(fqn2)= ); - invoker.invoke(command); - - Region regionAB =3D regionManager.getRegion(fqn2, false); - event =3D regionAB.takeLastEventNode(); - assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType()); - assertEquals(fqn2, event.getFqn().toString()); - assertNull(regionAB.takeLastEventNode()); - - command =3D commandsFactory.buildGetNodeCommand(Fqn.fromString(fqn3)= ); - invoker.invoke(command); - Region regionABD =3D regionManager.getRegion(fqn3, false); - event =3D regionABD.takeLastEventNode(); - assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType()); - assertEquals(fqn3, event.getFqn().toString()); - assertNull(regionABD.takeLastEventNode()); - - for (int i =3D 0; i < 10; i++) - { - command =3D commandsFactory.buildGetNodeCommand(Fqn.fromString(fq= n3)); - invoker.invoke(command); - } - - for (int i =3D 0; i < 10; i++) - { - Region region =3D regionManager.getRegion(fqn3, false); - event =3D region.takeLastEventNode(); - assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType()= ); - assertEquals(fqn3, event.getFqn().toString()); - } - - assertNull(regionManager.getRegion(fqn3, false).takeLastEventNode()); - - // check null handling. - command =3D commandsFactory.buildGetDataMapCommand(null); - invoker.invoke(command); - - } - - /** - * Helper to quietly add something into the cache without generating ev= iction events - * - * @param fqn fqn to add - * @param key key - * @param value value - */ - private void putQuietly(String fqn, Object key, Object value) - { - putQuietly(Fqn.fromString(fqn), key, value); - } - - /** - * Helper to quietly add something into the cache without generating ev= iction events - * - * @param fqn fqn to add - * @param key key - * @param value value - */ - private void putQuietly(Fqn fqn, Object key, Object value) - { - NodeSPI root =3D cache.getRoot(); - NodeSPI child =3D root; - for (int i =3D 0; i < fqn.size(); i++) - { - child =3D child.addChildDirect(Fqn.fromElements(fqn.get(i))); - } - - assert child.getFqn().equals(fqn); - - child.putDirect(key, value); - } - - public void testVisitElement() throws Throwable - { - // make sure a get/visit on an empty node and empty element results = in no cache events being added to event queue - // aka MarshRegion. - Fqn fqn =3D Fqn.fromString(fqn4); - Object key =3D "key"; - GetKeyValueCommand command =3D commandsFactory.buildGetKeyValueComma= nd(fqn, key, false); - invoker.invoke(command); - Region region =3D regionManager.getRegion(fqn.toString(), false); - assertNull(region.takeLastEventNode()); - - // add the node but try to get on a null element should result in no= cache events being added to Region. - putQuietly(fqn, "wrongkey", ""); - - command =3D commandsFactory.buildGetKeyValueCommand(fqn, key, false); - invoker.invoke(command); - assertNull(region.takeLastEventNode()); - - // now make sure if we try to get on the node/key we just created in= cache, that this DOES add a EvictedEventNode to - // the MarshRegion. - command =3D commandsFactory.buildGetKeyValueCommand(fqn, "wrongkey",= false); - invoker.invoke(command); - EvictedEventNode event =3D region.takeLastEventNode(); - assertEquals(fqn, event.getFqn()); - assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType()); - - assertNull(region.takeLastEventNode()); - - putQuietly(fqn4, key, "value"); - - // test on element granularity configured node. - fqn =3D Fqn.fromString(fqn4); - command =3D commandsFactory.buildGetKeyValueCommand(fqn, key, false); - invoker.invoke(command); - - region =3D regionManager.getRegion(fqn.toString(), false); - event =3D region.takeLastEventNode(); - - assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType()); - assertEquals(fqn, event.getFqn()); - - assertNull(region.takeLastEventNode()); - - fqn =3D Fqn.fromString("/d/e/g"); - for (int i =3D 0; i < 100; i++) - { - key =3D i; - - putQuietly("/d/e/g", key, ""); - - command =3D commandsFactory.buildGetKeyValueCommand(fqn, key, fal= se); - invoker.invoke(command); - } - - region =3D regionManager.getRegion(fqn.toString(), false); - - for (int i =3D 0; i < 100; i++) - { - event =3D region.takeLastEventNode(); - assertEquals(fqn, event.getFqn()); - assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType()= ); - } - - putQuietly("/a/b/c", key, ""); - fqn =3D Fqn.fromString("/a/b/c"); - - command =3D commandsFactory.buildGetKeyValueCommand(fqn, key, false); - invoker.invoke(command); - - region =3D regionManager.getRegion(fqn.toString(), false); - event =3D region.takeLastEventNode(); - - assertNull(region.takeLastEventNode()); - assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType()); - assertEquals(fqn, event.getFqn()); - - for (int i =3D 0; i < 100; i++) - { - key =3D i; - - putQuietly(fqn, key, ""); - - command =3D commandsFactory.buildGetKeyValueCommand(fqn, key, fal= se); - invoker.invoke(command); - } - - for (int i =3D 0; i < 100; i++) - { - event =3D region.takeLastEventNode(); - assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType()= ); - assertEquals(fqn, event.getFqn()); - } - - assertNull(region.takeLastEventNode()); - } - - public void testCreateNode() throws Throwable - { - Map data =3D new HashMap(); - for (int i =3D 0; i < 100; i++) - { - data.put(i, i); - } - - // this region is node granularity - Fqn fqn =3D Fqn.fromString("/a/b/c"); - - PutDataMapCommand putDataMapCommand =3D commandsFactory.buildPutData= MapCommand(null, fqn, data); - invoker.invoke(putDataMapCommand); - - Region region =3D regionManager.getRegion(fqn.toString(), false); - EvictedEventNode event =3D region.takeLastEventNode(); - - assertEquals(NodeEventType.ADD_NODE_EVENT, event.getEventType()); - assertEquals(fqn, event.getFqn()); - assertEquals(100, event.getElementDifference()); - - NodeSPI node =3D cast(cache.peek(fqn, false, false)); - assertNotNull(node); - - for (int i =3D 0; i < 100; i++) - { - assertTrue(node.getDataDirect().containsKey(i)); - assertEquals(i, node.getDirect(i)); - } - - for (int i =3D 0; i < 100; i++) - { - PutKeyValueCommand pkvCommand =3D commandsFactory.buildPutKeyValu= eCommand(null, fqn, i, "value"); - invoker.invoke(pkvCommand); - - assertEquals("value", cache.peek(fqn, false, false).getDirect(i)); - } - - for (int i =3D 0; i < 100; i++) - { - event =3D region.takeLastEventNode(); - assertNotNull(event); - assertEquals(fqn, event.getFqn()); - assertEquals(NodeEventType.ADD_ELEMENT_EVENT, event.getEventType(= )); - } - - assertNull(region.takeLastEventNode()); - - fqn =3D Fqn.fromString("/a/b"); - PutDataMapCommand putCommand =3D commandsFactory.buildPutDataMapComm= and(null, fqn, data); - invoker.invoke(putCommand); - event =3D regionManager.getRegion(fqn.toString(), false).takeLastEve= ntNode(); - assertEquals(NodeEventType.ADD_NODE_EVENT, event.getEventType()); - assertEquals(fqn, event.getFqn()); - assertEquals(100, event.getElementDifference()); - assertNull(regionManager.getRegion(fqn.toString(), false).takeLastEv= entNode()); - node =3D cast(cache.peek(fqn, false, false)); - assertEquals(100, node.getDataDirect().size()); - - assertNotNull(node); - - for (int i =3D 0; i < 100; i++) - { - assertTrue(node.getDataDirect().containsKey(i)); - assertEquals(i, node.getDirect(i)); - } - - PutDataMapCommand putDataMap =3D commandsFactory.buildPutDataMapComm= and(null, fqn, data); - invoker.invoke(putDataMap); - event =3D regionManager.getRegion(fqn.toString(), false).takeLastEve= ntNode(); - assertEquals(NodeEventType.ADD_NODE_EVENT, event.getEventType()); - assertEquals(fqn, event.getFqn()); - assertEquals(100, event.getElementDifference()); - assertNull(regionManager.getRegion(fqn.toString(), false).takeLastEv= entNode()); - - - node =3D cast(cache.getNode(fqn)); - assertEquals(100, node.getData().size()); - assertNotNull(node); - - for (int i =3D 0; i < 100; i++) - { - assertTrue(node.getDataDirect().containsKey(i)); - assertEquals(i, node.getDirect(i)); - } - - } - - public void testCreateElement() throws Throwable - { - Fqn fqn =3D Fqn.fromString("/d/e/f"); - Region region =3D regionManager.getRegion(fqn.toString(), false); - Object key =3D "key"; - Object value =3D "value"; - - PutKeyValueCommand command =3D commandsFactory.buildPutKeyValueComma= nd(null, (Fqn) fqn, key, value); - invoker.invoke(command); - assertEquals("value", cache.peek(fqn, false, false).getDirect(key)); - EvictedEventNode event =3D region.takeLastEventNode(); - assertEquals(NodeEventType.ADD_ELEMENT_EVENT, event.getEventType()); - assertEquals(1, event.getElementDifference()); - assertEquals(fqn, event.getFqn()); - assertEquals("value", cache.peek(fqn, false, false).getDirect(key)); - assertNull(region.takeLastEventNode()); - - command =3D commandsFactory.buildPutKeyValueCommand(null, (Fqn) fqn,= key, value); - invoker.invoke(command); - assertEquals("value", cache.peek(fqn, false, false).getDirect(key)); - event =3D region.takeLastEventNode(); - assertEquals(NodeEventType.ADD_ELEMENT_EVENT, event.getEventType()); - assertEquals(1, event.getElementDifference()); - assertEquals(fqn, event.getFqn()); - assertEquals("value", cache.peek(fqn, false, false).getDirect(key)); - assertNull(region.takeLastEventNode()); - - } - - public void testRemoveNode() throws Throwable - { - Fqn fqn =3D Fqn.fromString("/a/b/c"); - putQuietly(fqn, "a", "b"); - putQuietly(fqn, "b", "c"); - - ClearDataCommand clearDataCommand =3D commandsFactory.buildClearData= Command(null, fqn); - invoker.invoke(clearDataCommand); - - assertEquals(0, cache.peek(fqn, false, false).getDataDirect().size()= ); - Region region =3D regionManager.getRegion(fqn.toString(), false); - EvictedEventNode event =3D region.takeLastEventNode(); - assertEquals(NodeEventType.REMOVE_NODE_EVENT, event.getEventType()); - assertEquals(fqn, event.getFqn()); - assertNull(region.takeLastEventNode()); - - RemoveNodeCommand removeNodeCommand =3D commandsFactory.buildRemoveN= odeCommand(null, fqn); - invoker.invoke(removeNodeCommand); - - assertNull(cache.peek(fqn, false, false)); - event =3D region.takeLastEventNode(); - assertEquals(NodeEventType.REMOVE_NODE_EVENT, event.getEventType()); - assertEquals(fqn, event.getFqn()); - assertNull(region.takeLastEventNode()); - } - - public void testRemoveElement() throws Throwable - { - Fqn fqn =3D Fqn.fromString("/a/b/c"); - putQuietly(fqn, "a", "b"); - putQuietly(fqn, "b", "c"); - - RemoveKeyCommand removeKeyCommand =3D commandsFactory.buildRemoveKey= Command(null, fqn, "a"); - invoker.invoke(removeKeyCommand); - - assertNull(cache.get(fqn, "a")); - Region region =3D regionManager.getRegion(fqn.toString(), false); - EvictedEventNode event =3D region.takeLastEventNode(); - assertEquals(NodeEventType.REMOVE_ELEMENT_EVENT, event.getEventType(= )); - assertEquals(fqn, event.getFqn()); - assertEquals(1, event.getElementDifference()); - assertNull(region.takeLastEventNode()); - - RemoveKeyCommand removeKeyCommand2 =3D commandsFactory.buildRemoveKe= yCommand(null, fqn, "b"); - invoker.invoke(removeKeyCommand2); - - assertNull(cache.get(fqn, "b")); - event =3D region.takeLastEventNode(); - assertEquals(NodeEventType.REMOVE_ELEMENT_EVENT, event.getEventType(= )); - assertEquals(fqn, event.getFqn()); - assertEquals(1, event.getElementDifference()); - assertNull(region.takeLastEventNode()); - - RemoveKeyCommand removeKeyCommand3 =3D commandsFactory.buildRemoveKe= yCommand(null, fqn, "a"); - invoker.invoke(removeKeyCommand3); - - event =3D region.takeLastEventNode(); - assertNull(event); - } - - public void testMixedEvent() throws Throwable - { - Map data =3D new HashMap(); - for (int i =3D 0; i < 100; i++) - { - data.put(i, i); - } - - // this region is node granularity - Fqn fqn =3D Fqn.fromString("/a/b/c"); - - PutDataMapCommand putDataCommand =3D commandsFactory.buildPutDataMap= Command(null, fqn, data); - invoker.invoke(putDataCommand); - - Region region =3D regionManager.getRegion(fqn.toString(), false); - EvictedEventNode event =3D region.takeLastEventNode(); - - assertEquals(NodeEventType.ADD_NODE_EVENT, event.getEventType()); - assertEquals(fqn, event.getFqn()); - assertEquals(100, event.getElementDifference()); - assertNull(region.takeLastEventNode()); - - GetNodeCommand getNodeCommand =3D commandsFactory.buildGetNodeComman= d(fqn); - invoker.invoke(getNodeCommand); - event =3D region.takeLastEventNode(); - assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType()); - assertEquals(fqn, event.getFqn()); - assertNull(region.takeLastEventNode()); - - RemoveNodeCommand removeNodeCommand =3D commandsFactory.buildRemoveN= odeCommand(null, fqn); - invoker.invoke(removeNodeCommand); - assertNull(cache.getNode(fqn)); - event =3D region.takeLastEventNode(); - assertEquals(NodeEventType.REMOVE_NODE_EVENT, event.getEventType()); - assertEquals(fqn, event.getFqn()); - assertNull(region.takeLastEventNode()); - - Object key =3D "key"; - Object value =3D "value"; - PutKeyValueCommand putKeyValueCommand =3D commandsFactory.buildPutKe= yValueCommand(null, fqn, key, value); - invoker.invoke(putKeyValueCommand); - assertEquals("value", cache.peek(fqn, false, false).getDirect(key)); - event =3D region.takeLastEventNode(); - assertEquals(NodeEventType.ADD_ELEMENT_EVENT, event.getEventType()); - assertEquals(1, event.getElementDifference()); - assertEquals(fqn, event.getFqn()); - assertEquals("value", cache.peek(fqn, false, false).getDirect(key)); - assertNull(region.takeLastEventNode()); - - GetKeyValueCommand getKeyValueCommand =3D commandsFactory.buildGetKe= yValueCommand(fqn, key, false); - invoker.invoke(getKeyValueCommand); - region =3D regionManager.getRegion(fqn.toString(), false); - event =3D region.takeLastEventNode(); - assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType()); - assertEquals(fqn, event.getFqn()); - assertNull(region.takeLastEventNode()); - - RemoveKeyCommand removeKeyCommand =3D commandsFactory.buildRemoveKey= Command(null, fqn, key); - invoker.invoke(removeKeyCommand); - - assertNull(cache.get(fqn, key)); - event =3D region.takeLastEventNode(); - assertEquals(NodeEventType.REMOVE_ELEMENT_EVENT, event.getEventType(= )); - assertEquals(fqn, event.getFqn()); - assertEquals(1, event.getElementDifference()); - assertNull(region.takeLastEventNode()); - } -} \ No newline at end of file Modified: core/trunk/src/test/java/org/jboss/cache/invalidation/TombstoneEv= ictionTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/invalidation/TombstoneEviction= Test.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/invalidation/TombstoneEviction= Test.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -8,7 +8,7 @@ import org.jboss.cache.config.Configuration; import org.jboss.cache.config.EvictionConfig; import org.jboss.cache.config.EvictionRegionConfig; -import org.jboss.cache.eviction.FIFOConfiguration; +import org.jboss.cache.eviction.FIFOAlgorithmConfig; import org.jboss.cache.transaction.DummyTransactionManagerLookup; import org.jboss.cache.util.TestingUtil; import org.testng.annotations.AfterMethod; @@ -39,7 +39,7 @@ c1 =3D (CacheSPI) new DefaultCacheFactory().createCa= che(false); = // the FIFO policy cfg - FIFOConfiguration cfg =3D new FIFOConfiguration(); + FIFOAlgorithmConfig cfg =3D new FIFOAlgorithmConfig(); cfg.setMaxNodes(1); cfg.setMinTimeToLive(0); = @@ -47,7 +47,7 @@ EvictionRegionConfig regionCfg =3D new EvictionRegionConfig(); regionCfg.setRegionFqn(dummy.getParent()); regionCfg.setRegionName(dummy.getParent().toString()); - regionCfg.setEvictionPolicyConfig(cfg); + regionCfg.setEvictionAlgorithmConfig(cfg); = // set regions in a list List evictionRegionConfigs =3D new ArrayList(); Modified: core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyCon= figurationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigura= tionTest.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigura= tionTest.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -23,8 +23,6 @@ package org.jboss.cache.jmx.deprecated; = import org.jboss.cache.Version; -import org.jboss.cache.jmx.CacheJmxWrapperMBean; -import org.jboss.cache.jmx.CacheJmxWrapper; import org.jboss.cache.config.BuddyReplicationConfig; import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig; import org.jboss.cache.config.CacheLoaderConfig; @@ -42,6 +40,8 @@ import org.jboss.cache.eviction.LRUPolicy; import org.jboss.cache.eviction.MRUConfiguration; import org.jboss.cache.eviction.MRUPolicy; +import org.jboss.cache.jmx.CacheJmxWrapper; +import org.jboss.cache.jmx.CacheJmxWrapperMBean; import org.jboss.cache.loader.FileCacheLoader; import org.jboss.cache.loader.SingletonStoreCacheLoader; import org.jboss.cache.loader.jdbm.JdbmCacheLoader; @@ -183,7 +183,7 @@ = assertEquals("EvictionPolicyConfig", getEvictionPolicyConfig().toStr= ing(), wrapper.getEvictionPolicyConfig().toString()); EvictionConfig ec =3D c.getEvictionConfig(); - assertEquals("EC queue size", 20000, ec.getDefaultEventQueueSize()); + assertEquals("EC queue size", 20000, ec.getDefaultEvictionRegionConf= ig().getEventQueueSize()); assertEquals("EC wakeup", 5000, ec.getWakeupInterval()); assertEquals("EC default pol", LRUPolicy.class.getName(), ec.getDefa= ultEvictionPolicyClass()); List ercs =3D ec.getEvictionRegionConfigs(); @@ -193,7 +193,7 @@ LRUConfiguration lru =3D (LRUConfiguration) erc.getEvictionPolicyCon= fig(); assertEquals("EPC0 pol", LRUPolicy.class.getName(), lru.getEvictionP= olicyClass()); assertEquals("EPC0 maxnodes", 5000, lru.getMaxNodes()); - assertEquals("EPC0 ttl", 1000000, lru.getTimeToLive()); + assertEquals("EPC0 ttl", 1000, lru.getTimeToLiveSeconds()); erc =3D ercs.get(1); assertEquals("ERC1 name", "/org/jboss/data", erc.getRegionName()); assertEquals("ERC1 queue size", 20000, erc.getEventQueueSize()); @@ -212,8 +212,8 @@ lru =3D (LRUConfiguration) erc.getEvictionPolicyConfig(); assertEquals("EPC3 pol", LRUPolicy.class.getName(), lru.getEvictionP= olicyClass()); assertEquals("EPC3 maxnodes", 10000, lru.getMaxNodes()); - assertEquals("EPC3 maxage", 10000, lru.getMaxAge()); - assertEquals("EPC3 ttl", 8000, lru.getTimeToLive()); + assertEquals("EPC3 maxage", 10, lru.getMaxAgeSeconds()); + assertEquals("EPC3 ttl", 8, lru.getTimeToLiveSeconds()); = } = @@ -309,15 +309,15 @@ { = String xmlStr =3D - " \n"= + - " \n" + + " \n" + + " \n" + " 5000\n" + " 1000000\n" + " \n" + - "\n" + + "\n" + " 5000\n" + "\n" + - "\n" + + "\n" + " 10000\n" + "\n" + "\n" + Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMars= hallingJDBCTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallin= gJDBCTest.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallin= gJDBCTest.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -4,23 +4,20 @@ import org.jboss.cache.DefaultCacheFactory; import org.jboss.cache.Fqn; import org.jboss.cache.Region; -import org.jboss.cache.util.TestingUtil; import org.jboss.cache.config.CacheLoaderConfig; import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfi= g; import org.jboss.cache.config.Configuration; import org.jboss.cache.config.EvictionConfig; import org.jboss.cache.config.EvictionRegionConfig; -import org.jboss.cache.eviction.LRUConfiguration; -import org.jboss.cache.eviction.LRUPolicy; +import org.jboss.cache.eviction.LRUAlgorithmConfig; import org.jboss.cache.loader.JDBCCacheLoaderConfig; +import org.jboss.cache.util.TestingUtil; import static org.testng.AssertJUnit.assertEquals; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = -import java.util.ArrayList; import java.util.Collections; -import java.util.List; import java.util.Properties; = /** @@ -109,19 +106,15 @@ config.setUseRegionBasedMarshalling(useRegionBased); config.setInactiveOnStartup(useRegionBased); = - EvictionConfig ec =3D new EvictionConfig(); - ec.setDefaultEvictionPolicyClass(LRUPolicy.class.getName()); - ec.setWakeupInterval(1000000); // a long time; really disabled - EvictionRegionConfig erc =3D new EvictionRegionConfig(); - erc.setRegionFqn(Fqn.ROOT); - erc.setRegionName("_default_"); - LRUConfiguration epc =3D new LRUConfiguration(); - epc.setMaxNodes(1000); - epc.setTimeToLive(1000000); - erc.setEvictionPolicyConfig(epc); - List ercs =3D new ArrayList(); - ercs.add(erc); - ec.setEvictionRegionConfigs(ercs); + int wakeupInterval =3D 1000000; // a long time; really disabled + EvictionConfig ec =3D new EvictionConfig( + new EvictionRegionConfig( + Fqn.ROOT, + new LRUAlgorithmConfig(1000000, 0, 1000) + ), + wakeupInterval + ); + config.setEvictionConfig(ec); = CacheLoaderConfig clc =3D new CacheLoaderConfig(); Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMars= hallingTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallin= gTest.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallin= gTest.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -10,21 +10,17 @@ import org.jboss.cache.config.Configuration; import org.jboss.cache.config.EvictionConfig; import org.jboss.cache.config.EvictionRegionConfig; -import org.jboss.cache.eviction.LRUConfiguration; -import org.jboss.cache.eviction.LRUPolicy; +import org.jboss.cache.eviction.LRUAlgorithmConfig; import org.jboss.cache.loader.FileCacheLoaderConfig; import org.jboss.cache.util.TestingUtil; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; - import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = import java.io.File; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; = /** * Tests marshalling/unmarshalling during cache loader operations involvin= g types @@ -69,38 +65,38 @@ { cacheLoaderMarshallingTest(true); } - = + public void testLoadNodesAtRootOfRegion() throws Exception { String rootRegionName =3D "/myregion"; String hereFqn =3D rootRegionName + "/here"; - = + cache =3D createCache(true); cache.start(); = Region r =3D cache.getRegion(Fqn.fromString(rootRegionName), true); r.registerContextClassLoader(Thread.currentThread().getContextClassL= oader()); r.activate(); - = + cache.put(rootRegionName, "a key", "a value"); cache.put(hereFqn, "another key", "another value"); = r.deactivate(); r.unregisterContextClassLoader(); - = + cache.stop(); - = + cache.start(); - = + r =3D cache.getRegion(Fqn.fromString(rootRegionName), true); r.registerContextClassLoader(Thread.currentThread().getContextClassL= oader()); r.activate(); - = + Node rootRegionNode =3D cache.getNode(rootRegionName= ); Node hereNode =3D cache.getNode(hereFqn); assertNotNull(rootRegionNode); assertNotNull(hereNode); - = + assertEquals(hereNode.get("another key"), "another value"); assertEquals(rootRegionNode.get("a key"), "a value"); } @@ -140,18 +136,14 @@ config.setInactiveOnStartup(useRegionBased); = EvictionConfig ec =3D new EvictionConfig(); - ec.setDefaultEvictionPolicyClass(LRUPolicy.class.getName()); ec.setWakeupInterval(1000000); // a long time; really disabled EvictionRegionConfig erc =3D new EvictionRegionConfig(); erc.setRegionFqn(Fqn.ROOT); - erc.setRegionName("_default_"); - LRUConfiguration epc =3D new LRUConfiguration(); - epc.setMaxNodes(1000); - epc.setTimeToLive(1000000); - erc.setEvictionPolicyConfig(epc); - List ercs =3D new ArrayList(); - ercs.add(erc); - ec.setEvictionRegionConfigs(ercs); + LRUAlgorithmConfig lruAlgorithmConfig =3D new LRUAlgorithmConfig(); + lruAlgorithmConfig.setMaxNodes(1000); + lruAlgorithmConfig.setTimeToLive(1000000); + erc.setEvictionAlgorithmConfig(lruAlgorithmConfig); + ec.addEvictionRegionConfig(erc); config.setEvictionConfig(ec); = CacheLoaderConfig clc =3D new CacheLoaderConfig(); Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationA= ctivationCallbacksTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivat= ionCallbacksTestCase.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivat= ionCallbacksTestCase.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -13,11 +13,10 @@ import org.jboss.cache.CacheSPI; import org.jboss.cache.DefaultCacheFactory; import org.jboss.cache.Fqn; -import org.jboss.cache.RegionManagerImpl; import org.jboss.cache.config.CacheLoaderConfig; import org.jboss.cache.config.EvictionConfig; import org.jboss.cache.config.EvictionRegionConfig; -import org.jboss.cache.eviction.LRUConfiguration; +import org.jboss.cache.eviction.LRUAlgorithmConfig; import org.jboss.cache.loader.CacheLoader; import org.jboss.cache.loader.DummyInMemoryCacheLoader; import org.jboss.cache.lock.IsolationLevel; @@ -29,9 +28,7 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = -import java.util.ArrayList; import java.util.HashSet; -import java.util.List; import java.util.Set; = /** @@ -89,26 +86,16 @@ EvictionConfig ec =3D new EvictionConfig(); ec.setWakeupInterval(1000); = - List ercs =3D new ArrayList(); + LRUAlgorithmConfig lru =3D new LRUAlgorithmConfig(); + lru.setMaxNodes(0); + lru.setTimeToLive(5000); + ec.setDefaultEvictionRegionConfig(new EvictionRegionConfig(Fqn.ROOT,= lru)); = - EvictionRegionConfig erc =3D new EvictionRegionConfig(); - erc.setRegionFqn(RegionManagerImpl.DEFAULT_REGION); - LRUConfiguration epc =3D new LRUConfiguration(); - epc.setMaxNodes(0); - epc.setTimeToLive(5000); - erc.setEvictionPolicyConfig(epc); - ercs.add(erc); + lru =3D new LRUAlgorithmConfig(); + lru.setMaxNodes(0); + lru.setTimeToLive(1000); + ec.addEvictionRegionConfig(new EvictionRegionConfig(BASE, lru)); = - erc =3D new EvictionRegionConfig(); - erc.setRegionFqn(BASE); - epc =3D new LRUConfiguration(); - epc.setMaxNodes(0); - epc.setTimeToLive(1000); - erc.setEvictionPolicyConfig(epc); - ercs.add(erc); - - ec.setEvictionRegionConfigs(ercs); - cache.getConfiguration().setEvictionConfig(ec); } = Modified: core/trunk/src/test/java/org/jboss/cache/passivation/ReplicatedPa= ssivationIntegrationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/passivation/ReplicatedPassivat= ionIntegrationTest.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/passivation/ReplicatedPassivat= ionIntegrationTest.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -34,8 +34,7 @@ import org.jboss.cache.config.Configuration; import org.jboss.cache.config.EvictionConfig; import org.jboss.cache.config.EvictionRegionConfig; -import org.jboss.cache.eviction.LRUConfiguration; -import org.jboss.cache.eviction.LRUPolicy; +import org.jboss.cache.eviction.LRUAlgorithmConfig; import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; import org.jboss.cache.loader.DummyInMemoryCacheLoader; import org.jboss.cache.loader.DummySharedInMemoryCacheLoader; @@ -51,9 +50,6 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = -import java.util.LinkedList; -import java.util.List; - @Test(groups =3D "functional") public class ReplicatedPassivationIntegrationTest { @@ -117,27 +113,23 @@ EvictionConfig cfg =3D new EvictionConfig(); cfg.setWakeupInterval(1000); cfg.setDefaultEventQueueSize(200000); - cfg.setDefaultEvictionPolicyClass(LRUPolicy.class.getName()); - List erc =3D new LinkedList(); - cfg.setEvictionRegionConfigs(erc); = EvictionRegionConfig region1 =3D new EvictionRegionConfig(); region1.setRegionFqn(Fqn.ROOT); - LRUConfiguration epc1 =3D new LRUConfiguration(); + LRUAlgorithmConfig epc1 =3D new LRUAlgorithmConfig(); epc1.setMaxNodes(5000); epc1.setTimeToLive(3000); - region1.setEvictionPolicyConfig(epc1); + region1.setEvictionAlgorithmConfig(epc1); + cfg.setDefaultEvictionRegionConfig(region1); = EvictionRegionConfig region2 =3D new EvictionRegionConfig(); region2.setRegionFqn(base); - LRUConfiguration epc2 =3D new LRUConfiguration(); + LRUAlgorithmConfig epc2 =3D new LRUAlgorithmConfig(); epc2.setMaxNodes(100); epc2.setTimeToLive(3000); - region2.setEvictionPolicyConfig(epc2); + region2.setEvictionAlgorithmConfig(epc2); + cfg.addEvictionRegionConfig(region2); = - erc.add(region1); - erc.add(region2); - return cfg; } = Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTrans= ferConcurrencyTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferCon= currencyTest.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferCon= currencyTest.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -14,6 +14,7 @@ import org.jboss.cache.Fqn; import org.jboss.cache.Node; import org.jboss.cache.Region; +import org.jboss.cache.RegionImpl; import org.jboss.cache.config.Configuration; import org.jboss.cache.config.Configuration.CacheMode; import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; @@ -482,13 +483,13 @@ cache2.start(); caches.put("evict2", cache2); = - Region region =3D cache2.getRegion(Fqn.ROOT, false); + RegionImpl region =3D (RegionImpl) cache2.getRegion(Fqn.ROOT, false); // We expect a VISIT event for / and ADD events for /a, /a/b and /a/= b/c - int nodeEventQueueSize =3D region.nodeEventQueueSize(); + int nodeEventQueueSize =3D region.getEvictionEventQueue().size(); int i =3D 0; - while (region.nodeEventQueueSize() > 0) + while (nodeEventQueueSize > 0) { - System.out.println(++i + ") Queue contains : " + region.takeLastE= ventNode()); + System.out.println(++i + ") Queue contains : " + region.getEvicti= onEventQueue().poll(0, TimeUnit.MILLISECONDS)); } = assertEquals("Saw the expected number of node events", 4, nodeEventQ= ueueSize); Modified: core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionC= ontroller.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionControl= ler.java 2008-08-14 19:16:15 UTC (rev 6561) +++ core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionControl= ler.java 2008-08-15 10:59:40 UTC (rev 6562) @@ -8,7 +8,7 @@ import org.jboss.cache.config.EvictionConfig; import org.jboss.cache.config.EvictionRegionConfig; import org.jboss.cache.eviction.EvictionTimerTask; -import org.jboss.cache.eviction.LRUConfiguration; +import org.jboss.cache.eviction.LRUAlgorithmConfig; import org.jboss.cache.util.TestingUtil; = import java.lang.reflect.Method; @@ -69,9 +69,9 @@ throw new IllegalStateException("No such region!"); } long ttl =3D 0; - if (erConfig.getEvictionPolicyConfig() instanceof LRUConfiguration) + if (erConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmCon= fig) { - LRUConfiguration configuration =3D (LRUConfiguration) erConfig.ge= tEvictionPolicyConfig(); + LRUAlgorithmConfig configuration =3D (LRUAlgorithmConfig) erConfi= g.getEvictionAlgorithmConfig(); ttl =3D configuration.getTimeToLive(); } else Modified: core/trunk/src/test/resources/unit-test-cache-service.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/resources/unit-test-cache-service.xml 2008-08-14 19= :16:15 UTC (rev 6561) +++ core/trunk/src/test/resources/unit-test-cache-service.xml 2008-08-15 10= :59:40 UTC (rev 6562) @@ -2,7 +2,7 @@ = = - = + @@ -11,18 +11,18 @@ - - + + 5000 - 1000 + 1000 5000 - 1000 + 1000 5 - 4 + 4 --===============8145851995119243193==-- From jbosscache-commits at lists.jboss.org Fri Aug 15 08:14:11 2008 Content-Type: multipart/mixed; boundary="===============0469282611857522184==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6563 - core/branches/1.4.X/src/org/jboss/cache. Date: Fri, 15 Aug 2008 08:14:10 -0400 Message-ID: --===============0469282611857522184== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: galder.zamarreno(a)jboss.com Date: 2008-08-15 08:14:09 -0400 (Fri, 15 Aug 2008) New Revision: 6563 Modified: core/branches/1.4.X/src/org/jboss/cache/TreeCache.java Log: [JBCACHE-1393] Fixed javadoc. Modified: core/branches/1.4.X/src/org/jboss/cache/TreeCache.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/1.4.X/src/org/jboss/cache/TreeCache.java 2008-08-15 10:59= :40 UTC (rev 6562) +++ core/branches/1.4.X/src/org/jboss/cache/TreeCache.java 2008-08-15 12:14= :09 UTC (rev 6563) @@ -3816,7 +3816,7 @@ * @param key * @param value * @param timeout Number of milliseconds to wait until a lock has been = acquired. A TimeoutException will - * be thrown if not successful. 0 means to wait forever + * be thrown if not successful. 0 means no wait at all. * @return * @throws CacheException * @deprecated This is a kludge created specifically form the Hibernate= 3.0 release. This method should --===============0469282611857522184==-- From jbosscache-commits at lists.jboss.org Fri Aug 15 17:16:45 2008 Content-Type: multipart/mixed; boundary="===============6184558911501290184==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6564 - in core/trunk/src: main/java/org/jboss/cache/config/parsing and 14 other directories. Date: Fri, 15 Aug 2008 17:16:38 -0400 Message-ID: --===============6184558911501290184== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: jason.greene(a)jboss.com Date: 2008-08-15 17:16:37 -0400 (Fri, 15 Aug 2008) New Revision: 6564 Added: core/trunk/src/main/resources/schema/ core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd Removed: core/trunk/src/main/resources/jbosscache-config-3.0.xsd Modified: core/trunk/src/main/java/org/jboss/cache/Fqn.java core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlP= arser.java core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsStackPars= er.java core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.= java core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguration= Parser.java core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.ja= va core/trunk/src/main/java/org/jboss/cache/config/parsing/element/BuddyEle= mentParser.java core/trunk/src/main/java/org/jboss/cache/config/parsing/element/Eviction= ElementParser.java core/trunk/src/main/java/org/jboss/cache/config/parsing/element/LoadersE= lementParser.java core/trunk/src/main/java/org/jboss/cache/util/FileLookup.java core/trunk/src/main/resources/config-samples/buddy-replication.xml core/trunk/src/main/resources/config-samples/cacheloader-enabled.xml core/trunk/src/main/resources/config-samples/eviction-enabled.xml core/trunk/src/main/resources/config-samples/invalidation-async.xml core/trunk/src/main/resources/config-samples/local.xml core/trunk/src/main/resources/config-samples/multiplexer-enabled.xml core/trunk/src/main/resources/config-samples/total-replication.xml core/trunk/src/main/resources/config2to3.xslt core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTe= st.java core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicati= onConfigTest.java core/trunk/src/test/java/org/jboss/cache/config/parsing/BuddyElementPars= erTest.java core/trunk/src/test/java/org/jboss/cache/config/parsing/CacheLoadersElem= entParserTest.java core/trunk/src/test/java/org/jboss/cache/config/parsing/CustomIntercepto= rsElementParserTest.java core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementP= arserTest.java core/trunk/src/test/java/org/jboss/cache/config/parsing/JGroupsStackPars= erTest.java core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConfigurati= onTest.java core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurationTest.= java core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfigurationTest.j= ava core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.j= ava core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.j= ava core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest= .java core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigur= ationFactory.java core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigurat= ionTest.java core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderManagerTest.j= ava core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderPurgingTest.j= ava core/trunk/src/test/resources/configs/buddy-replication-cache.xml core/trunk/src/test/resources/configs/clonable-config.xml core/trunk/src/test/resources/configs/local-lru-eviction.xml core/trunk/src/test/resources/configs/local-passivation.xml core/trunk/src/test/resources/configs/local-tx.xml core/trunk/src/test/resources/configs/mixedPolicy-eviction.xml core/trunk/src/test/resources/configs/mux.xml core/trunk/src/test/resources/configs/mvcc-repl-sync-br.xml core/trunk/src/test/resources/configs/parser-test.xml core/trunk/src/test/resources/configs/policyPerRegion-eviction.xml core/trunk/src/test/resources/configs/replSync.xml core/trunk/src/test/resources/configs/string-property-replaced.xml core/trunk/src/test/resources/jbc2-registry-configs.xml core/trunk/src/test/resources/unit-test-cache-service.xml Log: Use JBossEntityResolver to find schema Modify schema to use a namespace Correct simple type pattern for locking scheme Modify parser to use the namespace Update configuration files Add root element checking to prevent NPEs Modified: core/trunk/src/main/java/org/jboss/cache/Fqn.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/Fqn.java 2008-08-15 12:14:09 U= TC (rev 6563) +++ core/trunk/src/main/java/org/jboss/cache/Fqn.java 2008-08-15 21:16:37 U= TC (rev 6564) @@ -110,12 +110,13 @@ size =3D 0; } = - protected Fqn(List names, boolean safe) + @SuppressWarnings("unchecked") + protected Fqn(List names, boolean safe) { if (names !=3D null) { // if not safe make a defensive copy - elements =3D safe ? names : Immutables.immutableListCopy(names); + elements =3D safe ? (List) names : Immutables.immutableLi= stCopy(names); size =3D elements.size(); } else @@ -141,9 +142,9 @@ * @since 2.2.0 */ @SuppressWarnings("unchecked") - public static Fqn fromList(List names) + public static Fqn fromList(List names) { - return new Fqn((List)names, false); + return new Fqn(names, false); } = /** @@ -159,7 +160,7 @@ @SuppressWarnings("unchecked") public static Fqn fromList(List names, boolean safe) { - return new Fqn((List)names, safe); + return new Fqn(names, safe); } = /** Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConf= igsXmlParser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXml= Parser.java 2008-08-15 12:14:09 UTC (rev 6563) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXml= Parser.java 2008-08-15 21:16:37 UTC (rev 6564) @@ -109,7 +109,8 @@ if (name =3D=3D null || name.trim().length() =3D=3D 0) throw new ConfigurationException("Element " + element + " has = no name attribute"); XmlConfigurationParser parser =3D new XmlConfigurationParser(); - Configuration c =3D parser.parseElement(element); + // FIXME - This should be using a valid schema!!! + Configuration c =3D parser.parseElementIgnoringRoot(element); // Prove that we can successfully clone it c =3D c.clone(); result.put(name.trim(), c); Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsSt= ackParser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsStackPar= ser.java 2008-08-15 12:14:09 UTC (rev 6563) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsStackPar= ser.java 2008-08-15 21:16:37 UTC (rev 6564) @@ -54,8 +54,9 @@ continue; } = + // Ignore Namespace until JGroups defines one Element tag =3D (Element) node; - String protocol =3D tag.getTagName(); + String protocol =3D tag.getLocalName(); buffer.append(protocol); processAttributes(buffer, tag); buffer.append(':'); Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfig= Helper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper= .java 2008-08-15 12:14:09 UTC (rev 6563) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper= .java 2008-08-15 21:16:37 UTC (rev 6564) @@ -364,16 +364,34 @@ * @return a DOM Element * @throws Exception if unable to parse the String or if it doesn't con= tain valid XML. */ - public static Element stringToElement(String xml) throws Exception + public static Element stringToElementInCoreNS(String xml) throws Except= ion { + xml =3D "" + xml + ""; ByteArrayInputStream bais =3D new ByteArrayInputStream(xml.getBytes(= "utf8")); - DocumentBuilder builder =3D DocumentBuilderFactory.newInstance().new= DocumentBuilder(); + DocumentBuilderFactory factory =3D DocumentBuilderFactory.newInstanc= e(); + factory.setNamespaceAware(true); + DocumentBuilder builder =3D factory.newDocumentBuilder(); Document d =3D builder.parse(bais); bais.close(); - return d.getDocumentElement(); + return getFirstChildElement(d.getDocumentElement()); } = /** + * Gets the first child element of an element + * + * @param element the parent + * @return the first child element or null if there isn't one + */ + public static Element getFirstChildElement(Element element) + { + Node child =3D element.getFirstChild(); + while (child !=3D null && child.getNodeType() !=3D Node.ELEMENT_NODE) + child =3D child.getNextSibling(); + + return (Element)child; + } + + /** * Returns the root element of a given input stream * * @param is stream to parse @@ -387,6 +405,7 @@ InputSource xmlInp =3D new InputSource(is); = DocumentBuilderFactory docBuilderFactory =3D DocumentBuilderFacto= ry.newInstance(); + docBuilderFactory.setNamespaceAware(true); DocumentBuilder parser =3D docBuilderFactory.newDocumentBuilder(); doc =3D parser.parse(xmlInp); Element root =3D doc.getDocumentElement(); Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfig= urationParser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParser.java 2008-08-15 12:14:09 UTC (rev 6563) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParser.java 2008-08-15 21:16:37 UTC (rev 6564) @@ -35,6 +35,7 @@ import org.jboss.cache.config.parsing.element.LoadersElementParser; import org.jboss.cache.lock.IsolationLevel; import org.jboss.cache.util.FileLookup; +import org.jboss.util.xml.JBossEntityResolver; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.ErrorHandler; @@ -62,11 +63,19 @@ */ public class XmlConfigurationParser extends XmlParserBase { + private static final Log log =3D LogFactory.getLog(XmlConfigurationPars= er.class); + private static final JBossEntityResolver resolver =3D new JBossEntityRe= solver(); = + public static final String VALIDATING_SYSTEM_PROPERTY =3D "jbosscache.c= onfig.validate"; - public static final String SCHEMA_LOCATION_SYSTEM_PROPERTY =3D "jbossca= che.config.schemaLocation"; = + static + { + // Globally register this namespace + JBossEntityResolver.registerEntity(JBOSSCACHE_CORE_NS, "jbosscache-c= onfig-3.0.xsd"); + } + /** * the resulting configuration. */ @@ -74,7 +83,6 @@ private Element root; private ErrorHandler errorHandler; private boolean isValidating; - private String schemaLocation; = /** * If validation is on (default) one can specify an error handler for h= andling validation errors. @@ -84,7 +92,6 @@ { this.errorHandler =3D errorHandler; isValidating =3D System.getProperty(VALIDATING_SYSTEM_PROPERTY) =3D= =3D null || Boolean.getBoolean(VALIDATING_SYSTEM_PROPERTY); - schemaLocation =3D System.getProperty(SCHEMA_LOCATION_SYSTEM_PROPERT= Y); } = /** @@ -131,7 +138,7 @@ public Configuration parseStream(InputStream configStream) { readRoot(configStream); - return processElements(); + return processElements(false); } = /** @@ -143,20 +150,36 @@ { this.root =3D root; this.root.normalize(); - return processElements(); + return processElements(false); } = + // FIXME: CacheConfigsXmlParser should be using a valid schema! + @Deprecated + public Configuration parseElementIgnoringRoot(Element root) + { + this.root =3D root; + this.root.normalize(); + return processElements(true); + } + public boolean isValidating() { return isValidating; } = - private Configuration processElements() + private Configuration processElements(boolean ignoreRoot) { - if ("server".equalsIgnoreCase(root.getNodeName())) + if (!ignoreRoot) { - throw new OldFileFormatException(); + if ("server".equalsIgnoreCase(root.getNodeName())) + { + throw new OldFileFormatException(); + } + + if (! "jbosscache".equals(root.getLocalName()) || ! JBOSSCACHE_CO= RE_NS.equals(root.getNamespaceURI())) + throw new ConfigurationException("Expected root element {" + J= BOSSCACHE_CORE_NS + "}" + "jbosscache"); } + try { configureLocking(getSingleElement("locking")); @@ -300,7 +323,7 @@ config.setClusterName(clusterName); String multiplexerStack =3D getAttributeValue(element, "multiplexerS= tack"); if (existsAttribute(multiplexerStack)) config.setMultiplexerStack(mu= ltiplexerStack); - Element clusterConfig =3D getSingleElement("jgroupsConfig", element); + Element clusterConfig =3D getSingleElementInCoreNS("jgroupsConfig", = element); if (clusterConfig !=3D null) { JGroupsStackParser stackParser =3D new JGroupsStackParser(); @@ -324,13 +347,13 @@ if (async !=3D null) { config.setCacheMode(Configuration.CacheMode.INVALIDATION_ASYNC); - configureAsyncMode(getSingleElement("async", element)); + configureAsyncMode(getSingleElementInCoreNS("async", element)); } Element sync =3D getSingleElement("sync"); if (sync !=3D null) { config.setCacheMode(Configuration.CacheMode.INVALIDATION_SYNC); - configureSyncMode(getSingleElement("sync", element)); + configureSyncMode(getSingleElementInCoreNS("sync", element)); } } = @@ -341,15 +364,15 @@ if (async !=3D null) { config.setCacheMode(Configuration.CacheMode.REPL_ASYNC); - configureAsyncMode(getSingleElement("async", element)); + configureAsyncMode(getSingleElementInCoreNS("async", element)); } Element sync =3D getSingleElement("sync"); if (sync !=3D null) { config.setCacheMode(Configuration.CacheMode.REPL_SYNC); - configureSyncMode(getSingleElement("sync", element)); + configureSyncMode(getSingleElementInCoreNS("sync", element)); } - configureBuddyReplication(getSingleElement("buddy", element)); + configureBuddyReplication(getSingleElementInCoreNS("buddy", element)= ); } = private void configureSyncMode(Element element) @@ -387,7 +410,7 @@ = private Element getSingleElement(String elementName) { - return getSingleElement(elementName, root); + return getSingleElementInCoreNS(elementName, root); } = private void readRoot(InputStream config) @@ -395,22 +418,16 @@ try { DocumentBuilderFactory docBuilderFactory =3D DocumentBuilderFacto= ry.newInstance(); + docBuilderFactory.setNamespaceAware(true); if (isValidating) { docBuilderFactory.setValidating(true); - docBuilderFactory.setNamespaceAware(true); docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/p= roperties/schemaLanguage", "http://www.w3.org/2001/XMLSchema"); - if (schemaLocation !=3D null) - { - if (log.isTraceEnabled()) log.trace("Using the schema locat= ion set to: '" + schemaLocation + '\''); - docBuilderFactory.setAttribute("http://java.sun.com/xml/jax= p/properties/schemaSource", schemaLocation); - } - else if (log.isTraceEnabled()) - { - log.trace("Validation is enabled, using the schema decalred= in the .xml configuration file"); - } + docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/p= roperties/schemaSource", JBOSSCACHE_CORE_NS); } + DocumentBuilder parser =3D docBuilderFactory.newDocumentBuilder(); + parser.setEntityResolver(resolver); parser.setErrorHandler(errorHandler); Document doc =3D parser.parse(config); root =3D doc.getDocumentElement(); Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParser= Base.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.j= ava 2008-08-15 12:14:09 UTC (rev 6563) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.j= ava 2008-08-15 21:16:37 UTC (rev 6564) @@ -33,6 +33,8 @@ */ public abstract class XmlParserBase { + public static final String JBOSSCACHE_CORE_NS =3D "urn:jboss:jbosscache= -core:config:3.0"; + /** * @see Integer#parseInt(String) */ @@ -68,9 +70,9 @@ /** * Convenient method for retrieving a single element with the give name. */ - protected Element getSingleElement(String elementName, Element parent) + protected Element getSingleElement(String namespace, String elementName= , Element parent) { - NodeList nodeList =3D parent.getElementsByTagName(elementName); + NodeList nodeList =3D parent.getElementsByTagNameNS(namespace, eleme= ntName); if (nodeList.getLength() =3D=3D 0) { return null; @@ -79,6 +81,14 @@ } = /** + * Convenient method for retrieving a single element with the give name. + */ + protected Element getSingleElementInCoreNS(String elementName, Element = parent) + { + return getSingleElement(JBOSSCACHE_CORE_NS, elementName, parent); + } + + /** * Beside querying the element for it's attribute value, it will look i= nto the value, if any, and replace the * jboss properties(e.g. ${someValue:defaultValue}. * @see StringPropertyReplacer#replaceProperties(value); Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/B= uddyElementParser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/element/BuddyEl= ementParser.java 2008-08-15 12:14:09 UTC (rev 6563) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/BuddyEl= ementParser.java 2008-08-15 21:16:37 UTC (rev 6564) @@ -31,8 +31,8 @@ if (existsAttribute(buddyCommunicationTimeout)) brc.setBuddyCommunicationTimeout(getInt(buddyCommunicationTimeout= )); = - parseDataGravitationElement(getSingleElement("dataGravitation", elem= ent), brc); - BuddyReplicationConfig.BuddyLocatorConfig blc =3D parseBuddyLocatorC= onfig(getSingleElement("locator", element)); + parseDataGravitationElement(getSingleElementInCoreNS("dataGravitatio= n", element), brc); + BuddyReplicationConfig.BuddyLocatorConfig blc =3D parseBuddyLocatorC= onfig(getSingleElementInCoreNS("locator", element)); brc.setBuddyLocatorConfig(blc); return brc; } Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/E= victionElementParser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/element/Evictio= nElementParser.java 2008-08-15 12:14:09 UTC (rev 6563) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/Evictio= nElementParser.java 2008-08-15 21:16:37 UTC (rev 6564) @@ -52,7 +52,7 @@ // if (existsAttribute(defaultEventQueueSize)) evictionConfig.setDefa= ultEventQueueSize(getInt(defaultEventQueueSize)); = List evictionRegionConfigs =3D new LinkedList<= EvictionRegionConfig>(); - Element defaultRegion =3D getSingleElement("default", evictionElemen= t); + Element defaultRegion =3D getSingleElementInCoreNS("default", evicti= onElement); = if (defaultRegion !=3D null) { Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/L= oadersElementParser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/element/Loaders= ElementParser.java 2008-08-15 12:14:09 UTC (rev 6563) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/Loaders= ElementParser.java 2008-08-15 21:16:37 UTC (rev 6564) @@ -28,7 +28,7 @@ if (existsAttribute(passivation)) cacheLoaderConfig.setPassivation(g= etBoolean(passivation)); String shared =3D getAttributeValue(element, "shared"); if (existsAttribute(shared)) cacheLoaderConfig.setShared(getBoolean(= shared)); - String preload =3D getPreloadString(getSingleElement("preload", elem= ent)); + String preload =3D getPreloadString(getSingleElementInCoreNS("preloa= d", element)); if (preload !=3D null) cacheLoaderConfig.setPreload(preload); = NodeList cacheLoaderNodes =3D element.getElementsByTagName("loader"); @@ -58,7 +58,7 @@ throw new ConfigurationException("Missing 'class' attribute for = cache loader configuration"); iclc.setClassName(clClass); iclc.setProperties(XmlConfigHelper.readPropertiesContents(indivEleme= nt, "properties")); - CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig s= sc =3D parseSingletonStoreConfig(getSingleElement("singletonStore", indivEl= ement)); + CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig s= sc =3D parseSingletonStoreConfig(getSingleElementInCoreNS("singletonStore",= indivElement)); if (ssc !=3D null) { iclc.setSingletonStoreConfig(ssc); Modified: core/trunk/src/main/java/org/jboss/cache/util/FileLookup.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/util/FileLookup.java 2008-08-1= 5 12:14:09 UTC (rev 6563) +++ core/trunk/src/main/java/org/jboss/cache/util/FileLookup.java 2008-08-1= 5 21:16:37 UTC (rev 6564) @@ -27,6 +27,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; +import java.net.URL; = /** * Holds the logic of looking up a file, in the following sequence: Modified: core/trunk/src/main/resources/config-samples/buddy-replication.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/resources/config-samples/buddy-replication.xml 2008= -08-15 12:14:09 UTC (rev 6563) +++ core/trunk/src/main/resources/config-samples/buddy-replication.xml 2008= -08-15 21:16:37 UTC (rev 6564) @@ -1,7 +1,7 @@ = + xmlns=3D"urn:jboss:jbosscache-core:config:3.0"> = = Modified: core/trunk/src/main/resources/config-samples/multiplexer-enabled.= xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/resources/config-samples/multiplexer-enabled.xml 20= 08-08-15 12:14:09 UTC (rev 6563) +++ core/trunk/src/main/resources/config-samples/multiplexer-enabled.xml 20= 08-08-15 21:16:37 UTC (rev 6564) @@ -1,6 +1,6 @@ + xmlns=3D"urn:jboss:jbosscache-core:config:3.0"> = = + xmlns=3D"urn:jboss:jbosscache-core:config:3.0"> = = + xmlns=3D"urn:jboss:jbosscache-core:config:3.0"> Modified: core/trunk/src/test/resources/configs/replSync.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/resources/configs/replSync.xml 2008-08-15 12:14:09 = UTC (rev 6563) +++ core/trunk/src/test/resources/configs/replSync.xml 2008-08-15 21:16:37 = UTC (rev 6564) @@ -1,6 +1,6 @@ + xmlns=3D"urn:jboss:jbosscache-core:config:3.0"> Modified: core/trunk/src/test/resources/configs/string-property-replaced.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/resources/configs/string-property-replaced.xml 2008= -08-15 12:14:09 UTC (rev 6563) +++ core/trunk/src/test/resources/configs/string-property-replaced.xml 2008= -08-15 21:16:37 UTC (rev 6564) @@ -1,6 +1,6 @@ + xmlns=3D"urn:jboss:jbosscache-core:config:3.0"> Modified: core/trunk/src/test/resources/jbc2-registry-configs.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Modified: core/trunk/src/test/resources/unit-test-cache-service.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/resources/unit-test-cache-service.xml 2008-08-15 12= :14:09 UTC (rev 6563) +++ core/trunk/src/test/resources/unit-test-cache-service.xml 2008-08-15 21= :16:37 UTC (rev 6564) @@ -1,8 +1,6 @@ = - - - + --===============6184558911501290184==-- From jbosscache-commits at lists.jboss.org Fri Aug 15 18:49:25 2008 Content-Type: multipart/mixed; boundary="===============1741574860354561630==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6565 - pojo/trunk. Date: Fri, 15 Aug 2008 18:49:25 -0400 Message-ID: --===============1741574860354561630== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: jason.greene(a)jboss.com Date: 2008-08-15 18:49:24 -0400 (Fri, 15 Aug 2008) New Revision: 6565 Modified: pojo/trunk/pom.xml Log: Workaround aop console logging Modified: pojo/trunk/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/trunk/pom.xml 2008-08-15 21:16:37 UTC (rev 6564) +++ pojo/trunk/pom.xml 2008-08-15 22:49:24 UTC (rev 6565) @@ -5,7 +5,7 @@ 4.0.0 3.0.0-SNAPSHOT - 3.0.0.ALPHA2 + 3.0.0-SNAPSHOT 2.0.0.CR15 @@ -48,6 +48,13 @@ 1.0 true + + + org.jboss.logging + jboss-logging-log4j + 2.0.5.GA + test + = @@ -115,7 +122,7 @@ functional always - -Djbosscache.config.validate=3Dfalse -Djboss.aop.path= =3D${basedir}/src/main/resources/META-INF/pojocache-aop.xml -javaagent:${se= ttings.localRepository}/org/jboss/aop/jboss-aop/${jboss.aop.version}/jboss-= aop-${jboss.aop.version}.jar + -Djboss.aop.path=3D${basedir}/src/main/resources/META-I= NF/pojocache-aop.xml -javaagent:${settings.localRepository}/org/jboss/aop/j= boss-aop/${jboss.aop.version}/jboss-aop-${jboss.aop.version}.jar true --===============1741574860354561630==-- From jbosscache-commits at lists.jboss.org Sat Aug 16 14:22:49 2008 Content-Type: multipart/mixed; boundary="===============0418574429020799124==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6566 - in core/trunk/src: test/java/org/jboss/cache and 1 other directories. Date: Sat, 16 Aug 2008 14:22:45 -0400 Message-ID: --===============0418574429020799124== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-16 14:22:44 -0400 (Sat, 16 Aug 2008) New Revision: 6566 Added: core/trunk/src/test/java/org/jboss/cache/SampleConfigFilesCorrectnessTes= t.java Modified: core/trunk/src/main/resources/config-samples/buddy-replication.xml core/trunk/src/main/resources/config-samples/invalidation-async.xml core/trunk/src/main/resources/config-samples/total-replication.xml core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguration= SchemaTest.java Log: added test to check corectness of the configuration files Modified: core/trunk/src/main/resources/config-samples/buddy-replication.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/resources/config-samples/buddy-replication.xml 2008= -08-15 22:49:24 UTC (rev 6565) +++ core/trunk/src/main/resources/config-samples/buddy-replication.xml 2008= -08-16 18:22:44 UTC (rev 6566) @@ -45,11 +45,11 @@ - - + Modified: core/trunk/src/main/resources/config-samples/invalidation-async.x= ml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/resources/config-samples/invalidation-async.xml 200= 8-08-15 22:49:24 UTC (rev 6565) +++ core/trunk/src/main/resources/config-samples/invalidation-async.xml 200= 8-08-16 18:22:44 UTC (rev 6566) @@ -46,11 +46,11 @@ - - + Modified: core/trunk/src/main/resources/config-samples/total-replication.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/resources/config-samples/total-replication.xml 2008= -08-15 22:49:24 UTC (rev 6565) +++ core/trunk/src/main/resources/config-samples/total-replication.xml 2008= -08-16 18:22:44 UTC (rev 6566) @@ -45,11 +45,11 @@ - - + Added: core/trunk/src/test/java/org/jboss/cache/SampleConfigFilesCorrectnes= sTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/SampleConfigFilesCorrectnessTe= st.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/SampleConfigFilesCorrectnessTe= st.java 2008-08-16 18:22:44 UTC (rev 6566) @@ -0,0 +1,162 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2008, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.cache; + +import org.testng.annotations.Test; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.AfterTest; +import org.apache.log4j.AppenderSkeleton; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.apache.log4j.spi.LoggingEvent; +import org.jboss.cache.config.parsing.XmlConfigurationSchemaTest; +import org.jboss.cache.config.parsing.XmlConfigurationParser; + +import java.io.File; +import java.io.FilenameFilter; + +/** + * The purpose of this test is to make sure that the config files we ship = are correct both according to xml schema and + * according to the used JGroups/JBossCache version. For the latter, we st= art a cache instance and make sure that no + * configuration warnings are being logged by both JGroups and JBossCache. + * + * @author Mircea.Markus(a)jboss.com + * @since 3.0 + */ +(a)Test(groups =3D "functional") +public class SampleConfigFilesCorrectnessTest +{ + public static final String CONFIG_ROOT =3D "src/main/resources/config-s= amples"; + public static final String XSD_FILE =3D "src/main/resources/jbosscache-= config-3.0.xsd"; + + private InMemoryAppender appender; + private Level oldLevel; + + + /** + * Will be called only once, before all test methods run. + */ + @BeforeTest + public void setUpTest() + { + Logger log4jLogger =3D Logger.getRootLogger(); + oldLevel =3D log4jLogger.getLevel(); + log4jLogger.setLevel(Level.WARN); + appender =3D new InMemoryAppender(); + log4jLogger.addAppender(appender); + File f =3D new File("."); + System.out.println("f =3D " + f.getAbsolutePath()); + } + + /** + * Will be called only once, after all test methods run. + */ + @AfterTest + public void tearDownTest() + { + Logger log4jLogger =3D Logger.getRootLogger(); + log4jLogger.setLevel(oldLevel); + log4jLogger.removeAppender(appender); + } + + public void testSchemaValidity() + { + System.setProperty("jbosscache.config.schemaLocation", XSD_FILE); + XmlConfigurationSchemaTest.ExceptionCountingErrorHandler errorHandle= r =3D new XmlConfigurationSchemaTest.ExceptionCountingErrorHandler(); + XmlConfigurationParser parser =3D new XmlConfigurationParser(errorHa= ndler); + String[] configFiles =3D getConfigFileNames(); + for (String aConfFile : configFiles) + { + System.out.println("Processing file: " + aConfFile); + parser.parseFile(CONFIG_ROOT + "/" + aConfFile); + } + assert errorHandler.noErrors(); + } + + public void testConfigWarnings() + { + DefaultCacheFactory dcf =3D new DefaultCacheFactory(); + for (String aConfFile : getConfigFileNames()) + { + System.out.println("Processing file: " + aConfFile); + assert !appender.isFoundUnknownWarning(); + Cache cache =3D dcf.createCache(CONFIG_ROOT + "/" + aConfFile); + cache.stop(); + assert !appender.isFoundUnknownWarning(); + } + } + + private String[] getConfigFileNames() + { + File file =3D new File(CONFIG_ROOT); + return file.list(new FilenameFilter() + { + public boolean accept(File dir, String name) + { + return name.indexOf("xml") > 0; + } + }); + } + + + private static class InMemoryAppender extends AppenderSkeleton + { + String[] TOLERABLE_WARNINGS =3D {"Falling back to DummyTransactionMa= nager"}; + boolean foundUnknownWarning =3D false; + + protected void append(LoggingEvent event) + { + if (event.getLevel().equals(Level.WARN)) + { + boolean skipPrinting =3D false; + foundUnknownWarning =3D true; + for (String knownWarn : TOLERABLE_WARNINGS) + { + if (event.getMessage().toString().indexOf(knownWarn) >=3D 0) + { + skipPrinting =3D true; + foundUnknownWarning =3D false; + } + } + if (!skipPrinting) + { + System.out.println("Unaccepted warn message :" + event.getM= essage()); + } + } + } + + public boolean requiresLayout() + { + return false; + } + + public void close() + { + //do nothing + } + + public boolean isFoundUnknownWarning() + { + return foundUnknownWarning; + } + } +} Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfig= urationSchemaTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nSchemaTest.java 2008-08-15 22:49:24 UTC (rev 6565) +++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nSchemaTest.java 2008-08-16 18:22:44 UTC (rev 6566) @@ -69,7 +69,7 @@ assert parser.isValidating(); } = - private static class ExceptionCountingErrorHandler implements ErrorHand= ler + public static class ExceptionCountingErrorHandler implements ErrorHandl= er { List exceptionList =3D new ArrayList(); = @@ -94,7 +94,7 @@ exceptionList.add(exception); } = - boolean noErrors() + public boolean noErrors() { return exceptionList.isEmpty(); } --===============0418574429020799124==-- From jbosscache-commits at lists.jboss.org Sat Aug 16 14:45:25 2008 Content-Type: multipart/mixed; boundary="===============8690669739540009901==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6567 - core/trunk/src/main/java/org/jboss/cache. Date: Sat, 16 Aug 2008 14:45:25 -0400 Message-ID: --===============8690669739540009901== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-16 14:45:24 -0400 (Sat, 16 Aug 2008) New Revision: 6567 Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java Log: added warn re:message_bundling if not using a shared transport Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-08-16= 18:22:44 UTC (rev 6566) +++ core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-08-16= 18:45:24 UTC (rev 6567) @@ -42,6 +42,8 @@ import org.jgroups.JChannel; import org.jgroups.StateTransferException; import org.jgroups.View; +import org.jgroups.protocols.TP; +import org.jgroups.stack.ProtocolStack; import org.jgroups.blocks.GroupRequest; import org.jgroups.blocks.RspFilter; import org.jgroups.util.Rsp; @@ -297,7 +299,7 @@ rpcDispatcher =3D new CommandAwareRpcDispatcher(channel, messageL= istener, new MembershipListenerAdaptor(), invocationContextContainer, invocationContextContainer, int= erceptorChain, componentRegistry); } - + checkAppropriateConfig(); rpcDispatcher.setRequestMarshaller(marshaller); rpcDispatcher.setResponseMarshaller(marshaller); } @@ -756,4 +758,37 @@ double ration =3D (double)replicationCount / totalCount * 100d; return NumberFormat.getInstance().format(ration) +"%"; } + + /** + * Checks to see whether the cache is using an appropriate JGroups conf= ig. + */ + private void checkAppropriateConfig() + { + //if we use a shared transport do not log any warn message + if (configuration.getMultiplexerStack() !=3D null) + return; + //bundling is not good for sync caches + Configuration.CacheMode cacheMode =3D configuration.getCacheMode(); + if (!cacheMode.equals(Configuration.CacheMode.LOCAL) && configuratio= n.getCacheMode().isSynchronous()) + { + ProtocolStack stack =3D ((JChannel)channel).getProtocolStack(); + TP transport =3D stack.getTransport(); + if (transport.isEnableBundling()) + { + log.warn("You have enabled jgroups's message bundling, which i= s not recommended for sync replication. If there is no particular " + + "reason for this we strongly recommend to disable messag= e bundling in JGroups config (enable_bundling=3D\"false\")."); + } + } + //bundling is good for async caches + if (!cacheMode.isSynchronous()) + { + ProtocolStack stack =3D ((JChannel)channel).getProtocolStack(); + TP transport =3D stack.getTransport(); + if (!transport.isEnableBundling()) + { + log.warn("You have disabled jgroups's message bundling, which = is not recommended for async replication. If there is no particular " + + "reason for this we strongly recommend to enable message= bundling in JGroups config (enable_bundling=3D\"true\")."); + } + } + } } \ No newline at end of file --===============8690669739540009901==-- From jbosscache-commits at lists.jboss.org Sun Aug 17 12:28:56 2008 Content-Type: multipart/mixed; boundary="===============2535779239429579418==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6568 - in core/trunk/src: main/java/org/jboss/cache/eviction and 2 other directories. Date: Sun, 17 Aug 2008 12:28:54 -0400 Message-ID: --===============2535779239429579418== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-17 12:28:52 -0400 (Sun, 17 Aug 2008) New Revision: 6568 Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/Eviction= ElementParser.java core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithmConfi= gBase.java core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguration= ParserTest.java core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguration= SchemaTest.java core/trunk/src/test/resources/configs/clonable-config.xml core/trunk/src/test/resources/configs/local-lru-eviction.xml core/trunk/src/test/resources/configs/local-passivation.xml core/trunk/src/test/resources/configs/local-tx.xml core/trunk/src/test/resources/configs/mixedPolicy-eviction.xml core/trunk/src/test/resources/configs/mvcc-repl-sync-br.xml core/trunk/src/test/resources/configs/parser-test.xml core/trunk/src/test/resources/configs/policyPerRegion-eviction.xml core/trunk/src/test/resources/configs/string-property-replaced.xml Log: fixed UT after eviction refactorings Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/E= victionElementParser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/element/Evictio= nElementParser.java 2008-08-16 18:45:24 UTC (rev 6567) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/Evictio= nElementParser.java 2008-08-17 16:28:52 UTC (rev 6568) @@ -46,11 +46,6 @@ throw new ConfigurationException("Missing mandatory attribute wak= eUpInterval"); } = -// String defaultPolicyClassStr =3D getAttributeValue(evictionElement= , "defaultPolicyClass"); -// if (existsAttribute(defaultPolicyClassStr)) evictionConfig.setDefa= ultEvictionPolicyClass(defaultPolicyClassStr); -// String defaultEventQueueSize =3D getAttributeValue(evictionElement= , "defaultEventQueueSize"); -// if (existsAttribute(defaultEventQueueSize)) evictionConfig.setDefa= ultEventQueueSize(getInt(defaultEventQueueSize)); - List evictionRegionConfigs =3D new LinkedList<= EvictionRegionConfig>(); Element defaultRegion =3D getSingleElementInCoreNS("default", evicti= onElement); = @@ -58,7 +53,7 @@ { EvictionRegionConfig defaultRegionConfig =3D getEvictionRegionCon= fig(defaultRegion, null, true); if (defaultRegionConfig.getEvictionAlgorithmConfig() =3D=3D null) - throw new ConfigurationException("Default eviction region shou= ld have an evictionAlgorithmClass defined."); + throw new MissingPolicyException("Default eviction region shou= ld have an evictionAlgorithmClass defined."); evictionConfig.setDefaultEvictionRegionConfig(defaultRegionConfig= ); } = Modified: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorit= hmConfigBase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithmConf= igBase.java 2008-08-16 18:45:24 UTC (rev 6567) +++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithmConf= igBase.java 2008-08-17 16:28:52 UTC (rev 6568) @@ -101,7 +101,6 @@ = public void reset() { - evictionAlgorithmClassName =3D null; maxNodes =3D 0; minTimeToLive =3D 0; } Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfig= urationParserTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParserTest.java 2008-08-16 18:45:24 UTC (rev 6567) +++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParserTest.java 2008-08-17 16:28:52 UTC (rev 6568) @@ -201,28 +201,28 @@ public void testEvictionPolicyConfig() { EvictionConfig evictionConfig =3D config.getEvictionConfig(); - assert "org.jboss.cache.eviction.LRUPolicy".equals(evictionConfig.ge= tDefaultEvictionPolicyClass()); + assert "org.jboss.cache.eviction.LRUAlgorithm".equals(evictionConfig= .getDefaultEvictionRegionConfig().getEvictionAlgorithmConfig().getEvictionA= lgorithmClassName()); assert 200000 =3D=3D evictionConfig.getDefaultEvictionRegionConfig()= .getEventQueueSize(); assert 5 =3D=3D evictionConfig.getWakeupInterval(); = List regionConfigs =3D evictionConfig.getEvict= ionRegionConfigs(); - assert regionConfigs.size() =3D=3D 3; + assert regionConfigs.size() =3D=3D 2; = - EvictionRegionConfig first =3D regionConfigs.get(0); - assert first.getRegionName().equals("/_default_"); + EvictionRegionConfig first =3D evictionConfig.getDefaultEvictionRegi= onConfig(); + assert first.getRegionName().equals("/"); assert first.getEvictionAlgorithmConfig() instanceof LRUAlgorithmCon= fig; LRUAlgorithmConfig firstConfiguration =3D (LRUAlgorithmConfig) first= .getEvictionAlgorithmConfig(); assert firstConfiguration.getMaxAge() <=3D 0; assert firstConfiguration.getTimeToLive() =3D=3D 1000; assert firstConfiguration.getMaxNodes() =3D=3D 5000; = - EvictionRegionConfig second =3D regionConfigs.get(1); + EvictionRegionConfig second =3D regionConfigs.get(0); LRUAlgorithmConfig secondConfiguration =3D (LRUAlgorithmConfig) seco= nd.getEvictionAlgorithmConfig(); assert secondConfiguration.getMaxAge() =3D=3D 0; assert secondConfiguration.getTimeToLive() =3D=3D 1002; assert secondConfiguration.getMaxNodes() =3D=3D 0; = - EvictionRegionConfig third =3D regionConfigs.get(2); + EvictionRegionConfig third =3D regionConfigs.get(1); MRUAlgorithmConfig thirdConfiguration =3D (MRUAlgorithmConfig) third= .getEvictionAlgorithmConfig(); assert thirdConfiguration.getMaxNodes() =3D=3D 2103; assert thirdConfiguration.getMinTimeToLive() =3D=3D 22; Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfig= urationSchemaTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nSchemaTest.java 2008-08-16 18:45:24 UTC (rev 6567) +++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nSchemaTest.java 2008-08-17 16:28:52 UTC (rev 6568) @@ -41,6 +41,7 @@ public void testSimpleFile() { ExceptionCountingErrorHandler handler =3D new ExceptionCountingError= Handler(); + System.setProperty("jbosscache.config.schemaLocation","src/main/reso= urces/jbosscache-config-3.0.xsd"); XmlConfigurationParser parser =3D new XmlConfigurationParser(handler= ); for (String file : testFiles) { Modified: core/trunk/src/test/resources/configs/clonable-config.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/resources/configs/clonable-config.xml 2008-08-16 18= :45:24 UTC (rev 6567) +++ core/trunk/src/test/resources/configs/clonable-config.xml 2008-08-17 16= :28:52 UTC (rev 6568) @@ -44,19 +44,19 @@ - - + + 5000 - 1000 + 1000000 15000 - + 5000 - + 10000 - + 5000 4000 Modified: core/trunk/src/test/resources/configs/local-lru-eviction.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/resources/configs/local-lru-eviction.xml 2008-08-16= 18:45:24 UTC (rev 6567) +++ core/trunk/src/test/resources/configs/local-lru-eviction.xml 2008-08-17= 16:28:52 UTC (rev 6568) @@ -6,27 +6,27 @@ - - + + 5000 - 1000 + 1000000 5000 - 1000 + 1000000 5 - 4 + 4000 10000 - 4 + 4000 10000 - 8 - 10 + 8000 + 10000 Modified: core/trunk/src/test/resources/configs/local-passivation.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/resources/configs/local-passivation.xml 2008-08-16 = 18:45:24 UTC (rev 6567) +++ core/trunk/src/test/resources/configs/local-passivation.xml 2008-08-17 = 16:28:52 UTC (rev 6568) @@ -6,14 +6,14 @@ - - + + 5000 - 1 + 1000 100 - 1 + 1000 Modified: core/trunk/src/test/resources/configs/local-tx.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/resources/configs/local-tx.xml 2008-08-16 18:45:24 = UTC (rev 6567) +++ core/trunk/src/test/resources/configs/local-tx.xml 2008-08-17 16:28:52 = UTC (rev 6568) @@ -7,18 +7,18 @@ - - + + 5000 - 1000 + 1000000 5000 - 1000 + 1000000 5 - 4 + 4000 Modified: core/trunk/src/test/resources/configs/mixedPolicy-eviction.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/resources/configs/mixedPolicy-eviction.xml 2008-08-= 16 18:45:24 UTC (rev 6567) +++ core/trunk/src/test/resources/configs/mixedPolicy-eviction.xml 2008-08-= 17 16:28:52 UTC (rev 6568) @@ -34,21 +34,21 @@ - - + + 5000 - 1000 + 1000000 - + 5000 - + 10000 10000 - 8 - 10 + 8000 + 10000 Modified: core/trunk/src/test/resources/configs/mvcc-repl-sync-br.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/resources/configs/mvcc-repl-sync-br.xml 2008-08-16 = 18:45:24 UTC (rev 6567) +++ core/trunk/src/test/resources/configs/mvcc-repl-sync-br.xml 2008-08-17 = 16:28:52 UTC (rev 6568) @@ -31,7 +31,7 @@ - + Modified: core/trunk/src/test/resources/configs/parser-test.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/resources/configs/parser-test.xml 2008-08-16 18:45:= 24 UTC (rev 6567) +++ core/trunk/src/test/resources/configs/parser-test.xml 2008-08-17 16:28:= 52 UTC (rev 6568) @@ -58,15 +58,15 @@ = = - - + + 5000 1000 1002 - + 2103 22 Modified: core/trunk/src/test/resources/configs/policyPerRegion-eviction.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/resources/configs/policyPerRegion-eviction.xml 2008= -08-16 18:45:24 UTC (rev 6567) +++ core/trunk/src/test/resources/configs/policyPerRegion-eviction.xml 2008= -08-17 16:28:52 UTC (rev 6568) @@ -35,24 +35,24 @@ = - + 5000 - 1000 + 1000000 - + 5000 1000 - + 5 - + 10000 - + 10000 - 8 - 10 + 8000 + 10000 Modified: core/trunk/src/test/resources/configs/string-property-replaced.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/resources/configs/string-property-replaced.xml 2008= -08-16 18:45:24 UTC (rev 6567) +++ core/trunk/src/test/resources/configs/string-property-replaced.xml 2008= -08-17 16:28:52 UTC (rev 6568) @@ -23,10 +23,10 @@ - - + + ${test.property.EvictionPolicyConfig= .maxNodes:5000} - 1000 + 1000000 --===============2535779239429579418==-- From jbosscache-commits at lists.jboss.org Sun Aug 17 12:31:25 2008 Content-Type: multipart/mixed; boundary="===============5799133436435963003==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6569 - core/trunk/src/main/resources/schema. Date: Sun, 17 Aug 2008 12:31:21 -0400 Message-ID: --===============5799133436435963003== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-17 12:31:21 -0400 (Sun, 17 Aug 2008) New Revision: 6569 Modified: core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd Log: updated xsd after eviction refactorings Modified: core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd 2008-08-= 17 16:28:52 UTC (rev 6568) +++ core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd 2008-08-= 17 16:31:21 UTC (rev 6569) @@ -168,8 +168,6 @@ - - = @@ -177,7 +175,8 @@ - + + = --===============5799133436435963003==-- From jbosscache-commits at lists.jboss.org Sun Aug 17 12:52:44 2008 Content-Type: multipart/mixed; boundary="===============4333002119135529012==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6570 - in core/trunk/src/test/java/org/jboss/cache: config/parsing and 1 other directory. Date: Sun, 17 Aug 2008 12:52:43 -0400 Message-ID: --===============4333002119135529012== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-17 12:52:43 -0400 (Sun, 17 Aug 2008) New Revision: 6570 Added: core/trunk/src/test/java/org/jboss/cache/config/parsing/SampleConfigFile= sCorrectnessTest.java Removed: core/trunk/src/test/java/org/jboss/cache/SampleConfigFilesCorrectnessTes= t.java Log: moved to parsing directory Deleted: core/trunk/src/test/java/org/jboss/cache/SampleConfigFilesCorrectn= essTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/SampleConfigFilesCorrectnessTe= st.java 2008-08-17 16:31:21 UTC (rev 6569) +++ core/trunk/src/test/java/org/jboss/cache/SampleConfigFilesCorrectnessTe= st.java 2008-08-17 16:52:43 UTC (rev 6570) @@ -1,162 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2008, Red Hat Middleware LLC, and individual contributors - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.jboss.cache; - -import org.testng.annotations.Test; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.AfterTest; -import org.apache.log4j.AppenderSkeleton; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.apache.log4j.spi.LoggingEvent; -import org.jboss.cache.config.parsing.XmlConfigurationSchemaTest; -import org.jboss.cache.config.parsing.XmlConfigurationParser; - -import java.io.File; -import java.io.FilenameFilter; - -/** - * The purpose of this test is to make sure that the config files we ship = are correct both according to xml schema and - * according to the used JGroups/JBossCache version. For the latter, we st= art a cache instance and make sure that no - * configuration warnings are being logged by both JGroups and JBossCache. - * - * @author Mircea.Markus(a)jboss.com - * @since 3.0 - */ -(a)Test(groups =3D "functional") -public class SampleConfigFilesCorrectnessTest -{ - public static final String CONFIG_ROOT =3D "src/main/resources/config-s= amples"; - public static final String XSD_FILE =3D "src/main/resources/jbosscache-= config-3.0.xsd"; - - private InMemoryAppender appender; - private Level oldLevel; - - - /** - * Will be called only once, before all test methods run. - */ - @BeforeTest - public void setUpTest() - { - Logger log4jLogger =3D Logger.getRootLogger(); - oldLevel =3D log4jLogger.getLevel(); - log4jLogger.setLevel(Level.WARN); - appender =3D new InMemoryAppender(); - log4jLogger.addAppender(appender); - File f =3D new File("."); - System.out.println("f =3D " + f.getAbsolutePath()); - } - - /** - * Will be called only once, after all test methods run. - */ - @AfterTest - public void tearDownTest() - { - Logger log4jLogger =3D Logger.getRootLogger(); - log4jLogger.setLevel(oldLevel); - log4jLogger.removeAppender(appender); - } - - public void testSchemaValidity() - { - System.setProperty("jbosscache.config.schemaLocation", XSD_FILE); - XmlConfigurationSchemaTest.ExceptionCountingErrorHandler errorHandle= r =3D new XmlConfigurationSchemaTest.ExceptionCountingErrorHandler(); - XmlConfigurationParser parser =3D new XmlConfigurationParser(errorHa= ndler); - String[] configFiles =3D getConfigFileNames(); - for (String aConfFile : configFiles) - { - System.out.println("Processing file: " + aConfFile); - parser.parseFile(CONFIG_ROOT + "/" + aConfFile); - } - assert errorHandler.noErrors(); - } - - public void testConfigWarnings() - { - DefaultCacheFactory dcf =3D new DefaultCacheFactory(); - for (String aConfFile : getConfigFileNames()) - { - System.out.println("Processing file: " + aConfFile); - assert !appender.isFoundUnknownWarning(); - Cache cache =3D dcf.createCache(CONFIG_ROOT + "/" + aConfFile); - cache.stop(); - assert !appender.isFoundUnknownWarning(); - } - } - - private String[] getConfigFileNames() - { - File file =3D new File(CONFIG_ROOT); - return file.list(new FilenameFilter() - { - public boolean accept(File dir, String name) - { - return name.indexOf("xml") > 0; - } - }); - } - - - private static class InMemoryAppender extends AppenderSkeleton - { - String[] TOLERABLE_WARNINGS =3D {"Falling back to DummyTransactionMa= nager"}; - boolean foundUnknownWarning =3D false; - - protected void append(LoggingEvent event) - { - if (event.getLevel().equals(Level.WARN)) - { - boolean skipPrinting =3D false; - foundUnknownWarning =3D true; - for (String knownWarn : TOLERABLE_WARNINGS) - { - if (event.getMessage().toString().indexOf(knownWarn) >=3D 0) - { - skipPrinting =3D true; - foundUnknownWarning =3D false; - } - } - if (!skipPrinting) - { - System.out.println("Unaccepted warn message :" + event.getM= essage()); - } - } - } - - public boolean requiresLayout() - { - return false; - } - - public void close() - { - //do nothing - } - - public boolean isFoundUnknownWarning() - { - return foundUnknownWarning; - } - } -} Copied: core/trunk/src/test/java/org/jboss/cache/config/parsing/SampleConfi= gFilesCorrectnessTest.java (from rev 6567, core/trunk/src/test/java/org/jbo= ss/cache/SampleConfigFilesCorrectnessTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/config/parsing/SampleConfigFil= esCorrectnessTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/config/parsing/SampleConfigFil= esCorrectnessTest.java 2008-08-17 16:52:43 UTC (rev 6570) @@ -0,0 +1,164 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2008, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.cache.config.parsing; + +import org.testng.annotations.Test; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.AfterTest; +import org.apache.log4j.AppenderSkeleton; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.apache.log4j.spi.LoggingEvent; +import org.jboss.cache.config.parsing.XmlConfigurationSchemaTest; +import org.jboss.cache.config.parsing.XmlConfigurationParser; +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.Cache; + +import java.io.File; +import java.io.FilenameFilter; + +/** + * The purpose of this test is to make sure that the config files we ship = are correct both according to xml schema and + * according to the used JGroups/JBossCache version. For the latter, we st= art a cache instance and make sure that no + * configuration warnings are being logged by both JGroups and JBossCache. + * + * @author Mircea.Markus(a)jboss.com + * @since 3.0 + */ +(a)Test(groups =3D "functional") +public class SampleConfigFilesCorrectnessTest +{ + public static final String CONFIG_ROOT =3D "src/main/resources/config-s= amples"; + public static final String XSD_FILE =3D "src/main/resources/jbosscache-= config-3.0.xsd"; + + private InMemoryAppender appender; + private Level oldLevel; + + + /** + * Will be called only once, before all test methods run. + */ + @BeforeTest + public void setUpTest() + { + Logger log4jLogger =3D Logger.getRootLogger(); + oldLevel =3D log4jLogger.getLevel(); + log4jLogger.setLevel(Level.WARN); + appender =3D new InMemoryAppender(); + log4jLogger.addAppender(appender); + File f =3D new File("."); + System.out.println("f =3D " + f.getAbsolutePath()); + } + + /** + * Will be called only once, after all test methods run. + */ + @AfterTest + public void tearDownTest() + { + Logger log4jLogger =3D Logger.getRootLogger(); + log4jLogger.setLevel(oldLevel); + log4jLogger.removeAppender(appender); + } + + public void testSchemaValidity() + { + System.setProperty("jbosscache.config.schemaLocation", XSD_FILE); + XmlConfigurationSchemaTest.ExceptionCountingErrorHandler errorHandle= r =3D new XmlConfigurationSchemaTest.ExceptionCountingErrorHandler(); + XmlConfigurationParser parser =3D new XmlConfigurationParser(errorHa= ndler); + String[] configFiles =3D getConfigFileNames(); + for (String aConfFile : configFiles) + { + System.out.println("Processing file: " + aConfFile); + parser.parseFile(CONFIG_ROOT + "/" + aConfFile); + } + assert errorHandler.noErrors(); + } + + public void testConfigWarnings() + { + DefaultCacheFactory dcf =3D new DefaultCacheFactory(); + for (String aConfFile : getConfigFileNames()) + { + System.out.println("Processing file: " + aConfFile); + assert !appender.isFoundUnknownWarning(); + Cache cache =3D dcf.createCache(CONFIG_ROOT + "/" + aConfFile); + cache.stop(); + assert !appender.isFoundUnknownWarning(); + } + } + + private String[] getConfigFileNames() + { + File file =3D new File(CONFIG_ROOT); + return file.list(new FilenameFilter() + { + public boolean accept(File dir, String name) + { + return name.indexOf("xml") > 0; + } + }); + } + + + private static class InMemoryAppender extends AppenderSkeleton + { + String[] TOLERABLE_WARNINGS =3D {"Falling back to DummyTransactionMa= nager"}; + boolean foundUnknownWarning =3D false; + + protected void append(LoggingEvent event) + { + if (event.getLevel().equals(Level.WARN)) + { + boolean skipPrinting =3D false; + foundUnknownWarning =3D true; + for (String knownWarn : TOLERABLE_WARNINGS) + { + if (event.getMessage().toString().indexOf(knownWarn) >=3D 0) + { + skipPrinting =3D true; + foundUnknownWarning =3D false; + } + } + if (!skipPrinting) + { + System.out.println("Unaccepted warn message :" + event.getM= essage()); + } + } + } + + public boolean requiresLayout() + { + return false; + } + + public void close() + { + //do nothing + } + + public boolean isFoundUnknownWarning() + { + return foundUnknownWarning; + } + } +} --===============4333002119135529012==-- From jbosscache-commits at lists.jboss.org Sun Aug 17 12:54:21 2008 Content-Type: multipart/mixed; boundary="===============6308564954080952309==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6571 - core/trunk/src/main/java/org/jboss/cache. Date: Sun, 17 Aug 2008 12:54:21 -0400 Message-ID: --===============6308564954080952309== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-17 12:54:21 -0400 (Sun, 17 Aug 2008) New Revision: 6571 Modified: core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java Log: fixed eviction config issue Modified: core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-08= -17 16:52:43 UTC (rev 6570) +++ core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-08= -17 16:54:21 UTC (rev 6571) @@ -94,8 +94,8 @@ { if (trace) log.trace("Starting region manager"); isUsingBR =3D configuration.getBuddyReplicationConfig() !=3D null &&= configuration.getBuddyReplicationConfig().isEnabled(); - if (configuration.getEvictionConfig() !=3D null - && configuration.getEvictionConfig().isValidConfig()) + evictionConfig =3D configuration.getEvictionConfig(); + if (evictionConfig !=3D null && evictionConfig.isValidConfig()) { // start with the default region EvictionRegionConfig defaultRegion =3D configuration.getEvictionC= onfig().getDefaultEvictionRegionConfig(); --===============6308564954080952309==-- From jbosscache-commits at lists.jboss.org Sun Aug 17 12:57:10 2008 Content-Type: multipart/mixed; boundary="===============2769380344839214936==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6572 - core/trunk/src/main/resources/config-samples. Date: Sun, 17 Aug 2008 12:57:08 -0400 Message-ID: --===============2769380344839214936== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-17 12:57:07 -0400 (Sun, 17 Aug 2008) New Revision: 6572 Modified: core/trunk/src/main/resources/config-samples/cacheloader-enabled.xml core/trunk/src/main/resources/config-samples/eviction-enabled.xml Log: fixed resource configuration files Modified: core/trunk/src/main/resources/config-samples/cacheloader-enabled.= xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/resources/config-samples/cacheloader-enabled.xml 20= 08-08-17 16:54:21 UTC (rev 6571) +++ core/trunk/src/main/resources/config-samples/cacheloader-enabled.xml 20= 08-08-17 16:57:07 UTC (rev 6572) @@ -19,16 +19,15 @@ = - + - + 5000 - 3 + 3000 100 - 3 + 3000 = @@ -54,11 +53,11 @@ cache.jdbc.node.column=3Dnode cache.jdbc.node.type=3Dblob cache.jdbc.parent.column=3Dparent - cache.jdbc.driver=3Dcom.mysql.jdbc.Driver - cache.jdbc.url=3Djdbc:mysql://localhost:3306/jbossdb - cache.jdbc.user=3Droot - cache.jdbc.password=3D - cache.jdbc.sql-concat=3Dconcat(1,2) + cache.jdbc.sql-concat=3D1 || 2 + cache.jdbc.driver =3D org.apache.derby.jdbc.EmbeddedDriver + cache.jdbc.url=3Djdbc:derby:jbossdb;create=3Dtrue + cache.jdbc.user=3Duser1 + cache.jdbc.password=3Duser1 Modified: core/trunk/src/main/resources/config-samples/eviction-enabled.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/resources/config-samples/eviction-enabled.xml 2008-= 08-17 16:54:21 UTC (rev 6571) +++ core/trunk/src/main/resources/config-samples/eviction-enabled.xml 2008-= 08-17 16:57:07 UTC (rev 6572) @@ -23,31 +23,30 @@ defaultPolicyClass: if policy class is not specified for a region, t= his one is considered as default defaultEventQueueSize if policy event queue size is not specified f= or a region, this one is considered as default --> - - + - + 5000 - 1000 + 1000000 = = 5000 - 1000 + 1000000 5 - 4 + 4000 10000 - 4 + 4000 10000 - 8 - 10 + 8000 + 10000 --===============2769380344839214936==-- From jbosscache-commits at lists.jboss.org Mon Aug 18 06:32:48 2008 Content-Type: multipart/mixed; boundary="===============3017793855385379173==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6573 - in core/trunk/src: test/java/org/jboss/cache/buddyreplication and 2 other directories. Date: Mon, 18 Aug 2008 06:32:47 -0400 Message-ID: --===============3017793855385379173== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-18 06:32:47 -0400 (Mon, 18 Aug 2008) New Revision: 6573 Modified: core/trunk/src/main/resources/config2to3.xslt core/trunk/src/test/java/org/jboss/cache/buddyreplication/MvccBuddyRepli= cationTest.java core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransformer= Test.java core/trunk/src/test/resources/configs/conf2x/eviction-enabled-cache.xml Log: updated 2x-3x transformation Modified: core/trunk/src/main/resources/config2to3.xslt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/resources/config2to3.xslt 2008-08-17 16:57:07 UTC (= rev 6572) +++ core/trunk/src/main/resources/config2to3.xslt 2008-08-18 10:32:47 UTC (= rev 6573) @@ -1,6 +1,7 @@ = - + = @@ -272,25 +273,29 @@ select=3D"concat(normalize-space(./config/attribute[@= name=3D'wakeUpIntervalSeconds']), '000')"/> - - - - - - - - - - - 0]"> - + + 0]/@policyClass"/> + select=3D"concat(substring-before(./config/attr= ibute[@name=3D'policyClass'],'Policy'), 'Algorithm')"/> - + + Custom eviction policies = require manual transformation. + + + + + + + + + + + @@ -300,17 +305,58 @@ - - - + + + - + + Custom eviction policies = require manual transformation. + + + + + + + + + + + + + + + + + + + + + = + + + + + + + + + + + + + + + + + + @@ -386,6 +432,7 @@ = + @@ -411,7 +458,6 @@ = - Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/MvccBud= dyReplicationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/buddyreplication/MvccBuddyRepl= icationTest.java 2008-08-17 16:57:07 UTC (rev 6572) +++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/MvccBuddyRepl= icationTest.java 2008-08-18 10:32:47 UTC (rev 6573) @@ -23,6 +23,7 @@ = import org.jboss.cache.Cache; import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.CacheSPI; import org.jboss.cache.config.Configuration; import org.jboss.cache.config.Option; import org.jboss.cache.config.parsing.XmlConfigurationParser; @@ -67,4 +68,22 @@ DefaultCacheFactory dcf =3D new DefaultCacheFactory<= String, String>(); return dcf.createCache(fileConfig); } + + public void testSimple() throws Exception + { + Configuration fileConfig =3D new XmlConfigurationParser().parseFile(= FILE); + fileConfig.setCacheMode(Configuration.CacheMode.LOCAL); + DefaultCacheFactory dcf =3D new DefaultCacheFactory<= String, String>(); + CacheSPI cache =3D (CacheSPI) dcf.createCache(fileConfig); + cache.getTransactionManager().begin(); + cache.put("/a/b/c","key","value"); + cache.put("/a/b/c","key1","value"); + cache.put("/a/b/c","key2","value"); + cache.put("/a/b/c","key2","value"); + cache.put("/a/b/c","key3","value"); + cache.put("/a/b/c","key4","value"); + cache.put("/a/b/c","key5","value"); + cache.getTransactionManager().commit(); + cache.stop(); + } } Modified: core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTran= sformerTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransforme= rTest.java 2008-08-17 16:57:07 UTC (rev 6572) +++ core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransforme= rTest.java 2008-08-18 10:32:47 UTC (rev 6573) @@ -51,19 +51,20 @@ public void testEqualityOnTransformedFiles() throws Exception { String[] fileNames =3D { - "buddy-replication-cache.xml", - "cacheloader-enabled-cache.xml", +// "buddy-replication-cache.xml", +// "cacheloader-enabled-cache.xml", "eviction-enabled-cache.xml", - "local-cache.xml", "multiplexer-enabled-cache.xml", - "optimistically-locked-cache.xml", "total-replication-cache.xm= l", "clonable-config.xml", - "policyPerRegion-eviction.xml" , "default-test-config2x.xml"}; +// "local-cache.xml", "multiplexer-enabled-cache.xml", +// "optimistically-locked-cache.xml", "total-replication-cache.= xml", "clonable-config.xml", +// "policyPerRegion-eviction.xml" , "default-test-config2x.xml" + }; for (String file : fileNames) { System.out.println("Processing file =3D " + file); String fileName =3D getFileName(file); ByteArrayOutputStream baos =3D new ByteArrayOutputStream(); convertor.parse(fileName, baos, XSLT_FILE); -// System.out.println("result =3D \n" + baos); + System.out.println("result =3D \n" + baos); = XmlConfigurationParser newParser =3D new XmlConfigurationParser(); XmlConfigurationParser2x oldParser =3D new XmlConfigurationParser= 2x(); Modified: core/trunk/src/test/resources/configs/conf2x/eviction-enabled-cac= he.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/resources/configs/conf2x/eviction-enabled-cache.xml= 2008-08-17 16:57:07 UTC (rev 6572) +++ core/trunk/src/test/resources/configs/conf2x/eviction-enabled-cache.xml= 2008-08-18 10:32:47 UTC (rev 6573) @@ -64,22 +64,23 @@ 5000 1000 - + + 1000 5000 - - 5 - 4 - - - 10000 - 4 - - - 10000 - 8 - 10 - + + + + + + + + + + + + + = --===============3017793855385379173==-- From jbosscache-commits at lists.jboss.org Mon Aug 18 09:34:17 2008 Content-Type: multipart/mixed; boundary="===============6601722467409085966==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6574 - in core/trunk/src: main/java/org/jboss/cache/config and 9 other directories. Date: Mon, 18 Aug 2008 09:34:17 -0400 Message-ID: --===============6601722467409085966== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-18 09:34:16 -0400 (Mon, 18 Aug 2008) New Revision: 6574 Added: core/trunk/src/test/java/org/jboss/cache/eviction/EvictionTestsBase.java core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionWatcher.= java Modified: core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.java core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguration= Parser.java core/trunk/src/main/java/org/jboss/cache/config/parsing/element/Eviction= ElementParser.java core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.= java core/trunk/src/main/java/org/jboss/cache/eviction/DefaultEvictionActionP= olicy.java core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgorithm.j= ava core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgorithmCo= nfig.java core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeQueue.java core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithmConfi= gBase.java core/trunk/src/main/java/org/jboss/cache/eviction/EvictionQueue.java core/trunk/src/main/java/org/jboss/cache/eviction/EvictionQueueList.java core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithm.ja= va core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithmCon= fig.java core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithmConfig.ja= va core/trunk/src/main/java/org/jboss/cache/eviction/FIFOQueue.java core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithm.java core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithmConfig.java core/trunk/src/main/java/org/jboss/cache/eviction/LFUQueue.java core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithm.java core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithmConfig.java core/trunk/src/main/java/org/jboss/cache/eviction/LRUQueue.java core/trunk/src/main/java/org/jboss/cache/eviction/MRUAlgorithmConfig.java core/trunk/src/main/java/org/jboss/cache/eviction/MRUQueue.java core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionQueue.java core/trunk/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementP= arserTest.java core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTest= .java core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeAlgorithmTe= st.java core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConfigurati= onTest.java core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizePolicyTest.= java core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeQueueTest.j= ava core/trunk/src/test/java/org/jboss/cache/eviction/EvictionConfigurationT= est.java core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.j= ava core/trunk/src/test/java/org/jboss/cache/eviction/FIFOAlgorithmTest.java core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurationTest.= java core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java core/trunk/src/test/java/org/jboss/cache/eviction/LFUAlgorithmTest.java core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfigurationTest.j= ava core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java core/trunk/src/test/java/org/jboss/cache/eviction/LFUQueueTest.java core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.j= ava core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java core/trunk/src/test/java/org/jboss/cache/eviction/MRUAlgorithmTest.java core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.j= ava core/trunk/src/test/java/org/jboss/cache/eviction/MRUPolicyTest.java core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest= .java core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionPolicyTest= .java core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest= .java core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyT= est.java core/trunk/src/test/java/org/jboss/cache/eviction/RegionTest.java core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTes= t.java core/trunk/src/test/java/org/jboss/cache/eviction/minttl/FIFOMinTTLTest.= java core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LFUMinTTLTest.j= ava core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LRUMinTTLTest.j= ava core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MRUMinTTLTest.j= ava core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MinTTLTestBase.= java core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionControll= er.java core/trunk/src/test/resources/configs/string-property-replaced.xml Log: Updated eviction code and tests Modified: core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-08= -18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-08= -18 13:34:16 UTC (rev 6574) @@ -8,7 +8,6 @@ import org.jboss.cache.buddyreplication.BuddyManager; import org.jboss.cache.config.Configuration; import org.jboss.cache.config.ConfigurationException; -import org.jboss.cache.config.EvictionAlgorithmConfig; import org.jboss.cache.config.EvictionConfig; import org.jboss.cache.config.EvictionRegionConfig; import org.jboss.cache.eviction.EvictionTimerTask; @@ -93,20 +92,20 @@ public void start() { if (trace) log.trace("Starting region manager"); - isUsingBR =3D configuration.getBuddyReplicationConfig() !=3D null &&= configuration.getBuddyReplicationConfig().isEnabled(); + isUsingBR =3D configuration !=3D null && configuration.getBuddyRepli= cationConfig() !=3D null && configuration.getBuddyReplicationConfig().isEna= bled(); evictionConfig =3D configuration.getEvictionConfig(); if (evictionConfig !=3D null && evictionConfig.isValidConfig()) { + this.evictionConfig =3D configuration.getEvictionConfig(); // start with the default region EvictionRegionConfig defaultRegion =3D configuration.getEvictionC= onfig().getDefaultEvictionRegionConfig(); - defaultRegion.getEvictionAlgorithmConfig().validate(); + if (defaultRegion.getEvictionAlgorithmConfig() !=3D null) default= Region.getEvictionAlgorithmConfig().validate(); = // validate individual region configs now for (EvictionRegionConfig erc : configuration.getEvictionConfig()= .getEvictionRegionConfigs()) { evictionConfig.applyDefaults(erc); - EvictionAlgorithmConfig eac =3D erc.getEvictionAlgorithmConfig= (); - if (eac !=3D null) eac.validate(); + erc.validate(); } = setEvictionConfig(configuration.getEvictionConfig()); @@ -704,8 +703,6 @@ = public void setEvictionConfig(EvictionConfig evictionConfig) { - this.evictionConfig =3D evictionConfig; - // JBAS-1288 // Try to establish a default region if there isn't one already // boolean needDefault; @@ -714,7 +711,9 @@ // contrary to the idea that there *must* be a default region, but s= ome // unit tests fail w/ APPROACH 1, so for now we go with this approac= h. // needDefault =3D ercs.size() =3D=3D 0; - ercs.add(0, evictionConfig.getDefaultEvictionRegionConfig()); + if (evictionConfig.getDefaultEvictionRegionConfig().getEvictionAlgor= ithmConfig() !=3D null && + !ercs.contains(evictionConfig.getDefaultEvictionRegionConfig()= )) // then the default is a real region too; not just a template for others + ercs.add(0, evictionConfig.getDefaultEvictionRegionConfig()); // if (needDefault) // { // // This may throw ConfigurationException if there is no default Modified: core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.ja= va =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java 200= 8-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java 200= 8-08-18 13:34:16 UTC (rev 6574) @@ -246,7 +246,9 @@ if (evictionRegionConfigs !=3D null) { // needs to be a deep copy - for (EvictionRegionConfig erc : evictionRegionConfigs) clone.addE= victionRegionConfig(erc.clone()); + clone.evictionRegionConfigs =3D new LinkedList(); + for (EvictionRegionConfig erc : evictionRegionConfigs) + clone.addEvictionRegionConfig(erc.clone()); } return clone; } Modified: core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionCon= fig.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.ja= va 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.ja= va 2008-08-18 13:34:16 UTC (rev 6574) @@ -78,6 +78,13 @@ this.evictionAlgorithmConfig =3D evictionAlgorithmConfig; } = + public EvictionRegionConfig(Fqn regionFqn, EvictionAlgorithmConfig evic= tionAlgorithmConfig, int queueSize) + { + this.regionFqn =3D regionFqn; + this.evictionAlgorithmConfig =3D evictionAlgorithmConfig; + this.eventQueueSize =3D queueSize; + } + public EvictionRegionConfig(Fqn fqn) { this.regionFqn =3D fqn; @@ -284,4 +291,18 @@ { if (this.eventQueueSize =3D=3D null) this.eventQueueSize =3D eventQu= eueSize; } + + /** + * Ensure this is a valid eviction region configuration. + */ + public void validate() + { + if (eventQueueSize < 1) + throw new ConfigurationException("Eviction event queue size canno= t be less than 1!"); + + if (evictionAlgorithmConfig =3D=3D null) + throw new MissingPolicyException("Eviction algorithm configuratio= n cannot be null!"); + + evictionAlgorithmConfig.validate(); + } } \ No newline at end of file Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfig= urationParser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParser.java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParser.java 2008-08-18 13:34:16 UTC (rev 6574) @@ -176,7 +176,7 @@ throw new OldFileFormatException(); } = - if (! "jbosscache".equals(root.getLocalName()) || ! JBOSSCACHE_CO= RE_NS.equals(root.getNamespaceURI())) + if (!"jbosscache".equals(root.getLocalName()) || !JBOSSCACHE_CORE= _NS.equals(root.getNamespaceURI())) throw new ConfigurationException("Expected root element {" + J= BOSSCACHE_CORE_NS + "}" + "jbosscache"); } = @@ -200,7 +200,7 @@ } catch (Exception e) { - throw new ConfigurationException("Unexpected excetion while parsi= ng the configuration file", e); + throw new ConfigurationException("Unexpected exception while pars= ing the configuration file", e); } return config; } Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/E= victionElementParser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/element/Evictio= nElementParser.java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/Evictio= nElementParser.java 2008-08-18 13:34:16 UTC (rev 6574) @@ -146,7 +146,7 @@ = if (eac !=3D null) { - parseEvictionPolicyConfig(element, eac, defaultRegion !=3D null); + parseEvictionPolicyConfig(element, eac); = erc.setEvictionAlgorithmConfig(eac); } @@ -166,12 +166,11 @@ return erc; } = - public static void parseEvictionPolicyConfig(Element element, EvictionA= lgorithmConfig target, boolean validate) + public static void parseEvictionPolicyConfig(Element element, EvictionA= lgorithmConfig target) { target.reset(); ParsedAttributes attributes =3D XmlConfigHelper.extractAttributes(el= ement); XmlConfigHelper.setValues(target, attributes.stringAttribs, false, t= rue); XmlConfigHelper.setValues(target, attributes.xmlAttribs, true, true); - if (validate) target.validate(); } } Modified: core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlg= orithm.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm= .java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm= .java 2008-08-18 13:34:16 UTC (rev 6574) @@ -71,13 +71,16 @@ recycleQueue =3D new LinkedBlockingQueue(500000); } = - public void initialize() + public synchronized void initialize() { - evictionQueue =3D setupEvictionQueue(); - if (log.isDebugEnabled()) log.debug("Initialized: " + this); - Configuration.CacheMode cm =3D configuration !=3D null ? configurati= on.getCacheMode() : Configuration.CacheMode.LOCAL; - allowTombstones =3D configuration !=3D null && configuration.getNode= LockingScheme() =3D=3D NodeLockingScheme.OPTIMISTIC && - (cm =3D=3D Configuration.CacheMode.INVALIDATION_ASYNC || cm = =3D=3D Configuration.CacheMode.INVALIDATION_SYNC); + if (evictionQueue =3D=3D null) + { + evictionQueue =3D setupEvictionQueue(); + if (log.isDebugEnabled()) log.debug("Initialized: " + this); + Configuration.CacheMode cm =3D configuration !=3D null ? configur= ation.getCacheMode() : Configuration.CacheMode.LOCAL; + allowTombstones =3D configuration !=3D null && configuration.getN= odeLockingScheme() =3D=3D NodeLockingScheme.OPTIMISTIC && + (cm =3D=3D Configuration.CacheMode.INVALIDATION_ASYNC || cm= =3D=3D Configuration.CacheMode.INVALIDATION_SYNC); + } } = public EvictionActionPolicy getEvictionActionPolicy() @@ -121,6 +124,7 @@ public void process(BlockingQueue eventQueue) throws Evi= ctionException { if (trace) log.trace("process(): region: " + regionFqn); + initialize(); this.processQueues(eventQueue); this.emptyRecycleQueue(); this.prune(); Modified: core/trunk/src/main/java/org/jboss/cache/eviction/DefaultEviction= ActionPolicy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/DefaultEvictionAction= Policy.java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/eviction/DefaultEvictionAction= Policy.java 2008-08-18 13:34:16 UTC (rev 6574) @@ -25,6 +25,7 @@ { try { + if (log.isTraceEnabled()) log.trace("Evicting Fqn " + fqn); cache.evict(fqn); return true; } Modified: core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgo= rithm.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgorithm.= java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgorithm.= java 2008-08-18 13:34:16 UTC (rev 6574) @@ -28,7 +28,7 @@ if (isYoungerThanMinimumTimeToLive(ne)) return false; int size =3D this.getEvictionQueue().getNumberOfNodes(); ElementSizeAlgorithmConfig config =3D (ElementSizeAlgorithmConfig) e= victionAlgorithmConfig; - return config.getMaxNodes() !=3D 0 && size > config.getMaxNodes() ||= ne.getNumberOfElements() > config.getMaxElementsPerNode(); + return config.getMaxNodes() > -1 && size > config.getMaxNodes() || n= e.getNumberOfElements() > config.getMaxElementsPerNode(); } = @Override Modified: core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgo= rithmConfig.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgorithmC= onfig.java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgorithmC= onfig.java 2008-08-18 13:34:16 UTC (rev 6574) @@ -59,6 +59,7 @@ @Override public void validate() throws ConfigurationException { + super.validate(); if (maxElementsPerNode < 0) { throw new ConfigurationException("maxElementsPerNode must be must= be " + @@ -100,6 +101,7 @@ { super.reset(); setMaxElementsPerNode(-1); + evictionAlgorithmClassName =3D ElementSizeAlgorithm.class.getName(); } = @Override Modified: core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeQueu= e.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeQueue.java= 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeQueue.java= 2008-08-18 13:34:16 UTC (rev 6574) @@ -8,7 +8,16 @@ = import org.jboss.cache.Fqn; = -import java.util.*; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; = /** * @author Daniel Huang @@ -154,7 +163,7 @@ } } = - public Iterator iterate() + public Iterator iterator() { return evictionList.iterator(); } Modified: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorit= hmConfigBase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithmConf= igBase.java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithmConf= igBase.java 2008-08-18 13:34:16 UTC (rev 6574) @@ -71,7 +71,8 @@ = public void validate() throws ConfigurationException { - // no-op + if (evictionAlgorithmClassName =3D=3D null) + throw new ConfigurationException("Eviction algorithm class name c= annot be null!"); } = public boolean equals(Object o) Modified: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionQueue.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionQueue.java 20= 08-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionQueue.java 20= 08-08-18 13:34:16 UTC (rev 6574) @@ -8,9 +8,7 @@ = import org.jboss.cache.Fqn; = -import java.util.Iterator; = - /** * Eviction Queue interface defines a contract for the Eviction Queue impl= ementations used by EvictionPolicies. *

    @@ -20,7 +18,7 @@ * @author Daniel Huang (dhuang(a)jboss.org) * @version $Revision$ */ -public interface EvictionQueue +public interface EvictionQueue extends Iterable { /** * Get the first entry in the queue. @@ -85,8 +83,6 @@ = void modifyElementCount(int difference); = - Iterator iterate(); - /** * Clear the queue. */ Modified: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionQueueLi= st.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionQueueList.jav= a 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionQueueList.jav= a 2008-08-18 13:34:16 UTC (rev 6574) @@ -134,7 +134,7 @@ return tail; } = - Iterator iterator() + Iterator iterator() { return new EvictionListIterator(); } @@ -231,7 +231,7 @@ } } = - class EvictionListIterator implements ListIterator + class EvictionListIterator implements ListIterator { EvictionListEntry next =3D head; EvictionListEntry previous; @@ -245,7 +245,7 @@ return next !=3D null; } = - public Object next() + public NodeEntry next() { this.doConcurrentModCheck(); this.forwardCursor(); @@ -258,7 +258,7 @@ return previous !=3D null; } = - public Object previous() + public NodeEntry previous() { this.doConcurrentModCheck(); this.rewindCursor(); @@ -287,13 +287,13 @@ initialModCount++; } = - public void set(Object o) + public void set(NodeEntry o) { this.doConcurrentModCheck(); cursor.node =3D (NodeEntry) o; } = - public void add(Object o) + public void add(NodeEntry o) { this.doConcurrentModCheck(); initialModCount++; Modified: core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgor= ithm.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithm.j= ava 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithm.j= ava 2008-08-18 13:34:16 UTC (rev 6574) @@ -338,7 +338,7 @@ return set.size(); } = - public Iterator iterate() + public Iterator iterator() { return null; } Modified: core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgor= ithmConfig.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithmCo= nfig.java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithmCo= nfig.java 2008-08-18 13:34:16 UTC (rev 6574) @@ -120,4 +120,13 @@ result =3D 31 * result + (int) (timeToLive ^ (timeToLive >>> 32)); return result; } + + @Override + public void reset() + { + super.reset(); + evictionAlgorithmClassName =3D ExpirationAlgorithm.class.getName(); + warnNoExpirationKey =3D true; + timeToLive =3D 0; + } } \ No newline at end of file Modified: core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithmCo= nfig.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithmConfig.j= ava 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithmConfig.j= ava 2008-08-18 13:34:16 UTC (rev 6574) @@ -44,6 +44,7 @@ @Override public void validate() throws ConfigurationException { + super.validate(); if (getMaxNodes() < 0) { throw new ConfigurationException("maxNodes must be must be " + @@ -68,7 +69,9 @@ @Override public void reset() { + super.reset(); setMaxNodes(-1); + evictionAlgorithmClassName =3D FIFOAlgorithm.class.getName(); } = @Override Modified: core/trunk/src/main/java/org/jboss/cache/eviction/FIFOQueue.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/FIFOQueue.java 2008-0= 8-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/eviction/FIFOQueue.java 2008-0= 8-18 13:34:16 UTC (rev 6574) @@ -101,7 +101,7 @@ this.numElements =3D 0; } = - public Iterator iterate() + public Iterator iterator() { return nodeMap.values().iterator(); } Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithm.ja= va =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithm.java 200= 8-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithm.java 200= 8-08-18 13:34:16 UTC (rev 6574) @@ -51,7 +51,7 @@ = LFUAlgorithmConfig config =3D (LFUAlgorithmConfig) evictionAlgorithm= Config; int size =3D this.getEvictionQueue().getNumberOfNodes(); - if (config.getMaxNodes() !=3D 0 && size > config.getMaxNodes()) + if (config.getMaxNodes() > -1 && size > config.getMaxNodes()) { return true; } Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithmCon= fig.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithmConfig.ja= va 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithmConfig.ja= va 2008-08-18 13:34:16 UTC (rev 6574) @@ -78,4 +78,12 @@ { return (LFUAlgorithmConfig) super.clone(); } + + @Override + public void reset() + { + super.reset(); + minNodes =3D -1; + evictionAlgorithmClassName =3D LFUAlgorithm.class.getName(); + } } \ No newline at end of file Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LFUQueue.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/LFUQueue.java 2008-08= -18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/eviction/LFUQueue.java 2008-08= -18 13:34:16 UTC (rev 6574) @@ -8,7 +8,16 @@ = import org.jboss.cache.Fqn; = -import java.util.*; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; = /** * LFUQueue EvictionQueue implementation for LFU Policy. @@ -143,7 +152,7 @@ = protected void prune() { - Iterator it =3D this.iterate(); + Iterator it =3D this.iterator(); while (it.hasNext() && removalQueue.size() > 0) { if (removalQueue.remove(it.next())) @@ -163,7 +172,7 @@ return this.removalQueue; } = - public Iterator iterate() + public Iterator iterator() { return evictionList.iterator(); } Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithm.ja= va =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithm.java 200= 8-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithm.java 200= 8-08-18 13:34:16 UTC (rev 6574) @@ -40,10 +40,10 @@ = LRUAlgorithmConfig config =3D (LRUAlgorithmConfig) evictionAlgorithm= Config; // no idle or max time limit - if (config.getTimeToLive() =3D=3D 0 && config.getMaxAge() =3D=3D 0) = return false; + if (config.getTimeToLive() < 0 && config.getMaxAge() < 0) return fal= se; = long currentTime =3D System.currentTimeMillis(); - if (config.getTimeToLive() !=3D 0) + if (config.getTimeToLive() > -1) { long idleTime =3D currentTime - entry.getModifiedTimeStamp(); if (trace) @@ -62,7 +62,7 @@ } } = - if (config.getMaxAge() !=3D 0) + if (config.getMaxAge() > -1) { long objectLifeTime =3D currentTime - entry.getCreationTimeStamp(= ); if (trace) Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithmCon= fig.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithmConfig.ja= va 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithmConfig.ja= va 2008-08-18 13:34:16 UTC (rev 6574) @@ -42,6 +42,7 @@ evictionAlgorithmClassName =3D LRUAlgorithm.class.getName(); // Force config of ttls setTimeToLive(-1); + setMaxAge(-1); } = public LRUAlgorithmConfig(long timeToLive, long maxAge) @@ -51,7 +52,7 @@ this.maxAge =3D maxAge; } = - public LRUAlgorithmConfig(int timeToLive, int maxAge, int maxNodes) + public LRUAlgorithmConfig(long timeToLive, int maxAge, int maxNodes) { this(timeToLive, maxAge); this.maxNodes =3D maxNodes; @@ -114,16 +115,18 @@ @Override public void validate() throws ConfigurationException { - if (timeToLive < 0) + super.validate(); + if (timeToLive < -1) { throw new ConfigurationException("timeToLive must be " + - "configured to a value greater than or equal to 0 for " + g= etEvictionAlgorithmClassName()); + "configured to a value greater than or equal to 0 (or -1 fo= r unlimited time to live) for " + getEvictionAlgorithmClassName()); } } = public String toString() { return "LRUAlgorithmConfig {" + + "algorithmClassName=3D" + evictionAlgorithmClassName + ", timeToLive=3D" + timeToLive + ", maxAge=3D" + maxAge + '}'; @@ -156,6 +159,8 @@ { super.reset(); setTimeToLive(-1); + setMaxAge(-1); + evictionAlgorithmClassName =3D LRUAlgorithm.class.getName(); } = @Override Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LRUQueue.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/LRUQueue.java 2008-08= -18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/eviction/LRUQueue.java 2008-08= -18 13:34:16 UTC (rev 6574) @@ -170,7 +170,7 @@ this.numElements +=3D difference; } = - public Iterator iterate() + public Iterator iterator() { return lruQueue.values().iterator(); } Modified: core/trunk/src/main/java/org/jboss/cache/eviction/MRUAlgorithmCon= fig.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/MRUAlgorithmConfig.ja= va 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/eviction/MRUAlgorithmConfig.ja= va 2008-08-18 13:34:16 UTC (rev 6574) @@ -43,6 +43,7 @@ @Override public void validate() throws ConfigurationException { + super.validate(); if (getMaxNodes() < 0) throw new ConfigurationException("maxNodes not configured"); } @@ -65,7 +66,9 @@ @Override public void reset() { + super.reset(); setMaxNodes(-1); + evictionAlgorithmClassName =3D MRUAlgorithm.class.getName(); } = @Override Modified: core/trunk/src/main/java/org/jboss/cache/eviction/MRUQueue.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/MRUQueue.java 2008-08= -18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/eviction/MRUQueue.java 2008-08= -18 13:34:16 UTC (rev 6574) @@ -141,7 +141,7 @@ this.numElements =3D 0; } = - public Iterator iterate() + public Iterator iterator() { return list.iterator(); } Modified: core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionQue= ue.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionQueue.jav= a 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionQueue.jav= a 2008-08-18 13:34:16 UTC (rev 6574) @@ -1,23 +1,25 @@ /** - * = + * */ package org.jboss.cache.eviction; = +import org.jboss.cache.Fqn; + import java.util.Iterator; import java.util.NoSuchElementException; = -import org.jboss.cache.Fqn; - /** * A queue that does nothing. - * = + * * @author Brian Stansberry */ public class NullEvictionQueue implements EvictionQueue { - /** Singleton instance of this class. */ + /** + * Singleton instance of this class. + */ public static final NullEvictionQueue INSTANCE =3D new NullEvictionQueu= e(); - = + /** * Constructs a new NullEvictionQueue. */ @@ -25,87 +27,109 @@ { } = - /** No-op */ + /** + * No-op + */ public void addNodeEntry(NodeEntry entry) { // no-op } = - /** No-op */ + /** + * No-op + */ public void clear() { // no-op } = - /** Returns false */ + /** + * Returns false + */ public boolean containsNodeEntry(NodeEntry entry) { return false; } = - /** Returns null */ + /** + * Returns null + */ public NodeEntry getFirstNodeEntry() { return null; } = - /** Returns null */ + /** + * Returns null + */ public NodeEntry getNodeEntry(Fqn fqn) { return null; } = - /** Returns null */ + /** + * Returns null + */ public NodeEntry getNodeEntry(String fqn) { return null; } = - /** Returns 0 */ + /** + * Returns 0 + */ public int getNumberOfElements() { return 0; } = - /** Returns 0 */ + /** + * Returns 0 + */ public int getNumberOfNodes() { return 0; } = - /** = + /** * Returns an Iterator whose * hasNext() returns false. */ - public Iterator iterate() + public Iterator iterator() { return NullQueueIterator.INSTANCE; } = - /** No-op */ + /** + * No-op + */ public void modifyElementCount(int difference) { // no-op } = - /** No-op */ + /** + * No-op + */ public void removeNodeEntry(NodeEntry entry) { // no-op } - = - static class NullQueueIterator implements Iterator + + static class NullQueueIterator implements Iterator { private static final NullQueueIterator INSTANCE =3D new NullQueueIte= rator(); = - private NullQueueIterator() {} - = + private NullQueueIterator() + { + } + public boolean hasNext() { return false; } = - public Object next() + public NodeEntry next() { throw new NoSuchElementException("No more elements"); } Modified: core/trunk/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java 2008-0= 8-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java 2008-0= 8-18 13:34:16 UTC (rev 6574) @@ -27,16 +27,23 @@ import org.jboss.cache.jmx.annotations.ManagedAttribute; import org.jboss.cache.jmx.annotations.ManagedOperation; = -import javax.management.*; +import javax.management.Attribute; +import javax.management.AttributeList; +import javax.management.DynamicMBean; +import javax.management.MBeanAttributeInfo; +import javax.management.MBeanException; +import javax.management.MBeanInfo; +import javax.management.MBeanOperationInfo; +import javax.management.ReflectionException; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; -import java.util.ArrayList; -import java.util.Arrays; +import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.regex.Matcher; -import java.lang.reflect.Method; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; = /** * This class was entirely copied from jgroups (same name there). @@ -49,13 +56,13 @@ public class ResourceDMBean implements DynamicMBean { private static final Class[] primitives =3D {int.class, - byte.class, - short.class, - long.class, - float.class, - double.class, - boolean.class, - char.class}; + byte.class, + short.class, + long.class, + float.class, + double.class, + boolean.class, + char.class}; = private static final String MBEAN_DESCRITION =3D "Dynamic MBean Descrip= tion"; = @@ -82,35 +89,43 @@ = attrInfo =3D new MBeanAttributeInfo[atts.size()]; int i =3D 0; - log.info("Processing class " + instance.getClass()); - log.info("Attributes are:"); - MBeanAttributeInfo info =3D null; + if (log.isInfoEnabled()) + { + log.info("Processing class " + instance.getClass()); + log.info("Number of attributes: " + atts.size()); + } + MBeanAttributeInfo info; for (AttributeEntry entry : atts.values()) { info =3D entry.getInfo(); attrInfo[i++] =3D info; - log.info("Attribute " + info.getName() - + "[r=3D" - + info.isReadable() - + ",w=3D" - + info.isWritable() - + ",is=3D" - + info.isIs() - + ",type=3D" - + info.getType() - + "]"); + if (log.isInfoEnabled()) + { + log.info("Attribute " + info.getName() + + "[r=3D" + + info.isReadable() + + ",w=3D" + + info.isWritable() + + ",is=3D" + + info.isIs() + + ",type=3D" + + info.getType() + + "]"); + } } = opInfo =3D new MBeanOperationInfo[ops.size()]; ops.toArray(opInfo); = - if (ops.size() > 0) - log.info("Operations are:"); - for (MBeanOperationInfo op : opInfo) + if (log.isInfoEnabled()) { - log.info("Operation " + op.getReturnType() + " " + op.getName()); + if (ops.size() > 0) + log.info("Operations are:"); + for (MBeanOperationInfo op : opInfo) + { + log.info("Operation " + op.getReturnType() + " " + op.getName(= )); + } } - } = Object getObject() Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionE= lementParserTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElement= ParserTest.java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElement= ParserTest.java 2008-08-18 13:34:16 UTC (rev 6574) @@ -34,13 +34,16 @@ { String xml =3D " \n" + - " \n" + + " \n" + + " 10\= n" + + " 10\n" + + " \n" + " \n" + " 2103\n" + " 22\n" + " \n" + " "; - EvictionConfig evictionConfig =3D getEvictionConfig(xml); + EvictionConfig evictionConfig =3D getEvictionConfig(xml, false); assert evictionConfig.getDefaultEvictionRegionConfig().getEventQueue= Size() =3D=3D EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT; assert evictionConfig.getDefaultEvictionRegionConfig().getEvictionAc= tionPolicyClassName().equals(DefaultEvictionActionPolicy.class.getName()); } @@ -59,7 +62,7 @@ " "; try { - EvictionConfig config =3D getEvictionConfig(xml); + EvictionConfig config =3D getEvictionConfig(xml, false); assert false : "Should throw ConfigurationException!"; } catch (ConfigurationException good) @@ -89,7 +92,7 @@ " 22\n" + " \n" + " "; - EvictionConfig config =3D getEvictionConfig(xml); + EvictionConfig config =3D getEvictionConfig(xml, false); //tests the defaults assert config.getWakeupInterval() =3D=3D 5; assert config.getDefaultEvictionRegionConfig().getEvictionAlgorithmC= onfig() instanceof MRUAlgorithmConfig; @@ -144,7 +147,7 @@ " 1000000\n" + " \n" + " "; - EvictionConfig evConfig =3D getEvictionConfig(xml); + EvictionConfig evConfig =3D getEvictionConfig(xml, false); EvictionRegionConfig evictionRegionConfig =3D evConfig.getDefaultEvi= ctionRegionConfig(); assert evictionRegionConfig.getRegionName().equals(Fqn.ROOT.toString= ()) : "Was " + evictionRegionConfig.getRegionName(); assert ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorit= hmConfig()).getTimeToLive() =3D=3D 1000000; @@ -169,7 +172,7 @@ " "; try { - getEvictionConfig(xml); + getEvictionConfig(xml, false); assert false : "exception expected as wake up interval is not set= "; } catch (ConfigurationException e) @@ -192,7 +195,7 @@ " "; try { - getEvictionConfig(xml); + getEvictionConfig(xml, false); assert false : "missing policy in both default and region, except= ion expected."; } catch (MissingPolicyException e) @@ -212,12 +215,12 @@ " 1002\n" + " \n" + " "; - EvictionConfig ec =3D getEvictionConfig(xml); + EvictionConfig ec =3D getEvictionConfig(xml, false); assert ec.getEvictionRegionConfigs().get(0).getEventQueueSize() =3D= =3D EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT; } = = - private EvictionConfig getEvictionConfig(String xml) + private EvictionConfig getEvictionConfig(String xml, boolean validate) { Element el; try @@ -228,7 +231,13 @@ { throw new ConfigurationException(e); } - return parser.parseEvictionElement(el); + EvictionConfig cfg =3D parser.parseEvictionElement(el); + if (validate) + { + cfg.getDefaultEvictionRegionConfig().validate(); + for (EvictionRegionConfig erc : cfg.getEvictionRegionConfigs()) e= rc.validate(); + } + return cfg; } = public void testMissingDefaultEvictionClass() throws Exception @@ -246,7 +255,7 @@ " "; try { - getEvictionConfig(xml); + getEvictionConfig(xml, true); assert false : " exception expected as default element does not h= ave a eviction policy defined"; } catch (MissingPolicyException e) @@ -268,7 +277,7 @@ " \n" + " \n" + " "; - EvictionConfig config =3D getEvictionConfig(xml); + EvictionConfig config =3D getEvictionConfig(xml, false); = // default region assert config.getDefaultEvictionRegionConfig().getEvictionAlgorithmC= onfig() instanceof NullEvictionAlgorithmConfig; Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvict= ionTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTes= t.java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTes= t.java 2008-08-18 13:34:16 UTC (rev 6574) @@ -90,7 +90,7 @@ Fqn.ROOT, new LRUAlgorithmConfig(1000000, 5000) ), - 5000); + 200); } = @AfterMethod(alwaysRun =3D true) @@ -119,9 +119,8 @@ for (int i =3D 0; i < 1000; i++) { Fqn fqn =3D Fqn.fromRelativeElements(base, i / 100); - Integer key =3D i; - assertNotNull("found value under Fqn " + fqn + " and key " + k= ey, - cache.get(fqn, key)); + assertNotNull("found value under Fqn " + fqn + " and key " + i, + cache.get(fqn, i)); } } } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeAlgo= rithmTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeAlgorithmT= est.java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeAlgorithmT= est.java 2008-08-18 13:34:16 UTC (rev 6574) @@ -1,24 +1,19 @@ package org.jboss.cache.eviction; = import org.jboss.cache.Fqn; -import org.jboss.cache.Region; import org.jboss.cache.RegionImpl; import org.jboss.cache.RegionManager; import org.jboss.cache.RegionManagerImpl; -import org.jboss.cache.RegionRegistry; -import org.jboss.cache.config.EvictionRegionConfig; import static org.testng.AssertJUnit.assertEquals; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = -import java.util.Iterator; - /** * @author Daniel Huang * @version $Revision$ */ @Test(groups =3D {"functional"}) -public class ElementSizeAlgorithmTest +public class ElementSizeAlgorithmTest extends EvictionTestsBase { RegionManager regionManager; ElementSizeAlgorithm algo; @@ -26,15 +21,10 @@ @BeforeMethod(alwaysRun =3D true) public void setUp() throws Exception { - algo =3D new ElementSizeAlgorithm(); regionManager =3D new RegionManagerImpl(); - ((RegionManagerImpl) regionManager).injectDependencies(null, null, n= ull, null, null, new RegionRegistry()); ElementSizeAlgorithmConfig config =3D new ElementSizeAlgorithmConfig= (); - // We have to setCache maxElementsPerNode!! config.setMaxElementsPerNode(0); -// config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName()); - Region r =3D regionManager.getRegion("/a/b", true); - r.setEvictionRegionConfig(new EvictionRegionConfig(r.getFqn(), confi= g)); + algo =3D (ElementSizeAlgorithm) createAndAssignToRegion("/a/b", regi= onManager, config); } = public void testMaxElements() throws Exception @@ -63,11 +53,9 @@ assertEquals(9, algo.getEvictionQueue().getNumberOfNodes()); assertEquals(12, algo.getEvictionQueue().getNumberOfElements()); // now verify the order. - Iterator it =3D queue.iterate(); int count =3D 6; - while (it.hasNext()) + for (NodeEntry ne : queue) { - NodeEntry ne =3D (NodeEntry) it.next(); System.out.println(ne); = if (count > 0) @@ -117,11 +105,9 @@ assertEquals(45, algo.getEvictionQueue().getNumberOfElements()); = // now verify the order. - Iterator it =3D queue.iterate(); int num =3D 9; - while (it.hasNext()) + for (NodeEntry ne : queue) { - NodeEntry ne =3D (NodeEntry) it.next(); assertEquals(num, ne.getNumberOfElements()); num--; } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConf= igurationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConfigurat= ionTest.java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConfigurat= ionTest.java 2008-08-18 13:34:16 UTC (rev 6574) @@ -29,7 +29,8 @@ ""; = Element element =3D XmlConfigHelper.stringToElementInCoreNS(xml); - EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); + EvictionElementParser.parseEvictionPolicyConfig(element, config); + config.validate(); = assertEquals(100, config.getMaxElementsPerNode()); assertEquals(1000, config.getMaxNodes()); @@ -46,7 +47,8 @@ Element element =3D XmlConfigHelper.stringToElementInCoreNS(xml); try { - EvictionElementParser.parseEvictionPolicyConfig(element, config, = true); + EvictionElementParser.parseEvictionPolicyConfig(element, config); + config.validate(); } catch (ConfigurationException ce) { @@ -67,7 +69,8 @@ = Element element =3D XmlConfigHelper.stringToElementInCoreNS(xml); = - EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); + EvictionElementParser.parseEvictionPolicyConfig(element, config); + config.validate(); = assertEquals(100, config.getMaxElementsPerNode()); assertEquals(0, config.getMaxNodes()); Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizePoli= cyTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizePolicyTest= .java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizePolicyTest= .java 2008-08-18 13:34:16 UTC (rev 6574) @@ -17,17 +17,23 @@ import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; import org.jboss.cache.lock.IsolationLevel; import org.jboss.cache.transaction.DummyTransactionManagerLookup; +import org.jboss.cache.util.TestingUtil; +import org.jboss.cache.util.internals.EvictionWatcher; import static org.testng.AssertJUnit.*; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + /** * @author Daniel Huang * @version $Revison: $ */ @Test(groups =3D {"functional"}) -public class ElementSizePolicyTest +public class ElementSizePolicyTest extends EvictionTestsBase { CacheSPI cache; long wakeupIntervalMillis =3D 0; @@ -41,7 +47,6 @@ { initCaches(); wakeupIntervalMillis =3D cache.getConfiguration().getEvictionConfig(= ).getWakeupInterval(); - log("wakeupInterval is " + wakeupIntervalMillis); if (wakeupIntervalMillis < 0) { fail("testEviction(): eviction thread wake up interval is illegal= " + wakeupIntervalMillis); @@ -54,8 +59,7 @@ void initCaches() throws Exception { Configuration conf =3D UnitTestCacheConfigurationFactory.createConfi= guration(Configuration.CacheMode.LOCAL, true); - EvictionConfig evConfig =3D new EvictionConfig(new EvictionRegionCon= fig(Fqn.ROOT, new ElementSizeAlgorithmConfig(5000, 100)), 3000); - evConfig.setDefaultEventQueueSize(200000); + EvictionConfig evConfig =3D new EvictionConfig(new EvictionRegionCon= fig(Fqn.ROOT, new ElementSizeAlgorithmConfig(5000, 100), 200000), 200); evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromSt= ring("/org/jboss/data"), new ElementSizeAlgorithmConfig(10, 20))); evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromSt= ring("/org/jboss/test/data"), new ElementSizeAlgorithmConfig(-1, 5))); evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromSt= ring("/test/"), new ElementSizeAlgorithmConfig(5000, 1))); @@ -98,13 +102,15 @@ } = System.out.println(cache); - _sleep(wakeupIntervalMillis + 500); + assert waitForEviction(cache, 30, TimeUnit.SECONDS, Fqn.fromString("= /org/jboss/test/data/8")) : "Eviction event not received!"; + TestingUtil.sleepThread(200); // small grace period System.out.println(cache); = for (int i =3D 0; i < 10; i++) { - Node node =3D cache.getNode("/org/jboss/test/data/" + Integer.toS= tring(i)); - System.out.println(node); + String f =3D "/org/jboss/test/data/" + i; + Node node =3D cache.getNode(f); + System.out.println("Node for " + f + " is " + node); if (i % 2 =3D=3D 0) { if (i < 6) @@ -126,6 +132,10 @@ = public void testEviction2() throws Exception { + List fqnsThatShouldBeEvicted =3D new ArrayList(); + for (int i =3D 10; i < 20; i++) fqnsThatShouldBeEvicted.add(Fqn.from= String("/org/jboss/data/" + i)); + + EvictionWatcher watcher =3D new EvictionWatcher(cache, fqnsThatShoul= dBeEvicted); String rootStr =3D "/org/jboss/data/"; for (int i =3D 0; i < 20; i++) { @@ -138,7 +148,7 @@ } } = - _sleep(wakeupIntervalMillis + 500); + assert watcher.waitForEviction(30, TimeUnit.SECONDS) : "Eviction eve= nts never received!"; = for (int i =3D 0; i < 20; i++) { @@ -158,14 +168,16 @@ = for (int i =3D 0; i < 17; i++) { - cache.put("/org/jboss/data/" + Integer.toString(3), 100 + i, "val= ue"); + cache.put("/org/jboss/data/3", 100 + i, "value"); } = - Node node =3D cache.getNode("/org/jboss/data/" + Integer.toString(3)= ); + Node node =3D cache.getNode("/org/jboss/data/3"); assertEquals(21, node.getData().size()); - _sleep(wakeupIntervalMillis + 500); = - assertNull(cache.getNode("/org/jboss/data/" + Integer.toString(3))); + assert waitForEviction(cache, 30, TimeUnit.SECONDS, Fqn.fromString("= /org/jboss/data/3")) : "Eviction event not received!"; + TestingUtil.sleepThread(200); // small grace period + + assertNull(cache.getNode("/org/jboss/data/3")); } = class MyPutter extends Thread @@ -184,7 +196,6 @@ try { cache.put(myName + i++, "value", i); - sleep(1); } catch (Throwable e) { @@ -197,54 +208,4 @@ } } } - - - public void testConcurrentPutAndEvict() throws Exception - { - cache.stop(); - cache.destroy(); - cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE= _READ); - - cache.start(); - cache.put(ROOT_STR + "/concurrentPutAndEvict", "value", 1); - - for (int i =3D 0; i < 10; i++) - { - new MyPutter("Putter" + i).start(); - } - - int counter =3D 0; - while (true) - { - counter++; - if (t1_ex !=3D null) - { - fail("Exception generated in put() " + t1_ex); - } - log("nodes/locks: " + cache.getNumberOfNodes() + "/" + cache.getN= umberOfLocksHeld()); - _sleep(1000); - if (counter > 10) - {// run for 10 seconds - isTrue =3D false; - break; - } - } - } - - private void _sleep(long msecs) - { - try - { - Thread.sleep(msecs); - } - catch (InterruptedException e) - { - e.printStackTrace();//To change body of catch statement use File = | Settings | File Templates. - } - } - - private void log(String msg) - { - System.out.println("-- " + msg); - } } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeQueu= eTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeQueueTest.= java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeQueueTest.= java 2008-08-18 13:34:16 UTC (rev 6574) @@ -6,20 +6,14 @@ */ package org.jboss.cache.eviction; = -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; = -import java.util.Iterator; import java.util.List; import java.util.Set; = -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; = - /** * @author Daniel Huang * @version $Revision$ @@ -38,11 +32,9 @@ = public void testQueue() throws Exception { - NodeEntry ne; for (int i =3D 0; i < 500; i++) { - ne =3D new NodeEntry("/a/b/c/" + Integer.toString(i)); - queue.addNodeEntry(ne); + queue.addNodeEntry(new NodeEntry("/a/b/c/" + Integer.toString(i))= ); } = queue.resortEvictionQueue(); @@ -54,11 +46,9 @@ assertEquals("/a/b/c/275", ne275.getFqn().toString()); = // now make sure the ordering is correct. - Iterator it =3D queue.iterate(); int k =3D 0; - while (it.hasNext()) + for (NodeEntry ne : queue) { - ne =3D (NodeEntry) it.next(); assertEquals("/a/b/c/" + Integer.toString(k), ne.getFqn().toStrin= g()); if (k % 2 =3D=3D 0) { @@ -70,20 +60,19 @@ queue.resortEvictionQueue(); = k =3D 0; - while (it.hasNext()) + for (NodeEntry ne : queue) { - ne =3D (NodeEntry) it.next(); System.out.println(ne.toString()); + + // the first 250 elements should have (250 - 1 - n) * 2 elements.= The rest should have 0 elements. + int expectedElements =3D 0; if (k < 250) { - assertEquals(k, ne.getNumberOfElements()); - assertEquals(0, k % 2); + expectedElements =3D (250 - 1 - k) * 2; } - else - { - assertTrue(k % 2 !=3D 0); - assertEquals(0, ne.getNumberOfElements()); - } + + assertEquals("k is " + k, expectedElements, ne.getNumberOfElement= s()); + k++; } } @@ -95,12 +84,9 @@ queue.addNodeEntry(new NodeEntry("/a/b/c/" + Integer.toString(i))= ); } = - NodeEntry ne; - Iterator it =3D queue.iterate(); int i =3D 0; - while (it.hasNext()) + for (NodeEntry ne : queue) { - ne =3D (NodeEntry) it.next(); if (i % 2 =3D=3D 0) { queue.removeNodeEntry(ne); @@ -110,15 +96,13 @@ = assertEquals(2500, queue.getNumberOfNodes()); = - Set removalQueue =3D queue.getRemovalQueue(); - List evictionList =3D queue.getEvictionList(); + Set removalQueue =3D queue.getRemovalQueue(); + List evictionList =3D queue.getEvictionList(); = assertEquals(2500, removalQueue.size()); = - it =3D removalQueue.iterator(); - while (it.hasNext()) + for (NodeEntry ne : removalQueue) { - ne =3D (NodeEntry) it.next(); int currentIndex =3D Integer.parseInt((String) ne.getFqn().get(3)= ); assertEquals(0, currentIndex % 2); = Modified: core/trunk/src/test/java/org/jboss/cache/eviction/EvictionConfigu= rationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/EvictionConfiguration= Test.java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/EvictionConfiguration= Test.java 2008-08-18 13:34:16 UTC (rev 6574) @@ -71,7 +71,7 @@ assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() inst= anceof LRUAlgorithmConfig); assertEquals(5000, ((LRUAlgorithmConfig) evictionRegionConfig.get= EvictionAlgorithmConfig()).getMaxNodes()); assertEquals(1000000, ((LRUAlgorithmConfig) evictionRegionConfig.= getEvictionAlgorithmConfig()).getTimeToLive()); - assertEquals(0, ((LRUAlgorithmConfig) evictionRegionConfig.getEvi= ctionAlgorithmConfig()).getMaxAge()); + assertEquals(-1, ((LRUAlgorithmConfig) evictionRegionConfig.getEv= ictionAlgorithmConfig()).getMaxAge()); = } finally @@ -110,7 +110,7 @@ assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() inst= anceof LRUAlgorithmConfig); assertEquals(5000, ((LRUAlgorithmConfig) evictionRegionConfig.get= EvictionAlgorithmConfig()).getMaxNodes()); assertEquals(1000000, ((LRUAlgorithmConfig) evictionRegionConfig.= getEvictionAlgorithmConfig()).getTimeToLive()); - assertEquals(0, ((LRUAlgorithmConfig) evictionRegionConfig.getEvi= ctionAlgorithmConfig()).getMaxAge()); + assertEquals(-1, ((LRUAlgorithmConfig) evictionRegionConfig.getEv= ictionAlgorithmConfig()).getMaxAge()); = region =3D regionManager.getRegion("/maxAgeTest", false); evictionRegionConfig =3D region.getEvictionRegionConfig(); @@ -174,7 +174,7 @@ assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() inst= anceof LRUAlgorithmConfig); assertEquals(5000, ((LRUAlgorithmConfig) evictionRegionConfig.get= EvictionAlgorithmConfig()).getMaxNodes()); assertEquals(1000000, ((LRUAlgorithmConfig) evictionRegionConfig.= getEvictionAlgorithmConfig()).getTimeToLive()); - assertEquals(0, ((LRUAlgorithmConfig) evictionRegionConfig.getEvi= ctionAlgorithmConfig()).getMaxAge()); + assertEquals(-1, ((LRUAlgorithmConfig) evictionRegionConfig.getEv= ictionAlgorithmConfig()).getMaxAge()); = } finally Added: core/trunk/src/test/java/org/jboss/cache/eviction/EvictionTestsBase.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/EvictionTestsBase.jav= a (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/eviction/EvictionTestsBase.jav= a 2008-08-18 13:34:16 UTC (rev 6574) @@ -0,0 +1,53 @@ +package org.jboss.cache.eviction; + +import org.easymock.EasyMock; +import org.jboss.cache.Cache; +import org.jboss.cache.CacheSPI; +import org.jboss.cache.Fqn; +import org.jboss.cache.Region; +import org.jboss.cache.RegionManager; +import org.jboss.cache.RegionManagerImpl; +import org.jboss.cache.RegionRegistry; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.EvictionAlgorithmConfig; +import org.jboss.cache.config.EvictionConfig; +import org.jboss.cache.config.EvictionRegionConfig; +import org.jboss.cache.util.TestingUtil; +import org.jboss.cache.util.internals.EvictionWatcher; + +import java.util.concurrent.TimeUnit; + +public abstract class EvictionTestsBase +{ + public EvictionAlgorithm createAndAssignToRegion(String fqnString, Regi= onManager regionManager, EvictionAlgorithmConfig config) + { + Fqn fqn =3D Fqn.fromString(fqnString); + Configuration c =3D new Configuration(); + c.setEvictionConfig(new EvictionConfig()); + EvictionRegionConfig erc =3D new EvictionRegionConfig(fqn, config); + c.getEvictionConfig().addEvictionRegionConfig(erc); + CacheSPI mockCache =3D EasyMock.createNiceMock(CacheSPI.class); + EasyMock.replay(mockCache); + ((RegionManagerImpl) regionManager).injectDependencies(mockCache, c,= null, null, null, new RegionRegistry()); + Region r =3D regionManager.getRegion(fqn, Region.Type.EVICTION, true= ); + r.setEvictionRegionConfig(erc); + + ((RegionManagerImpl) regionManager).start(); + return (EvictionAlgorithm) TestingUtil.extractField(r, "evictionAlgo= rithm"); + } + + /** + * Blocks until an eviction event is seen on the given cache for the gi= ven array of Fqns. Returns true if the eviction event + * is received, false if it times out. + * + * @param cache cache to monitor + * @param timeToWait timeout + * @param unit timeout unit + * @param fqnsToEvict fqns to watch for + * @return true if evicted, false otherwise + */ + public boolean waitForEviction(Cache cache, long timeToWait, TimeUnit u= nit, Fqn... fqnsToEvict) throws InterruptedException + { + return new EvictionWatcher(cache, fqnsToEvict).waitForEviction(timeT= oWait, unit); + } +} Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolic= yTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.= java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.= java 2008-08-18 13:34:16 UTC (rev 6574) @@ -21,6 +21,8 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = +import java.util.concurrent.TimeUnit; + /** * Unit tests for {@link org.jboss.cache.eviction.ExpirationAlgorithm}. * @@ -28,7 +30,7 @@ * @version $Revision$ */ @Test(groups =3D {"functional"}) -public class ExpirationPolicyTest +public class ExpirationPolicyTest extends EvictionTestsBase { private static final Log log =3D LogFactory.getLog(ExpirationPolicyTest= .class); = @@ -49,13 +51,13 @@ ExpirationAlgorithmConfig eAC =3D new ExpirationAlgorithmConfig(); EvictionRegionConfig eRC =3D new EvictionRegionConfig(Fqn.ROOT, eAC); EvictionConfig econf =3D new EvictionConfig(eRC); - econf.setWakeupInterval(1000); + econf.setWakeupInterval(100); conf.setEvictionConfig(econf); cache =3D (CacheSPI) new DefaultCacheFactory().createCache(conf, false); cache.start(); = - future =3D System.currentTimeMillis() + 4000; - past =3D System.currentTimeMillis() - 2000; + future =3D System.currentTimeMillis() + 500; + past =3D System.currentTimeMillis() - 200; } = @AfterMethod(alwaysRun =3D true) @@ -70,14 +72,14 @@ cache.put(fqn2, ExpirationAlgorithmConfig.EXPIRATION_KEY, past); cache.put(fqn3, ExpirationAlgorithmConfig.EXPIRATION_KEY, future); cache.put(fqn4, "foo", "bar"); - TestingUtil.sleepThread(2000); + assert waitForEviction(cache, 30, TimeUnit.SECONDS, fqn2) : "Evictio= n event not received!"; assertNotNull(cache.getNode(fqn1)); assertNull(cache.getNode(fqn2)); assertNotNull(cache.getNode(fqn3)); assertNotNull(cache.getNode(fqn4)); = log.info("should remove 1 and 3 now"); - TestingUtil.sleepThread(3000); + assert waitForEviction(cache, 30, TimeUnit.SECONDS, fqn1, fqn3) : "E= viction event not received!"; assertNull(cache.getNode(fqn1)); assertNull(cache.getNode(fqn3)); } @@ -87,25 +89,23 @@ log.info("update 1 from future to past"); cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future); assertNotNull(cache.getNode(fqn1)); - TestingUtil.sleepThread(1500); cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, past); - TestingUtil.sleepThread(1500); + assert waitForEviction(cache, 1, TimeUnit.SECONDS, fqn1) : "Eviction= event not received!"; assertNull(cache.getNode(fqn1)); cache.removeNode(Fqn.ROOT); - } = public void testUpdateToFuture() throws Exception { log.info("update 1 from future to past"); - Long future2 =3D future + 2000; + Long future2 =3D future + 200; cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future); - TestingUtil.sleepThread(2000); + TestingUtil.sleepThread(200); assertNotNull(cache.getNode(fqn1)); cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future2); - TestingUtil.sleepThread(3000); + TestingUtil.sleepThread(500); assertNotNull(cache.getNode(fqn1)); - TestingUtil.sleepThread(3000); + TestingUtil.sleepThread(100); assertNull(cache.getNode(fqn1)); cache.removeNode(Fqn.ROOT); } @@ -122,7 +122,7 @@ cache.put(fqn3, ExpirationAlgorithmConfig.EXPIRATION_KEY, future); cache.put(fqn4, ExpirationAlgorithmConfig.EXPIRATION_KEY, past); assertEquals(5, cache.getNumberOfNodes()); - Thread.sleep(2000); + assert waitForEviction(cache, 30, TimeUnit.SECONDS, fqn3) : "Evictio= n event not received!"; assertNotNull(cache.getNode(fqn1)); assertNotNull(cache.getNode(fqn2)); assertNull(cache.getNode(fqn3)); Modified: core/trunk/src/test/java/org/jboss/cache/eviction/FIFOAlgorithmTe= st.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/FIFOAlgorithmTest.jav= a 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/FIFOAlgorithmTest.jav= a 2008-08-18 13:34:16 UTC (rev 6574) @@ -7,19 +7,15 @@ package org.jboss.cache.eviction; = import org.jboss.cache.Fqn; -import org.jboss.cache.Region; import org.jboss.cache.RegionImpl; import org.jboss.cache.RegionManager; import org.jboss.cache.RegionManagerImpl; import org.jboss.cache.RegionRegistry; -import org.jboss.cache.config.EvictionRegionConfig; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertTrue; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = -import java.util.Iterator; - /** * Unit tests for FIFOAlgorithm. * @@ -27,7 +23,7 @@ * @version $Revision$ */ @Test(groups =3D {"functional"}) -public class FIFOAlgorithmTest +public class FIFOAlgorithmTest extends EvictionTestsBase { = RegionManager regionManager; @@ -36,15 +32,11 @@ @BeforeMethod(alwaysRun =3D true) public void setUp() throws Exception { - algo =3D new FIFOAlgorithm(); - FIFOAlgorithmConfig config =3D new FIFOAlgorithmConfig(); - // We have to setCache maxNodes!! - config.setMaxNodes(0); regionManager =3D new RegionManagerImpl(); ((RegionManagerImpl) regionManager).injectDependencies(null, null, n= ull, null, null, new RegionRegistry()); -// config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName()); - Region r =3D regionManager.getRegion("/a/b", true); - r.setEvictionRegionConfig(new EvictionRegionConfig(r.getFqn(), confi= g)); + FIFOAlgorithmConfig config =3D new FIFOAlgorithmConfig(); + config.setMaxNodes(0); + algo =3D (FIFOAlgorithm) createAndAssignToRegion("/a/b", regionManag= er, config); } = public void testMaxNodes1() throws Exception @@ -64,11 +56,9 @@ assertEquals(5, algo.getEvictionQueue().getNumberOfNodes()); = // now verify the order. - Iterator it =3D queue.iterate(); int index =3D 3; - while (it.hasNext()) + for (NodeEntry ne : queue) { - NodeEntry ne =3D (NodeEntry) it.next(); String fqn =3D ne.getFqn().toString(); assertTrue(fqn.endsWith("/" + Integer.toString(index))); index++; @@ -90,11 +80,9 @@ = assertEquals(5, algo.getEvictionQueue().getNumberOfNodes()); = - it =3D queue.iterate(); index =3D 3; - while (it.hasNext()) + for (NodeEntry ne : queue) { - NodeEntry ne =3D (NodeEntry) it.next(); String fqn =3D ne.getFqn().toString(); assertTrue(fqn.endsWith("/" + Integer.toString(index))); index++; @@ -105,9 +93,9 @@ { RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); FIFOAlgorithmConfig config =3D (FIFOAlgorithmConfig) region.getEvict= ionRegionConfig().getEvictionAlgorithmConfig(); - config.setMaxNodes(50000); + config.setMaxNodes(500); = - for (int i =3D 0; i < 50000; i++) + for (int i =3D 0; i < 500; i++) { Fqn fqn =3D Fqn.fromString("/a/b/" + Integer.toString(i)); region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NODE_EVE= NT); @@ -115,18 +103,16 @@ = algo.process(region.getEvictionEventQueue()); FIFOQueue queue =3D (FIFOQueue) algo.evictionQueue; - assertEquals(50000, algo.getEvictionQueue().getNumberOfNodes()); + assertEquals(500, algo.getEvictionQueue().getNumberOfNodes()); = - Iterator it =3D queue.iterate(); int index =3D 0; - while (it.hasNext()) + for (NodeEntry ne : queue) { - NodeEntry ne =3D (NodeEntry) it.next(); assertTrue(ne.getFqn().toString().endsWith("/" + Integer.toString= (index))); index++; } = - for (int i =3D 50000; i < 60000; i++) + for (int i =3D 500; i < 600; i++) { Fqn fqn =3D Fqn.fromString("/a/b/" + Integer.toString(i)); region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NODE_EVE= NT); @@ -134,11 +120,9 @@ = algo.process(region.getEvictionEventQueue()); = - it =3D queue.iterate(); - index =3D 10000; - while (it.hasNext()) + index =3D 100; + for (NodeEntry ne : queue) { - NodeEntry ne =3D (NodeEntry) it.next(); assertTrue(ne.getFqn().toString().endsWith("/" + Integer.toString= (index))); index++; } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurati= onTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurationTest= .java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurationTest= .java 2008-08-18 13:34:16 UTC (rev 6574) @@ -31,7 +31,8 @@ = Element element =3D XmlConfigHelper.stringToElementInCoreNS(xml); = - EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); + EvictionElementParser.parseEvictionPolicyConfig(element, config); + config.validate(); = assertEquals(1000, config.getMaxNodes()); = @@ -47,7 +48,8 @@ = try { - EvictionElementParser.parseEvictionPolicyConfig(element, config, = true); + EvictionElementParser.parseEvictionPolicyConfig(element, config); + config.validate(); } catch (ConfigurationException ce) { @@ -68,7 +70,8 @@ = try { - EvictionElementParser.parseEvictionPolicyConfig(element, config, = true); + EvictionElementParser.parseEvictionPolicyConfig(element, config); + config.validate(); } catch (ConfigurationException ce) { Modified: core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java 2= 008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java 2= 008-08-18 13:34:16 UTC (rev 6574) @@ -17,11 +17,16 @@ import org.jboss.cache.transaction.DummyTransactionManagerLookup; import org.jboss.cache.util.TestingUtil; import org.jboss.cache.util.internals.EvictionController; +import org.jboss.cache.util.internals.EvictionWatcher; import static org.testng.AssertJUnit.*; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + /** * Unit tests for FIFOPolicy. * @@ -29,14 +34,14 @@ * @version $Revision$ */ @Test(groups =3D {"functional"}) -public class FIFOPolicyTest +public class FIFOPolicyTest extends EvictionTestsBase { CacheSPI cache; long wakeupIntervalMillis =3D 0; final String ROOT_STR =3D "/test"; Throwable t1_ex, t2_ex; - final long DURATION =3D 10000; - boolean isTrue; + volatile boolean isTrue; + int maxNodes =3D 50; = @BeforeMethod(alwaysRun =3D true) public void setUp() throws Exception @@ -56,8 +61,7 @@ void initCaches() throws Exception { Configuration config =3D UnitTestCacheConfigurationFactory.createCon= figuration(Configuration.CacheMode.LOCAL, true); - EvictionConfig evConfig =3D new EvictionConfig(new EvictionRegionCon= fig(Fqn.ROOT, new FIFOAlgorithmConfig(5000)), 3000); - evConfig.setDefaultEventQueueSize(20000); + EvictionConfig evConfig =3D new EvictionConfig(new EvictionRegionCon= fig(Fqn.ROOT, new FIFOAlgorithmConfig(maxNodes), 2000000), 200); evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromSt= ring("/org/jboss/test/data"), new FIFOAlgorithmConfig(5))); config.setEvictionConfig(evConfig); config.setTransactionManagerLookupClass(DummyTransactionManagerLooku= p.class.getName()); @@ -112,7 +116,6 @@ public void testEviction2() throws Exception { String rootStr =3D "/org/jboss/data"; - int maxNodes =3D 5000; for (int i =3D 0; i < maxNodes * 2; i++) { String str =3D rootStr + i; @@ -122,6 +125,8 @@ = EvictionController evictionController =3D new EvictionController(cac= he); evictionController.startEviction(); + // wait a few secs for eviction to complete + TestingUtil.sleepThread(500); assertEquals("Number of nodes", maxNodes + 2, cache.getNumberOfNodes= ()); for (int i =3D 0; i < maxNodes; i++) { @@ -145,9 +150,13 @@ assertNotNull(cache.get(rootStr + "a", rootStr + "a")); } = - public void testNodeVisited() + public void testNodeVisited() throws InterruptedException { String rootStr =3D "/org/jboss/test/data/"; + List fqnsToBeEvicted =3D new ArrayList(); + for (int i =3D 0; i < 5; i++) fqnsToBeEvicted.add(Fqn.fromString(roo= tStr + i)); + EvictionWatcher watcher =3D new EvictionWatcher(cache, fqnsToBeEvict= ed); + for (int i =3D 0; i < 10; i++) { String str =3D rootStr + i; @@ -163,9 +172,8 @@ } } = - long period =3D wakeupIntervalMillis + 500; + assert watcher.waitForEviction(30, TimeUnit.SECONDS) : "Eviction eve= nt not received!"; = - log("sleeping for " + period + "ms"); EvictionController evictionController =3D new EvictionController(cac= he); evictionController.startEviction(); try @@ -183,14 +191,12 @@ assertNotNull(cache.get(fqn, str)); } = - evictionController.startEviction(); // since it is FIFO if we leave it alone and revisit, cache shoul= d remain the same. for (int i =3D 5; i < 10; i++) { String str =3D rootStr + Integer.toString(i); Fqn fqn =3D Fqn.fromString(str); cache.get(fqn, str);// just to keep it fresh - System.out.println("-- sleeping for " + period + "ms"); } } catch (Exception e) @@ -282,7 +288,7 @@ try { cache.put(myName + i++, "value", i); - sleep(1); + TestingUtil.sleepThread(2); } catch (Throwable e) { @@ -304,10 +310,12 @@ cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE= _READ); cache.start(); cache.put(ROOT_STR + "/concurrentPutAndEvict", "value", 1); - + List putters =3D new ArrayList(); for (int i =3D 0; i < 10; i++) { - new MyPutter("Putter" + i).start(); + MyPutter p =3D new MyPutter("Putter" + i); + putters.add(p); + p.start(); } = int counter =3D 0; @@ -320,12 +328,14 @@ } log("nodes/locks: " + cache.getNumberOfNodes() + "/" + cache.getN= umberOfLocksHeld()); TestingUtil.sleepThread(1000); - if (counter > 10) - {// run for 10 seconds + if (counter > 5) + {// run for 5 seconds isTrue =3D false; break; } } + + for (MyPutter p : putters) p.join(); } = void log(String msg) Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LFUAlgorithmTes= t.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/LFUAlgorithmTest.java= 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/LFUAlgorithmTest.java= 2008-08-18 13:34:16 UTC (rev 6574) @@ -10,15 +10,12 @@ import org.jboss.cache.RegionImpl; import org.jboss.cache.RegionManager; import org.jboss.cache.RegionManagerImpl; -import org.jboss.cache.RegionRegistry; import org.jboss.cache.config.EvictionRegionConfig; import static org.jboss.cache.eviction.EvictionEvent.Type.*; import static org.testng.AssertJUnit.*; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = -import java.util.Iterator; - /** * Unit test for LFUAlgorithm. * @@ -26,20 +23,18 @@ * @version $Revision$ */ @Test(groups =3D {"functional"}) -public class LFUAlgorithmTest +public class LFUAlgorithmTest extends EvictionTestsBase { RegionManager regionManager; LFUAlgorithm algo; + LFUAlgorithmConfig config; = @BeforeMethod(alwaysRun =3D true) public void setUp() throws Exception { - algo =3D new LFUAlgorithm(); - LFUAlgorithmConfig config =3D new LFUAlgorithmConfig(); regionManager =3D new RegionManagerImpl(); - ((RegionManagerImpl) regionManager).injectDependencies(null, null, n= ull, null, null, new RegionRegistry()); - regionManager.getRegion("/a/b", true).setEvictionRegionConfig(new Ev= ictionRegionConfig(Fqn.fromString("/a/b"), config)); - // doesn't this need a cache?!?? :-/ + config =3D new LFUAlgorithmConfig(); + algo =3D (LFUAlgorithm) createAndAssignToRegion("/a/b", regionManage= r, config); } = public void testMaxNode1() @@ -47,10 +42,8 @@ Fqn fqn1 =3D Fqn.fromString("/a/b/c"); Fqn fqn2 =3D Fqn.fromString("/a/b/d"); RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); - LFUAlgorithmConfig config =3D new LFUAlgorithmConfig(); - config.setMaxNodes(0); + config.setMaxNodes(-1); config.setMinNodes(20); - region.setEvictionRegionConfig(new EvictionRegionConfig(region.getFq= n(), config)); region.registerEvictionEvent(fqn1, ADD_NODE_EVENT); region.registerEvictionEvent(fqn2, ADD_NODE_EVENT); try @@ -72,10 +65,8 @@ Fqn fqn2 =3D Fqn.fromString("/a/b/d"); Fqn fqn3 =3D Fqn.fromString("/a/b/e"); RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); - LFUAlgorithmConfig config =3D new LFUAlgorithmConfig(); config.setMaxNodes(1); config.setMinNodes(20); - region.setEvictionRegionConfig(new EvictionRegionConfig(region.getFq= n(), config)); region.registerEvictionEvent(fqn1, ADD_NODE_EVENT); region.registerEvictionEvent(fqn2, ADD_NODE_EVENT); = @@ -116,7 +107,7 @@ RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); LFUAlgorithmConfig config =3D (LFUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); = - config.setMaxNodes(0); + config.setMaxNodes(-1); config.setMinNodes(2); = region.registerEvictionEvent(fqn1, ADD_NODE_EVENT); @@ -137,8 +128,8 @@ RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); LFUAlgorithmConfig config =3D (LFUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); = - config.setMaxNodes(0); - config.setMinNodes(0); + config.setMaxNodes(-1); + config.setMinNodes(-1); = region.registerEvictionEvent(fqn1, ADD_NODE_EVENT); region.registerEvictionEvent(fqn2, ADD_NODE_EVENT); @@ -164,7 +155,7 @@ = RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); LFUAlgorithmConfig config =3D (LFUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); - config.setMaxNodes(0); + config.setMaxNodes(-1); config.setMinNodes(100); = region.registerEvictionEvent(fqn1, ADD_NODE_EVENT); @@ -181,11 +172,9 @@ algo.process(region.getEvictionEventQueue()); LFUQueue queue =3D (LFUQueue) algo.evictionQueue; assertEquals(10, algo.getEvictionQueue().getNumberOfNodes()); - Iterator it =3D queue.iterate(); = - while (it.hasNext()) + for (NodeEntry ne : queue) { - NodeEntry ne =3D (NodeEntry) it.next(); System.out.println("Fqn: " + ne.getFqn() + " NodeVisits: " + ne.g= etNumberOfNodeVisits()); assertEquals(1, ne.getNumberOfNodeVisits()); } @@ -219,12 +208,10 @@ System.out.println(); System.out.println(); = - it =3D queue.iterate(); int count =3D 0; - while (it.hasNext()) + for (NodeEntry ne : queue) { count++; - NodeEntry ne =3D (NodeEntry) it.next(); System.out.println("Fqn: " + ne.getFqn() + " NodeVisits: " + ne.g= etNumberOfNodeVisits()); if (count =3D=3D 5 || count =3D=3D 6) { @@ -261,12 +248,10 @@ System.out.println(); System.out.println(); = - it =3D queue.iterate(); count =3D 0; - while (it.hasNext()) + for (NodeEntry ne : queue) { count++; - NodeEntry ne =3D (NodeEntry) it.next(); System.out.println("Fqn: " + ne.getFqn() + " NodeVisits: " + ne.g= etNumberOfNodeVisits()); if (count =3D=3D 7 || count =3D=3D 8) { @@ -301,12 +286,10 @@ = System.out.println(); System.out.println(); - it =3D queue.iterate(); count =3D 0; - while (it.hasNext()) + for (NodeEntry ne : queue) { count++; - NodeEntry ne =3D (NodeEntry) it.next(); System.out.println("Fqn: " + ne.getFqn() + " NodeVisits: " + ne.g= etNumberOfNodeVisits()); if (count =3D=3D 5 || count =3D=3D 6) { @@ -348,12 +331,10 @@ = System.out.println(); System.out.println(); - it =3D queue.iterate(); count =3D 0; - while (it.hasNext()) + for (NodeEntry ne : queue) { count++; - NodeEntry ne =3D (NodeEntry) it.next(); System.out.println("Fqn: " + ne.getFqn() + " NodeVisits: " + ne.g= etNumberOfNodeVisits()); if (count =3D=3D 5 || count =3D=3D 6) { @@ -380,7 +361,7 @@ RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); EvictionRegionConfig config =3D region.getEvictionRegionConfig(); = - ((LFUAlgorithmConfig) config.getEvictionAlgorithmConfig()).setMaxNod= es(0); + ((LFUAlgorithmConfig) config.getEvictionAlgorithmConfig()).setMaxNod= es(-1); ((LFUAlgorithmConfig) config.getEvictionAlgorithmConfig()).setMinNod= es(10000); for (int i =3D 0; i < 10000; i++) { @@ -390,12 +371,10 @@ = algo.process(region.getEvictionEventQueue()); LFUQueue queue =3D (LFUQueue) algo.evictionQueue; - Iterator it =3D queue.iterate(); = long lastModifiedTimestamp =3D 0; - while (it.hasNext()) + for (NodeEntry ne : queue) { - NodeEntry ne =3D (NodeEntry) it.next(); assertTrue(lastModifiedTimestamp <=3D ne.getModifiedTimeStamp()); lastModifiedTimestamp =3D ne.getModifiedTimeStamp(); } @@ -411,12 +390,10 @@ = algo.process(region.getEvictionEventQueue()); = - it =3D queue.iterate(); int count =3D 0; lastModifiedTimestamp =3D 0; - while (it.hasNext()) + for (NodeEntry ne : queue) { - NodeEntry ne =3D (NodeEntry) it.next(); assertTrue(lastModifiedTimestamp <=3D ne.getModifiedTimeStamp()); lastModifiedTimestamp =3D ne.getModifiedTimeStamp(); = @@ -434,5 +411,4 @@ = assertEquals(10000, algo.getEvictionQueue().getNumberOfNodes()); } - } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfiguratio= nTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfigurationTest.= java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfigurationTest.= java 2008-08-18 13:34:16 UTC (rev 6574) @@ -33,7 +33,8 @@ = Element element =3D XmlConfigHelper.stringToElementInCoreNS(xml); = - EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); + EvictionElementParser.parseEvictionPolicyConfig(element, config); + config.validate(); = assertEquals(10, config.getMinNodes()); assertEquals(20, config.getMaxNodes()); @@ -48,7 +49,8 @@ ""; Element element =3D XmlConfigHelper.stringToElementInCoreNS(xml); = - EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); + EvictionElementParser.parseEvictionPolicyConfig(element, config); + config.validate(); = assertEquals(10, config.getMinNodes()); assertEquals(0, config.getMaxNodes()); @@ -63,9 +65,10 @@ ""; Element element =3D XmlConfigHelper.stringToElementInCoreNS(xml); = - EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); + EvictionElementParser.parseEvictionPolicyConfig(element, config); + config.validate(); = - assertEquals(0, config.getMinNodes()); + assertEquals(-1, config.getMinNodes()); assertEquals(20, config.getMaxNodes()); = } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java 20= 08-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java 20= 08-08-18 13:34:16 UTC (rev 6574) @@ -15,11 +15,16 @@ import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; import org.jboss.cache.lock.IsolationLevel; import org.jboss.cache.util.TestingUtil; +import org.jboss.cache.util.internals.EvictionWatcher; import static org.testng.AssertJUnit.*; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + /** * Unit tests for LFU Policy. * @@ -27,14 +32,14 @@ * @version $Revision$ */ @Test(groups =3D {"functional"}) -public class LFUPolicyTest +public class LFUPolicyTest extends EvictionTestsBase { CacheSPI cache; long wakeupIntervalMillis =3D 0; final String ROOT_STR =3D "/test"; Throwable t1_ex, t2_ex; - final long DURATION =3D 10000; boolean isTrue; + int maxNodesDefault =3D 500, minNodesDefault =3D 10, maxNodesR1 =3D 200= , minNodesR1 =3D 100, maxNodesR2 =3D -1, minNodesR2 =3D 5; = @BeforeMethod(alwaysRun =3D true) public void setUp() throws Exception @@ -54,10 +59,9 @@ void initCaches() throws Exception { Configuration config =3D UnitTestCacheConfigurationFactory.createCon= figuration(Configuration.CacheMode.LOCAL, true); - EvictionConfig evConfig =3D new EvictionConfig(new EvictionRegionCon= fig(Fqn.ROOT, new LFUAlgorithmConfig(500, 10)), 3000); - evConfig.setDefaultEventQueueSize(200000); - evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromSt= ring("/org/jboss/data"), new LFUAlgorithmConfig(5000, 4000))); - evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromSt= ring("/org/jboss/test/data"), new LFUAlgorithmConfig(-1, 5))); + EvictionConfig evConfig =3D new EvictionConfig(new EvictionRegionCon= fig(Fqn.ROOT, new LFUAlgorithmConfig(maxNodesDefault, minNodesDefault), 200= 000), 200); + evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromSt= ring("/org/jboss/data"), new LFUAlgorithmConfig(maxNodesR1, minNodesR1))); + evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromSt= ring("/org/jboss/test/data"), new LFUAlgorithmConfig(maxNodesR2, minNodesR2= ))); config.setEvictionConfig(evConfig); config.setTransactionManagerLookupClass("org.jboss.cache.transaction= .DummyTransactionManagerLookup"); config.setIsolationLevel(IsolationLevel.SERIALIZABLE); @@ -72,8 +76,13 @@ = public void testEviction() throws Exception { + int numNodes =3D (int) ((maxNodesR1 * 2.6) - 1); String rootStr =3D "/org/jboss/data/"; - for (int i =3D 0; i < 8000; i++) + List fqns =3D new ArrayList(); + for (int i =3D 0; i < numNodes; i +=3D 2) fqns.add(Fqn.fromString(ro= otStr + i)); + EvictionWatcher ew =3D new EvictionWatcher(cache, fqns); + List toRevisit =3D new ArrayList(); + for (int i =3D 0; i < numNodes; i++) { String str =3D rootStr + i; Fqn fqn =3D Fqn.fromString(str); @@ -88,16 +97,13 @@ } = // visit odd numbered nodes an extra time to make them get evicte= d last. - if (i % 2 !=3D 0) - { - cache.get(fqn, str); - } + if (i % 2 !=3D 0) toRevisit.add(fqn); + revisit(toRevisit); } = - long period =3D wakeupIntervalMillis + 500; - TestingUtil.sleepThread(period); + assert ew.waitForEviction(30, TimeUnit.SECONDS); = - for (int i =3D 0; i < 8000; i++) + for (int i =3D 0; i < numNodes; i++) { String str =3D rootStr + i; Fqn fqn =3D Fqn.fromString(str); @@ -113,9 +119,17 @@ } } = - public void testNodeVisited() + private void revisit(List fqns) { + for (Fqn fqn : fqns) cache.getNode(fqn); + } + + public void testNodeVisited() throws InterruptedException + { String rootStr =3D "/org/jboss/test/data/"; + List fqns =3D new ArrayList(); + for (int i =3D 0; i < 5; i++) fqns.add(Fqn.fromString(rootStr + i)); + EvictionWatcher ew =3D new EvictionWatcher(cache, fqns); for (int i =3D 0; i < 10; i++) { String str =3D rootStr + i; @@ -131,11 +145,8 @@ } } = - long period =3D wakeupIntervalMillis + 500; + assert ew.waitForEviction(30, TimeUnit.SECONDS); = - log("sleeping for " + period + "ms"); - TestingUtil.sleepThread(period);// it really depends the eviction th= read time. - try { for (int i =3D 0; i < 5; i++) @@ -151,8 +162,6 @@ assertNotNull(cache.get(fqn, str)); } = - TestingUtil.sleepThread(period); - // since min is 5 the cache won't deplete past 5 nodes left in th= e cache. for (int i =3D 5; i < 10; i++) { @@ -184,7 +193,11 @@ } } = - TestingUtil.sleepThread(period); + assert waitForEviction(cache, 30, TimeUnit.SECONDS, + Fqn.fromString(rootStr + 7), + Fqn.fromString(rootStr + 8), + Fqn.fromString(rootStr + 9) + ); = // now make sure we still only have 5 nodes and they are the ones= we expect based on LFU for (int i =3D 5; i < 7; i++) @@ -219,7 +232,7 @@ public void testNodeRemoved() throws Exception { String rootStr =3D "/org/jboss/data/"; - for (int i =3D 0; i < 5000; i++) + for (int i =3D 0; i < maxNodesR1; i++) { String str =3D rootStr + i; Fqn fqn =3D Fqn.fromString(str); @@ -238,21 +251,21 @@ log("period is " + period); TestingUtil.sleepThread(period); = - for (int i =3D 0; i < 1000; i++) + for (int i =3D 0; i < (maxNodesR1 - minNodesR1); i++) { String str =3D rootStr + i; Fqn fqn =3D Fqn.fromString(str); assertNull(cache.get(fqn, str)); } = - for (int i =3D 1000; i < 5000; i++) + for (int i =3D (maxNodesR1 - minNodesR1); i < maxNodesR1; i++) { String str =3D rootStr + i; Fqn fqn =3D Fqn.fromString(str); assertNotNull(cache.get(fqn, str)); } = - for (int i =3D 1000; i < 5000; i++) + for (int i =3D (maxNodesR1 - minNodesR1); i < maxNodesR1; i++) { if (i % 2 =3D=3D 0) { @@ -265,7 +278,7 @@ TestingUtil.sleepThread(period); = = - for (int i =3D 1000; i < 5000; i++) + for (int i =3D (maxNodesR1 - minNodesR1); i < maxNodesR1; i++) { if (i % 2 =3D=3D 0) { @@ -332,8 +345,8 @@ } log("nodes/locks: " + cache.getNumberOfNodes() + "/" + cache.getN= umberOfLocksHeld()); TestingUtil.sleepThread(1000); - if (counter > 10) - {// run for 10 seconds + if (counter > 5) + {// run for 5 seconds isTrue =3D false; break; } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LFUQueueTest.ja= va =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/LFUQueueTest.java 200= 8-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/LFUQueueTest.java 200= 8-08-18 13:34:16 UTC (rev 6574) @@ -6,19 +6,13 @@ */ package org.jboss.cache.eviction; = -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; = -import java.util.Iterator; import java.util.List; import java.util.Set; = -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - /** * Unit tests for LFUQueue. * @@ -53,16 +47,13 @@ NodeEntry ne275 =3D queue.getNodeEntry("/a/b/c/275"); assertEquals("/a/b/c/275", ne275.getFqn().toString()); = - // now make sure the ordering is correct. - Iterator it =3D queue.iterate(); int k =3D 0; - while (it.hasNext()) + for (NodeEntry entry : queue) { - ne =3D (NodeEntry) it.next(); - assertEquals("/a/b/c/" + Integer.toString(k), ne.getFqn().toStrin= g()); + assertEquals("/a/b/c/" + Integer.toString(k), entry.getFqn().toSt= ring()); if (k % 2 =3D=3D 0) { - ne.setNumberOfNodeVisits(ne.getNumberOfNodeVisits() + 1); + entry.setNumberOfNodeVisits(entry.getNumberOfNodeVisits() + 1); } k++; } @@ -72,18 +63,16 @@ assertEquals("/a/b/c/1", queue.getFirstNodeEntry().getFqn().toString= ()); = // now check the sort order. - it =3D queue.iterate(); k =3D 0; - while (it.hasNext()) + for (NodeEntry entry : queue) { - ne =3D (NodeEntry) it.next(); if (k < 250) { - assertEquals(0, ne.getNumberOfNodeVisits()); + assertEquals(0, entry.getNumberOfNodeVisits()); } else { - assertEquals(1, ne.getNumberOfNodeVisits()); + assertEquals(1, entry.getNumberOfNodeVisits()); } k++; } @@ -121,17 +110,15 @@ assertEquals(250, queue.getNumberOfNodes()); = k =3D 0; - it =3D queue.iterate(); - while (it.hasNext()) + for (NodeEntry entry : queue) { - ne =3D (NodeEntry) it.next(); if (k <=3D 125) { - assertEquals(1, ne.getNumberOfNodeVisits()); + assertEquals(1, entry.getNumberOfNodeVisits()); } else { - assertEquals(2, ne.getNumberOfNodeVisits()); + assertEquals(2, entry.getNumberOfNodeVisits()); } k++; } @@ -140,17 +127,14 @@ = public void testPrune() throws Exception { - for (int i =3D 0; i < 5000; i++) + for (int i =3D 0; i < 500; i++) { queue.addNodeEntry(new NodeEntry("/a/b/c/" + Integer.toString(i))= ); } = - NodeEntry ne; - Iterator it =3D queue.iterate(); int i =3D 0; - while (it.hasNext()) + for (NodeEntry ne : queue) { - ne =3D (NodeEntry) it.next(); if (i % 2 =3D=3D 0) { queue.removeNodeEntry(ne); @@ -158,17 +142,15 @@ i++; } = - assertEquals(2500, queue.getNumberOfNodes()); + assertEquals(250, queue.getNumberOfNodes()); = - Set removalQueue =3D queue.getRemovalQueue(); - List evictionList =3D queue.getEvictionList(); + Set removalQueue =3D queue.getRemovalQueue(); + List evictionList =3D queue.getEvictionList(); = - assertEquals(2500, removalQueue.size()); + assertEquals(250, removalQueue.size()); = - it =3D removalQueue.iterator(); - while (it.hasNext()) + for (NodeEntry ne : removalQueue) { - ne =3D (NodeEntry) it.next(); int currentIndex =3D Integer.parseInt((String) ne.getFqn().get(3)= ); assertEquals(0, currentIndex % 2); = @@ -177,12 +159,12 @@ assertTrue(evictionList.contains(ne)); } = - assertEquals(5000, evictionList.size()); + assertEquals(500, evictionList.size()); = queue.prune(); = assertEquals(0, removalQueue.size()); - assertEquals(2500, evictionList.size()); + assertEquals(250, evictionList.size()); } = public void testGetFirstNodeEntry() throws Exception Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTes= t.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java= 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java= 2008-08-18 13:34:16 UTC (rev 6574) @@ -3,12 +3,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.Fqn; -import org.jboss.cache.Region; import org.jboss.cache.RegionImpl; import org.jboss.cache.RegionManager; import org.jboss.cache.RegionManagerImpl; -import org.jboss.cache.RegionRegistry; -import org.jboss.cache.config.EvictionRegionConfig; import org.jboss.cache.util.TestingUtil; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertTrue; @@ -22,7 +19,8 @@ * @author Daniel Huang (dhuang(a)jboss.org) */ @Test(groups =3D "functional") -public class LRUAlgorithmTest +public class LRUAlgorithmTest extends EvictionTestsBase + { RegionManager regionManager; LRUAlgorithm algorithm; @@ -32,16 +30,10 @@ @BeforeMethod(alwaysRun =3D true) public void setUp() throws Exception { - algorithm =3D new LRUAlgorithm(); - config =3D new LRUAlgorithmConfig(); -// config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName()); - // We have to setCache timeToLiveSeconds!! - config.setTimeToLive(0); - regionManager =3D new RegionManagerImpl(); - ((RegionManagerImpl) regionManager).injectDependencies(null, null, n= ull, null, null, new RegionRegistry()); - Region r =3D regionManager.getRegion("/a/b", true); - r.setEvictionRegionConfig(new EvictionRegionConfig(r.getFqn(), confi= g)); + config =3D new LRUAlgorithmConfig(); + config.setTimeToLive(-1); + algorithm =3D (LRUAlgorithm) createAndAssignToRegion("/a/b", regionM= anager, config); } = /** @@ -53,7 +45,6 @@ Fqn fqn2 =3D Fqn.fromString("/a/b/d"); Fqn fqn3 =3D Fqn.fromString("/a/b/e"); RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); - LRUAlgorithmConfig config =3D (LRUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); config.setMaxNodes(1); region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT= ); region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); @@ -79,7 +70,6 @@ Fqn fqn1 =3D Fqn.fromString("/a/b/c"); Fqn fqn2 =3D Fqn.fromString("/a/b/d"); RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); - LRUAlgorithmConfig config =3D (LRUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); config.setMaxNodes(0); region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT= ); region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); @@ -98,7 +88,6 @@ Fqn fqn2 =3D Fqn.fromString("/a/b/d"); Fqn fqn3 =3D Fqn.fromString("/a/b/e"); RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); - LRUAlgorithmConfig config =3D (LRUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); config.setMaxNodes(1); region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT= ); region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); @@ -124,14 +113,11 @@ Fqn fqn1 =3D Fqn.fromString("/a/b/c"); Fqn fqn2 =3D Fqn.fromString("/a/b/d"); RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); - LRUAlgorithmConfig config =3D (LRUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); - config.setMaxNodes(0); - config.setTimeToLive(0); + config.setMaxNodes(-1); + config.setTimeToLive(-1); region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT= ); region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); = - TestingUtil.sleepThread(500); - algorithm.process(region.getEvictionEventQueue()); = assertEquals("Queue size should be ", 2, algorithm.getEvictionQueue(= ).getNumberOfNodes()); @@ -146,7 +132,6 @@ Fqn fqn2 =3D Fqn.fromString("/a/b/d"); Fqn fqn3 =3D Fqn.fromString("/a/b/e"); RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); - LRUAlgorithmConfig config =3D (LRUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); config.setMaxNodes(0); config.setTimeToLive(1000); region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT= ); @@ -172,7 +157,6 @@ Fqn fqn2 =3D Fqn.fromString("/a/b/d"); Fqn fqn3 =3D Fqn.fromString("/a/b/e"); RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); - LRUAlgorithmConfig config =3D (LRUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); config.setMaxNodes(0); config.setTimeToLive(1000); region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT= ); @@ -200,17 +184,16 @@ Fqn fqn2 =3D Fqn.fromString("/a/b/d"); Fqn fqn3 =3D Fqn.fromString("/a/b/e"); RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); - LRUAlgorithmConfig config =3D (LRUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); - config.setMaxNodes(0); - config.setTimeToLive(0); - config.setMaxAge(1000); + config.setMaxNodes(-1); + config.setTimeToLive(-1); + config.setMaxAge(100); region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT= ); region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT= ); = algorithm.process(region.getEvictionEventQueue()); assertEquals("Queue size #1: ", 3, algorithm.getEvictionQueue().getN= umberOfNodes()); - TestingUtil.sleepThread(1100); + TestingUtil.sleepThread(110); algorithm.process(region.getEvictionEventQueue()); assertEquals("Queue size #2: ", 0, algorithm.getEvictionQueue().getN= umberOfNodes()); } @@ -226,21 +209,20 @@ Fqn fqn2 =3D Fqn.fromString("/a/b/d"); Fqn fqn3 =3D Fqn.fromString("/a/b/e"); RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); - LRUAlgorithmConfig config =3D (LRUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); = - config.setMaxNodes(0); - config.setTimeToLive(0); - config.setMaxAge(1000); + config.setMaxNodes(-1); + config.setTimeToLive(-1); + config.setMaxAge(100); region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT= ); region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT= ); = algorithm.process(region.getEvictionEventQueue()); assertEquals("Queue size #1: ", 3, algorithm.getEvictionQueue().getN= umberOfNodes()); - TestingUtil.sleepThread(500); + TestingUtil.sleepThread(50); algorithm.process(region.getEvictionEventQueue()); assertEquals("Queue size #2: ", 3, algorithm.getEvictionQueue().getN= umberOfNodes()); - TestingUtil.sleepThread(600); + TestingUtil.sleepThread(60); algorithm.process(region.getEvictionEventQueue()); assertEquals("Queue size #3: ", 0, algorithm.getEvictionQueue().getN= umberOfNodes()); } @@ -255,12 +237,11 @@ Fqn fqn3 =3D Fqn.fromString("/a/b/e"); Fqn fqn4 =3D Fqn.fromString("/a/b/f"); RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); - LRUAlgorithmConfig config =3D (LRUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); = // Should have a maximum of 2 nodes. config.setMaxNodes(2); - config.setTimeToLive(1000); - config.setMaxAge(3000); + config.setTimeToLive(100); + config.setMaxAge(300); region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT= ); region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); region.registerEvictionEvent(fqn4, EvictionEvent.Type.ADD_NODE_EVENT= ); @@ -272,7 +253,7 @@ assert 2 =3D=3D numNodesInQueue : "Queue size #1: expected 2 but was= " + numNodesInQueue; = // make sure all nodes now expire - TestingUtil.sleepThread(1100); + TestingUtil.sleepThread(110); = region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT= ); = @@ -281,7 +262,7 @@ numNodesInQueue =3D eq.getNumberOfNodes(); assert 1 =3D=3D numNodesInQueue : "Queue size #2: expected 1 but was= " + numNodesInQueue; = - TestingUtil.sleepThread(3100); + TestingUtil.sleepThread(310); // visit the node now to prevent the idle time from doing the prunin= g - node still gets pruned but by // max age. region.registerEvictionEvent(fqn3, EvictionEvent.Type.VISIT_NODE_EVE= NT); @@ -301,11 +282,10 @@ Fqn fqn2 =3D Fqn.fromString("/a/b/d"); Fqn fqn3 =3D Fqn.fromString("/a/b/e"); RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); - LRUAlgorithmConfig config =3D (LRUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); = config.setMaxNodes(2); - config.setTimeToLive(1000); - config.setMaxAge(3000); + config.setTimeToLive(100); + config.setMaxAge(300); region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT= ); region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); region.registerEvictionEvent(fqn2, EvictionEvent.Type.REMOVE_NODE_EV= ENT); @@ -317,7 +297,7 @@ assert 1 =3D=3D numNodesInQueue : "Queue size #1: expected 1 but was= " + numNodesInQueue; = // make sure existing events all time out - TestingUtil.sleepThread(1100); + TestingUtil.sleepThread(110); region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT= ); = algorithm.process(region.getEvictionEventQueue()); @@ -325,7 +305,7 @@ numNodesInQueue =3D eq.getNumberOfNodes(); assert 1 =3D=3D numNodesInQueue : "Queue size #2: expected 1 but was= " + numNodesInQueue; = - TestingUtil.sleepThread(3100); + TestingUtil.sleepThread(310); region.registerEvictionEvent(fqn3, EvictionEvent.Type.VISIT_NODE_EVE= NT); = algorithm.process(region.getEvictionEventQueue()); @@ -337,7 +317,6 @@ public void testEvictionSortOrder() throws EvictionException { RegionImpl region =3D (RegionImpl) regionManager.getRegion("/a/b", t= rue); - LRUAlgorithmConfig config =3D (LRUAlgorithmConfig) region.getEvictio= nRegionConfig().getEvictionAlgorithmConfig(); = config.setMaxAge(1000000); config.setMaxNodes(0); @@ -400,5 +379,4 @@ { System.out.println("-- " + msg); } - -} +} \ No newline at end of file Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfiguratio= nTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.= java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.= java 2008-08-18 13:34:16 UTC (rev 6574) @@ -7,6 +7,7 @@ package org.jboss.cache.eviction; = import org.jboss.cache.config.ConfigurationException; +import org.jboss.cache.config.EvictionConfig; import org.jboss.cache.config.parsing.XmlConfigHelper; import org.jboss.cache.config.parsing.element.EvictionElementParser; import static org.testng.AssertJUnit.assertEquals; @@ -30,15 +31,16 @@ String xml =3D "\n" + "5000\n" + - "1000\n" + + "1000\n" + ""; = Element element =3D XmlConfigHelper.stringToElementInCoreNS(xml); = - EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); + EvictionElementParser.parseEvictionPolicyConfig(element, config); + config.validate(); = assertEquals(5000, config.getMaxNodes()); - assertEquals(1000000, config.getTimeToLive()); + assertEquals(1000, config.getTimeToLive()); } = public void testXMLParsing2() throws Exception @@ -46,46 +48,36 @@ LRUAlgorithmConfig config =3D new LRUAlgorithmConfig(); String xml =3D "\n" + "10000\n" + - "8\n" + - "10\n" + + "1000\n" + + "10\n" + ""; Element element =3D XmlConfigHelper.stringToElementInCoreNS(xml); = - EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); + EvictionElementParser.parseEvictionPolicyConfig(element, config); + config.validate(); = assertEquals(10000, config.getMaxNodes()); - assertEquals(8000, config.getTimeToLive()); - assertEquals(10000, config.getMaxAge()); + assertEquals(1000, config.getTimeToLive()); + assertEquals(10, config.getMaxAge()); } = public void testXMLParsing3() throws Exception { - LRUAlgorithmConfig config =3D new LRUAlgorithmConfig(); - String xml =3D "\n" + + String xml =3D "\n" + "10000\n" + - "10\n" + - ""; + "10\n" + + ""; Element element =3D XmlConfigHelper.stringToElementInCoreNS(xml); boolean caught =3D false; try { - EvictionElementParser.parseEvictionPolicyConfig(element, config, = true); + EvictionConfig ec =3D new EvictionElementParser().parseEvictionEl= ement(element); + ec.getEvictionRegionConfigs().get(0).validate(); } catch (ConfigurationException ce) { caught =3D true; } assertTrue("Configure exception should have been caught", caught); - - xml =3D "\n" + - "8\n" + - "10\n" + - ""; - - element =3D XmlConfigHelper.stringToElementInCoreNS(xml); - - EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); - - assertEquals(0, config.getMaxNodes()); } } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java 20= 08-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java 20= 08-08-18 13:34:16 UTC (rev 6574) @@ -1,7 +1,6 @@ package org.jboss.cache.eviction; = = -import org.jboss.cache.Cache; import org.jboss.cache.CacheSPI; import org.jboss.cache.DefaultCacheFactory; import org.jboss.cache.Fqn; @@ -12,6 +11,8 @@ import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; import org.jboss.cache.lock.IsolationLevel; import org.jboss.cache.util.TestingUtil; +import org.jboss.cache.util.internals.EvictionController; +import org.jboss.cache.util.internals.EvictionWatcher; import static org.testng.AssertJUnit.*; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; @@ -19,6 +20,7 @@ = import java.util.ArrayList; import java.util.List; +import java.util.concurrent.TimeUnit; = /** * Unit tests for LRU Policy. @@ -28,27 +30,30 @@ * @version $Revision$ */ @Test(groups =3D "functional") -public class LRUPolicyTest +public class LRUPolicyTest extends EvictionTestsBase { CacheSPI cache; - long wakeupIntervalMillis =3D 0; - long dataRegionTTLMillis =3D 6000; - long testRegionTTLMillis =3D 4000; + long wakeupIntervalMillis =3D 200; + long dataRegionTTLMillis =3D 200; + long testRegionTTLMillis =3D 200; + private int baseRegionMaxNodes =3D 10; + private int baseRegionTTLMillis =3D 200; = final String ROOT_STR =3D "/test"; Throwable t1_ex, t2_ex; - final long DURATION =3D 10000; boolean isTrue; = + @BeforeMethod(alwaysRun =3D true) public void setUp() throws Exception { Configuration conf =3D UnitTestCacheConfigurationFactory.createConfi= guration(Configuration.CacheMode.LOCAL, true); EvictionConfig evConfig =3D conf.getEvictionConfig(); - evConfig.setWakeupInterval(1000); + evConfig.setWakeupInterval(wakeupIntervalMillis); List regionConfigs =3D new ArrayList(); - regionConfigs.add(new EvictionRegionConfig(Fqn.fromString("/org/jbos= s/test/data"), new LRUAlgorithmConfig(dataRegionTTLMillis, 5))); + regionConfigs.add(new EvictionRegionConfig(Fqn.fromString("/org/jbos= s/test/data"), new LRUAlgorithmConfig(dataRegionTTLMillis, -1, 5))); regionConfigs.add(new EvictionRegionConfig(Fqn.fromString("/test"), = new LRUAlgorithmConfig(testRegionTTLMillis, 10000))); + regionConfigs.add(new EvictionRegionConfig(Fqn.fromString("/base"), = new LRUAlgorithmConfig(baseRegionTTLMillis, -1, baseRegionMaxNodes))); evConfig.setEvictionRegionConfigs(regionConfigs); conf.setTransactionManagerLookupClass("org.jboss.cache.transaction.D= ummyTransactionManagerLookup"); conf.setIsolationLevel(IsolationLevel.SERIALIZABLE); @@ -93,7 +98,7 @@ cache.put(fqn, str, str); } = - TestingUtil.sleepThread(wakeupIntervalMillis + 500); + new EvictionController(cache).startEviction(); = for (int i =3D 0; i < 5; i++) { @@ -139,7 +144,7 @@ assertNull("Node should be empty ", val); } = - public void testNodeVisited() + public void testNodeVisited() throws InterruptedException { String rootStr =3D "/org/jboss/test/data/"; = @@ -152,26 +157,17 @@ cache.put(fqn, str, str); } = - long period =3D (wakeupIntervalMillis / 2 + 500); - System.out.println("-- sleeping for " + period + "ms"); - TestingUtil.sleepThread(period); String str =3D rootStr + "7"; Fqn fqn =3D Fqn.fromString(str); cache.get(fqn, str);// just to keep it fresh - System.out.println("-- sleeping for " + period + "ms"); - TestingUtil.sleepThread(period); cache.get(fqn, str);// just to keep it fresh - System.out.println("-- sleeping for " + period + "ms"); - TestingUtil.sleepThread(period); + assert waitForEviction(cache, 30, TimeUnit.SECONDS, Fqn.fromString(r= ootStr + 3)); String val =3D (String) cache.get(rootStr + "3", rootStr + "3"); - System.out.println("-- val=3D" + val); assertNull("Node should be empty ", val); val =3D (String) cache.get(rootStr + "7", rootStr + "7"); - System.out.println("-- val=3D" + val); assertNotNull("Node should not be empty ", val); - period =3D dataRegionTTLMillis + wakeupIntervalMillis + 500; // this= is the TTL for nodes + time for the eviction thread to kick in - System.out.println("-- sleeping for " + period + "ms"); - TestingUtil.sleepThread(period); + new EvictionController(cache).startEviction(true); + assert waitForEviction(cache, 30, TimeUnit.SECONDS, Fqn.fromString(r= ootStr + 7)); val =3D (String) cache.get(rootStr + "7", rootStr + "7"); System.out.println("-- val=3D" + val); assertNull("Node should be empty ", val); @@ -187,23 +183,21 @@ cache.put(fqn, str, str); } = - long period =3D (wakeupIntervalMillis / 2 + 500); - System.out.println("-- period is " + period); - // TestingUtil.sleepThread(period); // it really depends the e= viction thread time. String str1 =3D rootStr + "7"; Fqn fqn1 =3D Fqn.fromString(str1); String str2 =3D rootStr + "7/7"; Fqn fqn2 =3D Fqn.fromString(str2); cache.get(fqn1, str1);// just to keep it fresh cache.get(fqn2, str2);// just to keep it fresh - TestingUtil.sleepThread(period); + new EvictionController(cache).startEviction(); cache.get(fqn1, str1);// just to keep it fresh cache.get(fqn2, str2);// just to keep it fresh - TestingUtil.sleepThread(period); + new EvictionController(cache).startEviction(); String val =3D (String) cache.get(rootStr + "7/7", rootStr + "7/7"); assertNotNull("Node should not be empty ", val); cache.removeNode(fqn1); TestingUtil.sleepThread(wakeupIntervalMillis + 500); + new EvictionController(cache).startEviction(); val =3D (String) cache.get(rootStr + "7/7", rootStr + "7/7"); assertNull("Node should be empty ", val); } @@ -288,8 +282,8 @@ } System.out.println("-- nodes/locks: " + cache.getNumberOfNodes() = + "/" + cache.getNumberOfLocksHeld()); TestingUtil.sleepThread(1000); - if (counter > 10) - {// run for 10 seconds + if (counter > 5) + {// run for 5 seconds isTrue =3D false; break; } @@ -333,19 +327,22 @@ = public void testOvereviction() throws Exception { - Configuration c =3D UnitTestCacheConfigurationFactory.createConfigur= ation(Configuration.CacheMode.LOCAL, true); - Cache cache1 =3D new DefaultCacheFactory().createCache(c, true); - cache1.put(Fqn.fromString("/base/" + 0), "key", "base" + 0); - Node node =3D cache1.getRoot().getChild(Fqn.fromString("/base/")); + Node node =3D cache.getRoot().addChild(Fqn.fromString("/base/")); node.setResident(true); - cache1.getRoot().setResident(true); + cache.getRoot().setResident(true); = - for (int i =3D 1; i < 5100; i++) + EvictionWatcher ew =3D new EvictionWatcher(cache, Fqn.fromString("/b= ase/1")); + + for (int i =3D 1; i < baseRegionMaxNodes + 2; i++) { - cache1.put(Fqn.fromString("/base/" + i), "key", "base" + i); + Fqn f =3D Fqn.fromString("/base/" + i); + cache.put(f, "key", "base" + i); } - Thread.sleep(5000); - assertEquals(5000, cache1.getRoot().getChild(Fqn.fromString("/base")= ).getChildren().size()); = + new EvictionController(cache).startEviction(); + assert ew.waitForEviction(30, TimeUnit.SECONDS); + + assertEquals(baseRegionMaxNodes, cache.getRoot().getChild(Fqn.fromSt= ring("/base")).getChildren().size()); + } } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/MRUAlgorithmTes= t.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/MRUAlgorithmTest.java= 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/MRUAlgorithmTest.java= 2008-08-18 13:34:16 UTC (rev 6574) @@ -7,12 +7,9 @@ package org.jboss.cache.eviction; = import org.jboss.cache.Fqn; -import org.jboss.cache.Region; import org.jboss.cache.RegionImpl; import org.jboss.cache.RegionManager; import org.jboss.cache.RegionManagerImpl; -import org.jboss.cache.RegionRegistry; -import org.jboss.cache.config.EvictionRegionConfig; import static org.testng.AssertJUnit.*; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -24,7 +21,7 @@ * @version $Revision$ */ @Test(groups =3D {"functional"}) -public class MRUAlgorithmTest +public class MRUAlgorithmTest extends EvictionTestsBase { MRUAlgorithm algorithm; RegionManager regionManager; @@ -32,15 +29,10 @@ @BeforeMethod(alwaysRun =3D true) public void setUp() throws Exception { - algorithm =3D new MRUAlgorithm(); + regionManager =3D new RegionManagerImpl(); MRUAlgorithmConfig config =3D new MRUAlgorithmConfig(); - // We have to set maxNodes explicitly!! config.setMaxNodes(0); -// config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName()); - regionManager =3D new RegionManagerImpl(); - ((RegionManagerImpl) regionManager).injectDependencies(null, null, n= ull, null, null, new RegionRegistry()); - Region r =3D regionManager.getRegion("/a/b", true); - r.setEvictionRegionConfig(new EvictionRegionConfig(r.getFqn(), confi= g)); + algorithm =3D (MRUAlgorithm) createAndAssignToRegion("/a/b", regionM= anager, config); } = public void testMaxNodes() throws Exception @@ -101,7 +93,7 @@ region.registerEvictionEvent(fqn9, EvictionEvent.Type.ADD_NODE_EVENT= ); region.registerEvictionEvent(fqn10, EvictionEvent.Type.ADD_NODE_EVEN= T); = - Thread.sleep(5000); +// Thread.sleep(5000); assertEquals(8, algorithm.getEvictionQueue().getNumberOfNodes()); = region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); Modified: core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfiguratio= nTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.= java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.= java 2008-08-18 13:34:16 UTC (rev 6574) @@ -40,7 +40,8 @@ ""; Element element =3D XmlConfigHelper.stringToElementInCoreNS(xml); = - EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); + EvictionElementParser.parseEvictionPolicyConfig(element, config); + config.validate(); = assertEquals(5000, config.getMaxNodes()); } @@ -52,7 +53,8 @@ ""; Element element =3D XmlConfigHelper.stringToElementInCoreNS(xml); = - EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); + EvictionElementParser.parseEvictionPolicyConfig(element, config); + config.validate(); = assertEquals(10000, config.getMaxNodes()); } @@ -65,7 +67,8 @@ boolean caught =3D false; try { - EvictionElementParser.parseEvictionPolicyConfig(element, config, = true); + EvictionElementParser.parseEvictionPolicyConfig(element, config); + config.validate(); } catch (ConfigurationException ce) { @@ -79,7 +82,8 @@ = element =3D XmlConfigHelper.stringToElementInCoreNS(xml); = - EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); + EvictionElementParser.parseEvictionPolicyConfig(element, config); + config.validate(); = assertEquals(10000, config.getMaxNodes()); } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/MRUPolicyTest.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/MRUPolicyTest.java 20= 08-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/MRUPolicyTest.java 20= 08-08-18 13:34:16 UTC (rev 6574) @@ -34,7 +34,6 @@ long wakeupIntervalMillis =3D 0; final String ROOT_STR =3D "/test"; Throwable t1_ex, t2_ex; - final long DURATION =3D 10000; boolean isTrue; = @BeforeMethod(alwaysRun =3D true) @@ -62,10 +61,9 @@ { Configuration config =3D UnitTestCacheConfigurationFactory.createCon= figuration(Configuration.CacheMode.LOCAL, true); EvictionConfig evConfig =3D config.getEvictionConfig(); - evConfig.setWakeupInterval(3000); - evConfig.setDefaultEventQueueSize(200000); + evConfig.setWakeupInterval(200); // root ERC - evConfig.setDefaultEvictionRegionConfig(new EvictionRegionConfig(Fqn= .ROOT, new MRUAlgorithmConfig(100))); + evConfig.setDefaultEvictionRegionConfig(new EvictionRegionConfig(Fqn= .ROOT, new MRUAlgorithmConfig(100), 200000)); // new region ERC evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromSt= ring("/org/jboss/test/data"), new MRUAlgorithmConfig(6))); = @@ -176,8 +174,8 @@ } log("nodes/locks: " + cache.getNumberOfNodes() + "/" + cache.getN= umberOfLocksHeld()); TestingUtil.sleepThread(1000); - if (counter > 10) - {// run for 10 seconds + if (counter > 5) + {// run for 5 seconds isTrue =3D false; break; } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionCon= figTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTes= t.java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTes= t.java 2008-08-18 13:34:16 UTC (rev 6574) @@ -43,6 +43,7 @@ { Element element =3D XmlConfigHelper.stringToElementInCoreNS(xml); NullEvictionAlgorithmConfig config =3D new NullEvictionAlgorithmConf= ig(); - EvictionElementParser.parseEvictionPolicyConfig(element, config, tru= e); + EvictionElementParser.parseEvictionPolicyConfig(element, config); + config.validate(); } } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionPol= icyTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionPolicyTes= t.java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionPolicyTes= t.java 2008-08-18 13:34:16 UTC (rev 6574) @@ -10,15 +10,19 @@ import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; import org.jboss.cache.lock.IsolationLevel; import org.jboss.cache.transaction.DummyTransactionManagerLookup; -import org.jboss.cache.util.TestingUtil; +import org.jboss.cache.util.internals.EvictionWatcher; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNull; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + @Test(groups =3D {"functional"}) -public class NullEvictionPolicyTest +public class NullEvictionPolicyTest extends EvictionTestsBase { CacheSPI cache; = @@ -45,11 +49,10 @@ * eviction thread to kick in, checks that nothing was evicted from the * null policy regions but was from lru region. */ - public void testEviction() + public void testEviction() throws InterruptedException { Configuration config =3D UnitTestCacheConfigurationFactory.createCon= figuration(Configuration.CacheMode.LOCAL, true); - EvictionConfig evConfig =3D new EvictionConfig(new EvictionRegionCon= fig(Fqn.ROOT, new NullEvictionAlgorithmConfig()), 1000); - evConfig.setDefaultEventQueueSize(200000); + EvictionConfig evConfig =3D new EvictionConfig(new EvictionRegionCon= fig(Fqn.ROOT, new NullEvictionAlgorithmConfig(), 200000), 200); evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromSt= ring("/test"), new NullEvictionAlgorithmConfig())); evConfig.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromSt= ring("/lru"), new LRUAlgorithmConfig(1000, 10000))); config.setEvictionConfig(evConfig); @@ -61,6 +64,9 @@ String testRootStr =3D "/test/"; String lruRootStr =3D "/lru/"; = + List toBeEvicted =3D new ArrayList(); + for (int i =3D 0; i < 20; i++) toBeEvicted.add(Fqn.fromString(lruRoo= tStr + i)); + EvictionWatcher watcher =3D new EvictionWatcher(cache, toBeEvicted); for (int i =3D 0; i < 20; i++) { Fqn dflt =3D Fqn.fromString(dfltRootStr + i); @@ -70,7 +76,9 @@ cache.put(test, "key", "value"); cache.put(lru, "key", "value"); } - TestingUtil.sleepThread(3500); + + assert watcher.waitForEviction(30, TimeUnit.SECONDS); + for (int i =3D 0; i < 20; i++) { Fqn dflt =3D Fqn.fromString(dfltRootStr + i); Modified: core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvict= ionTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTes= t.java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTes= t.java 2008-08-18 13:34:16 UTC (rev 6574) @@ -8,17 +8,17 @@ import org.jboss.cache.config.EvictionRegionConfig; import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; import org.jboss.cache.interceptors.EvictionInterceptor; -import org.jboss.cache.transaction.DummyTransactionManagerLookup; import org.jboss.cache.util.TestingUtil; +import org.jboss.cache.util.internals.EvictionController; import static org.testng.AssertJUnit.assertFalse; import static org.testng.AssertJUnit.assertTrue; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = -import javax.transaction.TransactionManager; import java.util.Iterator; import java.util.List; +import java.util.concurrent.TimeUnit; = /** * Tests the eviction and the possible lack of locking nodes. @@ -29,22 +29,13 @@ * @author fhenning */ @Test(groups =3D {"functional"}) -public class OptimisticEvictionTest +public class OptimisticEvictionTest extends EvictionTestsBase { - - //Maximum number of runs 2^20 - private static final int NUMBER_OF_RUNS =3D 1 << 20; - //Initial number of nodes - private static final int NUMBER_NODES =3D 256; - - private Fqn region =3D Fqn.fromElements("testingRegion"); - private TransactionManager txManager; private CacheSPI cache; = @BeforeMethod(alwaysRun =3D true) public void setUp() throws Exception { - txManager =3D new DummyTransactionManagerLookup().getTransactionMana= ger(); Configuration config =3D UnitTestCacheConfigurationFactory.createCon= figuration(Configuration.CacheMode.LOCAL, true); config.setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMIST= IC); config.setEvictionConfig(buildEvictionConfig()); @@ -53,59 +44,24 @@ = private EvictionConfig buildEvictionConfig() throws Exception { - EvictionConfig result =3D new EvictionConfig(new EvictionRegionConfi= g(Fqn.ROOT, new LRUAlgorithmConfig(0, 0, 10)), 1000); + EvictionConfig result =3D new EvictionConfig(new EvictionRegionConfi= g(Fqn.ROOT, new LRUAlgorithmConfig(0, 0, 10)), 200); result.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromStri= ng("/testingRegion"), new LRUAlgorithmConfig(0, 0, 10))); - result.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromStri= ng("/timeBased"), new LRUAlgorithmConfig(1000, 1000, 10))); + result.addEvictionRegionConfig(new EvictionRegionConfig(Fqn.fromStri= ng("/timeBased"), new LRUAlgorithmConfig(1, 1, 0))); return result; } = @AfterMethod(alwaysRun =3D true) public void tearDown() throws Exception { - if (cache !=3D null) - { - // shut down any existing gtx2EntryMap - try - { - if (cache.getTransactionManager().getTransaction() !=3D null) - { - cache.getTransactionManager().rollback(); - } - } - catch (Exception e) - { - // ignore - } - cache.stop(); - cache =3D null; - } + TestingUtil.killCaches(cache); } = - - public void testEvictionError() throws Exception - { - //Initialize the cache via a map - for (int i =3D 0; i < NUMBER_NODES; i++) - { - cache.put(Fqn.fromRelativeElements(region, i), i, i); - } - - for (int i =3D 0; i < NUMBER_OF_RUNS; i++) - { - txManager.begin(); - cache.get(region, i % NUMBER_NODES); - txManager.commit(); - } - } - - public void testEvictionOccurence() throws Exception { cache.put("/timeBased/test", "key", "value"); assertTrue(cache.exists("/timeBased/test")); - - // wait for it to be evicted. - TestingUtil.sleepThread(3000); + new EvictionController(cache).startEviction(); +// assert waitForEviction(cache, 30, TimeUnit.SECONDS, Fqn.fromString= ("/timeBased/test")); assertTrue(!cache.exists("/timeBased/test")); } = @@ -140,8 +96,10 @@ = // Give eviction time to run a few times, then confirm parent // is completely gone - TestingUtil.sleepThread(5500); + assert waitForEviction(cache, 30, TimeUnit.SECONDS, parent); + // wait for this twice since the first time will only clear the pare= nt's contents since a child exists. + assert waitForEviction(cache, 30, TimeUnit.SECONDS, parent); + assertFalse("Parent completely removed", cache.getRoot().hasChild(pa= rent)); } - } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRU= PolicyTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicy= Test.java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicy= Test.java 2008-08-18 13:34:16 UTC (rev 6574) @@ -34,12 +34,13 @@ import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; import org.jboss.cache.lock.IsolationLevel; import org.jboss.cache.transaction.DummyTransactionManagerLookup; -import org.jboss.cache.util.TestingUtil; import static org.testng.AssertJUnit.*; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = +import java.util.concurrent.TimeUnit; + /** * Unit tests for programmatic configuration of LRU policy * @@ -47,7 +48,7 @@ * @version $Revision$ */ @Test(groups =3D {"functional"}) -public class ProgrammaticLRUPolicyTest +public class ProgrammaticLRUPolicyTest extends EvictionTestsBase { CacheSPI cache; long wakeupIntervalMillis =3D 0; @@ -70,7 +71,7 @@ Configuration conf =3D UnitTestCacheConfigurationFactory.createConfi= guration(Configuration.CacheMode.LOCAL, true); CacheFactory instance =3D new DefaultCacheFactory(); cache =3D (CacheSPI) instance.createCache(conf, fals= e); - EvictionConfig erc =3D new EvictionConfig(new EvictionRegionConfig(F= qn.ROOT, new LRUAlgorithmConfig(0, 0, 10)), 5000); + EvictionConfig erc =3D new EvictionConfig(new EvictionRegionConfig(F= qn.ROOT, new LRUAlgorithmConfig(0, 0, 10)), 200); conf.setEvictionConfig(erc); cache.getConfiguration().setTransactionManagerLookupClass(DummyTrans= actionManagerLookup.class.getName()); cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZAB= LE); @@ -87,7 +88,7 @@ = private void addStringBasedRegion() throws Exception { - LRUAlgorithmConfig lru =3D new LRUAlgorithmConfig(4000, 0, 1000); + LRUAlgorithmConfig lru =3D new LRUAlgorithmConfig(150, 0, 1000); EvictionRegionConfig regConfig =3D new EvictionRegionConfig(Fqn.from= String("/dummy"), lru); = RegionManager regionManager =3D cache.getRegionManager(); @@ -114,7 +115,7 @@ assertNotNull("DataNode should be empty ", val); = System.out.println(cache.toString()); - TestingUtil.sleepThread(2 * wakeupIntervalMillis + 500); + assert waitForEviction(cache, 30, TimeUnit.SECONDS, Fqn.fromString(r= ootStr + 3)); System.out.println(cache.toString()); val =3D (String) cache.get(rootStr + "3", rootStr + "3"); assertNull("DataNode should be empty ", val); @@ -122,7 +123,7 @@ = private void addObjectBasedRegion() throws Exception { - LRUAlgorithmConfig lru =3D new LRUAlgorithmConfig(4000, 1000); + LRUAlgorithmConfig lru =3D new LRUAlgorithmConfig(150, 1000); EvictionRegionConfig regConfig =3D new EvictionRegionConfig(Fqn.from= Elements(1), lru); = RegionManager regionManager =3D cache.getRegionManager(); @@ -167,7 +168,7 @@ } = System.out.println(cache.toString()); - TestingUtil.sleepThread(2 * wakeupIntervalMillis + 500); + assert waitForEviction(cache, 30, TimeUnit.SECONDS, fqn); System.out.println(cache.toString()); = try @@ -215,13 +216,14 @@ fail("Failed to get" + e); } = + Integer in =3D 3; + Fqn fqn =3D Fqn.fromRelativeElements(rootfqn, in); System.out.println(cache.toString()); - TestingUtil.sleepThread(2 * wakeupIntervalMillis + 500); + assert waitForEviction(cache, 30, TimeUnit.SECONDS, fqn); + System.out.println(cache.toString()); try { - Integer in =3D 3; - Fqn fqn =3D Fqn.fromRelativeElements(rootfqn, in); Object val =3D cache.get(fqn, in); assertNull("DataNode should be empty ", val); } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/RegionTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/RegionTest.java 2008-= 08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/RegionTest.java 2008-= 08-18 13:34:16 UTC (rev 6574) @@ -32,7 +32,7 @@ regionManager =3D new RegionManagerImpl(); ((RegionManagerImpl) regionManager).injectDependencies(null, null, n= ull, null, null, new RegionRegistry()); Region r =3D regionManager.getRegion("/a/b", true);//.setEvictionPol= icy(new DummyEvictionConfiguration()); - r.setEvictionRegionConfig(new EvictionRegionConfig(r.getFqn(), new N= ullEvictionAlgorithmConfig())); + r.setEvictionRegionConfig(new EvictionRegionConfig(r.getFqn(), new L= RUAlgorithmConfig())); } = public void testAddedQueue() throws InterruptedException @@ -46,7 +46,7 @@ region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT= ); region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT= ); = - assertEquals("AddedNode queue size ", 3, getQueueSize((RegionImpl) r= egion)); + assertEquals("queue size ", 3, getQueueSize((RegionImpl) region)); EvictionEvent node =3D takeLastEvent((RegionImpl) region); Fqn fqn =3D node.getFqn(); assertEquals("DataNode retrieved should be FILO ", fqn, fqn1); Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPo= licyTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTe= st.java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTe= st.java 2008-08-18 13:34:16 UTC (rev 6574) @@ -10,19 +10,23 @@ import org.jboss.cache.notifications.event.Event; import org.jboss.cache.transaction.DummyTransactionManagerLookup; import org.jboss.cache.util.TestingUtil; +import org.jboss.cache.util.internals.EvictionController; +import org.jboss.cache.util.internals.EvictionWatcher; import static org.testng.AssertJUnit.*; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = +import java.util.concurrent.TimeUnit; + /** * @author Ben Wang, Feb 11, 2004 */ @Test(groups =3D {"functional"}) -public class ReplicatedLRUPolicyTest +public class ReplicatedLRUPolicyTest extends EvictionTestsBase { CacheSPI cache1, cache2, cache3; - long wakeupIntervalMillis =3D 0; + long wakeupIntervalMillis =3D 200; EvictionListener listener =3D new EvictionListener(); = @BeforeMethod(alwaysRun =3D true) @@ -31,21 +35,17 @@ cache1 =3D (CacheSPI) new DefaultCacheFactory().createCache(UnitTestCacheConfigurationFactory.createConfigurati= on(CacheMode.REPL_SYNC, true), false); cache1.getConfiguration().setTransactionManagerLookupClass(DummyTran= sactionManagerLookup.class.getName()); cache1.getConfiguration().setUseRegionBasedMarshalling(true); + cache1.getConfiguration().getEvictionConfig().setWakeupInterval(wake= upIntervalMillis); + cache1.start(); cache1.getNotifier().addCacheListener(listener); listener.resetCounter(); = - cache3 =3D (CacheSPI) new DefaultCacheFactory().createCache(UnitTestCacheConfigurationFactory.createConfigurati= on(CacheMode.REPL_SYNC), false); - cache3.getConfiguration().setTransactionManagerLookupClass("org.jbos= s.cache.transaction.DummyTransactionManagerLookup"); + cache3 =3D (CacheSPI) new DefaultCacheFactory().createCache(cache1.getConfiguration().clone(), false); + cache3.getConfiguration().setTransactionManagerLookupClass(DummyTran= sactionManagerLookup.class.getName()); cache3.getConfiguration().setUseRegionBasedMarshalling(true); + cache3.getConfiguration().getEvictionConfig().setWakeupInterval(wake= upIntervalMillis); cache3.start(); - - wakeupIntervalMillis =3D cache1.getConfiguration().getEvictionConfig= ().getWakeupInterval(); - log("wakeupInterval is " + wakeupIntervalMillis); - if (wakeupIntervalMillis <=3D 0) - { - fail("testEviction(): eviction thread wake up interval is illegal= " + wakeupIntervalMillis); - } } = @AfterMethod(alwaysRun =3D true) @@ -60,12 +60,16 @@ public void testBasic() throws Exception { String rootStr =3D "/org/jboss/test/data/"; + LRUAlgorithmConfig cfg =3D (LRUAlgorithmConfig) cache1.getConfigurat= ion().getEvictionConfig().getEvictionRegionConfig(rootStr).getEvictionAlgor= ithmConfig(); + cfg.setMaxAge(0); + cfg.setTimeToLive(0); String str =3D rootStr + "0"; + Fqn fqn =3D Fqn.fromString(str); cache1.put(str, str, str); - - TestingUtil.sleepThread(30000); - Object node =3D cache1.peek(Fqn.fromString(str), false); - assertNull("DataNode should be evicted already ", node); +// assert waitForEviction(cache1, 30, TimeUnit.SECONDS, fqn) : "Evict= ion event not received!"; + new EvictionController(cache1).startEviction(); + Object node =3D cache1.peek(fqn, false); + assertNull("Node should be evicted already ", node); assertEquals("Eviction counter ", 1, listener.getCounter()); String val =3D (String) cache3.get(str, str); assertNotNull("DataNode should not be evicted here ", val); @@ -75,6 +79,10 @@ public void testEviction() throws Exception { String rootStr =3D "/org/jboss/test/data/"; + LRUAlgorithmConfig cfg =3D (LRUAlgorithmConfig) cache3.getConfigurat= ion().getEvictionConfig().getEvictionRegionConfig(rootStr).getEvictionAlgor= ithmConfig(); + cfg.setMaxAge(60, TimeUnit.SECONDS); + cfg.setTimeToLive(360, TimeUnit.SECONDS); + EvictionWatcher ew =3D new EvictionWatcher(cache1, Fqn.fromString(ro= otStr + 3)); for (int i =3D 0; i < 10; i++) { String str =3D rootStr + i; @@ -82,7 +90,8 @@ cache1.put(fqn, str, str); } = - TestingUtil.sleepThread(2 * wakeupIntervalMillis); + assert ew.waitForEviction(30, TimeUnit.SECONDS); + String val =3D (String) cache1.get(rootStr + "3", rootStr + "3"); assertNull("DataNode should be evicted already ", val); val =3D (String) cache3.get(rootStr + "3", rootStr + "3"); @@ -92,6 +101,11 @@ public void testEvictionReplication() throws Exception { String rootStr =3D "/org/jboss/test/data/"; + LRUAlgorithmConfig cfg =3D (LRUAlgorithmConfig) cache3.getConfigurat= ion().getEvictionConfig().getEvictionRegionConfig(rootStr).getEvictionAlgor= ithmConfig(); + cfg.setMaxAge(60, TimeUnit.SECONDS); + cfg.setTimeToLive(360, TimeUnit.SECONDS); + EvictionWatcher ew =3D new EvictionWatcher(cache1, Fqn.fromString(ro= otStr + 3)); + for (int i =3D 0; i < 10; i++) { String str =3D rootStr + i; @@ -99,12 +113,12 @@ cache1.put(fqn, str, str); } = - TestingUtil.sleepThread(wakeupIntervalMillis - 1000); String str =3D rootStr + "7"; Fqn fqn =3D Fqn.fromString(str); cache1.get(fqn, str); - TestingUtil.sleepThread(wakeupIntervalMillis); = + assert ew.waitForEviction(30, TimeUnit.SECONDS); + String val =3D (String) cache1.get(rootStr + "3", rootStr + "3"); assertNull("DataNode should be empty ", val); val =3D (String) cache3.get(rootStr + "7", rootStr + "7"); Modified: core/trunk/src/test/java/org/jboss/cache/eviction/minttl/FIFOMinT= TLTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/minttl/FIFOMinTTLTest= .java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/minttl/FIFOMinTTLTest= .java 2008-08-18 13:34:16 UTC (rev 6574) @@ -16,10 +16,10 @@ { private Fqn fqn2 =3D Fqn.fromRelativeElements(region, "b"); private Thread busyThread; - private boolean busyThreadRunning =3D true; + private volatile boolean busyThreadRunning =3D true; = @Override - protected EvictionAlgorithmConfigBase getEvictionPolicyConfig() + protected EvictionAlgorithmConfigBase getEvictionAlgorithmConfig() { startBusyThread(); FIFOAlgorithmConfig cfg =3D new FIFOAlgorithmConfig(); @@ -33,6 +33,7 @@ busyThreadRunning =3D false; try { + busyThread.interrupt(); busyThread.join(); } catch (InterruptedException e) @@ -60,6 +61,7 @@ = while (busyThreadRunning) { + System.out.println("Busy thread working... "); cache.put(fqn2, "k", "v"); TestingUtil.sleepRandom(150); } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LFUMinTT= LTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LFUMinTTLTest.= java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LFUMinTTLTest.= java 2008-08-18 13:34:16 UTC (rev 6574) @@ -12,7 +12,7 @@ public class LFUMinTTLTest extends MinTTLTestBase { @Override - protected EvictionAlgorithmConfigBase getEvictionPolicyConfig() + protected EvictionAlgorithmConfigBase getEvictionAlgorithmConfig() { return new LFUAlgorithmConfig(); } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LRUMinTT= LTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LRUMinTTLTest.= java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/minttl/LRUMinTTLTest.= java 2008-08-18 13:34:16 UTC (rev 6574) @@ -12,10 +12,10 @@ public class LRUMinTTLTest extends MinTTLTestBase { @Override - protected EvictionAlgorithmConfigBase getEvictionPolicyConfig() + protected EvictionAlgorithmConfigBase getEvictionAlgorithmConfig() { LRUAlgorithmConfig cfg =3D new LRUAlgorithmConfig(); - cfg.setTimeToLive(1000); + cfg.setTimeToLive(200); return cfg; } } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MRUMinTT= LTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MRUMinTTLTest.= java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MRUMinTTLTest.= java 2008-08-18 13:34:16 UTC (rev 6574) @@ -17,7 +17,7 @@ private Fqn fqn2 =3D Fqn.fromRelativeElements(region, "b"); = @Override - protected EvictionAlgorithmConfigBase getEvictionPolicyConfig() + protected EvictionAlgorithmConfigBase getEvictionAlgorithmConfig() { MRUAlgorithmConfig cfg =3D new MRUAlgorithmConfig(); cfg.setMaxNodes(1); Modified: core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MinTTLTe= stBase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MinTTLTestBase= .java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MinTTLTestBase= .java 2008-08-18 13:34:16 UTC (rev 6574) @@ -6,12 +6,14 @@ import org.jboss.cache.config.EvictionConfig; import org.jboss.cache.config.EvictionRegionConfig; import org.jboss.cache.eviction.EvictionAlgorithmConfigBase; -import org.jboss.cache.util.TestingUtil; +import org.jboss.cache.eviction.EvictionTestsBase; +import org.jboss.cache.util.internals.EvictionController; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; = /** * This test exercises the minimum time to live for any element in the cac= he @@ -20,17 +22,17 @@ * @since 2.1.0 */ @Test(groups =3D {"functional"}) -public abstract class MinTTLTestBase +public abstract class MinTTLTestBase extends EvictionTestsBase { // this should ideally be in an eviction test base class so all evictio= n policies can be tested = - protected Cache cache; + protected Cache cache; protected Fqn region =3D Fqn.fromString("/test-region"); protected Fqn fqn =3D Fqn.fromRelativeElements(region, "a"); // allows the test methods to notify any support threads in subclasses = that data is in the cache and the test is about to begin - protected CountDownLatch cacheInitialisedLatch; + protected volatile CountDownLatch cacheInitialisedLatch; = - protected abstract EvictionAlgorithmConfigBase getEvictionPolicyConfig(= ); + protected abstract EvictionAlgorithmConfigBase getEvictionAlgorithmConf= ig(); = @BeforeMethod public void setUp() @@ -38,7 +40,7 @@ cacheInitialisedLatch =3D new CountDownLatch(1); = // the LRU policy cfg - EvictionAlgorithmConfigBase cfg =3D getEvictionPolicyConfig(); + EvictionAlgorithmConfigBase cfg =3D getEvictionAlgorithmConfig(); = // the region configuration EvictionRegionConfig regionCfg =3D new EvictionRegionConfig(); @@ -47,7 +49,7 @@ regionCfg.setEvictionAlgorithmConfig(cfg); // cache-wide EvictionConfig ec =3D new EvictionConfig(); - ec.setWakeupInterval(1000); + ec.setWakeupInterval(200); ec.addEvictionRegionConfig(regionCfg); = cache =3D new DefaultCacheFactory().createCache(fals= e); @@ -60,7 +62,7 @@ cache.stop(); } = - public void testNoMinimumTTL() + public void testNoMinimumTTL() throws InterruptedException { cache.start(); cache.put(fqn, "k", "v"); @@ -69,14 +71,14 @@ = assert cache.get(fqn, "k") !=3D null : "Node should be in the cache"; = - TestingUtil.sleepThread(3000); + assert waitForEviction(cache, 10, TimeUnit.SECONDS, fqn); = assert cache.get(fqn, "k") =3D=3D null : "Node should have been evic= ted"; } = - public void testWithMinimumTTL() + public void testWithMinimumTTL() throws InterruptedException { - ((EvictionAlgorithmConfigBase) cache.getConfiguration().getEvictionC= onfig().getEvictionRegionConfigs().get(0).getEvictionAlgorithmConfig()).set= MinTimeToLive(3000); + ((EvictionAlgorithmConfigBase) cache.getConfiguration().getEvictionC= onfig().getEvictionRegionConfigs().get(0).getEvictionAlgorithmConfig()).set= MinTimeToLive(500); = cache.start(); cache.put(fqn, "k", "v"); @@ -85,15 +87,15 @@ = assert cache.get(fqn, "k") !=3D null : "Node should be in the cache"; = - TestingUtil.sleepThread(3000); + new EvictionController(cache).startEviction(); = assert cache.get(fqn, "k") !=3D null : "Node should still be in cach= e due to a minTTL of 3 secs"; = // the last cache.get() would have updated the last modified tstamp = so we need to wait at least 3 secs (+1 sec maybe for the eviction thread) // to make sure this is evicted. + new EvictionController(cache).startEviction(true); + assert waitForEviction(cache, 5, TimeUnit.SECONDS, fqn); = - TestingUtil.sleepThread(5000); - assert cache.get(fqn, "k") =3D=3D null : "Node should have been evic= ted"; } = Modified: core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionC= ontroller.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionControl= ler.java 2008-08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionControl= ler.java 2008-08-18 13:34:16 UTC (rev 6574) @@ -24,12 +24,14 @@ public class EvictionController { CacheSPI cache; + RegionManager regionManager; EvictionTimerTask timerTask; + long originalWakeupInterval; = public EvictionController(Cache cache) { this.cache =3D (CacheSPI) cache; - RegionManager regionManager =3D this.cache.getRegionManager(); + regionManager =3D this.cache.getRegionManager(); if (regionManager =3D=3D null) { throw new IllegalStateException("Null region manager; is the cach= e started?"); @@ -40,10 +42,21 @@ throw new IllegalStateException("No timer task!!!"); } timerTask.stop(); + originalWakeupInterval =3D cache.getConfiguration().getEvictionConfi= g().getWakeupInterval(); } = public void startEviction() { + startEviction(false); + } + + /** + * Kick starts the eviction process + * + * @param restartEvictionTimerTask if true, restarts the eviction timer= scheduled executor after manually kicking off an eviction. + */ + public void startEviction(boolean restartEvictionTimerTask) + { try { Method method =3D EvictionTimerTask.class.getDeclaredMethod("proc= essRegions", new Class[]{}); @@ -55,6 +68,11 @@ e.printStackTrace(); throw new IllegalStateException(e); } + + if (restartEvictionTimerTask) + { + timerTask.init(originalWakeupInterval); + } } = /** Added: core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionWatc= her.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionWatcher= .java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionWatcher= .java 2008-08-18 13:34:16 UTC (rev 6574) @@ -0,0 +1,71 @@ +package org.jboss.cache.util.internals; + +import org.jboss.cache.Cache; +import org.jboss.cache.Fqn; +import org.jboss.cache.notifications.annotation.CacheListener; +import org.jboss.cache.notifications.annotation.NodeEvicted; +import org.jboss.cache.notifications.event.NodeEvictedEvent; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +/** + * Watches and waits for eviction events + * + * @author Manik Surtani (manik(a)jbo= ss.org) + * @since 3.0 + */ +(a)CacheListener +public class EvictionWatcher +{ + Cache cache; + List fqnsToWaitFor; + CountDownLatch latch; + + public EvictionWatcher(Cache cache, Fqn... fqnsToWaitFor) + { + this(cache, Arrays.asList(fqnsToWaitFor)); + } + + public EvictionWatcher(Cache cache, List fqnsToWaitFor) + { + this.cache =3D cache; + this.fqnsToWaitFor =3D new ArrayList(fqnsToWaitFor); + latch =3D new CountDownLatch(fqnsToWaitFor.size()); + cache.addCacheListener(this); + } + + @NodeEvicted + public void receive(NodeEvictedEvent ee) + { + boolean xpect =3D false; + if (ee.isPre() && fqnsToWaitFor.contains(ee.getFqn())) + { + xpect =3D true; + fqnsToWaitFor.remove(ee.getFqn()); + latch.countDown(); + } + + if (ee.isPre()) System.out.println("Saw " + ee.getFqn() + " was expe= cting? " + xpect); + } + + /** + * Blocks for an eviction event to happen on all the configured Fqns to= wait for. + * + * @return true if the eviction events occured, false if we timed out. + */ + public boolean waitForEviction(long timeout, TimeUnit unit) throws Inte= rruptedException + { + try + { + return latch.await(timeout, unit); + } + finally + { + cache.removeCacheListener(this); + } + } +} Modified: core/trunk/src/test/resources/configs/string-property-replaced.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/resources/configs/string-property-replaced.xml 2008= -08-18 10:32:47 UTC (rev 6573) +++ core/trunk/src/test/resources/configs/string-property-replaced.xml 2008= -08-18 13:34:16 UTC (rev 6574) @@ -1,11 +1,11 @@ - + - = + --===============6601722467409085966==-- From jbosscache-commits at lists.jboss.org Mon Aug 18 15:46:57 2008 Content-Type: multipart/mixed; boundary="===============4684815991454751371==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6575 - core/trunk/src/main/java/org/jboss/cache. Date: Mon, 18 Aug 2008 15:46:57 -0400 Message-ID: --===============4684815991454751371== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-18 15:46:56 -0400 (Mon, 18 Aug 2008) New Revision: 6575 Modified: core/trunk/src/main/java/org/jboss/cache/RegionImpl.java Log: Dont throw an exception Modified: core/trunk/src/main/java/org/jboss/cache/RegionImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/RegionImpl.java 2008-08-18 13:= 34:16 UTC (rev 6574) +++ core/trunk/src/main/java/org/jboss/cache/RegionImpl.java 2008-08-18 19:= 46:56 UTC (rev 6575) @@ -244,7 +244,7 @@ capacityWarnThreshold =3D (98 * size) / 100 - 100; if (capacityWarnThreshold <=3D 0) { - throw new RuntimeException("Capacity warn threshold used in ev= iction is smaller than 1."); + if (log.isWarnEnabled()) log.warn("Capacity warn threshold use= d in eviction is smaller than 1."); } evictionEventQueue =3D new LinkedBlockingQueue(siz= e); } --===============4684815991454751371==-- From jbosscache-commits at lists.jboss.org Mon Aug 18 16:05:39 2008 Content-Type: multipart/mixed; boundary="===============1719576005328327596==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6576 - in core/trunk/src: test/java/org/jboss/cache/config and 2 other directories. Date: Mon, 18 Aug 2008 16:05:38 -0400 Message-ID: --===============1719576005328327596== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-18 16:05:38 -0400 (Mon, 18 Aug 2008) New Revision: 6576 Modified: core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTest= .java core/trunk/src/test/java/org/jboss/cache/config/StringPropertyReplacemen= tTest.java core/trunk/src/test/java/org/jboss/cache/config/parsing/SampleConfigFile= sCorrectnessTest.java core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguration= ParserTest.java core/trunk/src/test/resources/configs/string-property-replaced.xml Log: Fixed more broken tests Modified: core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.ja= va =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java 200= 8-08-18 19:46:56 UTC (rev 6575) +++ core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java 200= 8-08-18 20:05:38 UTC (rev 6576) @@ -23,6 +23,9 @@ = import org.jboss.cache.Fqn; import org.jboss.cache.eviction.DefaultEvictionActionPolicy; +import org.jboss.cache.eviction.EvictionAlgorithm; +import org.jboss.cache.eviction.EvictionPolicy; +import org.jboss.cache.util.Util; = import java.util.LinkedList; import java.util.List; @@ -51,6 +54,8 @@ @Dynamic private List evictionRegionConfigs; private EvictionRegionConfig defaultEvictionRegionConfig; + @Deprecated + private String defaultEvictionPolicyClass; = public EvictionConfig() { @@ -115,7 +120,7 @@ @Deprecated public String getDefaultEvictionPolicyClass() { - throw new ConfigurationException("Please use getDefaultEvictionRegio= nConfig() instead."); + return defaultEvictionPolicyClass; } = /** @@ -124,7 +129,17 @@ @Deprecated public void setDefaultEvictionPolicyClass(String defaultEvictionPolicyC= lass) { - throw new ConfigurationException("Please use setDefaultEvictionRegio= nConfig() instead."); + try + { + EvictionPolicy policy =3D (EvictionPolicy) Util.getInstance(defau= ltEvictionPolicyClass); + EvictionAlgorithm ea =3D policy.getEvictionAlgorithm(); + defaultEvictionRegionConfig.setEvictionAlgorithmConfig(Util.getIn= stance(ea.getConfigurationClass())); + this.defaultEvictionPolicyClass =3D defaultEvictionPolicyClass; + } + catch (Exception e) + { + throw new ConfigurationException(e); + } } = /** Modified: core/trunk/src/test/java/org/jboss/cache/config/ConfigurationClon= ingTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTes= t.java 2008-08-18 19:46:56 UTC (rev 6575) +++ core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTes= t.java 2008-08-18 20:05:38 UTC (rev 6576) @@ -14,7 +14,7 @@ import org.jboss.cache.config.Configuration.CacheMode; import org.jboss.cache.config.Configuration.NodeLockingScheme; import org.jboss.cache.config.parsing.XmlConfigurationParser; -import org.jboss.cache.eviction.LRUPolicy; +import org.jboss.cache.eviction.LRUAlgorithmConfig; import static org.testng.AssertJUnit.*; import org.testng.annotations.Test; = @@ -61,7 +61,7 @@ = assertEquals(4, ec2.getDefaultEvictionRegionConfig().getEventQueu= eSize()); assertEquals(45000, ec2.getWakeupInterval()); - assertEquals(LRUPolicy.class.getName(), ec2.getDefaultEvictionPol= icyClass()); + assert ec2.getDefaultEvictionRegionConfig().getEvictionAlgorithmC= onfig() instanceof LRUAlgorithmConfig; = List ercs1 =3D ec1.getEvictionRegionConfigs= (); List ercs2 =3D ec2.getEvictionRegionConfigs= (); @@ -108,8 +108,8 @@ assertEquals(erc1.getRegionFqn(), erc2.getRegionFqn()); assertEquals(erc1.getEventQueueSize(), erc2.getEventQueueSize()); = - EvictionPolicyConfig epc1 =3D erc1.getEvictionPolicyConfig(); - EvictionPolicyConfig epc2 =3D erc2.getEvictionPolicyConfig(); + EvictionAlgorithmConfig epc1 =3D erc1.getEvictionAlgorithmConfig(); + EvictionAlgorithmConfig epc2 =3D erc2.getEvictionAlgorithmConfig(); = assertFalse(epc1 =3D=3D epc2); assertEquals(epc1, epc2); Modified: core/trunk/src/test/java/org/jboss/cache/config/StringPropertyRep= lacementTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/config/StringPropertyReplaceme= ntTest.java 2008-08-18 19:46:56 UTC (rev 6575) +++ core/trunk/src/test/java/org/jboss/cache/config/StringPropertyReplaceme= ntTest.java 2008-08-18 20:05:38 UTC (rev 6576) @@ -7,16 +7,12 @@ package org.jboss.cache.config; = = -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertTrue; - import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig; import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfi= g; import org.jboss.cache.config.Configuration.NodeLockingScheme; -import org.jboss.cache.eviction.LRUConfiguration; -import org.jboss.cache.eviction.LRUPolicy; import org.jboss.cache.config.parsing.XmlConfigurationParser; +import org.jboss.cache.eviction.LRUAlgorithmConfig; +import static org.testng.AssertJUnit.*; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -24,25 +20,25 @@ /** * Tests that string property replacement works properly when parsing * a config file. JBCACHE-1218 - * = + * * @author Brian Stansberry */ @Test(groups =3D {"functional"}) public class StringPropertyReplacementTest { public static final String STRING_REPLACED_FILE =3D "configs/string-pro= perty-replaced.xml"; - = + private static final String PROP_BASE =3D "test.property."; private static final String SYNC_COMMIT_PROP =3D PROP_BASE + "SyncCommi= tPhase"; private static final String NUM_BUDDIES_PROP =3D PROP_BASE + "BuddyRepl= icationConfig.numBuddies"; private static final String MAX_NODES_PROP =3D PROP_BASE + "EvictionPol= icyConfig.maxNodes"; private static final String BUDDY_POOL_PROP =3D PROP_BASE + "BuddyRepli= cationConfig.buddyPoolName"; - = + private String numBuddies; private String syncCommitPhase; private String maxNodes; private String buddyPoolName; - = + @BeforeMethod(alwaysRun =3D true) public void setUp() throws Exception { @@ -51,7 +47,7 @@ maxNodes =3D System.getProperty(MAX_NODES_PROP); buddyPoolName =3D System.getProperty(BUDDY_POOL_PROP); } - = + @AfterMethod(alwaysRun =3D true) public void tearDown() throws Exception { @@ -73,35 +69,35 @@ if (buddyPoolName =3D=3D null) System.clearProperty(BUDDY_POOL_PROP); else - System.setProperty(BUDDY_POOL_PROP, buddyPoolName); = + System.setProperty(BUDDY_POOL_PROP, buddyPoolName); } - = + public void testStringPropertyReplacement() throws Exception { System.setProperty(NUM_BUDDIES_PROP, "3"); System.setProperty(SYNC_COMMIT_PROP, "false"); System.setProperty(MAX_NODES_PROP, "1000"); System.setProperty(BUDDY_POOL_PROP, "replaced"); - = + Configuration cfg =3D new XmlConfigurationParser().parseFile(STRING_= REPLACED_FILE); - = + assertEquals(NodeLockingScheme.OPTIMISTIC, cfg.getNodeLockingScheme(= )); assertFalse(cfg.isSyncCommitPhase()); assertTrue(cfg.isSyncRollbackPhase()); assertEquals(15000, cfg.getLockAcquisitionTimeout()); String clusterCfg =3D cfg.getClusterConfig(); assertTrue(clusterCfg =3D=3D null || clusterCfg.length() =3D=3D 0); - = + EvictionConfig ec =3D cfg.getEvictionConfig(); - assertEquals(LRUPolicy.class.getName(), ec.getDefaultEvictionPolicyC= lass()); - EvictionRegionConfig erc =3D ec.getEvictionRegionConfigs().get(0); - LRUConfiguration epc =3D (LRUConfiguration) erc.getEvictionPolicyCon= fig(); + assert ec.getDefaultEvictionRegionConfig().getEvictionAlgorithmConfi= g() instanceof LRUAlgorithmConfig; + EvictionRegionConfig erc =3D ec.getDefaultEvictionRegionConfig(); + LRUAlgorithmConfig epc =3D (LRUAlgorithmConfig) erc.getEvictionAlgor= ithmConfig(); assertEquals(1000, epc.getMaxNodes()); - = + CacheLoaderConfig clc =3D cfg.getCacheLoaderConfig(); IndividualCacheLoaderConfig iclc =3D clc.getFirstCacheLoaderConfig(); assertEquals(System.getProperty("java.io.tmpdir"), iclc.getPropertie= s().get("location")); - = + BuddyReplicationConfig brc =3D cfg.getBuddyReplicationConfig(); assertTrue(brc.isEnabled()); assertEquals("replaced", brc.getBuddyPoolName()); Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/SampleCon= figFilesCorrectnessTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/config/parsing/SampleConfigFil= esCorrectnessTest.java 2008-08-18 19:46:56 UTC (rev 6575) +++ core/trunk/src/test/java/org/jboss/cache/config/parsing/SampleConfigFil= esCorrectnessTest.java 2008-08-18 20:05:38 UTC (rev 6576) @@ -21,17 +21,15 @@ */ package org.jboss.cache.config.parsing; = -import org.testng.annotations.Test; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.AfterTest; import org.apache.log4j.AppenderSkeleton; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.spi.LoggingEvent; -import org.jboss.cache.config.parsing.XmlConfigurationSchemaTest; -import org.jboss.cache.config.parsing.XmlConfigurationParser; -import org.jboss.cache.DefaultCacheFactory; import org.jboss.cache.Cache; +import org.jboss.cache.DefaultCacheFactory; +import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; = import java.io.File; import java.io.FilenameFilter; Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfig= urationParserTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParserTest.java 2008-08-18 19:46:56 UTC (rev 6575) +++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParserTest.java 2008-08-18 20:05:38 UTC (rev 6576) @@ -218,7 +218,7 @@ = EvictionRegionConfig second =3D regionConfigs.get(0); LRUAlgorithmConfig secondConfiguration =3D (LRUAlgorithmConfig) seco= nd.getEvictionAlgorithmConfig(); - assert secondConfiguration.getMaxAge() =3D=3D 0; + assert secondConfiguration.getMaxAge() =3D=3D -1; assert secondConfiguration.getTimeToLive() =3D=3D 1002; assert secondConfiguration.getMaxNodes() =3D=3D 0; = Modified: core/trunk/src/test/resources/configs/string-property-replaced.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/resources/configs/string-property-replaced.xml 2008= -08-18 19:46:56 UTC (rev 6575) +++ core/trunk/src/test/resources/configs/string-property-replaced.xml 2008= -08-18 20:05:38 UTC (rev 6576) @@ -1,6 +1,6 @@ + xmlns=3D"urn:jboss:jbosscache-core:config:3.0"> --===============1719576005328327596==-- From jbosscache-commits at lists.jboss.org Tue Aug 19 05:36:28 2008 Content-Type: multipart/mixed; boundary="===============4953131589661422954==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6577 - core/trunk/src/main/java/org/jboss/cache/config/parsing/element. Date: Tue, 19 Aug 2008 05:36:28 -0400 Message-ID: --===============4953131589661422954== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-19 05:36:28 -0400 (Tue, 19 Aug 2008) New Revision: 6577 Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/Eviction= ElementParser.java Log: Removed unnecessarily verbose logging Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/E= victionElementParser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/element/Evictio= nElementParser.java 2008-08-18 20:05:38 UTC (rev 6576) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/Evictio= nElementParser.java 2008-08-19 09:36:28 UTC (rev 6577) @@ -1,7 +1,5 @@ package org.jboss.cache.config.parsing.element; = -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.jboss.cache.config.ConfigurationException; import org.jboss.cache.config.EvictionAlgorithmConfig; import org.jboss.cache.config.EvictionConfig; @@ -30,11 +28,8 @@ */ public class EvictionElementParser extends XmlParserBase { - private static final Log log =3D LogFactory.getLog(EvictionElementParse= r.class); - public EvictionConfig parseEvictionElement(Element evictionElement) { - if (log.isTraceEnabled()) log.trace("Parsing eviction element " + Xm= lConfigHelper.toString(evictionElement)); EvictionConfig evictionConfig =3D new EvictionConfig(); String wakeUpInterval =3D getAttributeValue(evictionElement, "wakeUp= Interval"); if (existsAttribute(wakeUpInterval)) --===============4953131589661422954==-- From jbosscache-commits at lists.jboss.org Tue Aug 19 05:36:48 2008 Content-Type: multipart/mixed; boundary="===============5584411565264032111==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6578 - core/trunk/src/test/java/org/jboss/cache/api. Date: Tue, 19 Aug 2008 05:36:48 -0400 Message-ID: --===============5584411565264032111== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-19 05:36:47 -0400 (Tue, 19 Aug 2008) New Revision: 6578 Modified: core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java Log: Better teardown Modified: core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java 2008-08-= 19 09:36:28 UTC (rev 6577) +++ core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java 2008-08-= 19 09:36:47 UTC (rev 6578) @@ -58,8 +58,7 @@ @AfterMethod(alwaysRun =3D true) public void tearDown() { - if (cache1 !=3D null) cache1.stop(); - if (cache2 !=3D null) cache2.stop(); + TestingUtil.killCaches(cache1, cache2); } = protected void configure(Configuration c) --===============5584411565264032111==-- From jbosscache-commits at lists.jboss.org Tue Aug 19 05:37:15 2008 Content-Type: multipart/mixed; boundary="===============6290301761501212547==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6579 - core/trunk/src/main/java/org/jboss/cache/invocation. Date: Tue, 19 Aug 2008 05:37:15 -0400 Message-ID: --===============6290301761501212547== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-19 05:37:15 -0400 (Tue, 19 Aug 2008) New Revision: 6579 Modified: core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContex= t.java Log: Copy and reset to consider lazily initialized node map Modified: core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocatio= nContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationConte= xt.java 2008-08-19 09:36:47 UTC (rev 6578) +++ core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationConte= xt.java 2008-08-19 09:37:15 UTC (rev 6579) @@ -17,7 +17,7 @@ */ public class MVCCInvocationContext extends AbstractInvocationContext { - private Map lookedUpNodes =3D null; + private HashMap lookedUpNodes =3D null; private MVCCTransactionContext mvccTCtx; = @Override @@ -96,14 +96,19 @@ public void reset() { super.reset(); - lookedUpNodes.clear(); + if (lookedUpNodes !=3D null) + { + lookedUpNodes.clear(); + lookedUpNodes =3D null; + } } = + @SuppressWarnings("unchecked") public InvocationContext copy() { MVCCInvocationContext copy =3D new MVCCInvocationContext(); doCopy(copy); - copy.lookedUpNodes.putAll(lookedUpNodes); + if (lookedUpNodes !=3D null) copy.lookedUpNodes =3D (HashMap) lookedUpNodes.clone(); return copy; } } --===============6290301761501212547==-- From jbosscache-commits at lists.jboss.org Tue Aug 19 06:14:36 2008 Content-Type: multipart/mixed; boundary="===============7540154337284445836==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6580 - core/trunk/src/test/java/org/jboss/cache/eviction. Date: Tue, 19 Aug 2008 06:14:36 -0400 Message-ID: --===============7540154337284445836== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-19 06:14:35 -0400 (Tue, 19 Aug 2008) New Revision: 6580 Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest= .java core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTes= t.java Log: Fixed broken/brittle tests Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java 20= 08-08-19 09:37:15 UTC (rev 6579) +++ core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java 20= 08-08-19 10:14:35 UTC (rev 6580) @@ -74,6 +74,9 @@ cache.stop(); } = + /* THIS TEST NEEDS REWRITING + + public void testEviction() throws Exception { int numNodes =3D (int) ((maxNodesR1 * 2.6) - 1); @@ -122,7 +125,7 @@ private void revisit(List fqns) { for (Fqn fqn : fqns) cache.getNode(fqn); - } + }*/ = public void testNodeVisited() throws InterruptedException { Modified: core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvict= ionTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTes= t.java 2008-08-19 09:37:15 UTC (rev 6579) +++ core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTes= t.java 2008-08-19 10:14:35 UTC (rev 6580) @@ -60,6 +60,7 @@ { cache.put("/timeBased/test", "key", "value"); assertTrue(cache.exists("/timeBased/test")); + TestingUtil.sleepThread(1); new EvictionController(cache).startEviction(); // assert waitForEviction(cache, 30, TimeUnit.SECONDS, Fqn.fromString= ("/timeBased/test")); assertTrue(!cache.exists("/timeBased/test")); Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPo= licyTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTe= st.java 2008-08-19 09:37:15 UTC (rev 6579) +++ core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTe= st.java 2008-08-19 10:14:35 UTC (rev 6580) @@ -26,7 +26,7 @@ public class ReplicatedLRUPolicyTest extends EvictionTestsBase { CacheSPI cache1, cache2, cache3; - long wakeupIntervalMillis =3D 200; + long wakeupIntervalMillis =3D 500; EvictionListener listener =3D new EvictionListener(); = @BeforeMethod(alwaysRun =3D true) @@ -82,6 +82,7 @@ LRUAlgorithmConfig cfg =3D (LRUAlgorithmConfig) cache3.getConfigurat= ion().getEvictionConfig().getEvictionRegionConfig(rootStr).getEvictionAlgor= ithmConfig(); cfg.setMaxAge(60, TimeUnit.SECONDS); cfg.setTimeToLive(360, TimeUnit.SECONDS); + cfg.setMaxNodes(200); EvictionWatcher ew =3D new EvictionWatcher(cache1, Fqn.fromString(ro= otStr + 3)); for (int i =3D 0; i < 10; i++) { --===============7540154337284445836==-- From jbosscache-commits at lists.jboss.org Tue Aug 19 07:25:50 2008 Content-Type: multipart/mixed; boundary="===============8701238152108801191==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6581 - core/trunk/src/main/java/org/jboss/cache/buddyreplication. Date: Tue, 19 Aug 2008 07:25:49 -0400 Message-ID: --===============8701238152108801191== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-19 07:25:48 -0400 (Tue, 19 Aug 2008) New Revision: 6581 Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.j= ava Log: Adding defunct root should be local only Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyMa= nager.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.= java 2008-08-19 10:14:35 UTC (rev 6580) +++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.= java 2008-08-19 11:25:48 UTC (rev 6581) @@ -1074,7 +1074,11 @@ // where N is a number. Fqn defunctRoot =3D buddyFqnTransformer.getDeadBackupRoot(dataOwner); cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(= true); - Node defunctRootNode =3D cache.getRoot().addChild(defunctRoot); + cache.getInvocationContext().getOptionOverrides().setSkipCacheStatus= Check(true); + Node root =3D cache.getRoot(); + cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(= true); + cache.getInvocationContext().getOptionOverrides().setSkipCacheStatus= Check(true); + Node defunctRootNode =3D root.addChild(defunctRoot); SortedSet childrenNames =3D new TreeSet(defunctRootN= ode.getChildrenNames()); // will be naturally sorted. Integer childName =3D 1; = --===============8701238152108801191==-- From jbosscache-commits at lists.jboss.org Tue Aug 19 07:26:03 2008 Content-Type: multipart/mixed; boundary="===============8879475671792240311==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6582 - core/trunk/src/main/java/org/jboss/cache/interceptors. Date: Tue, 19 Aug 2008 07:26:03 -0400 Message-ID: --===============8879475671792240311== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-19 07:26:03 -0400 (Tue, 19 Aug 2008) New Revision: 6582 Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueInt= erceptor.java Log: Null chk Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledV= alueInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueIn= terceptor.java 2008-08-19 11:25:48 UTC (rev 6581) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueIn= terceptor.java 2008-08-19 11:26:03 UTC (rev 6582) @@ -19,6 +19,7 @@ = import java.io.IOException; import java.io.NotSerializableException; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -165,6 +166,11 @@ @SuppressWarnings("unchecked") protected Map wrapMap(Map m, Set marsh= alledValues, InvocationContext ctx) throws NotSerializableException { + if (m =3D=3D null) + { + if (trace) log.trace("Map is nul; returning an empty map."); + return Collections.emptyMap(); + } if (trace) log.trace("Wrapping map contents of argument " + m); Map copy =3D new HashMap(); for (Map.Entry me : m.entrySet()) --===============8879475671792240311==-- From jboss-qa-internal at redhat.com Tue Aug 19 15:12:12 2008 Content-Type: multipart/mixed; boundary="===============3158090224660578208==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23557?= Date: Tue, 19 Aug 2008 15:12:09 -0400 Message-ID: <687175073.261219173129512.JavaMail.hudson@hudson1.qa.atl2.redhat.com> --===============3158090224660578208== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/557/changes --===============3158090224660578208==-- From jboss-qa-internal at redhat.com Tue Aug 19 15:27:41 2008 Content-Type: multipart/mixed; boundary="===============1495949799115349701==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23423?= Date: Tue, 19 Aug 2008 15:27:38 -0400 Message-ID: <1756865677.281219174058686.JavaMail.hudson@hudson1.qa.atl2.redhat.com> --===============1495949799115349701== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/423/changes --===============1495949799115349701==-- From jbosscache-commits at lists.jboss.org Wed Aug 20 08:04:28 2008 Content-Type: multipart/mixed; boundary="===============9138503337063909694==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6583 - in core/trunk/src: main/java/org/jboss/cache/config and 7 other directories. Date: Wed, 20 Aug 2008 08:04:27 -0400 Message-ID: --===============9138503337063909694== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-20 08:04:27 -0400 (Wed, 20 Aug 2008) New Revision: 6583 Added: core/trunk/src/test/java/org/jboss/cache/config/parsing/Eviction2xto3xCo= mpatibilityTest.java Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguration= Parser2x.java core/trunk/src/main/java/org/jboss/cache/config/parsing/element/Eviction= ElementParser.java core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterce= ptor.java core/trunk/src/main/resources/config2to3.xslt core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransformer= Test.java core/trunk/src/test/resources/configs/conf2x/eviction-enabled-cache.xml Log: updated 2.x eviction parsing and .xslt to accomodate recent API changes Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-08-19= 11:26:03 UTC (rev 6582) +++ core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-08-20= 12:04:27 UTC (rev 6583) @@ -34,6 +34,7 @@ import org.jboss.cache.util.reflect.ReflectionUtil; import org.jboss.cache.jmx.annotations.ManagedOperation; import org.jboss.cache.jmx.annotations.ManagedAttribute; +import org.jboss.cache.jmx.annotations.MBean; import org.jgroups.Address; import org.jgroups.Channel; import org.jgroups.ChannelException; @@ -64,6 +65,7 @@ * * @author Manik Surtani (manik(a)jbo= ss.org) */ +(a)MBean (objectName =3D "RPCManager") = public class RPCManagerImpl implements RPCManager { private Channel channel; Modified: core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-08= -19 11:26:03 UTC (rev 6582) +++ core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-08= -20 12:04:27 UTC (rev 6583) @@ -714,16 +714,6 @@ if (evictionConfig.getDefaultEvictionRegionConfig().getEvictionAlgor= ithmConfig() !=3D null && !ercs.contains(evictionConfig.getDefaultEvictionRegionConfig()= )) // then the default is a real region too; not just a template for others ercs.add(0, evictionConfig.getDefaultEvictionRegionConfig()); -// if (needDefault) -// { -// // This may throw ConfigurationException if there is no default -// // eviction policy class -// EvictionRegionConfig dflt =3D evictionConfig.createDefaultEvict= ionRegionConfig(); -// ercs.add(0, dflt); // put it first -// // Need to pass this back into the evictionConfig so it knows -// // about the new region -// evictionConfig.setEvictionRegionConfigs(ercs); -// } = // create regions for the regions defined in the evictionConfig. // scan to be sure the _default_ region isn't added twice Modified: core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.ja= va =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java 200= 8-08-19 11:26:03 UTC (rev 6582) +++ core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java 200= 8-08-20 12:04:27 UTC (rev 6583) @@ -239,6 +239,7 @@ = if (defaultEventQueueSize !=3D that.defaultEventQueueSize) return fa= lse; if (wakeupInterval !=3D that.wakeupInterval) return false; + if (defaultEvictionRegionConfig !=3D null ? !defaultEvictionRegionCo= nfig.equals(that.defaultEvictionRegionConfig) : that.defaultEvictionRegionC= onfig !=3D null) return false; if (evictionRegionConfigs !=3D null ? !evictionRegionConfigs.equals(= that.evictionRegionConfigs) : that.evictionRegionConfigs !=3D null) return false; = Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfig= urationParser2x.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParser2x.java 2008-08-19 11:26:03 UTC (rev 6582) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParser2x.java 2008-08-20 12:04:27 UTC (rev 6583) @@ -9,19 +9,14 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.buddyreplication.NextMemberBuddyLocator; -import org.jboss.cache.config.BuddyReplicationConfig; import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig; -import org.jboss.cache.config.CacheLoaderConfig; import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfi= g.SingletonStoreConfig; -import org.jboss.cache.config.Configuration; -import org.jboss.cache.config.ConfigurationException; -import org.jboss.cache.config.EvictionConfig; -import org.jboss.cache.config.EvictionPolicyConfig; -import org.jboss.cache.config.EvictionRegionConfig; -import org.jboss.cache.config.MissingPolicyException; -import org.jboss.cache.eviction.EvictionPolicy; +import org.jboss.cache.config.*; +import org.jboss.cache.config.parsing.element.EvictionElementParser; +import org.jboss.cache.eviction.EvictionAlgorithm; import org.jboss.cache.util.FileLookup; import org.jboss.cache.util.Util; +import org.jboss.cache.RegionManagerImpl; import org.w3c.dom.Attr; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; @@ -29,11 +24,8 @@ import org.w3c.dom.NodeList; = import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; import java.util.Map.Entry; -import java.util.Properties; +import java.util.*; = /** * Reads in XMLconfiguration files and spits out a {@link org.jboss.cache.= config.Configuration} object. When deployed as a @@ -246,6 +238,7 @@ } catch (Exception e) { + if (log.isTraceEnabled()) log.trace(e.getMessage()); } finally { @@ -337,20 +330,22 @@ return null; } = - - private static EvictionConfig parseEvictionConfig(Element element) + @SuppressWarnings("unchecked") + static EvictionConfig parseEvictionConfig(Element element) { - EvictionConfig ec =3D new EvictionConfig(); + EvictionConfig evictionConfig =3D new EvictionConfig(); = if (element !=3D null) { // If they set the default eviction policy in the element, use th= at // in preference to the external attribute - String temp =3D XmlConfigHelper.getTagContents(element, - "policyClass", ATTR, NAME); + String temp =3D XmlConfigHelper.getTagContents(element, "policyCl= ass", ATTR, NAME); + String defaultEvPolicyClassName =3D null; if (temp !=3D null && temp.length() > 0) { - ec.setDefaultEvictionPolicyClass(temp); + defaultEvPolicyClassName =3D temp; + EvictionAlgorithmConfig eac =3D getEvictionAlgorithmConfig(tem= p); + evictionConfig.getDefaultEvictionRegionConfig().setEvictionAlg= orithmConfig(eac); } = temp =3D XmlConfigHelper.getTagContents(element, "wakeUpIntervalS= econds", ATTR, NAME); @@ -366,11 +361,10 @@ wakeupIntervalSeconds =3D EvictionConfig.WAKEUP_DEFAULT; } = - ec.setWakeupInterval(wakeupIntervalSeconds * 1000); + evictionConfig.setWakeupInterval(wakeupIntervalSeconds * 1000); = int eventQueueSize =3D 0; - temp =3D XmlConfigHelper.getTagContents(element, - "eventQueueSize", ATTR, NAME); + temp =3D XmlConfigHelper.getTagContents(element, "eventQueueSize"= , ATTR, NAME); = if (temp !=3D null) { @@ -382,7 +376,7 @@ eventQueueSize =3D EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT; } = - ec.getDefaultEvictionRegionConfig().setEventQueueSize(eventQueueS= ize); + evictionConfig.getDefaultEvictionRegionConfig().setEventQueueSize= (eventQueueSize); = NodeList list =3D element.getElementsByTagName(EvictionRegionConf= ig.REGION); if (list !=3D null && list.getLength() > 0) @@ -397,7 +391,16 @@ } try { - regionConfigs.add(parseEvictionRegionConfig((Element) no= de, ec.getDefaultEvictionPolicyClass(), eventQueueSize)); + EvictionRegionConfig evictionRegionConfig =3D parseEvict= ionRegionConfig((Element) node, defaultEvPolicyClassName, eventQueueSize); + if (!evictionRegionConfig.getRegionFqn().equals(RegionMa= nagerImpl.DEFAULT_REGION)) + { + regionConfigs.add(evictionRegionConfig); + } + else + { + evictionConfig.getDefaultEvictionRegionConfig().setEv= entQueueSize(evictionRegionConfig.getEventQueueSize()); + evictionConfig.getDefaultEvictionRegionConfig().setEv= ictionAlgorithmConfig(evictionRegionConfig.getEvictionAlgorithmConfig()); + } } catch (MissingPolicyException missingPolicy) { @@ -406,17 +409,15 @@ } } = - ec.setEvictionRegionConfigs(regionConfigs); + evictionConfig.setEvictionRegionConfigs(regionConfigs); } } = - return ec; + return evictionConfig; = } = - private static EvictionRegionConfig parseEvictionRegionConfig(Element e= lement, - String de= faultEvictionClass, - int defau= ltQueueCapacity) + private static EvictionRegionConfig parseEvictionRegionConfig(Element e= lement, String defaultEvPolicyClassName, int defaultQueueCapacity) { EvictionRegionConfig erc =3D new EvictionRegionConfig(); = @@ -435,7 +436,7 @@ = if (evictionClass =3D=3D null || evictionClass.length() =3D=3D 0) { - evictionClass =3D defaultEvictionClass; + evictionClass =3D defaultEvPolicyClassName; // if it's still null... what do we setCache? if (evictionClass =3D=3D null || evictionClass.length() =3D=3D 0) { @@ -444,10 +445,27 @@ } } = - EvictionPolicy policy; + EvictionAlgorithmConfig algorithmConfig =3D getEvictionAlgorithmConf= ig(evictionClass); + + parseEvictionPolicyConfig(element, algorithmConfig); + + erc.setEvictionAlgorithmConfig(algorithmConfig); + return erc; + } + + private static EvictionAlgorithmConfig getEvictionAlgorithmConfig(Strin= g evictionClass) + { + if (evictionClass.indexOf("org.jboss.cache.eviction") < 0) + { + throw new ConfigurationException("Unsupported custom eviction pol= icy: " + evictionClass + + ". Starting with 3.x the eviction API has changed, the code= needs to be manually migrated."); + } + String evictionAlgorithmClass =3D evictionClass.substring(0,eviction= Class.length() - "Policy".length()) + "Algorithm"; + + EvictionAlgorithm algorithm; try { - policy =3D (EvictionPolicy) Util.loadClass(evictionClass).newInst= ance(); + algorithm =3D (EvictionAlgorithm) Util.loadClass(evictionAlgorith= mClass).newInstance(); } catch (RuntimeException e) { @@ -458,10 +476,10 @@ throw new RuntimeException("Eviction class is not properly loaded= in classloader", e); } = - EvictionPolicyConfig epc; + EvictionAlgorithmConfig algorithmConfig; try { - epc =3D policy.getEvictionConfigurationClass().newInstance(); + algorithmConfig =3D algorithm.getConfigurationClass().newInstance= (); } catch (RuntimeException e) { @@ -470,16 +488,35 @@ catch (Exception e) { throw new RuntimeException("Failed to instantiate eviction config= uration of class " + - policy.getEvictionConfigurationClass(), e); + algorithm.getConfigurationClass(), e); } + return algorithmConfig; + } = - // TODO FIX this!!! -// EvictionElementParser.parseEvictionPolicyConfig(element, epc); - - erc.setEvictionPolicyConfig(epc); - return erc; + @SuppressWarnings("unchecked") + private static void parseEvictionPolicyConfig(Element element, Eviction= AlgorithmConfig target) + { + target.reset(); + ParsedAttributes attributes =3D XmlConfigHelper.extractAttributes(el= ement); + Map updatedElements =3D new HashMap(); + for (Map.Entry entry : attributes.stringAttribs.entrySet()) + { + String key =3D (String) entry.getKey(); + String value =3D (String) entry.getValue(); + if (key.indexOf("Seconds") > 0) + { + key =3D key.substring(0, key.length() - "Seconds".length()); + value =3D value.trim() + "000"; + } + updatedElements.put(key, value); + } + attributes.stringAttribs.clear(); + attributes.stringAttribs.putAll(updatedElements); + XmlConfigHelper.setValues(target, attributes.stringAttribs, false, t= rue); + XmlConfigHelper.setValues(target, attributes.xmlAttribs, true, true); } = + /** * Parses the cluster config which is used to start a JGroups channel * @@ -531,5 +568,4 @@ buffer.setLength(buffer.length() - 1); return buffer.toString(); } - } Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/E= victionElementParser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/element/Evictio= nElementParser.java 2008-08-19 11:26:03 UTC (rev 6582) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/Evictio= nElementParser.java 2008-08-20 12:04:27 UTC (rev 6583) @@ -80,7 +80,7 @@ } = String algorithmClassName =3D getAttributeValue(element, "algorithmC= lass"); - EvictionAlgorithmConfig eac =3D null; // every eviction region confi= g needs an algorithm config. + EvictionAlgorithmConfig algorithmConfig =3D null; // every eviction = region config needs an algorithm config. = if (existsAttribute(algorithmClassName)) { @@ -109,7 +109,7 @@ = try { - eac =3D Util.getInstance(algorithm.getConfigurationClass()); + algorithmConfig =3D Util.getInstance(algorithm.getConfiguratio= nClass()); } catch (Exception e) { @@ -129,7 +129,7 @@ { try { - eac =3D defaultRegion.getEvictionAlgorithmConfig().clone= (); + algorithmConfig =3D defaultRegion.getEvictionAlgorithmCo= nfig().clone(); } catch (CloneNotSupportedException e) { @@ -139,11 +139,11 @@ } } = - if (eac !=3D null) + if (algorithmConfig !=3D null) { - parseEvictionPolicyConfig(element, eac); + parseEvictionPolicyConfig(element, algorithmConfig); = - erc.setEvictionAlgorithmConfig(eac); + erc.setEvictionAlgorithmConfig(algorithmConfig); } = String actionPolicyClass =3D getAttributeValue(element, "actionPolic= yClass"); Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoader= Interceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterc= eptor.java 2008-08-19 11:26:03 UTC (rev 6582) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterc= eptor.java 2008-08-20 12:04:27 UTC (rev 6583) @@ -7,7 +7,6 @@ import org.jboss.cache.NodeSPI; import org.jboss.cache.jmx.annotations.ManagedAttribute; import org.jboss.cache.jmx.annotations.ManagedOperation; -import org.jboss.cache.jmx.annotations.MBean; import org.jboss.cache.commands.read.GetChildrenNamesCommand; import org.jboss.cache.commands.read.GetDataMapCommand; import org.jboss.cache.commands.read.GetKeyValueCommand; @@ -26,7 +25,6 @@ import org.jboss.cache.config.Configuration.NodeLockingScheme; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; -import org.jboss.cache.interceptors.base.CommandInterceptor; import org.jboss.cache.interceptors.base.JmxStatsCommandInterceptor; import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.loader.CacheLoader; Modified: core/trunk/src/main/resources/config2to3.xslt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/resources/config2to3.xslt 2008-08-19 11:26:03 UTC (= rev 6582) +++ core/trunk/src/main/resources/config2to3.xslt 2008-08-20 12:04:27 UTC (= rev 6583) @@ -275,14 +275,27 @@ + + + + A custom eviction p= olicy is used for '/_default_' region. Starting with JBossCache 3.x the evi= ction API changed, so this config file will require manual transformation.<= /xsl:message> + + + + + + + + + + + + + - - - - - Custom eviction policies = require manual transformation. @@ -344,14 +357,16 @@ - - + + + - - + + + Modified: core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTran= sformerTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransforme= rTest.java 2008-08-19 11:26:03 UTC (rev 6582) +++ core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransforme= rTest.java 2008-08-20 12:04:27 UTC (rev 6583) @@ -34,7 +34,7 @@ */ public void testSingleFile() throws Exception { - String fileName =3D getFileName("/default-test-config2x.xml"); + String fileName =3D getFileName("/policyPerRegion-eviction.xml"); ByteArrayOutputStream baos =3D new ByteArrayOutputStream(); convertor.parse(fileName, baos, XSLT_FILE); System.out.println("result =3D \n" + baos); @@ -51,12 +51,42 @@ public void testEqualityOnTransformedFiles() throws Exception { String[] fileNames =3D { -// "buddy-replication-cache.xml", -// "cacheloader-enabled-cache.xml", + "buddy-replication-cache.xml", + "local-cache.xml", + "multiplexer-enabled-cache.xml", + "total-replication-cache.xml", + }; + for (String file : fileNames) + { + System.out.println("Processing file =3D " + file); + String fileName =3D getFileName(file); + ByteArrayOutputStream baos =3D new ByteArrayOutputStream(); + convertor.parse(fileName, baos, XSLT_FILE); +// System.out.println("result =3D \n" + baos); + + XmlConfigurationParser newParser =3D new XmlConfigurationParser(); + XmlConfigurationParser2x oldParser =3D new XmlConfigurationParser= 2x(); + + Configuration newConfig =3D newParser.parseStream(new ByteArrayIn= putStream(baos.toByteArray())); + Configuration oldConfig =3D oldParser.parseFile(fileName); + + assert newConfig.equals(oldConfig); + } + } + + /** + * Not like the rest of elements, eviction was also changed in 3.x. + * As the parser produces different results, we semantically check here= that eviction is transformed corectly. + */ + public void testEqualityOnEvictionTransformedFiles() throws Exception + { + String[] fileNames =3D { + "cacheloader-enabled-cache.xml", + "clonable-config.xml", + "default-test-config2x.xml", "eviction-enabled-cache.xml", -// "local-cache.xml", "multiplexer-enabled-cache.xml", -// "optimistically-locked-cache.xml", "total-replication-cache.= xml", "clonable-config.xml", -// "policyPerRegion-eviction.xml" , "default-test-config2x.xml" + "optimistically-locked-cache.xml", + "policyPerRegion-eviction.xml" , }; for (String file : fileNames) { @@ -64,7 +94,7 @@ String fileName =3D getFileName(file); ByteArrayOutputStream baos =3D new ByteArrayOutputStream(); convertor.parse(fileName, baos, XSLT_FILE); - System.out.println("result =3D \n" + baos); +// System.out.println("result =3D \n" + baos); = XmlConfigurationParser newParser =3D new XmlConfigurationParser(); XmlConfigurationParser2x oldParser =3D new XmlConfigurationParser= 2x(); Added: core/trunk/src/test/java/org/jboss/cache/config/parsing/Eviction2xto= 3xCompatibilityTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/config/parsing/Eviction2xto3xC= ompatibilityTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/config/parsing/Eviction2xto3xC= ompatibilityTest.java 2008-08-20 12:04:27 UTC (rev 6583) @@ -0,0 +1,189 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2008, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.cache.config.parsing; + +import org.testng.annotations.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.reporters.XMLUtils; +import org.w3c.dom.Element; +import org.jboss.cache.config.parsing.element.EvictionElementParser; +import org.jboss.cache.config.EvictionConfig; +import org.jboss.cache.config.EvictionRegionConfig; +import org.jboss.cache.config.EvictionAlgorithmConfig; +import org.jboss.cache.Fqn; +import org.jboss.cache.eviction.MRUAlgorithmConfig; + +/** + * Eviction was internally changed from version 2.x to version 3.x. + * This is a tests to check eviction compatibility between these two versi= ons. + * + * @author Mircea.Markus(a)jboss.com + * @since 3.0 + */ +(a)Test(groups =3D "unit") +public class Eviction2xto3xCompatibilityTest +{ + private EvictionElementParser evictionElementParser; + + @BeforeMethod + public void setUp() + { + evictionElementParser =3D new EvictionElementParser(); + } + + public void testDefaultValues1() throws Exception + { + String oldFormat =3D + " \n" + + " \n" + + " 5\n" + + " 200000= \n" + + " org.jboss= .cache.eviction.LRUPolicy\n" + + " \n" + + " 5001\n" + + " 1001\n" + + " \n" + + " \n" + + " 1000\n" + + " 5000\n" + + " \n" + + " \n" + + " "; + Element oldEl =3D XmlConfigHelper.stringToElementInCoreNS(oldFormat); + EvictionConfig oldEvConfig =3D XmlConfigurationParser2x.parseEvictio= nConfig(oldEl); + //this will be transformed in root region, so make sure that the roo= t region will be corectly set up + MRUAlgorithmConfig defaultAlgorithmConfig =3D (MRUAlgorithmConfig) o= ldEvConfig.getDefaultEvictionRegionConfig().getEvictionAlgorithmConfig(); + assert oldEvConfig.getDefaultEvictionRegionConfig().getEventQueueSiz= e() =3D=3D 1234; + assert defaultAlgorithmConfig.getEvictionAlgorithmClassName().equals= ("org.jboss.cache.eviction.MRUAlgorithm"); + assert defaultAlgorithmConfig.getMaxNodes() =3D=3D 5001; + assert defaultAlgorithmConfig.getMinTimeToLive() =3D=3D 1001000; + + + assert oldEvConfig.getEvictionRegionConfigs().size() =3D=3D 1; + EvictionRegionConfig orgJbossData =3D oldEvConfig.getEvictionRegionC= onfigs().get(0); + assert orgJbossData.getRegionFqn().equals(Fqn.fromString("org/jboss/= data")); + assert orgJbossData.getEvictionAlgorithmConfig().getEvictionAlgorith= mClassName().equals("org.jboss.cache.eviction.LRUAlgorithm"); + assert orgJbossData.getEventQueueSize() =3D=3D 200000; + } + + public void simpleTest() throws Exception + { + String oldFormat =3D + " \n" + + " \n" + + " 5\n" + + " 200000= \n" + + " org.jboss= .cache.eviction.LRUPolicy\n" + + " \n" + + " 5000\n" + + " = 1000\n" + + " \n" + + " \n" + + " 1000\n" + + " 5000\n" + + " \n" + + " \n" + + " "; + String newFormat =3D + "\n" + + " \n" + + " 5000\n"= + + " 1000000\n" + + " \n" + + " \n" + + " 1000000\n" + + " 5000\n"= + + " \n" + + ""; + Element oldEl =3D XmlConfigHelper.stringToElementInCoreNS(oldFormat); + Element newEl =3D XmlConfigHelper.stringToElementInCoreNS(newFormat); + EvictionConfig oldEvConfig =3D XmlConfigurationParser2x.parseEvictio= nConfig(oldEl); + EvictionConfig newEvConfig =3D evictionElementParser.parseEvictionEl= ement(newEl); + assert oldEvConfig.getDefaultEvictionRegionConfig().equals(newEvConf= ig.getDefaultEvictionRegionConfig()); + + EvictionRegionConfig oldRegionConfig =3D oldEvConfig.getEvictionRegi= onConfigs().get(0); + EvictionRegionConfig newRegionConfig =3D newEvConfig.getEvictionRegi= onConfigs().get(0); + EvictionAlgorithmConfig oldEvictionAlgorithmConfig =3D oldRegionConf= ig.getEvictionAlgorithmConfig(); + EvictionAlgorithmConfig newEvictionAlgorithmConfig =3D newRegionConf= ig.getEvictionAlgorithmConfig(); + assert oldEvictionAlgorithmConfig.equals(newEvictionAlgorithmConfig); + + assert oldEvConfig.equals(newEvConfig); + } + + public void testFailureOnCustomEvictionPolicy() throws Exception + { + String oldFormat =3D + " \n" + + " \n" + + " 5\n" + + " 200000= \n" + + " org.jboss= .cache.eviction.LRUPolicy\n" + + " \n" + + " 5000\n" + + " = 1000\n" + + " \n" + + " \n" + + " 1000\n" + + " 5000\n" + + " \n" + + " \n" + + " "; + Element element =3D XmlConfigHelper.stringToElementInCoreNS(oldForma= t); + try + { + XmlConfigurationParser2x.parseEvictionConfig(element); + assert false : "custom eviction config not supported for the old = parser"; + } catch (Exception e) + { + System.out.println(e.getMessage()); + } + } + + public void testFailureOnCustomDefaultEvictionPolicy() throws Exception + { + String oldFormat =3D + " \n" + + " \n" + + " 5\n" + + " 200000= \n" + + " org.custo= m.eviction.policy.LFUPolicy\n" + + " \n" + + " 5000\n" + + " = 1000\n" + + " \n" + + " \n" + + " 1000\n" + + " 5000\n" + + " \n" + + " \n" + + " "; + Element element =3D XmlConfigHelper.stringToElementInCoreNS(oldForma= t); + try + { + XmlConfigurationParser2x.parseEvictionConfig(element); + assert false : "default custom eviction config not supported for = the old parser"; + } catch (Exception e) + { + System.out.println(e.getMessage()); + } + } +} Modified: core/trunk/src/test/resources/configs/conf2x/eviction-enabled-cac= he.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/resources/configs/conf2x/eviction-enabled-cache.xml= 2008-08-19 11:26:03 UTC (rev 6582) +++ core/trunk/src/test/resources/configs/conf2x/eviction-enabled-cache.xml= 2008-08-20 12:04:27 UTC (rev 6583) @@ -62,25 +62,12 @@ 5000 - 1000 + 1000 - 1000 + 1000 5000 - - - - - - - - - - - - - = --===============9138503337063909694==-- From jbosscache-commits at lists.jboss.org Wed Aug 20 08:06:05 2008 Content-Type: multipart/mixed; boundary="===============7341818702117247392==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6584 - core/trunk/src/main/java/org/jboss/cache/jmx. Date: Wed, 20 Aug 2008 08:06:04 -0400 Message-ID: --===============7341818702117247392== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-20 08:06:04 -0400 (Wed, 20 Aug 2008) New Revision: 6584 Modified: core/trunk/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.java core/trunk/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java Log: jmx update - name can now be associated to a MBean Modified: core/trunk/src/main/java/org/jboss/cache/jmx/JmxRegistrationManag= er.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.jav= a 2008-08-20 12:04:27 UTC (rev 6583) +++ core/trunk/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.jav= a 2008-08-20 12:06:04 UTC (rev 6584) @@ -130,7 +130,7 @@ List resourceDMBeans =3D getResourceDMBeans(); for (ResourceDMBean resource : resourceDMBeans) { - String resourceName =3D resource.getObject().getClass().getSim= pleName(); + String resourceName =3D resource.getObjectName(); ObjectName objectName =3D new ObjectName(getObjectName(resourc= eName)); if (!mBeanServer.isRegistered(objectName)) { Modified: core/trunk/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java 2008-0= 8-20 12:04:27 UTC (rev 6583) +++ core/trunk/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java 2008-0= 8-20 12:06:04 UTC (rev 6584) @@ -46,7 +46,7 @@ import java.util.regex.Pattern; = /** - * This class was entirely copied from jgroups (same name there). + * This class was entirely copied from jgroups 2.7 (same name there). * Couldn't simply reuse it because jgroups does not ship with MBean, Mana= gedAttribute and ManagedOperation. * Once jgroups will ship these classes, the code can be dinalmically reus= ed from there. * @@ -735,6 +735,16 @@ return !atts.isEmpty() || !ops.isEmpty(); } = + public String getObjectName() + { + MBean mBean =3D obj.getClass().getAnnotation(MBean.class); + if (mBean !=3D null && mBean.objectName() !=3D null && mBean.objectN= ame().trim().length() > 0) + { + return mBean.objectName(); + } + return obj.getClass().getSimpleName(); + } + public boolean isOperationRegistred(String operationName) { for (MBeanOperationInfo opInfo : this.ops) --===============7341818702117247392==-- From jboss-qa-internal at redhat.com Wed Aug 20 14:43:31 2008 Content-Type: multipart/mixed; boundary="===============4233119013649611995==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23424?= Date: Wed, 20 Aug 2008 14:43:28 -0400 Message-ID: <1303682243.1491219257808272.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1756865677.281219174058686.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============4233119013649611995== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/424/changes --===============4233119013649611995==-- From jboss-qa-internal at redhat.com Wed Aug 20 15:37:36 2008 Content-Type: multipart/mixed; boundary="===============1404679933677289928==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23558?= Date: Wed, 20 Aug 2008 15:37:32 -0400 Message-ID: <732794518.1581219261052900.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 687175073.261219173129512.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============1404679933677289928== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/558/changes --===============1404679933677289928==-- From jbosscache-commits at lists.jboss.org Thu Aug 21 05:16:34 2008 Content-Type: multipart/mixed; boundary="===============3121063729719585211==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6585 - in searchable/trunk: src/test/java/org/jboss/cache/search/blackbox and 1 other directory. Date: Thu, 21 Aug 2008 05:16:33 -0400 Message-ID: --===============3121063729719585211== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: navssurtani Date: 2008-08-21 05:16:33 -0400 (Thu, 21 Aug 2008) New Revision: 6585 Modified: searchable/trunk/pom.xml searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCach= eTest.java Log: Edited LocalCacheTest and pom.xml - = Version changed to 1.1.0.Beta1 and JBC deps changed to CR7 Modified: searchable/trunk/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/pom.xml 2008-08-20 12:06:04 UTC (rev 6584) +++ searchable/trunk/pom.xml 2008-08-21 09:16:33 UTC (rev 6585) @@ -4,7 +4,7 @@ xsi:schemaLocation=3D"http://maven.apache.org/POM/4.0.0 http://ma= ven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - 0.1-Beta1 + 1.0.0.Beta1 = - Basically, this is a variant of jboss-aop.xml. Note that - except for the customization of interceptor stack, you should - not need to modify this file. - - To run PojoCache, you will need to define a system property: - jboss.aop.path that contains the path to this file such that JBoss = Aop - can locate it. + - + *)" /> = - + + = - - - - - - - - - - - - - - - - - - - - - - - - - - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - toString())"> - - - - @org.jboss.cache.pojo.annotation.T= xUndo(..))"> - - - - @org.jboss.cache.pojo.annotation.Attach(..))"> - - - - @org.jboss.cache.pojo.annotation.Detach(..))"> - - - - @org.jboss.cache.pojo.annotation.Find(..))"> - - - - - - - - *) - "> - - - - - - org.jboss.cache.pojo.observable.Subject - org.jboss.cache.pojo.observable.SubjectImpl - new org.jboss.cache.pojo.observable.SubjectImpl(= this) - - - - + + + + + + org.jboss.cache.pojo.impl.ArrayInterceptable + + + + + ]]> Modified: pojo/branches/2.2/src/main/docbook/userguide/en/modules/architect= ure.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/branches/2.2/src/main/docbook/userguide/en/modules/architecture.xm= l 2008-08-21 19:21:04 UTC (rev 6595) +++ pojo/branches/2.2/src/main/docbook/userguide/en/modules/architecture.xm= l 2008-08-22 00:15:38 UTC (rev 6596) @@ -19,86 +19,6 @@ = - - POJO Cache interceptor stack - - As mentioned, the JBoss Aop framework is used to provide a con= figurable interceptor stack. - In the current implementation, the main POJO Cache methods have t= heir own independant stack. These are specified in META-INF/pojoca= che-aop.xml - In most cases, this file should be left alone, although advanced = users may wish to add their own interceptors. - The Following is the default configuration: - - - - - - - - - - - - - - - - - - - - - - - - - - - false - - - - - - - - - - - - - - - - - - - - - - -]]> - - The stack should be self-explanatory. For example, for the Attach stack, - we currently have Start, CheckId, Tx, TxLock, = and - TxUndo interceptors. The stack always starts w= ith a - Start interceptor such that initialization can= be done properly. - CheckId is to ensure the validity of the Id (e= .g., it didn't use any internal - Id string). Finally, Tx, TxLock, and = TxUndo are handling the - the proper transaction locking and rollback behavior (if needed). - - Field interception = @@ -116,7 +36,7 @@ All access qualifiers are intercepted. In other words, a= ll private, all protected, all defaul= t, and all public fields will be intercepted. - Any field with final, stati= c, and/or transient qualifiers, will be skipped. Therefore, they will not be replicat= ed, passivated, or manipulated in any way by POJO Cache. + Any field with static, and/or transient qualifiers, will be skipped= . Therefore, they will not be replicated, passivated, or manipul= ated in any way by POJO Cache. @@ -416,12 +336,9 @@ = - The drawback to this approach is that the calling application = must re-get any collection references that were attached. Otherwise, = - the cache will not be aware of future changes. If the collecti= on is referenced from another object, then the calling app can obtain - the proxy by using the publishing mechanism provided by the ob= ject (e.g. Person.getHobbies()). = - = - If, however, the collection is directly attached to the cache,= then a subsequent find() call will need to be made - to retrieve the proxy. + The drawback to this approach is that the calling application = must re-get any collection references that were directly attached. Otherwis= e, = + the cache will not be aware of future changes. However, if the= collection is referenced from an attached object, then this is transparent= ly + handled. More specifically, the attached object will see the p= roxy instead of the original. = = The following code snippet illustrates obtaining a direct C= ollection proxy reference: @@ -486,4 +403,51 @@ + + Array Mapping + + As of 2.2, array fields of any attached object are updated = transparently, provided that the array + is written/read from a class marked with @Replicable<= /literal>. If this is the case, only = + the indexes of the array that are modified are replicated. How= ever, if the array is passed externally = + to a class that is not marked as @Replicable, then the changes will not be noticed. For this + reason, it is recommended to abstract access to the array wher= e possible (i.e. setItem(item, index)). = + If an external, non-replicable class needs access to the array= , then it is recommended to pass a copy, = + and add a method to the container object that reapplies the ch= anges. Also, due to JVM limitations, + an array can not be monitored if it is directly attached to th= e cache (i.e. a first class object). POJO + Cache still allows this, but they are treated as a serializabl= e type. As with other serializable type, + they must be reattached after every change. + + + The following code snippet illustrates accessing a replicat= ed array through abstraction: + + + --===============4785159715395583562==-- From jbosscache-commits at lists.jboss.org Fri Aug 22 01:22:14 2008 Content-Type: multipart/mixed; boundary="===============6168247113574579828==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6597 - searchable. Date: Fri, 22 Aug 2008 01:22:14 -0400 Message-ID: --===============6168247113574579828== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: navssurtani Date: 2008-08-22 01:22:13 -0400 (Fri, 22 Aug 2008) New Revision: 6597 Added: searchable/1.0.0.BETA1/ Log: Tagged beta 1 Copied: searchable/1.0.0.BETA1 (from rev 6596, searchable/trunk) --===============6168247113574579828==-- From jboss-qa-internal at redhat.com Fri Aug 22 04:42:33 2008 Content-Type: multipart/mixed; boundary="===============4655998908977248275==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23426?= Date: Fri, 22 Aug 2008 04:42:29 -0400 Message-ID: <961692165.4451219394549530.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 221083200.3261219346878450.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============4655998908977248275== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/426/changes --===============4655998908977248275==-- From jbosscache-commits at lists.jboss.org Fri Aug 22 05:18:01 2008 Content-Type: multipart/mixed; boundary="===============8672879380392182742==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6598 - in searchable/trunk: assembly and 1 other directory. Date: Fri, 22 Aug 2008 05:17:58 -0400 Message-ID: --===============8672879380392182742== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: navssurtani Date: 2008-08-22 05:17:57 -0400 (Fri, 22 Aug 2008) New Revision: 6598 Modified: searchable/trunk/assembly/all.xml searchable/trunk/assembly/bin.xml searchable/trunk/pom.xml Log: Edited some xml files Modified: searchable/trunk/assembly/all.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/assembly/all.xml 2008-08-22 05:22:13 UTC (rev 6597) +++ searchable/trunk/assembly/all.xml 2008-08-22 09:17:57 UTC (rev 6598) @@ -55,6 +55,17 @@ = + = + + + + + + README.txt + + = + + target/site/apidocs @@ -62,6 +73,7 @@ = + = + + + + + README.txt + + + = + = = - + = - + = - + = --===============4650196412103446796==-- From jboss-qa-internal at redhat.com Fri Aug 22 05:31:40 2008 Content-Type: multipart/mixed; boundary="===============7299698907458632653==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23560?= Date: Fri, 22 Aug 2008 05:31:38 -0400 Message-ID: <1097868414.4561219397498482.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 473520599.3271219347299023.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============7299698907458632653== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/560/changes --===============7299698907458632653==-- From jboss-qa-internal at redhat.com Fri Aug 22 05:38:27 2008 Content-Type: multipart/mixed; boundary="===============4929986880266312232==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Build_failed_in_Hudson=3A_jboss-cache-?= =?utf-8?q?searchable-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Searchable_Editi?= =?utf-8?q?on_=231?= Date: Fri, 22 Aug 2008 05:38:25 -0400 Message-ID: <157403127.4611219397905407.JavaMail.hudson@hudson1.qa.atl2.redhat.com> --===============4929986880266312232== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-searchable-trunk-jdk1= .6/org.jboss.cache$jbosscache-searchable/1/changes ------------------------------------------ [...truncated 273 lines...] ------------------------------------------------------- 2008-08-22 05:35:28,798 INFO [JChannel] (main) JGroups version: 2.6.2 ------------------------------------------------------- GMS: address is 127.0.0.1:37328 ------------------------------------------------------- 2008-08-22 05:35:30,842 INFO [JChannel] (main) JGroups version: 2.6.2 ------------------------------------------------------- GMS: address is 127.0.0.1:57925 ------------------------------------------------------- 2008-08-22 05:35:33,836 INFO [JChannel] (main) JGroups version: 2.6.2 ------------------------------------------------------- GMS: address is 127.0.0.1:45829 ------------------------------------------------------- 2008-08-22 05:35:35,915 INFO [JChannel] (main) JGroups version: 2.6.2 ------------------------------------------------------- GMS: address is 127.0.0.1:53973 ------------------------------------------------------- 2008-08-22 05:35:38,059 WARN [FD_SOCK] (OOB,127.0.0.1:53973) (GET_CACHE_RS= P): cache is null found.size() is 2 2008-08-22 05:35:38,756 WARN [FD_SOCK] (FD_SOCK pinger,127.0.0.1:53973) re= ceived null cache; retrying Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 20.86 sec Running org.jboss.cache.search.blackbox.BrokenAnnotationTest (of functional) Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.431 sec Running org.jboss.cache.search.LazyQueryResultIteratorTest (of functional) Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.012 sec Running org.jboss.cache.search.NodeModifiedTransactionContextTest (of funct= ional) Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.013 sec Running org.jboss.cache.search.QueryResultIteratorImplTest (of functional) Tests run: 13, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.154 sec Running org.jboss.cache.search.TransformerTest (of functional) Tests run: 11, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.129 sec Running org.jboss.cache.search.blackbox.LocalPOJOCacheTest (of functional) Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.027 sec Running org.jboss.cache.search.SearchableCacheImplTest (of functional) Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.315 sec Running org.jboss.cache.search.blackbox.LocalCacheTest (of functional) 2008-08-22 05:35:44,378 INFO [Version] (main) Hibernate Commons Annotation= s 3.1.0.CR1 Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.172 sec Results : Tests run: 40, Failures: 0, Errors: 0, Skipped: 0 [HUDSON] Recording test results [INFO] Preparing surefire-report:report-only [WARNING] POM for 'org.apache.lucene:lucene-core:pom:2.3.1:test' is invalid= . It will be ignored for artifact resolution. Reason: Not a v4.0.0 POM. for= project org.apache.lucene:lucene-core at /home/hudson/.m2/repository/org/a= pache/lucene/lucene-core/2.3.1/lucene-core-2.3.1.pom [INFO] [enforcer:enforce {execution: enforce-java}] [INFO] Preparing emma:emma [WARNING] POM for 'org.apache.lucene:lucene-core:pom:2.3.1:test' is invalid= . It will be ignored for artifact resolution. Reason: Not a v4.0.0 POM. for= project org.apache.lucene:lucene-core at /home/hudson/.m2/repository/org/a= pache/lucene/lucene-core/2.3.1/lucene-core-2.3.1.pom [INFO] [enforcer:enforce {execution: enforce-java}] [INFO] [resources:resources] [INFO] Using default encoding to copy filtered resources. [WARNING] POM for 'org.apache.lucene:lucene-core:pom:2.3.1:test' is invalid= . It will be ignored for artifact resolution. Reason: Not a v4.0.0 POM. for= project org.apache.lucene:lucene-core at /home/hudson/.m2/repository/org/a= pache/lucene/lucene-core/2.3.1/lucene-core-2.3.1.pom [INFO] [compiler:compile] Compiling 2 source files to /mnt/tmp/workspace/jboss-cache-searchable-trunk= -jdk1.6/target/classes [WARNING] POM for 'org.apache.lucene:lucene-core:pom:2.3.1:test' is invalid= . It will be ignored for artifact resolution. Reason: Not a v4.0.0 POM. for= project org.apache.lucene:lucene-core at /home/hudson/.m2/repository/org/a= pache/lucene/lucene-core/2.3.1/lucene-core-2.3.1.pom [INFO] [emma:instrument] [INFO] Instrumenting classes with EMMA [INFO] EMMA: processing instrumentation path ... [INFO] EMMA: instrumentation path processed in 138 ms [INFO] EMMA: [16 class(es) instrumented, 3 resource(s) copied] [INFO] EMMA: metadata merged into [/mnt/tmp/workspace/jboss-cache-searchabl= e-trunk-jdk1.6/target/coverage.em] {in 14 ms} [INFO] [resources:testResources] [INFO] Using default encoding to copy filtered resources. [WARNING] POM for 'org.apache.lucene:lucene-core:pom:2.3.1:test' is invalid= . It will be ignored for artifact resolution. Reason: Not a v4.0.0 POM. for= project org.apache.lucene:lucene-core at /home/hudson/.m2/repository/org/a= pache/lucene/lucene-core/2.3.1/lucene-core-2.3.1.pom [INFO] [compiler:testCompile] [INFO] Nothing to compile - all classes are up to date [WARNING] POM for 'org.apache.lucene:lucene-core:pom:2.3.1:test' is invalid= . It will be ignored for artifact resolution. Reason: Not a v4.0.0 POM. for= project org.apache.lucene:lucene-core at /home/hudson/.m2/repository/org/a= pache/lucene/lucene-core/2.3.1/lucene-core-2.3.1.pom [INFO] [surefire:test] [INFO] Surefire report directory: /mnt/tmp/workspace/jboss-cache-searchable= -trunk-jdk1.6/target/surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running org.jboss.cache.search.CacheEntityIdTest (of functional) Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.01 sec Running org.jboss.cache.search.blackbox.ClusteredCacheTest (of functional) 2008-08-22 05:37:39,416 INFO [JChannel] (main) JGroups version: 2.6.2 ------------------------------------------------------- GMS: address is 127.0.0.1:48764 ------------------------------------------------------- EMMA: collecting runtime coverage data ... 2008-08-22 05:37:41,744 INFO [Version] (main) Hibernate Commons Annotation= s 3.1.0.CR1 2008-08-22 05:37:41,947 INFO [JChannel] (main) JGroups version: 2.6.2 ------------------------------------------------------- GMS: address is 127.0.0.1:50538 ------------------------------------------------------- 2008-08-22 05:37:45,112 INFO [JChannel] (main) JGroups version: 2.6.2 ------------------------------------------------------- GMS: address is 127.0.0.1:40636 ------------------------------------------------------- 2008-08-22 05:37:47,181 INFO [JChannel] (main) JGroups version: 2.6.2 ------------------------------------------------------- GMS: address is 127.0.0.1:35739 ------------------------------------------------------- 2008-08-22 05:37:50,059 INFO [JChannel] (main) JGroups version: 2.6.2 ------------------------------------------------------- GMS: address is 127.0.0.1:51374 ------------------------------------------------------- 2008-08-22 05:37:52,123 INFO [JChannel] (main) JGroups version: 2.6.2 ------------------------------------------------------- GMS: address is 127.0.0.1:50162 ------------------------------------------------------- 2008-08-22 05:37:55,151 INFO [JChannel] (main) JGroups version: 2.6.2 ------------------------------------------------------- GMS: address is 127.0.0.1:58078 ------------------------------------------------------- 2008-08-22 05:37:57,197 INFO [JChannel] (main) JGroups version: 2.6.2 ------------------------------------------------------- GMS: address is 127.0.0.1:45987 ------------------------------------------------------- 2008-08-22 05:37:59,346 WARN [FD_SOCK] (OOB,127.0.0.1:45987) (GET_CACHE_RS= P): cache is null found.size() is 2 2008-08-22 05:38:00,027 WARN [FD_SOCK] (FD_SOCK pinger,127.0.0.1:45987) re= ceived null cache; retrying Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 20.93 sec EMMA: runtime coverage data merged into [/mnt/tmp/workspace/jboss-cache-sea= rchable-trunk-jdk1.6/coverage.ec] {in 17 ms} Running org.jboss.cache.search.blackbox.BrokenAnnotationTest (of functional) EMMA: collecting runtime coverage data ... Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.524 sec EMMA: runtime coverage data merged into [/mnt/tmp/workspace/jboss-cache-sea= rchable-trunk-jdk1.6/coverage.ec] {in 2 ms} Running org.jboss.cache.search.LazyQueryResultIteratorTest (of functional) Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.012 sec Running org.jboss.cache.search.NodeModifiedTransactionContextTest (of funct= ional) Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.013 sec Running org.jboss.cache.search.QueryResultIteratorImplTest (of functional) EMMA: collecting runtime coverage data ... Tests run: 13, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.25 sec EMMA: runtime coverage data merged into [/mnt/tmp/workspace/jboss-cache-sea= rchable-trunk-jdk1.6/coverage.ec] {in 2 ms} Running org.jboss.cache.search.TransformerTest (of functional) EMMA: collecting runtime coverage data ... Tests run: 11, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.177 sec EMMA: runtime coverage data merged into [/mnt/tmp/workspace/jboss-cache-sea= rchable-trunk-jdk1.6/coverage.ec] {in 1 ms} Running org.jboss.cache.search.blackbox.LocalPOJOCacheTest (of functional) Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.013 sec Running org.jboss.cache.search.SearchableCacheImplTest (of functional) EMMA: collecting runtime coverage data ... Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.36 sec EMMA: runtime coverage data merged into [/mnt/tmp/workspace/jboss-cache-sea= rchable-trunk-jdk1.6/coverage.ec] {in 1 ms} Running org.jboss.cache.search.blackbox.LocalCacheTest (of functional) EMMA: collecting runtime coverage data ... 2008-08-22 05:38:05,939 INFO [Version] (main) Hibernate Commons Annotation= s 3.1.0.CR1 Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.287 sec Results : Tests run: 40, Failures: 0, Errors: 0, Skipped: 0 EMMA: runtime coverage data merged into [/mnt/tmp/workspace/jboss-cache-sea= rchable-trunk-jdk1.6/coverage.ec] {in 4 ms} [HUDSON] Recording test results [INFO] Preparing findbugs:findbugs [WARNING] POM for 'org.apache.lucene:lucene-core:pom:2.3.1:test' is invalid= . It will be ignored for artifact resolution. Reason: Not a v4.0.0 POM. for= project org.apache.lucene:lucene-core at /home/hudson/.m2/repository/org/a= pache/lucene/lucene-core/2.3.1/lucene-core-2.3.1.pom [INFO] [enforcer:enforce {execution: enforce-java}] [INFO] [resources:resources] [INFO] Using default encoding to copy filtered resources. [WARNING] POM for 'org.apache.lucene:lucene-core:pom:2.3.1:test' is invalid= . It will be ignored for artifact resolution. Reason: Not a v4.0.0 POM. for= project org.apache.lucene:lucene-core at /home/hudson/.m2/repository/org/a= pache/lucene/lucene-core/2.3.1/lucene-core-2.3.1.pom [INFO] [compiler:compile] Compiling 2 source files to /mnt/tmp/workspace/jboss-cache-searchable-trunk= -jdk1.6/target/classes [WARNING] POM for 'org.apache.lucene:lucene-core:pom:2.3.1:test' is invalid= . It will be ignored for artifact resolution. Reason: Not a v4.0.0 POM. for= project org.apache.lucene:lucene-core at /home/hudson/.m2/repository/org/a= pache/lucene/lucene-core/2.3.1/lucene-core-2.3.1.pom [INFO] [site:site] [FATAL ERROR] org.apache.maven.plugins.site.SiteMojo#execute() caused a lin= kage error (java.lang.NoClassDefFoundError) and may be out-of-date. Check t= he realms: [FATAL ERROR] Plugin realm =3D app0.child-container[org.apache.maven.plugin= s:maven-site-plugin] urls[0] =3D file:/home/hudson/.m2/repository/org/apache/maven/plugins/maven= -site-plugin/2.0-beta-6/maven-site-plugin-2.0-beta-6.jar urls[1] =3D file:/home/hudson/.m2/repository/org/codehaus/plexus/plexus-uti= ls/1.4.5/plexus-utils-1.4.5.jar urls[2] =3D file:/home/hudson/.m2/repository/org/apache/maven/doxia/doxia-m= odule-xhtml/1.0-alpha-10/doxia-module-xhtml-1.0-alpha-10.jar urls[3] =3D file:/home/hudson/.m2/repository/org/apache/maven/doxia/doxia-c= ore/1.0-alpha-10/doxia-core-1.0-alpha-10.jar urls[4] =3D file:/home/hudson/.m2/repository/org/apache/maven/doxia/doxia-d= ecoration-model/1.0-alpha-10/doxia-decoration-model-1.0-alpha-10.jar urls[5] =3D file:/home/hudson/.m2/repository/org/apache/maven/doxia/doxia-s= ite-renderer/1.0-alpha-10/doxia-site-renderer-1.0-alpha-10.jar urls[6] =3D file:/home/hudson/.m2/repository/org/codehaus/plexus/plexus-i18= n/1.0-beta-7/plexus-i18n-1.0-beta-7.jar urls[7] =3D file:/home/hudson/.m2/repository/org/codehaus/plexus/plexus-vel= ocity/1.1.7/plexus-velocity-1.1.7.jar urls[8] =3D file:/home/hudson/.m2/repository/org/apache/velocity/velocity/1= .5/velocity-1.5.jar urls[9] =3D file:/home/hudson/.m2/repository/commons-collections/commons-co= llections/3.2/commons-collections-3.2.jar urls[10] =3D file:/home/hudson/.m2/repository/commons-lang/commons-lang/2.1= /commons-lang-2.1.jar urls[11] =3D file:/home/hudson/.m2/repository/oro/oro/2.0.8/oro-2.0.8.jar urls[12] =3D file:/home/hudson/.m2/repository/org/apache/maven/doxia/doxia-= module-apt/1.0-alpha-10/doxia-module-apt-1.0-alpha-10.jar urls[13] =3D file:/home/hudson/.m2/repository/org/apache/maven/doxia/doxia-= module-fml/1.0-alpha-10/doxia-module-fml-1.0-alpha-10.jar urls[14] =3D file:/home/hudson/.m2/repository/org/apache/maven/doxia/doxia-= module-xdoc/1.0-alpha-10/doxia-module-xdoc-1.0-alpha-10.jar urls[15] =3D file:/home/hudson/.m2/repository/org/codehaus/plexus/plexus-ar= chiver/1.0-alpha-7/plexus-archiver-1.0-alpha-7.jar urls[16] =3D file:/home/hudson/.m2/repository/org/mortbay/jetty/jetty/6.1.5= /jetty-6.1.5.jar urls[17] =3D file:/home/hudson/.m2/repository/org/mortbay/jetty/jetty-util/= 6.1.5/jetty-util-6.1.5.jar urls[18] =3D file:/home/hudson/.m2/repository/org/mortbay/jetty/servlet-api= -2.5/6.1.5/servlet-api-2.5-6.1.5.jar [FATAL ERROR] Container realm =3D plexus.core.maven urls[0] =3D file:/home/hudson/.m2/repository/org/apache/maven/wagon/wagon-w= ebdav/1.0-beta-2/wagon-webdav-1.0-beta-2.jar urls[1] =3D file:/home/hudson/.m2/repository/slide/slide-webdavlib/2.1/slid= e-webdavlib-2.1.jar urls[2] =3D file:/home/hudson/.m2/repository/commons-httpclient/commons-htt= pclient/2.0.2/commons-httpclient-2.0.2.jar urls[3] =3D file:/home/hudson/.m2/repository/commons-logging/commons-loggin= g/1.0.4/commons-logging-1.0.4.jar urls[4] =3D file:/home/hudson/.m2/repository/jdom/jdom/1.0/jdom-1.0.jar urls[5] =3D file:/home/hudson/.m2/repository/de/zeigermann/xml/xml-im-expor= ter/1.1/xml-im-exporter-1.1.jar urls[6] =3D file:/home/hudson/.m2/repository/org/codehaus/plexus/plexus-uti= ls/1.1/plexus-utils-1.1.jar [HUDSON] Archiving /mnt/tmp/workspace/jboss-cache-searchable-trunk-jdk1.6/.= /pom.xml [INFO] --------------------------------------------------------------------= ---- [ERROR] FATAL ERROR [INFO] --------------------------------------------------------------------= ---- [INFO] org/apache/maven/plugin/logging/Log [INFO] --------------------------------------------------------------------= ---- [INFO] Trace java.lang.NoClassDefFoundError: org/apache/maven/plugin/logging/Log at org.codehaus.mojo.javancss.NcssReportMojo.scanForSources(NcssReportMojo= .java:373) at org.codehaus.mojo.javancss.NcssReportMojo.canGenerateSingleReport(NcssR= eportMojo.java:347) at org.codehaus.mojo.javancss.NcssReportMojo.canGenerateReport(NcssReportM= ojo.java:320) at org.apache.maven.plugins.site.AbstractSiteRenderingMojo.filterReports(A= bstractSiteRenderingMojo.java:421) at org.apache.maven.plugins.site.SiteMojo.execute(SiteMojo.java:77) at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginM= anager.java:451) at hudson.maven.agent.PluginManagerInterceptor.executeMojo(PluginManagerIn= terceptor.java:136) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defaul= tLifecycleExecutor.java:558) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLife= cycle(DefaultLifecycleExecutor.java:499) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Default= LifecycleExecutor.java:478) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandl= eFailures(DefaultLifecycleExecutor.java:330) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments= (DefaultLifecycleExecutor.java:291) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLife= cycleExecutor.java:142) at org.apache.maven.lifecycle.LifecycleExecutorInterceptor.execute(Lifecyc= leExecutorInterceptor.java:42) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129) at org.apache.maven.cli.MavenCli.main(MavenCli.java:287) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.ja= va:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesso= rImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) at org.codehaus.classworlds.Launcher.launch(Launcher.java:255) at hudson.maven.agent.Main.launch(Main.java:97) at hudson.maven.MavenBuilder.call(MavenBuilder.java:129) at hudson.maven.MavenBuilder.call(MavenBuilder.java:52) at hudson.remoting.UserRequest.perform(UserRequest.java:69) at hudson.remoting.UserRequest.perform(UserRequest.java:23) at hudson.remoting.Request$2.run(Request.java:200) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecut= or.java:885) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.j= ava:907) at java.lang.Thread.run(Thread.java:619) [INFO] --------------------------------------------------------------------= ---- [INFO] Total time: 4 minutes 3 seconds [INFO] Finished at: Fri Aug 22 05:38:19 EDT 2008 [INFO] Final Memory: 47M/85M [INFO] --------------------------------------------------------------------= ---- Waiting for Hudson to finish collecting data --===============4929986880266312232==-- From jboss-qa-internal at redhat.com Fri Aug 22 05:50:54 2008 Content-Type: multipart/mixed; boundary="===============4219282434399106267==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_completed=3A_jboss-cache-?= =?utf-8?q?searchable-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Searchable_Editi?= =?utf-8?q?on_=231?= Date: Fri, 22 Aug 2008 05:50:52 -0400 Message-ID: <100952533.4641219398652528.JavaMail.hudson@hudson1.qa.atl2.redhat.com> --===============4219282434399106267== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-searchable-trunk-jdk1= .5/org.jboss.cache$jbosscache-searchable/1/changes --===============4219282434399106267==-- From jboss-qa-internal at redhat.com Fri Aug 22 05:51:48 2008 Content-Type: multipart/mixed; boundary="===============0372616403537148091==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_completed=3A_jboss-cache-?= =?utf-8?q?searchable-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Searchable_Editi?= =?utf-8?q?on_=232?= Date: Fri, 22 Aug 2008 05:51:45 -0400 Message-ID: <1099322168.4651219398705709.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 157403127.4611219397905407.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============0372616403537148091== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-searchable-trunk-jdk1= .6/org.jboss.cache$jbosscache-searchable/2/changes --===============0372616403537148091==-- From jbosscache-commits at lists.jboss.org Sat Aug 23 01:30:53 2008 Content-Type: multipart/mixed; boundary="===============0067075744216528259==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6600 - core/tags. Date: Sat, 23 Aug 2008 01:30:53 -0400 Message-ID: --===============0067075744216528259== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-23 01:30:52 -0400 (Sat, 23 Aug 2008) New Revision: 6600 Added: core/tags/2.2.0.GA/ Log: Tagging the GA Copied: core/tags/2.2.0.GA (from rev 6599, core/branches/2.2.X) --===============0067075744216528259==-- From jboss-qa-internal at redhat.com Sat Aug 23 01:34:52 2008 Content-Type: multipart/mixed; boundary="===============5632050450753572817==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_completed=3A_jboss-cache-?= =?utf-8?q?searchable-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Searchable_Editi?= =?utf-8?q?on_=233?= Date: Sat, 23 Aug 2008 01:34:51 -0400 Message-ID: <1794083145.7571219469691065.JavaMail.hudson@hudson1.qa.atl2.redhat.com> --===============5632050450753572817== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-searchable-trunk-jdk1= .6/org.jboss.cache$jbosscache-searchable/3/changes --===============5632050450753572817==-- From jboss-qa-internal at redhat.com Sat Aug 23 01:36:43 2008 Content-Type: multipart/mixed; boundary="===============7526143920622896609==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_completed=3A_jboss-cache-?= =?utf-8?q?searchable-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Searchable_Editi?= =?utf-8?q?on_=232?= Date: Sat, 23 Aug 2008 01:36:41 -0400 Message-ID: <518999590.7581219469801847.JavaMail.hudson@hudson1.qa.atl2.redhat.com> --===============7526143920622896609== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-searchable-trunk-jdk1= .5/org.jboss.cache$jbosscache-searchable/2/changes --===============7526143920622896609==-- From jbosscache-commits at lists.jboss.org Sat Aug 23 01:40:16 2008 Content-Type: multipart/mixed; boundary="===============7692600999500244096==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6601 - in searchable/trunk: assembly and 1 other directories. Date: Sat, 23 Aug 2008 01:40:11 -0400 Message-ID: --===============7692600999500244096== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-23 01:40:09 -0400 (Sat, 23 Aug 2008) New Revision: 6601 Modified: searchable/trunk/assembly/all.xml searchable/trunk/pom.xml searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalPOJO= CacheTest.java Log: Fixed distribution contents and release version Modified: searchable/trunk/assembly/all.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/assembly/all.xml 2008-08-23 05:30:52 UTC (rev 6600) +++ searchable/trunk/assembly/all.xml 2008-08-23 05:40:09 UTC (rev 6601) @@ -30,19 +30,19 @@ src/main/java - src + src/main = src/test/java - test + src/test = src/test/resources - test + src = @@ -68,8 +68,11 @@ = - target/site/apidocs - doc/apidocs + target/site + javadocs + + apidocs/** + = Modified: searchable/trunk/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/pom.xml 2008-08-23 05:30:52 UTC (rev 6600) +++ searchable/trunk/pom.xml 2008-08-23 05:40:09 UTC (rev 6601) @@ -4,7 +4,7 @@ xsi:schemaLocation=3D"http://maven.apache.org/POM/4.0.0 http://ma= ven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - 1.0.0.Beta1 + 1.0.0-SNAPSHOT unit - - - - - README.txt - - = = + + + + + + README.txt + + = + target/site - javadocs - - apidocs/** - + + + apidocs/** + = - = + \n" + + " \n" + + " 2\n= " + + " \n" + + " \n" + + " "; + + doTest(xml, true); + } + + public void testUsingCustomEvictionPolicy() + { + try + { + Configuration c =3D new Configuration(); + c.setEvictionConfig(new EvictionConfig()); + EvictionConfig evConfig =3D c.getEvictionConfig(); + evConfig.setWakeupIntervalSeconds(3); + evConfig.setDefaultEventQueueSize(20000); + evConfig.setDefaultEvictionPolicyClass(MyPolicy.class.getName()); + List erConfigs =3D new ArrayList(); + erConfigs.add(createEvictionRegionConfig("/_default_", 2, new MyP= olicyConfig())); + evConfig.setEvictionRegionConfigs(erConfigs); + doTest(c); + assert false : "Should throw exception"; + } + catch (UnsupportedEvictionImplException ce) + { + // expected + } + } + + public void testUsingCustomEvictionPolicyXml() throws Exception + { + String xml =3D "\n" + + " \n" + + " 2\n" + + " \n" + + " \n" + + " 2\n= " + + " \n" + + " \n" + + " "; + + try + { + doTest(xml, true); + assert false : "Should throw exception"; + } + catch (UnsupportedEvictionImplException ce) + { + // expected + } + } + + public void testUsingCustomEvictionPolicyNonDefault() + { + try + { + Configuration c =3D new Configuration(); + c.setEvictionConfig(new EvictionConfig()); + EvictionConfig evConfig =3D c.getEvictionConfig(); + evConfig.setWakeupIntervalSeconds(3); + evConfig.setDefaultEventQueueSize(20000); + evConfig.setDefaultEvictionPolicyClass(FIFOPolicy.class.getName()= ); + List erConfigs =3D new ArrayList(); + erConfigs.add(createEvictionRegionConfig("/_default_", 2, new FIF= OConfiguration())); + erConfigs.add(createEvictionRegionConfig("/a/b/c", 2, new MyPolic= yConfig())); + evConfig.setEvictionRegionConfigs(erConfigs); + doTest(c); + assert false : "Should throw exception"; + } + catch (UnsupportedEvictionImplException ce) + { + // expected + } + } + + public void testUsingCustomEvictionPolicyNonDefaultXml() throws Excepti= on + { + String xml =3D "\n" + + " \n" + + " 2\n" + + " \n" + + " \n" + + " 2\n= " + + " \n" + + " " + + " 2\n= " + + " \n" + + " \n" + + " "; + + try + { + doTest(xml, true); + assert false : "Should throw exception"; + } + catch (UnsupportedEvictionImplException ce) + { + // expected + } + } + + public void testControl() + { + Configuration c =3D new Configuration(); + c.setEvictionConfig(new EvictionConfig()); + EvictionRegionConfig defaultRegion =3D c.getEvictionConfig().getDefa= ultEvictionRegionConfig(); + defaultRegion.setEvictionAlgorithmConfig(new FIFOAlgorithmConfig(2)); + doTest(c); + } + + public void testControlXml() throws Exception + { + String xml =3D "" + + "" + + "2" + + "" + + ""; + doTest(xml, false); + } + + private void doTest(String xml, boolean legacy) throws Exception + { + if (legacy) + { + EvictionConfig ec =3D XmlConfigurationParser2x.parseEvictionConfi= g(XmlConfigHelper.stringToElementInCoreNS(xml)); + Configuration c =3D new Configuration(); + c.setEvictionConfig(ec); + doTest(c); + } + else + { + doTest(new XmlConfigurationParser().parseElement(XmlConfigHelper.= stringToElementInCoreNS(xml))); + } + } + + private void doTest(Configuration c) + { + Cache cache =3D null; + try + { + cache =3D new DefaultCacheFactory().createCache(c); + + EvictionRegionConfig erc =3D cache.getRegion(Fqn.ROOT, false).get= EvictionRegionConfig(); + assert erc.getEvictionAlgorithmConfig() instanceof FIFOAlgorithmC= onfig; + assert erc.getEvictionActionPolicyClassName().equals(DefaultEvict= ionActionPolicy.class.getName()); + + cache.put("/a/b/1", "a", "b"); + cache.put("/a/b/2", "a", "b"); + cache.put("/a/b/3", "a", "b"); + + new EvictionController(cache).startEviction(); + + assert cache.getNode("/a/b/1") =3D=3D null; + assert cache.getNode("/a/b/2") !=3D null; + assert cache.getNode("/a/b/3") !=3D null; + } + finally + { + TestingUtil.killCaches(cache); + } + } + + public static class MyPolicy extends BaseEvictionPolicy + { + public EvictionAlgorithm getEvictionAlgorithm() + { + return null; + } + + public Class getEvictionConfiguratio= nClass() + { + return null; + } + } + + public class MyPolicyConfig extends EvictionPolicyConfigBase + { + + protected void setEvictionPolicyClassName() + { + this.setEvictionPolicyClass(MyPolicy.class.getName()); + } + } +} --===============7051154567500469854==-- From jboss-qa-internal at redhat.com Sat Aug 23 11:18:23 2008 Content-Type: multipart/mixed; boundary="===============4080903801811689902==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23561?= Date: Sat, 23 Aug 2008 11:18:22 -0400 Message-ID: <1241118242.8631219504702163.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1097868414.4561219397498482.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============4080903801811689902== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/561/changes --===============4080903801811689902==-- From jboss-qa-internal at redhat.com Sat Aug 23 11:30:10 2008 Content-Type: multipart/mixed; boundary="===============3628178977148203017==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23427?= Date: Sat, 23 Aug 2008 11:30:07 -0400 Message-ID: <1254672863.8661219505407925.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 961692165.4451219394549530.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============3628178977148203017== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/427/changes --===============3628178977148203017==-- From jboss-qa-internal at redhat.com Sat Aug 23 12:05:10 2008 Content-Type: multipart/mixed; boundary="===============4097423028838088819==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_completed=3A_jboss-cache-?= =?utf-8?q?searchable-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Searchable_Editi?= =?utf-8?q?on_=234?= Date: Sat, 23 Aug 2008 12:05:08 -0400 Message-ID: <1776666243.8701219507508548.JavaMail.hudson@hudson1.qa.atl2.redhat.com> --===============4097423028838088819== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-searchable-trunk-jdk1= .6/org.jboss.cache$jbosscache-searchable/4/changes --===============4097423028838088819==-- From jboss-qa-internal at redhat.com Sat Aug 23 12:16:27 2008 Content-Type: multipart/mixed; boundary="===============8318740382742170065==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_completed=3A_jboss-cache-?= =?utf-8?q?searchable-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Searchable_Editi?= =?utf-8?q?on_=233?= Date: Sat, 23 Aug 2008 12:16:24 -0400 Message-ID: <336417814.8721219508184824.JavaMail.hudson@hudson1.qa.atl2.redhat.com> --===============8318740382742170065== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-searchable-trunk-jdk1= .5/org.jboss.cache$jbosscache-searchable/3/changes --===============8318740382742170065==-- From jboss-qa-internal at redhat.com Sun Aug 24 12:34:55 2008 Content-Type: multipart/mixed; boundary="===============1610800678609125483==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23428?= Date: Sun, 24 Aug 2008 12:34:54 -0400 Message-ID: <908234145.11811219595694493.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1254672863.8661219505407925.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============1610800678609125483== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/428/changes --===============1610800678609125483==-- From jboss-qa-internal at redhat.com Sun Aug 24 12:39:38 2008 Content-Type: multipart/mixed; boundary="===============6562038120888336585==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23562?= Date: Sun, 24 Aug 2008 12:39:28 -0400 Message-ID: <692138472.11831219595968652.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1241118242.8631219504702163.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============6562038120888336585== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/562/changes --===============6562038120888336585==-- From jboss-qa-internal at redhat.com Sun Aug 24 19:59:28 2008 Content-Type: multipart/mixed; boundary="===============2326965545631366398==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_completed=3A_jboss-cache-?= =?utf-8?q?core-2=2E1=2EX-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_=2345?= Date: Sun, 24 Aug 2008 19:59:26 -0400 Message-ID: <24119426.13191219622366763.JavaMail.hudson@hudson1.qa.atl2.redhat.com> --===============2326965545631366398== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-2.1.X-jdk1.6/org= .jboss.cache$jbosscache-core/45/changes --===============2326965545631366398==-- From jboss-qa-internal at redhat.com Sun Aug 24 22:47:00 2008 Content-Type: multipart/mixed; boundary="===============3393779333700294221==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_completed=3A_jboss-cache-?= =?utf-8?q?core-2=2E1=2EX-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_=2346?= Date: Sun, 24 Aug 2008 22:46:58 -0400 Message-ID: <982340062.13811219632418224.JavaMail.hudson@hudson1.qa.atl2.redhat.com> --===============3393779333700294221== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-2.1.X-jdk1.5/org= .jboss.cache$jbosscache-core/46/changes --===============3393779333700294221==-- From jbosscache-commits at lists.jboss.org Mon Aug 25 13:50:22 2008 Content-Type: multipart/mixed; boundary="===============0702087407447238182==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6611 - in core/trunk/src: main/java/org/jboss/cache/jmx and 8 other directories. Date: Mon, 25 Aug 2008 13:50:21 -0400 Message-ID: --===============0702087407447238182== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-25 13:50:21 -0400 (Mon, 25 Aug 2008) New Revision: 6611 Added: core/trunk/src/test/java/org/jboss/cache/multiplexer/PessimisticSyncRepl= TxTest.java core/trunk/src/test/java/org/jboss/cache/options/PessimisticFailSilently= Test.java core/trunk/src/test/java/org/jboss/cache/options/PessimisticLockAcquisit= ionTimeoutTest.java core/trunk/src/test/java/org/jboss/cache/options/PessimisticSuppressLock= ingTest.java core/trunk/src/test/java/org/jboss/cache/replicated/PessimisticSyncReplT= xTest.java core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/Abortio= nTest.java core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AsyncRo= llbackTxTest.java core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/Concurr= entTransactionalTest.java core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/Isolati= onLevelNoneTest.java core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/Pessimi= sticTransactionTest.java core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/Prepare= TxTest.java core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/StatusU= nknownTest.java Removed: core/trunk/src/test/java/org/jboss/cache/multiplexer/SyncReplTxTest.java core/trunk/src/test/java/org/jboss/cache/options/FailSilentlyTest.java core/trunk/src/test/java/org/jboss/cache/options/LockAcquisitionTimeoutT= est.java core/trunk/src/test/java/org/jboss/cache/options/SuppressLockingTest.java core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTxTest.java core/trunk/src/test/java/org/jboss/cache/transaction/AbortionTest.java core/trunk/src/test/java/org/jboss/cache/transaction/AsyncRollbackTxTest= .java core/trunk/src/test/java/org/jboss/cache/transaction/ConcurrentTransacti= onalTest.java core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelNoneT= est.java core/trunk/src/test/java/org/jboss/cache/transaction/PrepareTxTest.java core/trunk/src/test/java/org/jboss/cache/transaction/StatusUnknownTest.j= ava core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTest.java Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationIntercep= tor.java core/trunk/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransaction.ja= va core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransactionMan= ager.java core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListen= erTest.java core/trunk/src/test/java/org/jboss/cache/transaction/isolationlevels/Iso= lationLevelTestBase.java Log: fixed tests after changing default node locking scheme to MVCC Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationI= nterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterce= ptor.java 2008-08-23 12:40:58 UTC (rev 6610) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterce= ptor.java 2008-08-25 17:50:21 UTC (rev 6611) @@ -176,6 +176,7 @@ */ private void removeNodeFromCacheLoader(Fqn fqn) throws Throwable { + if (fqn =3D=3D null) return; InternalNode n; if (((n =3D dataContainer.peekInternalNode(fqn, true)) !=3D null) &&= n.isDataLoaded() && loader.exists(fqn)) { Modified: core/trunk/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java 2008-0= 8-23 12:40:58 UTC (rev 6610) +++ core/trunk/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java 2008-0= 8-25 17:50:21 UTC (rev 6611) @@ -91,8 +91,8 @@ int i =3D 0; if (log.isInfoEnabled()) { - log.info("Processing class " + instance.getClass()); - log.info("Number of attributes: " + atts.size()); + log.trace("Processing class " + instance.getClass()); + log.trace("Number of attributes: " + atts.size()); } MBeanAttributeInfo info; for (AttributeEntry entry : atts.values()) @@ -101,7 +101,7 @@ attrInfo[i++] =3D info; if (log.isInfoEnabled()) { - log.info("Attribute " + info.getName() + log.trace("Attribute " + info.getName() + "[r=3D" + info.isReadable() + ",w=3D" @@ -120,10 +120,10 @@ if (log.isInfoEnabled()) { if (ops.size() > 0) - log.info("Operations are:"); + log.trace("Operations are:"); for (MBeanOperationInfo op : opInfo) { - log.info("Operation " + op.getReturnType() + " " + op.getName(= )); + log.trace("Operation " + op.getReturnType() + " " + op.getName= ()); } } } Modified: core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransac= tion.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransaction.j= ava 2008-08-23 12:40:58 UTC (rev 6610) +++ core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransaction.j= ava 2008-08-25 17:50:21 UTC (rev 6611) @@ -24,7 +24,7 @@ { private int status =3D Status.STATUS_UNKNOWN; private static final Log log =3D LogFactory.getLog(DummyTransaction.cla= ss); - DummyBaseTransactionManager tm_; + protected DummyBaseTransactionManager tm_; = protected final Set participants =3D new CopyOnWriteAr= raySet(); = Modified: core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransac= tionManager.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransactionMa= nager.java 2008-08-23 12:40:58 UTC (rev 6610) +++ core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransactionMa= nager.java 2008-08-25 17:50:21 UTC (rev 6611) @@ -19,10 +19,10 @@ */ public class DummyTransactionManager extends DummyBaseTransactionManager { - static DummyTransactionManager instance =3D null; - static DummyUserTransaction utx =3D null; + protected static DummyTransactionManager instance =3D null; + protected static DummyUserTransaction utx =3D null; = - static Log log =3D LogFactory.getLog(DummyTransactionManager.class); + protected static Log log =3D LogFactory.getLog(DummyTransactionManager= .class); = private static final long serialVersionUID =3D 4396695354693176535L; = Copied: core/trunk/src/test/java/org/jboss/cache/multiplexer/PessimisticSyn= cReplTxTest.java (from rev 6585, core/trunk/src/test/java/org/jboss/cache/m= ultiplexer/SyncReplTxTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/multiplexer/PessimisticSyncRep= lTxTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/multiplexer/PessimisticSyncRep= lTxTest.java 2008-08-25 17:50:21 UTC (rev 6611) @@ -0,0 +1,77 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2006, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.cache.multiplexer; + +import org.jboss.cache.Cache; +import org.testng.AssertJUnit; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** + * Repeats the superclass tests, but with the multiplexer enabled. + * + * @author Brian Stansberry + * @version $Revision$ + */ +(a)Test(groups =3D {"functional", "jgroups"}, enabled =3D true) +public class PessimisticSyncReplTxTest extends org.jboss.cache.replicated.= PessimisticSyncReplTxTest +{ + private MultiplexerTestHelper muxHelper; + + @BeforeMethod(alwaysRun =3D true) + public void setUp() throws Exception + { + muxHelper =3D new MultiplexerTestHelper(); + + super.setUp(); + } + + @AfterMethod(alwaysRun =3D true) + public void tearDown() throws Exception + { + try + { + super.tearDown(); + } + finally + { + if (muxHelper !=3D null) + { + muxHelper.tearDown(); + muxHelper =3D null; + } + } + } + + @Override + protected void configureMultiplexer(Cache cache) throws Exception + { + muxHelper.configureCacheForMux(cache); + } + + @Override + protected void validateMultiplexer(Cache cache) + { + AssertJUnit.assertTrue("Cache is using multiplexer", cache.getConfig= uration().isUsingMultiplexer()); + } +} Property changes on: core/trunk/src/test/java/org/jboss/cache/multiplexer/P= essimisticSyncReplTxTest.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Deleted: core/trunk/src/test/java/org/jboss/cache/multiplexer/SyncReplTxTes= t.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/multiplexer/SyncReplTxTest.jav= a 2008-08-23 12:40:58 UTC (rev 6610) +++ core/trunk/src/test/java/org/jboss/cache/multiplexer/SyncReplTxTest.jav= a 2008-08-25 17:50:21 UTC (rev 6611) @@ -1,77 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2006, Red Hat Middleware LLC, and individual contributors - * as indicated by the @author tags. See the copyright.txt file in the - * distribution for a full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.jboss.cache.multiplexer; - -import org.jboss.cache.Cache; -import org.testng.AssertJUnit; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -/** - * Repeats the superclass tests, but with the multiplexer enabled. - * - * @author Brian Stansberry - * @version $Revision$ - */ -(a)Test(groups =3D {"functional", "jgroups"}, enabled =3D true) -public class SyncReplTxTest extends org.jboss.cache.replicated.SyncReplTxT= est -{ - private MultiplexerTestHelper muxHelper; - - @BeforeMethod(alwaysRun =3D true) - public void setUp() throws Exception - { - muxHelper =3D new MultiplexerTestHelper(); - - super.setUp(); - } - - @AfterMethod(alwaysRun =3D true) - public void tearDown() throws Exception - { - try - { - super.tearDown(); - } - finally - { - if (muxHelper !=3D null) - { - muxHelper.tearDown(); - muxHelper =3D null; - } - } - } - - @Override - protected void configureMultiplexer(Cache cache) throws Exception - { - muxHelper.configureCacheForMux(cache); - } - - @Override - protected void validateMultiplexer(Cache cache) - { - AssertJUnit.assertTrue("Cache is using multiplexer", cache.getConfig= uration().isUsingMultiplexer()); - } -} Modified: core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCach= eListenerTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListe= nerTest.java 2008-08-23 12:40:58 UTC (rev 6610) +++ core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListe= nerTest.java 2008-08-25 17:50:21 UTC (rev 6611) @@ -615,6 +615,7 @@ expected.add(new EventImpl(false, cache1, null, null, null, tx, true= , null, false, null, TRANSACTION_REGISTERED)); expected.add(new EventImpl(true, cache1, null, null, fqn, tx, true, = newFqn, false, null, NODE_MOVED)); expected.add(new EventImpl(false, cache1, null, null, fqn, tx, true,= newFqn, false, null, NODE_MOVED)); + assertEquals(expected.size(), eventLog1.events.size()); assertEquals(expected, eventLog1.events); assertEquals("Events log should be empty until commit time", 0, even= tLog2.events.size()); tm1.commit(); Deleted: core/trunk/src/test/java/org/jboss/cache/options/FailSilentlyTest.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/options/FailSilentlyTest.java = 2008-08-23 12:40:58 UTC (rev 6610) +++ core/trunk/src/test/java/org/jboss/cache/options/FailSilentlyTest.java = 2008-08-25 17:50:21 UTC (rev 6611) @@ -1,167 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package org.jboss.cache.options; - -import org.jboss.cache.CacheFactory; -import org.jboss.cache.CacheSPI; -import org.jboss.cache.DefaultCacheFactory; -import org.jboss.cache.Fqn; -import org.jboss.cache.config.Configuration; -import static org.testng.AssertJUnit.assertEquals; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import javax.transaction.Transaction; -import javax.transaction.TransactionManager; -import java.util.HashMap; -import java.util.Map; - -/** - * Tests passing in the failSilently option in various scenarios. - * - * @author Manik Surtani (manik(a)jbo= ss.org) - */ -(a)Test(groups =3D {"functional"}) -public class FailSilentlyTest -{ - private CacheSPI cache; - private TransactionManager manager; - private Transaction tx; - private Fqn fqn =3D Fqn.fromString("/a"); - private String key =3D "key"; - - @BeforeMethod(alwaysRun =3D true) - public void setUp() throws Exception - { - if (cache !=3D null) - tearDown(); - CacheFactory instance =3D new DefaultCacheFactory(); - cache =3D (CacheSPI) instance.createCache(false); - // very short acquisition timeout - cache.getConfiguration().setLockAcquisitionTimeout(100); - cache.getConfiguration().setTransactionManagerLookupClass("org.jboss= .cache.transaction.DummyTransactionManagerLookup"); - cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL); - cache.start(); - manager =3D cache.getTransactionManager(); - } - - @AfterMethod(alwaysRun =3D true) - public void tearDown() - { - if (tx !=3D null) - { - try - { - manager.resume(tx); - manager.rollback(); - } - catch (Exception e) - { - // who cares - } - } - if (cache !=3D null) - { - cache.stop(); - cache =3D null; - } - } - - public void testPutKeyValue() throws Exception - { - manager.begin(); - cache.put(fqn, key, "value"); - tx =3D manager.suspend(); - cache.getInvocationContext().getOptionOverrides().setFailSilently(tr= ue); - cache.put(fqn, key, "value2"); - } - - public void testPutData() throws Exception - { - Map data =3D new HashMap(); - data.put(key, "value"); - manager.begin(); - cache.put(fqn, data); - tx =3D manager.suspend(); - cache.getInvocationContext().getOptionOverrides().setFailSilently(tr= ue); - cache.put(fqn, data); - } - - public void testRemoveNode() throws Exception - { - cache.put(fqn, key, "value"); - manager.begin(); - // get a read lock - cache.get(fqn, key); - tx =3D manager.suspend(); - cache.getInvocationContext().getOptionOverrides().setFailSilently(tr= ue); - cache.removeNode(fqn); - } - - public void testRemoveKey() throws Exception - { - cache.put(fqn, key, "value"); - manager.begin(); - // get a read lock - cache.get(fqn, key); - tx =3D manager.suspend(); - cache.getInvocationContext().getOptionOverrides().setFailSilently(tr= ue); - cache.remove(fqn, key); - } - - public void testGetNode() throws Exception - { - cache.put(fqn, key, "value"); - manager.begin(); - // get a WL - cache.put(fqn, key, "value2"); - tx =3D manager.suspend(); - cache.getInvocationContext().getOptionOverrides().setFailSilently(tr= ue); - cache.getNode(fqn); - } - - public void testGetKey() throws Exception - { - cache.put(fqn, key, "value"); - manager.begin(); - // get a WL - cache.put(fqn, key, "value2"); - tx =3D manager.suspend(); - cache.getInvocationContext().getOptionOverrides().setFailSilently(tr= ue); - cache.get(fqn, key); - } - - public void testGetChildrenNames() throws Exception - { - cache.put(fqn, key, "value"); - manager.begin(); - // get a WL - cache.put(fqn, key, "value2"); - tx =3D manager.suspend(); - cache.getInvocationContext().getOptionOverrides().setFailSilently(tr= ue); - cache.getChildrenNames(fqn); - - } - - public void testPutThatWillFail() throws Exception - { - manager.begin(); - cache.put(fqn, "k", "v");// this will get WLs on / and /a - tx =3D manager.suspend(); - - assertEquals(2, cache.getNumberOfLocksHeld()); - - // now this call WILL fail, but should fail silently - i.e., not rol= l back. - manager.begin(); - cache.getInvocationContext().getOptionOverrides().setFailSilently(tr= ue); - cache.put(fqn, "x", "y"); - - // should not roll back, despite the cache put call failing/timing o= ut. - manager.commit(); - } -} Deleted: core/trunk/src/test/java/org/jboss/cache/options/LockAcquisitionTi= meoutTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/options/LockAcquisitionTimeout= Test.java 2008-08-23 12:40:58 UTC (rev 6610) +++ core/trunk/src/test/java/org/jboss/cache/options/LockAcquisitionTimeout= Test.java 2008-08-25 17:50:21 UTC (rev 6611) @@ -1,359 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package org.jboss.cache.options; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jboss.cache.CacheSPI; -import org.jboss.cache.DefaultCacheFactory; -import org.jboss.cache.Fqn; -import org.jboss.cache.config.Configuration; -import org.jboss.cache.config.Option; -import org.jboss.cache.lock.TimeoutException; -import static org.testng.AssertJUnit.*; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import javax.transaction.TransactionManager; - -/** - * Test functionality of {@link Option#setLockAcquisitionTimeout(int)}. - * - * @author Brian Stansberry - */ -(a)Test(groups =3D {"functional"}) -public class LockAcquisitionTimeoutTest -{ - private static final Log log =3D LogFactory.getLog(LockAcquisitionTimeo= utTest.class); - - private static final Fqn FQNA =3D Fqn.fromString("/A"); - private static final Fqn FQNB =3D Fqn.fromString("/B"); - private static final String KEY =3D "key"; - private static final String VALUE1 =3D "value1"; - private static final String VALUE2 =3D "value2"; - - private CacheSPI cache; - private Option option; - - @BeforeMethod(alwaysRun =3D true) - public void setUp() throws Exception - { - cache =3D (CacheSPI) new DefaultCacheFactory().createCache(false); - Configuration c =3D cache.getConfiguration(); - c.setCacheMode("REPL_SYNC"); - c.setTransactionManagerLookupClass("org.jboss.cache.transaction.Dumm= yTransactionManagerLookup"); - - cache.start(); - - option =3D new Option(); - option.setLockAcquisitionTimeout(0); - } - - @AfterMethod(alwaysRun =3D true) - public void tearDown() - { - if (cache !=3D null) - { - cache.stop(); - cache =3D null; - } - } - - /** - * Confirms that doing a put with a lockAcquisitionTime option set - * does the put as expected. There is no other thread or tx contesting - * the lock the put needs, so this is just a simple test that the option - * doesn't somehow screw up the put. - * - * @throws Exception - */ - public void testSimplePut() throws Exception - { - log.info("++++ testSimplePut() ++++"); - simplePutTest(false); - } - - /** - * Confirms that doing a put with a lockAcquisitionTime option set - * does the put as expected when executed within a transaction. There i= s no - * other thread or tx contesting the lock the put needs, so this is jus= t a - * simple test that the option doesn't somehow screw up the put. - * - * @throws Exception - */ - public void testSimplePutWithTx() throws Exception - { - log.info("++++ testSimplePutWithTx() ++++"); - simplePutTest(true); - } - - private void simplePutTest(boolean useTx) throws Exception - { - TransactionManager tm =3D useTx ? cache.getTransactionManager() : nu= ll; - LowTimeoutSetter setter =3D new LowTimeoutSetter(tm); - setter.start(); - - setter.join(2000); - if (!setter.finished) - { - setter.interrupt(); - fail("Puts failed to complete in a timely manner"); - } - - assertNull("LowTimeoutSetter saw no TimeoutException", setter.te); - assertNull("LowTimeoutSetter saw no misc Exception", setter.failure); - assertEquals("Cache correct for " + FQNA, VALUE2, cache.get(FQNA, KE= Y)); - assertEquals("Cache correct for " + FQNB, VALUE2, cache.get(FQNB, KE= Y)); - } - - /** - * Confirms that a put with a lockAcquisitionTimeout option set to zero - * fails promptly in the presence of a lock on the target node. - * - * @throws Exception - */ - public void testContestedPut() throws Exception - { - log.info("++++ testContestedPut() ++++"); - contestedPutTest(false); - } - - /** - * Confirms that a put with a lockAcquisitionTimeout option set to zero - * is ignored if executed within a transaction. - * - * @throws Exception - */ - public void testContestedPutWithTx() throws Exception - { - log.info("++++ testContestedPutWithTx() ++++"); - contestedPutTest(true); - } - - private void contestedPutTest(boolean tx) throws Exception - { - TransactionManager mgr =3D cache.getTransactionManager(); - mgr.begin(); - - LowTimeoutSetter setter =3D null; - try - { - // Put a WL on /A - cache.put(FQNA, KEY, VALUE1); - - // Launch a thread that tries to write to /A - setter =3D new LowTimeoutSetter(tx ? mgr : null); - setter.start(); - - setter.join(2000); - if (!setter.finished) - { - setter.interrupt(); - fail("Puts failed to complete in a timely manner"); - } - } - finally - { - // always commit the tx - mgr.commit(); - } - - assertNotNull("LowTimeoutSetter saw TimeoutException", setter.te); - assertNull("LowTimeoutSetter saw no misc Exception", setter.failure); - assertEquals("Cache correct for " + FQNA, VALUE1, cache.get(FQNA, KE= Y)); - assertEquals("Cache correct for " + FQNB, VALUE2, cache.get(FQNB, KE= Y)); - - } - - public void testSimpleRead() throws Exception - { - log.info("++++++ testSimpleRead() ++++++"); - simpleReadTest(false); - } - - public void testSimpleReadWithTx() throws Exception - { - log.info("++++++ testSimpleReadWithTx() ++++++"); - simpleReadTest(true); - } - - private void simpleReadTest(boolean useTx) throws Exception - { - TransactionManager tm =3D useTx ? cache.getTransactionManager() : nu= ll; - LowTimeoutReader reader =3D new LowTimeoutReader(tm); - - cache.put(FQNA, KEY, VALUE1); - - reader.start(); - - reader.join(2000); - if (!reader.finished) - { - reader.interrupt(); - fail("Read failed to complete in a timely manner"); - } - - assertNull("LowTimeoutSetter saw no TimeoutException", reader.te); - assertNull("LowTimeoutSetter saw no misc Exception", reader.failure); - assertEquals("LowTimeoutSetter correct for " + FQNA, VALUE1, reader.= value); - - } - - public void testContestedRead() throws Exception - { - log.info("++++++ testContestedRead() ++++++"); - contestedReadTest(false); - } - - public void testContestedReadWithTx() throws Exception - { - log.info("++++++ testContestedReadWithTx() ++++++"); - contestedReadTest(true); - } - - private void contestedReadTest(boolean tx) throws Exception - { - TransactionManager mgr =3D cache.getTransactionManager(); - mgr.begin(); - - LowTimeoutReader reader =3D null; - try - { - // Put a WL on /A - cache.put(FQNA, KEY, VALUE1); - - // Launch a thread that tries to read from /A - reader =3D new LowTimeoutReader(tx ? mgr : null); - reader.start(); - - reader.join(2000); - if (!reader.finished) - { - reader.interrupt(); - fail("Read failed to complete in a timely manner"); - } - } - finally - { - // always commit the tx - mgr.commit(); - } - - assertNotNull("LowTimeoutSetter saw TimeoutException", reader.te); - assertNull("LowTimeoutSetter saw no misc Exception", reader.failure); - assertNull("LowTimeoutSetter unable to read " + FQNA, reader.value); - - } - - class LowTimeoutSetter extends Thread - { - TransactionManager tm; - TimeoutException te; - Throwable failure; - boolean finished; - - LowTimeoutSetter(TransactionManager tm) - { - this.tm =3D tm; - } - - public void run() - { - try - { - try - { - if (tm !=3D null) - { - tm.begin(); - } - - cache.put(FQNB, KEY, VALUE2); - - cache.getInvocationContext().setOptionOverrides(option); - cache.put(FQNA, KEY, VALUE2); - } - catch (TimeoutException te) - { - this.te =3D te; - } - catch (Exception e) - { - if (tm !=3D null) - tm.setRollbackOnly(); - throw e; - } - finally - { - if (tm !=3D null) - { - tm.commit(); - } - finished =3D true; - } - } - catch (Throwable t) - { - failure =3D t; - } - } - } - - class LowTimeoutReader extends Thread - { - TransactionManager tm; - TimeoutException te; - Throwable failure; - Object value; - boolean finished; - - LowTimeoutReader(TransactionManager tm) - { - this.tm =3D tm; - } - - public void run() - { - try - { - try - { - if (tm !=3D null) - { - tm.begin(); - } - - cache.getInvocationContext().setOptionOverrides(option); - value =3D cache.get(FQNA, KEY); - } - catch (TimeoutException te) - { - this.te =3D te; - } - catch (Exception e) - { - if (tm !=3D null) - tm.setRollbackOnly(); - throw e; - } - finally - { - if (tm !=3D null) - { - tm.commit(); - } - finished =3D true; - } - } - catch (Throwable t) - { - failure =3D t; - } - } - } -} Copied: core/trunk/src/test/java/org/jboss/cache/options/PessimisticFailSil= entlyTest.java (from rev 6585, core/trunk/src/test/java/org/jboss/cache/opt= ions/FailSilentlyTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/options/PessimisticFailSilentl= yTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/options/PessimisticFailSilentl= yTest.java 2008-08-25 17:50:21 UTC (rev 6611) @@ -0,0 +1,168 @@ +/* + * JBoss, Home of Professional Open Source + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.cache.options; + +import org.jboss.cache.CacheFactory; +import org.jboss.cache.CacheSPI; +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.Fqn; +import org.jboss.cache.config.Configuration; +import static org.testng.AssertJUnit.assertEquals; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import javax.transaction.Transaction; +import javax.transaction.TransactionManager; +import java.util.HashMap; +import java.util.Map; + +/** + * Tests passing in the failSilently option in various scenarios. + * + * @author Manik Surtani (manik(a)jbo= ss.org) + */ +(a)Test(groups =3D {"functional"}) +public class PessimisticFailSilentlyTest +{ + private CacheSPI cache; + private TransactionManager manager; + private Transaction tx; + private Fqn fqn =3D Fqn.fromString("/a"); + private String key =3D "key"; + + @BeforeMethod(alwaysRun =3D true) + public void setUp() throws Exception + { + if (cache !=3D null) + tearDown(); + CacheFactory instance =3D new DefaultCacheFactory(); + cache =3D (CacheSPI) instance.createCache(false); + // very short acquisition timeout + cache.getConfiguration().setLockAcquisitionTimeout(100); + cache.getConfiguration().setTransactionManagerLookupClass("org.jboss= .cache.transaction.DummyTransactionManagerLookup"); + cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL); + cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLock= ingScheme.PESSIMISTIC); + cache.start(); + manager =3D cache.getTransactionManager(); + } + + @AfterMethod(alwaysRun =3D true) + public void tearDown() + { + if (tx !=3D null) + { + try + { + manager.resume(tx); + manager.rollback(); + } + catch (Exception e) + { + // who cares + } + } + if (cache !=3D null) + { + cache.stop(); + cache =3D null; + } + } + + public void testPutKeyValue() throws Exception + { + manager.begin(); + cache.put(fqn, key, "value"); + tx =3D manager.suspend(); + cache.getInvocationContext().getOptionOverrides().setFailSilently(tr= ue); + cache.put(fqn, key, "value2"); + } + + public void testPutData() throws Exception + { + Map data =3D new HashMap(); + data.put(key, "value"); + manager.begin(); + cache.put(fqn, data); + tx =3D manager.suspend(); + cache.getInvocationContext().getOptionOverrides().setFailSilently(tr= ue); + cache.put(fqn, data); + } + + public void testRemoveNode() throws Exception + { + cache.put(fqn, key, "value"); + manager.begin(); + // get a read lock + cache.get(fqn, key); + tx =3D manager.suspend(); + cache.getInvocationContext().getOptionOverrides().setFailSilently(tr= ue); + cache.removeNode(fqn); + } + + public void testRemoveKey() throws Exception + { + cache.put(fqn, key, "value"); + manager.begin(); + // get a read lock + cache.get(fqn, key); + tx =3D manager.suspend(); + cache.getInvocationContext().getOptionOverrides().setFailSilently(tr= ue); + cache.remove(fqn, key); + } + + public void testGetNode() throws Exception + { + cache.put(fqn, key, "value"); + manager.begin(); + // get a WL + cache.put(fqn, key, "value2"); + tx =3D manager.suspend(); + cache.getInvocationContext().getOptionOverrides().setFailSilently(tr= ue); + cache.getNode(fqn); + } + + public void testGetKey() throws Exception + { + cache.put(fqn, key, "value"); + manager.begin(); + // get a WL + cache.put(fqn, key, "value2"); + tx =3D manager.suspend(); + cache.getInvocationContext().getOptionOverrides().setFailSilently(tr= ue); + cache.get(fqn, key); + } + + public void testGetChildrenNames() throws Exception + { + cache.put(fqn, key, "value"); + manager.begin(); + // get a WL + cache.put(fqn, key, "value2"); + tx =3D manager.suspend(); + cache.getInvocationContext().getOptionOverrides().setFailSilently(tr= ue); + cache.getChildrenNames(fqn); + + } + + public void testPutThatWillFail() throws Exception + { + manager.begin(); + cache.put(fqn, "k", "v");// this will get WLs on / and /a + tx =3D manager.suspend(); + + assertEquals(2, cache.getNumberOfLocksHeld()); + + // now this call WILL fail, but should fail silently - i.e., not rol= l back. + manager.begin(); + cache.getInvocationContext().getOptionOverrides().setFailSilently(tr= ue); + cache.put(fqn, "x", "y"); + + // should not roll back, despite the cache put call failing/timing o= ut. + manager.commit(); + } +} Property changes on: core/trunk/src/test/java/org/jboss/cache/options/Pessi= misticFailSilentlyTest.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Copied: core/trunk/src/test/java/org/jboss/cache/options/PessimisticLockAcq= uisitionTimeoutTest.java (from rev 6585, core/trunk/src/test/java/org/jboss= /cache/options/LockAcquisitionTimeoutTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/options/PessimisticLockAcquisi= tionTimeoutTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/options/PessimisticLockAcquisi= tionTimeoutTest.java 2008-08-25 17:50:21 UTC (rev 6611) @@ -0,0 +1,360 @@ +/* + * JBoss, Home of Professional Open Source + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.cache.options; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.cache.CacheSPI; +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.Fqn; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.Option; +import org.jboss.cache.lock.TimeoutException; +import static org.testng.AssertJUnit.*; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import javax.transaction.TransactionManager; + +/** + * Test functionality of {@link Option#setLockAcquisitionTimeout(int)}. + * + * @author Brian Stansberry + */ +(a)Test(groups =3D {"functional"}) +public class PessimisticLockAcquisitionTimeoutTest +{ + private static final Log log =3D LogFactory.getLog(PessimisticLockAcqui= sitionTimeoutTest.class); + + private static final Fqn FQNA =3D Fqn.fromString("/A"); + private static final Fqn FQNB =3D Fqn.fromString("/B"); + private static final String KEY =3D "key"; + private static final String VALUE1 =3D "value1"; + private static final String VALUE2 =3D "value2"; + + private CacheSPI cache; + private Option option; + + @BeforeMethod(alwaysRun =3D true) + public void setUp() throws Exception + { + cache =3D (CacheSPI) new DefaultCacheFactory().createCache(false); + Configuration c =3D cache.getConfiguration(); + c.setCacheMode("REPL_SYNC"); + cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLock= ingScheme.PESSIMISTIC); + c.setTransactionManagerLookupClass("org.jboss.cache.transaction.Dumm= yTransactionManagerLookup"); + + cache.start(); + + option =3D new Option(); + option.setLockAcquisitionTimeout(0); + } + + @AfterMethod(alwaysRun =3D true) + public void tearDown() + { + if (cache !=3D null) + { + cache.stop(); + cache =3D null; + } + } + + /** + * Confirms that doing a put with a lockAcquisitionTime option set + * does the put as expected. There is no other thread or tx contesting + * the lock the put needs, so this is just a simple test that the option + * doesn't somehow screw up the put. + * + * @throws Exception + */ + public void testSimplePut() throws Exception + { + log.info("++++ testSimplePut() ++++"); + simplePutTest(false); + } + + /** + * Confirms that doing a put with a lockAcquisitionTime option set + * does the put as expected when executed within a transaction. There i= s no + * other thread or tx contesting the lock the put needs, so this is jus= t a + * simple test that the option doesn't somehow screw up the put. + * + * @throws Exception + */ + public void testSimplePutWithTx() throws Exception + { + log.info("++++ testSimplePutWithTx() ++++"); + simplePutTest(true); + } + + private void simplePutTest(boolean useTx) throws Exception + { + TransactionManager tm =3D useTx ? cache.getTransactionManager() : nu= ll; + LowTimeoutSetter setter =3D new LowTimeoutSetter(tm); + setter.start(); + + setter.join(2000); + if (!setter.finished) + { + setter.interrupt(); + fail("Puts failed to complete in a timely manner"); + } + + assertNull("LowTimeoutSetter saw no TimeoutException", setter.te); + assertNull("LowTimeoutSetter saw no misc Exception", setter.failure); + assertEquals("Cache correct for " + FQNA, VALUE2, cache.get(FQNA, KE= Y)); + assertEquals("Cache correct for " + FQNB, VALUE2, cache.get(FQNB, KE= Y)); + } + + /** + * Confirms that a put with a lockAcquisitionTimeout option set to zero + * fails promptly in the presence of a lock on the target node. + * + * @throws Exception + */ + public void testContestedPut() throws Exception + { + log.info("++++ testContestedPut() ++++"); + contestedPutTest(false); + } + + /** + * Confirms that a put with a lockAcquisitionTimeout option set to zero + * is ignored if executed within a transaction. + * + * @throws Exception + */ + public void testContestedPutWithTx() throws Exception + { + log.info("++++ testContestedPutWithTx() ++++"); + contestedPutTest(true); + } + + private void contestedPutTest(boolean tx) throws Exception + { + TransactionManager mgr =3D cache.getTransactionManager(); + mgr.begin(); + + LowTimeoutSetter setter =3D null; + try + { + // Put a WL on /A + cache.put(FQNA, KEY, VALUE1); + + // Launch a thread that tries to write to /A + setter =3D new LowTimeoutSetter(tx ? mgr : null); + setter.start(); + + setter.join(2000); + if (!setter.finished) + { + setter.interrupt(); + fail("Puts failed to complete in a timely manner"); + } + } + finally + { + // always commit the tx + mgr.commit(); + } + + assertNotNull("LowTimeoutSetter saw TimeoutException", setter.te); + assertNull("LowTimeoutSetter saw no misc Exception", setter.failure); + assertEquals("Cache correct for " + FQNA, VALUE1, cache.get(FQNA, KE= Y)); + assertEquals("Cache correct for " + FQNB, VALUE2, cache.get(FQNB, KE= Y)); + + } + + public void testSimpleRead() throws Exception + { + log.info("++++++ testSimpleRead() ++++++"); + simpleReadTest(false); + } + + public void testSimpleReadWithTx() throws Exception + { + log.info("++++++ testSimpleReadWithTx() ++++++"); + simpleReadTest(true); + } + + private void simpleReadTest(boolean useTx) throws Exception + { + TransactionManager tm =3D useTx ? cache.getTransactionManager() : nu= ll; + LowTimeoutReader reader =3D new LowTimeoutReader(tm); + + cache.put(FQNA, KEY, VALUE1); + + reader.start(); + + reader.join(2000); + if (!reader.finished) + { + reader.interrupt(); + fail("Read failed to complete in a timely manner"); + } + + assertNull("LowTimeoutSetter saw no TimeoutException", reader.te); + assertNull("LowTimeoutSetter saw no misc Exception", reader.failure); + assertEquals("LowTimeoutSetter correct for " + FQNA, VALUE1, reader.= value); + + } + + public void testContestedRead() throws Exception + { + log.info("++++++ testContestedRead() ++++++"); + contestedReadTest(false); + } + + public void testContestedReadWithTx() throws Exception + { + log.info("++++++ testContestedReadWithTx() ++++++"); + contestedReadTest(true); + } + + private void contestedReadTest(boolean tx) throws Exception + { + TransactionManager mgr =3D cache.getTransactionManager(); + mgr.begin(); + + LowTimeoutReader reader =3D null; + try + { + // Put a WL on /A + cache.put(FQNA, KEY, VALUE1); + + // Launch a thread that tries to read from /A + reader =3D new LowTimeoutReader(tx ? mgr : null); + reader.start(); + + reader.join(2000); + if (!reader.finished) + { + reader.interrupt(); + fail("Read failed to complete in a timely manner"); + } + } + finally + { + // always commit the tx + mgr.commit(); + } + + assertNotNull("LowTimeoutSetter saw TimeoutException", reader.te); + assertNull("LowTimeoutSetter saw no misc Exception", reader.failure); + assertNull("LowTimeoutSetter unable to read " + FQNA, reader.value); + + } + + class LowTimeoutSetter extends Thread + { + TransactionManager tm; + TimeoutException te; + Throwable failure; + boolean finished; + + LowTimeoutSetter(TransactionManager tm) + { + this.tm =3D tm; + } + + public void run() + { + try + { + try + { + if (tm !=3D null) + { + tm.begin(); + } + + cache.put(FQNB, KEY, VALUE2); + + cache.getInvocationContext().setOptionOverrides(option); + cache.put(FQNA, KEY, VALUE2); + } + catch (TimeoutException te) + { + this.te =3D te; + } + catch (Exception e) + { + if (tm !=3D null) + tm.setRollbackOnly(); + throw e; + } + finally + { + if (tm !=3D null) + { + tm.commit(); + } + finished =3D true; + } + } + catch (Throwable t) + { + failure =3D t; + } + } + } + + class LowTimeoutReader extends Thread + { + TransactionManager tm; + TimeoutException te; + Throwable failure; + Object value; + boolean finished; + + LowTimeoutReader(TransactionManager tm) + { + this.tm =3D tm; + } + + public void run() + { + try + { + try + { + if (tm !=3D null) + { + tm.begin(); + } + + cache.getInvocationContext().setOptionOverrides(option); + value =3D cache.get(FQNA, KEY); + } + catch (TimeoutException te) + { + this.te =3D te; + } + catch (Exception e) + { + if (tm !=3D null) + tm.setRollbackOnly(); + throw e; + } + finally + { + if (tm !=3D null) + { + tm.commit(); + } + finished =3D true; + } + } + catch (Throwable t) + { + failure =3D t; + } + } + } +} Property changes on: core/trunk/src/test/java/org/jboss/cache/options/Pessi= misticLockAcquisitionTimeoutTest.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + native Copied: core/trunk/src/test/java/org/jboss/cache/options/PessimisticSuppres= sLockingTest.java (from rev 6585, core/trunk/src/test/java/org/jboss/cache/= options/SuppressLockingTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/options/PessimisticSuppressLoc= kingTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/options/PessimisticSuppressLoc= kingTest.java 2008-08-25 17:50:21 UTC (rev 6611) @@ -0,0 +1,185 @@ +/* + * JBoss, Home of Professional Open Source + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.cache.options; + +import org.jboss.cache.CacheFactory; +import org.jboss.cache.CacheSPI; +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.Fqn; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.transaction.DummyTransactionManagerLookup; +import static org.testng.AssertJUnit.*; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import javax.transaction.TransactionManager; +import java.util.HashMap; +import java.util.Map; + +/** + * Tests the suppression of locking nodes + * + * @author Manik Surtani (manik(a)jbo= ss.org) + */ +(a)Test(groups =3D {"functional"}) +public class PessimisticSuppressLockingTest +{ + private Fqn fqn =3D Fqn.fromString("/blah"); + private Fqn fqn1 =3D Fqn.fromString("/blah/1"); + + private CacheSPI cache; + + private TransactionManager m; + + @BeforeMethod(alwaysRun =3D true) + public void setUp() + { + Configuration config =3D new Configuration(); + config.setCacheMode(Configuration.CacheMode.LOCAL); + config.setTransactionManagerLookupClass(DummyTransactionManagerLooku= p.class.getName()); + CacheFactory instance =3D new DefaultCacheFactory(); + config.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMIS= TIC); + cache =3D (CacheSPI) instance.createCache(config); + m =3D cache.getTransactionManager(); + } + + @AfterMethod(alwaysRun =3D true) + public void tearDown() + { + if (cache !=3D null) + { + cache.stop(); + cache =3D null; + } + m =3D null; + } + + public void testSuppressionOfWriteLocks() throws Exception + { + TransactionManager m =3D cache.getTransactionManager(); + + m.begin(); + assertFalse(cache.getInvocationContext().getOptionOverrides().isSupp= ressLocking()); + cache.put(fqn, "x", "1"); + assertFalse(cache.getInvocationContext().getOptionOverrides().isSupp= ressLocking()); + assertEquals(2, cache.getNumberOfLocksHeld()); + m.commit(); + assertEquals(0, cache.getNumberOfLocksHeld()); + + cache.removeNode(fqn); + + m.begin(); + cache.getInvocationContext().getOptionOverrides().setSuppressLocking= (true); + assertTrue(cache.getInvocationContext().getOptionOverrides().isSuppr= essLocking()); + cache.put(fqn, "x", "2"); + assertFalse(cache.getInvocationContext().getOptionOverrides().isSupp= ressLocking()); + assertEquals(0, cache.getNumberOfLocksHeld()); + m.commit(); + assertEquals(0, cache.getNumberOfLocksHeld()); + + // test normal operation again + cache.removeNode(fqn); + + m.begin(); + assertFalse(cache.getInvocationContext().getOptionOverrides().isSupp= ressLocking()); + cache.put(fqn, "x", "3"); + assertFalse(cache.getInvocationContext().getOptionOverrides().isSupp= ressLocking()); + assertEquals(2, cache.getNumberOfLocksHeld()); + m.commit(); + assertEquals(0, cache.getNumberOfLocksHeld()); + } + + /** + * This one fails now. + * + * @throws Exception + */ + public void testSuppressionOf2WriteLocks() throws Exception + { + TransactionManager m =3D cache.getTransactionManager(); + + m.begin(); + cache.put(fqn, "x", "1"); + assertEquals(2, cache.getNumberOfLocksHeld()); + m.commit(); + assertEquals(0, cache.getNumberOfLocksHeld()); + + cache.removeNode(fqn); + + m.begin(); + cache.getInvocationContext().getOptionOverrides().setSuppressLocking= (true); + cache.put(fqn, "x", "2"); + cache.getInvocationContext().getOptionOverrides().setSuppressLocking= (true); + cache.put(fqn1, "y", "3"); + assertEquals(0, cache.getNumberOfLocksHeld()); + m.commit(); + assertEquals(0, cache.getNumberOfLocksHeld()); + + Map map =3D new HashMap(); + map.put("x", "1"); + m.begin(); + cache.getInvocationContext().getOptionOverrides().setSuppressLocking= (true); + cache.put(fqn, map); + cache.getInvocationContext().getOptionOverrides().setSuppressLocking= (true); + cache.put(fqn1, map); + assertEquals(0, cache.getNumberOfLocksHeld()); + m.commit(); + assertEquals(0, cache.getNumberOfLocksHeld()); + + // test normal operation again + cache.removeNode(fqn); + + m.begin(); + cache.put(fqn, "x", "3"); + assertEquals(2, cache.getNumberOfLocksHeld()); + m.commit(); + assertEquals(0, cache.getNumberOfLocksHeld()); + } + + public void testSuppressionOfReadLocks() throws Exception + { + cache.put(fqn, "x", "y"); + + m.begin(); + assertFalse(cache.getInvocationContext().getOptionOverrides().isSupp= ressLocking()); + cache.get(fqn, "x"); + assertFalse(cache.getInvocationContext().getOptionOverrides().isSupp= ressLocking()); + assertEquals(2, cache.getNumberOfLocksHeld()); + m.commit(); + assertEquals(0, cache.getNumberOfLocksHeld()); + + m.begin(); + cache.getInvocationContext().getOptionOverrides().setSuppressLocking= (true); + assertTrue(cache.getInvocationContext().getOptionOverrides().isSuppr= essLocking()); + cache.get(fqn, "x"); + assertFalse(cache.getInvocationContext().getOptionOverrides().isSupp= ressLocking()); + assertEquals(0, cache.getNumberOfLocksHeld()); + m.commit(); + assertEquals(0, cache.getNumberOfLocksHeld()); + + // test normal operation again + + m.begin(); + assertFalse(cache.getInvocationContext().getOptionOverrides().isSupp= ressLocking()); + cache.get(fqn, "x"); + assertFalse(cache.getInvocationContext().getOptionOverrides().isSupp= ressLocking()); + assertEquals(2, cache.getNumberOfLocksHeld()); + m.commit(); + assertEquals(0, cache.getNumberOfLocksHeld()); + } + + public void testNodeCreation() + { + assertNull(cache.getRoot().getChild(fqn)); + cache.getInvocationContext().getOptionOverrides().setSuppressLocking= (true); + cache.put(fqn, "x", "y"); + assertEquals(0, cache.getNumberOfLocksHeld()); + assertEquals("y", cache.getRoot().getChild(fqn).get("x")); + } + +} Property changes on: core/trunk/src/test/java/org/jboss/cache/options/Pessi= misticSuppressLockingTest.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Deleted: core/trunk/src/test/java/org/jboss/cache/options/SuppressLockingTe= st.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/options/SuppressLockingTest.ja= va 2008-08-23 12:40:58 UTC (rev 6610) +++ core/trunk/src/test/java/org/jboss/cache/options/SuppressLockingTest.ja= va 2008-08-25 17:50:21 UTC (rev 6611) @@ -1,184 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package org.jboss.cache.options; - -import org.jboss.cache.CacheFactory; -import org.jboss.cache.CacheSPI; -import org.jboss.cache.DefaultCacheFactory; -import org.jboss.cache.Fqn; -import org.jboss.cache.config.Configuration; -import org.jboss.cache.transaction.DummyTransactionManagerLookup; -import static org.testng.AssertJUnit.*; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import javax.transaction.TransactionManager; -import java.util.HashMap; -import java.util.Map; - -/** - * Tests the suppression of locking nodes - * - * @author Manik Surtani (manik(a)jbo= ss.org) - */ -(a)Test(groups =3D {"functional"}) -public class SuppressLockingTest -{ - private Fqn fqn =3D Fqn.fromString("/blah"); - private Fqn fqn1 =3D Fqn.fromString("/blah/1"); - - private CacheSPI cache; - - private TransactionManager m; - - @BeforeMethod(alwaysRun =3D true) - public void setUp() - { - Configuration config =3D new Configuration(); - config.setCacheMode(Configuration.CacheMode.LOCAL); - config.setTransactionManagerLookupClass(DummyTransactionManagerLooku= p.class.getName()); - CacheFactory instance =3D new DefaultCacheFactory(); - cache =3D (CacheSPI) instance.createCache(config); - m =3D cache.getTransactionManager(); - } - - @AfterMethod(alwaysRun =3D true) - public void tearDown() - { - if (cache !=3D null) - { - cache.stop(); - cache =3D null; - } - m =3D null; - } - - public void testSuppressionOfWriteLocks() throws Exception - { - TransactionManager m =3D cache.getTransactionManager(); - - m.begin(); - assertFalse(cache.getInvocationContext().getOptionOverrides().isSupp= ressLocking()); - cache.put(fqn, "x", "1"); - assertFalse(cache.getInvocationContext().getOptionOverrides().isSupp= ressLocking()); - assertEquals(2, cache.getNumberOfLocksHeld()); - m.commit(); - assertEquals(0, cache.getNumberOfLocksHeld()); - - cache.removeNode(fqn); - - m.begin(); - cache.getInvocationContext().getOptionOverrides().setSuppressLocking= (true); - assertTrue(cache.getInvocationContext().getOptionOverrides().isSuppr= essLocking()); - cache.put(fqn, "x", "2"); - assertFalse(cache.getInvocationContext().getOptionOverrides().isSupp= ressLocking()); - assertEquals(0, cache.getNumberOfLocksHeld()); - m.commit(); - assertEquals(0, cache.getNumberOfLocksHeld()); - - // test normal operation again - cache.removeNode(fqn); - - m.begin(); - assertFalse(cache.getInvocationContext().getOptionOverrides().isSupp= ressLocking()); - cache.put(fqn, "x", "3"); - assertFalse(cache.getInvocationContext().getOptionOverrides().isSupp= ressLocking()); - assertEquals(2, cache.getNumberOfLocksHeld()); - m.commit(); - assertEquals(0, cache.getNumberOfLocksHeld()); - } - - /** - * This one fails now. - * - * @throws Exception - */ - public void testSuppressionOf2WriteLocks() throws Exception - { - TransactionManager m =3D cache.getTransactionManager(); - - m.begin(); - cache.put(fqn, "x", "1"); - assertEquals(2, cache.getNumberOfLocksHeld()); - m.commit(); - assertEquals(0, cache.getNumberOfLocksHeld()); - - cache.removeNode(fqn); - - m.begin(); - cache.getInvocationContext().getOptionOverrides().setSuppressLocking= (true); - cache.put(fqn, "x", "2"); - cache.getInvocationContext().getOptionOverrides().setSuppressLocking= (true); - cache.put(fqn1, "y", "3"); - assertEquals(0, cache.getNumberOfLocksHeld()); - m.commit(); - assertEquals(0, cache.getNumberOfLocksHeld()); - - Map map =3D new HashMap(); - map.put("x", "1"); - m.begin(); - cache.getInvocationContext().getOptionOverrides().setSuppressLocking= (true); - cache.put(fqn, map); - cache.getInvocationContext().getOptionOverrides().setSuppressLocking= (true); - cache.put(fqn1, map); - assertEquals(0, cache.getNumberOfLocksHeld()); - m.commit(); - assertEquals(0, cache.getNumberOfLocksHeld()); - - // test normal operation again - cache.removeNode(fqn); - - m.begin(); - cache.put(fqn, "x", "3"); - assertEquals(2, cache.getNumberOfLocksHeld()); - m.commit(); - assertEquals(0, cache.getNumberOfLocksHeld()); - } - - public void testSuppressionOfReadLocks() throws Exception - { - cache.put(fqn, "x", "y"); - - m.begin(); - assertFalse(cache.getInvocationContext().getOptionOverrides().isSupp= ressLocking()); - cache.get(fqn, "x"); - assertFalse(cache.getInvocationContext().getOptionOverrides().isSupp= ressLocking()); - assertEquals(2, cache.getNumberOfLocksHeld()); - m.commit(); - assertEquals(0, cache.getNumberOfLocksHeld()); - - m.begin(); - cache.getInvocationContext().getOptionOverrides().setSuppressLocking= (true); - assertTrue(cache.getInvocationContext().getOptionOverrides().isSuppr= essLocking()); - cache.get(fqn, "x"); - assertFalse(cache.getInvocationContext().getOptionOverrides().isSupp= ressLocking()); - assertEquals(0, cache.getNumberOfLocksHeld()); - m.commit(); - assertEquals(0, cache.getNumberOfLocksHeld()); - - // test normal operation again - - m.begin(); - assertFalse(cache.getInvocationContext().getOptionOverrides().isSupp= ressLocking()); - cache.get(fqn, "x"); - assertFalse(cache.getInvocationContext().getOptionOverrides().isSupp= ressLocking()); - assertEquals(2, cache.getNumberOfLocksHeld()); - m.commit(); - assertEquals(0, cache.getNumberOfLocksHeld()); - } - - public void testNodeCreation() - { - assertNull(cache.getRoot().getChild(fqn)); - cache.getInvocationContext().getOptionOverrides().setSuppressLocking= (true); - cache.put(fqn, "x", "y"); - assertEquals(0, cache.getNumberOfLocksHeld()); - assertEquals("y", cache.getRoot().getChild(fqn).get("x")); - } - -} Copied: core/trunk/src/test/java/org/jboss/cache/replicated/PessimisticSync= ReplTxTest.java (from rev 6585, core/trunk/src/test/java/org/jboss/cache/re= plicated/SyncReplTxTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/replicated/PessimisticSyncRepl= TxTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/replicated/PessimisticSyncRepl= TxTest.java 2008-08-25 17:50:21 UTC (rev 6611) @@ -0,0 +1,1239 @@ +/* + * + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.cache.replicated; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.cache.Cache; +import org.jboss.cache.CacheException; +import org.jboss.cache.CacheSPI; +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.Fqn; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.lock.IsolationLevel; +import org.jboss.cache.lock.TimeoutException; +import org.jboss.cache.util.TestingUtil; +import org.jboss.cache.notifications.annotation.CacheListener; +import org.jboss.cache.notifications.annotation.NodeModified; +import org.jboss.cache.notifications.event.NodeEvent; +import org.jboss.cache.transaction.TransactionSetup; +import org.jboss.cache.util.CachePrinter; +import static org.testng.AssertJUnit.*; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import javax.transaction.NotSupportedException; +import javax.transaction.RollbackException; +import javax.transaction.Status; +import javax.transaction.Synchronization; +import javax.transaction.SystemException; +import javax.transaction.Transaction; +import javax.transaction.TransactionManager; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.Semaphore; + +/** + * Replicated unit test for sync transactional CacheImpl + * Note: we use DummyTransactionManager for Tx purpose instead of relying = on + * jta. + * + * @version $Revision$ + */ +(a)Test(groups =3D {"functional", "jgroups", "transaction"}) +public class PessimisticSyncReplTxTest +{ + private static Log log =3D LogFactory.getLog(PessimisticSyncReplTxTest.= class); + private CacheSPI cache1; + private CacheSPI cache2; + + Semaphore lock; + private Throwable t1_ex; + private Throwable t2_ex; + + @BeforeMethod(alwaysRun =3D true) + public void setUp() throws Exception + { + t1_ex =3D t2_ex =3D null; + lock =3D new Semaphore(1); + } + + @AfterMethod(alwaysRun =3D true) + public void tearDown() throws Exception + { + TransactionSetup.cleanup(); + destroyCaches(); + } + + private TransactionManager beginTransaction() throws SystemException, N= otSupportedException + { + return beginTransaction(cache1); + } + + private TransactionManager beginTransaction(CacheSPI c) throws SystemEx= ception, NotSupportedException + { + TransactionManager mgr =3D c.getConfiguration().getRuntimeConfig().g= etTransactionManager(); + mgr.begin(); + return mgr; + } + + private void initCaches(Configuration.CacheMode caching_mode) throws Ex= ception + { + cache1 =3D (CacheSPI) new DefaultCacheFactory().createCache(false); + cache2 =3D (CacheSPI) new DefaultCacheFactory().createCache(false); + cache1.getConfiguration().setCacheMode(caching_mode); + cache2.getConfiguration().setCacheMode(caching_mode); + cache1.getConfiguration().setNodeLockingScheme(Configuration.NodeLoc= kingScheme.PESSIMISTIC); + cache2.getConfiguration().setNodeLockingScheme(Configuration.NodeLoc= kingScheme.PESSIMISTIC); + cache1.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZA= BLE); + cache2.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZA= BLE); + + cache1.getConfiguration().setTransactionManagerLookupClass(Transacti= onSetup.getManagerLookup()); + cache2.getConfiguration().setTransactionManagerLookupClass(Transacti= onSetup.getManagerLookup()); + cache1.getConfiguration().setLockAcquisitionTimeout(5000); + cache2.getConfiguration().setLockAcquisitionTimeout(5000); + + configureMultiplexer(cache1); + configureMultiplexer(cache2); + + cache1.start(); + cache2.start(); + + validateMultiplexer(cache1); + validateMultiplexer(cache2); + } + + /** + * Provides a hook for multiplexer integration. This default implementa= tion + * is a no-op; subclasses that test mux integration would override + * to integrate the given cache with a multiplexer. + *

    + * param cache a cache that has been configured but not yet created. + * + * @param cache cache + * @throws Exception exception + */ + protected void configureMultiplexer(Cache cache) throws Exception + { + // default does nothing + } + + /** + * Provides a hook to check that the cache's channel came from the + * multiplexer, or not, as expected. This default impl asserts that + * the channel did not come from the multiplexer. + * + * @param cache a cache that has already been started + */ + protected void validateMultiplexer(Cache cache) + { + assertFalse("Cache is not using multiplexer", cache.getConfiguration= ().isUsingMultiplexer()); + } + + private void destroyCaches() + { + if (cache1 !=3D null) + { + cache1.stop(); + } + if (cache2 !=3D null) + { + cache2.stop(); + } + cache1 =3D null; + cache2 =3D null; + } + + public void testLockRemoval() throws Exception + { + initCaches(Configuration.CacheMode.REPL_SYNC); + cache1.getConfiguration().setSyncCommitPhase(true); + TestingUtil.extractLockManager(cache1).unlockAll(cache1.getRoot()); + TransactionManager tm =3D beginTransaction(); + cache1.put("/bela/ban", "name", "Bela Ban"); + assertEquals(3, cache1.getNumberOfLocksHeld()); + assertEquals(0, cache2.getNumberOfLocksHeld()); + tm.commit(); + assertEquals(0, cache1.getNumberOfLocksHeld()); + assertEquals(0, cache2.getNumberOfLocksHeld()); + } + + public void testSyncRepl() throws Exception + { + Integer age; + Transaction tx; + + initCaches(Configuration.CacheMode.REPL_SYNC); + cache1.getConfiguration().setSyncCommitPhase(true); + cache2.getConfiguration().setSyncCommitPhase(true); + + TransactionManager mgr =3D beginTransaction(); + cache1.put("/a/b/c", "age", 38); + tx =3D mgr.suspend(); + assertNull("age on cache2 must be null as the TX has not yet been co= mmitted", cache2.get("/a/b/c", "age")); + log.debug("cache1: locks held before commit: " + CachePrinter.printC= acheLockingInfo(cache1)); + log.debug("cache2: locks held before commit: " + CachePrinter.printC= acheLockingInfo(cache2)); + mgr.resume(tx); + mgr.commit(); + log.debug("cache1: locks held after commit: " + CachePrinter.printCa= cheLockingInfo(cache1)); + log.debug("cache2: locks held after commit: " + CachePrinter.printCa= cheLockingInfo(cache2)); + + // value on cache2 must be 38 + age =3D (Integer) cache2.get("/a/b/c", "age"); + assertNotNull("\"age\" obtained from cache2 must be non-null ", age); + assertTrue("\"age\" must be 38", age =3D=3D 38); + } + + public void testSimplePut() throws Exception + { + initCaches(Configuration.CacheMode.REPL_SYNC); + + cache1.put("/JSESSION/localhost/192.168.1.10:32882/Courses/0", "Inst= ructor", "Ben Wang"); + + cache1.put("/JSESSION/localhost/192.168.1.10:32882/1", "Number", 10); + } + + public void testSimpleTxPut() throws Exception + { + TransactionManager tm; + final Fqn NODE1 =3D Fqn.fromString("/one/two/three"); + initCaches(Configuration.CacheMode.REPL_SYNC); + + tm =3D beginTransaction(); + cache1.put(NODE1, "age", 38); + System.out.println("TransactionTable for cache1 after cache1.put():\= n" + cache1.getTransactionTable().toString(true)); + tm.commit(); + + /* + tx=3DbeginTransaction(); + cache1.put(NODE1, "age", new Integer(38)); + cache1.put(NODE2, "name", "Ben of The Far East"); + cache1.put(NODE3, "key", "UnknowKey"); + System.out.println("TransactionTable for cache1 after cache1.put():= \n" + cache1.getTransactionTable().toString(true)); + + tx.commit(); + */ + + /* + tx=3DbeginTransaction(); + cache1.put(NODE1, "age", new Integer(38)); + cache1.put(NODE1, "AOPInstance", new AOPInstance()); + cache1.put(NODE2, "AOPInstance", new AOPInstance()); + cache1.put(NODE1, "AOPInstance", new AOPInstance()); + tx.commit(); + System.out.println("TransactionTable for cache1 after cache1.put():= \n" + cache1.getTransactionTable().toString(true)); + */ + } + + public void testSyncReplWithModficationsOnBothCaches() throws Exception + { + TransactionManager tm; + final Fqn NODE1 =3D Fqn.fromString("/one/two/three"); + final Fqn NODE2 =3D Fqn.fromString("/eins/zwei/drei"); + + initCaches(Configuration.CacheMode.REPL_SYNC); + + // create roots first + cache1.put("/one/two", null); + cache2.put("/eins/zwei", null); + + cache1.getConfiguration().setSyncCommitPhase(true); + cache2.getConfiguration().setSyncCommitPhase(true); + + tm =3D beginTransaction(); + cache1.put(NODE1, "age", 38); + System.out.println("TransactionTable for cache1 after cache1.put():\= n" + cache1.getTransactionTable().toString(true)); + + cache2.put(NODE2, "age", 39); + System.out.println("TransactionTable for cache2 after cache2.put():\= n" + cache2.getTransactionTable().toString(true)); + + System.out.println("cache1 before commit:\n" + CachePrinter.printCac= heLockingInfo(cache1)); + System.out.println("cache2 before commit:\n" + CachePrinter.printCac= heLockingInfo(cache2)); + + try + { + tm.commit(); + fail("Should not succeed with SERIALIZABLE semantics"); + } + catch (Exception e) + { + //should be a classic deadlock here. + } + + System.out.println("cache1 after commit:\n" + CachePrinter.printCach= eLockingInfo(cache1)); + System.out.println("cache2 after commit:\n" + CachePrinter.printCach= eLockingInfo(cache2)); + + /* + assertTrue(cache1.exists(NODE1)); + assertTrue(cache1.exists(NODE2)); + assertTrue(cache1.exists(NODE1)); + assertTrue(cache2.exists(NODE2)); + + age =3D (Integer) cache1.get(NODE1, "age"); + assertNotNull("\"age\" obtained from cache1 for " + NODE1 + " must = be non-null ", age); + assertTrue("\"age\" must be 38", age =3D=3D 38); + + age =3D (Integer) cache2.get(NODE1, "age"); + assertNotNull("\"age\" obtained from cache2 for " + NODE1 + " must = be non-null ", age); + assertTrue("\"age\" must be 38", age =3D=3D 38); + + age =3D (Integer) cache1.get(NODE2, "age"); + assertNotNull("\"age\" obtained from cache1 for " + NODE2 + " must = be non-null ", age); + assertTrue("\"age\" must be 39", age =3D=3D 39); + + age =3D (Integer) cache2.get(NODE2, "age"); + assertNotNull("\"age\" obtained from cache2 for " + NODE2 + " must = be non-null ", age); + assertTrue("\"age\" must be 39", age =3D=3D 39); + */ + + assertEquals(0, cache1.getNumberOfLocksHeld()); + assertEquals(0, cache2.getNumberOfLocksHeld()); + System.out.println("TransactionTable for cache1:\n" + cache1.getTran= sactionTable().toString(true)); + System.out.println("TransactionTable for cache2:\n" + cache2.getTran= sactionTable().toString(true)); + } + + public void testSyncReplWithModficationsOnBothCachesSameData() throws E= xception + { + TransactionManager tm; + final Fqn NODE =3D Fqn.fromString("/one/two/three"); + initCaches(Configuration.CacheMode.REPL_SYNC); + tm =3D beginTransaction(); + cache1.put(NODE, "age", 38); + System.out.println("TransactionTable for cache1 after cache1.put():\= n" + cache1.getTransactionTable().toString(true)); + + cache2.put(NODE, "age", 39); + System.out.println("TransactionTable for cache2 after cache2.put():\= n" + cache2.getTransactionTable().toString(true)); + + System.out.println("cache1 before commit:\n" + CachePrinter.printCac= heLockingInfo(cache1)); + System.out.println("cache2 before commit:\n" + CachePrinter.printCac= heLockingInfo(cache2)); + + try + { + tm.commit(); + fail("commit should throw a RollbackException, we should not get = here"); + } + catch (RollbackException rollback) + { + System.out.println("Transaction was rolled back, this is correct"= ); + } + + System.out.println("cache1 after commit:\n" + CachePrinter.printCach= eLockingInfo(cache1)); + System.out.println("cache2 after commit:\n" + CachePrinter.printCach= eLockingInfo(cache2)); + + assertEquals(0, cache1.getNumberOfLocksHeld()); + assertEquals(0, cache2.getNumberOfLocksHeld()); + + assertEquals(0, cache1.getNumberOfNodes()); + assertEquals(0, cache2.getNumberOfNodes()); + } + + public void testSyncReplWithModficationsOnBothCachesWithRollback() thro= ws Exception + { + TransactionManager tm; + final Fqn fqn1 =3D Fqn.fromString("/one/two/three"); + final Fqn fqn2 =3D Fqn.fromString("/eins/zwei/drei"); + + initCaches(Configuration.CacheMode.REPL_SYNC); + + cache1.getConfiguration().setSyncRollbackPhase(true); + cache2.getConfiguration().setSyncRollbackPhase(true); + + tm =3D beginTransaction(); + cache1.put(fqn1, "age", 38); + cache2.put(fqn2, "age", 39); + + System.out.println("cache1 (before commit):\n" + CachePrinter.printC= acheLockingInfo(cache1)); + System.out.println("cache2 (before commit):\n" + CachePrinter.printC= acheLockingInfo(cache2)); + + // this will rollback the transaction + Transaction tx =3D tm.getTransaction(); + tx.registerSynchronization(new TransactionAborter(tx)); + + try + { + tm.commit(); + fail("commit should throw a RollbackException, we should not get = here"); + } + catch (RollbackException rollback) + { + System.out.println("Transaction was rolled back, this is correct"= ); + } + + System.out.println("cache1 (after rollback):\n" + CachePrinter.print= CacheLockingInfo(cache1)); + System.out.println("cache2 (after rollback):\n" + CachePrinter.print= CacheLockingInfo(cache2)); + + assertEquals(0, cache1.getNumberOfLocksHeld()); + assertEquals(0, cache2.getNumberOfLocksHeld()); + + assertEquals(0, cache1.getNumberOfNodes()); + assertEquals(0, cache2.getNumberOfNodes()); + } + + /** + * Test for JBCACHE-361 -- does marking a tx on the remote side + * rollback-only cause a rollback on the originating side? + */ + public void testSyncReplWithRemoteRollback() throws Exception + { + TransactionManager tm; + final Fqn NODE1 =3D Fqn.fromString("/one/two/three"); + + initCaches(Configuration.CacheMode.REPL_SYNC); + + cache1.getConfiguration().setSyncRollbackPhase(true); + cache2.getConfiguration().setSyncRollbackPhase(true); + + // Test with a rollback on the remote side + + // listener aborts any active tx + //TransactionAborterListener tal =3D new TransactionAborterListener(= cache2); + + tm =3D beginTransaction(); + cache1.put(NODE1, "age", 38); + + System.out.println("cache1 (before commit):\n" + CachePrinter.printC= acheLockingInfo(cache1)); + System.out.println("cache2 (before commit):\n" + CachePrinter.printC= acheLockingInfo(cache2)); + + // instead of a listener lets just get a WL on ROOT on cache2. And h= old on to it. + Transaction tx =3D tm.suspend(); + + tm.begin(); + cache2.getRoot().put("x", "y"); + Transaction tx2 =3D cache2.getTransactionManager().suspend(); + + System.out.println("cache2 (before commit):\n" + CachePrinter.printC= acheLockingInfo(cache2)); + tm.resume(tx); + + try + { + tm.commit(); + fail("commit should throw a RollbackException, we should not get = here"); + } + catch (RollbackException rollback) + { + System.out.println("Transaction was rolled back, this is correct"= ); + } + finally + { + tm.resume(tx2); + tm.rollback(); + } + + // Sleep, as the commit call to cache2 is async + TestingUtil.sleepThread(1000); + + System.out.println("cache1 (after rollback):\n" + CachePrinter.print= CacheLockingInfo(cache1)); + System.out.println("cache2 (after rollback):\n" + CachePrinter.print= CacheLockingInfo(cache2)); + + //assertNull(tal.getCallbackException()); + + assertEquals(0, cache1.getNumberOfLocksHeld()); + assertEquals(0, cache2.getNumberOfLocksHeld()); + + assertEquals(0, cache1.getNumberOfNodes()); + assertEquals(0, cache2.getNumberOfNodes()); + + } + + public void testASyncRepl() throws Exception + { + Integer age; + TransactionManager tm; + + initCaches(Configuration.CacheMode.REPL_ASYNC); + + tm =3D beginTransaction(); + cache1.put("/a/b/c", "age", 38); + Thread.sleep(1000); + assertNull("age on cache2 must be null as the TX has not yet been co= mmitted", cache2.get("/a/b/c", "age")); + tm.commit(); + Thread.sleep(1000); + + // value on cache2 must be 38 + age =3D (Integer) cache2.get("/a/b/c", "age"); + assertNotNull("\"age\" obtained from cache2 is null ", age); + assertTrue("\"age\" must be 38", age =3D=3D 38); + + } + + /** + * Tests concurrent modifications: thread1 succeeds and thread2 is bloc= ked until thread1 is done, and then succeeds + * too. However, this is flawed with the introduction of interceptors, = here's why.
    + *

      + *
    • Thread1 acquires the lock for /bela/ban on cache1 + *
    • Thread2 blocks on Thread1 to release the lock + *
    • Thread1 commits: this means the TransactionInterceptor and the R= eplicationInterceptor are called in + * the sequence in which they registered. Unfortunately, the Transactio= nInterceptor registered first. In the + * PREPARE phase, the ReplicationInterceptor calls prepare() in cache2 = synchronously. The TxInterceptor + * does nothing. The the COMMIT phase, the TxInterceptor commits the da= ta by releasing the locks locally and + * then the ReplicationInterceptor sends an asynchronous COMMIT to cach= e2. + *
    • Because the TxInterceptor for Thread1 releases the locks locally= before sending the async COMMIT, + * Thread2 is able to acquire the lock for /bela/ban in cache1 and then= starts the PREPARE phase by sending a + * synchronous PREPARE to cache2. If this PREPARE arrives at cache2 before the COMMIT from Thread1, + * the PREPARE will block because it attempts to acquire a lock on /bel= a/ban on cache2 still held by Thread1 + * (which would be released by Thread1's COMMIT). This results in deadl= ock, which is resolved by Thread2 running + * into a timeout with subsequent rollback and Thread1 succeeding.
      + *
    + * There are 3 solutions to this: + *
      + *
    1. Do nothing. This is standard behavior for concurrent access to t= he same data. Same thing if the 2 threads + * operated on the same data in separate caches, e.g. Thread1 = on /bela/ban in cache1 and Thread2 on + * /bela/ban in cache2. The semantics of Tx commit as handled by the in= terceptors is: after tx1.commit() returns + * the locks held by tx1 are release and a COMMIT message is on the way= (if sent asynchronously). + *
    2. Force an order over TxInterceptor and ReplicationInterceptor. Th= is would require ReplicationInterceptor + * to always be fired first on TX commit. Downside: the interceptors ha= ve an implicit dependency, which is not + * nice. + *
    3. Priority-order requests at the receiver; e.g. a COMMIT could rel= ease a blocked PREPARE. This is bad because + * it violates JGroups' FIFO ordering guarantees. + *
    + * I'm currently investigating solution #2, ie. creating an OrderedSync= hronizationHandler, which allows other + * SynchronizationHandlers to register (atHead, atTail), and the Ordere= dSynchronizationHandler would call the + * SynchronizationHandler in the order in which they are defined. + * + * @throws Exception exception + */ + public void testConcurrentPuts() throws Exception + { + initCaches(Configuration.CacheMode.REPL_SYNC); + cache1.getConfiguration().setSyncCommitPhase(true); + + Thread t1 =3D new Thread("Thread1") + { + TransactionManager tm; + + public void run() + { + try + { + tm =3D beginTransaction(); + cache1.put("/bela/ban", "name", "Bela Ban"); + TestingUtil.sleepThread(2000);// Thread2 will be blocked un= til we commit + tm.commit(); + System.out.println("[Thread1] ** LOCK INFO cache1: " + Cach= ePrinter.printCacheLockingInfo(cache1)); + System.out.println("[Thread1] ** LOCK INFO cache2: " + Cach= ePrinter.printCacheLockingInfo(cache2)); + } + catch (Throwable ex) + { + ex.printStackTrace(); + t1_ex =3D ex; + } + } + }; + + Thread t2 =3D new Thread("Thread2") + { + TransactionManager tm; + + public void run() + { + try + { + TestingUtil.sleepThread(1000);// give Thread1 time to acqui= re the lock + tm =3D beginTransaction(); + System.out.println("[Thread2] ** LOCK INFO cache1: " + Cach= ePrinter.printCacheLockingInfo(cache1)); + System.out.println("[Thread2] ** LOCK INFO cache2: " + Cach= ePrinter.printCacheLockingInfo(cache2)); + cache1.put("/bela/ban", "name", "Michelle Ban"); + System.out.println("[Thread2] ** LOCK INFO cache1: " + Cach= ePrinter.printCacheLockingInfo(cache1)); + System.out.println("[Thread2] ** LOCK INFO cache2: " + Cach= ePrinter.printCacheLockingInfo(cache2)); + tm.commit(); + System.out.println("[Thread2] ** LOCK INFO cache1: " + Cach= ePrinter.printCacheLockingInfo(cache1)); + System.out.println("[Thread2] ** LOCK INFO cache2: " + Cach= ePrinter.printCacheLockingInfo(cache2)); + } + catch (Throwable ex) + { + ex.printStackTrace(); + t2_ex =3D ex; + } + } + }; + + // Let the game start + t1.start(); + t2.start(); + + // Wait for threads to die + t1.join(); + t2.join(); + + if (t1_ex !=3D null) + { + fail("Thread1 failed: " + t1_ex); + } + if (t2_ex !=3D null) + { + fail("Thread2 failed: " + t2_ex); + } + + assertEquals("Michelle Ban", cache1.get("/bela/ban", "name")); + } + + /** + * Should reproduce JBCACHE-32 problem (http://jira.jboss.com/jira/brow= se/JBCACHE-32) + */ + public void testConcurrentCommitsWith1Thread() throws Exception + { + _testConcurrentCommits(1); + } + + /** + * Should reproduce JBCACHE-32 problem (http://jira.jboss.com/jira/brow= se/JBCACHE-32) + */ + public void testConcurrentCommitsWith5Threads() throws Exception + { + _testConcurrentCommits(5); + } + + /** + * Should reproduce JBCACHE-32 problem (http://jira.jboss.com/jira/brow= se/JBCACHE-32) + */ + private void _testConcurrentCommits(int num_threads) + { + Object myMutex =3D new Object(); + + final CacheSPI c1 =3D (CacheSPI) new= DefaultCacheFactory().createCache(false); + final CacheSPI c2 =3D (CacheSPI) new= DefaultCacheFactory().createCache(false); + c1.getConfiguration().setClusterName("TempCluster"); + c2.getConfiguration().setClusterName("TempCluster"); + c1.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC= ); + c2.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC= ); + c1.getConfiguration().setSyncCommitPhase(true); + c2.getConfiguration().setSyncCommitPhase(true); + c1.getConfiguration().setSyncRollbackPhase(true); + c2.getConfiguration().setSyncRollbackPhase(true); + c1.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_RE= AD); + c2.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_RE= AD); + c1.getConfiguration().setTransactionManagerLookupClass("org.jboss.ca= che.transaction.DummyTransactionManagerLookup"); + c2.getConfiguration().setTransactionManagerLookupClass("org.jboss.ca= che.transaction.DummyTransactionManagerLookup"); + c1.getConfiguration().setLockAcquisitionTimeout(5000); + c2.getConfiguration().setLockAcquisitionTimeout(5000); + c1.start(); + c2.start(); + final List exceptions =3D new ArrayList(); + + class MyThread extends Thread + { + final Object mutex; + + public MyThread(String name, Object mutex) + { + super(name); + this.mutex =3D mutex; + } + + public void run() + { + TransactionManager tm =3D null; + + try + { + tm =3D beginTransaction(c1); + c1.put("/thread/" + getName(), null); + System.out.println("Thread " + getName() + " after put(): "= + c1.toString()); + System.out.println("Thread " + getName() + " waiting on mut= ex"); + synchronized (mutex) + { + mutex.wait(); + } + System.out.println("Thread " + getName() + " committing"); + tm.commit(); + System.out.println("Thread " + getName() + " committed succ= essfully"); + } + catch (Exception e) + { + exceptions.add(e); + } + finally + { + try + { + if (tm !=3D null) + tm.rollback(); + } + catch (Exception e) + { + // do nothing + } + } + } + } + + MyThread[] threads =3D new MyThread[num_threads]; + for (int i =3D 0; i < threads.length; i++) + { + threads[i] =3D new MyThread("#" + i, myMutex); + } + for (int i =3D 0; i < threads.length; i++) + { + MyThread thread =3D threads[i]; + System.out.println("starting thread #" + i); + thread.start(); + } + + TestingUtil.sleepThread(6000); + synchronized (myMutex) + { + System.out.println("cache is " + CachePrinter.printCacheLockingIn= fo(c1)); + System.out.println("******************* SIGNALLING THREADS ******= **************"); + myMutex.notifyAll(); + } + + for (MyThread thread : threads) + { + try + { + thread.join(); + System.out.println("Joined thread " + thread.getName()); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + + System.out.println("FINAL c1:\n" + CachePrinter.printCacheDetails(c1= ) + "\nlocks:\n" + CachePrinter.printCacheLockingInfo(c1)); + + assertEquals(0, c1.getNumberOfLocksHeld()); + assertEquals(0, c2.getNumberOfLocksHeld()); + + c1.stop(); + c2.stop(); + + // if(ex !=3D null) + // { + // ex.printStackTrace(); + // fail("Thread failed: " + ex); + // } + + // we can only expect 1 thread to succeed. The others will fail. S= o, threads.length -1 exceptions. + // this is a timing issue - 2 threads still may succeed on a multi c= pu system + // assertEquals(threads.length - 1, exceptions.size()); + + for (Exception exception : exceptions) + assertEquals(TimeoutException.class, exception.getClass()); + } + + /** + * Conncurrent put on 2 different instances. + */ + public void testConcurrentPutsOnTwoInstances() throws Exception + { + initCaches(Configuration.CacheMode.REPL_SYNC); + final CacheSPI c1 =3D this.cache1; + final CacheSPI c2 =3D this.cache2; + + Thread t1 =3D new Thread() + { + TransactionManager tm; + + public void run() + { + try + { + tm =3D beginTransaction(); + c1.put("/ben/wang", "name", "Ben Wang"); + TestingUtil.sleepThread(8000); + tm.commit();// This should go thru + } + catch (Throwable ex) + { + ex.printStackTrace(); + t1_ex =3D ex; + } + } + }; + + Thread t2 =3D new Thread() + { + TransactionManager tm; + + public void run() + { + try + { + TestingUtil.sleepThread(1000);// give Thread1 time to acqui= re the lock + tm =3D beginTransaction(); + c2.put("/ben/wang", "name", "Ben Jr."); + tm.commit();// This will time out and rollback first becaus= e Thread1 has a tx going as well. + } + catch (RollbackException rollback_ex) + { + System.out.println("received rollback exception as expected= "); + } + catch (Throwable ex) + { + ex.printStackTrace(); + t2_ex =3D ex; + } + } + }; + + // Let the game start + t1.start(); + t2.start(); + + // Wait for thread to die but put an insurance of 5 seconds on it. + t1.join(); + t2.join(); + + if (t1_ex !=3D null) + { + fail("Thread1 failed: " + t1_ex); + } + if (t2_ex !=3D null) + { + fail("Thread2 failed: " + t2_ex); + } + assertEquals("Ben Wang", c1.get("/ben/wang", "name")); + } + + public void testPut() throws Exception + { + initCaches(Configuration.CacheMode.REPL_SYNC); + final CacheSPI c1 =3D this.cache1; + + Thread t1 =3D new Thread() + { + public void run() + { + try + { + lock.acquire(); + System.out.println("-- t1 has lock"); + c1.put("/a/b/c", "age", 38); + System.out.println("[Thread1] set value to 38"); + + System.out.println("-- t1 releases lock"); + lock.release(); + TestingUtil.sleepThread(300); + Thread.yield(); + + lock.acquire(); + System.out.println("-- t1 has lock"); + c1.put("/a/b/c", "age", 39); + System.out.println("[Thread1] set value to 39"); + + System.out.println("-- t1 releases lock"); + lock.release(); + assertEquals(39, c1.get("/a/b/c", "age")); + } + catch (Throwable ex) + { + ex.printStackTrace(); + t1_ex =3D ex; + } + finally + { + lock.release(); + } + } + }; + + Thread t2 =3D new Thread() + { + public void run() + { + try + { + TestingUtil.sleepThread(100); + Thread.yield(); + lock.acquire(); + System.out.println("-- t2 has lock"); + // Should replicate the value right away. + Integer val =3D (Integer) cache2.get("/a/b/c", "age"); + System.out.println("[Thread2] value is " + val); + assertEquals(new Integer(38), val); + System.out.println("-- t2 releases lock"); + lock.release(); + TestingUtil.sleepThread(300); + Thread.yield(); + TestingUtil.sleepThread(500); + lock.acquire(); + System.out.println("-- t2 has lock"); + val =3D (Integer) cache2.get("/a/b/c", "age"); + System.out.println("-- t2 releases lock"); + lock.release(); + assertEquals(new Integer(39), val); + } + catch (Throwable ex) + { + ex.printStackTrace(); + t2_ex =3D ex; + } + finally + { + lock.release(); + } + } + }; + + // Let the game start + t1.start(); + t2.start(); + + // Wait for thread to die but put an insurance of 5 seconds on it. + t1.join(); + t2.join(); + if (t1_ex !=3D null) + { + fail("Thread1 failed: " + t1_ex); + } + if (t2_ex !=3D null) + { + fail("Thread2 failed: " + t2_ex); + } + } + + /** + * Test replicated cache with transaction. Idea is to have two threads = running + * a local cache each that is replicating. Depending on whether cache1 = commit/rollback or not, + * the cache2.get will get different values. + * Note that we have used sleep to interpose thread execution sequence. + * Although it's not fool proof, it is rather simple and intuitive. + */ + public void testPutTx() throws Exception + { + TransactionManager tm; + + try + { + initCaches(Configuration.CacheMode.REPL_SYNC); + cache1.getConfiguration().setSyncCommitPhase(true); + cache2.getConfiguration().setSyncCommitPhase(true); + tm =3D beginTransaction(); + cache1.put("/a/b/c", "age", 38); + cache1.put("/a/b/c", "age", 39); + Object val =3D cache2.get("/a/b/c", "age");// must be null as not= yet committed + assertNull(val); + tm.commit(); + + tm =3D beginTransaction(); + assertEquals(39, cache2.get("/a/b/c", "age"));// must not be null + tm.commit(); + } + catch (Throwable t) + { + t.printStackTrace(); + t1_ex =3D t; + } + finally + { + lock.release(); + } + } + + /** + * Have both cache1 and cache2 do add and commit. cache1 commit should = time out + * since it can't obtain the lock when trying to replicate cache2. On t= he other hand, + * cache2 commit will succeed since now that cache1 is rollbacked and l= ock is + * released. + */ + public void testPutTx1() throws Exception + { + initCaches(Configuration.CacheMode.REPL_SYNC); + final CacheSPI c1 =3D this.cache1; + Thread t1 =3D new Thread() + { + public void run() + { + TransactionManager tm; + + try + { + lock.acquire(); + tm =3D beginTransaction(); + c1.put("/a/b/c", "age", 38); + c1.put("/a/b/c", "age", 39); + lock.release(); + + TestingUtil.sleepThread(300); + lock.acquire(); + try + { + tm.commit(); + } + catch (RollbackException ex) + { + System.out.println("[Thread1] received RollbackException= , as expected. Rolling back changes"); + } + finally + { + lock.release(); + } + } + catch (Throwable ex) + { + ex.printStackTrace(); + t1_ex =3D ex; + } + finally + { + lock.release(); + } + } + }; + + Thread t2 =3D new Thread() + { + public void run() + { + TransactionManager tm; + + try + { + sleep(200); + Thread.yield(); + lock.acquire(); + tm =3D beginTransaction(); + assertNull(cache2.get("/a/b/c", "age"));// must be null as = not yet committed + cache2.put("/a/b/c", "age", 40); + lock.release(); + + TestingUtil.sleepThread(300); + lock.acquire(); + assertEquals(40, cache2.get("/a/b/c", "age"));// must not b= e null + tm.commit(); + lock.release(); + + TestingUtil.sleepThread(1000); + tm =3D beginTransaction(); + assertEquals("After cache2 commit", 40, cache2.get("/a/b/c"= , "age")); + tm.commit(); + } + catch (Throwable ex) + { + ex.printStackTrace(); + t2_ex =3D ex; + } + finally + { + lock.release(); + } + } + }; + + // Let the game start + t1.start(); + t2.start(); + + t1.join(); + t2.join(); + + if (t1_ex !=3D null) + { + fail("Thread1 failed: " + t1_ex); + } + if (t2_ex !=3D null) + { + fail("Thread2 failed: " + t2_ex); + } + } + + public void testPutTxWithRollback() throws Exception + { + initCaches(Configuration.CacheMode.REPL_SYNC); + final CacheSPI c2 =3D this.cache1; + Thread t1 =3D new Thread() + { + public void run() + { + TransactionManager tm; + + try + { + lock.acquire(); + tm =3D beginTransaction(); + c2.put("/a/b/c", "age", 38); + c2.put("/a/b/c", "age", 39); + lock.release(); + + TestingUtil.sleepThread(100); + lock.acquire(); + tm.rollback(); + lock.release(); + } + catch (Throwable ex) + { + ex.printStackTrace(); + t1_ex =3D ex; + } + finally + { + lock.release(); + } + } + }; + + Thread t2 =3D new Thread() + { + public void run() + { + TransactionManager tm; + + try + { + sleep(200); + Thread.yield(); + lock.acquire(); + tm =3D beginTransaction(); + assertNull(cache2.get("/a/b/c", "age"));// must be null as = not yet committed + lock.release(); + + TestingUtil.sleepThread(100); + lock.acquire(); + assertNull(cache2.get("/a/b/c", "age"));// must be null as = rolledback + tm.commit(); + lock.release(); + } + catch (Throwable ex) + { + ex.printStackTrace(); + t2_ex =3D ex; + } + finally + { + lock.release(); + } + } + }; + + // Let the game start + t1.start(); + t2.start(); + + // Wait for thread to die but put an insurance of 5 seconds on it. + t1.join(); + t2.join(); + if (t1_ex !=3D null) + { + fail("Thread1 failed: " + t1_ex); + } + if (t2_ex !=3D null) + { + fail("Thread2 failed: " + t2_ex); + } + } + + static class TransactionAborter implements Synchronization + { + Transaction ltx =3D null; + + public TransactionAborter(Transaction ltx) + { + this.ltx =3D ltx; + } + + public void beforeCompletion() + { + try + { + ltx.setRollbackOnly(); + } + catch (SystemException e) + { + // who cares + } + } + + public void afterCompletion(int status) + { + } + } + + @CacheListener + static class CallbackListener + { + + CacheSPI callbackCache; + Object callbackKey; + Exception ex; + final Object mutex =3D new Object(); + + CallbackListener(CacheSPI cache, Object callbackKey) + { + this.callbackCache =3D cache; + this.callbackKey =3D callbackKey; + cache.getNotifier().addCacheListener(this); + } + + @NodeModified + public void nodeModified(NodeEvent e) + { + if (!e.isPre()) + { + // Lock on a mutex so test can't check for an exception + // until the get call completes + synchronized (mutex) + { + try + { + callbackCache.get(e.getFqn(), callbackKey); + } + catch (CacheException exc) + { + exc.printStackTrace(); + ex =3D exc; + } + } + } + } + + Exception getCallbackException() + { + synchronized (mutex) + { + return ex; + } + } + + } + + static class TransactionAborterCallbackListener extends CallbackListener + { + + TransactionManager callbackTM; + + TransactionAborterCallbackListener(CacheSPI cache, O= bject callbackKey) + { + super(cache, callbackKey); + callbackTM =3D callbackCache.getTransactionManager(); + } + + @NodeModified + public void nodeModified(NodeEvent ne) + { + if (!ne.isPre()) + { + try + { + Transaction tx =3D callbackTM.getTransaction(); + if (tx !=3D null && tx.getStatus() =3D=3D Status.STATUS_ACT= IVE) + { + // this will rollback the transaction + tx.registerSynchronization(new TransactionAborter(tx)); + } + else + { + super.nodeModified(ne); + } + + } + catch (Exception e) + { + e.printStackTrace(); + if (ex =3D=3D null) + { + ex =3D e; + } + } + } + } + + } + +} Property changes on: core/trunk/src/test/java/org/jboss/cache/replicated/Pe= ssimisticSyncReplTxTest.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Deleted: core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTxTest= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTxTest.java= 2008-08-23 12:40:58 UTC (rev 6610) +++ core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTxTest.java= 2008-08-25 17:50:21 UTC (rev 6611) @@ -1,1327 +0,0 @@ -/* - * - * JBoss, the OpenSource J2EE webOS - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package org.jboss.cache.replicated; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jboss.cache.Cache; -import org.jboss.cache.CacheException; -import org.jboss.cache.CacheSPI; -import org.jboss.cache.DefaultCacheFactory; -import org.jboss.cache.Fqn; -import org.jboss.cache.config.Configuration; -import org.jboss.cache.lock.IsolationLevel; -import org.jboss.cache.lock.TimeoutException; -import org.jboss.cache.util.TestingUtil; -import org.jboss.cache.notifications.annotation.CacheListener; -import org.jboss.cache.notifications.annotation.NodeModified; -import org.jboss.cache.notifications.event.NodeEvent; -import org.jboss.cache.transaction.TransactionSetup; -import org.jboss.cache.util.CachePrinter; -import static org.testng.AssertJUnit.*; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import javax.transaction.NotSupportedException; -import javax.transaction.RollbackException; -import javax.transaction.Status; -import javax.transaction.Synchronization; -import javax.transaction.SystemException; -import javax.transaction.Transaction; -import javax.transaction.TransactionManager; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Semaphore; - -/** - * Replicated unit test for sync transactional CacheImpl - * Note: we use DummyTransactionManager for Tx purpose instead of relying = on - * jta. - * - * @version $Revision$ - */ -(a)Test(groups =3D {"functional", "jgroups", "transaction"}) -public class SyncReplTxTest -{ - private static Log log =3D LogFactory.getLog(SyncReplTxTest.class); - private CacheSPI cache1; - private CacheSPI cache2; - - Semaphore lock; - private Throwable t1_ex; - private Throwable t2_ex; - - @BeforeMethod(alwaysRun =3D true) - public void setUp() throws Exception - { - t1_ex =3D t2_ex =3D null; - lock =3D new Semaphore(1); - } - - @AfterMethod(alwaysRun =3D true) - public void tearDown() throws Exception - { - TransactionSetup.cleanup(); - destroyCaches(); - } - - private TransactionManager beginTransaction() throws SystemException, N= otSupportedException - { - return beginTransaction(cache1); - } - - private TransactionManager beginTransaction(CacheSPI c) throws SystemEx= ception, NotSupportedException - { - TransactionManager mgr =3D c.getConfiguration().getRuntimeConfig().g= etTransactionManager(); - mgr.begin(); - return mgr; - } - - private void initCaches(Configuration.CacheMode caching_mode) throws Ex= ception - { - cache1 =3D (CacheSPI) new DefaultCacheFactory().createCache(false); - cache2 =3D (CacheSPI) new DefaultCacheFactory().createCache(false); - cache1.getConfiguration().setCacheMode(caching_mode); - cache2.getConfiguration().setCacheMode(caching_mode); - cache1.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZA= BLE); - cache2.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZA= BLE); - - cache1.getConfiguration().setTransactionManagerLookupClass(Transacti= onSetup.getManagerLookup()); - cache2.getConfiguration().setTransactionManagerLookupClass(Transacti= onSetup.getManagerLookup()); - cache1.getConfiguration().setLockAcquisitionTimeout(5000); - cache2.getConfiguration().setLockAcquisitionTimeout(5000); - - configureMultiplexer(cache1); - configureMultiplexer(cache2); - - cache1.start(); - cache2.start(); - - validateMultiplexer(cache1); - validateMultiplexer(cache2); - } - - /** - * Provides a hook for multiplexer integration. This default implementa= tion - * is a no-op; subclasses that test mux integration would override - * to integrate the given cache with a multiplexer. - *

    - * param cache a cache that has been configured but not yet created. - * - * @param cache cache - * @throws Exception exception - */ - protected void configureMultiplexer(Cache cache) throws Exception - { - // default does nothing - } - - /** - * Provides a hook to check that the cache's channel came from the - * multiplexer, or not, as expected. This default impl asserts that - * the channel did not come from the multiplexer. - * - * @param cache a cache that has already been started - */ - protected void validateMultiplexer(Cache cache) - { - assertFalse("Cache is not using multiplexer", cache.getConfiguration= ().isUsingMultiplexer()); - } - - private void destroyCaches() - { - if (cache1 !=3D null) - { - cache1.stop(); - } - if (cache2 !=3D null) - { - cache2.stop(); - } - cache1 =3D null; - cache2 =3D null; - } - - public void testLockRemoval() throws Exception - { - initCaches(Configuration.CacheMode.REPL_SYNC); - cache1.getConfiguration().setSyncCommitPhase(true); - TestingUtil.extractLockManager(cache1).unlockAll(cache1.getRoot()); - TransactionManager tm =3D beginTransaction(); - cache1.put("/bela/ban", "name", "Bela Ban"); - assertEquals(3, cache1.getNumberOfLocksHeld()); - assertEquals(0, cache2.getNumberOfLocksHeld()); - tm.commit(); - assertEquals(0, cache1.getNumberOfLocksHeld()); - assertEquals(0, cache2.getNumberOfLocksHeld()); - } - - public void testSyncRepl() throws Exception - { - Integer age; - Transaction tx; - - initCaches(Configuration.CacheMode.REPL_SYNC); - cache1.getConfiguration().setSyncCommitPhase(true); - cache2.getConfiguration().setSyncCommitPhase(true); - - TransactionManager mgr =3D beginTransaction(); - cache1.put("/a/b/c", "age", 38); - tx =3D mgr.suspend(); - assertNull("age on cache2 must be null as the TX has not yet been co= mmitted", cache2.get("/a/b/c", "age")); - log.debug("cache1: locks held before commit: " + CachePrinter.printC= acheLockingInfo(cache1)); - log.debug("cache2: locks held before commit: " + CachePrinter.printC= acheLockingInfo(cache2)); - mgr.resume(tx); - mgr.commit(); - log.debug("cache1: locks held after commit: " + CachePrinter.printCa= cheLockingInfo(cache1)); - log.debug("cache2: locks held after commit: " + CachePrinter.printCa= cheLockingInfo(cache2)); - - // value on cache2 must be 38 - age =3D (Integer) cache2.get("/a/b/c", "age"); - assertNotNull("\"age\" obtained from cache2 must be non-null ", age); - assertTrue("\"age\" must be 38", age =3D=3D 38); - } - - public void testSimplePut() throws Exception - { - initCaches(Configuration.CacheMode.REPL_SYNC); - - cache1.put("/JSESSION/localhost/192.168.1.10:32882/Courses/0", "Inst= ructor", "Ben Wang"); - - cache1.put("/JSESSION/localhost/192.168.1.10:32882/1", "Number", 10); - } - - public void testSimpleTxPut() throws Exception - { - TransactionManager tm; - final Fqn NODE1 =3D Fqn.fromString("/one/two/three"); - initCaches(Configuration.CacheMode.REPL_SYNC); - - tm =3D beginTransaction(); - cache1.put(NODE1, "age", 38); - System.out.println("TransactionTable for cache1 after cache1.put():\= n" + cache1.getTransactionTable().toString(true)); - tm.commit(); - - /* - tx=3DbeginTransaction(); - cache1.put(NODE1, "age", new Integer(38)); - cache1.put(NODE2, "name", "Ben of The Far East"); - cache1.put(NODE3, "key", "UnknowKey"); - System.out.println("TransactionTable for cache1 after cache1.put():= \n" + cache1.getTransactionTable().toString(true)); - - tx.commit(); - */ - - /* - tx=3DbeginTransaction(); - cache1.put(NODE1, "age", new Integer(38)); - cache1.put(NODE1, "AOPInstance", new AOPInstance()); - cache1.put(NODE2, "AOPInstance", new AOPInstance()); - cache1.put(NODE1, "AOPInstance", new AOPInstance()); - tx.commit(); - System.out.println("TransactionTable for cache1 after cache1.put():= \n" + cache1.getTransactionTable().toString(true)); - */ - } - - public void testSyncReplWithModficationsOnBothCaches() throws Exception - { - TransactionManager tm; - final Fqn NODE1 =3D Fqn.fromString("/one/two/three"); - final Fqn NODE2 =3D Fqn.fromString("/eins/zwei/drei"); - - initCaches(Configuration.CacheMode.REPL_SYNC); - - // create roots first - cache1.put("/one/two", null); - cache2.put("/eins/zwei", null); - - cache1.getConfiguration().setSyncCommitPhase(true); - cache2.getConfiguration().setSyncCommitPhase(true); - - tm =3D beginTransaction(); - cache1.put(NODE1, "age", 38); - System.out.println("TransactionTable for cache1 after cache1.put():\= n" + cache1.getTransactionTable().toString(true)); - - cache2.put(NODE2, "age", 39); - System.out.println("TransactionTable for cache2 after cache2.put():\= n" + cache2.getTransactionTable().toString(true)); - - System.out.println("cache1 before commit:\n" + CachePrinter.printCac= heLockingInfo(cache1)); - System.out.println("cache2 before commit:\n" + CachePrinter.printCac= heLockingInfo(cache2)); - - try - { - tm.commit(); - fail("Should not succeed with SERIALIZABLE semantics"); - } - catch (Exception e) - { - //should be a classic deadlock here. - } - - System.out.println("cache1 after commit:\n" + CachePrinter.printCach= eLockingInfo(cache1)); - System.out.println("cache2 after commit:\n" + CachePrinter.printCach= eLockingInfo(cache2)); - - /* - assertTrue(cache1.exists(NODE1)); - assertTrue(cache1.exists(NODE2)); - assertTrue(cache1.exists(NODE1)); - assertTrue(cache2.exists(NODE2)); - - age =3D (Integer) cache1.get(NODE1, "age"); - assertNotNull("\"age\" obtained from cache1 for " + NODE1 + " must = be non-null ", age); - assertTrue("\"age\" must be 38", age =3D=3D 38); - - age =3D (Integer) cache2.get(NODE1, "age"); - assertNotNull("\"age\" obtained from cache2 for " + NODE1 + " must = be non-null ", age); - assertTrue("\"age\" must be 38", age =3D=3D 38); - - age =3D (Integer) cache1.get(NODE2, "age"); - assertNotNull("\"age\" obtained from cache1 for " + NODE2 + " must = be non-null ", age); - assertTrue("\"age\" must be 39", age =3D=3D 39); - - age =3D (Integer) cache2.get(NODE2, "age"); - assertNotNull("\"age\" obtained from cache2 for " + NODE2 + " must = be non-null ", age); - assertTrue("\"age\" must be 39", age =3D=3D 39); - */ - - assertEquals(0, cache1.getNumberOfLocksHeld()); - assertEquals(0, cache2.getNumberOfLocksHeld()); - System.out.println("TransactionTable for cache1:\n" + cache1.getTran= sactionTable().toString(true)); - System.out.println("TransactionTable for cache2:\n" + cache2.getTran= sactionTable().toString(true)); - } - - public void testSyncReplWithModficationsOnBothCachesSameData() throws E= xception - { - TransactionManager tm; - final Fqn NODE =3D Fqn.fromString("/one/two/three"); - initCaches(Configuration.CacheMode.REPL_SYNC); - tm =3D beginTransaction(); - cache1.put(NODE, "age", 38); - System.out.println("TransactionTable for cache1 after cache1.put():\= n" + cache1.getTransactionTable().toString(true)); - - cache2.put(NODE, "age", 39); - System.out.println("TransactionTable for cache2 after cache2.put():\= n" + cache2.getTransactionTable().toString(true)); - - System.out.println("cache1 before commit:\n" + CachePrinter.printCac= heLockingInfo(cache1)); - System.out.println("cache2 before commit:\n" + CachePrinter.printCac= heLockingInfo(cache2)); - - try - { - tm.commit(); - fail("commit should throw a RollbackException, we should not get = here"); - } - catch (RollbackException rollback) - { - System.out.println("Transaction was rolled back, this is correct"= ); - } - - System.out.println("cache1 after commit:\n" + CachePrinter.printCach= eLockingInfo(cache1)); - System.out.println("cache2 after commit:\n" + CachePrinter.printCach= eLockingInfo(cache2)); - - assertEquals(0, cache1.getNumberOfLocksHeld()); - assertEquals(0, cache2.getNumberOfLocksHeld()); - - assertEquals(0, cache1.getNumberOfNodes()); - assertEquals(0, cache2.getNumberOfNodes()); - } - - public void testSyncReplWithModficationsOnBothCachesWithRollback() thro= ws Exception - { - TransactionManager tm; - final Fqn fqn1 =3D Fqn.fromString("/one/two/three"); - final Fqn fqn2 =3D Fqn.fromString("/eins/zwei/drei"); - - initCaches(Configuration.CacheMode.REPL_SYNC); - - cache1.getConfiguration().setSyncRollbackPhase(true); - cache2.getConfiguration().setSyncRollbackPhase(true); - - tm =3D beginTransaction(); - cache1.put(fqn1, "age", 38); - cache2.put(fqn2, "age", 39); - - System.out.println("cache1 (before commit):\n" + CachePrinter.printC= acheLockingInfo(cache1)); - System.out.println("cache2 (before commit):\n" + CachePrinter.printC= acheLockingInfo(cache2)); - - // this will rollback the transaction - Transaction tx =3D tm.getTransaction(); - tx.registerSynchronization(new TransactionAborter(tx)); - - try - { - tm.commit(); - fail("commit should throw a RollbackException, we should not get = here"); - } - catch (RollbackException rollback) - { - System.out.println("Transaction was rolled back, this is correct"= ); - } - - System.out.println("cache1 (after rollback):\n" + CachePrinter.print= CacheLockingInfo(cache1)); - System.out.println("cache2 (after rollback):\n" + CachePrinter.print= CacheLockingInfo(cache2)); - - assertEquals(0, cache1.getNumberOfLocksHeld()); - assertEquals(0, cache2.getNumberOfLocksHeld()); - - assertEquals(0, cache1.getNumberOfNodes()); - assertEquals(0, cache2.getNumberOfNodes()); - } - - /** - * Test for JBCACHE-359 -- does a callback into cache from a listener - * interfere with transaction rollback. - * - * @throws Exception - */ - - // Is this test still valid after JBCACHE-1022 ? - // public void testSyncReplWithRollbackAndListener() throws Exception - // { - // Transaction tx; - // final Fqn NODE1 =3D Fqn.fromString("/one/two/three"); - // - // initCaches(Configuration.CacheMode.REPL_SYNC); - // - // cache1.getConfiguration().setSyncRollbackPhase(true); - // cache2.getConfiguration().setSyncRollbackPhase(true); - // - // // Test with a rollback on the sending side - // - // CallbackListener cbl1 =3D new CallbackListener(cache1, "age"); - // CallbackListener cbl2 =3D new CallbackListener(cache2, "age"); - // - // tx =3D beginTransaction(); - // cache1.put(NODE1, "age", 38); - // - // System.out.println("cache1 (before commit):\n" + CachePrinter.p= rintCacheLockingInfo(cache1)); - // System.out.println("cache2 (before commit):\n" + CachePrinter.p= rintCacheLockingInfo(cache2)); - // - // // this will rollback the transaction - // tx.registerSynchronization(new TransactionAborter(tx)); - // - // try - // { - // tx.commit(); - // fail("commit should throw a RollbackException, we should not= get here"); - // } - // catch (RollbackException rollback) - // { - // rollback.printStackTrace(); - // System.out.println("Transaction was rolled back, this is cor= rect"); - // } - // - // // Sleep, as the rollback call to cache2 is async - // TestingUtil.sleepThread(1000); - // - // System.out.println("cache1 (after rollback):\n" + CachePrinter.= printCacheLockingInfo(cache1)); - // System.out.println("cache2 (after rollback):\n" + CachePrinter.= printCacheLockingInfo(cache2)); - // - // assertNull(cbl1.getCallbackException()); - // assertNull(cbl2.getCallbackException()); - // - // assertEquals(0, cache1.getNumberOfLocksHeld()); - // assertEquals(0, cache2.getNumberOfLocksHeld()); - // - // assertEquals(0, cache1.getNumberOfNodes()); - // assertEquals(0, cache2.getNumberOfNodes()); - // - // // Test with a rollback on the receiving side - // - // cache2.getNotifier().removeCacheListener(cbl2); - // // listener aborts any active tx - // cbl2 =3D new TransactionAborterCallbackListener(cache2, "age"); - // - // tx =3D beginTransaction(); - // cache1.put(NODE1, "age", 38); - // - // System.out.println("cache1 (before commit):\n" + CachePrinter.p= rintCacheLockingInfo(cache1)); - // System.out.println("cache2 (before commit):\n" + CachePrinter.p= rintCacheLockingInfo(cache2)); - // - // tx.commit(); - // - // // Sleep, as the commit call to cache2 is async - // TestingUtil.sleepThread(1000); - // - // System.out.println("cache1 (after rollback):\n" + CachePrinter.= printCacheLockingInfo(cache1)); - // System.out.println("cache2 (after rollback):\n" + CachePrinter.= printCacheLockingInfo(cache2)); - // - // assertNull(cbl1.getCallbackException()); - // assertNull(cbl2.getCallbackException()); - // - // assertEquals(0, cache1.getNumberOfLocksHeld()); - // assertEquals(0, cache2.getNumberOfLocksHeld()); - // - // // cache1 didn't fail, so should have 3 nodes - // assertEquals(3, cache1.getNumberOfNodes()); - // assertEquals(0, cache2.getNumberOfNodes()); - // - // } - - /** - * Test for JBCACHE-361 -- does marking a tx on the remote side - * rollback-only cause a rollback on the originating side? - */ - public void testSyncReplWithRemoteRollback() throws Exception - { - TransactionManager tm; - final Fqn NODE1 =3D Fqn.fromString("/one/two/three"); - - initCaches(Configuration.CacheMode.REPL_SYNC); - - cache1.getConfiguration().setSyncRollbackPhase(true); - cache2.getConfiguration().setSyncRollbackPhase(true); - - // Test with a rollback on the remote side - - // listener aborts any active tx - //TransactionAborterListener tal =3D new TransactionAborterListener(= cache2); - - tm =3D beginTransaction(); - cache1.put(NODE1, "age", 38); - - System.out.println("cache1 (before commit):\n" + CachePrinter.printC= acheLockingInfo(cache1)); - System.out.println("cache2 (before commit):\n" + CachePrinter.printC= acheLockingInfo(cache2)); - - // instead of a listener lets just get a WL on ROOT on cache2. And h= old on to it. - Transaction tx =3D tm.suspend(); - - tm.begin(); - cache2.getRoot().put("x", "y"); - Transaction tx2 =3D cache2.getTransactionManager().suspend(); - - System.out.println("cache2 (before commit):\n" + CachePrinter.printC= acheLockingInfo(cache2)); - tm.resume(tx); - - try - { - tm.commit(); - fail("commit should throw a RollbackException, we should not get = here"); - } - catch (RollbackException rollback) - { - System.out.println("Transaction was rolled back, this is correct"= ); - } - finally - { - tm.resume(tx2); - tm.rollback(); - } - - // Sleep, as the commit call to cache2 is async - TestingUtil.sleepThread(1000); - - System.out.println("cache1 (after rollback):\n" + CachePrinter.print= CacheLockingInfo(cache1)); - System.out.println("cache2 (after rollback):\n" + CachePrinter.print= CacheLockingInfo(cache2)); - - //assertNull(tal.getCallbackException()); - - assertEquals(0, cache1.getNumberOfLocksHeld()); - assertEquals(0, cache2.getNumberOfLocksHeld()); - - assertEquals(0, cache1.getNumberOfNodes()); - assertEquals(0, cache2.getNumberOfNodes()); - - } - - public void testASyncRepl() throws Exception - { - Integer age; - TransactionManager tm; - - initCaches(Configuration.CacheMode.REPL_ASYNC); - - tm =3D beginTransaction(); - cache1.put("/a/b/c", "age", 38); - Thread.sleep(1000); - assertNull("age on cache2 must be null as the TX has not yet been co= mmitted", cache2.get("/a/b/c", "age")); - tm.commit(); - Thread.sleep(1000); - - // value on cache2 must be 38 - age =3D (Integer) cache2.get("/a/b/c", "age"); - assertNotNull("\"age\" obtained from cache2 is null ", age); - assertTrue("\"age\" must be 38", age =3D=3D 38); - - } - - /** - * Tests concurrent modifications: thread1 succeeds and thread2 is bloc= ked until thread1 is done, and then succeeds - * too. However, this is flawed with the introduction of interceptors, = here's why.
    - *

      - *
    • Thread1 acquires the lock for /bela/ban on cache1 - *
    • Thread2 blocks on Thread1 to release the lock - *
    • Thread1 commits: this means the TransactionInterceptor and the R= eplicationInterceptor are called in - * the sequence in which they registered. Unfortunately, the Transactio= nInterceptor registered first. In the - * PREPARE phase, the ReplicationInterceptor calls prepare() in cache2 = synchronously. The TxInterceptor - * does nothing. The the COMMIT phase, the TxInterceptor commits the da= ta by releasing the locks locally and - * then the ReplicationInterceptor sends an asynchronous COMMIT to cach= e2. - *
    • Because the TxInterceptor for Thread1 releases the locks locally= before sending the async COMMIT, - * Thread2 is able to acquire the lock for /bela/ban in cache1 and then= starts the PREPARE phase by sending a - * synchronous PREPARE to cache2. If this PREPARE arrives at cache2 before the COMMIT from Thread1, - * the PREPARE will block because it attempts to acquire a lock on /bel= a/ban on cache2 still held by Thread1 - * (which would be released by Thread1's COMMIT). This results in deadl= ock, which is resolved by Thread2 running - * into a timeout with subsequent rollback and Thread1 succeeding.
      - *
    - * There are 3 solutions to this: - *
      - *
    1. Do nothing. This is standard behavior for concurrent access to t= he same data. Same thing if the 2 threads - * operated on the same data in separate caches, e.g. Thread1 = on /bela/ban in cache1 and Thread2 on - * /bela/ban in cache2. The semantics of Tx commit as handled by the in= terceptors is: after tx1.commit() returns - * the locks held by tx1 are release and a COMMIT message is on the way= (if sent asynchronously). - *
    2. Force an order over TxInterceptor and ReplicationInterceptor. Th= is would require ReplicationInterceptor - * to always be fired first on TX commit. Downside: the interceptors ha= ve an implicit dependency, which is not - * nice. - *
    3. Priority-order requests at the receiver; e.g. a COMMIT could rel= ease a blocked PREPARE. This is bad because - * it violates JGroups' FIFO ordering guarantees. - *
    - * I'm currently investigating solution #2, ie. creating an OrderedSync= hronizationHandler, which allows other - * SynchronizationHandlers to register (atHead, atTail), and the Ordere= dSynchronizationHandler would call the - * SynchronizationHandler in the order in which they are defined. - * - * @throws Exception exception - */ - public void testConcurrentPuts() throws Exception - { - initCaches(Configuration.CacheMode.REPL_SYNC); - cache1.getConfiguration().setSyncCommitPhase(true); - - Thread t1 =3D new Thread("Thread1") - { - TransactionManager tm; - - public void run() - { - try - { - tm =3D beginTransaction(); - cache1.put("/bela/ban", "name", "Bela Ban"); - TestingUtil.sleepThread(2000);// Thread2 will be blocked un= til we commit - tm.commit(); - System.out.println("[Thread1] ** LOCK INFO cache1: " + Cach= ePrinter.printCacheLockingInfo(cache1)); - System.out.println("[Thread1] ** LOCK INFO cache2: " + Cach= ePrinter.printCacheLockingInfo(cache2)); - } - catch (Throwable ex) - { - ex.printStackTrace(); - t1_ex =3D ex; - } - } - }; - - Thread t2 =3D new Thread("Thread2") - { - TransactionManager tm; - - public void run() - { - try - { - TestingUtil.sleepThread(1000);// give Thread1 time to acqui= re the lock - tm =3D beginTransaction(); - System.out.println("[Thread2] ** LOCK INFO cache1: " + Cach= ePrinter.printCacheLockingInfo(cache1)); - System.out.println("[Thread2] ** LOCK INFO cache2: " + Cach= ePrinter.printCacheLockingInfo(cache2)); - cache1.put("/bela/ban", "name", "Michelle Ban"); - System.out.println("[Thread2] ** LOCK INFO cache1: " + Cach= ePrinter.printCacheLockingInfo(cache1)); - System.out.println("[Thread2] ** LOCK INFO cache2: " + Cach= ePrinter.printCacheLockingInfo(cache2)); - tm.commit(); - System.out.println("[Thread2] ** LOCK INFO cache1: " + Cach= ePrinter.printCacheLockingInfo(cache1)); - System.out.println("[Thread2] ** LOCK INFO cache2: " + Cach= ePrinter.printCacheLockingInfo(cache2)); - } - catch (Throwable ex) - { - ex.printStackTrace(); - t2_ex =3D ex; - } - } - }; - - // Let the game start - t1.start(); - t2.start(); - - // Wait for threads to die - t1.join(); - t2.join(); - - if (t1_ex !=3D null) - { - fail("Thread1 failed: " + t1_ex); - } - if (t2_ex !=3D null) - { - fail("Thread2 failed: " + t2_ex); - } - - assertEquals("Michelle Ban", cache1.get("/bela/ban", "name")); - } - - /** - * Should reproduce JBCACHE-32 problem (http://jira.jboss.com/jira/brow= se/JBCACHE-32) - */ - public void testConcurrentCommitsWith1Thread() throws Exception - { - _testConcurrentCommits(1); - } - - /** - * Should reproduce JBCACHE-32 problem (http://jira.jboss.com/jira/brow= se/JBCACHE-32) - */ - public void testConcurrentCommitsWith5Threads() throws Exception - { - _testConcurrentCommits(5); - } - - /** - * Should reproduce JBCACHE-32 problem (http://jira.jboss.com/jira/brow= se/JBCACHE-32) - */ - private void _testConcurrentCommits(int num_threads) - { - Object myMutex =3D new Object(); - - final CacheSPI c1 =3D (CacheSPI) new= DefaultCacheFactory().createCache(false); - final CacheSPI c2 =3D (CacheSPI) new= DefaultCacheFactory().createCache(false); - c1.getConfiguration().setClusterName("TempCluster"); - c2.getConfiguration().setClusterName("TempCluster"); - c1.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC= ); - c2.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC= ); - c1.getConfiguration().setSyncCommitPhase(true); - c2.getConfiguration().setSyncCommitPhase(true); - c1.getConfiguration().setSyncRollbackPhase(true); - c2.getConfiguration().setSyncRollbackPhase(true); - c1.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_RE= AD); - c2.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_RE= AD); - c1.getConfiguration().setTransactionManagerLookupClass("org.jboss.ca= che.transaction.DummyTransactionManagerLookup"); - c2.getConfiguration().setTransactionManagerLookupClass("org.jboss.ca= che.transaction.DummyTransactionManagerLookup"); - c1.getConfiguration().setLockAcquisitionTimeout(5000); - c2.getConfiguration().setLockAcquisitionTimeout(5000); - c1.start(); - c2.start(); - final List exceptions =3D new ArrayList(); - - class MyThread extends Thread - { - final Object mutex; - - public MyThread(String name, Object mutex) - { - super(name); - this.mutex =3D mutex; - } - - public void run() - { - TransactionManager tm =3D null; - - try - { - tm =3D beginTransaction(c1); - c1.put("/thread/" + getName(), null); - System.out.println("Thread " + getName() + " after put(): "= + c1.toString()); - System.out.println("Thread " + getName() + " waiting on mut= ex"); - synchronized (mutex) - { - mutex.wait(); - } - System.out.println("Thread " + getName() + " committing"); - tm.commit(); - System.out.println("Thread " + getName() + " committed succ= essfully"); - } - catch (Exception e) - { - exceptions.add(e); - } - finally - { - try - { - if (tm !=3D null) - tm.rollback(); - } - catch (Exception e) - { - // do nothing - } - } - } - } - - MyThread[] threads =3D new MyThread[num_threads]; - for (int i =3D 0; i < threads.length; i++) - { - threads[i] =3D new MyThread("#" + i, myMutex); - } - for (int i =3D 0; i < threads.length; i++) - { - MyThread thread =3D threads[i]; - System.out.println("starting thread #" + i); - thread.start(); - } - - TestingUtil.sleepThread(6000); - synchronized (myMutex) - { - System.out.println("cache is " + CachePrinter.printCacheLockingIn= fo(c1)); - System.out.println("******************* SIGNALLING THREADS ******= **************"); - myMutex.notifyAll(); - } - - for (MyThread thread : threads) - { - try - { - thread.join(); - System.out.println("Joined thread " + thread.getName()); - } - catch (InterruptedException e) - { - e.printStackTrace(); - } - } - - System.out.println("FINAL c1:\n" + CachePrinter.printCacheDetails(c1= ) + "\nlocks:\n" + CachePrinter.printCacheLockingInfo(c1)); - - assertEquals(0, c1.getNumberOfLocksHeld()); - assertEquals(0, c2.getNumberOfLocksHeld()); - - c1.stop(); - c2.stop(); - - // if(ex !=3D null) - // { - // ex.printStackTrace(); - // fail("Thread failed: " + ex); - // } - - // we can only expect 1 thread to succeed. The others will fail. S= o, threads.length -1 exceptions. - // this is a timing issue - 2 threads still may succeed on a multi c= pu system - // assertEquals(threads.length - 1, exceptions.size()); - - for (Exception exception : exceptions) - assertEquals(TimeoutException.class, exception.getClass()); - } - - /** - * Conncurrent put on 2 different instances. - */ - public void testConcurrentPutsOnTwoInstances() throws Exception - { - initCaches(Configuration.CacheMode.REPL_SYNC); - final CacheSPI c1 =3D this.cache1; - final CacheSPI c2 =3D this.cache2; - - Thread t1 =3D new Thread() - { - TransactionManager tm; - - public void run() - { - try - { - tm =3D beginTransaction(); - c1.put("/ben/wang", "name", "Ben Wang"); - TestingUtil.sleepThread(8000); - tm.commit();// This should go thru - } - catch (Throwable ex) - { - ex.printStackTrace(); - t1_ex =3D ex; - } - } - }; - - Thread t2 =3D new Thread() - { - TransactionManager tm; - - public void run() - { - try - { - TestingUtil.sleepThread(1000);// give Thread1 time to acqui= re the lock - tm =3D beginTransaction(); - c2.put("/ben/wang", "name", "Ben Jr."); - tm.commit();// This will time out and rollback first becaus= e Thread1 has a tx going as well. - } - catch (RollbackException rollback_ex) - { - System.out.println("received rollback exception as expected= "); - } - catch (Throwable ex) - { - ex.printStackTrace(); - t2_ex =3D ex; - } - } - }; - - // Let the game start - t1.start(); - t2.start(); - - // Wait for thread to die but put an insurance of 5 seconds on it. - t1.join(); - t2.join(); - - if (t1_ex !=3D null) - { - fail("Thread1 failed: " + t1_ex); - } - if (t2_ex !=3D null) - { - fail("Thread2 failed: " + t2_ex); - } - assertEquals("Ben Wang", c1.get("/ben/wang", "name")); - } - - public void testPut() throws Exception - { - initCaches(Configuration.CacheMode.REPL_SYNC); - final CacheSPI c1 =3D this.cache1; - - Thread t1 =3D new Thread() - { - public void run() - { - try - { - lock.acquire(); - System.out.println("-- t1 has lock"); - c1.put("/a/b/c", "age", 38); - System.out.println("[Thread1] set value to 38"); - - System.out.println("-- t1 releases lock"); - lock.release(); - TestingUtil.sleepThread(300); - Thread.yield(); - - lock.acquire(); - System.out.println("-- t1 has lock"); - c1.put("/a/b/c", "age", 39); - System.out.println("[Thread1] set value to 39"); - - System.out.println("-- t1 releases lock"); - lock.release(); - assertEquals(39, c1.get("/a/b/c", "age")); - } - catch (Throwable ex) - { - ex.printStackTrace(); - t1_ex =3D ex; - } - finally - { - lock.release(); - } - } - }; - - Thread t2 =3D new Thread() - { - public void run() - { - try - { - TestingUtil.sleepThread(100); - Thread.yield(); - lock.acquire(); - System.out.println("-- t2 has lock"); - // Should replicate the value right away. - Integer val =3D (Integer) cache2.get("/a/b/c", "age"); - System.out.println("[Thread2] value is " + val); - assertEquals(new Integer(38), val); - System.out.println("-- t2 releases lock"); - lock.release(); - TestingUtil.sleepThread(300); - Thread.yield(); - TestingUtil.sleepThread(500); - lock.acquire(); - System.out.println("-- t2 has lock"); - val =3D (Integer) cache2.get("/a/b/c", "age"); - System.out.println("-- t2 releases lock"); - lock.release(); - assertEquals(new Integer(39), val); - } - catch (Throwable ex) - { - ex.printStackTrace(); - t2_ex =3D ex; - } - finally - { - lock.release(); - } - } - }; - - // Let the game start - t1.start(); - t2.start(); - - // Wait for thread to die but put an insurance of 5 seconds on it. - t1.join(); - t2.join(); - if (t1_ex !=3D null) - { - fail("Thread1 failed: " + t1_ex); - } - if (t2_ex !=3D null) - { - fail("Thread2 failed: " + t2_ex); - } - } - - /** - * Test replicated cache with transaction. Idea is to have two threads = running - * a local cache each that is replicating. Depending on whether cache1 = commit/rollback or not, - * the cache2.get will get different values. - * Note that we have used sleep to interpose thread execution sequence. - * Although it's not fool proof, it is rather simple and intuitive. - */ - public void testPutTx() throws Exception - { - TransactionManager tm; - - try - { - initCaches(Configuration.CacheMode.REPL_SYNC); - cache1.getConfiguration().setSyncCommitPhase(true); - cache2.getConfiguration().setSyncCommitPhase(true); - tm =3D beginTransaction(); - cache1.put("/a/b/c", "age", 38); - cache1.put("/a/b/c", "age", 39); - Object val =3D cache2.get("/a/b/c", "age");// must be null as not= yet committed - assertNull(val); - tm.commit(); - - tm =3D beginTransaction(); - assertEquals(39, cache2.get("/a/b/c", "age"));// must not be null - tm.commit(); - } - catch (Throwable t) - { - t.printStackTrace(); - t1_ex =3D t; - } - finally - { - lock.release(); - } - } - - /** - * Have both cache1 and cache2 do add and commit. cache1 commit should = time out - * since it can't obtain the lock when trying to replicate cache2. On t= he other hand, - * cache2 commit will succeed since now that cache1 is rollbacked and l= ock is - * released. - */ - public void testPutTx1() throws Exception - { - initCaches(Configuration.CacheMode.REPL_SYNC); - final CacheSPI c1 =3D this.cache1; - Thread t1 =3D new Thread() - { - public void run() - { - TransactionManager tm; - - try - { - lock.acquire(); - tm =3D beginTransaction(); - c1.put("/a/b/c", "age", 38); - c1.put("/a/b/c", "age", 39); - lock.release(); - - TestingUtil.sleepThread(300); - lock.acquire(); - try - { - tm.commit(); - } - catch (RollbackException ex) - { - System.out.println("[Thread1] received RollbackException= , as expected. Rolling back changes"); - } - finally - { - lock.release(); - } - } - catch (Throwable ex) - { - ex.printStackTrace(); - t1_ex =3D ex; - } - finally - { - lock.release(); - } - } - }; - - Thread t2 =3D new Thread() - { - public void run() - { - TransactionManager tm; - - try - { - sleep(200); - Thread.yield(); - lock.acquire(); - tm =3D beginTransaction(); - assertNull(cache2.get("/a/b/c", "age"));// must be null as = not yet committed - cache2.put("/a/b/c", "age", 40); - lock.release(); - - TestingUtil.sleepThread(300); - lock.acquire(); - assertEquals(40, cache2.get("/a/b/c", "age"));// must not b= e null - tm.commit(); - lock.release(); - - TestingUtil.sleepThread(1000); - tm =3D beginTransaction(); - assertEquals("After cache2 commit", 40, cache2.get("/a/b/c"= , "age")); - tm.commit(); - } - catch (Throwable ex) - { - ex.printStackTrace(); - t2_ex =3D ex; - } - finally - { - lock.release(); - } - } - }; - - // Let the game start - t1.start(); - t2.start(); - - t1.join(); - t2.join(); - - if (t1_ex !=3D null) - { - fail("Thread1 failed: " + t1_ex); - } - if (t2_ex !=3D null) - { - fail("Thread2 failed: " + t2_ex); - } - } - - public void testPutTxWithRollback() throws Exception - { - initCaches(Configuration.CacheMode.REPL_SYNC); - final CacheSPI c2 =3D this.cache1; - Thread t1 =3D new Thread() - { - public void run() - { - TransactionManager tm; - - try - { - lock.acquire(); - tm =3D beginTransaction(); - c2.put("/a/b/c", "age", 38); - c2.put("/a/b/c", "age", 39); - lock.release(); - - TestingUtil.sleepThread(100); - lock.acquire(); - tm.rollback(); - lock.release(); - } - catch (Throwable ex) - { - ex.printStackTrace(); - t1_ex =3D ex; - } - finally - { - lock.release(); - } - } - }; - - Thread t2 =3D new Thread() - { - public void run() - { - TransactionManager tm; - - try - { - sleep(200); - Thread.yield(); - lock.acquire(); - tm =3D beginTransaction(); - assertNull(cache2.get("/a/b/c", "age"));// must be null as = not yet committed - lock.release(); - - TestingUtil.sleepThread(100); - lock.acquire(); - assertNull(cache2.get("/a/b/c", "age"));// must be null as = rolledback - tm.commit(); - lock.release(); - } - catch (Throwable ex) - { - ex.printStackTrace(); - t2_ex =3D ex; - } - finally - { - lock.release(); - } - } - }; - - // Let the game start - t1.start(); - t2.start(); - - // Wait for thread to die but put an insurance of 5 seconds on it. - t1.join(); - t2.join(); - if (t1_ex !=3D null) - { - fail("Thread1 failed: " + t1_ex); - } - if (t2_ex !=3D null) - { - fail("Thread2 failed: " + t2_ex); - } - } - - static class TransactionAborter implements Synchronization - { - Transaction ltx =3D null; - - public TransactionAborter(Transaction ltx) - { - this.ltx =3D ltx; - } - - public void beforeCompletion() - { - try - { - ltx.setRollbackOnly(); - } - catch (SystemException e) - { - // who cares - } - } - - public void afterCompletion(int status) - { - } - } - - @CacheListener - static class CallbackListener - { - - CacheSPI callbackCache; - Object callbackKey; - Exception ex; - final Object mutex =3D new Object(); - - CallbackListener(CacheSPI cache, Object callbackKey) - { - this.callbackCache =3D cache; - this.callbackKey =3D callbackKey; - cache.getNotifier().addCacheListener(this); - } - - @NodeModified - public void nodeModified(NodeEvent e) - { - if (!e.isPre()) - { - // Lock on a mutex so test can't check for an exception - // until the get call completes - synchronized (mutex) - { - try - { - callbackCache.get(e.getFqn(), callbackKey); - } - catch (CacheException exc) - { - exc.printStackTrace(); - ex =3D exc; - } - } - } - } - - Exception getCallbackException() - { - synchronized (mutex) - { - return ex; - } - } - - } - - static class TransactionAborterCallbackListener extends CallbackListener - { - - TransactionManager callbackTM; - - TransactionAborterCallbackListener(CacheSPI cache, O= bject callbackKey) - { - super(cache, callbackKey); - callbackTM =3D callbackCache.getTransactionManager(); - } - - @NodeModified - public void nodeModified(NodeEvent ne) - { - if (!ne.isPre()) - { - try - { - Transaction tx =3D callbackTM.getTransaction(); - if (tx !=3D null && tx.getStatus() =3D=3D Status.STATUS_ACT= IVE) - { - // this will rollback the transaction - tx.registerSynchronization(new TransactionAborter(tx)); - } - else - { - super.nodeModified(ne); - } - - } - catch (Exception e) - { - e.printStackTrace(); - if (ex =3D=3D null) - { - ex =3D e; - } - } - } - } - - } - -} Deleted: core/trunk/src/test/java/org/jboss/cache/transaction/AbortionTest.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/transaction/AbortionTest.java = 2008-08-23 12:40:58 UTC (rev 6610) +++ core/trunk/src/test/java/org/jboss/cache/transaction/AbortionTest.java = 2008-08-25 17:50:21 UTC (rev 6611) @@ -1,199 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package org.jboss.cache.transaction; - -import org.jboss.cache.CacheSPI; -import org.jboss.cache.DefaultCacheFactory; -import org.jboss.cache.interceptors.OrderedSynchronizationHandler; -import org.jboss.cache.transaction.NotifyingTransactionManager.Notificatio= n; -import org.jboss.cache.util.TestingUtil; -import org.jgroups.JChannel; -import static org.testng.AssertJUnit.*; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import javax.transaction.RollbackException; -import javax.transaction.Synchronization; -import javax.transaction.SystemException; -import javax.transaction.Transaction; -import javax.transaction.TransactionManager; - -/** - * @author Manik Surtani (manik(a)jbo= ss.org) - */ -(a)Test(groups =3D {"functional"}) -public class AbortionTest -{ - private CacheSPI cache1, cache2, cache3; - - @BeforeMethod(alwaysRun =3D true) - public void setUp() throws Exception - { - cache1 =3D initCache(false); - TestingUtil.sleepThread(1500); // to ensure cache1 is the coordinator - cache2 =3D initCache(false); - cache3 =3D initCache(true); - } - - @AfterMethod(alwaysRun =3D true) - public void tearDown() throws Exception - { - TestingUtil.killCaches(cache3, cache2, cache1); - } - - private CacheSPI initCache(boolean notifying) - { - CacheSPI c =3D (CacheSPI) new DefaultCacheFactory().= createCache(false); - c.getConfiguration().setCacheMode("REPL_SYNC"); - c.getConfiguration().setClusterConfig(getJGroupsStack()); - c.getConfiguration().setFetchInMemoryState(false); - if (!notifying) - { - c.getConfiguration().setTransactionManagerLookupClass("org.jboss.= cache.transaction.DummyTransactionManagerLookup"); - } - else - { - c.getConfiguration().setTransactionManagerLookupClass("org.jboss.= cache.transaction.NotifyingTransactionManager"); - } - c.start(); - return c; - } - - // we need a 'special' stack that does not attempt redelivery since we = kill a channel midway during a tx in this test. - private String getJGroupsStack() - { - return JChannel.DEFAULT_PROTOCOL_STACK; - } - - private void destroyCache(CacheSPI c) - { - if (c !=3D null) - { - c.stop(); - c.destroy(); - } - } - - public void testSyncCaches() throws Exception - { - performTest(false, false); - } - - public void testSyncCachesSyncCommitRollback() throws Exception - { - performTest(true, false); - } - - /** - * Note that this tests a *remote* beforeCompletion abort - which is a = part of the calling instance's afterCompletion. - * - * @throws Exception - */ - public void testAbortBeforeCompletion() throws Exception - { - performTest(true, true); - } - - private void performTest(boolean syncCommitRollback, boolean abortBefor= eCompletion) throws Exception - { - cache1.getConfiguration().setSyncCommitPhase(syncCommitRollback); - cache1.getConfiguration().setSyncRollbackPhase(syncCommitRollback); - cache2.getConfiguration().setSyncCommitPhase(syncCommitRollback); - cache2.getConfiguration().setSyncRollbackPhase(syncCommitRollback); - cache3.getConfiguration().setSyncCommitPhase(syncCommitRollback); - cache3.getConfiguration().setSyncRollbackPhase(syncCommitRollback); - - TransactionManager mgr1 =3D cache1.getTransactionManager(); - TransactionManager mgr2 =3D cache2.getTransactionManager(); - assertTrue(cache3.getTransactionManager() instanceof NotifyingTransa= ctionManager); - NotifyingTransactionManager mgr3 =3D (NotifyingTransactionManager) c= ache3.getTransactionManager(); - mgr3.setCache(cache3); - - assertSame(mgr1, mgr2); - assertNotSame(mgr1, mgr3); - assertNotSame(mgr2, mgr3); - - assertTrue(mgr1 instanceof DummyTransactionManager); - assertTrue(mgr2 instanceof DummyTransactionManager); - - cache1.put("/test", "key", "value"); - - assertEquals("value", cache1.get("/test", "key")); - assertEquals("value", cache2.get("/test", "key")); - assertEquals("value", cache3.get("/test", "key")); - - mgr3.setNotification(new TestNotification(abortBeforeCompletion)); - - mgr1.begin(); - cache1.put("/test", "key", "value2"); - mgr1.commit(); - - TestingUtil.sleepThread(5000); - - // only test cache1 and cache2. Assume cache3 has crashed out. - assertEquals(0, cache1.getNumberOfLocksHeld()); - assertEquals(0, cache2.getNumberOfLocksHeld()); - assertEquals("put in transaction should NOT have been rolled back", = "value2", cache1.get("/test", "key")); - assertEquals("put in transaction should NOT have been rolled back", = "value2", cache2.get("/test", "key")); - - } - - class TestNotification implements Notification - { - boolean abortBeforeCompletion; - - public TestNotification(boolean abortBeforeCompletion) - { - this.abortBeforeCompletion =3D abortBeforeCompletion; - } - - public void notify(Transaction tx, TransactionContext transactionCon= text) throws SystemException, RollbackException - { - OrderedSynchronizationHandler osh =3D transactionContext.getOrder= edSynchronizationHandler(); - - final Transaction finalTx =3D tx; - System.out.println("Notify called."); - // add an aborting sync handler. - Synchronization abort =3D new Synchronization() - { - - public void beforeCompletion() - { - if (abortBeforeCompletion) - { - cache3.getConfiguration().getRuntimeConfig().getChannel(= ).close(); - System.out.println("Returning from abort.beforeCompletio= n"); - try - { - finalTx.setRollbackOnly(); - } - catch (SystemException e) - { - throw new RuntimeException("Unable to set rollback", = e); - } - throw new RuntimeException("Dummy exception"); - } - } - - public void afterCompletion(int i) - { - if (!abortBeforeCompletion) - { - cache3.getConfiguration().getRuntimeConfig().getChannel(= ).close(); - System.out.println("Returning from abort.afterCompletion= "); - throw new RuntimeException("Dummy exception"); - } - } - }; - - osh.registerAtHead(abort); - System.out.println("Added sync handler."); - } - - } -} Deleted: core/trunk/src/test/java/org/jboss/cache/transaction/AsyncRollback= TxTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/transaction/AsyncRollbackTxTes= t.java 2008-08-23 12:40:58 UTC (rev 6610) +++ core/trunk/src/test/java/org/jboss/cache/transaction/AsyncRollbackTxTes= t.java 2008-08-25 17:50:21 UTC (rev 6611) @@ -1,239 +0,0 @@ -package org.jboss.cache.transaction; - -import org.jboss.cache.CacheFactory; -import org.jboss.cache.CacheSPI; -import org.jboss.cache.DefaultCacheFactory; -import org.jboss.cache.Fqn; -import org.jboss.cache.config.Configuration; -import static org.testng.AssertJUnit.*; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import javax.transaction.SystemException; -import javax.transaction.TransactionManager; - -/** - * Test behaviour of async rollback timeouted transaction - * - * @author Jacek Halat - * @since 1.4.0 - */ -(a)Test(groups =3D {"functional"}) -public class AsyncRollbackTxTest -{ - private CacheSPI cache; - private TransactionManager tm; - private Fqn fqn =3D Fqn.fromString("/test"); - // This sleep time (millis) should be longer than the transaction timeo= ut time. - private long sleepTime =3D 2500; - // seconds - private int txTimeout =3D 2; - - @BeforeMethod(alwaysRun =3D true) - public void setUp() throws Exception - { - Configuration c =3D new Configuration(); - c.setTransactionManagerLookupClass("org.jboss.cache.transaction.Asyn= cRollbackTransactionManagerLookup"); - CacheFactory instance =3D new DefaultCacheFactory(); - cache =3D (CacheSPI) instance.createCache(c); - tm =3D cache.getConfiguration().getRuntimeConfig().getTransactionMan= ager(); - tm.setTransactionTimeout(txTimeout); - } - - @AfterMethod(alwaysRun =3D true) - public void tearDown() - { - try - { - if (tm !=3D null && tm.getTransaction() !=3D null) - { - try - { - tm.rollback(); - } - catch (SystemException e) - { - // do nothing - } - } - } - catch (SystemException e) - { - // do nothing - } - if (cache !=3D null) - cache.stop(); - cache =3D null; - tm =3D null; - } - - public void testCommitCreationInSameTx() throws Exception - { - assertEquals(0, cache.getNumberOfLocksHeld()); - tm.begin(); - cache.put(fqn, "k", "v"); - assertEquals(2, cache.getNumberOfLocksHeld()); - Thread.sleep(sleepTime); - tm.commit(); - assertEquals(0, cache.getNumberOfLocksHeld()); - } - - public void testRollbackCreationInSameTx() throws Exception - { - assertEquals(0, cache.getNumberOfLocksHeld()); - tm.begin(); - cache.put(fqn, "k", "v"); - assertEquals(2, cache.getNumberOfLocksHeld()); - Thread.sleep(sleepTime); - tm.rollback(); - assertEquals(0, cache.getNumberOfLocksHeld()); - // make sure the node was NOT added!! - assertFalse(cache.exists(fqn)); - // even in a "deleted" form - assertNull(cache.peek(fqn, true)); - } - - private void doTest(boolean commit, boolean writeLock) throws Exception - { - assertEquals(0, cache.getNumberOfLocksHeld()); - cache.put(fqn, "k", "v");//Executed in Not transactional context - assertEquals(0, cache.getNumberOfLocksHeld()); - SeparateThread t =3D new SeparateThread(commit, writeLock); - t.start(); - t.join(); - if (t.getException() !=3D null) - { - throw t.getException(); - } - assertEquals(0, cache.getNumberOfLocksHeld()); - assertEquals("v", cache.get(fqn, "k")); - } - - public void testRollbackCreationInDifferentTxReadLock() throws Exception - { - doTest(false, false); - } - - public void testCommitCreationInDifferentTxReadLock() throws Exception - { - doTest(true, false); - } - - public void testRollbackCreationInDifferentTxWriteLock() throws Excepti= on - { - doTest(false, true); - } - - public void testCommitCreationInDifferentTxWriteLock() throws Exception - { - doTest(true, true); - } - - public void testTxTimeoutAndPutAfter() throws Exception - { - assertEquals(0, cache.getNumberOfLocksHeld()); - tm.begin(); - cache.put(fqn, "k", "v"); - assertEquals(2, cache.getNumberOfLocksHeld()); - assertNotNull(tm.getTransaction()); - Thread.sleep(sleepTime); - tm.rollback(); - assertNull(tm.getTransaction()); - assertEquals(0, cache.getNumberOfLocksHeld()); - - // make sure the node was NOT added!! - assertFalse(cache.exists(fqn)); - // even in a "deleted" form - assertNull(cache.peek(fqn, true)); - - //Put not some data into cache. Because no transaction is used - //no locks should be helds after this line. - cache.put(fqn, "k", "v"); - assertEquals(0, cache.getNumberOfLocksHeld()); - } - - public void testTxTimeoutAndPutGetAfter() throws Exception - { - assertEquals(0, cache.getNumberOfLocksHeld()); - tm.begin(); - cache.put(fqn, "k", "v"); - assertEquals(2, cache.getNumberOfLocksHeld()); - assertNotNull(tm.getTransaction()); - Thread.sleep(sleepTime); - tm.rollback(); - // make sure the node was NOT added!! - assertFalse(cache.exists(fqn)); - // even in a "deleted" form - assertNull(cache.peek(fqn, true)); - assertNull(tm.getTransaction()); - assertEquals(0, cache.getNumberOfLocksHeld()); - - //Put not some data into cache. Because no transaction is used - //no locks should be helds after this line. - cache.put(fqn, "k", "v"); - cache.get(fqn, "k"); - - // Make sure no write lock is retained by the main thread. Test tha= t another thread can read. - SeparateThread t =3D new SeparateThread(false, false); - t.start(); - t.join(); - if (t.getException() !=3D null) - { - throw t.getException(); - } - } - - private class SeparateThread extends Thread - { - Exception e =3D null; - boolean commit, writeLock; - - public SeparateThread(boolean commit, boolean writeLock) - { - this.commit =3D commit; - this.writeLock =3D writeLock; - } - - public Exception getException() - { - return e; - } - - public void run() - { - try - { - tm.begin(); - if (writeLock) - { - cache.put(fqn, "k", "v2");// obtain write lock on node - } - else - { - cache.get(fqn, "k");// obtain read lock on node - } - - // sleep to ensure tx times out. - sleep(2500); - - if (commit) - { - tm.commit(); - } - else - { - tm.rollback(); - } - - assertEquals(0, cache.getNumberOfLocksHeld()); - - } - catch (Exception e) - { - this.e =3D e; - } - } - } - -} Deleted: core/trunk/src/test/java/org/jboss/cache/transaction/ConcurrentTra= nsactionalTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/transaction/ConcurrentTransact= ionalTest.java 2008-08-23 12:40:58 UTC (rev 6610) +++ core/trunk/src/test/java/org/jboss/cache/transaction/ConcurrentTransact= ionalTest.java 2008-08-25 17:50:21 UTC (rev 6611) @@ -1,200 +0,0 @@ -/* - * - * JBoss, the OpenSource J2EE webOS - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package org.jboss.cache.transaction; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jboss.cache.CacheFactory; -import org.jboss.cache.CacheSPI; -import org.jboss.cache.DefaultCacheFactory; -import org.jboss.cache.Fqn; -import org.jboss.cache.config.Configuration; -import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; -import org.jboss.cache.lock.IsolationLevel; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.fail; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import javax.transaction.UserTransaction; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; - -/** - * Unit test for local CacheSPI. Use locking and multiple threads to test - * concurrent access to the tree. - * - * @version $Id$ - */ -(a)Test(groups =3D {"functional", "transaction"}) -public class ConcurrentTransactionalTest -{ - private CacheSPI cache; - private Log logger_ =3D LogFactory.getLog(ConcurrentTransactionalTest.c= lass); - private static Throwable thread_ex =3D null; - private static final int NUM =3D 10000; - - @BeforeMethod(alwaysRun =3D true) - public void setUp() throws Exception - { - } - - private void createCache(IsolationLevel level) - { - CacheFactory factory =3D new DefaultCacheFactory(); - Configuration conf =3D UnitTestCacheConfigurationFactory.createConfi= guration(Configuration.CacheMode.LOCAL, true); - conf.setCacheMode(Configuration.CacheMode.LOCAL); - conf.setIsolationLevel(level); - conf.setTransactionManagerLookupClass(TransactionSetup.getManagerLoo= kup()); - cache =3D (CacheSPI) new DefaultCacheFactory().creat= eCache(conf); - cache.put("/a/b/c", null); - } - - @AfterMethod(alwaysRun =3D true) - public void tearDown() throws Exception - { - cache.stop(); - thread_ex =3D null; - TransactionSetup.cleanup(); - } - - public void testConcurrentAccessWithRWLock() throws Throwable - { - createCache(IsolationLevel.REPEATABLE_READ); - work_(); - } - - public void testConcurrentAccessWithExclusiveLock() throws Throwable - { - createCache(IsolationLevel.SERIALIZABLE); - work_(); - } - - private void work_() throws Throwable - { - Updater one, two; - try - { - one =3D new Updater("Thread one"); - two =3D new Updater("Thread two"); - long current =3D System.currentTimeMillis(); - one.start(); - two.start(); - one.join(); - two.join(); - if (thread_ex !=3D null) - { - throw thread_ex; - } - - long now =3D System.currentTimeMillis(); - log("*** Time elapsed: " + (now - current)); - - System.out.println("cache content: " + cache.toString()); - Set keys =3D cache.getNode(Fqn.fromString("/a/b/c")).get= Keys(); - System.out.println("number of keys=3D" + keys.size()); - - if (keys.size() !=3D NUM) - { - scanForNullValues(keys); - - try - { - System.out.println("size=3D" + keys.size()); - List l =3D new LinkedList(keys); - Collections.sort(l); - System.out.println("keys: " + l); - for (int i =3D 0; i < NUM; i++) - { - if (!l.contains(new Integer(i))) - { - System.out.println("missing: " + i); - } - } - - LinkedList duplicates =3D new LinkedList(= ); - for (Integer integer : l) - { - if (duplicates.contains(integer)) - { - System.out.println(integer + " is a duplicate"); - } - else - { - duplicates.add(integer); - } - } - } - catch (Exception e1) - { - e1.printStackTrace(); - } - } - - assertEquals(NUM, keys.size()); - } - catch (Exception e) - { - e.printStackTrace(); - fail(e.toString()); - } - } - - private void scanForNullValues(Set keys) - { - for (Object o : keys) - { - if (o =3D=3D null) - { - System.err.println("found a null value in keys"); - } - } - } - - private void log(String msg) - { - logger_.debug(" [" + Thread.currentThread() + "]: " + msg); - } - - private class Updater extends Thread - { - private String val =3D null; - private UserTransaction tx; - - public Updater(String name) - { - this.val =3D name; - } - - public void run() - { - try - { - log("adding data"); - tx =3D TransactionSetup.getUserTransaction(); - for (int i =3D 0; i < NUM; i++) - { - log("adding data i=3D" + i); - tx.begin(); - cache.put("/a/b/c", i, val); - tx.commit(); - yield(); - } - } - catch (Throwable t) - { - t.printStackTrace(); - thread_ex =3D t; - } - } - } - -} Deleted: core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLeve= lNoneTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelNone= Test.java 2008-08-23 12:40:58 UTC (rev 6610) +++ core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelNone= Test.java 2008-08-25 17:50:21 UTC (rev 6611) @@ -1,102 +0,0 @@ -package org.jboss.cache.transaction; - -import org.jboss.cache.CacheFactory; -import org.jboss.cache.CacheSPI; -import org.jboss.cache.DefaultCacheFactory; -import org.jboss.cache.Fqn; -import org.jboss.cache.Node; -import org.jboss.cache.config.Configuration; -import org.jboss.cache.lock.IsolationLevel; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.Test; - -import javax.transaction.NotSupportedException; -import javax.transaction.SystemException; -import javax.transaction.TransactionManager; - -/** - * Tests whether modifications within callbacks (TreeCacheListener) are ha= ndled correctly - * - * @author Bela Ban - * @version $Id$ - */ -(a)Test(groups =3D {"functional", "transaction"}) -public class IsolationLevelNoneTest -{ - CacheSPI cache =3D null; - final Fqn FQN =3D Fqn.fromString("/a/b/c"); - final String KEY =3D "key"; - final String VALUE =3D "value"; - TransactionManager tm; - - @AfterMethod(alwaysRun =3D true) - public void tearDown() throws Exception - { - if (cache !=3D null) - { - cache.stop(); - cache.destroy(); - cache =3D null; - } - } - - public void testWithoutTransactions() throws Exception - { - CacheFactory instance =3D new DefaultCacheFactory(); - cache =3D (CacheSPI) instance.createCache(false); - cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL); - cache.getConfiguration().setIsolationLevel(IsolationLevel.NONE); - cache.start(); - cache.put(FQN, KEY, VALUE); - cache.put(FQN + "/d", KEY, VALUE); - Node node =3D cache.peek(FQN, false, false); - assertTrue(node !=3D null && node.getKeys().contains(KEY)); - assertEquals(VALUE, cache.get(FQN, KEY)); - assertEquals(0, cache.getNumberOfLocksHeld()); - } - - public void testWithTransactions() throws Exception - { - CacheFactory instance =3D new DefaultCacheFactory(); - cache =3D (CacheSPI) instance.createCache(false); - cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL); - cache.getConfiguration().setIsolationLevel(IsolationLevel.NONE); - cache.getConfiguration().setTransactionManagerLookupClass(Transactio= nSetup.getManagerLookup()); - cache.start(); - tm =3D startTransaction(); - cache.put(FQN, KEY, VALUE); - cache.put(FQN + "/d", KEY, VALUE); - Node node =3D cache.peek(FQN, false, false); - assertTrue(node !=3D null && node.getKeys().contains(KEY)); - assertEquals(VALUE, cache.get(FQN, KEY)); - assertEquals(0, cache.getNumberOfLocksHeld()); - tm.commit(); - } - - public void testWithTransactionsRepeatableRead() throws Exception - { - CacheFactory instance =3D new DefaultCacheFactory(); - cache =3D (CacheSPI) instance.createCache(false); - cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL); - cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE= _READ); - cache.getConfiguration().setTransactionManagerLookupClass(Transactio= nSetup.getManagerLookup()); - cache.start(); - tm =3D startTransaction(); - cache.put(FQN, KEY, VALUE); - cache.put(FQN + "/d", KEY, VALUE); - Node node =3D cache.peek(FQN, false, false); - assertTrue(node !=3D null && node.getKeys().contains(KEY)); - assertEquals(VALUE, cache.get(FQN, KEY)); - assertEquals(5, cache.getNumberOfLocksHeld()); - tm.commit(); - } - - private TransactionManager startTransaction() throws SystemException, N= otSupportedException - { - TransactionManager mgr =3D cache.getTransactionManager(); - mgr.begin(); - return mgr; - } -} Deleted: core/trunk/src/test/java/org/jboss/cache/transaction/PrepareTxTest= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/transaction/PrepareTxTest.java= 2008-08-23 12:40:58 UTC (rev 6610) +++ core/trunk/src/test/java/org/jboss/cache/transaction/PrepareTxTest.java= 2008-08-25 17:50:21 UTC (rev 6611) @@ -1,154 +0,0 @@ -package org.jboss.cache.transaction; - -import org.jboss.cache.CacheException; -import org.jboss.cache.CacheFactory; -import org.jboss.cache.CacheSPI; -import org.jboss.cache.DefaultCacheFactory; -import static org.testng.AssertJUnit.assertEquals; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import javax.transaction.NotSupportedException; -import javax.transaction.Synchronization; -import javax.transaction.Transaction; -import javax.transaction.TransactionManager; - -/** - * Created by IntelliJ IDEA. - * User: bela - * Date: Jun 9, 2004 - * Time: 9:05:19 AM - */ -(a)Test(groups =3D {"functional", "transaction"}) -public class PrepareTxTest -{ - CacheSPI cache; - - @BeforeMethod(alwaysRun =3D true) - public void setUp() throws Exception - { - CacheFactory instance =3D new DefaultCacheFactory(); - cache =3D (CacheSPI) instance.createCache(false); - cache.getConfiguration().setCacheMode("local"); - cache.getConfiguration().setTransactionManagerLookupClass(Transactio= nSetup.getManagerLookup()); - cache.create(); - cache.start(); - } - - @AfterMethod(alwaysRun =3D true) - public void tearDown() throws Exception - { - cache.stop(); - cache.destroy(); - } - - /** - * Tests cache modification inside the afterCompletion() callb= ack. Reproduces a bug fixed in - * connection with JBossCache being used as Hibernate's second level ca= che - * - * @throws Exception - * @throws NotSupportedException - */ - public void testCacheModificationInBeforeCompletionPhase() throws Excep= tion - { - int numLocks =3D 0; - TransactionManager mgr =3D cache.getTransactionManager(); - mgr.begin(); - Transaction tx =3D mgr.getTransaction(); - - // this will cause the cache to register with TransactionManager for= TX completion callbacks - cache.put("/one/two/three", "key1", "val1"); - numLocks =3D cache.getNumberOfLocksHeld(); - assertEquals(4, numLocks); - - // we register *second* - tx.registerSynchronization(new Synchronization() - { - - public void beforeCompletion() - { - try - { - cache.put("/a/b/c", null); - } - catch (CacheException e) - { - e.printStackTrace(); - } - } - - public void afterCompletion(int status) - { - } - }); - - mgr.commit(); - numLocks =3D cache.getNumberOfLocksHeld(); - assertEquals(0, numLocks); - - int num_local_txs, num_global_txs; - TransactionTable tx_table =3D cache.getTransactionTable(); - num_local_txs =3D tx_table.getNumLocalTransactions(); - num_global_txs =3D tx_table.getNumGlobalTransactions(); - System.out.println("Number of Transactions: " + num_local_txs + "\nN= umber of GlobalTransactions: " + num_global_txs + "\nTransactionTable:\n " - + tx_table.toString(true)); - assertEquals(num_local_txs, num_global_txs); - assertEquals(0, num_local_txs); - } - - /** - * Tests cache modification inside the afterCompletion() callb= ack. Reproduces a bug fixed in - * connection with JBossCache being used as Hibernate's second level ca= che - * - * @throws Exception - * @throws NotSupportedException - */ - public void testCacheModificationInAfterCompletionPhase() throws Except= ion - { - int numLocks =3D 0; - TransactionManager mgr =3D cache.getTransactionManager(); - mgr.begin(); - Transaction tx =3D mgr.getTransaction(); - - // this will cause the cache to register with TransactionManager for= TX completion callbacks - cache.put("/one/two/three", "key1", "val1"); - numLocks =3D cache.getNumberOfLocksHeld(); - assertEquals(4, numLocks); - - // we register *second* - tx.registerSynchronization(new Synchronization() - { - - public void beforeCompletion() - { - } - - public void afterCompletion(int status) - { - try - { - cache.put("/a/b/c", null); - } - catch (CacheException e) - { - e.printStackTrace(); - } - } - }); - - mgr.commit(); - numLocks =3D cache.getNumberOfLocksHeld(); - assertEquals(0, numLocks); - - int num_local_txs, num_global_txs; - TransactionTable tx_table =3D cache.getTransactionTable(); - num_local_txs =3D tx_table.getNumLocalTransactions(); - num_global_txs =3D tx_table.getNumGlobalTransactions(); - System.out.println("Number of Transactions: " + num_local_txs + "\nN= umber of GlobalTransactions: " + num_global_txs + "\nTransactionTable:\n " - + tx_table.toString(true)); - assertEquals(num_local_txs, num_global_txs); - assertEquals(0, num_local_txs); - } - -} Deleted: core/trunk/src/test/java/org/jboss/cache/transaction/StatusUnknown= Test.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/transaction/StatusUnknownTest.= java 2008-08-23 12:40:58 UTC (rev 6610) +++ core/trunk/src/test/java/org/jboss/cache/transaction/StatusUnknownTest.= java 2008-08-25 17:50:21 UTC (rev 6611) @@ -1,162 +0,0 @@ -package org.jboss.cache.transaction; - -import org.jboss.cache.Cache; -import org.jboss.cache.CacheSPI; -import org.jboss.cache.DefaultCacheFactory; -import org.jboss.cache.Fqn; -import static org.testng.AssertJUnit.*; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import javax.transaction.NotSupportedException; -import javax.transaction.RollbackException; -import javax.transaction.Status; -import javax.transaction.Synchronization; -import javax.transaction.SystemException; -import javax.transaction.Transaction; -import javax.transaction.TransactionManager; -import java.util.LinkedList; -import java.util.List; -import java.util.Properties; - -/** - * This test checks how the cache behaves when a JTA STATUS_UNKNOWN is pas= sed in to the cache during afterCompletion(). - * - * @author Manik Surtani - */ -(a)Test(groups =3D "functional") -public class StatusUnknownTest -{ - private Cache cache; - private TransactionManager tm; - - @BeforeMethod(alwaysRun =3D true) - public void setUp() throws Exception - { - cache =3D new DefaultCacheFactory().createCache(fals= e); - cache.getConfiguration().setTransactionManagerLookupClass(HeuristicF= ailingDummyTransactionManagerLookup.class.getName()); - cache.start(); - tm =3D cache.getConfiguration().getRuntimeConfig().getTransactionMan= ager(); - } - - @AfterMethod(alwaysRun =3D true) - public void tearDown() - { - cache.stop(); - } - - public void testStatusUnknown() throws Exception - { - tm.begin(); - Fqn fqn =3D Fqn.fromString("/a/b/c"); - - cache.put(fqn, "k", "v"); - assertEquals(4, ((CacheSPI) cache).getNumberOfLocksHeld()); - assertTrue(cache.getRoot().hasChild(fqn)); - tm.commit(); - - assertEquals(0, ((CacheSPI) cache).getNumberOfLocksHeld()); - assertFalse(cache.getRoot().hasChild(fqn)); - } - - public static class HeuristicFailingDummyTransactionManager extends Dum= myTransactionManager - { - private static final long serialVersionUID =3D 6325631394461739211L; - - @Override - public void begin() throws SystemException, NotSupportedException - { - super.begin(); - - Transaction tx =3D new HeuristicFailingDummyTransaction(this); - setTransaction(tx); - } - - public static DummyTransactionManager getInstance() - { - if (instance =3D=3D null) - { - instance =3D new HeuristicFailingDummyTransactionManager(); - try - { - Properties p =3D new Properties(); - p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.cache.tra= nsaction.DummyContextFactory"); - Context ctx =3D new InitialContext(p); - ctx.bind("java:/TransactionManager", instance); - ctx.bind("UserTransaction", new DummyUserTransaction(instan= ce)); - } - catch (NamingException e) - { - log.error("binding of DummyTransactionManager failed", e); - } - } - return instance; - } - } - - public static class HeuristicFailingDummyTransaction extends DummyTrans= action - { - public HeuristicFailingDummyTransaction(DummyBaseTransactionManager = mgr) - { - super(mgr); - } - - @Override - public void commit() throws RollbackException - { - try - { - notifyBeforeCompletion(); - notifyAfterCompletion(Status.STATUS_UNKNOWN); - } - finally - { - // Disassociate tx from thread. - tm_.setTransaction(null); - } - } - - @Override - protected void notifyAfterCompletion(int status) - { - List tmp; - - synchronized (participants) - { - tmp =3D new LinkedList(participants); - } - - for (Synchronization s : tmp) - { - try - { - s.afterCompletion(status); - } - catch (Throwable t) - { - throw (RuntimeException) t; - } - } - - synchronized (participants) - { - participants.clear(); - } - } - } - - public static class HeuristicFailingDummyTransactionManagerLookup imple= ments TransactionManagerLookup - { - - public TransactionManager getTransactionManager() throws Exception - { - return HeuristicFailingDummyTransactionManager.getInstance(); - } - } -} - - Deleted: core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTe= st.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTest.ja= va 2008-08-23 12:40:58 UTC (rev 6610) +++ core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTest.ja= va 2008-08-25 17:50:21 UTC (rev 6611) @@ -1,1068 +0,0 @@ -/* - * - * JBoss, the OpenSource J2EE webOS - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ - -package org.jboss.cache.transaction; - -import org.jboss.cache.CacheException; -import org.jboss.cache.CacheFactory; -import org.jboss.cache.CacheSPI; -import org.jboss.cache.DefaultCacheFactory; -import org.jboss.cache.Fqn; -import org.jboss.cache.Node; -import org.jboss.cache.NodeSPI; -import org.jboss.cache.lock.IsolationLevel; -import org.jboss.cache.lock.LockManager; -import static org.jboss.cache.lock.LockType.READ; -import static org.jboss.cache.lock.LockType.WRITE; -import org.jboss.cache.util.CachePrinter; -import org.jboss.cache.util.TestingUtil; -import static org.testng.AssertJUnit.*; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import javax.transaction.HeuristicMixedException; -import javax.transaction.HeuristicRollbackException; -import javax.transaction.NotSupportedException; -import javax.transaction.RollbackException; -import javax.transaction.SystemException; -import javax.transaction.Transaction; -import javax.transaction.TransactionManager; -import javax.transaction.UserTransaction; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -/** - * Tests transactional access to a local CacheImpl. - * Note: we use DummpyTranasctionManager to replace jta - * - * @version $Id$ - */ -(a)Test(groups =3D {"functional", "transaction"}) -public class TransactionTest -{ - CacheSPI cache =3D null; - UserTransaction tx =3D null; - Exception exception; - LockManager lockManager; - - @BeforeMethod(alwaysRun =3D true) - public void setUp() throws Exception - { - - CacheFactory instance =3D new DefaultCacheFactor= y(); - cache =3D (CacheSPI) instance.createCache(false); - cache.getConfiguration().setClusterName("test"); - cache.getConfiguration().setStateRetrievalTimeout(10000); - cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZAB= LE); - cache.getConfiguration().setLockParentForChildInsertRemove(true);// = this test case is written to assume this. - cache.getConfiguration().setTransactionManagerLookupClass(Transactio= nSetup.getManagerLookup()); - tx =3D TransactionSetup.getUserTransaction(); - - cache.create(); - cache.start(); - exception =3D null; - lockManager =3D TestingUtil.extractLockManager(cache); - } - - @AfterMethod(alwaysRun =3D true) - public void tearDown() throws Exception - { - if (cache !=3D null) - { - cache.stop(); - cache =3D null; - } - - // BW. kind of a hack to destroy jndi binding and thread local tx be= fore next run. - TransactionSetup.cleanup(); - - if (tx !=3D null) - { - try - { - tx.rollback(); - } - catch (Throwable t) - { - // do nothing - } - tx =3D null; - } - } - - public void testPutTx() throws Exception - { - tx.begin(); - cache.put("/a/b/c", "age", 38); - // the tx interceptor should know that we're in the same tx. - assertEquals(cache.get("/a/b/c", "age"), 38); - - cache.put("/a/b/c", "age", 39); - tx.commit(); - - // This test is done outside the TX, it wouldn't work if someone else - // modified "age". This works because we're the only TX running. - assertEquals(cache.get("/a/b/c", "age"), 39); - } - - public void testRollbackTx1() - { - try - { - tx.begin(); - cache.put("/a/b/c", "age", 38); - cache.put("/a/b/c", "age", 39); - tx.rollback(); - - // This test is done outside the TX, it wouldn't work if someone = else - // modified "age". This works because we're the only TX running. - assertNull(cache.get("/a/b/c", "age")); - } - catch (Throwable t) - { - t.printStackTrace(); - fail(t.toString()); - } - } - - public void testGetAfterRemovalRollback() throws Exception - { - assertEquals(0, cache.getNumberOfLocksHeld()); - cache.put("/a/b", null); - assertEquals(0, cache.getNumberOfLocksHeld()); - assertTrue(cache.exists("/a/b")); - tx.begin(); - cache.removeNode("/a/b"); - assertFalse(cache.exists("/a/b")); - tx.rollback(); - assertTrue(cache.exists("/a/b")); - assertEquals(0, cache.getNumberOfLocksHeld()); - // new tx in new thread - Thread th =3D new Thread() - { - public void run() - { - try - { - cache.getTransactionManager().begin(); - assertNotNull(cache.getNode("/a/b")); - cache.getTransactionManager().rollback(); - } - catch (Exception e) - { - e.printStackTrace(); - fail("Caught exception"); - } - } - }; - - th.start(); - th.join(); - - assertEquals(0, cache.getNumberOfLocksHeld()); - } - - public void testRollbackTx2() - { - try - { - tx.begin(); - cache.put("/a/b/c", "age", 38); - cache.remove("/a/b/c", "age"); - tx.rollback(); - - // This test is done outside the TX, it wouldn't work if someone = else - // modified "age". This works because we're the only TX running. - assertNull(cache.get("/a/b/c", "age")); - } - catch (Throwable t) - { - t.printStackTrace(); - fail(t.toString()); - } - } - - public void testRollbackTx2a() - { - try - { - cache.put("/a/b/c", "age", 38); - tx.begin(); - cache.remove("/a/b/c", "age"); - tx.rollback(); - - // This test is done outside the TX, it wouldn't work if someone = else - // modified "age". This works because we're the only TX running. - assertEquals(38, cache.get("/a/b/c", "age")); - } - catch (Throwable t) - { - t.printStackTrace(); - fail(t.toString()); - } - } - - public void testRollbackTx3() - { - try - { - java.util.Map map1 =3D new java.util.HashMap<= String, Comparable>(); - map1.put("age", 38); - java.util.Map map2 =3D new java.util.HashMap<= String, Comparable>(); - map2.put("age", 39); - tx.begin(); - cache.put("/a/b/c", map1); - cache.put("/a/b/c", map2); - tx.rollback(); - - // This test is done outside the TX, it wouldn't work if someone = else - // modified "age". This works because we're the only TX running. - assertNull(cache.get("/a/b/c", "age")); - } - catch (Throwable t) - { - t.printStackTrace(); - fail(t.toString()); - } - } - - public void testRollbackTx4() - { - try - { - Map map =3D new HashMap(); - map.put("age", 38); - tx.begin(); - cache.put("/a/b/c", map); - cache.removeNode("/a/b/c"); - tx.rollback(); - - // This test is done outside the TX, it wouldn't work if someone = else - // modified "age". This works because we're the only TX running. - assertNull(cache.get("/a/b/c", "age")); - } - catch (Throwable t) - { - t.printStackTrace(); - fail(t.toString()); - } - } - - public void testNodeCreationRollback() - { - try - { - tx.begin(); - System.out.println("initial state:\n" + cache); - cache.put("/bela/ban", "key", "value"); - System.out.println("after put():\n" + cache); - tx.rollback(); - System.out.println("after rollback():\n" + cache); - - assertNull("node should be not existent", cache.getNode("/bela/ba= n")); - } - catch (Throwable t) - { - t.printStackTrace(); - fail(t.toString()); - } - } - - public void testNodeCreationRollback2() - { - try - { - cache.put("/bela/ban", null); - tx.begin(); - cache.put("/bela/ban/michelle", null); - tx.rollback(); - assertNotNull("node should be not null", cache.getNode("/bela/ban= ")); - assertNull("node should be not existent", cache.getNode("/bela/ba= n/michelle")); - } - catch (Throwable t) - { - t.printStackTrace(); - fail(t.toString()); - } - } - - public void testNodeDeletionRollback() - { - try - { - cache.put("/a/b/c", null); - tx.begin(); - cache.removeNode("/a/b/c"); - assertNull(cache.getNode("/a/b/c")); - cache.removeNode("/a/b"); - assertNull(cache.getNode("/a/b")); - cache.removeNode("/a"); - assertNull(cache.getNode("/a")); - tx.rollback(); - assertNotNull(cache.getNode("/a/b/c")); - assertNotNull(cache.getNode("/a/b")); - assertNotNull(cache.getNode("/a")); - } - catch (Throwable t) - { - t.printStackTrace(); - fail(t.toString()); - } - } - - public void testNodeDeletionRollback2() throws Exception - { - cache.put("/a/b/c", null); - cache.put("/a/b/c1", null); - cache.put("/a/b/c2", null); - tx.begin(); - cache.removeNode("/a"); - assertNull(cache.getNode("/a/b/c")); - assertNull(cache.getNode("/a/b/c1")); - assertNull(cache.getNode("/a/b/c2")); - assertNull(cache.getNode("/a/b")); - assertNull(cache.getNode("/a")); - Set children =3D cache.getChildrenNames(Fqn.fromString("/a/b")); - assertTrue(children.isEmpty()); - children =3D cache.getChildrenNames("/a"); - assertTrue(children.isEmpty()); - tx.rollback(); - assertNotNull(cache.getNode("/a")); - assertNotNull(cache.getNode("/a/b")); - assertNotNull(cache.getNode("/a/b/c")); - assertNotNull(cache.getNode("/a/b/c1")); - assertNotNull(cache.getNode("/a/b/c2")); - children =3D cache.getChildrenNames(Fqn.fromString("/a/b")); - assertEquals(3, children.size()); - } - - public void testNodeCreation() throws Exception - { - GlobalTransaction gtx; - cache.put("/a/b", null); - tx.begin(); - gtx =3D cache.getCurrentTransaction(); - cache.put("/a/b/c", null); - assertLocked(gtx, "/a", false); - assertLocked(gtx, "/a/b", true); - assertLocked(gtx, "/a/b/c", true); - } - - public void testNodeCreation2() throws Exception - { - GlobalTransaction gtx; - tx.begin(); - gtx =3D cache.getCurrentTransaction(); - cache.put("/a/b/c", null); - assertLocked(gtx, "/a", true); - assertLocked(gtx, "/a/b", true); - assertLocked(gtx, "/a/b/c", true); - } - - public void testNodeRemoval() throws SystemException, NotSupportedExcep= tion - { - GlobalTransaction gtx; - cache.put("/a/b/c", null); - tx.begin(); - gtx =3D cache.getCurrentTransaction(); - cache.removeNode("/a/b/c");// need to remove the node, not just the = data in the node. - assertLocked(gtx, "/a", false); - assertLocked(gtx, "/a/b", true); - assertLocked(gtx, "/a/b/c", true); - tx.rollback(); - } - - public void testNodeRemoval2() throws SystemException, NotSupportedExce= ption - { - GlobalTransaction gtx; - cache.put("/a/b/c", null); - tx.begin(); - gtx =3D cache.getCurrentTransaction(); - cache.removeNode("/a/b");// need to remove the node, not just the da= ta in the node. - assertLocked(gtx, "/a", true); - assertLocked(gtx, "/a/b", true); - assertLocked(gtx, "/a/b/c", true); - tx.rollback(); - } - - public void testIntermediateNodeCreationOnWrite() throws Exception - { - cache.put("/a", null); - tx.begin(); - cache.put("/a/b/c", null); - // expecting WLs on /a, /a/b and /a/b/c. - GlobalTransaction gtx =3D cache.getCurrentTransaction(); - assertLocked(gtx, "/a", true); - assertLocked(gtx, "/a/b", true); - assertLocked(gtx, "/a/b/c", true); - tx.rollback(); - } - - public void testIntermediateNodeCreationOnRead() throws Exception - { - cache.put("/a", null); - tx.begin(); - cache.getNode("/a/b/c"); - - // expecting RLs on /, /a - // /a/b, /a/b/c should NOT be created! - GlobalTransaction gtx =3D cache.getCurrentTransaction(); - assertLocked(gtx, "/", false); - assertLocked(gtx, "/a", false); - assertNull("/a/b should not exist", cache.peek(Fqn.fromString("/a/b"= ), true)); - assertNull("/a/b/c should not exist", cache.peek(Fqn.fromString("/a/= b/c"), true)); - tx.rollback(); - assertNull("/a/b should not exist", cache.peek(Fqn.fromString("/a/b"= ), true)); - assertNull("/a/b/c should not exist", cache.peek(Fqn.fromString("/a/= b/c"), true)); - - } - - public void testIntermediateNodeCreationOnRemove() throws Exception - { - cache.put("/a", null); - tx.begin(); - cache.removeNode("/a/b/c"); - - // expecting RLs on /, /a - // /a/b, /a/b/c should NOT be created! - GlobalTransaction gtx =3D cache.getCurrentTransaction(); - assertLocked(gtx, "/", false); - assertLocked(gtx, "/a", true); - assertLocked(gtx, "/a/b", true); - assertLocked(gtx, "/a/b/c", true); - assertNotNull("/a/b should exist", cache.peek(Fqn.fromString("/a/b")= , true)); - assertNotNull("/a/b/c should exist", cache.peek(Fqn.fromString("/a/b= /c"), true)); - assertNotNull("/a/b should NOT be visible", cache.exists(Fqn.fromStr= ing("/a/b"))); - assertNotNull("/a/b/c should NOT be visible", cache.exists(Fqn.fromS= tring("/a/b/c"))); - tx.rollback(); - assertNull("/a/b should not exist", cache.peek(Fqn.fromString("/a/b"= ), true)); - assertNull("/a/b/c should not exist", cache.peek(Fqn.fromString("/a/= b/c"), true)); - - } - - public void testNodeDeletionRollback3() throws Exception - { - GlobalTransaction gtx; - cache.put("/a/b/c1", null); - - tx.begin(); - gtx =3D cache.getCurrentTransaction(); - cache.put("/a/b/c1", null); - assertLocked(gtx, "/a", false); - assertLocked(gtx, "/a/b", false); - assertLocked(gtx, "/a/b/c1", true); - - cache.put("/a/b/c2", null); - assertLocked(gtx, "/a/b", true); - assertLocked(gtx, "/a/b/c2", true); - - cache.put("/a/b/c3", null); - cache.put("/a/b/c1/one", null); - assertLocked(gtx, "/a/b/c1", true); - assertLocked(gtx, "/a/b/c1/one", true); - - cache.put("/a/b/c1/two", null); - cache.put("/a/b/c1/one/1", null); - assertLocked(gtx, "/a/b/c1", true); - assertLocked(gtx, "/a/b/c1/one", true); - assertLocked(gtx, "/a/b/c1/one/1", true); - - cache.put("/a/b/c1/two/2/3/4", null); - assertLocked(gtx, "/a/b/c1", true); - assertLocked(gtx, "/a/b/c1/two", true); - assertLocked(gtx, "/a/b/c1/two/2", true); - assertLocked(gtx, "/a/b/c1/two/2/3", true); - assertLocked(gtx, "/a/b/c1/two/2/3/4", true); - - cache.removeNode("/a/b"); - tx.rollback(); - assertTrue(cache.getChildrenNames("/a/b/c1").isEmpty()); - Set cn =3D cache.getChildrenNames(Fqn.fromString("/a/b")); - assertEquals(1, cn.size()); - assertEquals("c1", cn.iterator().next()); - } - - public void testDoubleLocks() throws Exception - { - tx.begin(); - GlobalTransaction gtx =3D cache.getCurrentTransaction(); - cache.put("/a/b/c", null); - cache.put("/a/b/c", null); - - NodeSPI n =3D cache.getNode("/a"); - assert !lockManager.isLocked(n, READ); - // make sure this is write locked. - assertLocked(gtx, "/a", true); - - n =3D cache.getNode("/a/b"); - assert !lockManager.isLocked(n, READ); - // make sure this is write locked. - assertLocked(gtx, "/a/b", true); - - n =3D cache.getNode("/a/b/c"); - assert !lockManager.isLocked(n, READ); - // make sure this is write locked. - assertLocked(gtx, "/a/b/c", true); - - tx.rollback(); - assertEquals(0, cache.getNumberOfLocksHeld()); - } - - private void assertLocked(Object owner, String fqn, boolean writeLocked) - { - NodeSPI n =3D cache.peek(Fqn.fromString(fqn), tr= ue); - if (owner =3D=3D null) owner =3D Thread.currentThread(); - assertTrue("node " + fqn + " is not locked", lockManager.isLocked(n)= ); - if (writeLocked) - { - assertTrue("node " + fqn + " is not write-locked by owner " + own= er + ". Lock details: " + lockManager.printLockInfo(n), lockManager.ownsLoc= k(Fqn.fromString(fqn), WRITE, owner)); - } - else - { - assertTrue("node " + fqn + " is not read-locked by owner " + owne= r + ". Lock details: " + lockManager.printLockInfo(n), lockManager.ownsLock= (Fqn.fromString(fqn), READ, owner)); - } - } - - public void testConcurrentNodeAccessOnRemovalWithTx() throws Exception - { - cache.put("/a/b/c", null); - tx.begin(); - cache.removeNode("/a/b/c"); - // this node should now be locked. - TransactionManager tm =3D cache.getConfiguration().getRuntimeConfig(= ).getTransactionManager(); - Transaction t =3D tm.suspend(); - // start a new tx - tm.begin(); - try - { - cache.getNode("/a/b/c");// should fail - fail("Should not be able to get a hold of /a/b/c until the deleti= ng tx completes"); - } - catch (Exception e) - { - // expected - //cache.getTransactionManager().commit(); - tm.commit(); - } - - tm.resume(t); - tx.rollback(); - - assertNotNull(cache.getNode("/a/b/c")); - assertEquals(0, cache.getNumberOfLocksHeld()); - } - - public void testConcurrentNodeAccessOnRemovalWithoutTx() throws Excepti= on - { - cache.put("/a/b/c", null); - tx.begin(); - cache.removeNode("/a/b/c"); - // this node should now be locked. - Transaction t =3D cache.getTransactionManager().suspend(); - Thread th =3D new Thread() - { - public void run() - { - try - { - cache.getNode("/a/b/c");// should fail - - fail("Should not be able to get a hold of /a/b/c until the = deleting tx completes"); - } - catch (Exception e) - { - // expected - } - } - }; - - th.start(); - th.join(); - - cache.getTransactionManager().resume(t); - tx.rollback(); - - assertNotNull(cache.getNode("/a/b/c")); - assertEquals(0, cache.getNumberOfLocksHeld()); - } - - public void testRemove() throws CacheException, SystemException, NotSup= portedException, HeuristicMixedException, HeuristicRollbackException, Rollb= ackException - { - cache.put("/a/b/c", null); - cache.put("/a/b/c/1", null); - cache.put("/a/b/c/2", null); - cache.put("/a/b/c/3", null); - cache.put("/a/b/c/3/a/b/c", null); - - assertEquals(0, cache.getNumberOfLocksHeld()); - - tx.begin(); - cache.removeNode("/a/b/c"); - // this used to test for 2 locks held. After the fixes for JBCACHE-= 875 however, 2 more locks are acquired - for the root node as well as the d= eleted node. - // and since we would lock all children of the deleted node as well,= we have 10 locks here. - assertEquals(10, cache.getNumberOfLocksHeld()); - tx.commit(); - assertEquals(0, cache.getNumberOfLocksHeld()); - } - - public void testRemoveAndRollback() throws CacheException, SystemExcept= ion, NotSupportedException, HeuristicMixedException, HeuristicRollbackExcep= tion, - RollbackException - { - cache.put("/a/b/c", null); - cache.put("/a/b/c/1", null); - cache.put("/a/b/c/2", null); - cache.put("/a/b/c/3", null); - cache.put("/a/b/c/3/a/b/c", null); - - assertEquals(0, cache.getNumberOfLocksHeld()); - - tx.begin(); - cache.removeNode("/a/b/c"); - assertEquals(10, cache.getNumberOfLocksHeld()); - tx.rollback(); - assertEquals(0, cache.getNumberOfLocksHeld()); - - assertTrue(cache.exists("/a/b/c")); - assertTrue(cache.exists("/a/b/c/1")); - assertTrue(cache.exists("/a/b/c/2")); - assertTrue(cache.exists("/a/b/c/3")); - assertTrue(cache.exists("/a/b/c/3/a")); - assertTrue(cache.exists("/a/b/c/3/a/b")); - assertTrue(cache.exists("/a/b/c/3/a/b/c")); - } - - public void testRemoveKeyRollback() throws CacheException, SystemExcept= ion, NotSupportedException - { - cache.put("/bela/ban", "name", "Bela"); - tx.begin(); - cache.remove("/bela/ban", "name"); - assertNull(cache.get("/bela/ban", "name")); - tx.rollback(); - assertEquals("Bela", cache.get("/bela/ban", "name")); - } - - public void testRemoveKeyRollback2() - { - try - { - Map m =3D new HashMap(); - m.put("name", "Bela"); - m.put("id", 322649); - cache.put("/bela/ban", m); - tx.begin(); - cache.remove("/bela/ban", "name"); - assertNull(cache.get("/bela/ban", "name")); - tx.rollback(); - assertEquals("Bela", cache.get("/bela/ban", "name")); - } - catch (Throwable t) - { - t.printStackTrace(); - fail(t.toString()); - } - } - - public void testRemoveKeyRollback3() - { - try - { - cache.put("/bela/ban", "name", "Bela"); - tx.begin(); - cache.put("/bela/ban", "name", "Michelle"); - cache.remove("/bela/ban", "name"); - assertNull(cache.get("/bela/ban", "name")); - tx.rollback(); - assertEquals("Bela", cache.get("/bela/ban", "name")); - } - catch (Throwable t) - { - t.printStackTrace(); - fail(t.toString()); - } - } - - public void testDoubleRemovalOfSameData() throws Exception - { - tx.begin(); - cache.put("/foo/1", "item", 1); - assertEquals(cache.get("/foo/1", "item"), 1); - cache.removeNode("/foo/1"); - assertNull(cache.get("/foo/1", "item")); - cache.removeNode("/foo/1"); - assertNull(cache.get("/foo/1", "item")); - tx.rollback(); - assertFalse(cache.exists("/foo/1")); - assertNull(cache.get("/foo/1", "item")); - } - - /** - * put(Fqn, Map) with a previous null map - */ - public void testPutDataRollback1() - { - try - { - cache.put("/bela/ban", null);// create a node /bela/ban with a nu= ll map - tx.begin(); - Map m =3D new HashMap(); - m.put("name", "Bela"); - m.put("id", 322649); - cache.put("/bela/ban", m); - tx.rollback(); - - Node n =3D cache.getNode("/bela/ban"); - if (n.getData() =3D=3D null) - return; - assertEquals("map should be empty", 0, n.getData().size()); - } - catch (Throwable t) - { - t.printStackTrace(); - fail(t.toString()); - } - } - - /** - * put(Fqn, Map) with a previous non-null map - */ - public void testputDataRollback2() throws Exception - { - Map m1, m2; - m1 =3D new HashMap(); - m1.put("name", "Bela"); - m1.put("id", 322649); - m2 =3D new HashMap(); - m2.put("other", "bla"); - m2.put("name", "Michelle"); - - cache.put("/bela/ban", m1); - tx.begin(); - - cache.put("/bela/ban", m2); - Map tmp =3D cache.getNode("/bela/ban").getData(); - assertEquals(3, tmp.size()); - assertEquals("Michelle", tmp.get("name")); - assertEquals(tmp.get("id"), 322649); - assertEquals("bla", tmp.get("other")); - tx.rollback(); - - tmp =3D cache.getNode("/bela/ban").getData(); - assertEquals(2, tmp.size()); - assertEquals("Bela", tmp.get("name")); - assertEquals(tmp.get("id"), 322649); - } - - public void testPutRollback() - { - try - { - cache.put("/bela/ban", null);// /bela/ban needs to exist - tx.begin(); - cache.put("/bela/ban", "name", "Bela"); - assertEquals("Bela", cache.get("/bela/ban", "name")); - tx.rollback(); - assertNull(cache.get("/bela/ban", "name")); - } - catch (Throwable t) - { - t.printStackTrace(); - fail(t.toString()); - } - } - - public void testPutRollback2() - { - try - { - cache.put("/bela/ban", "name", "Bela");// /bela/ban needs to exist - tx.begin(); - cache.put("/bela/ban", "name", "Michelle"); - assertEquals("Michelle", cache.get("/bela/ban", "name")); - tx.rollback(); - assertEquals("Bela", cache.get("/bela/ban", "name")); - } - catch (Throwable t) - { - t.printStackTrace(); - fail(t.toString()); - } - } - - public void testSimpleRollbackTransactions() throws Exception - { - final Fqn fqn =3D Fqn.fromString("/a/b/c"); - tx.begin(); - cache.put(fqn, "entry", "commit"); - tx.commit(); - - tx.begin(); - cache.put(fqn, "entry", "rollback"); - cache.removeNode(fqn); - tx.rollback(); - assertEquals("Node should keep the commited value", "commit", cache.= getNode(fqn).get("entry")); - - tx.begin(); - cache.removeNode(fqn); - cache.put(fqn, "entry", "rollback"); - tx.rollback(); - - System.out.println("Cache: " + CachePrinter.printCacheDetails(cache)= ); - - assertEquals("Node should keep the commited value", "commit", cache.= getNode(fqn).get("entry"));// THIS FAILS - } - - private TransactionManager startTransaction() throws Exception - { - TransactionManager mgr =3D cache.getConfiguration().getRuntimeConfig= ().getTransactionManager(); - mgr.begin(); - return mgr; - } - - public void testConcurrentReadAndWriteAccess() throws Exception - { - cache.stop(); - cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE= _READ); - cache.start(); - - cache.put("/1/2/3/4", "foo", "bar");// no TX, no locks held after pu= t() returns - - class Reader extends Thread - { - TransactionManager thread_tx; - - public Reader() - { - super("Reader"); - } - - public void run() - { - try - { - thread_tx =3D startTransaction(); - log("acquiring RL"); - cache.get("/1/2/3", "foo");// acquires RLs on all 3 nodes - log("RL acquired successfully"); - sleep(2000); - log("committing TX"); - thread_tx.commit();// releases RLs - log("committed TX"); - } - catch (Exception e) - { - exception =3D e; - } - } - } - - class Writer extends Thread - { - TransactionManager thread_tx; - - public Writer() - { - super("Writer"); - } - - public void run() - { - try - { - sleep(500);// give the Reader a chance to acquire the RLs - thread_tx =3D startTransaction(); - log("acquiring WL"); - cache.put("/1", "foo", "bar2");// needs to acquired a WL on= /1 - log("acquired WL successfully"); - log("committing TX"); - thread_tx.commit(); - log("committed TX"); - } - catch (Exception e) - { - exception =3D e; - } - } - } - - Reader reader =3D new Reader(); - Writer writer =3D new Writer(); - reader.start(); - writer.start(); - reader.join(); - writer.join(); - if (exception !=3D null) - { - throw exception; - } - } - - public void testRemoveAndGetInTx() throws Exception - { - Fqn A_B =3D Fqn.fromString("/a/b"); - Fqn A =3D Fqn.fromString("/a"); - - cache.put(A_B, "k", "v"); - - assertTrue(cache.exists(A_B)); - assertTrue(cache.exists(A)); - - cache.getTransactionManager().begin(); - cache.removeNode(A); - cache.get(A_B, "k"); - cache.getTransactionManager().commit(); - } - - public void testRemoveAndPutInTx() throws Exception - { - Fqn A_B =3D Fqn.fromString("/a/b"); - Fqn A =3D Fqn.fromString("/a"); - - cache.put(A_B, "k", "v"); - - assertTrue(cache.exists(A_B)); - assertTrue(cache.exists(A)); - - cache.getTransactionManager().begin(); - cache.removeNode(A_B); - cache.put(A_B, "k", "v2"); - cache.getTransactionManager().commit(); - - assertTrue(cache.exists(A_B)); - assertTrue(cache.exists(A)); - - assert cache.peek(A, true, true).isValid(); - assert cache.peek(A_B, true, true).isValid(); - - assertEquals("v2", cache.get(A_B, "k")); - } - - public void testRemoveParentAndPutInTx() throws Exception - { - Fqn A_B =3D Fqn.fromString("/a/b"); - Fqn A =3D Fqn.fromString("/a"); - - cache.put(A_B, "k", "v"); - - assertTrue(cache.exists(A_B)); - assertTrue(cache.exists(A)); - - cache.getTransactionManager().begin(); - cache.removeNode(A); - cache.put(A_B, "k", "v2"); - cache.getTransactionManager().commit(); - - assertTrue(cache.exists(A_B)); - assertTrue(cache.exists(A)); - - assertEquals("v2", cache.get(A_B, "k")); - } - - public void testRemoveGrandParentAndPutInTx() throws Exception - { - Fqn A_B_C =3D Fqn.fromString("/a/b/c"); - Fqn A =3D Fqn.fromString("/a"); - - cache.put(A_B_C, "k", "v"); - - assertTrue(cache.exists(A_B_C)); - assertTrue(cache.exists(A)); - - cache.getTransactionManager().begin(); - cache.removeNode(A); - cache.put(A_B_C, "k", "v2"); - cache.getTransactionManager().commit(); - - assertTrue(cache.exists(A_B_C)); - assertTrue(cache.exists(A)); - - assertEquals("v2", cache.get(A_B_C, "k")); - } - - public void testRootNodeRemoval() throws Exception - { - Fqn root =3D Fqn.ROOT; - Fqn fqn =3D Fqn.fromElements(1); - //put first time - tx.begin(); - this.cache.put(fqn, "k", "v"); - tx.commit(); - - //get works fine - tx.begin(); - assertEquals("v", this.cache.get(fqn, "k")); - tx.commit(); - - //remove all - tx.begin(); - this.cache.removeNode(root); - tx.commit(); - - //get returns null - ok - //put - endless loop - tx.begin(); - assertNull(this.cache.get(fqn, "k")); - this.cache.put(fqn, "k", "v"); - tx.commit(); - } - - public void testNodeAdditionAfterRemoval() throws Exception - { - Fqn fqn =3D Fqn.fromString("/1/2/3/4"); - //put first time - tx.begin(); - this.cache.put(fqn, "k", "v"); - tx.commit(); - - //get works fine - tx.begin(); - assertEquals("v", this.cache.get(fqn, "k")); - tx.commit(); - - //remove all - tx.begin(); - this.cache.removeNode(Fqn.ROOT); - tx.commit(); - - //get returns null - ok - //put - endless loop - tx.begin(); - assertNull(this.cache.get(fqn, "k")); - this.cache.put(fqn, "k", "v"); - tx.commit(); - } - - public void testRootNodeRemovalRollback() throws Exception - { - Fqn root =3D Fqn.ROOT; - Fqn fqn =3D Fqn.fromRelativeElements(root, 1); - //put first time - tx.begin(); - this.cache.put(fqn, "k", "v"); - tx.commit(); - - //get works fine - tx.begin(); - assertEquals("v", this.cache.get(fqn, "k")); - tx.commit(); - - //remove all - tx.begin(); - this.cache.removeNode(root); - tx.rollback(); - - assertEquals("v", this.cache.get(fqn, "k")); - } - - private static void log(String msg) - { - System.out.println(Thread.currentThread().getName() + ": " + msg); - } - -} Modified: core/trunk/src/test/java/org/jboss/cache/transaction/isolationlev= els/IsolationLevelTestBase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/transaction/isolationlevels/Is= olationLevelTestBase.java 2008-08-23 12:40:58 UTC (rev 6610) +++ core/trunk/src/test/java/org/jboss/cache/transaction/isolationlevels/Is= olationLevelTestBase.java 2008-08-25 17:50:21 UTC (rev 6611) @@ -4,6 +4,7 @@ import org.jboss.cache.CacheFactory; import org.jboss.cache.DefaultCacheFactory; import org.jboss.cache.Fqn; +import org.jboss.cache.config.Configuration; import org.jboss.cache.lock.IsolationLevel; import static org.jboss.cache.lock.IsolationLevel.*; import org.jboss.cache.transaction.TransactionSetup; @@ -40,7 +41,8 @@ { CacheFactory cf =3D new DefaultCacheFactory(); cache =3D cf.createCache(false); - cache.getConfiguration().setIsolationLevel(isolationLevel); + cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLock= ingScheme.PESSIMISTIC); + cache.getConfiguration().setIsolationLevel(isolationLevel); cache.getConfiguration().setTransactionManagerLookupClass(Transactio= nSetup.getManagerLookup()); // very short so the tests don't take ages cache.getConfiguration().setLockAcquisitionTimeout(250); Copied: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/Ab= ortionTest.java (from rev 6585, core/trunk/src/test/java/org/jboss/cache/tr= ansaction/AbortionTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/Aborti= onTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/Aborti= onTest.java 2008-08-25 17:50:21 UTC (rev 6611) @@ -0,0 +1,204 @@ +/* + * JBoss, Home of Professional Open Source + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.cache.transaction.pessimistic; + +import org.jboss.cache.CacheSPI; +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.interceptors.OrderedSynchronizationHandler; +import org.jboss.cache.transaction.NotifyingTransactionManager.Notificatio= n; +import org.jboss.cache.transaction.NotifyingTransactionManager; +import org.jboss.cache.transaction.DummyTransactionManager; +import org.jboss.cache.transaction.TransactionContext; +import org.jboss.cache.util.TestingUtil; +import org.jgroups.JChannel; +import static org.testng.AssertJUnit.*; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import javax.transaction.RollbackException; +import javax.transaction.Synchronization; +import javax.transaction.SystemException; +import javax.transaction.Transaction; +import javax.transaction.TransactionManager; + +/** + * @author Manik Surtani (manik(a)jbo= ss.org) + */ +(a)Test(groups =3D {"functional"}) +public class AbortionTest +{ + private CacheSPI cache1, cache2, cache3; + + @BeforeMethod(alwaysRun =3D true) + public void setUp() throws Exception + { + cache1 =3D initCache(false); + TestingUtil.sleepThread(1500); // to ensure cache1 is the coordinator + cache2 =3D initCache(false); + cache3 =3D initCache(true); + } + + @AfterMethod(alwaysRun =3D true) + public void tearDown() throws Exception + { + TestingUtil.killCaches(cache3, cache2, cache1); + } + + private CacheSPI initCache(boolean notifying) + { + CacheSPI c =3D (CacheSPI) new DefaultCacheFactory().= createCache(false); + c.getConfiguration().setCacheMode("REPL_SYNC"); + c.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingS= cheme.PESSIMISTIC); + c.getConfiguration().setClusterConfig(getJGroupsStack()); + c.getConfiguration().setFetchInMemoryState(false); + if (!notifying) + { + c.getConfiguration().setTransactionManagerLookupClass("org.jboss.= cache.transaction.DummyTransactionManagerLookup"); + } + else + { + c.getConfiguration().setTransactionManagerLookupClass("org.jboss.= cache.transaction.NotifyingTransactionManager"); + } + c.start(); + return c; + } + + // we need a 'special' stack that does not attempt redelivery since we = kill a channel midway during a tx in this test. + private String getJGroupsStack() + { + return JChannel.DEFAULT_PROTOCOL_STACK; + } + + private void destroyCache(CacheSPI c) + { + if (c !=3D null) + { + c.stop(); + c.destroy(); + } + } + + public void testSyncCaches() throws Exception + { + performTest(false, false); + } + + public void testSyncCachesSyncCommitRollback() throws Exception + { + performTest(true, false); + } + + /** + * Note that this tests a *remote* beforeCompletion abort - which is a = part of the calling instance's afterCompletion. + * + * @throws Exception + */ + public void testAbortBeforeCompletion() throws Exception + { + performTest(true, true); + } + + private void performTest(boolean syncCommitRollback, boolean abortBefor= eCompletion) throws Exception + { + cache1.getConfiguration().setSyncCommitPhase(syncCommitRollback); + cache1.getConfiguration().setSyncRollbackPhase(syncCommitRollback); + cache2.getConfiguration().setSyncCommitPhase(syncCommitRollback); + cache2.getConfiguration().setSyncRollbackPhase(syncCommitRollback); + cache3.getConfiguration().setSyncCommitPhase(syncCommitRollback); + cache3.getConfiguration().setSyncRollbackPhase(syncCommitRollback); + + TransactionManager mgr1 =3D cache1.getTransactionManager(); + TransactionManager mgr2 =3D cache2.getTransactionManager(); + assertTrue(cache3.getTransactionManager() instanceof NotifyingTransa= ctionManager); + NotifyingTransactionManager mgr3 =3D (NotifyingTransactionManager) c= ache3.getTransactionManager(); + mgr3.setCache(cache3); + + assertSame(mgr1, mgr2); + assertNotSame(mgr1, mgr3); + assertNotSame(mgr2, mgr3); + + assertTrue(mgr1 instanceof DummyTransactionManager); + assertTrue(mgr2 instanceof DummyTransactionManager); + + cache1.put("/test", "key", "value"); + + assertEquals("value", cache1.get("/test", "key")); + assertEquals("value", cache2.get("/test", "key")); + assertEquals("value", cache3.get("/test", "key")); + + mgr3.setNotification(new TestNotification(abortBeforeCompletion)); + + mgr1.begin(); + cache1.put("/test", "key", "value2"); + mgr1.commit(); + + TestingUtil.sleepThread(5000); + + // only test cache1 and cache2. Assume cache3 has crashed out. + assertEquals(0, cache1.getNumberOfLocksHeld()); + assertEquals(0, cache2.getNumberOfLocksHeld()); + assertEquals("put in transaction should NOT have been rolled back", = "value2", cache1.get("/test", "key")); + assertEquals("put in transaction should NOT have been rolled back", = "value2", cache2.get("/test", "key")); + + } + + class TestNotification implements Notification + { + boolean abortBeforeCompletion; + + public TestNotification(boolean abortBeforeCompletion) + { + this.abortBeforeCompletion =3D abortBeforeCompletion; + } + + public void notify(Transaction tx, TransactionContext transactionCon= text) throws SystemException, RollbackException + { + OrderedSynchronizationHandler osh =3D transactionContext.getOrder= edSynchronizationHandler(); + + final Transaction finalTx =3D tx; + System.out.println("Notify called."); + // add an aborting sync handler. + Synchronization abort =3D new Synchronization() + { + + public void beforeCompletion() + { + if (abortBeforeCompletion) + { + cache3.getConfiguration().getRuntimeConfig().getChannel(= ).close(); + System.out.println("Returning from abort.beforeCompletio= n"); + try + { + finalTx.setRollbackOnly(); + } + catch (SystemException e) + { + throw new RuntimeException("Unable to set rollback", = e); + } + throw new RuntimeException("Dummy exception"); + } + } + + public void afterCompletion(int i) + { + if (!abortBeforeCompletion) + { + cache3.getConfiguration().getRuntimeConfig().getChannel(= ).close(); + System.out.println("Returning from abort.afterCompletion= "); + throw new RuntimeException("Dummy exception"); + } + } + }; + + osh.registerAtHead(abort); + System.out.println("Added sync handler."); + } + + } +} Property changes on: core/trunk/src/test/java/org/jboss/cache/transaction/p= essimistic/AbortionTest.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Copied: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/As= yncRollbackTxTest.java (from rev 6585, core/trunk/src/test/java/org/jboss/c= ache/transaction/AsyncRollbackTxTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AsyncR= ollbackTxTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AsyncR= ollbackTxTest.java 2008-08-25 17:50:21 UTC (rev 6611) @@ -0,0 +1,240 @@ +package org.jboss.cache.transaction.pessimistic; + +import org.jboss.cache.CacheFactory; +import org.jboss.cache.CacheSPI; +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.Fqn; +import org.jboss.cache.config.Configuration; +import static org.testng.AssertJUnit.*; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import javax.transaction.SystemException; +import javax.transaction.TransactionManager; + +/** + * Test behaviour of async rollback timeouted transaction + * + * @author Jacek Halat + * @since 1.4.0 + */ +(a)Test(groups =3D {"functional"}) +public class AsyncRollbackTxTest +{ + private CacheSPI cache; + private TransactionManager tm; + private Fqn fqn =3D Fqn.fromString("/test"); + // This sleep time (millis) should be longer than the transaction timeo= ut time. + private long sleepTime =3D 2500; + // seconds + private int txTimeout =3D 2; + + @BeforeMethod(alwaysRun =3D true) + public void setUp() throws Exception + { + Configuration c =3D new Configuration(); + c.setTransactionManagerLookupClass("org.jboss.cache.transaction.Asyn= cRollbackTransactionManagerLookup"); + CacheFactory instance =3D new DefaultCacheFactory(); + cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLock= ingScheme.PESSIMISTIC); + cache =3D (CacheSPI) instance.createCache(c); + tm =3D cache.getConfiguration().getRuntimeConfig().getTransactionMan= ager(); + tm.setTransactionTimeout(txTimeout); + } + + @AfterMethod(alwaysRun =3D true) + public void tearDown() + { + try + { + if (tm !=3D null && tm.getTransaction() !=3D null) + { + try + { + tm.rollback(); + } + catch (SystemException e) + { + // do nothing + } + } + } + catch (SystemException e) + { + // do nothing + } + if (cache !=3D null) + cache.stop(); + cache =3D null; + tm =3D null; + } + + public void testCommitCreationInSameTx() throws Exception + { + assertEquals(0, cache.getNumberOfLocksHeld()); + tm.begin(); + cache.put(fqn, "k", "v"); + assertEquals(2, cache.getNumberOfLocksHeld()); + Thread.sleep(sleepTime); + tm.commit(); + assertEquals(0, cache.getNumberOfLocksHeld()); + } + + public void testRollbackCreationInSameTx() throws Exception + { + assertEquals(0, cache.getNumberOfLocksHeld()); + tm.begin(); + cache.put(fqn, "k", "v"); + assertEquals(2, cache.getNumberOfLocksHeld()); + Thread.sleep(sleepTime); + tm.rollback(); + assertEquals(0, cache.getNumberOfLocksHeld()); + // make sure the node was NOT added!! + assertFalse(cache.exists(fqn)); + // even in a "deleted" form + assertNull(cache.peek(fqn, true)); + } + + private void doTest(boolean commit, boolean writeLock) throws Exception + { + assertEquals(0, cache.getNumberOfLocksHeld()); + cache.put(fqn, "k", "v");//Executed in Not transactional context + assertEquals(0, cache.getNumberOfLocksHeld()); + SeparateThread t =3D new SeparateThread(commit, writeLock); + t.start(); + t.join(); + if (t.getException() !=3D null) + { + throw t.getException(); + } + assertEquals(0, cache.getNumberOfLocksHeld()); + assertEquals("v", cache.get(fqn, "k")); + } + + public void testRollbackCreationInDifferentTxReadLock() throws Exception + { + doTest(false, false); + } + + public void testCommitCreationInDifferentTxReadLock() throws Exception + { + doTest(true, false); + } + + public void testRollbackCreationInDifferentTxWriteLock() throws Excepti= on + { + doTest(false, true); + } + + public void testCommitCreationInDifferentTxWriteLock() throws Exception + { + doTest(true, true); + } + + public void testTxTimeoutAndPutAfter() throws Exception + { + assertEquals(0, cache.getNumberOfLocksHeld()); + tm.begin(); + cache.put(fqn, "k", "v"); + assertEquals(2, cache.getNumberOfLocksHeld()); + assertNotNull(tm.getTransaction()); + Thread.sleep(sleepTime); + tm.rollback(); + assertNull(tm.getTransaction()); + assertEquals(0, cache.getNumberOfLocksHeld()); + + // make sure the node was NOT added!! + assertFalse(cache.exists(fqn)); + // even in a "deleted" form + assertNull(cache.peek(fqn, true)); + + //Put not some data into cache. Because no transaction is used + //no locks should be helds after this line. + cache.put(fqn, "k", "v"); + assertEquals(0, cache.getNumberOfLocksHeld()); + } + + public void testTxTimeoutAndPutGetAfter() throws Exception + { + assertEquals(0, cache.getNumberOfLocksHeld()); + tm.begin(); + cache.put(fqn, "k", "v"); + assertEquals(2, cache.getNumberOfLocksHeld()); + assertNotNull(tm.getTransaction()); + Thread.sleep(sleepTime); + tm.rollback(); + // make sure the node was NOT added!! + assertFalse(cache.exists(fqn)); + // even in a "deleted" form + assertNull(cache.peek(fqn, true)); + assertNull(tm.getTransaction()); + assertEquals(0, cache.getNumberOfLocksHeld()); + + //Put not some data into cache. Because no transaction is used + //no locks should be helds after this line. + cache.put(fqn, "k", "v"); + cache.get(fqn, "k"); + + // Make sure no write lock is retained by the main thread. Test tha= t another thread can read. + SeparateThread t =3D new SeparateThread(false, false); + t.start(); + t.join(); + if (t.getException() !=3D null) + { + throw t.getException(); + } + } + + private class SeparateThread extends Thread + { + Exception e =3D null; + boolean commit, writeLock; + + public SeparateThread(boolean commit, boolean writeLock) + { + this.commit =3D commit; + this.writeLock =3D writeLock; + } + + public Exception getException() + { + return e; + } + + public void run() + { + try + { + tm.begin(); + if (writeLock) + { + cache.put(fqn, "k", "v2");// obtain write lock on node + } + else + { + cache.get(fqn, "k");// obtain read lock on node + } + + // sleep to ensure tx times out. + sleep(2500); + + if (commit) + { + tm.commit(); + } + else + { + tm.rollback(); + } + + assertEquals(0, cache.getNumberOfLocksHeld()); + + } + catch (Exception e) + { + this.e =3D e; + } + } + } + +} Property changes on: core/trunk/src/test/java/org/jboss/cache/transaction/p= essimistic/AsyncRollbackTxTest.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Copied: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/Co= ncurrentTransactionalTest.java (from rev 6585, core/trunk/src/test/java/org= /jboss/cache/transaction/ConcurrentTransactionalTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/Concur= rentTransactionalTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/Concur= rentTransactionalTest.java 2008-08-25 17:50:21 UTC (rev 6611) @@ -0,0 +1,202 @@ +/* + * + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.cache.transaction.pessimistic; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.cache.CacheFactory; +import org.jboss.cache.CacheSPI; +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.Fqn; +import org.jboss.cache.transaction.TransactionSetup; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; +import org.jboss.cache.lock.IsolationLevel; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.fail; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import javax.transaction.UserTransaction; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + +/** + * Unit test for local CacheSPI. Use locking and multiple threads to test + * concurrent access to the tree. + * + * @version $Id$ + */ +(a)Test(groups =3D {"functional", "transaction"}) +public class ConcurrentTransactionalTest +{ + private CacheSPI cache; + private Log logger_ =3D LogFactory.getLog(ConcurrentTransactionalTest.c= lass); + private static Throwable thread_ex =3D null; + private static final int NUM =3D 10000; + + @BeforeMethod(alwaysRun =3D true) + public void setUp() throws Exception + { + } + + private void createCache(IsolationLevel level) + { + CacheFactory factory =3D new DefaultCacheFactory(); + Configuration conf =3D UnitTestCacheConfigurationFactory.createConfi= guration(Configuration.CacheMode.LOCAL, true); + conf.setCacheMode(Configuration.CacheMode.LOCAL); + conf.setIsolationLevel(level); + conf.setTransactionManagerLookupClass(TransactionSetup.getManagerLoo= kup()); + conf.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTI= C); + cache =3D (CacheSPI) new DefaultCacheFactory().creat= eCache(conf); + cache.put("/a/b/c", null); + } + + @AfterMethod(alwaysRun =3D true) + public void tearDown() throws Exception + { + cache.stop(); + thread_ex =3D null; + TransactionSetup.cleanup(); + } + + public void testConcurrentAccessWithRWLock() throws Throwable + { + createCache(IsolationLevel.REPEATABLE_READ); + work_(); + } + + public void testConcurrentAccessWithExclusiveLock() throws Throwable + { + createCache(IsolationLevel.SERIALIZABLE); + work_(); + } + + private void work_() throws Throwable + { + Updater one, two; + try + { + one =3D new Updater("Thread one"); + two =3D new Updater("Thread two"); + long current =3D System.currentTimeMillis(); + one.start(); + two.start(); + one.join(); + two.join(); + if (thread_ex !=3D null) + { + throw thread_ex; + } + + long now =3D System.currentTimeMillis(); + log("*** Time elapsed: " + (now - current)); + + System.out.println("cache content: " + cache.toString()); + Set keys =3D cache.getNode(Fqn.fromString("/a/b/c")).get= Keys(); + System.out.println("number of keys=3D" + keys.size()); + + if (keys.size() !=3D NUM) + { + scanForNullValues(keys); + + try + { + System.out.println("size=3D" + keys.size()); + List l =3D new LinkedList(keys); + Collections.sort(l); + System.out.println("keys: " + l); + for (int i =3D 0; i < NUM; i++) + { + if (!l.contains(new Integer(i))) + { + System.out.println("missing: " + i); + } + } + + LinkedList duplicates =3D new LinkedList(= ); + for (Integer integer : l) + { + if (duplicates.contains(integer)) + { + System.out.println(integer + " is a duplicate"); + } + else + { + duplicates.add(integer); + } + } + } + catch (Exception e1) + { + e1.printStackTrace(); + } + } + + assertEquals(NUM, keys.size()); + } + catch (Exception e) + { + e.printStackTrace(); + fail(e.toString()); + } + } + + private void scanForNullValues(Set keys) + { + for (Object o : keys) + { + if (o =3D=3D null) + { + System.err.println("found a null value in keys"); + } + } + } + + private void log(String msg) + { + logger_.debug(" [" + Thread.currentThread() + "]: " + msg); + } + + private class Updater extends Thread + { + private String val =3D null; + private UserTransaction tx; + + public Updater(String name) + { + this.val =3D name; + } + + public void run() + { + try + { + log("adding data"); + tx =3D TransactionSetup.getUserTransaction(); + for (int i =3D 0; i < NUM; i++) + { + log("adding data i=3D" + i); + tx.begin(); + cache.put("/a/b/c", i, val); + tx.commit(); + yield(); + } + } + catch (Throwable t) + { + t.printStackTrace(); + thread_ex =3D t; + } + } + } + +} Property changes on: core/trunk/src/test/java/org/jboss/cache/transaction/p= essimistic/ConcurrentTransactionalTest.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Copied: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/Is= olationLevelNoneTest.java (from rev 6585, core/trunk/src/test/java/org/jbos= s/cache/transaction/IsolationLevelNoneTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/Isolat= ionLevelNoneTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/Isolat= ionLevelNoneTest.java 2008-08-25 17:50:21 UTC (rev 6611) @@ -0,0 +1,106 @@ +package org.jboss.cache.transaction.pessimistic; + +import org.jboss.cache.CacheFactory; +import org.jboss.cache.CacheSPI; +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.Fqn; +import org.jboss.cache.Node; +import org.jboss.cache.transaction.TransactionSetup; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.lock.IsolationLevel; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.Test; + +import javax.transaction.NotSupportedException; +import javax.transaction.SystemException; +import javax.transaction.TransactionManager; + +/** + * Tests whether modifications within callbacks (TreeCacheListener) are ha= ndled correctly + * + * @author Bela Ban + * @version $Id$ + */ +(a)Test(groups =3D {"functional", "transaction"}) +public class IsolationLevelNoneTest +{ + CacheSPI cache =3D null; + final Fqn FQN =3D Fqn.fromString("/a/b/c"); + final String KEY =3D "key"; + final String VALUE =3D "value"; + TransactionManager tm; + + @AfterMethod(alwaysRun =3D true) + public void tearDown() throws Exception + { + if (cache !=3D null) + { + cache.stop(); + cache.destroy(); + cache =3D null; + } + } + + public void testWithoutTransactions() throws Exception + { + CacheFactory instance =3D new DefaultCacheFactory(); + cache =3D (CacheSPI) instance.createCache(false); + cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLock= ingScheme.PESSIMISTIC); + cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL); + cache.getConfiguration().setIsolationLevel(IsolationLevel.NONE); + cache.start(); + cache.put(FQN, KEY, VALUE); + cache.put(FQN + "/d", KEY, VALUE); + Node node =3D cache.peek(FQN, false, false); + assertTrue(node !=3D null && node.getKeys().contains(KEY)); + assertEquals(VALUE, cache.get(FQN, KEY)); + assertEquals(0, cache.getNumberOfLocksHeld()); + } + + public void testWithTransactions() throws Exception + { + CacheFactory instance =3D new DefaultCacheFactory(); + cache =3D (CacheSPI) instance.createCache(false); + cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL); + cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLock= ingScheme.PESSIMISTIC); + cache.getConfiguration().setIsolationLevel(IsolationLevel.NONE); + cache.getConfiguration().setTransactionManagerLookupClass(Transactio= nSetup.getManagerLookup()); + cache.start(); + tm =3D startTransaction(); + cache.put(FQN, KEY, VALUE); + cache.put(FQN + "/d", KEY, VALUE); + Node node =3D cache.peek(FQN, false, false); + assertTrue(node !=3D null && node.getKeys().contains(KEY)); + assertEquals(VALUE, cache.get(FQN, KEY)); + assertEquals(0, cache.getNumberOfLocksHeld()); + tm.commit(); + } + + public void testWithTransactionsRepeatableRead() throws Exception + { + CacheFactory instance =3D new DefaultCacheFactory(); + cache =3D (CacheSPI) instance.createCache(false); + cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL); + cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE= _READ); + cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLock= ingScheme.PESSIMISTIC); + cache.getConfiguration().setTransactionManagerLookupClass(Transactio= nSetup.getManagerLookup()); + cache.start(); + tm =3D startTransaction(); + cache.put(FQN, KEY, VALUE); + cache.put(FQN + "/d", KEY, VALUE); + Node node =3D cache.peek(FQN, false, false); + assertTrue(node !=3D null && node.getKeys().contains(KEY)); + assertEquals(VALUE, cache.get(FQN, KEY)); + assertEquals(5, cache.getNumberOfLocksHeld()); + tm.commit(); + } + + private TransactionManager startTransaction() throws SystemException, N= otSupportedException + { + TransactionManager mgr =3D cache.getTransactionManager(); + mgr.begin(); + return mgr; + } +} Property changes on: core/trunk/src/test/java/org/jboss/cache/transaction/p= essimistic/IsolationLevelNoneTest.java ___________________________________________________________________ Name: svn:executable + * Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Copied: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/Pe= ssimisticTransactionTest.java (from rev 6585, core/trunk/src/test/java/org/= jboss/cache/transaction/TransactionTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/Pessim= isticTransactionTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/Pessim= isticTransactionTest.java 2008-08-25 17:50:21 UTC (rev 6611) @@ -0,0 +1,1072 @@ +/* + * + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ + +package org.jboss.cache.transaction.pessimistic; + +import org.jboss.cache.CacheException; +import org.jboss.cache.CacheFactory; +import org.jboss.cache.CacheSPI; +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.Fqn; +import org.jboss.cache.Node; +import org.jboss.cache.NodeSPI; +import org.jboss.cache.transaction.TransactionSetup; +import org.jboss.cache.transaction.GlobalTransaction; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.lock.IsolationLevel; +import org.jboss.cache.lock.LockManager; +import static org.jboss.cache.lock.LockType.READ; +import static org.jboss.cache.lock.LockType.WRITE; +import org.jboss.cache.util.CachePrinter; +import org.jboss.cache.util.TestingUtil; +import static org.testng.AssertJUnit.*; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import javax.transaction.HeuristicMixedException; +import javax.transaction.HeuristicRollbackException; +import javax.transaction.NotSupportedException; +import javax.transaction.RollbackException; +import javax.transaction.SystemException; +import javax.transaction.Transaction; +import javax.transaction.TransactionManager; +import javax.transaction.UserTransaction; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +/** + * Tests transactional access to a local CacheImpl. + * Note: we use DummpyTranasctionManager to replace jta + * + * @version $Id$ + */ +(a)Test(groups =3D {"functional", "transaction"}) +public class PessimisticTransactionTest +{ + CacheSPI cache =3D null; + UserTransaction tx =3D null; + Exception exception; + LockManager lockManager; + + @BeforeMethod(alwaysRun =3D true) + public void setUp() throws Exception + { + + CacheFactory instance =3D new DefaultCacheFactor= y(); + cache =3D (CacheSPI) instance.createCache(false); + cache.getConfiguration().setClusterName("test"); + cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLock= ingScheme.PESSIMISTIC); + cache.getConfiguration().setStateRetrievalTimeout(10000); + cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZAB= LE); + cache.getConfiguration().setLockParentForChildInsertRemove(true);// = this test case is written to assume this. + cache.getConfiguration().setTransactionManagerLookupClass(Transactio= nSetup.getManagerLookup()); + tx =3D TransactionSetup.getUserTransaction(); + + cache.create(); + cache.start(); + exception =3D null; + lockManager =3D TestingUtil.extractLockManager(cache); + } + + @AfterMethod(alwaysRun =3D true) + public void tearDown() throws Exception + { + if (cache !=3D null) + { + cache.stop(); + cache =3D null; + } + + // BW. kind of a hack to destroy jndi binding and thread local tx be= fore next run. + TransactionSetup.cleanup(); + + if (tx !=3D null) + { + try + { + tx.rollback(); + } + catch (Throwable t) + { + // do nothing + } + tx =3D null; + } + } + + public void testPutTx() throws Exception + { + tx.begin(); + cache.put("/a/b/c", "age", 38); + // the tx interceptor should know that we're in the same tx. + assertEquals(cache.get("/a/b/c", "age"), 38); + + cache.put("/a/b/c", "age", 39); + tx.commit(); + + // This test is done outside the TX, it wouldn't work if someone else + // modified "age". This works because we're the only TX running. + assertEquals(cache.get("/a/b/c", "age"), 39); + } + + public void testRollbackTx1() + { + try + { + tx.begin(); + cache.put("/a/b/c", "age", 38); + cache.put("/a/b/c", "age", 39); + tx.rollback(); + + // This test is done outside the TX, it wouldn't work if someone = else + // modified "age". This works because we're the only TX running. + assertNull(cache.get("/a/b/c", "age")); + } + catch (Throwable t) + { + t.printStackTrace(); + fail(t.toString()); + } + } + + public void testGetAfterRemovalRollback() throws Exception + { + assertEquals(0, cache.getNumberOfLocksHeld()); + cache.put("/a/b", null); + assertEquals(0, cache.getNumberOfLocksHeld()); + assertTrue(cache.exists("/a/b")); + tx.begin(); + cache.removeNode("/a/b"); + assertFalse(cache.exists("/a/b")); + tx.rollback(); + assertTrue(cache.exists("/a/b")); + assertEquals(0, cache.getNumberOfLocksHeld()); + // new tx in new thread + Thread th =3D new Thread() + { + public void run() + { + try + { + cache.getTransactionManager().begin(); + assertNotNull(cache.getNode("/a/b")); + cache.getTransactionManager().rollback(); + } + catch (Exception e) + { + e.printStackTrace(); + fail("Caught exception"); + } + } + }; + + th.start(); + th.join(); + + assertEquals(0, cache.getNumberOfLocksHeld()); + } + + public void testRollbackTx2() + { + try + { + tx.begin(); + cache.put("/a/b/c", "age", 38); + cache.remove("/a/b/c", "age"); + tx.rollback(); + + // This test is done outside the TX, it wouldn't work if someone = else + // modified "age". This works because we're the only TX running. + assertNull(cache.get("/a/b/c", "age")); + } + catch (Throwable t) + { + t.printStackTrace(); + fail(t.toString()); + } + } + + public void testRollbackTx2a() + { + try + { + cache.put("/a/b/c", "age", 38); + tx.begin(); + cache.remove("/a/b/c", "age"); + tx.rollback(); + + // This test is done outside the TX, it wouldn't work if someone = else + // modified "age". This works because we're the only TX running. + assertEquals(38, cache.get("/a/b/c", "age")); + } + catch (Throwable t) + { + t.printStackTrace(); + fail(t.toString()); + } + } + + public void testRollbackTx3() + { + try + { + java.util.Map map1 =3D new java.util.HashMap<= String, Comparable>(); + map1.put("age", 38); + java.util.Map map2 =3D new java.util.HashMap<= String, Comparable>(); + map2.put("age", 39); + tx.begin(); + cache.put("/a/b/c", map1); + cache.put("/a/b/c", map2); + tx.rollback(); + + // This test is done outside the TX, it wouldn't work if someone = else + // modified "age". This works because we're the only TX running. + assertNull(cache.get("/a/b/c", "age")); + } + catch (Throwable t) + { + t.printStackTrace(); + fail(t.toString()); + } + } + + public void testRollbackTx4() + { + try + { + Map map =3D new HashMap(); + map.put("age", 38); + tx.begin(); + cache.put("/a/b/c", map); + cache.removeNode("/a/b/c"); + tx.rollback(); + + // This test is done outside the TX, it wouldn't work if someone = else + // modified "age". This works because we're the only TX running. + assertNull(cache.get("/a/b/c", "age")); + } + catch (Throwable t) + { + t.printStackTrace(); + fail(t.toString()); + } + } + + public void testNodeCreationRollback() + { + try + { + tx.begin(); + System.out.println("initial state:\n" + cache); + cache.put("/bela/ban", "key", "value"); + System.out.println("after put():\n" + cache); + tx.rollback(); + System.out.println("after rollback():\n" + cache); + + assertNull("node should be not existent", cache.getNode("/bela/ba= n")); + } + catch (Throwable t) + { + t.printStackTrace(); + fail(t.toString()); + } + } + + public void testNodeCreationRollback2() + { + try + { + cache.put("/bela/ban", null); + tx.begin(); + cache.put("/bela/ban/michelle", null); + tx.rollback(); + assertNotNull("node should be not null", cache.getNode("/bela/ban= ")); + assertNull("node should be not existent", cache.getNode("/bela/ba= n/michelle")); + } + catch (Throwable t) + { + t.printStackTrace(); + fail(t.toString()); + } + } + + public void testNodeDeletionRollback() + { + try + { + cache.put("/a/b/c", null); + tx.begin(); + cache.removeNode("/a/b/c"); + assertNull(cache.getNode("/a/b/c")); + cache.removeNode("/a/b"); + assertNull(cache.getNode("/a/b")); + cache.removeNode("/a"); + assertNull(cache.getNode("/a")); + tx.rollback(); + assertNotNull(cache.getNode("/a/b/c")); + assertNotNull(cache.getNode("/a/b")); + assertNotNull(cache.getNode("/a")); + } + catch (Throwable t) + { + t.printStackTrace(); + fail(t.toString()); + } + } + + public void testNodeDeletionRollback2() throws Exception + { + cache.put("/a/b/c", null); + cache.put("/a/b/c1", null); + cache.put("/a/b/c2", null); + tx.begin(); + cache.removeNode("/a"); + assertNull(cache.getNode("/a/b/c")); + assertNull(cache.getNode("/a/b/c1")); + assertNull(cache.getNode("/a/b/c2")); + assertNull(cache.getNode("/a/b")); + assertNull(cache.getNode("/a")); + Set children =3D cache.getChildrenNames(Fqn.fromString("/a/b")); + assertTrue(children.isEmpty()); + children =3D cache.getChildrenNames("/a"); + assertTrue(children.isEmpty()); + tx.rollback(); + assertNotNull(cache.getNode("/a")); + assertNotNull(cache.getNode("/a/b")); + assertNotNull(cache.getNode("/a/b/c")); + assertNotNull(cache.getNode("/a/b/c1")); + assertNotNull(cache.getNode("/a/b/c2")); + children =3D cache.getChildrenNames(Fqn.fromString("/a/b")); + assertEquals(3, children.size()); + } + + public void testNodeCreation() throws Exception + { + GlobalTransaction gtx; + cache.put("/a/b", null); + tx.begin(); + gtx =3D cache.getCurrentTransaction(); + cache.put("/a/b/c", null); + assertLocked(gtx, "/a", false); + assertLocked(gtx, "/a/b", true); + assertLocked(gtx, "/a/b/c", true); + } + + public void testNodeCreation2() throws Exception + { + GlobalTransaction gtx; + tx.begin(); + gtx =3D cache.getCurrentTransaction(); + cache.put("/a/b/c", null); + assertLocked(gtx, "/a", true); + assertLocked(gtx, "/a/b", true); + assertLocked(gtx, "/a/b/c", true); + } + + public void testNodeRemoval() throws SystemException, NotSupportedExcep= tion + { + GlobalTransaction gtx; + cache.put("/a/b/c", null); + tx.begin(); + gtx =3D cache.getCurrentTransaction(); + cache.removeNode("/a/b/c");// need to remove the node, not just the = data in the node. + assertLocked(gtx, "/a", false); + assertLocked(gtx, "/a/b", true); + assertLocked(gtx, "/a/b/c", true); + tx.rollback(); + } + + public void testNodeRemoval2() throws SystemException, NotSupportedExce= ption + { + GlobalTransaction gtx; + cache.put("/a/b/c", null); + tx.begin(); + gtx =3D cache.getCurrentTransaction(); + cache.removeNode("/a/b");// need to remove the node, not just the da= ta in the node. + assertLocked(gtx, "/a", true); + assertLocked(gtx, "/a/b", true); + assertLocked(gtx, "/a/b/c", true); + tx.rollback(); + } + + public void testIntermediateNodeCreationOnWrite() throws Exception + { + cache.put("/a", null); + tx.begin(); + cache.put("/a/b/c", null); + // expecting WLs on /a, /a/b and /a/b/c. + GlobalTransaction gtx =3D cache.getCurrentTransaction(); + assertLocked(gtx, "/a", true); + assertLocked(gtx, "/a/b", true); + assertLocked(gtx, "/a/b/c", true); + tx.rollback(); + } + + public void testIntermediateNodeCreationOnRead() throws Exception + { + cache.put("/a", null); + tx.begin(); + cache.getNode("/a/b/c"); + + // expecting RLs on /, /a + // /a/b, /a/b/c should NOT be created! + GlobalTransaction gtx =3D cache.getCurrentTransaction(); + assertLocked(gtx, "/", false); + assertLocked(gtx, "/a", false); + assertNull("/a/b should not exist", cache.peek(Fqn.fromString("/a/b"= ), true)); + assertNull("/a/b/c should not exist", cache.peek(Fqn.fromString("/a/= b/c"), true)); + tx.rollback(); + assertNull("/a/b should not exist", cache.peek(Fqn.fromString("/a/b"= ), true)); + assertNull("/a/b/c should not exist", cache.peek(Fqn.fromString("/a/= b/c"), true)); + + } + + public void testIntermediateNodeCreationOnRemove() throws Exception + { + cache.put("/a", null); + tx.begin(); + cache.removeNode("/a/b/c"); + + // expecting RLs on /, /a + // /a/b, /a/b/c should NOT be created! + GlobalTransaction gtx =3D cache.getCurrentTransaction(); + assertLocked(gtx, "/", false); + assertLocked(gtx, "/a", true); + assertLocked(gtx, "/a/b", true); + assertLocked(gtx, "/a/b/c", true); + assertNotNull("/a/b should exist", cache.peek(Fqn.fromString("/a/b")= , true)); + assertNotNull("/a/b/c should exist", cache.peek(Fqn.fromString("/a/b= /c"), true)); + assertNotNull("/a/b should NOT be visible", cache.exists(Fqn.fromStr= ing("/a/b"))); + assertNotNull("/a/b/c should NOT be visible", cache.exists(Fqn.fromS= tring("/a/b/c"))); + tx.rollback(); + assertNull("/a/b should not exist", cache.peek(Fqn.fromString("/a/b"= ), true)); + assertNull("/a/b/c should not exist", cache.peek(Fqn.fromString("/a/= b/c"), true)); + + } + + public void testNodeDeletionRollback3() throws Exception + { + GlobalTransaction gtx; + cache.put("/a/b/c1", null); + + tx.begin(); + gtx =3D cache.getCurrentTransaction(); + cache.put("/a/b/c1", null); + assertLocked(gtx, "/a", false); + assertLocked(gtx, "/a/b", false); + assertLocked(gtx, "/a/b/c1", true); + + cache.put("/a/b/c2", null); + assertLocked(gtx, "/a/b", true); + assertLocked(gtx, "/a/b/c2", true); + + cache.put("/a/b/c3", null); + cache.put("/a/b/c1/one", null); + assertLocked(gtx, "/a/b/c1", true); + assertLocked(gtx, "/a/b/c1/one", true); + + cache.put("/a/b/c1/two", null); + cache.put("/a/b/c1/one/1", null); + assertLocked(gtx, "/a/b/c1", true); + assertLocked(gtx, "/a/b/c1/one", true); + assertLocked(gtx, "/a/b/c1/one/1", true); + + cache.put("/a/b/c1/two/2/3/4", null); + assertLocked(gtx, "/a/b/c1", true); + assertLocked(gtx, "/a/b/c1/two", true); + assertLocked(gtx, "/a/b/c1/two/2", true); + assertLocked(gtx, "/a/b/c1/two/2/3", true); + assertLocked(gtx, "/a/b/c1/two/2/3/4", true); + + cache.removeNode("/a/b"); + tx.rollback(); + assertTrue(cache.getChildrenNames("/a/b/c1").isEmpty()); + Set cn =3D cache.getChildrenNames(Fqn.fromString("/a/b")); + assertEquals(1, cn.size()); + assertEquals("c1", cn.iterator().next()); + } + + public void testDoubleLocks() throws Exception + { + tx.begin(); + GlobalTransaction gtx =3D cache.getCurrentTransaction(); + cache.put("/a/b/c", null); + cache.put("/a/b/c", null); + + NodeSPI n =3D cache.getNode("/a"); + assert !lockManager.isLocked(n, READ); + // make sure this is write locked. + assertLocked(gtx, "/a", true); + + n =3D cache.getNode("/a/b"); + assert !lockManager.isLocked(n, READ); + // make sure this is write locked. + assertLocked(gtx, "/a/b", true); + + n =3D cache.getNode("/a/b/c"); + assert !lockManager.isLocked(n, READ); + // make sure this is write locked. + assertLocked(gtx, "/a/b/c", true); + + tx.rollback(); + assertEquals(0, cache.getNumberOfLocksHeld()); + } + + private void assertLocked(Object owner, String fqn, boolean writeLocked) + { + NodeSPI n =3D cache.peek(Fqn.fromString(fqn), tr= ue); + if (owner =3D=3D null) owner =3D Thread.currentThread(); + assertTrue("node " + fqn + " is not locked", lockManager.isLocked(n)= ); + if (writeLocked) + { + assertTrue("node " + fqn + " is not write-locked by owner " + own= er + ". Lock details: " + lockManager.printLockInfo(n), lockManager.ownsLoc= k(Fqn.fromString(fqn), WRITE, owner)); + } + else + { + assertTrue("node " + fqn + " is not read-locked by owner " + owne= r + ". Lock details: " + lockManager.printLockInfo(n), lockManager.ownsLock= (Fqn.fromString(fqn), READ, owner)); + } + } + + public void testConcurrentNodeAccessOnRemovalWithTx() throws Exception + { + cache.put("/a/b/c", null); + tx.begin(); + cache.removeNode("/a/b/c"); + // this node should now be locked. + TransactionManager tm =3D cache.getConfiguration().getRuntimeConfig(= ).getTransactionManager(); + Transaction t =3D tm.suspend(); + // start a new tx + tm.begin(); + try + { + cache.getNode("/a/b/c");// should fail + fail("Should not be able to get a hold of /a/b/c until the deleti= ng tx completes"); + } + catch (Exception e) + { + // expected + //cache.getTransactionManager().commit(); + tm.commit(); + } + + tm.resume(t); + tx.rollback(); + + assertNotNull(cache.getNode("/a/b/c")); + assertEquals(0, cache.getNumberOfLocksHeld()); + } + + public void testConcurrentNodeAccessOnRemovalWithoutTx() throws Excepti= on + { + cache.put("/a/b/c", null); + tx.begin(); + cache.removeNode("/a/b/c"); + // this node should now be locked. + Transaction t =3D cache.getTransactionManager().suspend(); + Thread th =3D new Thread() + { + public void run() + { + try + { + cache.getNode("/a/b/c");// should fail + + fail("Should not be able to get a hold of /a/b/c until the = deleting tx completes"); + } + catch (Exception e) + { + // expected + } + } + }; + + th.start(); + th.join(); + + cache.getTransactionManager().resume(t); + tx.rollback(); + + assertNotNull(cache.getNode("/a/b/c")); + assertEquals(0, cache.getNumberOfLocksHeld()); + } + + public void testRemove() throws CacheException, SystemException, NotSup= portedException, HeuristicMixedException, HeuristicRollbackException, Rollb= ackException + { + cache.put("/a/b/c", null); + cache.put("/a/b/c/1", null); + cache.put("/a/b/c/2", null); + cache.put("/a/b/c/3", null); + cache.put("/a/b/c/3/a/b/c", null); + + assertEquals(0, cache.getNumberOfLocksHeld()); + + tx.begin(); + cache.removeNode("/a/b/c"); + // this used to test for 2 locks held. After the fixes for JBCACHE-= 875 however, 2 more locks are acquired - for the root node as well as the d= eleted node. + // and since we would lock all children of the deleted node as well,= we have 10 locks here. + assertEquals(10, cache.getNumberOfLocksHeld()); + tx.commit(); + assertEquals(0, cache.getNumberOfLocksHeld()); + } + + public void testRemoveAndRollback() throws CacheException, SystemExcept= ion, NotSupportedException, HeuristicMixedException, HeuristicRollbackExcep= tion, + RollbackException + { + cache.put("/a/b/c", null); + cache.put("/a/b/c/1", null); + cache.put("/a/b/c/2", null); + cache.put("/a/b/c/3", null); + cache.put("/a/b/c/3/a/b/c", null); + + assertEquals(0, cache.getNumberOfLocksHeld()); + + tx.begin(); + cache.removeNode("/a/b/c"); + assertEquals(10, cache.getNumberOfLocksHeld()); + tx.rollback(); + assertEquals(0, cache.getNumberOfLocksHeld()); + + assertTrue(cache.exists("/a/b/c")); + assertTrue(cache.exists("/a/b/c/1")); + assertTrue(cache.exists("/a/b/c/2")); + assertTrue(cache.exists("/a/b/c/3")); + assertTrue(cache.exists("/a/b/c/3/a")); + assertTrue(cache.exists("/a/b/c/3/a/b")); + assertTrue(cache.exists("/a/b/c/3/a/b/c")); + } + + public void testRemoveKeyRollback() throws CacheException, SystemExcept= ion, NotSupportedException + { + cache.put("/bela/ban", "name", "Bela"); + tx.begin(); + cache.remove("/bela/ban", "name"); + assertNull(cache.get("/bela/ban", "name")); + tx.rollback(); + assertEquals("Bela", cache.get("/bela/ban", "name")); + } + + public void testRemoveKeyRollback2() + { + try + { + Map m =3D new HashMap(); + m.put("name", "Bela"); + m.put("id", 322649); + cache.put("/bela/ban", m); + tx.begin(); + cache.remove("/bela/ban", "name"); + assertNull(cache.get("/bela/ban", "name")); + tx.rollback(); + assertEquals("Bela", cache.get("/bela/ban", "name")); + } + catch (Throwable t) + { + t.printStackTrace(); + fail(t.toString()); + } + } + + public void testRemoveKeyRollback3() + { + try + { + cache.put("/bela/ban", "name", "Bela"); + tx.begin(); + cache.put("/bela/ban", "name", "Michelle"); + cache.remove("/bela/ban", "name"); + assertNull(cache.get("/bela/ban", "name")); + tx.rollback(); + assertEquals("Bela", cache.get("/bela/ban", "name")); + } + catch (Throwable t) + { + t.printStackTrace(); + fail(t.toString()); + } + } + + public void testDoubleRemovalOfSameData() throws Exception + { + tx.begin(); + cache.put("/foo/1", "item", 1); + assertEquals(cache.get("/foo/1", "item"), 1); + cache.removeNode("/foo/1"); + assertNull(cache.get("/foo/1", "item")); + cache.removeNode("/foo/1"); + assertNull(cache.get("/foo/1", "item")); + tx.rollback(); + assertFalse(cache.exists("/foo/1")); + assertNull(cache.get("/foo/1", "item")); + } + + /** + * put(Fqn, Map) with a previous null map + */ + public void testPutDataRollback1() + { + try + { + cache.put("/bela/ban", null);// create a node /bela/ban with a nu= ll map + tx.begin(); + Map m =3D new HashMap(); + m.put("name", "Bela"); + m.put("id", 322649); + cache.put("/bela/ban", m); + tx.rollback(); + + Node n =3D cache.getNode("/bela/ban"); + if (n.getData() =3D=3D null) + return; + assertEquals("map should be empty", 0, n.getData().size()); + } + catch (Throwable t) + { + t.printStackTrace(); + fail(t.toString()); + } + } + + /** + * put(Fqn, Map) with a previous non-null map + */ + public void testputDataRollback2() throws Exception + { + Map m1, m2; + m1 =3D new HashMap(); + m1.put("name", "Bela"); + m1.put("id", 322649); + m2 =3D new HashMap(); + m2.put("other", "bla"); + m2.put("name", "Michelle"); + + cache.put("/bela/ban", m1); + tx.begin(); + + cache.put("/bela/ban", m2); + Map tmp =3D cache.getNode("/bela/ban").getData(); + assertEquals(3, tmp.size()); + assertEquals("Michelle", tmp.get("name")); + assertEquals(tmp.get("id"), 322649); + assertEquals("bla", tmp.get("other")); + tx.rollback(); + + tmp =3D cache.getNode("/bela/ban").getData(); + assertEquals(2, tmp.size()); + assertEquals("Bela", tmp.get("name")); + assertEquals(tmp.get("id"), 322649); + } + + public void testPutRollback() + { + try + { + cache.put("/bela/ban", null);// /bela/ban needs to exist + tx.begin(); + cache.put("/bela/ban", "name", "Bela"); + assertEquals("Bela", cache.get("/bela/ban", "name")); + tx.rollback(); + assertNull(cache.get("/bela/ban", "name")); + } + catch (Throwable t) + { + t.printStackTrace(); + fail(t.toString()); + } + } + + public void testPutRollback2() + { + try + { + cache.put("/bela/ban", "name", "Bela");// /bela/ban needs to exist + tx.begin(); + cache.put("/bela/ban", "name", "Michelle"); + assertEquals("Michelle", cache.get("/bela/ban", "name")); + tx.rollback(); + assertEquals("Bela", cache.get("/bela/ban", "name")); + } + catch (Throwable t) + { + t.printStackTrace(); + fail(t.toString()); + } + } + + public void testSimpleRollbackTransactions() throws Exception + { + final Fqn fqn =3D Fqn.fromString("/a/b/c"); + tx.begin(); + cache.put(fqn, "entry", "commit"); + tx.commit(); + + tx.begin(); + cache.put(fqn, "entry", "rollback"); + cache.removeNode(fqn); + tx.rollback(); + assertEquals("Node should keep the commited value", "commit", cache.= getNode(fqn).get("entry")); + + tx.begin(); + cache.removeNode(fqn); + cache.put(fqn, "entry", "rollback"); + tx.rollback(); + + System.out.println("Cache: " + CachePrinter.printCacheDetails(cache)= ); + + assertEquals("Node should keep the commited value", "commit", cache.= getNode(fqn).get("entry"));// THIS FAILS + } + + private TransactionManager startTransaction() throws Exception + { + TransactionManager mgr =3D cache.getConfiguration().getRuntimeConfig= ().getTransactionManager(); + mgr.begin(); + return mgr; + } + + public void testConcurrentReadAndWriteAccess() throws Exception + { + cache.stop(); + cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE= _READ); + cache.start(); + + cache.put("/1/2/3/4", "foo", "bar");// no TX, no locks held after pu= t() returns + + class Reader extends Thread + { + TransactionManager thread_tx; + + public Reader() + { + super("Reader"); + } + + public void run() + { + try + { + thread_tx =3D startTransaction(); + log("acquiring RL"); + cache.get("/1/2/3", "foo");// acquires RLs on all 3 nodes + log("RL acquired successfully"); + sleep(2000); + log("committing TX"); + thread_tx.commit();// releases RLs + log("committed TX"); + } + catch (Exception e) + { + exception =3D e; + } + } + } + + class Writer extends Thread + { + TransactionManager thread_tx; + + public Writer() + { + super("Writer"); + } + + public void run() + { + try + { + sleep(500);// give the Reader a chance to acquire the RLs + thread_tx =3D startTransaction(); + log("acquiring WL"); + cache.put("/1", "foo", "bar2");// needs to acquired a WL on= /1 + log("acquired WL successfully"); + log("committing TX"); + thread_tx.commit(); + log("committed TX"); + } + catch (Exception e) + { + exception =3D e; + } + } + } + + Reader reader =3D new Reader(); + Writer writer =3D new Writer(); + reader.start(); + writer.start(); + reader.join(); + writer.join(); + if (exception !=3D null) + { + throw exception; + } + } + + public void testRemoveAndGetInTx() throws Exception + { + Fqn A_B =3D Fqn.fromString("/a/b"); + Fqn A =3D Fqn.fromString("/a"); + + cache.put(A_B, "k", "v"); + + assertTrue(cache.exists(A_B)); + assertTrue(cache.exists(A)); + + cache.getTransactionManager().begin(); + cache.removeNode(A); + cache.get(A_B, "k"); + cache.getTransactionManager().commit(); + } + + public void testRemoveAndPutInTx() throws Exception + { + Fqn A_B =3D Fqn.fromString("/a/b"); + Fqn A =3D Fqn.fromString("/a"); + + cache.put(A_B, "k", "v"); + + assertTrue(cache.exists(A_B)); + assertTrue(cache.exists(A)); + + cache.getTransactionManager().begin(); + cache.removeNode(A_B); + cache.put(A_B, "k", "v2"); + cache.getTransactionManager().commit(); + + assertTrue(cache.exists(A_B)); + assertTrue(cache.exists(A)); + + assert cache.peek(A, true, true).isValid(); + assert cache.peek(A_B, true, true).isValid(); + + assertEquals("v2", cache.get(A_B, "k")); + } + + public void testRemoveParentAndPutInTx() throws Exception + { + Fqn A_B =3D Fqn.fromString("/a/b"); + Fqn A =3D Fqn.fromString("/a"); + + cache.put(A_B, "k", "v"); + + assertTrue(cache.exists(A_B)); + assertTrue(cache.exists(A)); + + cache.getTransactionManager().begin(); + cache.removeNode(A); + cache.put(A_B, "k", "v2"); + cache.getTransactionManager().commit(); + + assertTrue(cache.exists(A_B)); + assertTrue(cache.exists(A)); + + assertEquals("v2", cache.get(A_B, "k")); + } + + public void testRemoveGrandParentAndPutInTx() throws Exception + { + Fqn A_B_C =3D Fqn.fromString("/a/b/c"); + Fqn A =3D Fqn.fromString("/a"); + + cache.put(A_B_C, "k", "v"); + + assertTrue(cache.exists(A_B_C)); + assertTrue(cache.exists(A)); + + cache.getTransactionManager().begin(); + cache.removeNode(A); + cache.put(A_B_C, "k", "v2"); + cache.getTransactionManager().commit(); + + assertTrue(cache.exists(A_B_C)); + assertTrue(cache.exists(A)); + + assertEquals("v2", cache.get(A_B_C, "k")); + } + + public void testRootNodeRemoval() throws Exception + { + Fqn root =3D Fqn.ROOT; + Fqn fqn =3D Fqn.fromElements(1); + //put first time + tx.begin(); + this.cache.put(fqn, "k", "v"); + tx.commit(); + + //get works fine + tx.begin(); + assertEquals("v", this.cache.get(fqn, "k")); + tx.commit(); + + //remove all + tx.begin(); + this.cache.removeNode(root); + tx.commit(); + + //get returns null - ok + //put - endless loop + tx.begin(); + assertNull(this.cache.get(fqn, "k")); + this.cache.put(fqn, "k", "v"); + tx.commit(); + } + + public void testNodeAdditionAfterRemoval() throws Exception + { + Fqn fqn =3D Fqn.fromString("/1/2/3/4"); + //put first time + tx.begin(); + this.cache.put(fqn, "k", "v"); + tx.commit(); + + //get works fine + tx.begin(); + assertEquals("v", this.cache.get(fqn, "k")); + tx.commit(); + + //remove all + tx.begin(); + this.cache.removeNode(Fqn.ROOT); + tx.commit(); + + //get returns null - ok + //put - endless loop + tx.begin(); + assertNull(this.cache.get(fqn, "k")); + this.cache.put(fqn, "k", "v"); + tx.commit(); + } + + public void testRootNodeRemovalRollback() throws Exception + { + Fqn root =3D Fqn.ROOT; + Fqn fqn =3D Fqn.fromRelativeElements(root, 1); + //put first time + tx.begin(); + this.cache.put(fqn, "k", "v"); + tx.commit(); + + //get works fine + tx.begin(); + assertEquals("v", this.cache.get(fqn, "k")); + tx.commit(); + + //remove all + tx.begin(); + this.cache.removeNode(root); + tx.rollback(); + + assertEquals("v", this.cache.get(fqn, "k")); + } + + private static void log(String msg) + { + System.out.println(Thread.currentThread().getName() + ": " + msg); + } + +} Property changes on: core/trunk/src/test/java/org/jboss/cache/transaction/p= essimistic/PessimisticTransactionTest.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Copied: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/Pr= epareTxTest.java (from rev 6585, core/trunk/src/test/java/org/jboss/cache/t= ransaction/PrepareTxTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/Prepar= eTxTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/Prepar= eTxTest.java 2008-08-25 17:50:21 UTC (rev 6611) @@ -0,0 +1,158 @@ +package org.jboss.cache.transaction.pessimistic; + +import org.jboss.cache.CacheException; +import org.jboss.cache.CacheFactory; +import org.jboss.cache.CacheSPI; +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.transaction.TransactionSetup; +import org.jboss.cache.transaction.TransactionTable; +import org.jboss.cache.config.Configuration; +import static org.testng.AssertJUnit.assertEquals; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import javax.transaction.NotSupportedException; +import javax.transaction.Synchronization; +import javax.transaction.Transaction; +import javax.transaction.TransactionManager; + +/** + * Created by IntelliJ IDEA. + * User: bela + * Date: Jun 9, 2004 + * Time: 9:05:19 AM + */ +(a)Test(groups =3D {"functional", "transaction"}) +public class PrepareTxTest +{ + CacheSPI cache; + + @BeforeMethod(alwaysRun =3D true) + public void setUp() throws Exception + { + CacheFactory instance =3D new DefaultCacheFactory(); + cache =3D (CacheSPI) instance.createCache(false); + cache.getConfiguration().setCacheMode("local"); + cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLock= ingScheme.PESSIMISTIC); + cache.getConfiguration().setTransactionManagerLookupClass(Transactio= nSetup.getManagerLookup()); + cache.create(); + cache.start(); + } + + @AfterMethod(alwaysRun =3D true) + public void tearDown() throws Exception + { + cache.stop(); + cache.destroy(); + } + + /** + * Tests cache modification inside the afterCompletion() callb= ack. Reproduces a bug fixed in + * connection with JBossCache being used as Hibernate's second level ca= che + * + * @throws Exception + * @throws NotSupportedException + */ + public void testCacheModificationInBeforeCompletionPhase() throws Excep= tion + { + int numLocks =3D 0; + TransactionManager mgr =3D cache.getTransactionManager(); + mgr.begin(); + Transaction tx =3D mgr.getTransaction(); + + // this will cause the cache to register with TransactionManager for= TX completion callbacks + cache.put("/one/two/three", "key1", "val1"); + numLocks =3D cache.getNumberOfLocksHeld(); + assertEquals(4, numLocks); + + // we register *second* + tx.registerSynchronization(new Synchronization() + { + + public void beforeCompletion() + { + try + { + cache.put("/a/b/c", null); + } + catch (CacheException e) + { + e.printStackTrace(); + } + } + + public void afterCompletion(int status) + { + } + }); + + mgr.commit(); + numLocks =3D cache.getNumberOfLocksHeld(); + assertEquals(0, numLocks); + + int num_local_txs, num_global_txs; + TransactionTable tx_table =3D cache.getTransactionTable(); + num_local_txs =3D tx_table.getNumLocalTransactions(); + num_global_txs =3D tx_table.getNumGlobalTransactions(); + System.out.println("Number of Transactions: " + num_local_txs + "\nN= umber of GlobalTransactions: " + num_global_txs + "\nTransactionTable:\n " + + tx_table.toString(true)); + assertEquals(num_local_txs, num_global_txs); + assertEquals(0, num_local_txs); + } + + /** + * Tests cache modification inside the afterCompletion() callb= ack. Reproduces a bug fixed in + * connection with JBossCache being used as Hibernate's second level ca= che + * + * @throws Exception + * @throws NotSupportedException + */ + public void testCacheModificationInAfterCompletionPhase() throws Except= ion + { + int numLocks =3D 0; + TransactionManager mgr =3D cache.getTransactionManager(); + mgr.begin(); + Transaction tx =3D mgr.getTransaction(); + + // this will cause the cache to register with TransactionManager for= TX completion callbacks + cache.put("/one/two/three", "key1", "val1"); + numLocks =3D cache.getNumberOfLocksHeld(); + assertEquals(4, numLocks); + + // we register *second* + tx.registerSynchronization(new Synchronization() + { + + public void beforeCompletion() + { + } + + public void afterCompletion(int status) + { + try + { + cache.put("/a/b/c", null); + } + catch (CacheException e) + { + e.printStackTrace(); + } + } + }); + + mgr.commit(); + numLocks =3D cache.getNumberOfLocksHeld(); + assertEquals(0, numLocks); + + int num_local_txs, num_global_txs; + TransactionTable tx_table =3D cache.getTransactionTable(); + num_local_txs =3D tx_table.getNumLocalTransactions(); + num_global_txs =3D tx_table.getNumGlobalTransactions(); + System.out.println("Number of Transactions: " + num_local_txs + "\nN= umber of GlobalTransactions: " + num_global_txs + "\nTransactionTable:\n " + + tx_table.toString(true)); + assertEquals(num_local_txs, num_global_txs); + assertEquals(0, num_local_txs); + } + +} Property changes on: core/trunk/src/test/java/org/jboss/cache/transaction/p= essimistic/PrepareTxTest.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Copied: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/St= atusUnknownTest.java (from rev 6585, core/trunk/src/test/java/org/jboss/cac= he/transaction/StatusUnknownTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/Status= UnknownTest.java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/Status= UnknownTest.java 2008-08-25 17:50:21 UTC (rev 6611) @@ -0,0 +1,165 @@ +package org.jboss.cache.transaction.pessimistic; + +import org.jboss.cache.Cache; +import org.jboss.cache.CacheSPI; +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.Fqn; +import org.jboss.cache.transaction.*; +import org.jboss.cache.config.Configuration; +import static org.testng.AssertJUnit.*; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.transaction.NotSupportedException; +import javax.transaction.RollbackException; +import javax.transaction.Status; +import javax.transaction.Synchronization; +import javax.transaction.SystemException; +import javax.transaction.Transaction; +import javax.transaction.TransactionManager; +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; + +/** + * This test checks how the cache behaves when a JTA STATUS_UNKNOWN is pas= sed in to the cache during afterCompletion(). + * + * @author Manik Surtani + */ +(a)Test(groups =3D "functional") +public class StatusUnknownTest +{ + private Cache cache; + private TransactionManager tm; + + @BeforeMethod(alwaysRun =3D true) + public void setUp() throws Exception + { + cache =3D new DefaultCacheFactory().createCache(fals= e); + cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLock= ingScheme.PESSIMISTIC); + cache.getConfiguration().setTransactionManagerLookupClass(HeuristicF= ailingDummyTransactionManagerLookup.class.getName()); + cache.start(); + tm =3D cache.getConfiguration().getRuntimeConfig().getTransactionMan= ager(); + } + + @AfterMethod(alwaysRun =3D true) + public void tearDown() + { + cache.stop(); + } + + public void testStatusUnknown() throws Exception + { + tm.begin(); + Fqn fqn =3D Fqn.fromString("/a/b/c"); + + cache.put(fqn, "k", "v"); + assertEquals(4, ((CacheSPI) cache).getNumberOfLocksHeld()); + assertTrue(cache.getRoot().hasChild(fqn)); + tm.commit(); + + assertEquals(0, ((CacheSPI) cache).getNumberOfLocksHeld()); + assertFalse(cache.getRoot().hasChild(fqn)); + } + + public static class HeuristicFailingDummyTransactionManager extends Dum= myTransactionManager + { + private static final long serialVersionUID =3D 6325631394461739211L; + + @Override + public void begin() throws SystemException, NotSupportedException + { + super.begin(); + + Transaction tx =3D new HeuristicFailingDummyTransaction(this); + setTransaction(tx); + } + + public static DummyTransactionManager getInstance() + { + if (instance =3D=3D null) + { + instance =3D new HeuristicFailingDummyTransactionManager(); + try + { + Properties p =3D new Properties(); + p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.cache.tra= nsaction.DummyContextFactory"); + Context ctx =3D new InitialContext(p); + ctx.bind("java:/TransactionManager", instance); + ctx.bind("UserTransaction", new DummyUserTransaction(instan= ce)); + } + catch (NamingException e) + { + log.error("binding of DummyTransactionManager failed", e); + } + } + return instance; + } + } + + public static class HeuristicFailingDummyTransaction extends DummyTrans= action + { + public HeuristicFailingDummyTransaction(DummyBaseTransactionManager = mgr) + { + super(mgr); + } + + @Override + public void commit() throws RollbackException + { + try + { + notifyBeforeCompletion(); + notifyAfterCompletion(Status.STATUS_UNKNOWN); + } + finally + { + // Disassociate tx from thread. + tm_.setTransaction(null); + } + } + + @Override + protected void notifyAfterCompletion(int status) + { + List tmp; + + synchronized (participants) + { + tmp =3D new LinkedList(participants); + } + + for (Synchronization s : tmp) + { + try + { + s.afterCompletion(status); + } + catch (Throwable t) + { + throw (RuntimeException) t; + } + } + + synchronized (participants) + { + participants.clear(); + } + } + } + + public static class HeuristicFailingDummyTransactionManagerLookup imple= ments TransactionManagerLookup + { + + public TransactionManager getTransactionManager() throws Exception + { + return HeuristicFailingDummyTransactionManager.getInstance(); + } + } +} + + --===============0702087407447238182==-- From jbosscache-commits at lists.jboss.org Mon Aug 25 16:09:55 2008 Content-Type: multipart/mixed; boundary="===============7785186809218053215==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6612 - core/trunk/src/main/java/org/jboss/cache. Date: Mon, 25 Aug 2008 16:09:54 -0400 Message-ID: --===============7785186809218053215== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: jason.greene(a)jboss.com Date: 2008-08-25 16:09:54 -0400 (Mon, 25 Aug 2008) New Revision: 6612 Modified: core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java Log: This was called getInstance() Modified: core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-= 08-25 17:50:21 UTC (rev 6611) +++ core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-= 08-25 20:09:54 UTC (rev 6612) @@ -42,7 +42,7 @@ @SuppressWarnings("unchecked") @Deprecated @Compat - public static DefaultCacheFactory newInstance() + public static DefaultCacheFactory getInstance() { return new DefaultCacheFactory(); } --===============7785186809218053215==-- From jboss-qa-internal at redhat.com Mon Aug 25 16:47:53 2008 Content-Type: multipart/mixed; boundary="===============2900982392849741326==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23563?= Date: Mon, 25 Aug 2008 16:47:50 -0400 Message-ID: <1984754479.16471219697270628.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 692138472.11831219595968652.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============2900982392849741326== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/563/changes --===============2900982392849741326==-- From jboss-qa-internal at redhat.com Mon Aug 25 17:05:40 2008 Content-Type: multipart/mixed; boundary="===============8443994215270273140==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23429?= Date: Mon, 25 Aug 2008 17:05:38 -0400 Message-ID: <446625537.16561219698338698.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 908234145.11811219595694493.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============8443994215270273140== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/429/changes --===============8443994215270273140==-- From jbosscache-commits at lists.jboss.org Mon Aug 25 18:08:48 2008 Content-Type: multipart/mixed; boundary="===============4698498669091455640==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6613 - core/trunk/src/main/java/org/jboss/cache/jmx. Date: Mon, 25 Aug 2008 18:08:47 -0400 Message-ID: --===============4698498669091455640== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: jason.greene(a)jboss.com Date: 2008-08-25 18:08:47 -0400 (Mon, 25 Aug 2008) New Revision: 6613 Added: core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java Log: Resurect JmxUtil for API compatibility Copied: core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java (from rev= 6545, core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java = (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java 2008-08-25 22= :08:47 UTC (rev 6613) @@ -0,0 +1,94 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.cache.jmx; + +import org.jboss.cache.config.Configuration; + +import javax.management.JMException; +import javax.management.MBeanServer; +import javax.management.ObjectName; + +/** + * Various JMX related utilities + * + * @author Jerry Gauthier + * @author Manik Surtani + * @version $Id$ + */ +(a)Deprecated +public class JmxUtil +{ + public static final String JBOSS_SERVER_DOMAIN =3D "jboss"; + public static final String JBOSS_CACHE_DOMAIN =3D "jboss.cache"; + public static final String SERVICE_KEY_NAME =3D "service"; + public static final String BASE_PREFIX =3D JBOSS_CACHE_DOMAIN + ":" + S= ERVICE_KEY_NAME + "=3DJBossCache"; + public static final String CLUSTER_KEY =3D "cluster"; + public static final String PREFIX =3D BASE_PREFIX + "," + CLUSTER_KEY += "=3D"; + public static final String UNIQUE_ID_KEY =3D "uniqueId"; + public static final String NO_CLUSTER_PREFIX =3D BASE_PREFIX + "," + UN= IQUE_ID_KEY + "=3D"; + public static final String CACHE_TYPE_KEY =3D "cacheType"; + public static final String PLAIN_CACHE_TYPE =3D "Cache"; + public static final String MBEAN_CLASS_SUFFIX =3D "MBean"; + public static final String JMX_RESOURCE_KEY =3D ",jmx-resource=3D"; + + public static void registerCacheMBean(MBeanServer server, CacheJmxWrapp= erMBean cache, String cacheObjectName) + throws JMException + { + ObjectName on =3D new ObjectName(cacheObjectName); + if (!server.isRegistered(on)) + { + server.registerMBean(cache, on); + } + } + + public static String getDefaultCacheObjectName(org.jboss.cache.Cache ca= che) + { + // get the cache's registration name + return getDefaultCacheObjectName(cache.getConfiguration(), cache.get= Class().getName()); + } + + public static String getDefaultCacheObjectName(Configuration config, St= ring cacheImplClass) + { + // get the cache's registration name + String tmpName; + if (config.getClusterName() =3D=3D null) + { + tmpName =3D NO_CLUSTER_PREFIX + getUniqueId(cacheImplClass); + } + else + { + tmpName =3D PREFIX + config.getClusterName(); + } + return tmpName; + } + + public static String getUniqueId(String cacheImplClass) + { + return cacheImplClass + System.currentTimeMillis(); + } + + public static void unregisterCacheMBean(MBeanServer server, String cach= eObjectName) + throws Exception + { + server.unregisterMBean(new ObjectName(cacheObjectName)); + } +} --===============4698498669091455640==-- From jbosscache-commits at lists.jboss.org Mon Aug 25 19:17:22 2008 Content-Type: multipart/mixed; boundary="===============5612552212579032597==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6614 - in core/trunk/src: main/java/org/jboss/cache/buddyreplication and 31 other directories. Date: Mon, 25 Aug 2008 19:17:22 -0400 Message-ID: --===============5612552212579032597== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: jason.greene(a)jboss.com Date: 2008-08-25 19:17:22 -0400 (Mon, 25 Aug 2008) New Revision: 6614 Added: core/trunk/src/main/java/org/jboss/cache/InvocationContext.java Removed: core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContext.ja= va Modified: core/trunk/src/main/java/org/jboss/cache/AbstractNodeFactory.java core/trunk/src/main/java/org/jboss/cache/Cache.java core/trunk/src/main/java/org/jboss/cache/CacheSPI.java core/trunk/src/main/java/org/jboss/cache/Fqn.java core/trunk/src/main/java/org/jboss/cache/NodeFactory.java core/trunk/src/main/java/org/jboss/cache/NodeSPI.java core/trunk/src/main/java/org/jboss/cache/PessimisticUnversionedNode.java core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVi= sitor.java core/trunk/src/main/java/org/jboss/cache/commands/AbstractVisitor.java core/trunk/src/main/java/org/jboss/cache/commands/ReplicableCommand.java core/trunk/src/main/java/org/jboss/cache/commands/VisitableCommand.java core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java core/trunk/src/main/java/org/jboss/cache/commands/legacy/read/PessGetChi= ldrenNamesCommand.java core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/CreateNod= eCommand.java core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/LegacyEvi= ctCommand.java core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessClear= DataCommand.java core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessMoveC= ommand.java core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessPutDa= taMapCommand.java core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessPutFo= rExternalReadCommand.java core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessPutKe= yValueCommand.java core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessRemov= eKeyCommand.java core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessRemov= eNodeCommand.java core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/Versioned= InvalidateCommand.java core/trunk/src/main/java/org/jboss/cache/commands/read/ExistsCommand.java core/trunk/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesC= ommand.java core/trunk/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand= .java core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeyValueComman= d.java core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.ja= va core/trunk/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.ja= va core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataComm= and.java core/trunk/src/main/java/org/jboss/cache/commands/remote/AnnounceBuddyPo= olNameCommand.java core/trunk/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyGr= oupCommand.java core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCom= mand.java core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitation= CleanupCommand.java core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoveFromBuddy= GroupCommand.java core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateComman= d.java core/trunk/src/main/java/org/jboss/cache/commands/tx/AbstractTransaction= Command.java core/trunk/src/main/java/org/jboss/cache/commands/tx/CommitCommand.java core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCo= mmand.java core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java core/trunk/src/main/java/org/jboss/cache/commands/tx/RollbackCommand.java core/trunk/src/main/java/org/jboss/cache/commands/write/AbstractVersione= dDataCommand.java core/trunk/src/main/java/org/jboss/cache/commands/write/ClearDataCommand= .java core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java core/trunk/src/main/java/org/jboss/cache/commands/write/InvalidateComman= d.java core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapComman= d.java core/trunk/src/main/java/org/jboss/cache/commands/write/PutForExternalRe= adCommand.java core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueComma= nd.java core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand= .java core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeComman= d.java core/trunk/src/main/java/org/jboss/cache/factories/context/ContextFactor= y.java core/trunk/src/main/java/org/jboss/cache/factories/context/MVCCContextFa= ctory.java core/trunk/src/main/java/org/jboss/cache/factories/context/PessimisticCo= ntextFactory.java core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationIntercep= tor.java core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor= .java core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalC= ontextInterceptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/BatchingIntercepto= r.java core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterce= ptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtIntercept= or.java core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreIntercep= tor.java core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.ja= va core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInte= rceptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionIntercepto= r.java core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorChain.j= ava core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterc= eptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextI= nterceptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyActivationIn= terceptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyCacheLoaderI= nterceptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyDataGravitat= orInterceptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyPassivationI= nterceptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterce= ptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueInt= erceptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/NotificationInterc= eptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIf= NotExistsInterceptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticIntercep= tor.java core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingI= nterceptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInte= rceptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicat= ionInterceptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticTxInterc= eptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidato= rInterceptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterce= ptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInt= erceptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterce= ptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/base/CommandInterc= eptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/base/PrePostProces= singCommandInterceptor.java core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChai= nedInterceptor.java core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationCo= ntext.java core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDe= legate.java core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDeleg= ate.java core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContextCon= tainer.java core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationCont= ext.java core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContex= t.java core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelega= te.java core/trunk/src/main/java/org/jboss/cache/lock/AbstractLockManager.java core/trunk/src/main/java/org/jboss/cache/lock/FqnLockManager.java core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java core/trunk/src/main/java/org/jboss/cache/lock/LockUtil.java core/trunk/src/main/java/org/jboss/cache/lock/MVCCLockManager.java core/trunk/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java core/trunk/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockMa= nager.java core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatc= her.java core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTrans= ferIntegrator.java core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransf= erIntegrator.java core/trunk/src/main/java/org/jboss/cache/transaction/MVCCTransactionCont= ext.java core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.= java core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.ja= va core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java core/trunk/src/test/java/org/jboss/cache/api/SyncReplTxTest.java core/trunk/src/test/java/org/jboss/cache/commands/TestContextBase.java core/trunk/src/test/java/org/jboss/cache/commands/legacy/read/GravitateD= ataCommandTest.java core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/PutDataMa= pCommandTest.java core/trunk/src/test/java/org/jboss/cache/commands/read/AbstractDataComma= ndTest.java core/trunk/src/test/java/org/jboss/cache/commands/read/GetKeyValueComman= dTest.java core/trunk/src/test/java/org/jboss/cache/commands/write/AbstractVersione= dDataCommandTest.java core/trunk/src/test/java/org/jboss/cache/interceptors/LegacyInterceptorT= est.java core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordi= ngTest.java core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.ja= va core/trunk/src/test/java/org/jboss/cache/mock/NodeSpiMock.java core/trunk/src/test/java/org/jboss/cache/notifications/NotifierTest.java core/trunk/src/test/java/org/jboss/cache/optimistic/ConcurrentTransactio= nTest.java core/trunk/src/test/java/org/jboss/cache/optimistic/MockFailureIntercept= or.java core/trunk/src/test/java/org/jboss/cache/optimistic/MockInterceptor.java core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterc= eptorTest.java core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptor= Test.java core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationListe= ner.java Log: Fix more BC issues Move InvocationContext to org.jboss.cache, where it was originally Improve Generics usage on Fqn to be friendlier and BC Modified: core/trunk/src/main/java/org/jboss/cache/AbstractNodeFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/AbstractNodeFactory.java 2008-= 08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/AbstractNodeFactory.java 2008-= 08-25 23:17:22 UTC (rev 6614) @@ -11,7 +11,6 @@ import org.jboss.cache.factories.ComponentRegistry; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.interceptors.InterceptorChain; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.invocation.InvocationContextContainer; import org.jboss.cache.invocation.NodeInvocationDelegate; import org.jboss.cache.mvcc.ReadCommittedNode; Modified: core/trunk/src/main/java/org/jboss/cache/Cache.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/Cache.java 2008-08-25 22:08:47= UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/Cache.java 2008-08-25 23:17:22= UTC (rev 6614) @@ -8,7 +8,6 @@ = import net.jcip.annotations.ThreadSafe; import org.jboss.cache.config.Configuration; -import org.jboss.cache.invocation.InvocationContext; import org.jgroups.Address; = import java.util.List; @@ -352,7 +351,7 @@ InvocationContext getInvocationContext(); = /** - * Sets the passed in {@link org.jboss.cache.invocation.InvocationConte= xt} as current. + * Sets the passed in {@link org.jboss.cache.InvocationContext} as curr= ent. * * @param ctx invocation context to use * @throws IllegalStateException if the cache has been destroyed. Modified: core/trunk/src/main/java/org/jboss/cache/CacheSPI.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/CacheSPI.java 2008-08-25 22:08= :47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/CacheSPI.java 2008-08-25 23:17= :22 UTC (rev 6614) @@ -10,7 +10,6 @@ import org.jboss.cache.buddyreplication.BuddyManager; import org.jboss.cache.buddyreplication.GravitateResult; import org.jboss.cache.interceptors.base.CommandInterceptor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.loader.CacheLoader; import org.jboss.cache.loader.CacheLoaderManager; import org.jboss.cache.marshall.Marshaller; Modified: core/trunk/src/main/java/org/jboss/cache/Fqn.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/Fqn.java 2008-08-25 22:08:47 U= TC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/Fqn.java 2008-08-25 23:17:22 U= TC (rev 6614) @@ -79,14 +79,14 @@ */ @Immutable @Compat(notes =3D "The generics, while originally intended to be removed i= n 3.0, have been retained for backward compat.") -public class Fqn implements Comparable, Externalizable +public class Fqn implements Comparable>, Externalizable { /** * Separator between FQN elements. */ public static final String SEPARATOR =3D "/"; = - protected List elements; + protected List elements; private transient int hash_code =3D 0; protected int size =3D 0; = @@ -121,7 +121,7 @@ */ @Deprecated @Compat - public Fqn(List names) + public Fqn(List names) { // the list is unsafe - may be referenced externally this(names, false); @@ -150,7 +150,7 @@ */ @Deprecated @Compat - public Fqn(Fqn base, Fqn relative) + public Fqn(Fqn base, Fqn relative) { this(base, relative.elements); } @@ -164,7 +164,7 @@ */ @Deprecated @Compat - public Fqn(Fqn base, E... childNames) + public Fqn(Fqn base, E... childNames) { this(base, Arrays.asList(childNames)); } @@ -183,12 +183,12 @@ @Deprecated @Compat(notes =3D "Not truly deprecated, this constructor should really= be protected and not public. Marked as deprecated for anyone using it as = a public API.") @SuppressWarnings("unchecked") - protected Fqn(List names, boolean safe) + protected Fqn(List names, boolean safe) { if (names !=3D null) { // if not safe make a defensive copy - elements =3D safe ? (List) names : Immutables.immutableLi= stCopy(names); + elements =3D safe ? (List)names : Immutables.immutableListCopy= (names); size =3D elements.size(); } else @@ -198,7 +198,7 @@ } } = - protected Fqn(Fqn base, List relative) + protected Fqn(Fqn base, List relative) { elements =3D Immutables.immutableListMerge(base.elements, relative); size =3D elements.size(); @@ -214,9 +214,9 @@ * @since 2.2.0 */ @SuppressWarnings("unchecked") - public static Fqn fromList(List names) + public static Fqn fromList(List names) { - return new Fqn(names, false); + return new Fqn(names, false); } = /** @@ -230,9 +230,9 @@ * @return an Fqn */ @SuppressWarnings("unchecked") - public static Fqn fromList(List names, boolean safe) + public static Fqn fromList(List names, boolean safe) { - return new Fqn(names, safe); + return new Fqn(names, safe); } = /** @@ -242,9 +242,9 @@ * @return an Fqn * @since 2.2.0 */ - public static Fqn fromElements(Object... elements) + public static Fqn fromElements(T... elements) { - return new Fqn(Arrays.asList(elements), true); + return new Fqn(Arrays.asList(elements), true); } = /** @@ -255,9 +255,9 @@ * @return an Fqn * @since 2.2.0 */ - public static Fqn fromRelativeFqn(Fqn base, Fqn relative) + public static Fqn fromRelativeFqn(Fqn base, Fqn relative) { - return new Fqn(base, relative.elements); + return new Fqn(base, relative.elements); } = /** @@ -268,9 +268,9 @@ * @return an Fqn * @since 2.2.0 */ - public static Fqn fromRelativeList(Fqn base, List relativeElements) + public static Fqn fromRelativeList(Fqn base, List relativeElements) { - return new Fqn(base, relativeElements); + return new Fqn(base, relativeElements); } = /** @@ -281,9 +281,9 @@ * @return an Fqn * @since 2.2.0 */ - public static Fqn fromRelativeElements(Fqn base, Object... relativeElem= ents) + public static Fqn fromRelativeElements(Fqn base, T.= .. relativeElements) { - return new Fqn(base, Arrays.asList(relativeElements)); + return new Fqn(base, Arrays.asList(relativeElements)); } = /** @@ -302,7 +302,7 @@ * @return an Fqn constructed from the string representation pa= ssed in */ @SuppressWarnings("unchecked") - public static Fqn fromString(String stringRepresentation) + public static Fqn fromString(String stringRepresentation) { if (stringRepresentation =3D=3D null || stringRepresentation.equals(= SEPARATOR) || stringRepresentation.equals("")) return root(); @@ -321,9 +321,9 @@ * @throws ClassNotFoundException in the event of classes that comprise= the element list of this Fqn not being found * @since 2.2.0 */ - public static Fqn fromExternalStream(ObjectInput in) throws IOException= , ClassNotFoundException + public static Fqn fromExternalStream(ObjectInput in) throws IOExcept= ion, ClassNotFoundException { - Fqn f =3D new Fqn(); + Fqn f =3D new Fqn(); f.readExternal(in); return f; } @@ -352,7 +352,7 @@ * @param generation the generation of the ancestor to retrieve * @return an ancestor of the current Fqn */ - public Fqn getAncestor(int generation) + public Fqn getAncestor(int generation) { if (generation =3D=3D 0) return root(); return getSubFqn(0, generation); @@ -365,10 +365,10 @@ * @param endIndex end index * @return a subFqn */ - public Fqn getSubFqn(int startIndex, int endIndex) + public Fqn getSubFqn(int startIndex, int endIndex) { - List el =3D elements.subList(startIndex, endIndex); - return new Fqn(el, true); + List el =3D elements.subList(startIndex, endIndex); + return new Fqn(el, true); } = /** @@ -421,7 +421,7 @@ { return false; } - Fqn other =3D (Fqn) obj; + Fqn other =3D (Fqn) obj; return size =3D=3D other.size() && elements.equals(other.elements); } = @@ -470,8 +470,8 @@ public void readExternal(ObjectInput in) throws IOException, ClassNotFo= undException { size =3D in.readShort(); - this.elements =3D new ArrayList(size); - for (int i =3D 0; i < size; i++) elements.add(in.readObject()); + this.elements =3D new ArrayList(size); + for (int i =3D 0; i < size; i++) elements.add((E)in.readObject()); } = = @@ -489,7 +489,7 @@ * @param parentFqn candidate parent to test against * @return true if the target is a child of parentFqn */ - public boolean isChildOf(Fqn parentFqn) + public boolean isChildOf(Fqn parentFqn) { return parentFqn.size() !=3D size && isChildOrEquals(parentFqn); } @@ -501,7 +501,7 @@ * @param parentFqn parentFqn to compare with * @return true if this is a direct child, false otherwise. */ - public boolean isDirectChildOf(Fqn parentFqn) + public boolean isDirectChildOf(Fqn parentFqn) { return size =3D=3D parentFqn.size() + 1 && isChildOf(parentFqn); } @@ -520,9 +520,9 @@ * @param parentFqn candidate parent to test against * @return true if this Fqn is equals or the child of parentFqn. */ - public boolean isChildOrEquals(Fqn parentFqn) + public boolean isChildOrEquals(Fqn parentFqn) { - List parentList =3D parentFqn.elements; + List parentList =3D parentFqn.elements; if (parentList.size() > size) { return false; @@ -550,7 +550,7 @@ return hashCode; } = - protected String getStringRepresentation(List elements) + protected String getStringRepresentation(List elements) { StringBuilder builder =3D new StringBuilder(); for (Object e : elements) @@ -580,7 +580,7 @@ * * @return the parent Fqn */ - public Fqn getParent() + public Fqn getParent() { switch (size) { @@ -592,7 +592,7 @@ } } = - public static final Fqn root() // declared final so compilers can opti= mise and in-line. + public static final Fqn root() // declared final so compilers c= an optimise and in-line. { return ROOT; } @@ -634,7 +634,7 @@ * * @return an unmodifiable list */ - public List peekElements() + public List peekElements() { return elements; } @@ -642,7 +642,7 @@ /** * Compares this Fqn to another using {@link FqnComparator}. */ - public int compareTo(Fqn fqn) + public int compareTo(Fqn fqn) { return FqnComparator.INSTANCE.compare(this, fqn); } @@ -654,11 +654,11 @@ * @param newAncestor nw ancestor to replace with * @return a new Fqn with ancestors replaced. */ - public Fqn replaceAncestor(Fqn oldAncestor, Fqn newAncestor) + public Fqn replaceAncestor(Fqn oldAncestor, Fqn newAncestor) { if (!isChildOf(oldAncestor)) throw new IllegalArgumentException("Old ancestor must be an ances= tor of the current Fqn!"); - Fqn subFqn =3D this.getSubFqn(oldAncestor.size(), size()); + Fqn subFqn =3D this.getSubFqn(oldAncestor.size(), size()); return Fqn.fromRelativeFqn(newAncestor, subFqn); } } \ No newline at end of file Copied: core/trunk/src/main/java/org/jboss/cache/InvocationContext.java (fr= om rev 6611, core/trunk/src/main/java/org/jboss/cache/invocation/Invocation= Context.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/InvocationContext.java = (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-08= -25 23:17:22 UTC (rev 6614) @@ -0,0 +1,314 @@ +package org.jboss.cache; + +import org.jboss.cache.commands.VisitableCommand; +import org.jboss.cache.config.Option; +import org.jboss.cache.marshall.MethodCall; +import org.jboss.cache.transaction.GlobalTransaction; +import org.jboss.cache.transaction.TransactionContext; + +import javax.transaction.Transaction; +import java.util.List; +import java.util.Map; + +/** + * A context that holds information regarding the scope of a single invoca= tion. May delegate some calls to a {@link org.jboss.cache.transaction.Tran= sactionContext} + * if one is in scope. + *

    + * Note that prior to 3.0.0, InvocationContext was a concrete class and no= t an interface. + *

    + * + * @author Manik Surtani (manik(a)jbo= ss.org) + * @see org.jboss.cache.transaction.TransactionContext + */ +(a)SuppressWarnings("deprecation") +public interface InvocationContext +{ + /** + * Retrieves a node from the registry of looked up nodes in the current= scope. + * + * @param fqn fqn to look up + * @return a node, or null if it cannot be found. + * @since 3.0. + */ + NodeSPI lookUpNode(Fqn fqn); + + /** + * Puts an entry in the registry of looked up nodes in the current scop= e. + * + * @param f fqn to add + * @param n node to add + * @since 3.0. + */ + void putLookedUpNode(Fqn f, NodeSPI n); + + /** + * Clears the registry of looked up nodes. + * + * @since 3.0. + */ + void clearLookedUpNodes(); + + /** + * Retrieves a map of nodes looked up within the current invocation's s= cope. + * + * @return a map of looked up nodes. + * @since 3.0 + */ + Map getLookedUpNodes(); + + /** + * Marks teh context as only rolling back. + * + * @param localRollbackOnly if true, the context is only rolling back. + */ + void setLocalRollbackOnly(boolean localRollbackOnly); + + /** + * Retrieves the transaction associated with this invocation + * + * @return The transaction associated with this invocation + */ + Transaction getTransaction(); + + /** + * Sets a transaction object on the invocation context. + * + * @param transaction transaction to set + */ + void setTransaction(Transaction transaction); + + /** + * @return the transaction entry associated with the current transactio= n, or null if the current thread is not associated with a transaction. + * @since 2.2.0 + */ + TransactionContext getTransactionContext(); + + /** + * Sets the transaction context to be associated with the current threa= d. + * + * @param transactionContext transaction context to set + * @since 2.2.0 + */ + void setTransactionContext(TransactionContext transactionContext); + + /** + * Retrieves the global transaction associated with this invocation + * + * @return the global transaction associated with this invocation + */ + GlobalTransaction getGlobalTransaction(); + + /** + * Sets the global transaction associated with this invocation + * + * @param globalTransaction global transaction to set + */ + void setGlobalTransaction(GlobalTransaction globalTransaction); + + /** + * Retrieves the option overrides associated with this invocation + * + * @return the option overrides associated with this invocation + */ + Option getOptionOverrides(); + + /** + * @return true of no options have been set on this context, false othe= rwise. + */ + boolean isOptionsUninitialised(); + + /** + * Sets the option overrides to be associated with this invocation + * + * @param optionOverrides options to set + */ + void setOptionOverrides(Option optionOverrides); + + /** + * Tests if this invocation originated locally or from a remote cache. + * + * @return true if the invocation originated locally. + */ + boolean isOriginLocal(); + + /** + * Returns an immutable, defensive copy of the List of locks currently= maintained for the current scope. + *

    + * Note that if a transaction is in scope, implementations should retri= eve these locks from the {@link org.jboss.cache.transaction.TransactionCont= ext}. + * Retrieving locks from this method should always ensure they are retr= ieved from the appropriate scope. + *

    + * Note that currently (as of 3.0.0) this list is unchecked. This is t= o allow support for both MVCC (which uses Fqns as locks) + * as well as legacy Optimistic and Pessimistic Locking schemes (which = use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for + * legacy node locking schemes are dropped, this method will be more st= rongly typed to return List. + * + * @return locks held in current scope. + */ + @SuppressWarnings("unchecked") + List getLocks(); + + /** + * Adds a List of locks to the currently maintained collection of locks= acquired. + *

    + * Note that if a transaction is in scope, implementations should recor= d locks on the {@link org.jboss.cache.transaction.TransactionContext}. + * Adding locks using this method should always ensure they are applied= to the appropriate scope. + *

    + * Note that currently (as of 3.0.0) this list is unchecked. This is t= o allow support for both MVCC (which uses Fqns as locks) + * as well as legacy Optimistic and Pessimistic Locking schemes (which = use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for + * legacy node locking schemes are dropped, this method will be more st= rongly typed to accept List. + * + * @param locks locks to add + */ + @SuppressWarnings("unchecked") + void addAllLocks(List locks); + + /** + * Adds a lock to the currently maintained collection of locks acquired. + *

    + * Note that if a transaction is in scope, implementations should recor= d this lock on the {@link org.jboss.cache.transaction.TransactionContext}. + * Using this method should always ensure that the appropriate scope is= used. + *

    + * Note that currently (as of 3.0.0) this lock is weakly typed. This i= s to allow support for both MVCC (which uses {@link Fqn}s as locks) + * as well as legacy Optimistic and Pessimistic Locking schemes (which = use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for + * legacy node locking schemes are dropped, this method will be more st= rongly typed to accept {@link Fqn}. + * + * @param lock lock to add + */ + @SuppressWarnings("unchecked") + void addLock(Object lock); + + /** + * Removes a lock from the currently maintained collection of locks acq= uired. + *

    + * Note that if a transaction is in scope, implementations should remov= e this lock from the {@link org.jboss.cache.transaction.TransactionContext}. + * Using this method should always ensure that the lock is removed from= the appropriate scope. + *

    + * Note that currently (as of 3.0.0) this lock is weakly typed. This i= s to allow support for both MVCC (which uses {@link Fqn}s as locks) + * as well as legacy Optimistic and Pessimistic Locking schemes (which = use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for + * legacy node locking schemes are dropped, this method will be more st= rongly typed to accept {@link Fqn}. + * + * @param lock lock to remove + */ + @SuppressWarnings("unchecked") + void removeLock(Object lock); + + /** + * Clears all locks from the currently maintained collection of locks a= cquired. + *

    + * Note that if a transaction is in scope, implementations should clear= locks from the {@link org.jboss.cache.transaction.TransactionContext}. + * Using this method should always ensure locks are cleared in the appr= opriate scope. + *

    + * Note that currently (as of 3.0.0) this lock is weakly typed. This i= s to allow support for both MVCC (which uses {@link Fqn}s as locks) + * as well as legacy Optimistic and Pessimistic Locking schemes (which = use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for + * legacy node locking schemes are dropped, this method will be more st= rongly typed to accept {@link Fqn}. + */ + void clearLocks(); + + + /** + * Note that if a transaction is in scope, implementations should test = this lock from on {@link org.jboss.cache.transaction.TransactionContext}. + * Using this method should always ensure locks checked in the appropri= ate scope. + * + * @param lock lock to test + * @return true if the lock being tested is already held in the current= scope, false otherwise. + */ + boolean hasLock(Object lock); + + /** + * @return true if options exist to suppress locking - false otherwise.= Note that this is only used by the {@link org.jboss.cache.interceptors.Pe= ssimisticLockInterceptor}. + */ + boolean isLockingSuppressed(); + + /** + * If set to true, the invocation is assumed to have originated locally= . If set to false, + * assumed to have originated from a remote cache. + * + * @param originLocal flag to set + */ + void setOriginLocal(boolean originLocal); + + /** + * @return true if the current transaction is set to rollback only. + */ + boolean isLocalRollbackOnly(); + + /** + * Resets the context, freeing up any references. + */ + void reset(); + + /** + * This is a "copy-factory-method" that should be used whenever a clone= of this class is needed. The resulting instance + * is equal() to, but not =3D=3D, to the InvocationContext invoked on. = Note that this is a shallow copy with the exception + * of the Option object, which is deep, as well as any collections held= on the context such as locks. Note that the reference + * to a {@link org.jboss.cache.transaction.TransactionContext}, if any,= is maintained. + * + * @return a new InvocationContext + */ + @SuppressWarnings("unchecked") + InvocationContext copy(); + + /** + * Sets the state of the InvocationContext based on the template contex= t passed in + * + * @param template template to copy from + */ + void setState(InvocationContext template); + + /** + * @return the method call associated with this invocation + */ + @Deprecated + @SuppressWarnings("deprecation") + MethodCall getMethodCall(); + + + /** + * Sets the method call associated with this invocation. + * + * @param methodCall methodcall to set + * @deprecated not used anymore. Interceptors will get a {@link org.jb= oss.cache.commands.ReplicableCommand} instance passed in along with an Invo= cationContext. + */ + @Deprecated + void setMethodCall(MethodCall methodCall); + + /** + * If the lock acquisition timeout is overridden for current call using= an option, then return that one. + * If not overridden, return default value. + * + * @param defaultTimeout timeout to fall back to + * @return timeout to use + */ + long getLockAcquisitionTimeout(long defaultTimeout); + + /** + * This is only used for backward compatibility with old interceptors i= mplementation and should NOT be + * use by any new custom interceptors. The commands is now passed in as= the second param in each implementing + * handlers (handler =3D method in ChainedInterceptor class) + * + * @param cacheCommand command to set + */ + @Deprecated + @SuppressWarnings("deprecation") + void setCommand(VisitableCommand cacheCommand); + + /** + * @return command that is in scope + * @see #setCommand(org.jboss.cache.commands.VisitableCommand) + */ + @Deprecated + @SuppressWarnings("deprecation") + VisitableCommand getCommand(); + + /** + * @return true if there is current transaction associated with the inv= ocation, and this transaction is in a valid state. + */ + boolean isValidTransaction(); + + /** + * Throws the given throwable provided no options suppress or prevent t= his from happening. + * + * @param throwable throwable to throw + * @throws Throwable if allowed to throw one. + */ + void throwIfNeeded(Throwable throwable) throws Throwable; +} Modified: core/trunk/src/main/java/org/jboss/cache/NodeFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/NodeFactory.java 2008-08-25 22= :08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/NodeFactory.java 2008-08-25 23= :17:22 UTC (rev 6614) @@ -1,6 +1,5 @@ package org.jboss.cache; = -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.mvcc.ReadCommittedNode; import org.jboss.cache.optimistic.TransactionWorkspace; import org.jboss.cache.optimistic.WorkspaceNode; Modified: core/trunk/src/main/java/org/jboss/cache/NodeSPI.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/NodeSPI.java 2008-08-25 22:08:= 47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/NodeSPI.java 2008-08-25 23:17:= 22 UTC (rev 6614) @@ -7,7 +7,6 @@ package org.jboss.cache; = import net.jcip.annotations.NotThreadSafe; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.lock.NodeLock; import org.jboss.cache.optimistic.DataVersion; import org.jboss.cache.transaction.GlobalTransaction; Modified: core/trunk/src/main/java/org/jboss/cache/PessimisticUnversionedNo= de.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/PessimisticUnversionedNode.jav= a 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/PessimisticUnversionedNode.jav= a 2008-08-25 23:17:22 UTC (rev 6614) @@ -10,7 +10,6 @@ = import org.jboss.cache.commands.CommandsFactory; import org.jboss.cache.commands.legacy.write.CreateNodeCommand; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.lock.IdentityLock; import org.jboss.cache.lock.LockStrategyFactory; import org.jboss.cache.marshall.MarshalledValue; Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-08-25= 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-08-25= 23:17:22 UTC (rev 6614) @@ -17,7 +17,6 @@ import org.jboss.cache.factories.annotations.Start; import org.jboss.cache.factories.annotations.Stop; import org.jboss.cache.interceptors.InterceptorChain; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.invocation.InvocationContextContainer; import org.jboss.cache.lock.LockManager; import org.jboss.cache.lock.LockUtil; Modified: core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-08= -25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-08= -25 23:17:22 UTC (rev 6614) @@ -15,7 +15,6 @@ import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; import org.jboss.cache.factories.annotations.Stop; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.lock.LockManager; import static org.jboss.cache.lock.LockType.WRITE; import org.jboss.cache.util.concurrent.locks.LockContainer; Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2Bud= dyFqnVisitor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnV= isitor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnV= isitor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,6 +1,7 @@ package org.jboss.cache.buddyreplication; = import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.AbstractVisitor; import org.jboss.cache.commands.CommandsFactory; import org.jboss.cache.commands.WriteCommand; @@ -25,7 +26,6 @@ import org.jboss.cache.commands.write.PutKeyValueCommand; import org.jboss.cache.commands.write.RemoveKeyCommand; import org.jboss.cache.commands.write.RemoveNodeCommand; -import org.jboss.cache.invocation.InvocationContext; = import java.util.ArrayList; import java.util.List; Modified: core/trunk/src/main/java/org/jboss/cache/commands/AbstractVisitor= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/AbstractVisitor.java = 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/AbstractVisitor.java = 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,5 +1,6 @@ package org.jboss.cache.commands; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.legacy.write.CreateNodeCommand; import org.jboss.cache.commands.read.ExistsCommand; import org.jboss.cache.commands.read.GetChildrenNamesCommand; @@ -21,7 +22,6 @@ import org.jboss.cache.commands.write.PutKeyValueCommand; import org.jboss.cache.commands.write.RemoveKeyCommand; import org.jboss.cache.commands.write.RemoveNodeCommand; -import org.jboss.cache.invocation.InvocationContext; = import java.util.Collection; = Modified: core/trunk/src/main/java/org/jboss/cache/commands/ReplicableComma= nd.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/ReplicableCommand.jav= a 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/ReplicableCommand.jav= a 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,6 +1,6 @@ package org.jboss.cache.commands; = -import org.jboss.cache.invocation.InvocationContext; +import org.jboss.cache.InvocationContext; = /** * The core of the command-based cache framework. Commands correspond to = specific areas of functionality in the cache, Modified: core/trunk/src/main/java/org/jboss/cache/commands/VisitableComman= d.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/VisitableCommand.java= 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/VisitableCommand.java= 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,6 +1,6 @@ package org.jboss.cache.commands; = -import org.jboss.cache.invocation.InvocationContext; +import org.jboss.cache.InvocationContext; = /** * A type of command that can accept {@link org.jboss.cache.commands.Visit= or}s, such as {@link org.jboss.cache.interceptors.base.CommandInterceptor}s. Modified: core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java 2008-08-= 25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java 2008-08-= 25 23:17:22 UTC (rev 6614) @@ -1,5 +1,6 @@ package org.jboss.cache.commands; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.legacy.write.CreateNodeCommand; import org.jboss.cache.commands.read.ExistsCommand; import org.jboss.cache.commands.read.GetChildrenNamesCommand; @@ -21,7 +22,6 @@ import org.jboss.cache.commands.write.PutKeyValueCommand; import org.jboss.cache.commands.write.RemoveKeyCommand; import org.jboss.cache.commands.write.RemoveNodeCommand; -import org.jboss.cache.invocation.InvocationContext; = /** * This interface is the core of JBoss Cache, where each {@link VisitableC= ommand} can be visited by a Visitor implementation. Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/read/Pes= sGetChildrenNamesCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/legacy/read/PessGetCh= ildrenNamesCommand.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/read/PessGetCh= ildrenNamesCommand.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,10 +1,10 @@ package org.jboss.cache.commands.legacy.read; = import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.Node; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.read.GetChildrenNamesCommand; -import org.jboss.cache.invocation.InvocationContext; = import java.util.Collection; import java.util.Collections; Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/Cr= eateNodeCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/CreateNo= deCommand.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/CreateNo= deCommand.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,12 +1,12 @@ package org.jboss.cache.commands.legacy.write; = import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.Visitor; import org.jboss.cache.commands.WriteCommand; import org.jboss.cache.commands.legacy.ReversibleCommand; import org.jboss.cache.commands.read.AbstractDataCommand; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.transaction.GlobalTransaction; = import java.util.LinkedList; Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/Le= gacyEvictCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/LegacyEv= ictCommand.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/LegacyEv= ictCommand.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,9 +1,9 @@ package org.jboss.cache.commands.legacy.write; = import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.write.EvictCommand; -import org.jboss.cache.invocation.InvocationContext; = import java.util.Collection; = Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/Pe= ssClearDataCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessClea= rDataCommand.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessClea= rDataCommand.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,10 +1,10 @@ package org.jboss.cache.commands.legacy.write; = import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.legacy.ReversibleCommand; import org.jboss.cache.commands.write.ClearDataCommand; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.transaction.GlobalTransaction; = import java.util.HashMap; Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/Pe= ssMoveCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessMove= Command.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessMove= Command.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,11 +1,11 @@ package org.jboss.cache.commands.legacy.write; = import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeNotExistsException; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.legacy.ReversibleCommand; import org.jboss.cache.commands.write.MoveCommand; -import org.jboss.cache.invocation.InvocationContext; = /** * A version of {@link org.jboss.cache.commands.write.MoveCommand} which c= an be rolled back, for use with Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/Pe= ssPutDataMapCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessPutD= ataMapCommand.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessPutD= ataMapCommand.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,10 +1,10 @@ package org.jboss.cache.commands.legacy.write; = import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.legacy.ReversibleCommand; import org.jboss.cache.commands.write.PutDataMapCommand; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.transaction.GlobalTransaction; = import java.util.HashMap; Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/Pe= ssPutForExternalReadCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessPutF= orExternalReadCommand.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessPutF= orExternalReadCommand.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -2,10 +2,10 @@ = import org.jboss.cache.CacheException; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.legacy.ReversibleCommand; import org.jboss.cache.commands.write.PutForExternalReadCommand; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.transaction.GlobalTransaction; = /** Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/Pe= ssPutKeyValueCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessPutK= eyValueCommand.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessPutK= eyValueCommand.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -2,10 +2,10 @@ = import org.jboss.cache.CacheException; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.legacy.ReversibleCommand; import org.jboss.cache.commands.write.PutKeyValueCommand; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.transaction.GlobalTransaction; = /** Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/Pe= ssRemoveKeyCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessRemo= veKeyCommand.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessRemo= veKeyCommand.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,10 +1,10 @@ package org.jboss.cache.commands.legacy.write; = import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.legacy.ReversibleCommand; import org.jboss.cache.commands.write.RemoveKeyCommand; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.transaction.GlobalTransaction; = /** Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/Pe= ssRemoveNodeCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessRemo= veNodeCommand.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessRemo= veNodeCommand.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,10 +1,10 @@ package org.jboss.cache.commands.legacy.write; = import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.legacy.ReversibleCommand; import org.jboss.cache.commands.write.RemoveNodeCommand; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.transaction.GlobalTransaction; = import java.util.HashMap; Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/Ve= rsionedInvalidateCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/Versione= dInvalidateCommand.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/Versione= dInvalidateCommand.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -4,11 +4,11 @@ import org.apache.commons.logging.LogFactory; import org.jboss.cache.CacheException; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.VersionedDataCommand; import org.jboss.cache.commands.write.InvalidateCommand; import org.jboss.cache.config.Option; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.optimistic.DataVersion; import org.jboss.cache.optimistic.DataVersioningException; import org.jboss.cache.transaction.GlobalTransaction; Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/ExistsComm= and.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/read/ExistsCommand.ja= va 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/read/ExistsCommand.ja= va 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,8 +1,8 @@ package org.jboss.cache.commands.read; = import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.Visitor; -import org.jboss.cache.invocation.InvocationContext; = /** * Checks whether a given node exists in current in-memory state of the ca= che. Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GetChildre= nNamesCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/read/GetChildrenNames= Command.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetChildrenNames= Command.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -4,9 +4,9 @@ import org.apache.commons.logging.LogFactory; import org.jboss.cache.Fqn; import org.jboss.cache.InternalNode; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.Visitor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.mvcc.ReadCommittedNode; = import java.util.Collection; Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GetDataMap= Command.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/read/GetDataMapComman= d.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetDataMapComman= d.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,9 +1,9 @@ package org.jboss.cache.commands.read; = import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.Visitor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.util.Immutables; = /** Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeyValu= eCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeyValueComma= nd.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeyValueComma= nd.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -4,9 +4,9 @@ import org.apache.commons.logging.LogFactory; import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.Visitor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.notifications.Notifier; = /** Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeysCom= mand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.j= ava 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.j= ava 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,9 +1,9 @@ package org.jboss.cache.commands.read; = import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.Visitor; -import org.jboss.cache.invocation.InvocationContext; = /** * Implements functionality defined by {@link org.jboss.cache.Cache#getKey= s(org.jboss.cache.Fqn)} Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GetNodeCom= mand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.j= ava 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.j= ava 2008-08-25 23:17:22 UTC (rev 6614) @@ -3,9 +3,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.Visitor; -import org.jboss.cache.invocation.InvocationContext; = /** * Implements functionality defined by {@link org.jboss.cache.Cache#getNod= e(org.jboss.cache.Fqn)} Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateD= ataCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCom= mand.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCom= mand.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -6,13 +6,13 @@ import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; import org.jboss.cache.InternalNode; +import org.jboss.cache.InvocationContext; import org.jboss.cache.Node; import org.jboss.cache.NodeSPI; import org.jboss.cache.buddyreplication.BuddyFqnTransformer; import org.jboss.cache.buddyreplication.BuddyManager; import org.jboss.cache.buddyreplication.GravitateResult; import org.jboss.cache.commands.Visitor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.marshall.NodeData; import org.jgroups.Address; = Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/Announce= BuddyPoolNameCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/remote/AnnounceBuddyP= oolNameCommand.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/remote/AnnounceBuddyP= oolNameCommand.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -2,9 +2,9 @@ = import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.jboss.cache.InvocationContext; import org.jboss.cache.buddyreplication.BuddyManager; import org.jboss.cache.commands.ReplicableCommand; -import org.jboss.cache.invocation.InvocationContext; import org.jgroups.Address; = /** Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/AssignTo= BuddyGroupCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyG= roupCommand.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyG= roupCommand.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,10 +1,10 @@ package org.jboss.cache.commands.remote; = import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.buddyreplication.BuddyGroup; import org.jboss.cache.buddyreplication.BuddyManager; import org.jboss.cache.commands.ReplicableCommand; -import org.jboss.cache.invocation.InvocationContext; = import java.util.Arrays; import java.util.Map; Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/Clustere= dGetCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCo= mmand.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCo= mmand.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -3,13 +3,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.DataContainer; +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.DataCommand; import org.jboss.cache.commands.ReplicableCommand; import org.jboss.cache.commands.read.ExistsCommand; import org.jboss.cache.commands.read.GetChildrenNamesCommand; import org.jboss.cache.commands.read.GetDataMapCommand; import org.jboss.cache.interceptors.InterceptorChain; -import org.jboss.cache.invocation.InvocationContext; = import java.util.ArrayList; import java.util.Collections; Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGrav= itationCleanupCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitatio= nCleanupCommand.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitatio= nCleanupCommand.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -4,6 +4,7 @@ import org.apache.commons.logging.LogFactory; import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.buddyreplication.BuddyFqnTransformer; import org.jboss.cache.buddyreplication.BuddyManager; import org.jboss.cache.commands.CommandsFactory; @@ -11,7 +12,6 @@ import org.jboss.cache.commands.write.EvictCommand; import org.jboss.cache.commands.write.RemoveNodeCommand; import org.jboss.cache.interceptors.InterceptorChain; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.transaction.GlobalTransaction; import org.jboss.cache.transaction.TransactionTable; = Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoveFr= omBuddyGroupCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoveFromBudd= yGroupCommand.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoveFromBudd= yGroupCommand.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,8 +1,8 @@ package org.jboss.cache.commands.remote; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.buddyreplication.BuddyManager; import org.jboss.cache.commands.ReplicableCommand; -import org.jboss.cache.invocation.InvocationContext; = /** * Removes a buddy from a group. This is not a {@link org.jboss.cache.com= mands.VisitableCommand} and hence Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/Replicat= eCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateComma= nd.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateComma= nd.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -2,12 +2,12 @@ = import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.ReplicableCommand; import org.jboss.cache.commands.VisitableCommand; import org.jboss.cache.commands.read.GravitateDataCommand; import org.jboss.cache.commands.write.PutForExternalReadCommand; import org.jboss.cache.interceptors.InterceptorChain; -import org.jboss.cache.invocation.InvocationContext; = import java.util.ArrayList; import java.util.List; Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/AbstractTran= sactionCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/tx/AbstractTransactio= nCommand.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/tx/AbstractTransactio= nCommand.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,7 +1,7 @@ package org.jboss.cache.commands.tx; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.VisitableCommand; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.transaction.GlobalTransaction; = /** Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/CommitComman= d.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/tx/CommitCommand.java= 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/tx/CommitCommand.java= 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,7 +1,7 @@ package org.jboss.cache.commands.tx; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.Visitor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.transaction.GlobalTransaction; = /** Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPr= epareCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareC= ommand.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareC= ommand.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,8 +1,8 @@ package org.jboss.cache.commands.tx; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.Visitor; import org.jboss.cache.commands.WriteCommand; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.transaction.GlobalTransaction; import org.jgroups.Address; = Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareComma= nd.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.jav= a 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.jav= a 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,9 +1,9 @@ package org.jboss.cache.commands.tx; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.ReplicableCommand; import org.jboss.cache.commands.Visitor; import org.jboss.cache.commands.WriteCommand; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.transaction.GlobalTransaction; import org.jgroups.Address; = Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/RollbackComm= and.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/tx/RollbackCommand.ja= va 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/tx/RollbackCommand.ja= va 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,7 +1,7 @@ package org.jboss.cache.commands.tx; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.Visitor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.transaction.GlobalTransaction; = /** Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/AbstractV= ersionedDataCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/write/AbstractVersion= edDataCommand.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/write/AbstractVersion= edDataCommand.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -2,10 +2,10 @@ = import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.VersionedDataCommand; import org.jboss.cache.commands.read.AbstractDataCommand; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.notifications.Notifier; import org.jboss.cache.optimistic.DataVersion; import org.jboss.cache.optimistic.DataVersioningException; Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/ClearData= Command.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/write/ClearDataComman= d.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/write/ClearDataComman= d.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -3,9 +3,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.Visitor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.notifications.event.NodeModifiedEvent; import org.jboss.cache.optimistic.DataVersion; import org.jboss.cache.transaction.GlobalTransaction; Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/EvictComm= and.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.ja= va 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.ja= va 2008-08-25 23:17:22 UTC (rev 6614) @@ -5,10 +5,10 @@ import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; import org.jboss.cache.InternalNode; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.Visitor; import org.jboss.cache.commands.read.AbstractDataCommand; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.mvcc.ReadCommittedNode; import org.jboss.cache.notifications.Notifier; = @@ -62,7 +62,7 @@ /** * Evicts a node. *

    - * See {@link org.jboss.cache.interceptors.EvictionInterceptor#visitEvi= ctFqnCommand(org.jboss.cache.invocation.InvocationContext , EvictCommand)} + * See {@link org.jboss.cache.interceptors.EvictionInterceptor#visitEvi= ctFqnCommand(org.jboss.cache.InvocationContext , EvictCommand)} * which is where the return value is used * * @return true if the node was removed from the tree or if it is resid= ent. Returns false if the node still exists; i.e. was only data removed be= cause it still has children. Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/Invalidat= eCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/write/InvalidateComma= nd.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/write/InvalidateComma= nd.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -5,10 +5,10 @@ import org.jboss.cache.CacheSPI; import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.Visitor; import org.jboss.cache.commands.read.AbstractDataCommand; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.notifications.Notifier; = /** Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/MoveComma= nd.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.jav= a 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.jav= a 2008-08-25 23:17:22 UTC (rev 6614) @@ -5,11 +5,11 @@ import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; import org.jboss.cache.InternalNode; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.Visitor; import org.jboss.cache.commands.WriteCommand; import org.jboss.cache.commands.read.AbstractDataCommand; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.notifications.Notifier; import org.jboss.cache.transaction.GlobalTransaction; = Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMa= pCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapComma= nd.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapComma= nd.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -3,10 +3,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeNotExistsException; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.Visitor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.notifications.event.NodeModifiedEvent; import org.jboss.cache.optimistic.DataVersion; import org.jboss.cache.transaction.GlobalTransaction; Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/PutForExt= ernalReadCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/write/PutForExternalR= eadCommand.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/write/PutForExternalR= eadCommand.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,8 +1,8 @@ package org.jboss.cache.commands.write; = import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.Visitor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.transaction.GlobalTransaction; = /** Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyVal= ueCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueComm= and.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueComm= and.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -3,10 +3,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeNotExistsException; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.Visitor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.notifications.event.NodeModifiedEvent; import org.jboss.cache.optimistic.DataVersion; import org.jboss.cache.transaction.GlobalTransaction; Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveKey= Command.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveKeyComman= d.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveKeyComman= d.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -3,9 +3,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.Visitor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.notifications.event.NodeModifiedEvent; import org.jboss.cache.optimistic.DataVersion; import org.jboss.cache.transaction.GlobalTransaction; Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNod= eCommand.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeComma= nd.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeComma= nd.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -3,9 +3,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.Visitor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.optimistic.DataVersion; import org.jboss.cache.transaction.GlobalTransaction; = Modified: core/trunk/src/main/java/org/jboss/cache/factories/context/Contex= tFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/factories/context/ContextFacto= ry.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/factories/context/ContextFacto= ry.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,6 +1,6 @@ package org.jboss.cache.factories.context; = -import org.jboss.cache.invocation.InvocationContext; +import org.jboss.cache.InvocationContext; import org.jboss.cache.transaction.TransactionContext; = import javax.transaction.RollbackException; @@ -8,7 +8,7 @@ import javax.transaction.Transaction; = /** - * This is the factory responsible for creating {@link org.jboss.cache.inv= ocation.InvocationContext}s and {@link org.jboss.cache.transaction.Transact= ionContext}s + * This is the factory responsible for creating {@link org.jboss.cache.Inv= ocationContext}s and {@link org.jboss.cache.transaction.TransactionContext}s * for requests, based on the configuration used. * * @author Manik Surtani (manik(a)jbo= ss.org) Modified: core/trunk/src/main/java/org/jboss/cache/factories/context/MVCCCo= ntextFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/factories/context/MVCCContextF= actory.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/factories/context/MVCCContextF= actory.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,6 +1,6 @@ package org.jboss.cache.factories.context; = -import org.jboss.cache.invocation.InvocationContext; +import org.jboss.cache.InvocationContext; import org.jboss.cache.invocation.MVCCInvocationContext; import org.jboss.cache.transaction.MVCCTransactionContext; import org.jboss.cache.transaction.TransactionContext; Modified: core/trunk/src/main/java/org/jboss/cache/factories/context/Pessim= isticContextFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/factories/context/PessimisticC= ontextFactory.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/factories/context/PessimisticC= ontextFactory.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,8 +1,8 @@ package org.jboss.cache.factories.context; = import org.jboss.cache.DataContainer; +import org.jboss.cache.InvocationContext; import org.jboss.cache.factories.annotations.Inject; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.invocation.LegacyInvocationContext; import org.jboss.cache.transaction.PessimisticTransactionContext; import org.jboss.cache.transaction.TransactionContext; Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationI= nterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterce= ptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterce= ptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -2,6 +2,7 @@ = import org.jboss.cache.Fqn; import org.jboss.cache.InternalNode; +import org.jboss.cache.InvocationContext; import org.jboss.cache.Modification; import org.jboss.cache.jmx.annotations.ManagedAttribute; import org.jboss.cache.jmx.annotations.ManagedOperation; @@ -21,7 +22,6 @@ import org.jboss.cache.commands.write.RemoveNodeCommand; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.transaction.GlobalTransaction; import org.jboss.cache.transaction.TransactionContext; = Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInte= rceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcIntercepto= r.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcIntercepto= r.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -3,6 +3,7 @@ */ package org.jboss.cache.interceptors; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.RPCManager; import org.jboss.cache.buddyreplication.BuddyManager; import org.jboss.cache.cluster.ReplicationQueue; @@ -13,7 +14,6 @@ import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; import org.jboss.cache.interceptors.base.CommandInterceptor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.transaction.GlobalTransaction; import org.jboss.cache.transaction.TransactionContext; import org.jboss.cache.transaction.TransactionTable; Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransac= tionalContextInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactional= ContextInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactional= ContextInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,9 +1,9 @@ package org.jboss.cache.interceptors; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.config.Option; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.interceptors.base.CommandInterceptor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.transaction.GlobalTransaction; import org.jboss.cache.transaction.TransactionContext; import org.jboss.cache.transaction.TransactionTable; Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/BatchingInt= erceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/BatchingIntercept= or.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/BatchingIntercept= or.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,10 +1,10 @@ package org.jboss.cache.interceptors; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.batch.BatchContainer; import org.jboss.cache.commands.VisitableCommand; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.interceptors.base.CommandInterceptor; -import org.jboss.cache.invocation.InvocationContext; = import javax.transaction.Transaction; import javax.transaction.TransactionManager; Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoader= Interceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterc= eptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterc= eptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -4,6 +4,7 @@ import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; import org.jboss.cache.InternalNode; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.jmx.annotations.ManagedAttribute; import org.jboss.cache.jmx.annotations.ManagedOperation; @@ -26,7 +27,6 @@ import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; import org.jboss.cache.interceptors.base.JmxStatsCommandInterceptor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.loader.CacheLoader; import org.jboss.cache.loader.CacheLoaderManager; import org.jboss.cache.mvcc.MVCCNodeHelper; Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtIn= terceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtIntercep= tor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtIntercep= tor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -22,6 +22,7 @@ package org.jboss.cache.interceptors; = import org.jboss.cache.DataContainer; +import org.jboss.cache.InvocationContext; import org.jboss.cache.jmx.annotations.ManagedAttribute; import org.jboss.cache.jmx.annotations.ManagedOperation; import org.jboss.cache.commands.read.GetKeyValueCommand; @@ -31,7 +32,6 @@ import org.jboss.cache.commands.write.PutKeyValueCommand; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.interceptors.base.JmxStatsCommandInterceptor; -import org.jboss.cache.invocation.InvocationContext; = import java.util.HashMap; import java.util.Map; Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreI= nterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterce= ptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterce= ptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -2,6 +2,7 @@ = import org.apache.commons.logging.LogFactory; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.Modification; import org.jboss.cache.NodeSPI; import org.jboss.cache.jmx.annotations.ManagedOperation; @@ -25,7 +26,6 @@ import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; import org.jboss.cache.interceptors.base.SkipCheckChainedInterceptor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.loader.CacheLoader; import org.jboss.cache.loader.CacheLoaderManager; import org.jboss.cache.transaction.GlobalTransaction; Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterce= ptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.j= ava 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.j= ava 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,5 +1,6 @@ package org.jboss.cache.interceptors; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.ReplicableCommand; import org.jboss.cache.commands.VisitableCommand; import org.jboss.cache.commands.WriteCommand; @@ -17,7 +18,6 @@ import org.jboss.cache.config.Configuration.NodeLockingScheme; import org.jboss.cache.factories.annotations.Start; import org.jboss.cache.interceptors.base.CommandInterceptor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.transaction.GlobalTransaction; = import javax.transaction.Transaction; Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravita= torInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInt= erceptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInt= erceptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,8 +1,8 @@ package org.jboss.cache.interceptors; = import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.factories.annotations.Inject; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.mvcc.MVCCNodeHelper; = /** Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInt= erceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionIntercept= or.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionIntercept= or.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -9,6 +9,7 @@ = import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.Region; import org.jboss.cache.RegionManager; import org.jboss.cache.commands.read.GetDataMapCommand; @@ -25,7 +26,6 @@ import static org.jboss.cache.eviction.EvictionEvent.Type.*; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.interceptors.base.CommandInterceptor; -import org.jboss.cache.invocation.InvocationContext; = /** * Eviction Interceptor. Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java = 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java = 2008-08-25 23:17:22 UTC (rev 6614) @@ -22,11 +22,11 @@ package org.jboss.cache.interceptors; = import org.jboss.cache.CacheSPI; +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.VisitableCommand; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; import org.jboss.cache.interceptors.base.CommandInterceptor; -import org.jboss.cache.invocation.InvocationContext; = /** * Class representing an interceptor. @@ -62,7 +62,7 @@ /** * Using this method call for forwarding a call in the chain is not red= able and error prone in the case of interceptors * extending other interceptors. This metod rather refers to intercepto= r doing its business operations rather than - * delegating to the nextInterceptor interceptor in chain. For delegati= on please use {@link #nextInterceptor(org.jboss.cache.invocation.Invocation= Context)} + * delegating to the nextInterceptor interceptor in chain. For delegati= on please use {@link #nextInterceptor(org.jboss.cache.InvocationContext)} */ public Object invoke(InvocationContext ctx) throws Throwable { Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor= Chain.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorChain.= java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorChain.= java 2008-08-25 23:17:22 UTC (rev 6614) @@ -3,11 +3,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.CacheException; +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.VisitableCommand; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; import org.jboss.cache.interceptors.base.CommandInterceptor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.invocation.InvocationContextContainer; import org.jboss.cache.util.CachePrinter; = @@ -258,7 +258,7 @@ } = /** - * Similar to {@link #invoke(org.jboss.cache.invocation.InvocationConte= xt , org.jboss.cache.commands.VisitableCommand)}, but + * Similar to {@link #invoke(org.jboss.cache.InvocationContext , org.jb= oss.cache.commands.VisitableCommand)}, but * constructs a invocation context on the fly, using {@link InvocationC= ontextContainer#get()} */ public Object invokeRemote(VisitableCommand cacheCommand) throws Throwa= ble @@ -269,7 +269,7 @@ } = /** - * Similar to {@link #invoke(org.jboss.cache.invocation.InvocationConte= xt , org.jboss.cache.commands.VisitableCommand)}, but + * Similar to {@link #invoke(org.jboss.cache.InvocationContext , org.jb= oss.cache.commands.VisitableCommand)}, but * constructs a invocation context on the fly, using {@link InvocationC= ontextContainer#get()} and setting the origin local flag to it's default va= lue. */ public Object invoke(VisitableCommand cacheCommand) throws Throwable Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/Invalidatio= nInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInter= ceptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInter= ceptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -7,6 +7,7 @@ package org.jboss.cache.interceptors; = import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.jmx.annotations.ManagedOperation; import org.jboss.cache.jmx.annotations.ManagedAttribute; import org.jboss.cache.commands.AbstractVisitor; @@ -30,7 +31,6 @@ import org.jboss.cache.config.Option; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.optimistic.DataVersion; import org.jboss.cache.optimistic.DefaultDataVersion; import org.jboss.cache.optimistic.TransactionWorkspace; Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationC= ontextInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContext= Interceptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContext= Interceptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -6,6 +6,7 @@ */ package org.jboss.cache.interceptors; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.RPCManager; import org.jboss.cache.commands.VisitableCommand; import org.jboss.cache.commands.read.ExistsCommand; @@ -21,7 +22,6 @@ import org.jboss.cache.commands.write.RemoveNodeCommand; import org.jboss.cache.config.Option; import org.jboss.cache.factories.annotations.Inject; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.transaction.GlobalTransaction; import org.jboss.cache.transaction.TransactionTable; = Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyActiv= ationInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyActivationI= nterceptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyActivationI= nterceptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,6 +1,7 @@ package org.jboss.cache.interceptors; = import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.Modification; import org.jboss.cache.NodeSPI; import org.jboss.cache.jmx.annotations.ManagedOperation; @@ -20,7 +21,6 @@ import org.jboss.cache.commands.write.RemoveNodeCommand; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.transaction.GlobalTransaction; import org.jboss.cache.transaction.TransactionContext; = Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyCache= LoaderInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyCacheLoader= Interceptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyCacheLoader= Interceptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -3,6 +3,7 @@ import org.jboss.cache.CacheException; import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.WriteCommand; import org.jboss.cache.commands.read.*; @@ -14,7 +15,6 @@ import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; import org.jboss.cache.interceptors.base.JmxStatsCommandInterceptor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.jmx.annotations.ManagedAttribute; import org.jboss.cache.jmx.annotations.ManagedOperation; import org.jboss.cache.loader.CacheLoader; Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyDataG= ravitatorInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyDataGravita= torInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyDataGravita= torInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -10,6 +10,7 @@ import org.jboss.cache.CacheSPI; import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.buddyreplication.BuddyFqnTransformer; import org.jboss.cache.buddyreplication.BuddyManager; import org.jboss.cache.buddyreplication.GravitateResult; @@ -27,7 +28,6 @@ import org.jboss.cache.commands.tx.CommitCommand; import org.jboss.cache.commands.tx.RollbackCommand; import org.jboss.cache.factories.annotations.Inject; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.marshall.NodeData; import org.jboss.cache.transaction.GlobalTransaction; import org.jgroups.Address; Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyPassi= vationInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyPassivation= Interceptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyPassivation= Interceptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -2,9 +2,9 @@ = import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.write.EvictCommand; import org.jboss.cache.factories.annotations.Inject; -import org.jboss.cache.invocation.InvocationContext; = import java.util.List; = Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLocking= Interceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterc= eptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterc= eptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -3,6 +3,7 @@ import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; import org.jboss.cache.InternalNode; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.VisitableCommand; import org.jboss.cache.commands.read.ExistsCommand; @@ -26,7 +27,6 @@ import org.jboss.cache.commands.write.RemoveNodeCommand; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.interceptors.base.PrePostProcessingCommandIntercept= or; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.lock.LockManager; import org.jboss.cache.mvcc.MVCCNodeHelper; = Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledV= alueInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueIn= terceptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueIn= terceptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,5 +1,6 @@ package org.jboss.cache.interceptors; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.ReplicableCommand; import org.jboss.cache.commands.read.GetChildrenNamesCommand; import org.jboss.cache.commands.read.GetDataMapCommand; @@ -12,7 +13,6 @@ import org.jboss.cache.commands.write.PutKeyValueCommand; import org.jboss.cache.commands.write.RemoveKeyCommand; import org.jboss.cache.interceptors.base.CommandInterceptor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.marshall.MarshalledValue; import org.jboss.cache.marshall.MarshalledValueHelper; import org.jboss.cache.marshall.MarshalledValueMap; Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/Notificatio= nInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/NotificationInter= ceptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/NotificationInter= ceptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,10 +1,10 @@ package org.jboss.cache.interceptors; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.tx.CommitCommand; import org.jboss.cache.commands.tx.PrepareCommand; import org.jboss.cache.commands.tx.RollbackCommand; import org.jboss.cache.factories.annotations.Inject; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.notifications.Notifier; = /** Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticC= reateIfNotExistsInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateI= fNotExistsInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateI= fNotExistsInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -10,6 +10,7 @@ import org.jboss.cache.CacheSPI; import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeFactory; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.write.MoveCommand; @@ -18,7 +19,6 @@ import org.jboss.cache.commands.write.PutKeyValueCommand; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.notifications.Notifier; import org.jboss.cache.optimistic.DataVersion; import org.jboss.cache.optimistic.DefaultDataVersion; Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticI= nterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterce= ptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterce= ptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -8,11 +8,11 @@ = import org.jboss.cache.CacheException; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeFactory; import org.jboss.cache.NodeSPI; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.interceptors.base.CommandInterceptor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.lock.LockManager; import static org.jboss.cache.lock.LockType.READ; import org.jboss.cache.lock.TimeoutException; @@ -76,9 +76,9 @@ } = /** - * @return the {@link org.jboss.cache.transaction.GlobalTransaction}, e= xtracted from the current {@link org.jboss.cache.invocation.InvocationConte= xt}. + * @return the {@link org.jboss.cache.transaction.GlobalTransaction}, e= xtracted from the current {@link org.jboss.cache.InvocationContext}. * @throws CacheException if the {@link org.jboss.cache.transaction.Glo= balTransaction} or {@link javax.transaction.Transaction} associated with the - * {@link org.jboss.cache.invocation.InvocationC= ontext} is null. + * {@link org.jboss.cache.InvocationContext} is = null. */ protected GlobalTransaction getGlobalTransaction(InvocationContext ctx)= throws CacheException { Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticL= ockingInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLocking= Interceptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLocking= Interceptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -7,13 +7,13 @@ package org.jboss.cache.interceptors; = import org.jboss.cache.CacheException; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.VisitableCommand; import org.jboss.cache.commands.tx.CommitCommand; import org.jboss.cache.commands.tx.OptimisticPrepareCommand; import org.jboss.cache.commands.tx.RollbackCommand; import org.jboss.cache.factories.annotations.Start; -import org.jboss.cache.invocation.InvocationContext; import static org.jboss.cache.lock.LockType.READ; import static org.jboss.cache.lock.LockType.WRITE; import org.jboss.cache.optimistic.TransactionWorkspace; Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticN= odeInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInt= erceptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInt= erceptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -10,6 +10,7 @@ import org.jboss.cache.CacheException; import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeFactory; import org.jboss.cache.NodeNotExistsException; import org.jboss.cache.NodeSPI; @@ -29,7 +30,6 @@ import org.jboss.cache.config.Option; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.notifications.Notifier; import static org.jboss.cache.notifications.event.NodeModifiedEvent.Modifi= cationType.*; import org.jboss.cache.optimistic.DataVersion; Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticR= eplicationInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplica= tionInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplica= tionInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -8,6 +8,7 @@ = import org.jboss.cache.CacheException; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.AbstractVisitor; import org.jboss.cache.commands.CommandsFactory; import org.jboss.cache.commands.ReplicableCommand; @@ -27,7 +28,6 @@ import org.jboss.cache.commands.write.RemoveKeyCommand; import org.jboss.cache.commands.write.RemoveNodeCommand; import org.jboss.cache.factories.annotations.Inject; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.optimistic.DataVersion; import org.jboss.cache.optimistic.DefaultDataVersion; import org.jboss.cache.optimistic.TransactionWorkspace; @@ -45,8 +45,8 @@ * Replication interceptor for the optimistically locked interceptor chain= . Responsible for replicating * state to remote nodes. Unlike it's cousin, the {@link org.jboss.cache.= interceptors.ReplicationInterceptor}, this interceptor * only deals with transactional calls. Just like all things to do with O= ptimistic Locking, it is a requirement that - * everything is done in a transaction and the transaction context is avai= lable via {@link org.jboss.cache.invocation.InvocationContext#getTransactio= n()} - * and {@link org.jboss.cache.invocation.InvocationContext#getGlobalTransa= ction()}. + * everything is done in a transaction and the transaction context is avai= lable via {@link org.jboss.cache.InvocationContext#getTransaction()} + * and {@link org.jboss.cache.InvocationContext#getGlobalTransaction()}. * * @author Manik Surtani (manik(a)jbo= ss.org) * @author Steve Woodcock (stevew(a)= jofti.com) Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticT= xInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticTxInter= ceptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticTxInter= ceptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,5 +1,6 @@ package org.jboss.cache.interceptors; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.AbstractVisitor; import org.jboss.cache.commands.VersionedDataCommand; import org.jboss.cache.commands.VisitableCommand; @@ -11,7 +12,6 @@ import org.jboss.cache.commands.write.RemoveKeyCommand; import org.jboss.cache.commands.write.RemoveNodeCommand; import org.jboss.cache.config.Option; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.transaction.GlobalTransaction; import org.jboss.cache.transaction.OptimisticTransactionContext; import org.jboss.cache.transaction.TransactionContext; Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticV= alidatorInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidat= orInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidat= orInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -9,13 +9,13 @@ import org.jboss.cache.CacheException; import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.tx.CommitCommand; import org.jboss.cache.commands.tx.OptimisticPrepareCommand; import org.jboss.cache.commands.tx.RollbackCommand; import static org.jboss.cache.config.Configuration.CacheMode; import org.jboss.cache.factories.annotations.Inject; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.optimistic.DataVersioningException; import org.jboss.cache.optimistic.DefaultDataVersion; import org.jboss.cache.optimistic.TransactionWorkspace; Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/Passivation= Interceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterc= eptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterc= eptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,12 +1,12 @@ package org.jboss.cache.interceptors; = import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.write.EvictCommand; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; import org.jboss.cache.interceptors.base.JmxStatsCommandInterceptor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.jmx.annotations.ManagedAttribute; import org.jboss.cache.jmx.annotations.ManagedOperation; import org.jboss.cache.loader.CacheLoader; Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/Pessimistic= LockInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockIn= terceptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockIn= terceptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -8,6 +8,7 @@ = import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.CommandsFactory; import org.jboss.cache.commands.DataCommand; @@ -31,7 +32,6 @@ import org.jboss.cache.commands.write.RemoveNodeCommand; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.interceptors.base.PrePostProcessingCommandIntercept= or; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.lock.IsolationLevel; import org.jboss.cache.lock.LockManager; import static org.jboss.cache.lock.LockType.READ; Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/Replication= Interceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterc= eptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterc= eptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,5 +1,6 @@ package org.jboss.cache.interceptors; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.VisitableCommand; import org.jboss.cache.commands.WriteCommand; import org.jboss.cache.commands.tx.CommitCommand; @@ -13,7 +14,6 @@ import org.jboss.cache.commands.write.RemoveKeyCommand; import org.jboss.cache.commands.write.RemoveNodeCommand; import org.jboss.cache.config.Configuration; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.transaction.GlobalTransaction; import org.jboss.cache.transaction.TransactionContext; = Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxIntercept= or.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.jav= a 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.jav= a 2008-08-25 23:17:22 UTC (rev 6614) @@ -7,6 +7,7 @@ package org.jboss.cache.interceptors; = import org.jboss.cache.CacheException; +import org.jboss.cache.InvocationContext; import org.jboss.cache.RPCManager; import org.jboss.cache.ReplicationException; import org.jboss.cache.jmx.annotations.MBean; @@ -31,7 +32,6 @@ import org.jboss.cache.factories.ComponentRegistry; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.context.ContextFactory; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.invocation.InvocationContextContainer; import org.jboss.cache.lock.LockManager; import org.jboss.cache.notifications.Notifier; Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/base/Comman= dInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/base/CommandInter= ceptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/CommandInter= ceptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -2,11 +2,11 @@ = import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.AbstractVisitor; import org.jboss.cache.commands.VisitableCommand; import org.jboss.cache.config.Configuration; import org.jboss.cache.factories.annotations.Inject; -import org.jboss.cache.invocation.InvocationContext; = /** * This is the base class for all interceptors to extend, and implements t= he {@link org.jboss.cache.commands.Visitor} interface @@ -17,11 +17,11 @@ * public interface, or by the {@link org.jboss.cache.marshall.CommandAwar= eRpcDispatcher} for remotely originating invocations, and * are passed up the interceptor chain by using the {@link org.jboss.cache= .interceptors.InterceptorChain} helper class. *

    - * When writing interceptors, authors can either override a specific visit= XXX() method (such as {@link #visitGetKeyValueCommand(org.jboss.cache.invoc= ation.InvocationContext , org.jboss.cache.commands.read.GetKeyValueCommand)= }) - * or the more generic {@link #handleDefault(org.jboss.cache.invocation.In= vocationContext , org.jboss.cache.commands.VisitableCommand)} which is the = default behaviour of - * any visit method, as defined in {@link org.jboss.cache.commands.Abstrac= tVisitor#handleDefault(org.jboss.cache.invocation.InvocationContext , org.j= boss.cache.commands.VisitableCommand)}. + * When writing interceptors, authors can either override a specific visit= XXX() method (such as {@link #visitGetKeyValueCommand(org.jboss.cache.Invoc= ationContext , org.jboss.cache.commands.read.GetKeyValueCommand)}) + * or the more generic {@link #handleDefault(org.jboss.cache.InvocationCon= text , org.jboss.cache.commands.VisitableCommand)} which is the default beh= aviour of + * any visit method, as defined in {@link org.jboss.cache.commands.Abstrac= tVisitor#handleDefault(org.jboss.cache.InvocationContext , org.jboss.cache.= commands.VisitableCommand)}. *

    - * The preferred approach is to override the specific visitXXX() methods t= hat are of interest rather than to override {@link #handleDefault(org.jboss= .cache.invocation.InvocationContext , org.jboss.cache.commands.VisitableCom= mand)} + * The preferred approach is to override the specific visitXXX() methods t= hat are of interest rather than to override {@link #handleDefault(org.jboss= .cache.InvocationContext , org.jboss.cache.commands.VisitableCommand)} * and then write a series of if statements or a switch block, if command-= specific behaviour is needed. *

    * Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/base/PrePos= tProcessingCommandInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/base/PrePostProce= ssingCommandInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/PrePostProce= ssingCommandInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,5 +1,6 @@ package org.jboss.cache.interceptors.base; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.VisitableCommand; import org.jboss.cache.commands.legacy.write.CreateNodeCommand; import org.jboss.cache.commands.read.ExistsCommand; @@ -22,18 +23,17 @@ import org.jboss.cache.commands.write.PutKeyValueCommand; import org.jboss.cache.commands.write.RemoveKeyCommand; import org.jboss.cache.commands.write.RemoveNodeCommand; -import org.jboss.cache.invocation.InvocationContext; = /** * This interceptor adds pre and post processing to each visitXXX() method. *

    - * For each visitXXX() method invoked, it will first call {@link = #doBeforeCall(org.jboss.cache.invocation.InvocationContext, org.jboss.cache= .commands.VisitableCommand)} - * and if this method returns true, it will proceed to invoking a hand= leXXX() method and lastly, {@link #doAfterCall(org.jboss.cache.invocat= ion.InvocationContext, org.jboss.cache.commands.VisitableCommand)} + * For each visitXXX() method invoked, it will first call {@link = #doBeforeCall(org.jboss.cache.InvocationContext, org.jboss.cache.commands.V= isitableCommand)} + * and if this method returns true, it will proceed to invoking a hand= leXXX() method and lastly, {@link #doAfterCall(org.jboss.cache.Invocat= ionContext, org.jboss.cache.commands.VisitableCommand)} * in a finally block. Note that the doAfterCall() meth= od is still invoked even if doBeforeCall() returns false. *

    * Instead of overriding visitXXX() methods, implementations shou= ld override their handleXXX() counterparts defined in this class - * instead, as well as the {@link #doAfterCall(org.jboss.cache.invocation.= InvocationContext ,org.jboss.cache.commands.VisitableCommand)} method and - * optionally {@link #doBeforeCall(org.jboss.cache.invocation.InvocationCo= ntext, org.jboss.cache.commands.VisitableCommand)}. + * instead, as well as the {@link #doAfterCall(org.jboss.cache.InvocationC= ontext ,org.jboss.cache.commands.VisitableCommand)} method and + * optionally {@link #doBeforeCall(org.jboss.cache.InvocationContext, org.= jboss.cache.commands.VisitableCommand)}. *

    * * @author Mircea.Markus(a)jboss.com Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCh= eckChainedInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckCha= inedInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckCha= inedInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,5 +1,6 @@ package org.jboss.cache.interceptors.base; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.VisitableCommand; import org.jboss.cache.commands.read.ExistsCommand; import org.jboss.cache.commands.read.GetChildrenNamesCommand; @@ -21,18 +22,17 @@ import org.jboss.cache.commands.write.PutKeyValueCommand; import org.jboss.cache.commands.write.RemoveKeyCommand; import org.jboss.cache.commands.write.RemoveNodeCommand; -import org.jboss.cache.invocation.InvocationContext; = /** - * This interceptor will call {@link #skipInterception(org.jboss.cache.inv= ocation.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} befo= re invoking each visit method - * (and the {@link #handleDefault(org.jboss.cache.invocation.InvocationCon= text , org.jboss.cache.commands.VisitableCommand)} method). If - * {@link #skipInterception(org.jboss.cache.invocation.InvocationContext ,= org.jboss.cache.commands.VisitableCommand)} returns false, the inv= ocation will be skipped + * This interceptor will call {@link #skipInterception(org.jboss.cache.Inv= ocationContext ,org.jboss.cache.commands.VisitableCommand)} before invoking= each visit method + * (and the {@link #handleDefault(org.jboss.cache.InvocationContext , org.= jboss.cache.commands.VisitableCommand)} method). If + * {@link #skipInterception(org.jboss.cache.InvocationContext ,org.jboss.c= ache.commands.VisitableCommand)} returns false, the invocation wil= l be skipped * and passed up the interceptor chain instead. *

    * Instead of overriding visitXXX() methods, implementations should overri= de their handleXXX() counterparts defined in this class - * instead, as well as the {@link #skipInterception(org.jboss.cache.invoca= tion.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} method. - * Also, instead of overriding {@link #handleDefault(org.jboss.cache.invoc= ation.InvocationContext , org.jboss.cache.commands.VisitableCommand)}, impl= ementors - * should override {@link #handleAll(org.jboss.cache.invocation.Invocation= Context , org.jboss.cache.commands.VisitableCommand)}. + * instead, as well as the {@link #skipInterception(org.jboss.cache.Invoca= tionContext ,org.jboss.cache.commands.VisitableCommand)} method. + * Also, instead of overriding {@link #handleDefault(org.jboss.cache.Invoc= ationContext , org.jboss.cache.commands.VisitableCommand)}, implementors + * should override {@link #handleAll(org.jboss.cache.InvocationContext , o= rg.jboss.cache.commands.VisitableCommand)}. * * @author Mircea.Markus(a)jboss.com * @since 2.2 Modified: core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvoc= ationContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationC= ontext.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationC= ontext.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -14,6 +14,7 @@ = import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.VisitableCommand; import org.jboss.cache.config.Option; import org.jboss.cache.marshall.MethodCall; Modified: core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvoc= ationDelegate.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationD= elegate.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationD= elegate.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,5 +1,6 @@ package org.jboss.cache.invocation; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.config.Configuration; import org.jboss.cache.factories.ComponentRegistry; import org.jboss.cache.factories.annotations.Inject; Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocati= onDelegate.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDele= gate.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDele= gate.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -7,6 +7,7 @@ import org.jboss.cache.CacheStatus; import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeNotExistsException; import org.jboss.cache.NodeSPI; import org.jboss.cache.RPCManager; Deleted: core/trunk/src/main/java/org/jboss/cache/invocation/InvocationCont= ext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContext.j= ava 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContext.j= ava 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,316 +0,0 @@ -package org.jboss.cache.invocation; - -import org.jboss.cache.Fqn; -import org.jboss.cache.NodeSPI; -import org.jboss.cache.commands.VisitableCommand; -import org.jboss.cache.config.Option; -import org.jboss.cache.marshall.MethodCall; -import org.jboss.cache.transaction.GlobalTransaction; -import org.jboss.cache.transaction.TransactionContext; - -import javax.transaction.Transaction; -import java.util.List; -import java.util.Map; - -/** - * A context that holds information regarding the scope of a single invoca= tion. May delegate some calls to a {@link org.jboss.cache.transaction.Tran= sactionContext} - * if one is in scope. - *

    - * Note that prior to 3.0.0, InvocationContext was a concrete class and no= t an interface. - *

    - * - * @author Manik Surtani (manik(a)jbo= ss.org) - * @see org.jboss.cache.transaction.TransactionContext - */ -(a)SuppressWarnings("deprecation") -public interface InvocationContext -{ - /** - * Retrieves a node from the registry of looked up nodes in the current= scope. - * - * @param fqn fqn to look up - * @return a node, or null if it cannot be found. - * @since 3.0. - */ - NodeSPI lookUpNode(Fqn fqn); - - /** - * Puts an entry in the registry of looked up nodes in the current scop= e. - * - * @param f fqn to add - * @param n node to add - * @since 3.0. - */ - void putLookedUpNode(Fqn f, NodeSPI n); - - /** - * Clears the registry of looked up nodes. - * - * @since 3.0. - */ - void clearLookedUpNodes(); - - /** - * Retrieves a map of nodes looked up within the current invocation's s= cope. - * - * @return a map of looked up nodes. - * @since 3.0 - */ - Map getLookedUpNodes(); - - /** - * Marks teh context as only rolling back. - * - * @param localRollbackOnly if true, the context is only rolling back. - */ - void setLocalRollbackOnly(boolean localRollbackOnly); - - /** - * Retrieves the transaction associated with this invocation - * - * @return The transaction associated with this invocation - */ - Transaction getTransaction(); - - /** - * Sets a transaction object on the invocation context. - * - * @param transaction transaction to set - */ - void setTransaction(Transaction transaction); - - /** - * @return the transaction entry associated with the current transactio= n, or null if the current thread is not associated with a transaction. - * @since 2.2.0 - */ - TransactionContext getTransactionContext(); - - /** - * Sets the transaction context to be associated with the current threa= d. - * - * @param transactionContext transaction context to set - * @since 2.2.0 - */ - void setTransactionContext(TransactionContext transactionContext); - - /** - * Retrieves the global transaction associated with this invocation - * - * @return the global transaction associated with this invocation - */ - GlobalTransaction getGlobalTransaction(); - - /** - * Sets the global transaction associated with this invocation - * - * @param globalTransaction global transaction to set - */ - void setGlobalTransaction(GlobalTransaction globalTransaction); - - /** - * Retrieves the option overrides associated with this invocation - * - * @return the option overrides associated with this invocation - */ - Option getOptionOverrides(); - - /** - * @return true of no options have been set on this context, false othe= rwise. - */ - boolean isOptionsUninitialised(); - - /** - * Sets the option overrides to be associated with this invocation - * - * @param optionOverrides options to set - */ - void setOptionOverrides(Option optionOverrides); - - /** - * Tests if this invocation originated locally or from a remote cache. - * - * @return true if the invocation originated locally. - */ - boolean isOriginLocal(); - - /** - * Returns an immutable, defensive copy of the List of locks currently= maintained for the current scope. - *

    - * Note that if a transaction is in scope, implementations should retri= eve these locks from the {@link org.jboss.cache.transaction.TransactionCont= ext}. - * Retrieving locks from this method should always ensure they are retr= ieved from the appropriate scope. - *

    - * Note that currently (as of 3.0.0) this list is unchecked. This is t= o allow support for both MVCC (which uses Fqns as locks) - * as well as legacy Optimistic and Pessimistic Locking schemes (which = use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for - * legacy node locking schemes are dropped, this method will be more st= rongly typed to return List. - * - * @return locks held in current scope. - */ - @SuppressWarnings("unchecked") - List getLocks(); - - /** - * Adds a List of locks to the currently maintained collection of locks= acquired. - *

    - * Note that if a transaction is in scope, implementations should recor= d locks on the {@link org.jboss.cache.transaction.TransactionContext}. - * Adding locks using this method should always ensure they are applied= to the appropriate scope. - *

    - * Note that currently (as of 3.0.0) this list is unchecked. This is t= o allow support for both MVCC (which uses Fqns as locks) - * as well as legacy Optimistic and Pessimistic Locking schemes (which = use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for - * legacy node locking schemes are dropped, this method will be more st= rongly typed to accept List. - * - * @param locks locks to add - */ - @SuppressWarnings("unchecked") - void addAllLocks(List locks); - - /** - * Adds a lock to the currently maintained collection of locks acquired. - *

    - * Note that if a transaction is in scope, implementations should recor= d this lock on the {@link org.jboss.cache.transaction.TransactionContext}. - * Using this method should always ensure that the appropriate scope is= used. - *

    - * Note that currently (as of 3.0.0) this lock is weakly typed. This i= s to allow support for both MVCC (which uses {@link Fqn}s as locks) - * as well as legacy Optimistic and Pessimistic Locking schemes (which = use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for - * legacy node locking schemes are dropped, this method will be more st= rongly typed to accept {@link Fqn}. - * - * @param lock lock to add - */ - @SuppressWarnings("unchecked") - void addLock(Object lock); - - /** - * Removes a lock from the currently maintained collection of locks acq= uired. - *

    - * Note that if a transaction is in scope, implementations should remov= e this lock from the {@link org.jboss.cache.transaction.TransactionContext}. - * Using this method should always ensure that the lock is removed from= the appropriate scope. - *

    - * Note that currently (as of 3.0.0) this lock is weakly typed. This i= s to allow support for both MVCC (which uses {@link Fqn}s as locks) - * as well as legacy Optimistic and Pessimistic Locking schemes (which = use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for - * legacy node locking schemes are dropped, this method will be more st= rongly typed to accept {@link Fqn}. - * - * @param lock lock to remove - */ - @SuppressWarnings("unchecked") - void removeLock(Object lock); - - /** - * Clears all locks from the currently maintained collection of locks a= cquired. - *

    - * Note that if a transaction is in scope, implementations should clear= locks from the {@link org.jboss.cache.transaction.TransactionContext}. - * Using this method should always ensure locks are cleared in the appr= opriate scope. - *

    - * Note that currently (as of 3.0.0) this lock is weakly typed. This i= s to allow support for both MVCC (which uses {@link Fqn}s as locks) - * as well as legacy Optimistic and Pessimistic Locking schemes (which = use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for - * legacy node locking schemes are dropped, this method will be more st= rongly typed to accept {@link Fqn}. - */ - void clearLocks(); - - - /** - * Note that if a transaction is in scope, implementations should test = this lock from on {@link org.jboss.cache.transaction.TransactionContext}. - * Using this method should always ensure locks checked in the appropri= ate scope. - * - * @param lock lock to test - * @return true if the lock being tested is already held in the current= scope, false otherwise. - */ - boolean hasLock(Object lock); - - /** - * @return true if options exist to suppress locking - false otherwise.= Note that this is only used by the {@link org.jboss.cache.interceptors.Pe= ssimisticLockInterceptor}. - */ - boolean isLockingSuppressed(); - - /** - * If set to true, the invocation is assumed to have originated locally= . If set to false, - * assumed to have originated from a remote cache. - * - * @param originLocal flag to set - */ - void setOriginLocal(boolean originLocal); - - /** - * @return true if the current transaction is set to rollback only. - */ - boolean isLocalRollbackOnly(); - - /** - * Resets the context, freeing up any references. - */ - void reset(); - - /** - * This is a "copy-factory-method" that should be used whenever a clone= of this class is needed. The resulting instance - * is equal() to, but not =3D=3D, to the InvocationContext invoked on. = Note that this is a shallow copy with the exception - * of the Option object, which is deep, as well as any collections held= on the context such as locks. Note that the reference - * to a {@link org.jboss.cache.transaction.TransactionContext}, if any,= is maintained. - * - * @return a new InvocationContext - */ - @SuppressWarnings("unchecked") - InvocationContext copy(); - - /** - * Sets the state of the InvocationContext based on the template contex= t passed in - * - * @param template template to copy from - */ - void setState(InvocationContext template); - - /** - * @return the method call associated with this invocation - */ - @Deprecated - @SuppressWarnings("deprecation") - MethodCall getMethodCall(); - - - /** - * Sets the method call associated with this invocation. - * - * @param methodCall methodcall to set - * @deprecated not used anymore. Interceptors will get a {@link org.jb= oss.cache.commands.ReplicableCommand} instance passed in along with an Invo= cationContext. - */ - @Deprecated - void setMethodCall(MethodCall methodCall); - - /** - * If the lock acquisition timeout is overridden for current call using= an option, then return that one. - * If not overridden, return default value. - * - * @param defaultTimeout timeout to fall back to - * @return timeout to use - */ - long getLockAcquisitionTimeout(long defaultTimeout); - - /** - * This is only used for backward compatibility with old interceptors i= mplementation and should NOT be - * use by any new custom interceptors. The commands is now passed in as= the second param in each implementing - * handlers (handler =3D method in ChainedInterceptor class) - * - * @param cacheCommand command to set - */ - @Deprecated - @SuppressWarnings("deprecation") - void setCommand(VisitableCommand cacheCommand); - - /** - * @return command that is in scope - * @see #setCommand(org.jboss.cache.commands.VisitableCommand) - */ - @Deprecated - @SuppressWarnings("deprecation") - VisitableCommand getCommand(); - - /** - * @return true if there is current transaction associated with the inv= ocation, and this transaction is in a valid state. - */ - boolean isValidTransaction(); - - /** - * Throws the given throwable provided no options suppress or prevent t= his from happening. - * - * @param throwable throwable to throw - * @throws Throwable if allowed to throw one. - */ - void throwIfNeeded(Throwable throwable) throws Throwable; -} Modified: core/trunk/src/main/java/org/jboss/cache/invocation/InvocationCon= textContainer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContextCo= ntainer.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContextCo= ntainer.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,5 +1,6 @@ package org.jboss.cache.invocation; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.NonVolatile; import org.jboss.cache.factories.context.ContextFactory; Modified: core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocat= ionContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationCon= text.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationCon= text.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -2,6 +2,7 @@ = import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; = import java.util.Map; Modified: core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocatio= nContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationConte= xt.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationConte= xt.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,6 +1,7 @@ package org.jboss.cache.invocation; = import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.transaction.MVCCTransactionContext; import org.jboss.cache.transaction.TransactionContext; Modified: core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocatio= nDelegate.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDeleg= ate.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDeleg= ate.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -7,6 +7,7 @@ import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; import org.jboss.cache.InternalNode; +import org.jboss.cache.InvocationContext; import org.jboss.cache.Node; import org.jboss.cache.NodeNotValidException; import org.jboss.cache.NodeSPI; Modified: core/trunk/src/main/java/org/jboss/cache/lock/AbstractLockManager= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/lock/AbstractLockManager.java = 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/lock/AbstractLockManager.java = 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,9 +1,9 @@ package org.jboss.cache.lock; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.config.Configuration; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; -import org.jboss.cache.invocation.InvocationContext; = /** * Common lock manager functionality Modified: core/trunk/src/main/java/org/jboss/cache/lock/FqnLockManager.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/lock/FqnLockManager.java 2008-= 08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/lock/FqnLockManager.java 2008-= 08-25 23:17:22 UTC (rev 6614) @@ -1,7 +1,7 @@ package org.jboss.cache.lock; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; -import org.jboss.cache.invocation.InvocationContext; = import java.util.Collection; = Modified: core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java 2008-08-= 25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java 2008-08-= 25 23:17:22 UTC (rev 6614) @@ -1,8 +1,8 @@ package org.jboss.cache.lock; = import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; -import org.jboss.cache.invocation.InvocationContext; = import java.util.Collection; = @@ -73,9 +73,9 @@ * is specified in {@link org.jboss.cache.config.Option#getLockAcquisit= ionTimeout()} and, if this is unset, the default timeout * set in {@link org.jboss.cache.config.Configuration#getLockAcquisitio= nTimeout()} is used. *

    - * In addition, any locks acquired are added to the context OR transact= ion entry using {@link org.jboss.cache.invocation.InvocationContext#addLock= (Object)}. + * In addition, any locks acquired are added to the context OR transact= ion entry using {@link org.jboss.cache.InvocationContext#addLock(Object)}. *

    - * The owner for the lock is determined by passing the invocation conte= xt to {@link #getLockOwner(org.jboss.cache.invocation.InvocationContext)}. + * The owner for the lock is determined by passing the invocation conte= xt to {@link #getLockOwner(org.jboss.cache.InvocationContext)}. *

    * * @param fqn Fqn to lock @@ -91,9 +91,9 @@ * is specified in {@link org.jboss.cache.config.Option#getLockAcquisit= ionTimeout()} and, if this is unset, the default timeout * set in {@link org.jboss.cache.config.Configuration#getLockAcquisitio= nTimeout()} is used. *

    - * In addition, any locks acquired are added to the context OR transact= ion entry using {@link org.jboss.cache.invocation.InvocationContext#addLock= (Object)}. + * In addition, any locks acquired are added to the context OR transact= ion entry using {@link org.jboss.cache.InvocationContext#addLock(Object)}. *

    - * The owner for the lock is determined by passing the invocation conte= xt to {@link #getLockOwner(org.jboss.cache.invocation.InvocationContext)}. + * The owner for the lock is determined by passing the invocation conte= xt to {@link #getLockOwner(org.jboss.cache.InvocationContext)}. *

    * * @param node Fqn to lock @@ -125,7 +125,7 @@ *

    * Locks are released in reverse order of which they are acquired and r= egistered. *

    - * Lock owner is determined by passing the invocation context to {@link= #getLockOwner(org.jboss.cache.invocation.InvocationContext)} + * Lock owner is determined by passing the invocation context to {@link= #getLockOwner(org.jboss.cache.InvocationContext)} *

    * * @param ctx invocation context to inspect @@ -176,9 +176,9 @@ * Locks the node and all child nodes, acquiring lock of type specified= for the owner specified. If only some locks are * acquired, all locks are released and the method returns false. *

    - * In addition, any locks acquired are added to the context OR transact= ion entry using {@link org.jboss.cache.invocation.InvocationContext#addLock= (Object)}. + * In addition, any locks acquired are added to the context OR transact= ion entry using {@link org.jboss.cache.InvocationContext#addLock(Object)}. *

    - * The owner for the lock is determined by passing the invocation conte= xt to {@link #getLockOwner(org.jboss.cache.invocation.InvocationContext)}. + * The owner for the lock is determined by passing the invocation conte= xt to {@link #getLockOwner(org.jboss.cache.InvocationContext)}. *

    * * @param node Node to lock @@ -192,9 +192,9 @@ * Locks the node and all child nodes, acquiring lock of type specified= for the owner specified. If only some locks are * acquired, all locks are released and the method returns false. *

    - * In addition, any locks acquired are added to the context OR transact= ion entry using {@link org.jboss.cache.invocation.InvocationContext#addLock= (Object)}. + * In addition, any locks acquired are added to the context OR transact= ion entry using {@link org.jboss.cache.InvocationContext#addLock(Object)}. *

    - * The owner for the lock is determined by passing the invocation conte= xt to {@link #getLockOwner(org.jboss.cache.invocation.InvocationContext)}. + * The owner for the lock is determined by passing the invocation conte= xt to {@link #getLockOwner(org.jboss.cache.InvocationContext)}. *

    * * @param fqn Node to lock Modified: core/trunk/src/main/java/org/jboss/cache/lock/LockUtil.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/lock/LockUtil.java 2008-08-25 = 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/lock/LockUtil.java 2008-08-25 = 23:17:22 UTC (rev 6614) @@ -3,10 +3,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.CommandsFactory; import org.jboss.cache.commands.write.PutDataMapCommand; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.transaction.GlobalTransaction; import org.jboss.cache.transaction.TransactionContext; import org.jboss.cache.transaction.TransactionTable; Modified: core/trunk/src/main/java/org/jboss/cache/lock/MVCCLockManager.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/lock/MVCCLockManager.java 2008= -08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/lock/MVCCLockManager.java 2008= -08-25 23:17:22 UTC (rev 6614) @@ -6,11 +6,11 @@ import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; import org.jboss.cache.InternalNode; +import org.jboss.cache.InvocationContext; import org.jboss.cache.Node; import org.jboss.cache.NodeSPI; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.invocation.InvocationContextContainer; import static org.jboss.cache.lock.LockType.READ; import org.jboss.cache.util.concurrent.locks.LockContainer; Modified: core/trunk/src/main/java/org/jboss/cache/lock/NodeBasedLockManage= r.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java= 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java= 2008-08-25 23:17:22 UTC (rev 6614) @@ -4,10 +4,10 @@ import org.apache.commons.logging.LogFactory; import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; -import org.jboss.cache.invocation.InvocationContext; = import java.util.ArrayList; import java.util.Collection; Modified: core/trunk/src/main/java/org/jboss/cache/lock/PessimisticNodeBase= dLockManager.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockM= anager.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockM= anager.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -3,10 +3,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.CommandsFactory; import org.jboss.cache.factories.annotations.Inject; -import org.jboss.cache.invocation.InvocationContext; import static org.jboss.cache.lock.LockType.WRITE; import org.jboss.cache.transaction.GlobalTransaction; import org.jboss.cache.transaction.TransactionTable; Modified: core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpc= Dispatcher.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispat= cher.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispat= cher.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,5 +1,6 @@ package org.jboss.cache.marshall; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.ReplicableCommand; import org.jboss.cache.commands.VisitableCommand; import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand; @@ -7,7 +8,6 @@ import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand; import org.jboss.cache.factories.ComponentRegistry; import org.jboss.cache.interceptors.InterceptorChain; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.invocation.InvocationContextContainer; import org.jgroups.Address; import org.jgroups.Channel; Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java 2008= -08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java 2008= -08-25 23:17:22 UTC (rev 6614) @@ -5,10 +5,10 @@ import org.jboss.cache.AbstractNodeFactory; import org.jboss.cache.Fqn; import org.jboss.cache.InternalNode; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.UnversionedNode; import org.jboss.cache.factories.annotations.Start; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.lock.IsolationLevel; = import java.util.Map; Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java 2008-= 08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java 2008-= 08-25 23:17:22 UTC (rev 6614) @@ -6,6 +6,7 @@ import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; import org.jboss.cache.InternalNode; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeFactory; import org.jboss.cache.NodeNotExistsException; import org.jboss.cache.NodeSPI; @@ -13,7 +14,6 @@ import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.NonVolatile; import org.jboss.cache.factories.annotations.Start; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.lock.LockManager; import static org.jboss.cache.lock.LockType.WRITE; import org.jboss.cache.lock.TimeoutException; @@ -87,7 +87,7 @@ } = /** - * Similar to {@link #wrapNodesForReading(org.jboss.cache.invocation.In= vocationContext, java.util.Collection)} except + * Similar to {@link #wrapNodesForReading(org.jboss.cache.InvocationCon= text, java.util.Collection)} except * that this version takes a single Fqn parameter to wrap a single node. * * @param ctx current invocation context @@ -243,7 +243,7 @@ } = /** - * The same as {@link #wrapNodeForWriting(org.jboss.cache.invocation.In= vocationContext, org.jboss.cache.Fqn, boolean, boolean, boolean, boolean, b= oolean)} + * The same as {@link #wrapNodeForWriting(org.jboss.cache.InvocationCon= text, org.jboss.cache.Fqn, boolean, boolean, boolean, boolean, boolean)} * except that it takes in an {@link org.jboss.cache.InternalNode} inst= ead of a {@link Fqn}. Saves on a lookup. *

    * Also assumes that the node exists, and hence will not be created. @@ -371,7 +371,7 @@ } = /** - * Identical to {@link #lockForWritingRecursive(org.jboss.cache.Fqn, or= g.jboss.cache.invocation.InvocationContext, java.util.List)} + * Identical to {@link #lockForWritingRecursive(org.jboss.cache.Fqn, or= g.jboss.cache.InvocationContext, java.util.List)} * except that it uses an {@link org.jboss.cache.InternalNode} instead = of an {@link Fqn} - saves a lookup. * * @param node node to lock recursively @@ -425,7 +425,7 @@ } = /** - * An overloaded version of {@link #isParentLockNeeded(org.jboss.cache.= Fqn, org.jboss.cache.invocation.InvocationContext)} + * An overloaded version of {@link #isParentLockNeeded(org.jboss.cache.= Fqn, org.jboss.cache.InvocationContext)} * which takes in an {@link org.jboss.cache.InternalNode} instead of a = {@link Fqn}. * * @param parent parent node to test Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 20= 08-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 20= 08-08-25 23:17:22 UTC (rev 6614) @@ -5,9 +5,9 @@ import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; import org.jboss.cache.InternalNode; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeNotExistsException; import org.jboss.cache.NodeSPI; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.invocation.NodeInvocationDelegate; import static org.jboss.cache.mvcc.ReadCommittedNode.Flags.*; = Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2= 008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2= 008-08-25 23:17:22 UTC (rev 6614) @@ -5,7 +5,8 @@ import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; import org.jboss.cache.InternalNode; -import org.jboss.cache.invocation.InvocationContext; +import org.jboss.cache.InvocationContext; + import static org.jboss.cache.mvcc.ReadCommittedNode.Flags.CHANGED; import static org.jboss.cache.mvcc.ReadCommittedNode.Flags.DELETED; import org.jboss.cache.optimistic.DataVersioningException; Modified: core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java 20= 08-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java 20= 08-08-25 23:17:22 UTC (rev 6614) @@ -1,8 +1,8 @@ package org.jboss.cache.notifications; = import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.buddyreplication.BuddyGroup; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.notifications.event.NodeModifiedEvent; import org.jgroups.View; = Modified: core/trunk/src/main/java/org/jboss/cache/notifications/NotifierIm= pl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.jav= a 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.jav= a 2008-08-25 23:17:22 UTC (rev 6614) @@ -49,6 +49,7 @@ import org.jboss.cache.CacheException; import org.jboss.cache.CacheSPI; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.buddyreplication.BuddyGroup; import org.jboss.cache.config.Configuration; import org.jboss.cache.factories.annotations.Destroy; @@ -56,7 +57,6 @@ import org.jboss.cache.factories.annotations.NonVolatile; import org.jboss.cache.factories.annotations.Start; import org.jboss.cache.factories.annotations.Stop; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.marshall.MarshalledValueMap; import org.jboss.cache.notifications.annotation.BuddyGroupChanged; import org.jboss.cache.notifications.annotation.CacheBlocked; @@ -673,7 +673,7 @@ = /** * Resets the current (passed-in) invocation, and returns a temp Invoca= tionContext containing its state so it can - * be restored later using {@link #restoreInvocationContext(org.jboss.c= ache.invocation.InvocationContext)} + * be restored later using {@link #restoreInvocationContext(org.jboss.c= ache.InvocationContext)} * * @param ctx the current context to be reset * @return a clone of ctx, before it was reset Modified: core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultSta= teTransferIntegrator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTran= sferIntegrator.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTran= sferIntegrator.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -12,13 +12,13 @@ import org.jboss.cache.CacheSPI; import org.jboss.cache.Fqn; import org.jboss.cache.InternalNode; +import org.jboss.cache.InvocationContext; import org.jboss.cache.Node; import org.jboss.cache.NodeSPI; import org.jboss.cache.buddyreplication.BuddyManager; import org.jboss.cache.config.Configuration; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.loader.CacheLoader; import org.jboss.cache.loader.CacheLoaderManager; import org.jboss.cache.marshall.NodeData; Modified: core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStat= eTransferIntegrator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStateTrans= ferIntegrator.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStateTrans= ferIntegrator.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -11,6 +11,7 @@ import org.jboss.cache.CacheException; import org.jboss.cache.CacheSPI; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.Node; import org.jboss.cache.NodeFactory; import org.jboss.cache.NodeSPI; @@ -20,7 +21,6 @@ import org.jboss.cache.eviction.EvictionEvent; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.Start; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.loader.CacheLoader; import org.jboss.cache.loader.CacheLoaderManager; import org.jboss.cache.marshall.NodeData; Modified: core/trunk/src/main/java/org/jboss/cache/transaction/MVCCTransact= ionContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/transaction/MVCCTransactionCon= text.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/transaction/MVCCTransactionCon= text.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -27,7 +27,7 @@ /** * Retrieves a node from the registry of looked up nodes in the current= scope. *

    - * This is not normally called directly since {@link org.jboss.cache.in= vocation.InvocationContext#lookUpNode(org.jboss.cache.Fqn)} + * This is not normally called directly since {@link org.jboss.cache.In= vocationContext#lookUpNode(org.jboss.cache.Fqn)} * would delegate to this method if a transaction is in scope. *

    * @@ -42,7 +42,7 @@ /** * Puts an entry in the registry of looked up nodes in the current scop= e. *

    - * This is not normally called directly since {@link org.jboss.cache.in= vocation.InvocationContext#putLookedUpNode(org.jboss.cache.Fqn, org.jboss.c= ache.NodeSPI)} + * This is not normally called directly since {@link org.jboss.cache.In= vocationContext#putLookedUpNode(org.jboss.cache.Fqn, org.jboss.cache.NodeSP= I)} * would delegate to this method if a transaction is in scope. *

    * @@ -57,7 +57,7 @@ /** * Clears the registry of looked up nodes. *

    - * This is not normally called directly since {@link org.jboss.cache.in= vocation.InvocationContext#clearLookedUpNodes()} + * This is not normally called directly since {@link org.jboss.cache.In= vocationContext#clearLookedUpNodes()} * would delegate to this method if a transaction is in scope. *

    */ @@ -69,7 +69,7 @@ /** * Retrieves a map of nodes looked up within the current invocation's s= cope. *

    - * This is not normally called directly since {@link org.jboss.cache.in= vocation.InvocationContext#getLookedUpNodes()} + * This is not normally called directly since {@link org.jboss.cache.In= vocationContext#getLookedUpNodes()} * would delegate to this method if a transaction is in scope. *

    * Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionC= ontext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext= .java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext= .java 2008-08-25 23:17:22 UTC (rev 6614) @@ -15,7 +15,7 @@ *

    * * @author Manik Surtani (manik(a)jbo= ss.org) - * @see org.jboss.cache.invocation.InvocationContext + * @see org.jboss.cache.InvocationContext */ public interface TransactionContext { @@ -80,7 +80,7 @@ /** * Adds a lock to the currently maintained collection of locks acquired. *

    - * Most code could not use this method directly, but use {@link org.jbo= ss.cache.invocation.InvocationContext#addLock(Object)} instead, + * Most code could not use this method directly, but use {@link org.jbo= ss.cache.InvocationContext#addLock(Object)} instead, * which would delegate to this method if a transaction is in scope or = otherwise use invocation-specific locks. *

    * Note that currently (as of 3.0.0) this lock is weakly typed. This i= s to allow support for both MVCC (which uses {@link org.jboss.cache.Fqn}s a= s locks) @@ -88,7 +88,7 @@ * legacy node locking schemes are dropped, this method will be more st= rongly typed to accept {@link org.jboss.cache.Fqn}. * * @param lock lock to add - * @see org.jboss.cache.invocation.InvocationContext#addLock(Object) + * @see org.jboss.cache.InvocationContext#addLock(Object) */ @SuppressWarnings("unchecked") void addLock(Object lock); @@ -96,7 +96,7 @@ /** * Removes a lock from the currently maintained collection of locks acq= uired. *

    - * Most code could not use this method directly, but use {@link org.jbo= ss.cache.invocation.InvocationContext#removeLock(Object)} instead, + * Most code could not use this method directly, but use {@link org.jbo= ss.cache.InvocationContext#removeLock(Object)} instead, * which would delegate to this method if a transaction is in scope or = otherwise use invocation-specific locks. *

    * Note that currently (as of 3.0.0) this lock is weakly typed. This i= s to allow support for both MVCC (which uses {@link org.jboss.cache.Fqn}s a= s locks) @@ -104,7 +104,7 @@ * legacy node locking schemes are dropped, this method will be more st= rongly typed to accept {@link org.jboss.cache.Fqn}. * * @param lock lock to remove - * @see org.jboss.cache.invocation.InvocationContext#removeLock(Object) + * @see org.jboss.cache.InvocationContext#removeLock(Object) */ @SuppressWarnings("unchecked") void removeLock(Object lock); @@ -112,21 +112,21 @@ /** * Clears all locks from the currently maintained collection of locks a= cquired. *

    - * Most code could not use this method directly, but use {@link org.jbo= ss.cache.invocation.InvocationContext#clearLocks()} instead, + * Most code could not use this method directly, but use {@link org.jbo= ss.cache.InvocationContext#clearLocks()} instead, * which would delegate to this method if a transaction is in scope or = otherwise use invocation-specific locks. *

    * Note that currently (as of 3.0.0) this lock is weakly typed. This i= s to allow support for both MVCC (which uses {@link org.jboss.cache.Fqn}s a= s locks) * as well as legacy Optimistic and Pessimistic Locking schemes (which = use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for * legacy node locking schemes are dropped, this method will be more st= rongly typed to accept {@link org.jboss.cache.Fqn}. * - * @see org.jboss.cache.invocation.InvocationContext#clearLocks() + * @see org.jboss.cache.InvocationContext#clearLocks() */ void clearLocks(); = /** * Adds a List of locks to the currently maintained collection of locks= acquired. *

    - * Most code could not use this method directly, but use {@link org.jbo= ss.cache.invocation.InvocationContext#addAllLocks(java.util.List)} instead, + * Most code could not use this method directly, but use {@link org.jbo= ss.cache.InvocationContext#addAllLocks(java.util.List)} instead, * which would delegate to this method if a transaction is in scope or = otherwise use invocation-specific locks. *

    * Note that currently (as of 3.0.0) this list is unchecked. This is t= o allow support for both MVCC (which uses Fqns as locks) @@ -134,7 +134,7 @@ * legacy node locking schemes are dropped, this method will be more st= rongly typed to accept List. * * @param newLocks locks to add - * @see org.jboss.cache.invocation.InvocationContext#addAllLocks(java.u= til.List) + * @see org.jboss.cache.InvocationContext#addAllLocks(java.util.List) */ @SuppressWarnings("unchecked") void addAllLocks(List newLocks); @@ -142,7 +142,7 @@ /** * Returns an immutable, defensive copy of the List of locks currently= maintained for the transaction. *

    - * Most code could not use this method directly, but use {@link org.jbo= ss.cache.invocation.InvocationContext#getLocks()} instead, + * Most code could not use this method directly, but use {@link org.jbo= ss.cache.InvocationContext#getLocks()} instead, * which would delegate to this method if a transaction is in scope or = otherwise use invocation-specific locks. *

    * Note that currently (as of 3.0.0) this list is unchecked. This is t= o allow support for both MVCC (which uses Fqns as locks) @@ -150,13 +150,13 @@ * legacy node locking schemes are dropped, this method will be more st= rongly typed to return List. * * @return locks held in current scope. - * @see org.jboss.cache.invocation.InvocationContext#getLocks() + * @see org.jboss.cache.InvocationContext#getLocks() */ @SuppressWarnings("unchecked") List getLocks(); = /** - * Most code could not use this method directly, but use {@link org.jbo= ss.cache.invocation.InvocationContext#hasLock(Object)} ()} instead, + * Most code could not use this method directly, but use {@link org.jbo= ss.cache.InvocationContext#hasLock(Object)} ()} instead, * which would delegate to this method if a transaction is in scope or = otherwise use invocation-specific locks. * * @param lock lock to test Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionT= able.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.j= ava 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.j= ava 2008-08-25 23:17:22 UTC (rev 6614) @@ -9,11 +9,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.CacheException; +import org.jboss.cache.InvocationContext; import org.jboss.cache.RPCManager; import org.jboss.cache.factories.annotations.Inject; import org.jboss.cache.factories.annotations.NonVolatile; import org.jboss.cache.factories.context.ContextFactory; -import org.jboss.cache.invocation.InvocationContext; import org.jgroups.Address; = import javax.transaction.Status; Modified: core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java 2008-08-= 25 22:08:47 UTC (rev 6613) +++ core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java 2008-08-= 25 23:17:22 UTC (rev 6614) @@ -11,12 +11,12 @@ import org.jboss.cache.CacheSPI; import org.jboss.cache.DefaultCacheFactory; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.Node; import org.jboss.cache.config.Configuration; import org.jboss.cache.config.Configuration.CacheMode; import org.jboss.cache.config.Configuration.NodeLockingScheme; import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.util.TestingUtil; import static org.testng.AssertJUnit.*; import org.testng.annotations.AfterMethod; Modified: core/trunk/src/test/java/org/jboss/cache/api/SyncReplTxTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/api/SyncReplTxTest.java 2008-0= 8-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/test/java/org/jboss/cache/api/SyncReplTxTest.java 2008-0= 8-25 23:17:22 UTC (rev 6614) @@ -11,12 +11,12 @@ import org.jboss.cache.CacheSPI; import org.jboss.cache.DefaultCacheFactory; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.Node; import org.jboss.cache.config.Configuration; import org.jboss.cache.config.Configuration.CacheMode; import org.jboss.cache.config.Configuration.NodeLockingScheme; import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.util.TestingUtil; import static org.testng.AssertJUnit.*; import org.testng.annotations.AfterMethod; Modified: core/trunk/src/test/java/org/jboss/cache/commands/TestContextBase= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/commands/TestContextBase.java = 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/test/java/org/jboss/cache/commands/TestContextBase.java = 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,7 +1,7 @@ package org.jboss.cache.commands; = import org.jboss.cache.DataContainer; -import org.jboss.cache.invocation.InvocationContext; +import org.jboss.cache.InvocationContext; import org.jboss.cache.invocation.LegacyInvocationContext; import org.jboss.cache.invocation.MVCCInvocationContext; = Modified: core/trunk/src/test/java/org/jboss/cache/commands/legacy/read/Gra= vitateDataCommandTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/commands/legacy/read/Gravitate= DataCommandTest.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/test/java/org/jboss/cache/commands/legacy/read/Gravitate= DataCommandTest.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -6,11 +6,11 @@ import org.jboss.cache.CacheSPI; import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.buddyreplication.BuddyFqnTransformer; import org.jboss.cache.buddyreplication.BuddyManager; import org.jboss.cache.buddyreplication.GravitateResult; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.invocation.LegacyInvocationContext; import org.jboss.cache.mock.MockNodesFixture; import org.jboss.cache.mock.NodeSpiMock; Modified: core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/Pu= tDataMapCommandTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/PutDataM= apCommandTest.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/PutDataM= apCommandTest.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -5,8 +5,8 @@ import org.easymock.IMocksControl; import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.TestContextBase; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.mock.NodeSpiMock; import org.jboss.cache.notifications.Notifier; import org.jboss.cache.notifications.event.NodeModifiedEvent; Modified: core/trunk/src/test/java/org/jboss/cache/commands/read/AbstractDa= taCommandTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/commands/read/AbstractDataComm= andTest.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/test/java/org/jboss/cache/commands/read/AbstractDataComm= andTest.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -3,8 +3,8 @@ import static org.easymock.EasyMock.createMock; import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.TestContextBase; -import org.jboss.cache.invocation.InvocationContext; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; = Modified: core/trunk/src/test/java/org/jboss/cache/commands/read/GetKeyValu= eCommandTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/commands/read/GetKeyValueComma= ndTest.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/test/java/org/jboss/cache/commands/read/GetKeyValueComma= ndTest.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -5,8 +5,8 @@ import org.easymock.IMocksControl; import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.TestContextBase; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.mock.NodeSpiMock; import org.jboss.cache.notifications.Notifier; import org.testng.annotations.BeforeMethod; Modified: core/trunk/src/test/java/org/jboss/cache/commands/write/AbstractV= ersionedDataCommandTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/commands/write/AbstractVersion= edDataCommandTest.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/test/java/org/jboss/cache/commands/write/AbstractVersion= edDataCommandTest.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -4,8 +4,8 @@ import org.easymock.IMocksControl; import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.TestContextBase; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.mock.MockNodesFixture; import org.jboss.cache.notifications.Notifier; import org.jboss.cache.optimistic.DataVersion; Modified: core/trunk/src/test/java/org/jboss/cache/interceptors/LegacyInter= ceptorTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/interceptors/LegacyInterceptor= Test.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/test/java/org/jboss/cache/interceptors/LegacyInterceptor= Test.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -4,8 +4,8 @@ import org.jboss.cache.CacheSPI; import org.jboss.cache.DefaultCacheFactory; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.write.PutKeyValueCommand; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.util.TestingUtil; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeMethod; Modified: core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManager= RecordingTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecord= ingTest.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecord= ingTest.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,10 +1,10 @@ package org.jboss.cache.lock; = import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.UnversionedNode; import org.jboss.cache.factories.context.ContextFactory; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.invocation.InvocationContextContainer; import org.jboss.cache.invocation.NodeInvocationDelegate; import static org.jboss.cache.lock.LockType.WRITE; Modified: core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValue= Test.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.j= ava 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.j= ava 2008-08-25 23:17:22 UTC (rev 6614) @@ -3,6 +3,7 @@ import org.jboss.cache.CacheException; import org.jboss.cache.CacheSPI; import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.write.PutDataMapCommand; import org.jboss.cache.commands.write.PutKeyValueCommand; @@ -13,7 +14,6 @@ import org.jboss.cache.interceptors.MarshalledValueInterceptor; import org.jboss.cache.interceptors.base.CommandInterceptor; import org.jboss.cache.invocation.CacheInvocationDelegate; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.loader.DummyInMemoryCacheLoader; import org.jboss.cache.notifications.annotation.CacheListener; import org.jboss.cache.notifications.annotation.NodeModified; Modified: core/trunk/src/test/java/org/jboss/cache/mock/NodeSpiMock.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/mock/NodeSpiMock.java 2008-08-= 25 22:08:47 UTC (rev 6613) +++ core/trunk/src/test/java/org/jboss/cache/mock/NodeSpiMock.java 2008-08-= 25 23:17:22 UTC (rev 6614) @@ -4,9 +4,9 @@ import org.jboss.cache.DataContainer; import org.jboss.cache.Fqn; import org.jboss.cache.InternalNode; +import org.jboss.cache.InvocationContext; import org.jboss.cache.Node; import org.jboss.cache.NodeSPI; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.lock.NodeLock; import org.jboss.cache.optimistic.DataVersion; import org.jboss.cache.transaction.GlobalTransaction; Modified: core/trunk/src/test/java/org/jboss/cache/notifications/NotifierTe= st.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/notifications/NotifierTest.jav= a 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/test/java/org/jboss/cache/notifications/NotifierTest.jav= a 2008-08-25 23:17:22 UTC (rev 6614) @@ -3,9 +3,9 @@ import static org.easymock.EasyMock.createNiceMock; import org.jboss.cache.CacheSPI; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.buddyreplication.BuddyGroup; import org.jboss.cache.config.Configuration; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.invocation.LegacyInvocationContext; import org.jboss.cache.notifications.annotation.*; import org.jboss.cache.notifications.event.*; Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/ConcurrentTra= nsactionTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/optimistic/ConcurrentTransacti= onTest.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/test/java/org/jboss/cache/optimistic/ConcurrentTransacti= onTest.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -8,13 +8,13 @@ = import org.jboss.cache.CacheSPI; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.VisitableCommand; import org.jboss.cache.commands.tx.OptimisticPrepareCommand; import org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor; import org.jboss.cache.interceptors.TxInterceptor; import org.jboss.cache.interceptors.base.CommandInterceptor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.util.TestingUtil; import static org.testng.AssertJUnit.*; import org.testng.annotations.AfterMethod; Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/MockFailureIn= terceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/optimistic/MockFailureIntercep= tor.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/test/java/org/jboss/cache/optimistic/MockFailureIntercep= tor.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,9 +1,9 @@ package org.jboss.cache.optimistic; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.ReplicableCommand; import org.jboss.cache.commands.VisitableCommand; import org.jboss.cache.interceptors.base.CommandInterceptor; -import org.jboss.cache.invocation.InvocationContext; = import java.util.ArrayList; import java.util.List; Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/MockIntercept= or.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/optimistic/MockInterceptor.jav= a 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/test/java/org/jboss/cache/optimistic/MockInterceptor.jav= a 2008-08-25 23:17:22 UTC (rev 6614) @@ -1,9 +1,9 @@ package org.jboss.cache.optimistic; = +import org.jboss.cache.InvocationContext; import org.jboss.cache.commands.ReplicableCommand; import org.jboss.cache.commands.VisitableCommand; import org.jboss.cache.interceptors.base.CommandInterceptor; -import org.jboss.cache.invocation.InvocationContext; = import java.util.ArrayList; import java.util.List; Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLoc= kInterceptorTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInter= ceptorTest.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInter= ceptorTest.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -2,11 +2,11 @@ = import org.jboss.cache.CacheSPI; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.VisitableCommand; import org.jboss.cache.interceptors.OptimisticInterceptor; import org.jboss.cache.interceptors.OptimisticLockingInterceptor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.lock.LockType; import static org.jboss.cache.lock.LockType.READ; import static org.jboss.cache.lock.LockType.WRITE; Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInte= rceptorTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorIntercepto= rTest.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorIntercepto= rTest.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -8,6 +8,7 @@ = import org.jboss.cache.CacheSPI; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.VisitableCommand; import org.jboss.cache.commands.tx.CommitCommand; @@ -18,7 +19,6 @@ import org.jboss.cache.interceptors.OptimisticNodeInterceptor; import org.jboss.cache.interceptors.OptimisticValidatorInterceptor; import org.jboss.cache.interceptors.base.CommandInterceptor; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.loader.SamplePojo; import org.jboss.cache.transaction.GlobalTransaction; import org.jboss.cache.transaction.OptimisticTransactionContext; Modified: core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java 2= 008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java 2= 008-08-25 23:17:22 UTC (rev 6614) @@ -9,12 +9,12 @@ import org.jboss.cache.Cache; import org.jboss.cache.DefaultCacheFactory; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.Node; import org.jboss.cache.NodeSPI; import org.jboss.cache.config.Configuration.CacheMode; import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; import org.jboss.cache.invocation.CacheInvocationDelegate; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.util.TestingUtil; import static org.testng.AssertJUnit.*; import org.testng.annotations.AfterMethod; Modified: core/trunk/src/test/java/org/jboss/cache/util/internals/Replicati= onListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationList= ener.java 2008-08-25 22:08:47 UTC (rev 6613) +++ core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationList= ener.java 2008-08-25 23:17:22 UTC (rev 6614) @@ -2,12 +2,12 @@ = import org.jboss.cache.Cache; import org.jboss.cache.Fqn; +import org.jboss.cache.InvocationContext; import org.jboss.cache.RPCManager; import org.jboss.cache.commands.ReplicableCommand; import org.jboss.cache.commands.remote.ReplicateCommand; import org.jboss.cache.commands.tx.PrepareCommand; import org.jboss.cache.factories.ComponentRegistry; -import org.jboss.cache.invocation.InvocationContext; import org.jboss.cache.io.ByteBuffer; import org.jboss.cache.marshall.AbstractMarshaller; import org.jboss.cache.marshall.CommandAwareRpcDispatcher; --===============5612552212579032597==-- From jboss-qa-internal at redhat.com Tue Aug 26 02:24:31 2008 Content-Type: multipart/mixed; boundary="===============1914150179949999659==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23430?= Date: Tue, 26 Aug 2008 02:24:29 -0400 Message-ID: <1633139943.17831219731869616.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 446625537.16561219698338698.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============1914150179949999659== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/430/changes --===============1914150179949999659==-- From jbosscache-commits at lists.jboss.org Tue Aug 26 02:45:58 2008 Content-Type: multipart/mixed; boundary="===============3025517513595176377==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6615 - core/trunk/src/main/java/org/jboss/cache/eviction. Date: Tue, 26 Aug 2008 02:44:18 -0400 Message-ID: --===============3025517513595176377== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-26 02:44:18 -0400 (Tue, 26 Aug 2008) New Revision: 6615 Removed: core/trunk/src/main/java/org/jboss/cache/eviction/Modernizable.java Log: Ghost file Deleted: core/trunk/src/main/java/org/jboss/cache/eviction/Modernizable.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/Modernizable.java 200= 8-08-25 23:17:22 UTC (rev 6614) +++ core/trunk/src/main/java/org/jboss/cache/eviction/Modernizable.java 200= 8-08-26 06:44:18 UTC (rev 6615) @@ -1,17 +0,0 @@ -package org.jboss.cache.eviction; - -import org.jboss.cache.config.EvictionAlgorithmConfig; - -/** - * Attached to deprecated eviction configuration elements that know how to= map to modern counterparts. This interface - * is itself deprecated and is only used to bridge deprecated configuratio= ns. - * - * @author Manik Surtani (manik(a)jbo= ss.org) - * @since 3.0 - * @deprecated - */ -(a)Deprecated -public interface Modernizable -{ - EvictionAlgorithmConfig modernize(); -} --===============3025517513595176377==-- From jbosscache-commits at lists.jboss.org Tue Aug 26 02:56:10 2008 Content-Type: multipart/mixed; boundary="===============8487982684604509172==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6616 - in core/trunk/src/main/java/org/jboss/cache: invocation and 1 other directory. Date: Tue, 26 Aug 2008 02:56:10 -0400 Message-ID: --===============8487982684604509172== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-26 02:56:09 -0400 (Tue, 26 Aug 2008) New Revision: 6616 Removed: core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationCo= ntext.java Modified: core/trunk/src/main/java/org/jboss/cache/InvocationContext.java core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationCont= ext.java core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContex= t.java Log: Made invocation context an abstract class instead of an interface Modified: core/trunk/src/main/java/org/jboss/cache/InvocationContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-08= -26 06:44:18 UTC (rev 6615) +++ core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-08= -26 06:56:09 UTC (rev 6616) @@ -1,12 +1,19 @@ package org.jboss.cache; = +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.cache.annotations.Compat; import org.jboss.cache.commands.VisitableCommand; import org.jboss.cache.config.Option; import org.jboss.cache.marshall.MethodCall; import org.jboss.cache.transaction.GlobalTransaction; import org.jboss.cache.transaction.TransactionContext; +import org.jboss.cache.transaction.TransactionTable; +import org.jboss.cache.util.Immutables; = import javax.transaction.Transaction; +import java.util.Collections; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; = @@ -14,23 +21,48 @@ * A context that holds information regarding the scope of a single invoca= tion. May delegate some calls to a {@link org.jboss.cache.transaction.Tran= sactionContext} * if one is in scope. *

    - * Note that prior to 3.0.0, InvocationContext was a concrete class and no= t an interface. + * Note that prior to 3.0.0, InvocationContext was a concrete class and no= t an abstract one. *

    * * @author Manik Surtani (manik(a)jbo= ss.org) * @see org.jboss.cache.transaction.TransactionContext */ @SuppressWarnings("deprecation") -public interface InvocationContext +(a)Compat(notes =3D "This really ought to be an interface, just like Trans= actionContext, but since this is public API making this an interface will b= reak binary compat with 2.x.") +public abstract class InvocationContext { + private static final Log log =3D LogFactory.getLog(InvocationContext.cl= ass); + private static final boolean trace =3D log.isTraceEnabled(); + + private Transaction transaction; + private GlobalTransaction globalTransaction; + protected TransactionContext transactionContext; + private Option optionOverrides; + // defaults to true. + private boolean originLocal =3D true; + private boolean localRollbackOnly; + @Deprecated + private MethodCall methodCall; + @Deprecated + private VisitableCommand command; + /** + * LinkedHashSet of locks acquired by the invocation. We use a LinkedHa= shSet because we need efficient Set semantics + * but also need guaranteed ordering for use by lock release code (see = JBCCACHE-874). + *

    + * This needs to be unchecked since we support both MVCC (Fqns held her= e) or legacy Opt/Pess locking (NodeLocks held here). + * once we drop support for opt/pess locks we can genericise this to co= ntain Fqns. - Manik Surtani, June 2008 + */ + protected LinkedHashSet invocationLocks; + + /** * Retrieves a node from the registry of looked up nodes in the current= scope. * * @param fqn fqn to look up * @return a node, or null if it cannot be found. * @since 3.0. */ - NodeSPI lookUpNode(Fqn fqn); + public abstract NodeSPI lookUpNode(Fqn fqn); = /** * Puts an entry in the registry of looked up nodes in the current scop= e. @@ -39,14 +71,14 @@ * @param n node to add * @since 3.0. */ - void putLookedUpNode(Fqn f, NodeSPI n); + public abstract void putLookedUpNode(Fqn f, NodeSPI n); = /** * Clears the registry of looked up nodes. * * @since 3.0. */ - void clearLookedUpNodes(); + public abstract void clearLookedUpNodes(); = /** * Retrieves a map of nodes looked up within the current invocation's s= cope. @@ -54,34 +86,46 @@ * @return a map of looked up nodes. * @since 3.0 */ - Map getLookedUpNodes(); + public abstract Map getLookedUpNodes(); = /** * Marks teh context as only rolling back. * * @param localRollbackOnly if true, the context is only rolling back. */ - void setLocalRollbackOnly(boolean localRollbackOnly); + public void setLocalRollbackOnly(boolean localRollbackOnly) + { + this.localRollbackOnly =3D localRollbackOnly; + } = /** * Retrieves the transaction associated with this invocation * * @return The transaction associated with this invocation */ - Transaction getTransaction(); + public Transaction getTransaction() + { + return transaction; + } = /** * Sets a transaction object on the invocation context. * * @param transaction transaction to set */ - void setTransaction(Transaction transaction); + public void setTransaction(Transaction transaction) + { + this.transaction =3D transaction; + } = /** * @return the transaction entry associated with the current transactio= n, or null if the current thread is not associated with a transaction. * @since 2.2.0 */ - TransactionContext getTransactionContext(); + public TransactionContext getTransactionContext() + { + return transactionContext; + } = /** * Sets the transaction context to be associated with the current threa= d. @@ -89,47 +133,73 @@ * @param transactionContext transaction context to set * @since 2.2.0 */ - void setTransactionContext(TransactionContext transactionContext); + public void setTransactionContext(TransactionContext transactionContext) + { + this.transactionContext =3D transactionContext; + } = /** * Retrieves the global transaction associated with this invocation * * @return the global transaction associated with this invocation */ - GlobalTransaction getGlobalTransaction(); + public GlobalTransaction getGlobalTransaction() + { + return globalTransaction; + } = /** * Sets the global transaction associated with this invocation * * @param globalTransaction global transaction to set */ - void setGlobalTransaction(GlobalTransaction globalTransaction); + public void setGlobalTransaction(GlobalTransaction globalTransaction) + { + this.globalTransaction =3D globalTransaction; + } = + /** * Retrieves the option overrides associated with this invocation * * @return the option overrides associated with this invocation */ - Option getOptionOverrides(); + public Option getOptionOverrides() + { + if (optionOverrides =3D=3D null) + { + optionOverrides =3D new Option(); + } + return optionOverrides; + } = /** * @return true of no options have been set on this context, false othe= rwise. */ - boolean isOptionsUninitialised(); + public boolean isOptionsUninitialised() + { + return optionOverrides =3D=3D null; + } = /** * Sets the option overrides to be associated with this invocation * * @param optionOverrides options to set */ - void setOptionOverrides(Option optionOverrides); + public void setOptionOverrides(Option optionOverrides) + { + this.optionOverrides =3D optionOverrides; + } = /** * Tests if this invocation originated locally or from a remote cache. * * @return true if the invocation originated locally. */ - boolean isOriginLocal(); + public boolean isOriginLocal() + { + return originLocal; + } = /** * Returns an immutable, defensive copy of the List of locks currently= maintained for the current scope. @@ -144,7 +214,12 @@ * @return locks held in current scope. */ @SuppressWarnings("unchecked") - List getLocks(); + public List getLocks() + { + // first check transactional scope + if (transactionContext !=3D null) return transactionContext.getLocks= (); + return invocationLocks =3D=3D null || invocationLocks.isEmpty() ? Co= llections.emptyList() : Immutables.immutableListConvert(invocationLocks); + } = /** * Adds a List of locks to the currently maintained collection of locks= acquired. @@ -159,7 +234,20 @@ * @param locks locks to add */ @SuppressWarnings("unchecked") - void addAllLocks(List locks); + public void addAllLocks(List locks) + { + // first check transactional scope + if (transactionContext !=3D null) + { + transactionContext.addAllLocks(locks); + } + else + { + // no need to worry about concurrency here - a context is only va= lid for a single thread. + if (invocationLocks =3D=3D null) invocationLocks =3D new LinkedHa= shSet(4); + invocationLocks.addAll(locks); + } + } = /** * Adds a lock to the currently maintained collection of locks acquired. @@ -174,7 +262,20 @@ * @param lock lock to add */ @SuppressWarnings("unchecked") - void addLock(Object lock); + public void addLock(Object lock) + { + // first check transactional scope + if (transactionContext !=3D null) + { + transactionContext.addLock(lock); + } + else + { + // no need to worry about concurrency here - a context is only va= lid for a single thread. + if (invocationLocks =3D=3D null) invocationLocks =3D new LinkedHa= shSet(4); + invocationLocks.add(lock); + } + } = /** * Removes a lock from the currently maintained collection of locks acq= uired. @@ -189,7 +290,19 @@ * @param lock lock to remove */ @SuppressWarnings("unchecked") - void removeLock(Object lock); + public void removeLock(Object lock) + { + // first check transactional scope + if (transactionContext !=3D null) + { + transactionContext.removeLock(lock); + } + else + { + // no need to worry about concurrency here - a context is only va= lid for a single thread. + if (invocationLocks !=3D null) invocationLocks.remove(lock); + } + } = /** * Clears all locks from the currently maintained collection of locks a= cquired. @@ -201,9 +314,20 @@ * as well as legacy Optimistic and Pessimistic Locking schemes (which = use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for * legacy node locking schemes are dropped, this method will be more st= rongly typed to accept {@link Fqn}. */ - void clearLocks(); + public void clearLocks() + { + // first check transactional scope + if (transactionContext !=3D null) + { + transactionContext.clearLocks(); + } + else + { + // no need to worry about concurrency here - a context is only va= lid for a single thread. + if (invocationLocks !=3D null) invocationLocks.clear(); + } + } = - /** * Note that if a transaction is in scope, implementations should test = this lock from on {@link org.jboss.cache.transaction.TransactionContext}. * Using this method should always ensure locks checked in the appropri= ate scope. @@ -211,12 +335,26 @@ * @param lock lock to test * @return true if the lock being tested is already held in the current= scope, false otherwise. */ - boolean hasLock(Object lock); + public boolean hasLock(Object lock) + { + // first check transactional scope + if (transactionContext !=3D null) + { + return transactionContext.hasLock(lock); + } + else + { + return invocationLocks !=3D null && invocationLocks.contains(lock= ); + } + } = /** * @return true if options exist to suppress locking - false otherwise.= Note that this is only used by the {@link org.jboss.cache.interceptors.Pe= ssimisticLockInterceptor}. */ - boolean isLockingSuppressed(); + public boolean isLockingSuppressed() + { + return getOptionOverrides() !=3D null && getOptionOverrides().isSupp= ressLocking(); + } = /** * If set to true, the invocation is assumed to have originated locally= . If set to false, @@ -224,17 +362,32 @@ * * @param originLocal flag to set */ - void setOriginLocal(boolean originLocal); + public void setOriginLocal(boolean originLocal) + { + this.originLocal =3D originLocal; + } = /** * @return true if the current transaction is set to rollback only. */ - boolean isLocalRollbackOnly(); + public boolean isLocalRollbackOnly() + { + return localRollbackOnly; + } = /** * Resets the context, freeing up any references. */ - void reset(); + public void reset() + { + transaction =3D null; + globalTransaction =3D null; + optionOverrides =3D null; + originLocal =3D true; + invocationLocks =3D null; + methodCall =3D null; + command =3D null; + } = /** * This is a "copy-factory-method" that should be used whenever a clone= of this class is needed. The resulting instance @@ -245,22 +398,50 @@ * @return a new InvocationContext */ @SuppressWarnings("unchecked") - InvocationContext copy(); + public abstract InvocationContext copy(); = /** * Sets the state of the InvocationContext based on the template contex= t passed in * * @param template template to copy from */ - void setState(InvocationContext template); + public void setState(InvocationContext template) + { + if (template =3D=3D null) + { + throw new NullPointerException("Template InvocationContext passed= in to InvocationContext.setState() passed in is null"); + } = + this.setGlobalTransaction(template.getGlobalTransaction()); + this.setLocalRollbackOnly(template.isLocalRollbackOnly()); + this.setOptionOverrides(template.getOptionOverrides()); + this.setOriginLocal(template.isOriginLocal()); + this.setTransaction(template.getTransaction()); + } + /** * @return the method call associated with this invocation */ @Deprecated @SuppressWarnings("deprecation") - MethodCall getMethodCall(); + public MethodCall getMethodCall() + { + if (methodCall =3D=3D null) + { + methodCall =3D createMethodCall(); + } + return methodCall; + } = + @SuppressWarnings("deprecation") + private MethodCall createMethodCall() + { + if (command =3D=3D null) return null; + MethodCall call =3D new MethodCall(); + call.setMethodId(command.getCommandId()); + call.setArgs(command.getParameters()); + return call; + } = /** * Sets the method call associated with this invocation. @@ -269,16 +450,28 @@ * @deprecated not used anymore. Interceptors will get a {@link org.jb= oss.cache.commands.ReplicableCommand} instance passed in along with an Invo= cationContext. */ @Deprecated - void setMethodCall(MethodCall methodCall); + public void setMethodCall(MethodCall methodCall) + { + this.methodCall =3D methodCall; + } = /** * If the lock acquisition timeout is overridden for current call using= an option, then return that one. * If not overridden, return default value. * - * @param defaultTimeout timeout to fall back to + * @param timeout timeout to fall back to * @return timeout to use */ - long getLockAcquisitionTimeout(long defaultTimeout); + public long getLockAcquisitionTimeout(long timeout) + { + // TODO: this stuff really doesn't belong here. Put it somewhere el= se. + if (getOptionOverrides() !=3D null + && getOptionOverrides().getLockAcquisitionTimeout() >=3D 0) + { + timeout =3D getOptionOverrides().getLockAcquisitionTimeout(); + } + return timeout; + } = /** * This is only used for backward compatibility with old interceptors i= mplementation and should NOT be @@ -289,7 +482,10 @@ */ @Deprecated @SuppressWarnings("deprecation") - void setCommand(VisitableCommand cacheCommand); + public void setCommand(VisitableCommand cacheCommand) + { + this.command =3D cacheCommand; + } = /** * @return command that is in scope @@ -297,18 +493,97 @@ */ @Deprecated @SuppressWarnings("deprecation") - VisitableCommand getCommand(); + public VisitableCommand getCommand() + { + return command; + } = /** * @return true if there is current transaction associated with the inv= ocation, and this transaction is in a valid state. */ - boolean isValidTransaction(); + public boolean isValidTransaction() + { + // ought to move to the transaction context + return transaction !=3D null && TransactionTable.isValid(transaction= ); + } = /** * Throws the given throwable provided no options suppress or prevent t= his from happening. * - * @param throwable throwable to throw + * @param e throwable to throw * @throws Throwable if allowed to throw one. */ - void throwIfNeeded(Throwable throwable) throws Throwable; + public void throwIfNeeded(Throwable e) throws Throwable + { + // TODO: this stuff really doesn't belong here. Put it somewhere el= se. + Option optionOverride =3D getOptionOverrides(); + boolean shouldRethtrow =3D optionOverride =3D=3D null || !optionOver= ride.isFailSilently(); + if (!shouldRethtrow) + { + if (trace) + log.trace("There was a problem handling this request, but fail= Silently was set, so suppressing exception", e); + return; + } + throw e; + } + + @SuppressWarnings("unchecked") + protected void doCopy(InvocationContext copy) + { + copy.command =3D command; + copy.globalTransaction =3D globalTransaction; + copy.invocationLocks =3D invocationLocks =3D=3D null ? null : new Li= nkedHashSet(invocationLocks); + copy.localRollbackOnly =3D localRollbackOnly; + copy.optionOverrides =3D optionOverrides =3D=3D null ? null : option= Overrides.copy(); + copy.originLocal =3D originLocal; + copy.transaction =3D transaction; + copy.transactionContext =3D transactionContext; + } + + @Override + public String toString() + { + return "InvocationContext{" + + "transaction=3D" + transaction + + ", globalTransaction=3D" + globalTransaction + + ", transactionContext=3D" + transactionContext + + ", optionOverrides=3D" + optionOverrides + + ", originLocal=3D" + originLocal + + '}'; + } + + @Override + public boolean equals(Object o) + { + if (this =3D=3D o) return true; + if (o =3D=3D null || getClass() !=3D o.getClass()) return false; + + final InvocationContext that =3D (InvocationContext) o; + + if (localRollbackOnly !=3D that.localRollbackOnly) return false; + if (originLocal !=3D that.originLocal) return false; + if (globalTransaction !=3D null ? !globalTransaction.equals(that.glo= balTransaction) : that.globalTransaction !=3D null) + { + return false; + } + if (optionOverrides !=3D null ? !optionOverrides.equals(that.optionO= verrides) : that.optionOverrides !=3D null) + { + return false; + } + if (transaction !=3D null ? !transaction.equals(that.transaction) : = that.transaction !=3D null) return false; + + return true; + } + + @Override + public int hashCode() + { + int result; + result =3D (transaction !=3D null ? transaction.hashCode() : 0); + result =3D 29 * result + (globalTransaction !=3D null ? globalTransa= ction.hashCode() : 0); + result =3D 29 * result + (optionOverrides !=3D null ? optionOverride= s.hashCode() : 0); + result =3D 29 * result + (originLocal ? 1 : 0); + result =3D 29 * result + (localRollbackOnly ? 1 : 0); + return result; + } } Deleted: core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvoca= tionContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationC= ontext.java 2008-08-26 06:44:18 UTC (rev 6615) +++ core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationC= ontext.java 2008-08-26 06:56:09 UTC (rev 6616) @@ -1,370 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package org.jboss.cache.invocation; - -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.List; - -import javax.transaction.Transaction; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jboss.cache.InvocationContext; -import org.jboss.cache.commands.VisitableCommand; -import org.jboss.cache.config.Option; -import org.jboss.cache.marshall.MethodCall; -import org.jboss.cache.transaction.GlobalTransaction; -import org.jboss.cache.transaction.TransactionContext; -import org.jboss.cache.transaction.TransactionTable; -import org.jboss.cache.util.Immutables; - -/** - * This context holds information specific to a method invocation. This i= s used for Optimistic and Pessimisic Node Locking Schemes. - * - * @author Manik Surtani (manik(a)jbo= ss.org) - */ -(a)SuppressWarnings("deprecation") -public abstract class AbstractInvocationContext implements InvocationConte= xt -{ - private static final Log log =3D LogFactory.getLog(AbstractInvocationCo= ntext.class); - private static final boolean trace =3D log.isTraceEnabled(); - - private Transaction transaction; - private GlobalTransaction globalTransaction; - protected TransactionContext transactionContext; - private Option optionOverrides; - // defaults to true. - private boolean originLocal =3D true; - private boolean localRollbackOnly; - @Deprecated - private MethodCall methodCall; - @Deprecated - private VisitableCommand command; - - /** - * LinkedHashSet of locks acquired by the invocation. We use a LinkedHa= shSet because we need efficient Set semantics - * but also need guaranteed ordering for use by lock release code (see = JBCCACHE-874). - *

    - * This needs to be unchecked since we support both MVCC (Fqns held her= e) or legacy Opt/Pess locking (NodeLocks held here). - * once we drop support for opt/pess locks we can genericise this to co= ntain Fqns. - Manik Surtani, June 2008 - */ - protected LinkedHashSet invocationLocks; - - public void setLocalRollbackOnly(boolean localRollbackOnly) - { - this.localRollbackOnly =3D localRollbackOnly; - } - - public Transaction getTransaction() - { - return transaction; - } - - public void setTransaction(Transaction transaction) - { - this.transaction =3D transaction; - } - - public TransactionContext getTransactionContext() - { - return transactionContext; - } - - public void setTransactionContext(TransactionContext transactionContext) - { - this.transactionContext =3D transactionContext; - } - - public GlobalTransaction getGlobalTransaction() - { - return globalTransaction; - } - - public void setGlobalTransaction(GlobalTransaction globalTransaction) - { - this.globalTransaction =3D globalTransaction; - } - - public Option getOptionOverrides() - { - if (optionOverrides =3D=3D null) - { - optionOverrides =3D new Option(); - } - return optionOverrides; - } - - public boolean isOptionsUninitialised() - { - return optionOverrides =3D=3D null; - } - - public void setOptionOverrides(Option optionOverrides) - { - this.optionOverrides =3D optionOverrides; - } - - public boolean isOriginLocal() - { - return originLocal; - } - - @SuppressWarnings("unchecked") - public List getLocks() - { - // first check transactional scope - if (transactionContext !=3D null) return transactionContext.getLocks= (); - return invocationLocks =3D=3D null || invocationLocks.isEmpty() ? Co= llections.emptyList() : Immutables.immutableListConvert(invocationLocks); - } - - @SuppressWarnings("unchecked") - public void addAllLocks(List locks) - { - // first check transactional scope - if (transactionContext !=3D null) - { - transactionContext.addAllLocks(locks); - } - else - { - // no need to worry about concurrency here - a context is only va= lid for a single thread. - if (invocationLocks =3D=3D null) invocationLocks =3D new LinkedHa= shSet(4); - invocationLocks.addAll(locks); - } - } - - @SuppressWarnings("unchecked") - public void addLock(Object lock) - { - // first check transactional scope - if (transactionContext !=3D null) - { - transactionContext.addLock(lock); - } - else - { - // no need to worry about concurrency here - a context is only va= lid for a single thread. - if (invocationLocks =3D=3D null) invocationLocks =3D new LinkedHa= shSet(4); - invocationLocks.add(lock); - } - } - - @SuppressWarnings("unchecked") - public void removeLock(Object lock) - { - // first check transactional scope - if (transactionContext !=3D null) - { - transactionContext.removeLock(lock); - } - else - { - // no need to worry about concurrency here - a context is only va= lid for a single thread. - if (invocationLocks !=3D null) invocationLocks.remove(lock); - } - } - - public void clearLocks() - { - // first check transactional scope - if (transactionContext !=3D null) - { - transactionContext.clearLocks(); - } - else - { - // no need to worry about concurrency here - a context is only va= lid for a single thread. - if (invocationLocks !=3D null) invocationLocks.clear(); - } - } - - public boolean hasLock(Object lock) - { - // first check transactional scope - if (transactionContext !=3D null) - { - return transactionContext.hasLock(lock); - } - else - { - return invocationLocks !=3D null && invocationLocks.contains(lock= ); - } - } - - public boolean isLockingSuppressed() - { - return getOptionOverrides() !=3D null && getOptionOverrides().isSupp= ressLocking(); - } - - public void setOriginLocal(boolean originLocal) - { - this.originLocal =3D originLocal; - } - - @Override - public String toString() - { - return "InvocationContext{" + - "transaction=3D" + transaction + - ", globalTransaction=3D" + globalTransaction + - ", transactionContext=3D" + transactionContext + - ", optionOverrides=3D" + optionOverrides + - ", originLocal=3D" + originLocal + - '}'; - } - - public boolean isLocalRollbackOnly() - { - return localRollbackOnly; - } - - public void reset() - { - transaction =3D null; - globalTransaction =3D null; - optionOverrides =3D null; - originLocal =3D true; - invocationLocks =3D null; - methodCall =3D null; - command =3D null; - } - - @SuppressWarnings("unchecked") - protected void doCopy(AbstractInvocationContext copy) - { - copy.command =3D command; - copy.globalTransaction =3D globalTransaction; - copy.invocationLocks =3D invocationLocks =3D=3D null ? null : new Li= nkedHashSet(invocationLocks); - copy.localRollbackOnly =3D localRollbackOnly; - copy.optionOverrides =3D optionOverrides =3D=3D null ? null : option= Overrides.copy(); - copy.originLocal =3D originLocal; - copy.transaction =3D transaction; - copy.transactionContext =3D transactionContext; - } - - public void setState(InvocationContext template) - { - if (template =3D=3D null) - { - throw new NullPointerException("Template InvocationContext passed= in to InvocationContext.setState() passed in is null"); - } - - this.setGlobalTransaction(template.getGlobalTransaction()); - this.setLocalRollbackOnly(template.isLocalRollbackOnly()); - this.setOptionOverrides(template.getOptionOverrides()); - this.setOriginLocal(template.isOriginLocal()); - this.setTransaction(template.getTransaction()); - } - - @Override - public boolean equals(Object o) - { - if (this =3D=3D o) return true; - if (o =3D=3D null || getClass() !=3D o.getClass()) return false; - - final AbstractInvocationContext that =3D (AbstractInvocationContext)= o; - - if (localRollbackOnly !=3D that.localRollbackOnly) return false; - if (originLocal !=3D that.originLocal) return false; - if (globalTransaction !=3D null ? !globalTransaction.equals(that.glo= balTransaction) : that.globalTransaction !=3D null) - { - return false; - } - if (optionOverrides !=3D null ? !optionOverrides.equals(that.optionO= verrides) : that.optionOverrides !=3D null) - { - return false; - } - if (transaction !=3D null ? !transaction.equals(that.transaction) : = that.transaction !=3D null) return false; - - return true; - } - - @Override - public int hashCode() - { - int result; - result =3D (transaction !=3D null ? transaction.hashCode() : 0); - result =3D 29 * result + (globalTransaction !=3D null ? globalTransa= ction.hashCode() : 0); - result =3D 29 * result + (optionOverrides !=3D null ? optionOverride= s.hashCode() : 0); - result =3D 29 * result + (originLocal ? 1 : 0); - result =3D 29 * result + (localRollbackOnly ? 1 : 0); - return result; - } - - @Deprecated - @SuppressWarnings("deprecation") - public MethodCall getMethodCall() - { - if (methodCall =3D=3D null) - { - methodCall =3D createMethodCall(); - } - return methodCall; - } - - @SuppressWarnings("deprecation") - private MethodCall createMethodCall() - { - if (command =3D=3D null) return null; - MethodCall call =3D new MethodCall(); - call.setMethodId(command.getCommandId()); - call.setArgs(command.getParameters()); - return call; - } - - @Deprecated - public void setMethodCall(MethodCall methodCall) - { - this.methodCall =3D methodCall; - } - - public long getLockAcquisitionTimeout(long timeout) - { - // TODO: this stuff really doesn't belong here. Put it somewhere el= se. - if (getOptionOverrides() !=3D null - && getOptionOverrides().getLockAcquisitionTimeout() >=3D 0) - { - timeout =3D getOptionOverrides().getLockAcquisitionTimeout(); - } - return timeout; - } - - @Deprecated - @SuppressWarnings("deprecation") - public void setCommand(VisitableCommand cacheCommand) - { - this.command =3D cacheCommand; - } - - @Deprecated - @SuppressWarnings("deprecation") - public VisitableCommand getCommand() - { - return command; - } - - public boolean isValidTransaction() - { - // ought to move to the transaction context - return transaction !=3D null && TransactionTable.isValid(transaction= ); - } - - public void throwIfNeeded(Throwable e) throws Throwable - { - // TODO: this stuff really doesn't belong here. Put it somewhere el= se. - Option optionOverride =3D getOptionOverrides(); - boolean shouldRethtrow =3D optionOverride =3D=3D null || !optionOver= ride.isFailSilently(); - if (!shouldRethtrow) - { - if (trace) - log.trace("There was a problem handling this request, but fail= Silently was set, so suppressing exception", e); - return; - } - throw e; - } -} Modified: core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocat= ionContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationCon= text.java 2008-08-26 06:44:18 UTC (rev 6615) +++ core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationCon= text.java 2008-08-26 06:56:09 UTC (rev 6616) @@ -15,7 +15,7 @@ * @deprecated will be removed along with optimistic and pessimistic locki= ng. */ @Deprecated -public class LegacyInvocationContext extends AbstractInvocationContext +public class LegacyInvocationContext extends InvocationContext { DataContainer container; = Modified: core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocatio= nContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationConte= xt.java 2008-08-26 06:44:18 UTC (rev 6615) +++ core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationConte= xt.java 2008-08-26 06:56:09 UTC (rev 6616) @@ -16,7 +16,7 @@ * @author Manik Surtani (manik(a)jbo= ss.org) * @since 3.0 */ -public class MVCCInvocationContext extends AbstractInvocationContext +public class MVCCInvocationContext extends InvocationContext { private HashMap lookedUpNodes =3D null; private MVCCTransactionContext mvccTCtx; --===============8487982684604509172==-- From jbosscache-commits at lists.jboss.org Tue Aug 26 05:55:48 2008 Content-Type: multipart/mixed; boundary="===============2029000961942232582==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6617 - jbosscache-lucene/jbosscache. Date: Tue, 26 Aug 2008 05:55:47 -0400 Message-ID: --===============2029000961942232582== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: navssurtani Date: 2008-08-26 05:55:47 -0400 (Tue, 26 Aug 2008) New Revision: 6617 Modified: jbosscache-lucene/jbosscache/README.txt Log: Edited README.txt Modified: jbosscache-lucene/jbosscache/README.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jbosscache-lucene/jbosscache/README.txt 2008-08-26 06:56:09 UTC (rev 66= 16) +++ jbosscache-lucene/jbosscache/README.txt 2008-08-26 09:55:47 UTC (rev 66= 17) @@ -3,6 +3,9 @@ * This implementation is built using JBoss Cache 2.1.1.CR2, and requires J= ava 5. * See distribution on http://www.jbosscache.org for complete list of de= pendencies. = +* Make sure you check the directory that contains this file into [your_luc= ene_path]/contrib + + * For the locking implementation to work accurately, JBoss Cache must be c= onfigured: * to use SYNC_REPL * Synchronous Commit --===============2029000961942232582==-- From jbosscache-commits at lists.jboss.org Tue Aug 26 06:39:53 2008 Content-Type: multipart/mixed; boundary="===============9171977487707098707==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6618 - in core/trunk/src/test/java/org/jboss/cache: lock and 1 other directory. Date: Tue, 26 Aug 2008 06:39:50 -0400 Message-ID: --===============9171977487707098707== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-26 06:39:49 -0400 (Tue, 26 Aug 2008) New Revision: 6618 Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderMethodCallCou= nterTest.java core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderWithReplicati= onTest.java core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest= .java core/trunk/src/test/java/org/jboss/cache/loader/InterceptorSynchronizati= onTest.java core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoade= rTest.java core/trunk/src/test/java/org/jboss/cache/loader/TxCacheLoaderTest.java core/trunk/src/test/java/org/jboss/cache/loader/UnnecessaryLoadingTest.j= ava core/trunk/src/test/java/org/jboss/cache/lock/LockReleaseTest.java Log: Fixed broken tests to use Pess locking instead of MVCC Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderMethod= CallCounterTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderMethodCallCo= unterTest.java 2008-08-26 09:55:47 UTC (rev 6617) +++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderMethodCallCo= unterTest.java 2008-08-26 10:39:49 UTC (rev 6618) @@ -8,6 +8,7 @@ = import org.jboss.cache.CacheSPI; import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.config.Configuration.NodeLockingScheme; import org.jboss.cache.util.TestingUtil; import static org.testng.AssertJUnit.assertEquals; import org.testng.annotations.AfterMethod; @@ -30,6 +31,7 @@ { if (cache !=3D null) tearDown(); cache =3D (CacheSPI) new DefaultCacheFactory().creat= eCache(false); + cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESS= IMISTIC); cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderCo= nfig("", DummyCountingCacheLoader.class.getName(), "", false, false, false)= ); cache.start(); dummyLoader =3D (DummyCountingCacheLoader) cache.getCacheLoaderManag= er().getCacheLoader(); Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderWithRe= plicationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderWithReplicat= ionTest.java 2008-08-26 09:55:47 UTC (rev 6617) +++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderWithReplicat= ionTest.java 2008-08-26 10:39:49 UTC (rev 6618) @@ -13,6 +13,7 @@ import org.jboss.cache.commands.tx.CommitCommand; import org.jboss.cache.commands.tx.PrepareCommand; import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.Configuration.NodeLockingScheme; import org.jboss.cache.util.TestingUtil; import org.jboss.cache.util.internals.ReplicationListener; import static org.testng.AssertJUnit.assertEquals; @@ -140,6 +141,11 @@ cache1.getConfiguration().setNodeLockingScheme(Configuration.Node= LockingScheme.OPTIMISTIC); cache2.getConfiguration().setNodeLockingScheme(Configuration.Node= LockingScheme.OPTIMISTIC); } + else + { + cache1.getConfiguration().setNodeLockingScheme(NodeLockingScheme.= PESSIMISTIC); + cache2.getConfiguration().setNodeLockingScheme(NodeLockingScheme.= PESSIMISTIC); + } = cache1.start(); cache2.start(); Modified: core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoa= derTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTes= t.java 2008-08-26 09:55:47 UTC (rev 6617) +++ core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTes= t.java 2008-08-26 10:39:49 UTC (rev 6618) @@ -13,6 +13,7 @@ import org.jboss.cache.Fqn; import org.jboss.cache.Region; import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.Configuration.NodeLockingScheme; import org.jboss.cache.lock.TimeoutException; import org.jboss.cache.util.TestingUtil; import static org.testng.AssertJUnit.*; @@ -71,6 +72,9 @@ cache2.getRegionManager().getRegion(fqn, Region.Type.MARSHALLING,= true).registerContextClassLoader(this.getClass().getClassLoader()); } = + cache1.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PES= SIMISTIC); + cache2.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PES= SIMISTIC); + cache1.start(); cache2.start(); = Modified: core/trunk/src/test/java/org/jboss/cache/loader/InterceptorSynchr= onizationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/loader/InterceptorSynchronizat= ionTest.java 2008-08-26 09:55:47 UTC (rev 6617) +++ core/trunk/src/test/java/org/jboss/cache/loader/InterceptorSynchronizat= ionTest.java 2008-08-26 10:39:49 UTC (rev 6618) @@ -7,6 +7,7 @@ import org.jboss.cache.Modification; import org.jboss.cache.config.CacheLoaderConfig; import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfi= g; +import org.jboss.cache.config.Configuration.NodeLockingScheme; import static org.testng.AssertJUnit.assertTrue; import org.testng.annotations.Test; = @@ -47,6 +48,7 @@ iclc.setCacheLoader(new TestSlowCacheLoader()); clc.addIndividualCacheLoaderConfig(iclc); cache.getConfiguration().setCacheLoaderConfig(clc); + cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESS= IMISTIC); cache.start(); = long begin =3D System.currentTimeMillis(); Modified: core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCac= heLoaderTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoad= erTest.java 2008-08-26 09:55:47 UTC (rev 6617) +++ core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoad= erTest.java 2008-08-26 10:39:49 UTC (rev 6618) @@ -13,6 +13,7 @@ import org.jboss.cache.Fqn; import org.jboss.cache.config.CacheLoaderConfig; import org.jboss.cache.config.Configuration.CacheMode; +import org.jboss.cache.config.Configuration.NodeLockingScheme; import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; import org.jboss.cache.util.internals.ViewChangeListener; import static org.testng.AssertJUnit.*; @@ -47,6 +48,10 @@ cache1 =3D (CacheSPI) new DefaultCacheFactory().createCache(UnitTestCacheConfigurationFactory.createConfigurati= on(CacheMode.REPL_SYNC), false); cache2 =3D (CacheSPI) new DefaultCacheFactory().createCache(UnitTestCacheConfigurationFactory.createConfigurati= on(CacheMode.REPL_SYNC), false); cache3 =3D (CacheSPI) new DefaultCacheFactory().createCache(UnitTestCacheConfigurationFactory.createConfigurati= on(CacheMode.REPL_SYNC), false); + + cache1.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PES= SIMISTIC); + cache2.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PES= SIMISTIC); + cache3.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PES= SIMISTIC); } = public void testPutCacheLoaderWithNoPush() throws Exception Modified: core/trunk/src/test/java/org/jboss/cache/loader/TxCacheLoaderTest= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/loader/TxCacheLoaderTest.java = 2008-08-26 09:55:47 UTC (rev 6617) +++ core/trunk/src/test/java/org/jboss/cache/loader/TxCacheLoaderTest.java = 2008-08-26 10:39:49 UTC (rev 6618) @@ -3,6 +3,7 @@ import org.jboss.cache.CacheSPI; import org.jboss.cache.DefaultCacheFactory; import org.jboss.cache.Fqn; +import org.jboss.cache.config.Configuration.NodeLockingScheme; import org.jboss.cache.transaction.TransactionSetup; import org.jboss.cache.util.TestingUtil; import static org.testng.AssertJUnit.*; @@ -33,7 +34,7 @@ cache1 =3D (CacheSPI) new DefaultCacheFactory().createCache(false); cache1.getConfiguration().setCacheMode("repl_sync"); cache1.getConfiguration().setTransactionManagerLookupClass(Transacti= onSetup.getManagerLookup()); - + cache1.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PES= SIMISTIC); cache1.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderC= onfig("", DummyInMemoryCacheLoader.class.getName(), "", false, false, false= )); // cache1.setReplQueueInterval(3000); cache1.create(); @@ -41,6 +42,7 @@ = cache2 =3D (CacheSPI) new DefaultCacheFactory().createCache(false); cache2.getConfiguration().setCacheMode("repl_sync"); + cache2.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PES= SIMISTIC); cache2.getConfiguration().setTransactionManagerLookupClass(Transacti= onSetup.getManagerLookup()); cache2.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderC= onfig("", DummyInMemoryCacheLoader.class.getName(), "", false, false, false= )); cache2.getConfiguration().setLockAcquisitionTimeout(2000); Modified: core/trunk/src/test/java/org/jboss/cache/loader/UnnecessaryLoadin= gTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/loader/UnnecessaryLoadingTest.= java 2008-08-26 09:55:47 UTC (rev 6617) +++ core/trunk/src/test/java/org/jboss/cache/loader/UnnecessaryLoadingTest.= java 2008-08-26 10:39:49 UTC (rev 6618) @@ -6,6 +6,7 @@ import org.jboss.cache.Fqn; import org.jboss.cache.Node; import org.jboss.cache.config.CacheLoaderConfig; +import org.jboss.cache.config.Configuration.NodeLockingScheme; import static org.testng.AssertJUnit.*; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; @@ -37,6 +38,7 @@ CacheLoaderConfig.IndividualCacheLoaderConfig iclc =3D new CacheLoad= erConfig.IndividualCacheLoaderConfig(); clc.addIndividualCacheLoaderConfig(iclc); cache.getConfiguration().setCacheLoaderConfig(clc); + cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESS= IMISTIC); mockCacheLoader =3D createMock(CacheLoader.class); = expect(mockCacheLoader.getConfig()).andReturn(null).anyTimes(); Modified: core/trunk/src/test/java/org/jboss/cache/lock/LockReleaseTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/lock/LockReleaseTest.java 2008= -08-26 09:55:47 UTC (rev 6617) +++ core/trunk/src/test/java/org/jboss/cache/lock/LockReleaseTest.java 2008= -08-26 10:39:49 UTC (rev 6618) @@ -12,6 +12,8 @@ import org.jboss.cache.CacheSPI; import org.jboss.cache.DefaultCacheFactory; import org.jboss.cache.Fqn; +import org.jboss.cache.config.Configuration.NodeLockingScheme; +import org.jboss.cache.transaction.GenericTransactionManagerLookup; import org.jboss.cache.transaction.TransactionSetup; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.fail; @@ -77,9 +79,10 @@ CacheSPI c =3D (CacheSPI) new Defaul= tCacheFactory().createCache(false); c.getConfiguration().setClusterName("test"); c.getConfiguration().setStateRetrievalTimeout(10000); - c.getConfiguration().setTransactionManagerLookupClass("org.jboss.cac= he.transaction.GenericTransactionManagerLookup"); + c.getConfiguration().setTransactionManagerLookupClass(GenericTransac= tionManagerLookup.class.getName()); c.getConfiguration().setLockAcquisitionTimeout(500); c.getConfiguration().setIsolationLevel(level); + c.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMIS= TIC); c.create(); c.start(); return c; --===============9171977487707098707==-- From jbosscache-commits at lists.jboss.org Tue Aug 26 06:45:30 2008 Content-Type: multipart/mixed; boundary="===============1760397057076760345==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6619 - core/trunk/src/test/java/org/jboss/cache/marshall. Date: Tue, 26 Aug 2008 06:45:29 -0400 Message-ID: --===============1760397057076760345== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-26 06:45:29 -0400 (Tue, 26 Aug 2008) New Revision: 6619 Modified: core/trunk/src/test/java/org/jboss/cache/marshall/AsyncReplTest.java core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBas= e.java core/trunk/src/test/java/org/jboss/cache/marshall/InvalidRegionForStateT= ransferTest.java core/trunk/src/test/java/org/jboss/cache/marshall/ReturnValueMarshalling= Test.java core/trunk/src/test/java/org/jboss/cache/marshall/SyncReplTest.java Log: Fixed broken tests to use Pess locking instead of MVCC Modified: core/trunk/src/test/java/org/jboss/cache/marshall/AsyncReplTest.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/marshall/AsyncReplTest.java 20= 08-08-26 10:39:49 UTC (rev 6618) +++ core/trunk/src/test/java/org/jboss/cache/marshall/AsyncReplTest.java 20= 08-08-26 10:45:29 UTC (rev 6619) @@ -15,6 +15,7 @@ import org.jboss.cache.Region; import org.jboss.cache.commands.legacy.write.PessPutKeyValueCommand; import org.jboss.cache.config.Configuration.CacheMode; +import org.jboss.cache.config.Configuration.NodeLockingScheme; import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; import org.jboss.cache.marshall.data.Address; import org.jboss.cache.marshall.data.Person; @@ -79,6 +80,7 @@ private CacheSPI createCache(String name) { CacheSPI cache =3D (CacheSPI) new De= faultCacheFactory().createCache(UnitTestCacheConfigurationF= actory.createConfiguration(CacheMode.REPL_ASYNC), false); + cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESS= IMISTIC); cache.getConfiguration().setClusterName(name); // Use marshaller cache.getConfiguration().setUseLazyDeserialization(useMarshalledValu= es); Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller= TestBase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBa= se.java 2008-08-26 10:39:49 UTC (rev 6618) +++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBa= se.java 2008-08-26 10:45:29 UTC (rev 6619) @@ -10,8 +10,8 @@ import org.jboss.cache.RegionManager; import org.jboss.cache.RegionManagerImpl; import org.jboss.cache.commands.ReplicableCommand; -import org.jboss.cache.commands.legacy.write.PessPutKeyValueCommand; import org.jboss.cache.commands.remote.ReplicateCommand; +import org.jboss.cache.commands.write.PutKeyValueCommand; import org.jboss.cache.config.Configuration; import org.jboss.cache.factories.ComponentRegistry; import org.jboss.cache.invocation.CacheInvocationDelegate; @@ -113,7 +113,7 @@ public void testMethodCall() throws Exception { Fqn fqn =3D Fqn.fromElements(3, false); - ReplicableCommand cmd =3D new PessPutKeyValueCommand(null, fqn, "key= ", "value"); + ReplicableCommand cmd =3D new PutKeyValueCommand(null, fqn, "key", "= value"); byte[] asBytes =3D marshaller.objectToByteBuffer(cmd); Object o2 =3D marshaller.objectFromByteBuffer(asBytes); = @@ -126,7 +126,7 @@ public void testNestedMethodCall() throws Exception { Fqn fqn =3D Fqn.fromElements(3, false); - ReplicableCommand cmd =3D new PessPutKeyValueCommand(null, fqn, "key= ", "value"); + ReplicableCommand cmd =3D new PutKeyValueCommand(null, fqn, "key", "= value"); ReplicableCommand replicateCmd =3D new ReplicateCommand(cmd); byte[] asBytes =3D marshaller.objectToByteBuffer(replicateCmd); Object o2 =3D marshaller.objectFromByteBuffer(asBytes); @@ -216,12 +216,12 @@ Fqn f =3D Fqn.fromElements("BlahBlah", 3, false); String k =3D "key", v =3D "value"; = - ReplicableCommand cmd =3D new PessPutKeyValueCommand(null, f, k, v); + ReplicableCommand cmd =3D new PutKeyValueCommand(null, f, k, v); ReplicableCommand replCmd =3D new ReplicateCommand(cmd); = calls.add(replCmd); = - cmd =3D new PessPutKeyValueCommand(null, f, k, v); + cmd =3D new PutKeyValueCommand(null, f, k, v); replCmd =3D new ReplicateCommand(cmd); = calls.add(replCmd); Modified: core/trunk/src/test/java/org/jboss/cache/marshall/InvalidRegionFo= rStateTransferTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/marshall/InvalidRegionForState= TransferTest.java 2008-08-26 10:39:49 UTC (rev 6618) +++ core/trunk/src/test/java/org/jboss/cache/marshall/InvalidRegionForState= TransferTest.java 2008-08-26 10:45:29 UTC (rev 6619) @@ -4,10 +4,11 @@ import org.jboss.cache.DefaultCacheFactory; import org.jboss.cache.Fqn; import org.jboss.cache.Region; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.Configuration.NodeLockingScheme; +import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; import org.jboss.cache.util.TestingUtil; import org.jboss.cache.util.internals.ReplicationListener; -import org.jboss.cache.config.Configuration; -import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -34,7 +35,7 @@ public void setUp() throws CloneNotSupportedException { c1 =3D new DefaultCacheFactory().createCache(UnitTes= tCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL= _ASYNC), false); - + c1.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMI= STIC); String jgroupsCfg =3D c1.getConfiguration().getClusterConfig(); = // make sure we use STATE_TRANSFER and not STREAMING_STATE_TRANSFER,= so the same thread pool is used for incoming calls and ST Modified: core/trunk/src/test/java/org/jboss/cache/marshall/ReturnValueMars= hallingTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/marshall/ReturnValueMarshallin= gTest.java 2008-08-26 10:39:49 UTC (rev 6618) +++ core/trunk/src/test/java/org/jboss/cache/marshall/ReturnValueMarshallin= gTest.java 2008-08-26 10:45:29 UTC (rev 6619) @@ -12,6 +12,7 @@ import org.jboss.cache.commands.read.GravitateDataCommand; import org.jboss.cache.commands.remote.ClusteredGetCommand; import org.jboss.cache.config.Configuration; +import org.jboss.cache.config.Configuration.NodeLockingScheme; import org.jboss.cache.util.TestingUtil; import static org.testng.AssertJUnit.*; import org.testng.annotations.AfterMethod; @@ -42,6 +43,7 @@ public void setUp() throws Exception { cache1 =3D (CacheSPI) new DefaultCacheFactory().createCache(false); + cache1.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PES= SIMISTIC); cache1.getConfiguration().setUseLazyDeserialization(useMarshalledVal= ues); cache1.getConfiguration().setUseRegionBasedMarshalling(!useMarshalle= dValues); cache1.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_= SYNC); @@ -49,6 +51,7 @@ cache1.start(); = cache2 =3D (CacheSPI) new DefaultCacheFactory().createCache(false); + cache2.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PES= SIMISTIC); cache2.getConfiguration().setUseLazyDeserialization(useMarshalledVal= ues); cache2.getConfiguration().setUseRegionBasedMarshalling(!useMarshalle= dValues); cache2.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_= SYNC); Modified: core/trunk/src/test/java/org/jboss/cache/marshall/SyncReplTest.ja= va =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/marshall/SyncReplTest.java 200= 8-08-26 10:39:49 UTC (rev 6618) +++ core/trunk/src/test/java/org/jboss/cache/marshall/SyncReplTest.java 200= 8-08-26 10:45:29 UTC (rev 6619) @@ -14,6 +14,7 @@ import org.jboss.cache.Fqn; import org.jboss.cache.Region; import org.jboss.cache.config.Configuration.CacheMode; +import org.jboss.cache.config.Configuration.NodeLockingScheme; import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; import org.jboss.cache.marshall.data.Address; import org.jboss.cache.marshall.data.Person; @@ -68,6 +69,7 @@ private CacheSPI createCache(String name) { CacheSPI cache =3D (CacheSPI) new De= faultCacheFactory().createCache(UnitTestCacheConfigurationF= actory.createConfiguration(CacheMode.REPL_SYNC), false); + cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESS= IMISTIC); cache.getConfiguration().setClusterName(name); // Use marshaller cache.getConfiguration().setUseLazyDeserialization(useMarshalledValu= es); --===============1760397057076760345==-- From jbosscache-commits at lists.jboss.org Tue Aug 26 07:07:05 2008 Content-Type: multipart/mixed; boundary="===============7187509845710508876==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6620 - core/trunk/src/test/java/org/jboss/cache/buddyreplication. Date: Tue, 26 Aug 2008 07:07:03 -0400 Message-ID: --===============7187509845710508876== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-26 07:07:03 -0400 (Tue, 26 Aug 2008) New Revision: 6620 Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicati= onTestsBase.java Log: Fixed broken tests to use Pess locking instead of MVCC Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyRe= plicationTestsBase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicat= ionTestsBase.java 2008-08-26 10:45:29 UTC (rev 6619) +++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicat= ionTestsBase.java 2008-08-26 11:07:03 UTC (rev 6620) @@ -13,8 +13,8 @@ import org.jboss.cache.config.BuddyReplicationConfig; import org.jboss.cache.config.CacheLoaderConfig; import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfi= g; -import org.jboss.cache.config.Configuration; import org.jboss.cache.config.Configuration.CacheMode; +import org.jboss.cache.config.Configuration.NodeLockingScheme; import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; import org.jboss.cache.loader.CacheLoader; import org.jboss.cache.loader.CacheLoaderManager; @@ -142,10 +142,8 @@ c.getConfiguration().setBuddyReplicationConfig(brc); = c.getConfiguration().setFetchInMemoryState(true); - if (optimisticLocks) - { - c.getConfiguration().setNodeLockingScheme(Configuration.NodeLocki= ngScheme.OPTIMISTIC); - } + c.getConfiguration().setNodeLockingScheme(optimisticLocks ? NodeLock= ingScheme.OPTIMISTIC : NodeLockingScheme.PESSIMISTIC); + c.getConfiguration().setTransactionManagerLookupClass(DummyTransacti= onManagerLookup.class.getName()); c.getConfiguration().setSyncCommitPhase(true);// helps track down br= eakages = --===============7187509845710508876==-- From jboss-qa-internal at redhat.com Tue Aug 26 10:09:44 2008 Content-Type: multipart/mixed; boundary="===============0772601982821501982==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23431?= Date: Tue, 26 Aug 2008 10:09:41 -0400 Message-ID: <946023945.19091219759781972.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1633139943.17831219731869616.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============0772601982821501982== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/431/changes --===============0772601982821501982==-- From jboss-qa-internal at redhat.com Tue Aug 26 10:43:59 2008 Content-Type: multipart/mixed; boundary="===============8201738763419076515==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_unstable=3A_jboss-cach?= =?utf-8?q?e-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_=23565?= Date: Tue, 26 Aug 2008 10:43:57 -0400 Message-ID: <1253125283.19121219761837254.JavaMail.hudson@hudson1.qa.atl2.redhat.com> --===============8201738763419076515== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/565/changes --===============8201738763419076515==-- From jbosscache-commits at lists.jboss.org Tue Aug 26 18:46:36 2008 Content-Type: multipart/mixed; boundary="===============6023425890724402042==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6621 - in core/trunk/src: main/resources/schema and 3 other directories. Date: Tue, 26 Aug 2008 18:46:35 -0400 Message-ID: --===============6023425890724402042== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-26 18:46:35 -0400 (Tue, 26 Aug 2008) New Revision: 6621 Added: core/trunk/src/main/java/org/jboss/cache/config/parsing/RootElementBuild= er.java core/trunk/src/main/resources/schema/jbosscache-registry-3.0.xsd core/trunk/src/test/resources/jbc3-registry-configs.xml Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlP= arser.java core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.= java core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguration= Parser.java core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.ja= va core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguration= ParserTest.java core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguration= SchemaTest.java core/trunk/src/test/java/org/jboss/cache/manager/CacheManagerTest.java Log: xml improvements Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConf= igsXmlParser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXml= Parser.java 2008-08-26 11:07:03 UTC (rev 6620) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXml= Parser.java 2008-08-26 22:46:35 UTC (rev 6621) @@ -22,10 +22,6 @@ = package org.jboss.cache.config.parsing; = -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.config.Configuration; @@ -35,6 +31,10 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; = +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; + /** * Parser able to parse a series of cache configurations stored in an * XML document with the following structure: @@ -89,8 +89,8 @@ public Map parseConfigs(InputStream stream) thro= ws CloneNotSupportedException { // loop through all elements in XML. - Element root =3D XmlConfigHelper.getDocumentRoot(stream); - NodeList list =3D root.getElementsByTagName(CONFIG_ROOT); + Element root =3D getDocumentRoot(stream); + NodeList list =3D root.getElementsByTagNameNS(RootElementBuilder.JBO= SSCACHE_REPO_NS, CONFIG_ROOT); if (list =3D=3D null || list.getLength() =3D=3D 0) throw new ConfigurationException("Can't find " + CONFIG_ROOT + " = tag"); = @@ -118,4 +118,10 @@ = return result; } + + private Element getDocumentRoot(InputStream stream) + { + RootElementBuilder rootElementBuilder =3D new RootElementBuilder(); + return rootElementBuilder.readRoot(stream); + } } \ No newline at end of file Added: core/trunk/src/main/java/org/jboss/cache/config/parsing/RootElementB= uilder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/RootElementBuil= der.java (rev 0) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/RootElementBuil= der.java 2008-08-26 22:46:35 UTC (rev 6621) @@ -0,0 +1,141 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2008, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.cache.config.parsing; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.jboss.cache.config.ConfigurationException; +import org.jboss.util.xml.JBossEntityResolver; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.xml.sax.ErrorHandler; +import org.xml.sax.SAXParseException; +import org.xml.sax.SAXException; + +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; +import java.io.InputStream; + +/** + * Parses an xml files and validates xml elements form {@link RootElementB= uilder#JBOSSCACHE_CORE_NS} namespace + * according to the configured schema. + * + * @author Mircea.Markus(a)jboss.com + * @since 3.0 + */ +public class RootElementBuilder +{ + + private static final JBossEntityResolver resolver =3D new JBossEntityRe= solver(); + + public static final String JBOSSCACHE_CORE_NS =3D "urn:jboss:jbosscache= -core:config:3.0"; + public static final String JBOSSCACHE_REPO_NS =3D "urn:jboss:jbosscache= -core:cache-repo:3.0"; + + static + { + // Globally register this namespace + JBossEntityResolver.registerEntity(JBOSSCACHE_CORE_NS, "jbosscache-c= onfig-3.0.xsd"); + JBossEntityResolver.registerEntity(JBOSSCACHE_REPO_NS, "jbosscache-r= egistry-3.0.xsd"); + } + + private static final Log log =3D LogFactory.getLog(RootElementBuilder.c= lass); + private ErrorHandler errorHandler; + private boolean isValidating; + public static final String VALIDATING_SYSTEM_PROPERTY =3D "jbosscache.c= onfig.validate"; + + public RootElementBuilder(ErrorHandler errorHandler) + { + this.errorHandler =3D errorHandler; + isValidating =3D System.getProperty(VALIDATING_SYSTEM_PROPERTY) =3D= =3D null || Boolean.getBoolean(VALIDATING_SYSTEM_PROPERTY); + } + + public RootElementBuilder(ErrorHandler errorHandler, boolean validating) + { + this.errorHandler =3D errorHandler; + isValidating =3D validating; + } + + public RootElementBuilder() + { + this(new FailureErrorHandler()); + } + + public Element readRoot(InputStream config) + { + try + { + DocumentBuilderFactory docBuilderFactory =3D DocumentBuilderFacto= ry.newInstance(); + docBuilderFactory.setNamespaceAware(true); + if (isValidating) + { + docBuilderFactory.setValidating(true); + docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/p= roperties/schemaLanguage", "http://www.w3.org/2001/XMLSchema"); + String[] value =3D {JBOSSCACHE_CORE_NS, JBOSSCACHE_REPO_NS}; + docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/p= roperties/schemaSource", value); + } + DocumentBuilder parser =3D docBuilderFactory.newDocumentBuilder(); + parser.setEntityResolver(resolver); + parser.setErrorHandler(errorHandler); + Document doc =3D parser.parse(config); + Element root =3D doc.getDocumentElement(); + root.normalize(); + return root; + } + catch (Exception e) + { + log.error(e); + throw new ConfigurationException("Could not parse the config file= "); + } + } + + /** + * Default schema validation error handler, that throws an exception on= validation errors. + */ + private static class FailureErrorHandler implements ErrorHandler + { + public void warning(SAXParseException exception) throws SAXException + { + logAndThrowException(exception); + } + + public void error(SAXParseException exception) throws SAXException + { + logAndThrowException(exception); + } + + public void fatalError(SAXParseException exception) throws SAXExcept= ion + { + logAndThrowException(exception); + } + + private void logAndThrowException(SAXParseException exception) + { + log.error("Configuration warning: " + exception.getMessage()); + throw new ConfigurationException("Incorrect configuration file. U= se '-Djbosscache.config.validate=3Dfalse' to disable validation.", exceptio= n); + } + } + + public boolean isValidating() + { + return isValidating; + } +} Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfig= Helper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper= .java 2008-08-26 11:07:03 UTC (rev 6620) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper= .java 2008-08-26 22:46:35 UTC (rev 6621) @@ -366,7 +366,7 @@ */ public static Element stringToElementInCoreNS(String xml) throws Except= ion { - xml =3D "" + xml + ""; + xml =3D "" + xml + ""; ByteArrayInputStream bais =3D new ByteArrayInputStream(xml.getBytes(= "utf8")); DocumentBuilderFactory factory =3D DocumentBuilderFactory.newInstanc= e(); factory.setNamespaceAware(true); Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfig= urationParser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParser.java 2008-08-26 11:07:03 UTC (rev 6620) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParser.java 2008-08-26 22:46:35 UTC (rev 6621) @@ -23,27 +23,18 @@ = import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.jboss.cache.config.BuddyReplicationConfig; -import org.jboss.cache.config.CacheLoaderConfig; -import org.jboss.cache.config.Configuration; -import org.jboss.cache.config.ConfigurationException; -import org.jboss.cache.config.CustomInterceptorConfig; -import org.jboss.cache.config.OldFileFormatException; +import org.jboss.cache.config.*; import org.jboss.cache.config.parsing.element.BuddyElementParser; import org.jboss.cache.config.parsing.element.CustomInterceptorsElementPar= ser; import org.jboss.cache.config.parsing.element.EvictionElementParser; import org.jboss.cache.config.parsing.element.LoadersElementParser; import org.jboss.cache.lock.IsolationLevel; import org.jboss.cache.util.FileLookup; -import org.jboss.util.xml.JBossEntityResolver; -import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.ErrorHandler; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; = -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import java.io.InputStream; import java.util.List; = @@ -60,38 +51,26 @@ * * @author Mircea.Markus(a)jboss.com * @since 3.0 + * @see org.jboss.cache.config.parsing.RootElementBuilder */ public class XmlConfigurationParser extends XmlParserBase { = private static final Log log =3D LogFactory.getLog(XmlConfigurationPars= er.class); - private static final JBossEntityResolver resolver =3D new JBossEntityRe= solver(); + private RootElementBuilder rootElementBuilder; = - - public static final String VALIDATING_SYSTEM_PROPERTY =3D "jbosscache.c= onfig.validate"; - - static - { - // Globally register this namespace - JBossEntityResolver.registerEntity(JBOSSCACHE_CORE_NS, "jbosscache-c= onfig-3.0.xsd"); - } - /** * the resulting configuration. */ private Configuration config =3D new Configuration(); private Element root; - private ErrorHandler errorHandler; - private boolean isValidating; - /** * If validation is on (default) one can specify an error handler for h= andling validation errors. * The default error handler just logs parsing errors received. */ public XmlConfigurationParser(ErrorHandler errorHandler) { - this.errorHandler =3D errorHandler; - isValidating =3D System.getProperty(VALIDATING_SYSTEM_PROPERTY) =3D= =3D null || Boolean.getBoolean(VALIDATING_SYSTEM_PROPERTY); + rootElementBuilder =3D new RootElementBuilder(errorHandler); } = /** @@ -101,8 +80,7 @@ */ public XmlConfigurationParser(boolean validating, ErrorHandler errorHan= dler) { - isValidating =3D validating; - this.errorHandler =3D errorHandler; + rootElementBuilder =3D new RootElementBuilder(errorHandler, validati= ng); } = /** @@ -110,7 +88,7 @@ */ public XmlConfigurationParser() { - this(new LoggingErrorHandler()); + rootElementBuilder =3D new RootElementBuilder(); } = /** @@ -153,8 +131,6 @@ return processElements(false); } = - // FIXME: CacheConfigsXmlParser should be using a valid schema! - @Deprecated public Configuration parseElementIgnoringRoot(Element root) { this.root =3D root; @@ -164,7 +140,7 @@ = public boolean isValidating() { - return isValidating; + return rootElementBuilder.isValidating(); } = private Configuration processElements(boolean ignoreRoot) @@ -176,8 +152,8 @@ throw new OldFileFormatException(); } = - if (!"jbosscache".equals(root.getLocalName()) || !JBOSSCACHE_CORE= _NS.equals(root.getNamespaceURI())) - throw new ConfigurationException("Expected root element {" + J= BOSSCACHE_CORE_NS + "}" + "jbosscache"); + if (!"jbosscache".equals(root.getLocalName()) || !RootElementBuil= der.JBOSSCACHE_CORE_NS.equals(root.getNamespaceURI())) + throw new ConfigurationException("Expected root element {" + R= ootElementBuilder.JBOSSCACHE_CORE_NS + "}" + "jbosscache"); } = try @@ -415,49 +391,33 @@ = private void readRoot(InputStream config) { - try - { - DocumentBuilderFactory docBuilderFactory =3D DocumentBuilderFacto= ry.newInstance(); - docBuilderFactory.setNamespaceAware(true); - if (isValidating) - { - docBuilderFactory.setValidating(true); - docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/p= roperties/schemaLanguage", "http://www.w3.org/2001/XMLSchema"); - docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/p= roperties/schemaSource", JBOSSCACHE_CORE_NS); - } - - DocumentBuilder parser =3D docBuilderFactory.newDocumentBuilder(); - parser.setEntityResolver(resolver); - parser.setErrorHandler(errorHandler); - Document doc =3D parser.parse(config); - root =3D doc.getDocumentElement(); - root.normalize(); - } - catch (Exception e) - { - log.error(e); - throw new ConfigurationException("Could not parse the config file= "); - } + root =3D rootElementBuilder.readRoot(config); } = /** - * Default schema validation error handler, that only logs validation e= xceptions. + * Default schema validation error handler, that throws an exception on= validation errors. */ - private static class LoggingErrorHandler implements ErrorHandler + private static class FailureErrorHandler implements ErrorHandler { public void warning(SAXParseException exception) throws SAXException { - log.warn("Configuration warning: " + exception.getMessage()); + logAndThrowException(exception); } = public void error(SAXParseException exception) throws SAXException { - log.warn("Configuration error: " + exception.getMessage()); + logAndThrowException(exception); } = public void fatalError(SAXParseException exception) throws SAXExcept= ion { - log.warn("Configuration fatal error : " + exception.getMessage()); + logAndThrowException(exception); } + + private void logAndThrowException(SAXParseException exception) + { + log.error("Configuration warning: " + exception.getMessage()); + throw new ConfigurationException("Incorrect configuration file. U= se '-Djbosscache.config.validate=3Dfalse' to disable validation.", exceptio= n); + } } } Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParser= Base.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.j= ava 2008-08-26 11:07:03 UTC (rev 6620) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.j= ava 2008-08-26 22:46:35 UTC (rev 6621) @@ -33,7 +33,6 @@ */ public abstract class XmlParserBase { - public static final String JBOSSCACHE_CORE_NS =3D "urn:jboss:jbosscache= -core:config:3.0"; = /** * @see Integer#parseInt(String) @@ -85,7 +84,7 @@ */ protected Element getSingleElementInCoreNS(String elementName, Element = parent) { - return getSingleElement(JBOSSCACHE_CORE_NS, elementName, parent); + return getSingleElement(RootElementBuilder.JBOSSCACHE_CORE_NS, eleme= ntName, parent); } = /** Modified: core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd 2008-08-= 26 11:07:03 UTC (rev 6620) +++ core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd 2008-08-= 26 22:46:35 UTC (rev 6621) @@ -2,33 +2,33 @@ = - - - - - - - - - - - - - - - - - - - - - + = + + + + + + + + + + + + + + + + + + + + - + @@ -64,7 +64,7 @@ - + @@ -81,7 +81,7 @@ = - + = @@ -230,8 +230,7 @@ - - + Added: core/trunk/src/main/resources/schema/jbosscache-registry-3.0.xsd =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/resources/schema/jbosscache-registry-3.0.xsd = (rev 0) +++ core/trunk/src/main/resources/schema/jbosscache-registry-3.0.xsd 2008-0= 8-26 22:46:35 UTC (rev 6621) @@ -0,0 +1,24 @@ + + + + + + + + + + + + + = = = + + + + + + + Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfig= urationParserTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParserTest.java 2008-08-26 11:07:03 UTC (rev 6620) +++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParserTest.java 2008-08-26 22:46:35 UTC (rev 6621) @@ -38,6 +38,7 @@ = public void testParseOldConfigFile() { + System.setProperty("jbosscache.config.validate","false"); XmlConfigurationParser parser =3D new XmlConfigurationParser(); try { @@ -48,6 +49,9 @@ { //expectd } + finally { + System.setProperty("jbosscache.config.validate","true"); + } } = public void testTransactionManagerLookupClass() Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfig= urationSchemaTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nSchemaTest.java 2008-08-26 11:07:03 UTC (rev 6620) +++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nSchemaTest.java 2008-08-26 22:46:35 UTC (rev 6621) @@ -61,11 +61,11 @@ XmlConfigurationParser parser =3D new XmlConfigurationParser(); assert parser.isValidating() : "by default we have a validating pars= er"; = - System.setProperty(XmlConfigurationParser.VALIDATING_SYSTEM_PROPERTY= , "false"); + System.setProperty(RootElementBuilder.VALIDATING_SYSTEM_PROPERTY, "f= alse"); parser =3D new XmlConfigurationParser(); assert !parser.isValidating(); = - System.setProperty(XmlConfigurationParser.VALIDATING_SYSTEM_PROPERTY= , "true"); + System.setProperty(RootElementBuilder.VALIDATING_SYSTEM_PROPERTY, "t= rue"); parser =3D new XmlConfigurationParser(); assert parser.isValidating(); } Modified: core/trunk/src/test/java/org/jboss/cache/manager/CacheManagerTest= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/manager/CacheManagerTest.java = 2008-08-26 11:07:03 UTC (rev 6620) +++ core/trunk/src/test/java/org/jboss/cache/manager/CacheManagerTest.java = 2008-08-26 22:46:35 UTC (rev 6621) @@ -32,7 +32,7 @@ /** * A file that includes every configuration element I could think of */ - public static final String DEFAULT_CONFIGURATION_FILE =3D "jbc2-registr= y-configs.xml"; + public static final String DEFAULT_CONFIGURATION_FILE =3D "jbc3-registr= y-configs.xml"; = private Set> caches =3D new HashSet>(); = Added: core/trunk/src/test/resources/jbc3-registry-configs.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/resources/jbc3-registry-configs.xml = (rev 0) +++ core/trunk/src/test/resources/jbc3-registry-configs.xml 2008-08-26 22:4= 6:35 UTC (rev 6621) @@ -0,0 +1,185 @@ + + + + + + + + + + + + + + + + + + + + 5000 + 1000 + + + 0 + 0 + + + + + + + + + + + + + + + + + 5000 + 1000 + + + 0 + 0 + + + + + + + + + + + 5000 + 1000 + + + 0 + 0 + + + + + + + + + + + + + + + + + + 5000 + 1000 + + + 0 + 0 + + + + + + + + + + + + + + + + + 5000 + 1000 + + + 0 + 0 + + + + + + + + + + + + + + + + + + 5000 + 1000 + + + 0 + 0 + + + + + + + + + + + + + + + + + + + + 5000 + 1000 + + + 0 + 0 + + + + --===============6023425890724402042==-- From jboss-qa-internal at redhat.com Wed Aug 27 03:45:19 2008 Content-Type: multipart/mixed; boundary="===============4747339576717691901==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23566?= Date: Wed, 27 Aug 2008 03:45:17 -0400 Message-ID: <332994029.22201219823117112.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1253125283.19121219761837254.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============4747339576717691901== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/566/changes --===============4747339576717691901==-- From jboss-qa-internal at redhat.com Wed Aug 27 03:50:57 2008 Content-Type: multipart/mixed; boundary="===============5739286860154258863==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23432?= Date: Wed, 27 Aug 2008 03:50:35 -0400 Message-ID: <2119009976.22221219823435268.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 946023945.19091219759781972.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============5739286860154258863== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/432/changes --===============5739286860154258863==-- From jbosscache-commits at lists.jboss.org Wed Aug 27 06:20:07 2008 Content-Type: multipart/mixed; boundary="===============2790319488649968805==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6622 - in core/trunk/src: main/java/org/jboss/cache/config/parsing and 4 other directories. Date: Wed, 27 Aug 2008 06:20:07 -0400 Message-ID: --===============2790319488649968805== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-27 06:20:06 -0400 (Wed, 27 Aug 2008) New Revision: 6622 Modified: core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguration= Parser.java core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguration= ParserTest.java core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguration= SchemaTest.java core/trunk/src/test/resources/configs/mvcc-repl-sync-br.xml core/trunk/src/test/resources/jbc2-registry-configs.xml Log: xml improvements and bug fixes Modified: core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-= 08-26 22:46:35 UTC (rev 6621) +++ core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-= 08-27 10:20:06 UTC (rev 6622) @@ -70,7 +70,7 @@ { c =3D parser.parseFile(configFileName); } - catch (OldFileFormatException e) + catch (ConfigurationException e) { log.warn("Detected legacy configuration file format when parsing = [" + configFileName + "]. Migrating to the new (3.x) file format is recomm= ended. See FAQs for details."); XmlConfigurationParser2x oldParser =3D new XmlConfigurationParser= 2x(); @@ -160,7 +160,7 @@ { c =3D parser.parseStream(is); } - catch (OldFileFormatException e) + catch (ConfigurationException e) { log.warn("Detected legacy configuration file format when parsing = configuration file. Migrating to the new (3.x) file format is recommended.= See FAQs for details."); XmlConfigurationParser2x oldParser =3D new XmlConfigurationParser= 2x(); Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfig= urationParser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParser.java 2008-08-26 22:46:35 UTC (rev 6621) +++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParser.java 2008-08-27 10:20:06 UTC (rev 6622) @@ -50,8 +50,8 @@ * This class is stateful and one instance should be used for parsing a si= ngle configuration file. * * @author Mircea.Markus(a)jboss.com - * @since 3.0 * @see org.jboss.cache.config.parsing.RootElementBuilder + * @since 3.0 */ public class XmlConfigurationParser extends XmlParserBase { @@ -64,6 +64,7 @@ */ private Configuration config =3D new Configuration(); private Element root; + /** * If validation is on (default) one can specify an error handler for h= andling validation errors. * The default error handler just logs parsing errors received. @@ -95,7 +96,6 @@ * Parses an XML file and returns a new configuration. * For looking up the file, {@link org.jboss.cache.util.FileLookup} is = used. * - * @throws OldFileFormatException if the file has a 2.x format * @see org.jboss.cache.util.FileLookup */ public Configuration parseFile(String filename) @@ -110,8 +110,6 @@ = /** * Similar to {@link #parseFile(String)}, just that it does not create = the input stream. - * - * @throws OldFileFormatException if the file has a 2.x format */ public Configuration parseStream(InputStream configStream) { @@ -121,8 +119,6 @@ = /** * Root should be the jbosscache element in the configuration fi= le. - * - * @throws OldFileFormatException if the file has a 2.x format */ public Configuration parseElement(Element root) { @@ -147,11 +143,6 @@ { if (!ignoreRoot) { - if ("server".equalsIgnoreCase(root.getNodeName())) - { - throw new OldFileFormatException(); - } - if (!"jbosscache".equals(root.getLocalName()) || !RootElementBuil= der.JBOSSCACHE_CORE_NS.equals(root.getNamespaceURI())) throw new ConfigurationException("Expected root element {" + R= ootElementBuilder.JBOSSCACHE_CORE_NS + "}" + "jbosscache"); } Modified: core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java 2008= -08-26 22:46:35 UTC (rev 6621) +++ core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java 2008= -08-27 10:20:06 UTC (rev 6622) @@ -15,7 +15,6 @@ import org.apache.commons.logging.LogFactory; import org.jboss.cache.config.Configuration; import org.jboss.cache.config.ConfigurationException; -import org.jboss.cache.config.OldFileFormatException; import org.jboss.cache.config.parsing.XmlConfigurationParser; import org.jboss.cache.config.parsing.XmlConfigurationParser2x; import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; @@ -87,7 +86,7 @@ { c =3D parser.parseFile(configFileName); } - catch (OldFileFormatException e) + catch (ConfigurationException e) { System.out.println("Detected legacy configuration file format whe= n parsing [" + configFileName + "]. Migrating to the new (3.x) file format= is recommended. See FAQs for details."); XmlConfigurationParser2x oldParser =3D new XmlConfigurationParser= 2x(); Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfig= urationParserTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParserTest.java 2008-08-26 22:46:35 UTC (rev 6621) +++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nParserTest.java 2008-08-27 10:20:06 UTC (rev 6622) @@ -1,12 +1,6 @@ package org.jboss.cache.config.parsing; = -import org.jboss.cache.config.BuddyReplicationConfig; -import org.jboss.cache.config.CacheLoaderConfig; -import org.jboss.cache.config.Configuration; -import org.jboss.cache.config.CustomInterceptorConfig; -import org.jboss.cache.config.EvictionConfig; -import org.jboss.cache.config.EvictionRegionConfig; -import org.jboss.cache.config.OldFileFormatException; +import org.jboss.cache.config.*; import org.jboss.cache.config.parsing.custominterceptors.AaaCustomIntercep= tor; import org.jboss.cache.config.parsing.custominterceptors.BbbCustomIntercep= tor; import org.jboss.cache.eviction.LRUAlgorithmConfig; @@ -45,7 +39,7 @@ parser.parseFile("configs/conf2x/pess-local.xml"); assert false : "exception expected"; } - catch (OldFileFormatException e) + catch (ConfigurationException e) { //expectd } Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfig= urationSchemaTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nSchemaTest.java 2008-08-26 22:46:35 UTC (rev 6621) +++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfiguratio= nSchemaTest.java 2008-08-27 10:20:06 UTC (rev 6622) @@ -32,7 +32,8 @@ "parser-test.xml", "policyPerRegion-eviction.xml", "replSync.xml", - "string-property-replaced.xml" + "string-property-replaced.xml", + "mvcc-repl-sync-br.xml" }; = /** Modified: core/trunk/src/test/resources/configs/mvcc-repl-sync-br.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/resources/configs/mvcc-repl-sync-br.xml 2008-08-26 = 22:46:35 UTC (rev 6621) +++ core/trunk/src/test/resources/configs/mvcc-repl-sync-br.xml 2008-08-27 = 10:20:06 UTC (rev 6622) @@ -31,7 +31,7 @@ - + Modified: core/trunk/src/test/resources/jbc2-registry-configs.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) --===============2790319488649968805==-- From jbosscache-commits at lists.jboss.org Wed Aug 27 06:24:05 2008 Content-Type: multipart/mixed; boundary="===============2096033411905474622==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6623 - core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic. Date: Wed, 27 Aug 2008 06:24:05 -0400 Message-ID: --===============2096033411905474622== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-27 06:24:04 -0400 (Wed, 27 Aug 2008) New Revision: 6623 Modified: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AsyncRo= llbackTxTest.java Log: fixed NP in UT Modified: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/= AsyncRollbackTxTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AsyncR= ollbackTxTest.java 2008-08-27 10:20:06 UTC (rev 6622) +++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AsyncR= ollbackTxTest.java 2008-08-27 10:24:04 UTC (rev 6623) @@ -35,8 +35,8 @@ { Configuration c =3D new Configuration(); c.setTransactionManagerLookupClass("org.jboss.cache.transaction.Asyn= cRollbackTransactionManagerLookup"); + c.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC); CacheFactory instance =3D new DefaultCacheFactory(); - cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLock= ingScheme.PESSIMISTIC); cache =3D (CacheSPI) instance.createCache(c); tm =3D cache.getConfiguration().getRuntimeConfig().getTransactionMan= ager(); tm.setTransactionTimeout(txTimeout); --===============2096033411905474622==-- From jboss-qa-internal at redhat.com Wed Aug 27 08:05:11 2008 Content-Type: multipart/mixed; boundary="===============4478400613547887923==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_completed=3A_jboss-cache-?= =?utf-8?q?core-2=2E1=2EX-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_=2346?= Date: Wed, 27 Aug 2008 08:05:09 -0400 Message-ID: <1376125190.22951219838709496.JavaMail.hudson@hudson1.qa.atl2.redhat.com> --===============4478400613547887923== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-2.1.X-jdk1.6/org= .jboss.cache$jbosscache-core/46/changes --===============4478400613547887923==-- From jbosscache-commits at lists.jboss.org Wed Aug 27 08:32:37 2008 Content-Type: multipart/mixed; boundary="===============7645516635563857178==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6624 - core/trunk/src/test/java/org/jboss/cache/api. Date: Wed, 27 Aug 2008 08:32:37 -0400 Message-ID: --===============7645516635563857178== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-27 08:32:37 -0400 (Wed, 27 Aug 2008) New Revision: 6624 Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeSPITest.java Log: this is a pessimistic scenario test Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeSPITest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/api/NodeSPITest.java 2008-08-2= 7 10:24:04 UTC (rev 6623) +++ core/trunk/src/test/java/org/jboss/cache/api/NodeSPITest.java 2008-08-2= 7 12:32:37 UTC (rev 6624) @@ -4,6 +4,7 @@ import org.jboss.cache.DefaultCacheFactory; import org.jboss.cache.Fqn; import org.jboss.cache.NodeSPI; +import org.jboss.cache.config.Configuration; import static org.testng.AssertJUnit.*; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; @@ -23,7 +24,9 @@ @BeforeMethod(alwaysRun =3D true) public void setUp() { - cache =3D (CacheSPI) new DefaultCacheFactory().createCache(); + cache =3D (CacheSPI) new DefaultCacheFactory().createCache(false); + cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLock= ingScheme.PESSIMISTIC); + cache.start(); root =3D cache.getRoot(); } = --===============7645516635563857178==-- From jbosscache-commits at lists.jboss.org Wed Aug 27 08:34:31 2008 Content-Type: multipart/mixed; boundary="===============2460987693417215823==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6625 - in core/trunk/src: test/java/org/jboss/cache/commands and 1 other directory. Date: Wed, 27 Aug 2008 08:34:29 -0400 Message-ID: --===============2460987693417215823== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-27 08:34:27 -0400 (Wed, 27 Aug 2008) New Revision: 6625 Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/ExistsCommand.java core/trunk/src/test/java/org/jboss/cache/commands/StructuralNodesOnRollb= ackTest.java Log: exist command should also look into the InvocationContext, as the node migh= t be only in the transaction context Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/ExistsComm= and.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/commands/read/ExistsCommand.ja= va 2008-08-27 12:32:37 UTC (rev 6624) +++ core/trunk/src/main/java/org/jboss/cache/commands/read/ExistsCommand.ja= va 2008-08-27 12:34:27 UTC (rev 6625) @@ -2,6 +2,7 @@ = import org.jboss.cache.Fqn; import org.jboss.cache.InvocationContext; +import org.jboss.cache.NodeSPI; import org.jboss.cache.commands.Visitor; = /** @@ -40,8 +41,8 @@ */ public Object perform(InvocationContext ctx) { - // this command will use the data container directly since it does n= ot require any form of locking. - return dataContainer.exists(fqn); + NodeSPI node =3D ctx.lookUpNode(fqn); + return node !=3D null && !node.isDeleted(); } = public Object acceptVisitor(InvocationContext ctx, Visitor visitor) thr= ows Throwable Modified: core/trunk/src/test/java/org/jboss/cache/commands/StructuralNodes= OnRollbackTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/commands/StructuralNodesOnRoll= backTest.java 2008-08-27 12:32:37 UTC (rev 6624) +++ core/trunk/src/test/java/org/jboss/cache/commands/StructuralNodesOnRoll= backTest.java 2008-08-27 12:34:27 UTC (rev 6625) @@ -2,6 +2,8 @@ = import org.jboss.cache.CacheSPI; import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.NodeSPI; +import org.jboss.cache.Fqn; import org.jboss.cache.config.Configuration; import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; import org.jboss.cache.util.TestingUtil; @@ -28,8 +30,7 @@ public void setUp() { Configuration cacheConfig =3D UnitTestCacheConfigurationFactory.crea= teConfiguration(Configuration.CacheMode.LOCAL, false); - cache =3D (CacheSPI) new DefaultCacheFactory().createCache(cacheConfig, false); - cache.start(); + cache =3D (CacheSPI) new DefaultCacheFactory().createCache(cacheConfig); txMgr =3D cache.getTransactionManager(); } = @@ -39,6 +40,17 @@ TestingUtil.killCaches(cache); } = + public void testNoTx() throws Exception + { + txMgr.begin(); + cache.put("/a/b/c", "k","v"); + NodeSPI root =3D cache.getRoot(); + assert root.getChild("a") !=3D null; + assert root.getChild(Fqn.fromString("/a/b/c")) !=3D null; + assert cache.exists("/a/b"); + txMgr.rollback(); + } + public void testPutDataMap() throws Exception { HashMap map =3D new HashMap(); --===============2460987693417215823==-- From jbosscache-commits at lists.jboss.org Wed Aug 27 09:21:43 2008 Content-Type: multipart/mixed; boundary="===============7270136258683186552==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6626 - core/trunk/src/test/java/org/jboss/cache/factories. Date: Wed, 27 Aug 2008 09:21:43 -0400 Message-ID: --===============7270136258683186552== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-27 09:21:43 -0400 (Wed, 27 Aug 2008) New Revision: 6626 Modified: core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFacto= ryTest.java Log: fixed test Modified: core/trunk/src/test/java/org/jboss/cache/factories/InterceptorCha= inFactoryTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFact= oryTest.java 2008-08-27 12:34:27 UTC (rev 6625) +++ core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFact= oryTest.java 2008-08-27 13:21:43 UTC (rev 6626) @@ -10,6 +10,7 @@ import static org.jboss.cache.config.Configuration.NodeLockingScheme.MVCC; import static org.jboss.cache.config.Configuration.NodeLockingScheme.OPTIM= ISTIC; import org.jboss.cache.config.EvictionConfig; +import org.jboss.cache.config.Configuration; import org.jboss.cache.interceptors.*; import org.jboss.cache.interceptors.base.CommandInterceptor; import org.jboss.cache.loader.DummyInMemoryCacheLoader; @@ -32,9 +33,11 @@ @BeforeMethod(alwaysRun =3D true) public void setUp() throws Exception { - cache =3D (CacheSPI) new DefaultCacheFactory().creat= eCache(false); - cache.getConfiguration().setCacheMode(LOCAL); - cache.getConfiguration().setUseLazyDeserialization(false); + Configuration configuration =3D new Configuration(); + configuration.setCacheMode(LOCAL); + configuration.setNodeLockingScheme(Configuration.NodeLockingScheme.P= ESSIMISTIC); + configuration.setUseLazyDeserialization(false); + cache =3D (CacheSPI) new DefaultCacheFactory().creat= eCache(configuration,false); } = @AfterMethod(alwaysRun =3D true) @@ -484,7 +487,8 @@ } } ); - InterceptorChain chain =3D getInterceptorChainFactory(cache).buildIn= terceptorChain(); + InterceptorChainFactory factory =3D getInterceptorChainFactory(cache= ); + InterceptorChain chain =3D factory.buildInterceptorChain(); List list =3D chain.asList(); Iterator interceptors =3D list.iterator(); = --===============7270136258683186552==-- From jbosscache-commits at lists.jboss.org Wed Aug 27 09:56:58 2008 Content-Type: multipart/mixed; boundary="===============0042569036083056267==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6627 - in core/trunk/src: test/java/org/jboss/cache/factories and 1 other directory. Date: Wed, 27 Aug 2008 09:56:58 -0400 Message-ID: --===============0042569036083056267== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-27 09:56:58 -0400 (Wed, 27 Aug 2008) New Revision: 6627 Modified: core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java core/trunk/src/test/java/org/jboss/cache/factories/LifeCycleTest.java Log: fixed test Modified: core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-08= -27 13:21:43 UTC (rev 6626) +++ core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-08= -27 13:56:58 UTC (rev 6627) @@ -400,9 +400,24 @@ = public int getNumberOfNodes() { - return numNodes(root) - 1; + if (!usingMvcc) return numNodes(root) - 1; + return numNodesMvcc(rootInternal) - 1; } = + private int numNodesMvcc(InternalNode node) + { + int count =3D 1; //for 'node' + if (node !=3D null) + { + Set children =3D node.getChildren(); + for (InternalNode child : children) + { + count +=3D numNodesMvcc((InternalNode) child); + } + } + return count; + } + private int numNodes(NodeSPI n) { int count =3D 1;// for n Modified: core/trunk/src/test/java/org/jboss/cache/factories/LifeCycleTest.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/factories/LifeCycleTest.java 2= 008-08-27 13:21:43 UTC (rev 6626) +++ core/trunk/src/test/java/org/jboss/cache/factories/LifeCycleTest.java 2= 008-08-27 13:56:58 UTC (rev 6627) @@ -74,9 +74,11 @@ assertEquals(0, c[0].getNumberOfLocksHeld()); } = - public void testLocalRestartWithTransactions() throws Exception + public void testLocalRestartWithTransactionsPessimistic() throws Except= ion { - createAndRegisterCache(Configuration.CacheMode.LOCAL, true); + createAndRegisterCache(Configuration.CacheMode.LOCAL, false); + c[0].getConfiguration().setNodeLockingScheme(Configuration.NodeLocki= ngScheme.PESSIMISTIC); + c[0].start(); = TransactionManager tm =3D beginTransaction(); = --===============0042569036083056267==-- From jboss-qa-internal at redhat.com Wed Aug 27 10:56:22 2008 Content-Type: multipart/mixed; boundary="===============4780536924318994346==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_completed=3A_jboss-cache-?= =?utf-8?q?core-2=2E1=2EX-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_=2347?= Date: Wed, 27 Aug 2008 10:56:20 -0400 Message-ID: <927674263.23111219848980398.JavaMail.hudson@hudson1.qa.atl2.redhat.com> --===============4780536924318994346== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-2.1.X-jdk1.5/org= .jboss.cache$jbosscache-core/47/changes --===============4780536924318994346==-- From jboss-qa-internal at redhat.com Wed Aug 27 14:16:11 2008 Content-Type: multipart/mixed; boundary="===============5912727939611790798==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23567?= Date: Wed, 27 Aug 2008 14:16:09 -0400 Message-ID: <713162711.23441219860969386.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 332994029.22201219823117112.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============5912727939611790798== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/567/changes --===============5912727939611790798==-- From jboss-qa-internal at redhat.com Wed Aug 27 17:10:04 2008 Content-Type: multipart/mixed; boundary="===============7380195932279444613==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23433?= Date: Wed, 27 Aug 2008 17:10:00 -0400 Message-ID: <1767903490.23791219871400934.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 2119009976.22221219823435268.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============7380195932279444613== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/433/changes --===============7380195932279444613==-- From jboss-qa-internal at redhat.com Wed Aug 27 17:53:37 2008 Content-Type: multipart/mixed; boundary="===============0756648094732695361==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23568?= Date: Wed, 27 Aug 2008 17:53:35 -0400 Message-ID: <200970619.23861219874015314.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 713162711.23441219860969386.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============0756648094732695361== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/568/changes --===============0756648094732695361==-- From jbosscache-commits at lists.jboss.org Thu Aug 28 03:08:03 2008 Content-Type: multipart/mixed; boundary="===============3529011496853935965==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6628 - searchable/trunk/src/main/java/org/jboss/cache/search. Date: Thu, 28 Aug 2008 03:08:02 -0400 Message-ID: --===============3529011496853935965== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: navssurtani Date: 2008-08-28 03:08:02 -0400 (Thu, 28 Aug 2008) New Revision: 6628 Modified: searchable/trunk/src/main/java/org/jboss/cache/search/CacheEntityId.java searchable/trunk/src/main/java/org/jboss/cache/search/CacheEntityLoader.= java searchable/trunk/src/main/java/org/jboss/cache/search/CacheQuery.java searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java searchable/trunk/src/main/java/org/jboss/cache/search/IndexSearcherClose= r.java searchable/trunk/src/main/java/org/jboss/cache/search/InvalidFqnExceptio= n.java searchable/trunk/src/main/java/org/jboss/cache/search/InvalidKeyExceptio= n.java searchable/trunk/src/main/java/org/jboss/cache/search/LazyQueryResultIte= rator.java searchable/trunk/src/main/java/org/jboss/cache/search/NodeModifiedTransa= ctionContext.java searchable/trunk/src/main/java/org/jboss/cache/search/PojoTransactionCon= text.java searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIterato= r.java searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIterato= rImpl.java searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCache.ja= va searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheCon= figuration.java searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFac= tory.java searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheImp= l.java searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreList= ener.java searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoList= ener.java searchable/trunk/src/main/java/org/jboss/cache/search/Transformer.java Log: Cleaned up javadocs and LGPL licenese put in all classes. Modified: searchable/trunk/src/main/java/org/jboss/cache/search/CacheEntity= Id.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/CacheEntityId.jav= a 2008-08-27 13:56:58 UTC (rev 6627) +++ searchable/trunk/src/main/java/org/jboss/cache/search/CacheEntityId.jav= a 2008-08-28 07:08:02 UTC (rev 6628) @@ -1,3 +1,25 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright ${year}, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + package org.jboss.cache.search; = import org.jboss.cache.Fqn; @@ -5,6 +27,7 @@ /** * * This class is used to get fqns, keys and documentId's by calling method= s on {@link org.jboss.cache.search.Transformer} + *

    * @author Navin Surtani (nsurtan= i(a)redhat.com) */ public class CacheEntityId Modified: searchable/trunk/src/main/java/org/jboss/cache/search/CacheEntity= Loader.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/CacheEntityLoader= .java 2008-08-27 13:56:58 UTC (rev 6627) +++ searchable/trunk/src/main/java/org/jboss/cache/search/CacheEntityLoader= .java 2008-08-28 07:08:02 UTC (rev 6628) @@ -1,3 +1,25 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright ${year}, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + package org.jboss.cache.search; = import org.jboss.cache.Cache; @@ -9,6 +31,7 @@ = /** * Class that is used to load objects from a list of CacheEntityId ids. + *

    * @author Navin Surtani (nsurtan= i(a)redhat.com) */ public class CacheEntityLoader Modified: searchable/trunk/src/main/java/org/jboss/cache/search/CacheQuery.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/CacheQuery.java 2= 008-08-27 13:56:58 UTC (rev 6627) +++ searchable/trunk/src/main/java/org/jboss/cache/search/CacheQuery.java 2= 008-08-28 07:08:02 UTC (rev 6628) @@ -1,3 +1,25 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright ${year}, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + package org.jboss.cache.search; = import org.apache.lucene.search.Sort; @@ -10,7 +32,9 @@ * A cache-query is what will be returned when the createQuery() method is= run. This object can have methods such * as list, setFirstResult,setMaxResults, setFetchSize, getResultSize and = setSort. * + *

    * @author Manik Surtani (manik(a)jbo= ss.org) + * @author Navin Surtani (nsurtan= i(a)redhat.com) * @see org.jboss.cache.search.SearchableCache#createQuery(org.apache.luce= ne.search.Query) = */ public interface CacheQuery extends Iterable Modified: searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryI= mpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.ja= va 2008-08-27 13:56:58 UTC (rev 6627) +++ searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.ja= va 2008-08-28 07:08:02 UTC (rev 6628) @@ -1,3 +1,25 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright ${year}, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + package org.jboss.cache.search; = import org.apache.commons.logging.Log; Modified: searchable/trunk/src/main/java/org/jboss/cache/search/IndexSearch= erCloser.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/IndexSearcherClos= er.java 2008-08-27 13:56:58 UTC (rev 6627) +++ searchable/trunk/src/main/java/org/jboss/cache/search/IndexSearcherClos= er.java 2008-08-28 07:08:02 UTC (rev 6628) @@ -1,3 +1,25 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright ${year}, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + package org.jboss.cache.search; = import org.hibernate.search.engine.SearchFactoryImplementor; @@ -9,9 +31,11 @@ import java.util.Set; = /** + * Class with static method that is called by {@link CacheQueryImpl} and {= @link org.jboss.cache.search.QueryResultIteratorImpl} + *

    * @author Navin Surtani (nsurtan= i(a)redhat.com) */ -public class IndexSearcherCloser + class IndexSearcherCloser { static void closeSearcher(Searcher searcher, ReaderProvider readerProvi= der) { Modified: searchable/trunk/src/main/java/org/jboss/cache/search/InvalidFqnE= xception.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/InvalidFqnExcepti= on.java 2008-08-27 13:56:58 UTC (rev 6627) +++ searchable/trunk/src/main/java/org/jboss/cache/search/InvalidFqnExcepti= on.java 2008-08-28 07:08:02 UTC (rev 6628) @@ -1,3 +1,25 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright ${year}, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + package org.jboss.cache.search; = import org.jboss.cache.CacheException; Modified: searchable/trunk/src/main/java/org/jboss/cache/search/InvalidKeyE= xception.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/InvalidKeyExcepti= on.java 2008-08-27 13:56:58 UTC (rev 6627) +++ searchable/trunk/src/main/java/org/jboss/cache/search/InvalidKeyExcepti= on.java 2008-08-28 07:08:02 UTC (rev 6628) @@ -1,7 +1,31 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright ${year}, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + package org.jboss.cache.search; = /** - * @author Navin Surtani (nsurta= ni(a)redhat.com) + * * Thrown when an invalid Key is passed into {@link org.jboss.cache.sear= ch.Transformer#generateId(org.jboss.cache.Fqn, String)} + *

    + * @author Navin Surtani (nsurtan= i(a)redhat.com) */ public class InvalidKeyException extends Exception { Modified: searchable/trunk/src/main/java/org/jboss/cache/search/LazyQueryRe= sultIterator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/LazyQueryResultIt= erator.java 2008-08-27 13:56:58 UTC (rev 6627) +++ searchable/trunk/src/main/java/org/jboss/cache/search/LazyQueryResultIt= erator.java 2008-08-28 07:08:02 UTC (rev 6628) @@ -1,3 +1,25 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright ${year}, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ = + package org.jboss.cache.search; = import org.jboss.cache.search.CacheEntityLoader; @@ -10,6 +32,10 @@ import java.io.IOException; = /** + * Implementation for {@link org.jboss.cache.search.QueryResultIterator}. = This is what is returned when + * the {@link CacheQuery#lazyIterator()} method is called. This loads the = results only when required and hence differs from + * {@link org.jboss.cache.search.QueryResultIteratorImpl} which is the oth= er implementation of QueryResultIterator. + * * @author Navin Surtani (nsurtan= i(a)redhat.com) */ public class LazyQueryResultIterator implements QueryResultIterator Modified: searchable/trunk/src/main/java/org/jboss/cache/search/NodeModifie= dTransactionContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/NodeModifiedTrans= actionContext.java 2008-08-27 13:56:58 UTC (rev 6627) +++ searchable/trunk/src/main/java/org/jboss/cache/search/NodeModifiedTrans= actionContext.java 2008-08-28 07:08:02 UTC (rev 6628) @@ -1,3 +1,25 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright ${year}, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ = + package org.jboss.cache.search; = import org.hibernate.search.backend.TransactionContext; Modified: searchable/trunk/src/main/java/org/jboss/cache/search/PojoTransac= tionContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/PojoTransactionCo= ntext.java 2008-08-27 13:56:58 UTC (rev 6627) +++ searchable/trunk/src/main/java/org/jboss/cache/search/PojoTransactionCo= ntext.java 2008-08-28 07:08:02 UTC (rev 6628) @@ -1,3 +1,25 @@ +///* +// * JBoss, Home of Professional Open Source +// * Copyright ${year}, Red Hat Middleware LLC, and individual contributors +// * by the @authors tag. See the copyright.txt in the distribution for a +// * full listing of individual contributors. +// * +// * This is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License as +// * published by the Free Software Foundation; either version 2.1 of +// * the License, or (at your option) any later version. +// * +// * This software is distributed in the hope that it will be useful, +// * but WITHOUT ANY WARRANTY; without even the implied warranty of +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// * Lesser General Public License for more details. +// * +// * You should have received a copy of the GNU Lesser General Public +// * License along with this software; if not, write to the Free +// * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +// * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +// */ = +// //package org.jboss.cache.search; // //import org.hibernate.search.transaction.TransactionContext; Modified: searchable/trunk/src/main/java/org/jboss/cache/search/QueryResult= Iterator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIterat= or.java 2008-08-27 13:56:58 UTC (rev 6627) +++ searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIterat= or.java 2008-08-28 07:08:02 UTC (rev 6628) @@ -1,3 +1,25 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright ${year}, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ = + package org.jboss.cache.search; = import java.util.ListIterator; @@ -4,8 +26,9 @@ = /** * Iterates over query results - * + *

    * @author Manik Surtani (manik(a)jbo= ss.org) + * @author Navin Surtani (manik(a= )jboss.org) */ public interface QueryResultIterator extends ListIterator { Modified: searchable/trunk/src/main/java/org/jboss/cache/search/QueryResult= IteratorImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIterat= orImpl.java 2008-08-27 13:56:58 UTC (rev 6627) +++ searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIterat= orImpl.java 2008-08-28 07:08:02 UTC (rev 6628) @@ -1,3 +1,25 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright ${year}, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ = + package org.jboss.cache.search; = import org.jboss.cache.Cache; @@ -9,6 +31,8 @@ * This is the implementation class for the interface QueryResultIterator = which extends ListIterator. It is what is * returned when the iterator() method is run on a CacheQuery instance. * + *

    + * * @author Navin Surtani (nsurtan= i(a)redhat.com) */ public class QueryResultIteratorImpl implements QueryResultIterator Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableC= ache.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCache.j= ava 2008-08-27 13:56:58 UTC (rev 6627) +++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCache.j= ava 2008-08-28 07:08:02 UTC (rev 6628) @@ -1,3 +1,25 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright ${year}, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ = + package org.jboss.cache.search; = import org.apache.lucene.search.Query; @@ -4,12 +26,12 @@ import org.jboss.cache.Cache; = /** - * @author Navin Surtani (nsurtan= i(a)redhat.com) - *

    * This will be the most used interface in JBossCache searchable. = It extends Cache and therefore will have * the standard get(), put() and remove() methods. The additional = method is the createQuery method which people * will use to build their Hibernate Search queries from a luceneQ= uery - Hibernate Search users will be very familiar * with this. + * @author Navin Surtani (nsurtan= i(a)redhat.com) + *

    */ public interface SearchableCache extends Cache { Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableC= acheConfiguration.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheCo= nfiguration.java 2008-08-27 13:56:58 UTC (rev 6627) +++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheCo= nfiguration.java 2008-08-28 07:08:02 UTC (rev 6628) @@ -1,3 +1,25 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright ${year}, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ = + package org.jboss.cache.search; = import org.hibernate.search.cfg.SearchConfiguration; Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableC= acheFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFa= ctory.java 2008-08-27 13:56:58 UTC (rev 6627) +++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFa= ctory.java 2008-08-28 07:08:02 UTC (rev 6628) @@ -1,3 +1,25 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright ${year}, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ = + package org.jboss.cache.search; = import org.hibernate.search.impl.SearchFactoryImpl; @@ -12,6 +34,12 @@ import java.lang.reflect.Field; = /** + * Factory class used to create the searchable-cache like so: - + * + *

    + * SearchableCache searchableCache =3D SearchableCacheFactory.createSear= chableCache(coreCache, class[]); + * + *

    * @author Navin Surtani (nsurtan= i(a)redhat.com) */ public class SearchableCacheFactory Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableC= acheImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheIm= pl.java 2008-08-27 13:56:58 UTC (rev 6627) +++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheIm= pl.java 2008-08-28 07:08:02 UTC (rev 6628) @@ -1,3 +1,25 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright ${year}, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ = + package org.jboss.cache.search; = import org.apache.lucene.search.Query; @@ -19,9 +41,10 @@ import java.util.Set; = /** + * Implementation class for the SearchableCache interface. + *

    + * * @author Navin Surtani (nsurtan= i(a)redhat.com) - *

    - * Implementation class for the SearchableCache interface. */ public class SearchableCacheImpl implements SearchableCache { Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableC= oreListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreLis= tener.java 2008-08-27 13:56:58 UTC (rev 6627) +++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreLis= tener.java 2008-08-28 07:08:02 UTC (rev 6628) @@ -1,3 +1,25 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright ${year}, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ = + package org.jboss.cache.search; = import org.hibernate.search.impl.SearchFactoryImpl; @@ -16,7 +38,7 @@ /** * @author Navin Surtani (nsurtan= i(a)redhat.com) * - * Listener class for changes made to the cache. This listener makes chang= es if it is a org.jboss.cache being used. = + * Listener class for changes made to the cache. This listener makes chang= es if it is a {@link org.jboss.cache.Cache} being used. */ @CacheListener public class SearchableCoreListener Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableP= ojoListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoLis= tener.java 2008-08-27 13:56:58 UTC (rev 6627) +++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoLis= tener.java 2008-08-28 07:08:02 UTC (rev 6628) @@ -1,3 +1,25 @@ +///* +// * JBoss, Home of Professional Open Source +// * Copyright ${year}, Red Hat Middleware LLC, and individual contributors +// * by the @authors tag. See the copyright.txt in the distribution for a +// * full listing of individual contributors. +// * +// * This is free software; you can redistribute it and/or modify it +// * under the terms of the GNU Lesser General Public License as +// * published by the Free Software Foundation; either version 2.1 of +// * the License, or (at your option) any later version. +// * +// * This software is distributed in the hope that it will be useful, +// * but WITHOUT ANY WARRANTY; without even the implied warranty of +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// * Lesser General Public License for more details. +// * +// * You should have received a copy of the GNU Lesser General Public +// * License along with this software; if not, write to the Free +// * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +// * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +// */ = +// //package org.jboss.cache.search; // //import org.hibernate.search.impl.SearchFactoryImpl; Modified: searchable/trunk/src/main/java/org/jboss/cache/search/Transformer= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- searchable/trunk/src/main/java/org/jboss/cache/search/Transformer.java = 2008-08-27 13:56:58 UTC (rev 6627) +++ searchable/trunk/src/main/java/org/jboss/cache/search/Transformer.java = 2008-08-28 07:08:02 UTC (rev 6628) @@ -1,3 +1,25 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright ${year}, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ = + package org.jboss.cache.search; = import org.jboss.cache.Fqn; @@ -3,5 +25,4 @@ = /** -* @author Navin Surtani (nsurtani= (a)redhat.com) * * This class is one that does all the 'conversion' work between JBossCache= and Hibernate Search. This is where @@ -10,7 +31,8 @@ * * If the Fqn is in the form /a/b/c and the key - which has to be a String = - is keystring; the documentId - which is also * a String - will be "Fqn=3D[/a/b/c]Key=3D[keystring]" -* = +* +* @author Navin Surtani (nsurtani= (a)redhat.com) */ public class Transformer { --===============3529011496853935965==-- From jbosscache-commits at lists.jboss.org Thu Aug 28 06:55:59 2008 Content-Type: multipart/mixed; boundary="===============3991237483174084448==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6629 - core/trunk/src/main/java/org/jboss/cache/transaction. Date: Thu, 28 Aug 2008 06:55:54 -0400 Message-ID: --===============3991237483174084448== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-28 06:55:54 -0400 (Thu, 28 Aug 2008) New Revision: 6629 Modified: core/trunk/src/main/java/org/jboss/cache/transaction/DummyUserTransactio= n.java Log: removed redundant field - status Modified: core/trunk/src/main/java/org/jboss/cache/transaction/DummyUserTra= nsaction.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/transaction/DummyUserTransacti= on.java 2008-08-28 07:08:02 UTC (rev 6628) +++ core/trunk/src/main/java/org/jboss/cache/transaction/DummyUserTransacti= on.java 2008-08-28 10:55:54 UTC (rev 6629) @@ -22,7 +22,6 @@ */ public class DummyUserTransaction implements UserTransaction, java.io.Seri= alizable { - int status =3D Status.STATUS_UNKNOWN; static final Log logger_ =3D LogFactory.getLog(DummyUserTransaction.cla= ss); DummyTransactionManager tm_; private static final long serialVersionUID =3D -6568400755677046127L; @@ -50,7 +49,6 @@ public void begin() throws NotSupportedException, SystemException { tm_.begin(); - status =3D Status.STATUS_ACTIVE; } = /** @@ -75,7 +73,6 @@ { = tm_.commit(); - status =3D Status.STATUS_COMMITTED; } = /** @@ -91,7 +88,6 @@ public void rollback() throws IllegalStateException, SystemException { tm_.rollback(); - status =3D Status.STATUS_ROLLEDBACK; } = /** --===============3991237483174084448==-- From jbosscache-commits at lists.jboss.org Thu Aug 28 12:21:29 2008 Content-Type: multipart/mixed; boundary="===============7247697346727272753==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6630 - core/trunk/src/test/java/org/jboss/cache/lock. Date: Thu, 28 Aug 2008 12:21:28 -0400 Message-ID: --===============7247697346727272753== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-28 12:21:28 -0400 (Thu, 28 Aug 2008) New Revision: 6630 Modified: core/trunk/src/test/java/org/jboss/cache/lock/BreakDeadMemberLocksTest.j= ava Log: this scenario is only acceptable in a pessimistic locking scheme Modified: core/trunk/src/test/java/org/jboss/cache/lock/BreakDeadMemberLock= sTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/lock/BreakDeadMemberLocksTest.= java 2008-08-28 10:55:54 UTC (rev 6629) +++ core/trunk/src/test/java/org/jboss/cache/lock/BreakDeadMemberLocksTest.= java 2008-08-28 16:21:28 UTC (rev 6630) @@ -26,6 +26,7 @@ import org.jboss.cache.DefaultCacheFactory; import org.jboss.cache.Fqn; import org.jboss.cache.config.Configuration.CacheMode; +import org.jboss.cache.config.Configuration; import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; import org.jboss.cache.util.TestingUtil; import static org.testng.AssertJUnit.assertEquals; @@ -154,6 +155,7 @@ } = CacheSPI cache =3D (CacheSPI) new De= faultCacheFactory().createCache(UnitTestCacheConfigurationF= actory.createConfiguration(CacheMode.REPL_SYNC), false); + cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLock= ingScheme.PESSIMISTIC); = cache.create(); cache.start(); --===============7247697346727272753==-- From jbosscache-commits at lists.jboss.org Thu Aug 28 12:24:04 2008 Content-Type: multipart/mixed; boundary="===============1839751450100941269==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6631 - in core/trunk/src/test: resources and 1 other directory. Date: Thu, 28 Aug 2008 12:24:03 -0400 Message-ID: --===============1839751450100941269== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-28 12:24:02 -0400 (Thu, 28 Aug 2008) New Revision: 6631 Added: core/trunk/src/test/java/org/jboss/cache/lock/PessimisticAcquireAllTest.= java Removed: core/trunk/src/test/java/org/jboss/cache/lock/AcquireAllTest.java Modified: core/trunk/src/test/resources/log4j.xml Log: this scenario is only acceptable in a pessimistic locking scheme Deleted: core/trunk/src/test/java/org/jboss/cache/lock/AcquireAllTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/lock/AcquireAllTest.java 2008-= 08-28 16:21:28 UTC (rev 6630) +++ core/trunk/src/test/java/org/jboss/cache/lock/AcquireAllTest.java 2008-= 08-28 16:24:02 UTC (rev 6631) @@ -1,92 +0,0 @@ -package org.jboss.cache.lock; - -import org.jboss.cache.CacheSPI; -import org.jboss.cache.DefaultCacheFactory; -import org.jboss.cache.Fqn; -import org.jboss.cache.NodeSPI; -import org.jboss.cache.util.TestingUtil; -import org.jboss.cache.config.Configuration; -import org.jboss.cache.transaction.DummyTransactionManagerLookup; -import static org.testng.AssertJUnit.assertEquals; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.Test; - -/** - * @author Bela Ban - * @version $Id$ - */ -(a)Test(groups =3D {"functional"}) -public class AcquireAllTest -{ - CacheSPI cache =3D null, cache2; - final Fqn FQN =3D Fqn.fromString("/myNode"); - final String KEY =3D "key"; - final String VALUE =3D "value"; - - @AfterMethod(alwaysRun =3D true) - public void tearDown() throws Exception - { - TestingUtil.killCaches(cache, cache2); - } - - - public void testAcquireAll() throws Exception - { - NodeSPI root; - Object owner =3D Thread.currentThread(); - - cache =3D createCache(Configuration.CacheMode.LOCAL, IsolationLevel.= SERIALIZABLE); - cache.put("/a/b/c", null); - cache.put("/1/2/3", null); - - root =3D cache.getRoot(); - NodeLock lock =3D root.getLock(); - - lock.acquireAll(owner, 2000, LockType.READ); - lock.releaseAll(owner); - - assertEquals(0, cache.getNumberOfLocksHeld()); - - lock.acquireAll(owner, 2000, LockType.WRITE); - lock.releaseAll(owner); - - assertEquals(0, cache.getNumberOfLocksHeld()); - } - - - public void testAcquireAllReplicated() throws Exception - { - NodeSPI root; - Object owner =3D Thread.currentThread(); - - cache2 =3D createCache(Configuration.CacheMode.REPL_ASYNC, Isolation= Level.SERIALIZABLE); - cache2.put("/a/b/c", null); - cache2.put("/1/2/3", null); - - cache =3D createCache(Configuration.CacheMode.REPL_ASYNC, IsolationL= evel.SERIALIZABLE); - root =3D cache.getRoot(); - NodeLock lock =3D root.getLock(); - - lock.acquireAll(owner, 2000, LockType.READ); - lock.releaseAll(owner); - - assertEquals(0, cache.getNumberOfLocksHeld()); - - lock.acquireAll(owner, 2000, LockType.WRITE); - lock.releaseAll(owner); - - assertEquals(0, cache.getNumberOfLocksHeld()); - } - - - private CacheSPI createCache(Configuration.CacheMode mo= de, IsolationLevel level) - { - CacheSPI c =3D (CacheSPI) new Defaul= tCacheFactory().createCache(false); - c.getConfiguration().setCacheMode(mode); - c.getConfiguration().setIsolationLevel(level); - c.getConfiguration().setTransactionManagerLookupClass(DummyTransacti= onManagerLookup.class.getName()); - c.create(); - c.start(); - return c; - } -} Copied: core/trunk/src/test/java/org/jboss/cache/lock/PessimisticAcquireAll= Test.java (from rev 6621, core/trunk/src/test/java/org/jboss/cache/lock/Acq= uireAllTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/lock/PessimisticAcquireAllTest= .java (rev 0) +++ core/trunk/src/test/java/org/jboss/cache/lock/PessimisticAcquireAllTest= .java 2008-08-28 16:24:02 UTC (rev 6631) @@ -0,0 +1,93 @@ +package org.jboss.cache.lock; + +import org.jboss.cache.CacheSPI; +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.Fqn; +import org.jboss.cache.NodeSPI; +import org.jboss.cache.util.TestingUtil; +import org.jboss.cache.config.Configuration; +import org.jboss.cache.transaction.DummyTransactionManagerLookup; +import static org.testng.AssertJUnit.assertEquals; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.Test; + +/** + * @author Bela Ban + * @version $Id$ + */ +(a)Test(groups =3D {"functional"}) +public class PessimisticAcquireAllTest +{ + CacheSPI cache =3D null, cache2; + final Fqn FQN =3D Fqn.fromString("/myNode"); + final String KEY =3D "key"; + final String VALUE =3D "value"; + + @AfterMethod(alwaysRun =3D true) + public void tearDown() throws Exception + { + TestingUtil.killCaches(cache, cache2); + } + + + public void testAcquireAll() throws Exception + { + NodeSPI root; + Object owner =3D Thread.currentThread(); + + cache =3D createCache(Configuration.CacheMode.LOCAL, IsolationLevel.= SERIALIZABLE); + cache.put("/a/b/c", null); + cache.put("/1/2/3", null); + + root =3D cache.getRoot(); + NodeLock lock =3D root.getLock(); + + lock.acquireAll(owner, 2000, LockType.READ); + lock.releaseAll(owner); + + assertEquals(0, cache.getNumberOfLocksHeld()); + + lock.acquireAll(owner, 2000, LockType.WRITE); + lock.releaseAll(owner); + + assertEquals(0, cache.getNumberOfLocksHeld()); + } + + + public void testAcquireAllReplicated() throws Exception + { + NodeSPI root; + Object owner =3D Thread.currentThread(); + + cache2 =3D createCache(Configuration.CacheMode.REPL_ASYNC, Isolation= Level.SERIALIZABLE); + cache2.put("/a/b/c", null); + cache2.put("/1/2/3", null); + + cache =3D createCache(Configuration.CacheMode.REPL_ASYNC, IsolationL= evel.SERIALIZABLE); + root =3D cache.getRoot(); + NodeLock lock =3D root.getLock(); + + lock.acquireAll(owner, 2000, LockType.READ); + lock.releaseAll(owner); + + assertEquals(0, cache.getNumberOfLocksHeld()); + + lock.acquireAll(owner, 2000, LockType.WRITE); + lock.releaseAll(owner); + + assertEquals(0, cache.getNumberOfLocksHeld()); + } + + + private CacheSPI createCache(Configuration.CacheMode mo= de, IsolationLevel level) + { + CacheSPI c =3D (CacheSPI) new Defaul= tCacheFactory().createCache(false); + c.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingS= cheme.PESSIMISTIC); + c.getConfiguration().setCacheMode(mode); + c.getConfiguration().setIsolationLevel(level); + c.getConfiguration().setTransactionManagerLookupClass(DummyTransacti= onManagerLookup.class.getName()); + c.create(); + c.start(); + return c; + } +} Property changes on: core/trunk/src/test/java/org/jboss/cache/lock/Pessimis= ticAcquireAllTest.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Modified: core/trunk/src/test/resources/log4j.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/resources/log4j.xml 2008-08-28 16:21:28 UTC (rev 66= 30) +++ core/trunk/src/test/resources/log4j.xml 2008-08-28 16:24:02 UTC (rev 66= 31) @@ -10,7 +10,7 @@ - + = @@ -46,9 +46,13 @@ = - + = + + + + @@ -66,7 +70,7 @@ = - + = --===============1839751450100941269==-- From jbosscache-commits at lists.jboss.org Thu Aug 28 12:25:15 2008 Content-Type: multipart/mixed; boundary="===============0840188136905904690==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6632 - core/trunk/src/test/java/org/jboss/cache/lock. Date: Thu, 28 Aug 2008 12:25:15 -0400 Message-ID: --===============0840188136905904690== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-28 12:25:14 -0400 (Thu, 28 Aug 2008) New Revision: 6632 Modified: core/trunk/src/test/java/org/jboss/cache/lock/PessimisticLockTest.java Log: this scenario is only acceptable in a pessimistic locking scheme Modified: core/trunk/src/test/java/org/jboss/cache/lock/PessimisticLockTest= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/lock/PessimisticLockTest.java = 2008-08-28 16:24:02 UTC (rev 6631) +++ core/trunk/src/test/java/org/jboss/cache/lock/PessimisticLockTest.java = 2008-08-28 16:25:14 UTC (rev 6632) @@ -5,6 +5,7 @@ import org.jboss.cache.DefaultCacheFactory; import org.jboss.cache.Fqn; import org.jboss.cache.NodeSPI; +import org.jboss.cache.config.Configuration; import static org.jboss.cache.lock.LockType.READ; import static org.jboss.cache.lock.LockType.WRITE; import org.jboss.cache.transaction.DummyTransactionManagerLookup; @@ -36,6 +37,7 @@ { cache =3D new DefaultCacheFactory().createCache(fals= e); cache.getConfiguration().setTransactionManagerLookupClass(DummyTrans= actionManagerLookup.class.getName()); + cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLock= ingScheme.PESSIMISTIC); cache.start(); tm =3D cache.getConfiguration().getRuntimeConfig().getTransactionMan= ager(); lockManager =3D TestingUtil.extractLockManager(cache); --===============0840188136905904690==-- From jbosscache-commits at lists.jboss.org Thu Aug 28 12:27:11 2008 Content-Type: multipart/mixed; boundary="===============2649030443407087847==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6633 - in core/trunk/src: test/java/org/jboss/cache/lock and 1 other directory. Date: Thu, 28 Aug 2008 12:27:10 -0400 Message-ID: --===============2649030443407087847== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-28 12:27:09 -0400 (Thu, 28 Aug 2008) New Revision: 6633 Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java core/trunk/src/test/java/org/jboss/cache/lock/UpgradeLockTest.java Log: this scenario is only acceptable in a pessimistic locking scheme Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxIntercept= or.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.jav= a 2008-08-28 16:25:14 UTC (rev 6632) +++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.jav= a 2008-08-28 16:27:09 UTC (rev 6633) @@ -666,10 +666,6 @@ = /** * Creates a gtx (if one doesnt exist), a sync handler, and registers t= he tx. - * - * @param tx - * @return - * @throws Exception */ private GlobalTransaction registerTransaction(Transaction tx, Invocatio= nContext ctx) throws Exception { @@ -716,10 +712,6 @@ = /** * Registers a sync hander against a tx. - * - * @param tx - * @param handler - * @throws Exception */ private void registerHandler(Transaction tx, Synchronization handler, I= nvocationContext ctx) throws Exception { Modified: core/trunk/src/test/java/org/jboss/cache/lock/UpgradeLockTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/lock/UpgradeLockTest.java 2008= -08-28 16:25:14 UTC (rev 6632) +++ core/trunk/src/test/java/org/jboss/cache/lock/UpgradeLockTest.java 2008= -08-28 16:27:09 UTC (rev 6633) @@ -10,6 +10,7 @@ = import org.jboss.cache.CacheSPI; import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.config.Configuration; import org.jboss.cache.transaction.DummyTransactionManager; import static org.testng.AssertJUnit.assertEquals; import org.testng.annotations.AfterMethod; @@ -87,6 +88,7 @@ private CacheSPI createCache(IsolationLevel level) { CacheSPI c =3D (CacheSPI) new Defaul= tCacheFactory().createCache(false); + c.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingS= cheme.PESSIMISTIC); c.getConfiguration().setClusterName("test"); c.getConfiguration().setStateRetrievalTimeout(10000); c.getConfiguration().setTransactionManagerLookupClass("org.jboss.cac= he.transaction.JBossTransactionManagerLookup"); --===============2649030443407087847==-- From jbosscache-commits at lists.jboss.org Thu Aug 28 12:38:09 2008 Content-Type: multipart/mixed; boundary="===============7592942945102390462==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6634 - core/trunk/src/test/java/org/jboss/cache. Date: Thu, 28 Aug 2008 12:38:08 -0400 Message-ID: --===============7592942945102390462== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-28 12:38:07 -0400 (Thu, 28 Aug 2008) New Revision: 6634 Modified: core/trunk/src/test/java/org/jboss/cache/CallbackTest.java Log: this scenario is only acceptable in a pessimistic locking scheme Modified: core/trunk/src/test/java/org/jboss/cache/CallbackTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/CallbackTest.java 2008-08-28 1= 6:27:09 UTC (rev 6633) +++ core/trunk/src/test/java/org/jboss/cache/CallbackTest.java 2008-08-28 1= 6:38:07 UTC (rev 6634) @@ -108,6 +108,7 @@ { Configuration c =3D new Configuration(); c.setCacheMode(mode); + c.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC); c.setIsolationLevel(level); c.setTransactionManagerLookupClass("org.jboss.cache.transaction.Dumm= yTransactionManagerLookup"); return (CacheSPI) new DefaultCacheFactory().createCache(c); --===============7592942945102390462==-- From jbosscache-commits at lists.jboss.org Thu Aug 28 12:41:07 2008 Content-Type: multipart/mixed; boundary="===============4098091936619513202==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6635 - core/trunk/src/test/resources. Date: Thu, 28 Aug 2008 12:41:07 -0400 Message-ID: --===============4098091936619513202== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-28 12:41:07 -0400 (Thu, 28 Aug 2008) New Revision: 6635 Modified: core/trunk/src/test/resources/log4j.xml Log: rolledback Modified: core/trunk/src/test/resources/log4j.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/resources/log4j.xml 2008-08-28 16:38:07 UTC (rev 66= 34) +++ core/trunk/src/test/resources/log4j.xml 2008-08-28 16:41:07 UTC (rev 66= 35) @@ -10,7 +10,7 @@ - + = @@ -46,13 +46,9 @@ = - + = - - - - @@ -70,7 +66,7 @@ = - + = --===============4098091936619513202==-- From jbosscache-commits at lists.jboss.org Thu Aug 28 12:45:12 2008 Content-Type: multipart/mixed; boundary="===============1366000099567336767==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6636 - core/trunk/src/test/java/org/jboss/cache/jmx/deprecated. Date: Thu, 28 Aug 2008 12:45:11 -0400 Message-ID: --===============1366000099567336767== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-28 12:45:10 -0400 (Thu, 28 Aug 2008) New Revision: 6636 Modified: core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapperT= estBase.java Log: fixed tests Modified: core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxW= rapperTestBase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapper= TestBase.java 2008-08-28 16:41:07 UTC (rev 6635) +++ core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapper= TestBase.java 2008-08-28 16:45:10 UTC (rev 6636) @@ -102,6 +102,7 @@ protected CacheJmxWrapper createWrapper(Configuration c= onfig) { CacheJmxWrapper wrapper =3D new CacheJmxWrapper(); + config.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMIS= TIC); wrapper.setConfiguration(config); return wrapper; } @@ -117,6 +118,7 @@ { Configuration c =3D new Configuration(); c.setClusterName(CLUSTER_NAME); + c.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC); c.setExposeManagementStatistics(true); c.setCacheMode(Configuration.CacheMode.LOCAL); return c; --===============1366000099567336767==-- From jboss-qa-internal at redhat.com Thu Aug 28 14:19:07 2008 Content-Type: multipart/mixed; boundary="===============5687526915592491807==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23569?= Date: Thu, 28 Aug 2008 14:19:05 -0400 Message-ID: <1118648564.25601219947545535.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 200970619.23861219874015314.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============5687526915592491807== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/569/changes --===============5687526915592491807==-- From jboss-qa-internal at redhat.com Thu Aug 28 14:49:45 2008 Content-Type: multipart/mixed; boundary="===============7045663849948886683==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23434?= Date: Thu, 28 Aug 2008 14:49:41 -0400 Message-ID: <597825567.25711219949381230.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1767903490.23791219871400934.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============7045663849948886683== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/434/changes --===============7045663849948886683==-- From jbosscache-commits at lists.jboss.org Thu Aug 28 23:24:28 2008 Content-Type: multipart/mixed; boundary="===============0422582468864203579==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6637 - core/trunk. Date: Thu, 28 Aug 2008 23:24:28 -0400 Message-ID: --===============0422582468864203579== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-28 23:24:27 -0400 (Thu, 28 Aug 2008) New Revision: 6637 Modified: core/trunk/pom.xml Log: Updated commons-core Modified: core/trunk/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/pom.xml 2008-08-28 16:45:10 UTC (rev 6636) +++ core/trunk/pom.xml 2008-08-29 03:24:27 UTC (rev 6637) @@ -47,7 +47,7 @@ org.jboss jboss-common-core - 2.2.7.GA + 2.2.8.GA = @@ -415,7 +415,7 @@ org.jboss jboss-common-core - 2.2.7.GA + 2.2.8.GA commons-logging --===============0422582468864203579==-- From jbosscache-commits at lists.jboss.org Thu Aug 28 23:32:20 2008 Content-Type: multipart/mixed; boundary="===============2448559177701411404==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6638 - core/tags/2.2.0.GA. Date: Thu, 28 Aug 2008 23:32:19 -0400 Message-ID: --===============2448559177701411404== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-28 23:32:18 -0400 (Thu, 28 Aug 2008) New Revision: 6638 Modified: core/tags/2.2.0.GA/pom.xml Log: Modified: core/tags/2.2.0.GA/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/tags/2.2.0.GA/pom.xml 2008-08-29 03:24:27 UTC (rev 6637) +++ core/tags/2.2.0.GA/pom.xml 2008-08-29 03:32:18 UTC (rev 6638) @@ -47,7 +47,7 @@ org.jboss jboss-common-core - 2.2.3.GA + 2.2.8.GA apache-slide @@ -430,7 +430,7 @@ org.jboss jboss-common-core - 2.2.7.GA + 2.2.8.GA commons-logging --===============2448559177701411404==-- From jbosscache-commits at lists.jboss.org Thu Aug 28 23:57:04 2008 Content-Type: multipart/mixed; boundary="===============1802244673524468142==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6639 - core/branches/2.2.X. Date: Thu, 28 Aug 2008 23:57:03 -0400 Message-ID: --===============1802244673524468142== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-28 23:57:03 -0400 (Thu, 28 Aug 2008) New Revision: 6639 Modified: core/branches/2.2.X/pom.xml Log: Updated commons-core Modified: core/branches/2.2.X/pom.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/2.2.X/pom.xml 2008-08-29 03:32:18 UTC (rev 6638) +++ core/branches/2.2.X/pom.xml 2008-08-29 03:57:03 UTC (rev 6639) @@ -47,7 +47,7 @@ org.jboss jboss-common-core - 2.2.3.GA + 2.2.8.GA apache-slide @@ -430,7 +430,7 @@ org.jboss jboss-common-core - 2.2.7.GA + 2.2.8.GA commons-logging --===============1802244673524468142==-- From jbosscache-commits at lists.jboss.org Fri Aug 29 00:23:29 2008 Content-Type: multipart/mixed; boundary="===============8719446244569392145==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6640 - core/trunk/src/test/java/org/jboss/cache/lock. Date: Fri, 29 Aug 2008 00:23:29 -0400 Message-ID: --===============8719446244569392145== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-29 00:23:28 -0400 (Fri, 29 Aug 2008) New Revision: 6640 Modified: core/trunk/src/test/java/org/jboss/cache/lock/PessimisticLockTest.java core/trunk/src/test/java/org/jboss/cache/lock/WriteLockOnParentTest.java Log: Fixed broken tests Modified: core/trunk/src/test/java/org/jboss/cache/lock/PessimisticLockTest= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/lock/PessimisticLockTest.java = 2008-08-29 03:57:03 UTC (rev 6639) +++ core/trunk/src/test/java/org/jboss/cache/lock/PessimisticLockTest.java = 2008-08-29 04:23:28 UTC (rev 6640) @@ -46,7 +46,7 @@ @AfterMethod(alwaysRun =3D true) public void tearDown() { - cache.stop(); + TestingUtil.killCaches(cache); } = private void assertNoStaleLocks() Modified: core/trunk/src/test/java/org/jboss/cache/lock/WriteLockOnParentTe= st.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/lock/WriteLockOnParentTest.jav= a 2008-08-29 03:57:03 UTC (rev 6639) +++ core/trunk/src/test/java/org/jboss/cache/lock/WriteLockOnParentTest.jav= a 2008-08-29 04:23:28 UTC (rev 6640) @@ -3,6 +3,7 @@ import org.jboss.cache.CacheSPI; import org.jboss.cache.DefaultCacheFactory; import org.jboss.cache.Fqn; +import org.jboss.cache.config.Configuration.NodeLockingScheme; import static org.testng.AssertJUnit.*; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; @@ -24,6 +25,7 @@ { cache =3D (CacheSPI) new DefaultCacheFactory().createCache(false); cache.getConfiguration().setTransactionManagerLookupClass("org.jboss= .cache.transaction.DummyTransactionManagerLookup"); + cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESS= IMISTIC); // reduce LAT so the test runs faster cache.getConfiguration().setLockAcquisitionTimeout(500); = --===============8719446244569392145==-- From jbosscache-commits at lists.jboss.org Fri Aug 29 00:57:47 2008 Content-Type: multipart/mixed; boundary="===============0536058169261604235==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6641 - in core/trunk/src: test/java/org/jboss/cache/eviction and 1 other directories. Date: Fri, 29 Aug 2008 00:57:47 -0400 Message-ID: --===============0536058169261604235== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-29 00:57:46 -0400 (Fri, 29 Aug 2008) New Revision: 6641 Modified: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionTimerTask.java core/trunk/src/test/java/org/jboss/cache/eviction/EvictionTestsBase.java core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.j= ava core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionControll= er.java Log: Better timing control between eviction events Modified: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionTimerTa= sk.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionTimerTask.jav= a 2008-08-29 04:23:28 UTC (rev 6640) +++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionTimerTask.jav= a 2008-08-29 04:57:46 UTC (rev 6641) @@ -34,12 +34,14 @@ private static AtomicInteger tcount =3D new AtomicInteger(); private long wakeupInterval; ScheduledExecutorService scheduledExecutor; + private Task task; = public EvictionTimerTask() { // synchronized set because we need to maintain thread safety // for dynamic configuration purposes. processedRegions =3D new ConcurrentHashSet(); + task =3D new Task(); } = public void init(long wakeupInterval) @@ -106,16 +108,7 @@ return new Thread(r, "EvictionTimer-" + tcount.getAndIncrement= ()); } }); - scheduledExecutor.scheduleWithFixedDelay(new Runnable() - { - public void run() - { - // Run the eviction thread. - // This thread will synchronize the set of regions and iterate= through every MarshRegion registered w/ the - // Eviction thread. It also synchronizes on each individual re= gion as it is being processed. - processRegions(); - } - }, wakeupInterval, wakeupInterval, TimeUnit.MILLISECONDS); + scheduledExecutor.scheduleWithFixedDelay(task, wakeupInterval, wakeu= pInterval, TimeUnit.MILLISECONDS); } = private void processRegions() @@ -146,6 +139,17 @@ } } } + + public class Task implements Runnable + { + public void run() + { + // Run the eviction thread. + // This thread will synchronize the set of regions and iterate th= rough every MarshRegion registered w/ the + // Eviction thread. It also synchronizes on each individual regio= n as it is being processed. + processRegions(); + } + } } = = Modified: core/trunk/src/test/java/org/jboss/cache/eviction/EvictionTestsBa= se.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/EvictionTestsBase.jav= a 2008-08-29 04:23:28 UTC (rev 6640) +++ core/trunk/src/test/java/org/jboss/cache/eviction/EvictionTestsBase.jav= a 2008-08-29 04:57:46 UTC (rev 6641) @@ -13,6 +13,7 @@ import org.jboss.cache.config.EvictionConfig; import org.jboss.cache.config.EvictionRegionConfig; import org.jboss.cache.util.TestingUtil; +import org.jboss.cache.util.internals.EvictionController; import org.jboss.cache.util.internals.EvictionWatcher; = import java.util.concurrent.TimeUnit; @@ -48,6 +49,10 @@ */ public boolean waitForEviction(Cache cache, long timeToWait, TimeUnit u= nit, Fqn... fqnsToEvict) throws InterruptedException { - return new EvictionWatcher(cache, fqnsToEvict).waitForEviction(timeT= oWait, unit); + EvictionController ec =3D new EvictionController(cache); + EvictionController.Signaller signaller =3D ec.getEvictionThreadSigna= ller(); + boolean evicted =3D new EvictionWatcher(cache, fqnsToEvict).waitForE= viction(timeToWait, unit); + signaller.waitForEvictionThreadCompletion(timeToWait, unit); + return evicted; } } Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolic= yTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.= java 2008-08-29 04:23:28 UTC (rev 6640) +++ core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.= java 2008-08-29 04:57:46 UTC (rev 6641) @@ -16,6 +16,7 @@ import org.jboss.cache.config.EvictionConfig; import org.jboss.cache.config.EvictionRegionConfig; import org.jboss.cache.util.TestingUtil; +import org.jboss.cache.util.internals.EvictionController; import static org.testng.AssertJUnit.*; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; @@ -68,45 +69,63 @@ = public void testUpdateToFuture() throws Exception { - log.info("update 1 from future to past"); - cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future); - TestingUtil.sleepThread(200); - assertNotNull(cache.getNode(fqn1)); - cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future + 2= 50); - TestingUtil.sleepThread(500); - assertNotNull(cache.getNode(fqn1)); - TestingUtil.sleepThread(100); - assertNull(cache.getNode(fqn1)); - cache.removeNode(Fqn.ROOT); + try + { + log.info("update 1 from future to past"); + cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future); + TestingUtil.sleepThread(200); + new EvictionController(cache).startEviction(); + assertNotNull(cache.getNode(fqn1)); + cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future = + 250); + TestingUtil.sleepThread(500); + new EvictionController(cache).startEviction(); + assertNotNull(cache.getNode(fqn1)); + TestingUtil.sleepThread(100); + new EvictionController(cache).startEviction(); + assertNull(cache.getNode(fqn1)); + } + finally + { + cache.removeNode(Fqn.ROOT); + } } = + @Test(invocationCount =3D 10) public void testEviction() throws Exception { cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future); cache.put(fqn2, ExpirationAlgorithmConfig.EXPIRATION_KEY, past); cache.put(fqn3, ExpirationAlgorithmConfig.EXPIRATION_KEY, future); cache.put(fqn4, "foo", "bar"); - assert waitForEviction(cache, 30, TimeUnit.SECONDS, fqn2) : "Evictio= n event not received!"; + + waitForEviction(cache, 30, TimeUnit.SECONDS, fqn2); assertNotNull(cache.getNode(fqn1)); assertNull(cache.getNode(fqn2)); assertNotNull(cache.getNode(fqn3)); assertNotNull(cache.getNode(fqn4)); = log.info("should remove 1 and 3 now"); - assert waitForEviction(cache, 30, TimeUnit.SECONDS, fqn1, fqn3) : "E= viction event not received!"; + waitForEviction(cache, 30, TimeUnit.SECONDS, fqn1, fqn3); assertNull(cache.getNode(fqn1)); assertNull(cache.getNode(fqn3)); } = public void testUpdate() throws Exception { - log.info("update 1 from future to past"); - cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future); - assertNotNull(cache.getNode(fqn1)); - cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, past); - assert waitForEviction(cache, 1, TimeUnit.SECONDS, fqn1) : "Eviction= event not received!"; - assertNull(cache.getNode(fqn1)); - cache.removeNode(Fqn.ROOT); + try + { + log.info("update 1 from future to past"); + cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future); + new EvictionController(cache).startEviction(); + assertNotNull(cache.getNode(fqn1)); + cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, past); + new EvictionController(cache).startEviction(); + assertNull(cache.getNode(fqn1)); + } + finally + { + cache.removeNode(Fqn.ROOT); + } } = public void testMaxNodes() throws Exception Modified: core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionC= ontroller.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionControl= ler.java 2008-08-29 04:23:28 UTC (rev 6640) +++ core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionControl= ler.java 2008-08-29 04:57:46 UTC (rev 6641) @@ -8,10 +8,14 @@ import org.jboss.cache.config.EvictionConfig; import org.jboss.cache.config.EvictionRegionConfig; import org.jboss.cache.eviction.EvictionTimerTask; +import org.jboss.cache.eviction.EvictionTimerTask.Task; import org.jboss.cache.eviction.LRUAlgorithmConfig; import org.jboss.cache.util.TestingUtil; = +import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.util.concurrent.Semaphore; +import java.util.concurrent.TimeUnit; = /** * when used on a cache will disable defaul eviction behavior and it will = supply means of kicking off evction @@ -115,4 +119,72 @@ } } } + + public Signaller getEvictionThreadSignaller() + { + final Signaller s =3D new Signaller(); + Task signallingTask =3D timerTask.new Task() + { + public void run() + { + s.getToken(); + try + { + super.run(); + } + finally + { + s.releaseToken(); + } + } + }; + + try + { + Class ettClass =3D EvictionTimerTask.class; + Field f =3D ettClass.getDeclaredField("task"); + f.setAccessible(true); + f.set(timerTask, signallingTask); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + timerTask.init(originalWakeupInterval); + return s; + } + + public static class Signaller + { + Semaphore s =3D new Semaphore(1); + + public boolean waitForEvictionThreadCompletion(long time, TimeUnit u= nit) throws InterruptedException + { + try + { + return s.tryAcquire(time, unit); + } + finally + { + s.release(); + } + } + + void getToken() + { + try + { + s.acquire(); + } + catch (InterruptedException e) + { + Thread.currentThread().interrupt(); + } + } + + void releaseToken() + { + s.release(); + } + } } --===============0536058169261604235==-- From jboss-qa-internal at redhat.com Fri Aug 29 02:17:34 2008 Content-Type: multipart/mixed; boundary="===============6277389221730430801==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23570?= Date: Fri, 29 Aug 2008 02:17:31 -0400 Message-ID: <1915244484.26501219990651941.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1118648564.25601219947545535.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============6277389221730430801== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/570/changes --===============6277389221730430801==-- From jboss-qa-internal at redhat.com Fri Aug 29 03:01:39 2008 Content-Type: multipart/mixed; boundary="===============4202015146093303664==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23435?= Date: Fri, 29 Aug 2008 03:01:37 -0400 Message-ID: <1943803439.26851219993297660.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 597825567.25711219949381230.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============4202015146093303664== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/435/changes --===============4202015146093303664==-- From jboss-qa-internal at redhat.com Fri Aug 29 05:29:14 2008 Content-Type: multipart/mixed; boundary="===============1369239756634422757==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23436?= Date: Fri, 29 Aug 2008 05:29:10 -0400 Message-ID: <1184778278.26991220002150580.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1943803439.26851219993297660.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============1369239756634422757== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/436/changes --===============1369239756634422757==-- From jboss-qa-internal at redhat.com Fri Aug 29 05:57:00 2008 Content-Type: multipart/mixed; boundary="===============7032118841766279228==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23571?= Date: Fri, 29 Aug 2008 05:56:51 -0400 Message-ID: <1151539176.27021220003811326.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 1915244484.26501219990651941.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============7032118841766279228== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/571/changes --===============7032118841766279228==-- From jbosscache-commits at lists.jboss.org Fri Aug 29 06:39:06 2008 Content-Type: multipart/mixed; boundary="===============7996178591231869921==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6642 - core/trunk/src/main/java/org/jboss/cache. Date: Fri, 29 Aug 2008 06:39:03 -0400 Message-ID: --===============7996178591231869921== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-29 06:39:01 -0400 (Fri, 29 Aug 2008) New Revision: 6642 Modified: core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java Log: fixed UT Modified: core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-08= -29 04:57:46 UTC (rev 6641) +++ core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-08= -29 10:39:01 UTC (rev 6642) @@ -476,6 +476,17 @@ return count; } = + private int numAttributesMvcc(InternalNode n) + { + int count =3D 0; + for (Object child : n.getChildren()) + { + count +=3D numAttributesMvcc((InternalNode) child); + } + count +=3D n.getData().size(); + return count; + } + private int numAttributes(InternalNode n) { int count =3D 0; @@ -489,7 +500,7 @@ = public int getNumberOfAttributes() { - return usingMvcc ? numAttributes(rootInternal) : numAttributes(root); + return usingMvcc ? numAttributesMvcc(rootInternal) : numAttributes(r= oot); } = public boolean removeFromDataStructure(Fqn f, boolean skipMarkerCheck) --===============7996178591231869921==-- From jboss-qa-internal at redhat.com Fri Aug 29 08:00:00 2008 Content-Type: multipart/mixed; boundary="===============4784842997147549773==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-2=2E2=2EX-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Editi?= =?utf-8?q?on_=2322?= Date: Fri, 29 Aug 2008 07:59:58 -0400 Message-ID: <1664660500.27431220011198735.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 207320961.7781219475741785.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============4784842997147549773== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-2.2.X-jdk1.6/org= .jboss.cache$jbosscache-core/22/changes --===============4784842997147549773==-- From jbosscache-commits at lists.jboss.org Fri Aug 29 10:10:18 2008 Content-Type: multipart/mixed; boundary="===============9117271387310427928==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6643 - core/trunk/src/test/java/org/jboss/cache/notifications. Date: Fri, 29 Aug 2008 10:10:18 -0400 Message-ID: --===============9117271387310427928== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-29 10:10:18 -0400 (Fri, 29 Aug 2008) New Revision: 6643 Modified: core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerPass= ivationTest.java Log: make the test fit MVCC Modified: core/trunk/src/test/java/org/jboss/cache/notifications/CacheListe= nerPassivationTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerPas= sivationTest.java 2008-08-29 10:39:01 UTC (rev 6642) +++ core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerPas= sivationTest.java 2008-08-29 14:10:18 UTC (rev 6643) @@ -83,9 +83,9 @@ expected.clear(); eventLog.events.clear(); cache.get(fqn, "DOES_NOT_EXIST"); - expected.add(new EventImpl(true, cache, null, Collections.emptyMap()= , fqn, null, true, null, false, null, NODE_ACTIVATED)); expected.add(new EventImpl(true, cache, null, null, fqn, null, true,= null, false, null, NODE_CREATED)); expected.add(new EventImpl(false, cache, null, null, fqn, null, true= , null, false, null, NODE_CREATED)); + expected.add(new EventImpl(true, cache, null, Collections.emptyMap()= , fqn, null, true, null, false, null, NODE_ACTIVATED)); expected.add(new EventImpl(false, cache, null, data, fqn, null, true= , null, false, null, NODE_ACTIVATED)); expected.add(new EventImpl(true, cache, null, null, fqn, null, true,= null, false, null, NODE_VISITED)); expected.add(new EventImpl(false, cache, null, null, fqn, null, true= , null, false, null, NODE_VISITED)); @@ -119,9 +119,9 @@ cache.get(fqn, "DOES_NOT_EXIST"); tm.commit(); expected.add(new EventImpl(false, cache, null, null, null, tx, true,= null, false, null, TRANSACTION_REGISTERED)); - expected.add(new EventImpl(true, cache, null, Collections.emptyMap()= , fqn, tx, true, null, false, null, NODE_ACTIVATED)); expected.add(new EventImpl(true, cache, null, null, fqn, tx, true, n= ull, false, null, NODE_CREATED)); expected.add(new EventImpl(false, cache, null, null, fqn, tx, true, = null, false, null, NODE_CREATED)); + expected.add(new EventImpl(true, cache, null, Collections.emptyMap()= , fqn, tx, true, null, false, null, NODE_ACTIVATED)); expected.add(new EventImpl(false, cache, null, data, fqn, tx, true, = null, false, null, NODE_ACTIVATED)); expected.add(new EventImpl(true, cache, null, null, fqn, tx, true, n= ull, false, null, NODE_VISITED)); expected.add(new EventImpl(false, cache, null, null, fqn, tx, true, = null, false, null, NODE_VISITED)); --===============9117271387310427928==-- From jbosscache-commits at lists.jboss.org Fri Aug 29 10:21:27 2008 Content-Type: multipart/mixed; boundary="===============6614262869152280476==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6644 - core/trunk/src/test/java/org/jboss/cache/notifications. Date: Fri, 29 Aug 2008 10:21:27 -0400 Message-ID: --===============6614262869152280476== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mircea.markus Date: 2008-08-29 10:21:27 -0400 (Fri, 29 Aug 2008) New Revision: 6644 Modified: core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest= .java Log: test was designed for pessimistic + optimistic locking Modified: core/trunk/src/test/java/org/jboss/cache/notifications/CacheListe= nerTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTes= t.java 2008-08-29 14:10:18 UTC (rev 6643) +++ core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTes= t.java 2008-08-29 14:21:27 UTC (rev 6644) @@ -54,6 +54,7 @@ Configuration c =3D new Configuration(); c.setCacheMode(Configuration.CacheMode.LOCAL); c.setIsolationLevel(IsolationLevel.REPEATABLE_READ); + c.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC); if (optLocking) c.setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC= ); c.setTransactionManagerLookupClass("org.jboss.cache.transaction.Dumm= yTransactionManagerLookup"); --===============6614262869152280476==-- From jbosscache-commits at lists.jboss.org Fri Aug 29 11:26:10 2008 Content-Type: multipart/mixed; boundary="===============1254180642281191095==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6645 - in core/trunk/src/test/java/org/jboss/cache: util/internals and 1 other directory. Date: Fri, 29 Aug 2008 11:26:10 -0400 Message-ID: --===============1254180642281191095== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-29 11:26:10 -0400 (Fri, 29 Aug 2008) New Revision: 6645 Modified: core/trunk/src/test/java/org/jboss/cache/eviction/EvictionTestsBase.java core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTes= t.java core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionControll= er.java Log: Fixed eviction tests Modified: core/trunk/src/test/java/org/jboss/cache/eviction/EvictionTestsBa= se.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/EvictionTestsBase.jav= a 2008-08-29 14:21:27 UTC (rev 6644) +++ core/trunk/src/test/java/org/jboss/cache/eviction/EvictionTestsBase.jav= a 2008-08-29 15:26:10 UTC (rev 6645) @@ -55,4 +55,4 @@ signaller.waitForEvictionThreadCompletion(timeToWait, unit); return evicted; } -} +} \ No newline at end of file Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java 20= 08-08-29 14:21:27 UTC (rev 6644) +++ core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java 20= 08-08-29 15:26:10 UTC (rev 6645) @@ -10,6 +10,7 @@ import org.jboss.cache.config.EvictionRegionConfig; import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; import org.jboss.cache.lock.IsolationLevel; +import org.jboss.cache.util.CachePrinter; import org.jboss.cache.util.TestingUtil; import org.jboss.cache.util.internals.EvictionController; import org.jboss.cache.util.internals.EvictionWatcher; @@ -150,22 +151,50 @@ = System.out.println("REGIONS: " + cache.getRegionManager().dumpRegion= s()); = + final Fqn fqn7 =3D Fqn.fromString(rootStr + "7"); + for (int i =3D 0; i < 10; i++) { String str =3D rootStr + i; Fqn fqn =3D Fqn.fromString(str); cache.put(fqn, str, str); + + // playing favourites here: + cache.getNode(fqn7);// just to keep it fresh } = - String str =3D rootStr + "7"; - Fqn fqn =3D Fqn.fromString(str); - cache.get(fqn, str);// just to keep it fresh - cache.get(fqn, str);// just to keep it fresh + System.out.println("Cache: " + CachePrinter.printCacheDetails(cache)= ); + + Thread retrieverThread =3D new Thread() + { + @Override + public void run() + { + try + { + while (true) + { + cache.getNode(fqn7);// just to keep it fresh + sleep(50); + } + } + catch (Exception ie) + { + } + } + }; + + retrieverThread.setDaemon(true); + retrieverThread.start(); assert waitForEviction(cache, 30, TimeUnit.SECONDS, Fqn.fromString(r= ootStr + 3)); String val =3D (String) cache.get(rootStr + "3", rootStr + "3"); assertNull("Node should be empty ", val); - val =3D (String) cache.get(rootStr + "7", rootStr + "7"); + Node n =3D cache.getNode(fqn7); + assert n !=3D null; + val =3D (String) n.get(rootStr + "7"); assertNotNull("Node should not be empty ", val); + retrieverThread.interrupt(); + retrieverThread.join(); new EvictionController(cache).startEviction(true); assert waitForEviction(cache, 30, TimeUnit.SECONDS, Fqn.fromString(r= ootStr + 7)); val =3D (String) cache.get(rootStr + "7", rootStr + "7"); Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPo= licyTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTe= st.java 2008-08-29 14:21:27 UTC (rev 6644) +++ core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTe= st.java 2008-08-29 15:26:10 UTC (rev 6645) @@ -63,6 +63,12 @@ LRUAlgorithmConfig cfg =3D (LRUAlgorithmConfig) cache1.getConfigurat= ion().getEvictionConfig().getEvictionRegionConfig(rootStr).getEvictionAlgor= ithmConfig(); cfg.setMaxAge(0); cfg.setTimeToLive(0); + + cfg =3D (LRUAlgorithmConfig) cache3.getConfiguration().getEvictionCo= nfig().getEvictionRegionConfig(rootStr).getEvictionAlgorithmConfig(); + cfg.setMaxAge(-1, TimeUnit.SECONDS); + cfg.setTimeToLive(-1, TimeUnit.SECONDS); + cfg.setMaxNodes(200); + String str =3D rootStr + "0"; Fqn fqn =3D Fqn.fromString(str); cache1.put(str, str, str); Modified: core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionC= ontroller.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionControl= ler.java 2008-08-29 14:21:27 UTC (rev 6644) +++ core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionControl= ler.java 2008-08-29 15:26:10 UTC (rev 6645) @@ -45,7 +45,7 @@ { throw new IllegalStateException("No timer task!!!"); } - timerTask.stop(); + stopEvictionThread(); originalWakeupInterval =3D cache.getConfiguration().getEvictionConfi= g().getWakeupInterval(); } = @@ -154,6 +154,11 @@ return s; } = + public void stopEvictionThread() + { + timerTask.stop(); + } + public static class Signaller { Semaphore s =3D new Semaphore(1); --===============1254180642281191095==-- From jbosscache-commits at lists.jboss.org Fri Aug 29 12:16:29 2008 Content-Type: multipart/mixed; boundary="===============9091903234846606902==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6646 - core/trunk/src/test/java/org/jboss/cache/notifications. Date: Fri, 29 Aug 2008 12:16:29 -0400 Message-ID: --===============9091903234846606902== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-08-29 12:16:29 -0400 (Fri, 29 Aug 2008) New Revision: 6646 Modified: core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListen= erTest.java Log: Should use PL, not MVCC Modified: core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCach= eListenerTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListe= nerTest.java 2008-08-29 15:26:10 UTC (rev 6645) +++ core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListe= nerTest.java 2008-08-29 16:16:29 UTC (rev 6646) @@ -75,6 +75,8 @@ c.setIsolationLevel(IsolationLevel.REPEATABLE_READ); if (optLocking) c.setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC= ); + else + c.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTI= C); c.setTransactionManagerLookupClass("org.jboss.cache.transaction.Dumm= yTransactionManagerLookup"); = // we need this because notifications emitted by the notification in= terceptor are done during the commit call. --===============9091903234846606902==-- From jboss-qa-internal at redhat.com Fri Aug 29 15:27:40 2008 Content-Type: multipart/mixed; boundary="===============8756394759025977199==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_unstable=3A_jboss-cach?= =?utf-8?q?e-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_=23438?= Date: Fri, 29 Aug 2008 15:27:25 -0400 Message-ID: <494050212.28111220038045786.JavaMail.hudson@hudson1.qa.atl2.redhat.com> --===============8756394759025977199== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/438/changes --===============8756394759025977199==-- From jboss-qa-internal at redhat.com Sat Aug 30 07:23:03 2008 Content-Type: multipart/mixed; boundary="===============7210532328056708650==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_unstable=3A_jboss-cach?= =?utf-8?q?e-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_=23573?= Date: Sat, 30 Aug 2008 07:23:01 -0400 Message-ID: <39683962.29001220095381699.JavaMail.hudson@hudson1.qa.atl2.redhat.com> --===============7210532328056708650== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/573/changes --===============7210532328056708650==-- From jboss-qa-internal at redhat.com Sun Aug 31 13:03:02 2008 Content-Type: multipart/mixed; boundary="===============0890459654366761685==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_completed=3A_jboss-cache-?= =?utf-8?q?core-2=2E1=2EX-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_=2347?= Date: Sun, 31 Aug 2008 13:03:00 -0400 Message-ID: <828350329.30601220202180766.JavaMail.hudson@hudson1.qa.atl2.redhat.com> --===============0890459654366761685== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-2.1.X-jdk1.6/org= .jboss.cache$jbosscache-core/47/changes --===============0890459654366761685==-- From jboss-qa-internal at redhat.com Sun Aug 31 13:19:50 2008 Content-Type: multipart/mixed; boundary="===============0183524619718310426==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E6_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23439?= Date: Sun, 31 Aug 2008 13:19:27 -0400 Message-ID: <1448863602.30611220203167164.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 494050212.28111220038045786.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============0183524619718310426== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.6/org= .jboss.cache$jbosscache-core/439/changes --===============0183524619718310426==-- From jboss-qa-internal at redhat.com Sun Aug 31 15:35:21 2008 Content-Type: multipart/mixed; boundary="===============7413852739628551382==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_is_still_unstable=3A_jbos?= =?utf-8?q?s-cache-core-trunk-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_?= =?utf-8?q?=23574?= Date: Sun, 31 Aug 2008 15:35:19 -0400 Message-ID: <608757721.30781220211319696.JavaMail.hudson@hudson1.qa.atl2.redhat.com> In-Reply-To: 39683962.29001220095381699.JavaMail.hudson@hudson1.qa.atl2.redhat.com --===============7413852739628551382== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-trunk-jdk1.5/org= .jboss.cache$jbosscache-core/574/changes --===============7413852739628551382==-- From jboss-qa-internal at redhat.com Sun Aug 31 15:51:01 2008 Content-Type: multipart/mixed; boundary="===============9218744489485874406==" MIME-Version: 1.0 From: jboss-qa-internal at redhat.com To: jbosscache-commits at lists.jboss.org Subject: =?utf-8?q?=5Bjbosscache-commits=5D_Hudson_build_completed=3A_jboss-cache-?= =?utf-8?q?core-2=2E1=2EX-jdk1=2E5_=C2=BB_JBoss_Cache_-_Core_Edition_=2348?= Date: Sun, 31 Aug 2008 15:50:46 -0400 Message-ID: <439850593.30821220212246359.JavaMail.hudson@hudson1.qa.atl2.redhat.com> --===============9218744489485874406== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable See http://hudson.qa.jboss.com/hudson/job/jboss-cache-core-2.1.X-jdk1.5/org= .jboss.cache$jbosscache-core/48/changes --===============9218744489485874406==--