[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/loader ...

Galder Zamarreno galder.zamarreno at jboss.com
Fri Sep 29 14:27:21 EDT 2006


  User: gzamarreno
  Date: 06/09/29 14:27:21

  Modified:    tests/functional/org/jboss/cache/loader  
                        CacheLoaderManagerTest.java
  Added:       tests/functional/org/jboss/cache/loader  
                        SingletonStoreCacheLoaderTest.java
  Log:
  [JBCACHE-650] - SharedStoreCacheLoader refactored to SingletonStoreCacheLoader 
  adding the ability to push the in-memory state to the underlying cache loader when 
  assuming the coordinator role. Created AbstractDelegatingCacheLoader class that 
  contains basic delegating functionality. SingletonStoreCacheLoader and 
  AsyncCacheLoader now extend this class. Necessary configuration options added 
  and documentation has been updated to include explanation. Two singleton cache 
  sample configurations added too.
  
  Revision  Changes    Path
  1.11      +193 -0    JBossCache/tests/functional/org/jboss/cache/loader/CacheLoaderManagerTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheLoaderManagerTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/loader/CacheLoaderManagerTest.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -b -r1.10 -r1.11
  --- CacheLoaderManagerTest.java	19 Jul 2006 08:29:19 -0000	1.10
  +++ CacheLoaderManagerTest.java	29 Sep 2006 18:27:21 -0000	1.11
  @@ -11,6 +11,8 @@
   import junit.framework.TestSuite;
   import org.jboss.cache.config.CacheLoaderConfig;
   import org.jboss.cache.xml.XmlHelper;
  +import org.jboss.cache.CacheSPI;
  +import org.jboss.cache.CacheListener;
   import org.w3c.dom.Element;
   
   import java.util.List;
  @@ -440,6 +442,197 @@
   
   
       }
  +
  +   public void testSingletonConfiguration() throws Exception
  +   {
  +       String conf = "<config>" +
  +              "<passivation>false</passivation>" +
  +              "<preload>/, /blah, /blah2</preload>" +
  +              "<cacheloader>" +
  +              "    <class>org.jboss.cache.loader.FileCacheLoader</class>" +
  +              "    <async>false</async>" +
  +              "    <fetchPersistentState>false</fetchPersistentState>" +
  +              "    <ignoreModifications>true</ignoreModifications>" +
  +              "    <properties>" +
  +              "        location=" + getTempDir() +
  +              "    </properties>" +
  +              "</cacheloader>" +
  +              "</config>";
  +
  +       CacheLoaderManager mgr = new CacheLoaderManager();
  +       mgr.setConfig(strToElement(conf), null);
  +
  +       CacheLoaderConfig.IndividualCacheLoaderConfig iclc = mgr.getCacheLoaderConfig().getFirstCacheLoaderConfig();
  +       assertFalse("Singleton has not been configured", iclc.isSingletonStore());
  +       assertFalse("Singleton.pushStateWhenCoordinator has not been configured", iclc.isPushStateWhenCoordinator());
  +
  +       conf = "<config>" +
  +              "<passivation>false</passivation>" +
  +              "<preload>/, /blah, /blah2</preload>" +
  +              "<cacheloader>" +
  +              "    <class>org.jboss.cache.loader.FileCacheLoader</class>" +
  +              "    <async>false</async>" +
  +              "    <fetchPersistentState>false</fetchPersistentState>" +
  +              "    <ignoreModifications>true</ignoreModifications>" +
  +              "    <properties>" +
  +              "        location=" + getTempDir() +
  +              "    </properties>" +
  +              "    <singletonStore>true</singletonStore>" +
  +              "</cacheloader>" +
  +              "</config>";
  +
  +       mgr = new MockCacheLoaderManager();
  +       mgr.setConfig(strToElement(conf), null);
  +
  +       iclc = mgr.getCacheLoaderConfig().getFirstCacheLoaderConfig();
  +       assertTrue("Singleton has been configured", iclc.isSingletonStore());
  +       assertFalse("Singleton.pushStateWhenCoordinator has not been configured", iclc.isPushStateWhenCoordinator());
  +
  +       conf = "<config>" +
  +              "<passivation>false</passivation>" +
  +              "<preload>/, /blah, /blah2</preload>" +
  +              "<cacheloader>" +
  +              "    <class>org.jboss.cache.loader.FileCacheLoader</class>" +
  +              "    <async>false</async>" +
  +              "    <fetchPersistentState>false</fetchPersistentState>" +
  +              "    <ignoreModifications>true</ignoreModifications>" +
  +              "    <properties>" +
  +              "        location=" + getTempDir() +
  +              "    </properties>" +
  +              "    <singletonStore>false</singletonStore>" +
  +              "</cacheloader>" +
  +              "</config>";
  +
  +       mgr = new CacheLoaderManager();
  +       mgr.setConfig(strToElement(conf), null);
  +
  +       iclc = mgr.getCacheLoaderConfig().getFirstCacheLoaderConfig();
  +       assertFalse("Singleton has not been configured", iclc.isSingletonStore());
  +       assertFalse("Singleton.pushStateWhenCoordinator has not been configured", iclc.isPushStateWhenCoordinator());
  +
  +       conf = "<config>" +
  +              "<passivation>false</passivation>" +
  +              "<preload>/, /blah, /blah2</preload>" +
  +              "<cacheloader>" +
  +              "    <class>org.jboss.cache.loader.FileCacheLoader</class>" +
  +              "    <async>false</async>" +
  +              "    <fetchPersistentState>false</fetchPersistentState>" +
  +              "    <ignoreModifications>true</ignoreModifications>" +
  +              "    <properties>" +
  +              "        location=" + getTempDir() +
  +              "    </properties>" +
  +              "    <singletonStore pushStateWhenCoordinator=\"false\">true</singletonStore>" +
  +              "</cacheloader>" +
  +              "</config>";
  +
  +       mgr = new MockCacheLoaderManager();
  +       mgr.setConfig(strToElement(conf), null);
  +
  +       iclc = mgr.getCacheLoaderConfig().getFirstCacheLoaderConfig();
  +       assertTrue("Singleton has been configured", iclc.isSingletonStore());
  +       assertFalse("Singleton.pushStateWhenCoordinator has not been configured", iclc.isPushStateWhenCoordinator());
  +
  +       conf = "<config>" +
  +              "<passivation>false</passivation>" +
  +              "<preload>/, /blah, /blah2</preload>" +
  +              "<cacheloader>" +
  +              "    <class>org.jboss.cache.loader.FileCacheLoader</class>" +
  +              "    <async>false</async>" +
  +              "    <fetchPersistentState>false</fetchPersistentState>" +
  +              "    <ignoreModifications>true</ignoreModifications>" +
  +              "    <properties>" +
  +              "        location=" + getTempDir() +
  +              "    </properties>" +
  +              "    <singletonStore pushStateWhenCoordinator=\"false\">false</singletonStore>" +
  +              "</cacheloader>" +
  +              "</config>";
  +
  +       mgr = new CacheLoaderManager();
  +       mgr.setConfig(strToElement(conf), null);
  +
  +       iclc = mgr.getCacheLoaderConfig().getFirstCacheLoaderConfig();
  +       assertFalse("Singleton has not been configured", iclc.isSingletonStore());
  +       assertFalse("Singleton.pushStateWhenCoordinator has not been configured", iclc.isPushStateWhenCoordinator());
  +
  +       conf = "<config>" +
  +              "<passivation>false</passivation>" +
  +              "<preload>/, /blah, /blah2</preload>" +
  +              "<cacheloader>" +
  +              "    <class>org.jboss.cache.loader.FileCacheLoader</class>" +
  +              "    <async>false</async>" +
  +              "    <fetchPersistentState>false</fetchPersistentState>" +
  +              "    <ignoreModifications>true</ignoreModifications>" +
  +              "    <properties>" +
  +              "        location=" + getTempDir() +
  +              "    </properties>" +
  +              "    <singletonStore pushStateWhenCoordinator=\"true\">false</singletonStore>" +
  +              "</cacheloader>" +
  +              "</config>";
  +
  +       mgr = new CacheLoaderManager();
  +       mgr.setConfig(strToElement(conf), null);
  +
  +       iclc = mgr.getCacheLoaderConfig().getFirstCacheLoaderConfig();
  +       assertFalse("Singleton has not been configured", iclc.isSingletonStore());
  +       assertFalse("Singleton.pushStateWhenCoordinator should be false has not been configured", iclc.isPushStateWhenCoordinator());
  +
  +       conf = "<config>" +
  +              "<passivation>false</passivation>" +
  +              "<preload>/, /blah, /blah2</preload>" +
  +              "<cacheloader>" +
  +              "    <class>org.jboss.cache.loader.FileCacheLoader</class>" +
  +              "    <async>false</async>" +
  +              "    <fetchPersistentState>false</fetchPersistentState>" +
  +              "    <ignoreModifications>true</ignoreModifications>" +
  +              "    <properties>" +
  +              "        location=" + getTempDir() +
  +              "    </properties>" +
  +              "    <singletonStore pushStateWhenCoordinator=\"true\">true</singletonStore>" +
  +              "</cacheloader>" +
  +              "</config>";
  +
  +       mgr = new MockCacheLoaderManager();
  +       mgr.setConfig(strToElement(conf), null);
  +
  +       iclc = mgr.getCacheLoaderConfig().getFirstCacheLoaderConfig();
  +       assertTrue("Singleton has been configured", iclc.isSingletonStore());
  +       assertTrue("Singleton.pushStateWhenCoordinator has been configured", iclc.isPushStateWhenCoordinator());
  +
  +       conf = "<config>" +
  +              "<passivation>false</passivation>" +
  +              "<shared>true</shared>" +
  +              "<preload>/, /blah, /blah2</preload>" +
  +              "<cacheloader>" +
  +              "    <class>org.jboss.cache.loader.FileCacheLoader</class>" +
  +              "    <async>false</async>" +
  +              "    <fetchPersistentState>false</fetchPersistentState>" +
  +              "    <ignoreModifications>true</ignoreModifications>" +
  +              "    <properties>" +
  +              "        location=" + getTempDir() +
  +              "    </properties>" +
  +              "    <singletonStore pushStateWhenCoordinator=\"true\">true</singletonStore>" +
  +              "</cacheloader>" +
  +              "</config>";
  +
  +       mgr = new CacheLoaderManager();
  +       try
  +       {
  +          mgr.setConfig(strToElement(conf), null);
  +          fail("A cache loader cannot be configured as singleton and shared, should have thrown an Exception");
  +       }
  +       catch (Exception e)
  +       {
  +       }
  +    }
  +
  +    private class MockCacheLoaderManager extends CacheLoaderManager
  +    {
  +       protected void addCacheListener(CacheSPI cache, CacheListener listener)
  +       {
  +          /* do nothing... */
  +       }
  +    }
  +
       public static Test suite()
       {
           return new TestSuite(CacheLoaderManagerTest.class);
  
  
  
  1.1      date: 2006/09/29 18:27:21;  author: gzamarreno;  state: Exp;JBossCache/tests/functional/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java
  
  Index: SingletonStoreCacheLoaderTest.java
  ===================================================================
  /*
   * JBoss, the OpenSource J2EE webOS
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  package org.jboss.cache.loader;
  
  import org.jboss.cache.CacheSPI;
  import org.jboss.cache.Fqn;
  import org.jboss.cache.NodeImpl;
  import org.jboss.cache.TreeCache;
  import org.jboss.cache.TreeCacheProxyImpl;
  import org.jboss.cache.config.Configuration;
  import org.jboss.cache.xml.XmlHelper;
  import org.w3c.dom.Element;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /**
   * Unit test class for SingletonStoreCacheLoader
   *
   * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
   */
  public class SingletonStoreCacheLoaderTest extends AbstractCacheLoaderTestBase
  {
     private CacheSPI cache1, cache2, cache3;
     private static final Log log = LogFactory.getLog(SingletonStoreCacheLoaderTest.class);
  
     protected void setUp() throws Exception
     {
        log.info("*** test:" + getName() + " ***");
  
        TreeCache tc1 = new TreeCache();
        TreeCache tc2 = new TreeCache();
        TreeCache tc3 = new TreeCache();
  
        cache1 = new TreeCacheProxyImpl(tc1, (NodeImpl) tc1.getRoot());
        cache2 = new TreeCacheProxyImpl(tc2, (NodeImpl) tc2.getRoot());
        cache3 = new TreeCacheProxyImpl(tc3, (NodeImpl) tc3.getRoot());
  
        cache1.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
        cache2.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
        cache3.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
     }
  
     public void testPutCacheLoaderWithNoPush() throws Exception
     {
        initSingletonNonPushCache(cache1);
        initSingletonNonPushCache(cache2);
        initSingletonNonPushCache(cache3);
  
        createCaches();
        statCaches();
  
        cache1.put(fqn("/test1"), "key", "value");
        cache2.put(fqn("/test2"), "key", "value");
        cache3.put(fqn("/test3"), "key", "value");
  
        CacheLoader cl1 = getDelegatingCacheLoader(cache1);
        CacheLoader cl2 = getDelegatingCacheLoader(cache2);
        CacheLoader cl3 = getDelegatingCacheLoader(cache3);
  
        assertTrue("/test1 should have been entered in cl1", cl1.exists(fqn("/test1")));
        assertTrue("/test2 should have been entered in cl1", cl1.exists(fqn("/test2")));
        assertTrue("/test3 should have been entered in cl1", cl1.exists(fqn("/test3")));
  
        assertFalse("/test1 should not be in cl2", cl2.exists(fqn("/test1")));
        assertFalse("/test2 should not be in cl2", cl2.exists(fqn("/test2")));
        assertFalse("/test3 should not be in cl2", cl2.exists(fqn("/test3")));
  
        assertFalse("/test1 should not be in cl3", cl3.exists(fqn("/test1")));
        assertFalse("/test2 should not be in cl3", cl3.exists(fqn("/test2")));
        assertFalse("/test3 should not be in cl3", cl3.exists(fqn("/test3")));
  
        stopCache1();
  
        cache2.put(fqn("/test4"), "key", "value");
        cache3.put(fqn("/test5"), "key", "value");
  
        assertTrue("/test4 should have been entered in cl2", cl2.exists(fqn("/test4")));
        assertTrue("/test5 should have been entered in cl2", cl2.exists(fqn("/test5")));
  
        assertFalse("/test4 should not be in cl3", cl3.exists(fqn("/test4")));
        assertFalse("/test5 should not be in cl3", cl3.exists(fqn("/test5")));
  
        stopCache2();
  
        cache3.put(fqn("/test6"), "key", "value");
        assertTrue("/test5 should have been entered in cl3", cl3.exists(Fqn.fromString("/test6")));
     }
  
     public void testPutCacheLoaderWithPush() throws Exception
     {
        initSingletonWithPushCache(cache1);
        initSingletonWithPushCache(cache2);
        initSingletonWithPushCache(cache3);
  
        createCaches();
        statCaches();
  
        cache1.put(fqn("/a"), "a-key", "a-value");
        cache1.put(fqn("/a"), "aa-key", "aa-value");
        cache1.put(fqn("/a/b"), "b-key", "b-value");
        cache1.put(fqn("/a/b"), "bb-key", "bb-value");
        cache1.put(fqn("/a/b/c"), "c-key", "c-value");
        cache1.put(fqn("/a/b/d"), "d-key", "d-value");
        cache1.put(fqn("/e"), "e-key", "e-value");
        cache1.put(fqn("/e/f/g"), "g-key", "g-value");
  
        CacheLoader cl1 = getDelegatingCacheLoader(cache1);
        CacheLoader cl2 = getDelegatingCacheLoader(cache2);
        CacheLoader cl3 = getDelegatingCacheLoader(cache3);
  
        assertTrue(cl1.get(fqn("/a")).containsKey("a-key"));
        assertTrue(cl1.get(fqn("/a")).containsKey("aa-key"));
        assertTrue(cl1.get(fqn("/a/b")).containsKey("b-key"));
        assertTrue(cl1.get(fqn("/a/b")).containsKey("bb-key"));
        assertTrue(cl1.get(fqn("/a/b/c")).containsKey("c-key"));
        assertTrue(cl1.get(fqn("/a/b/d")).containsKey("d-key"));
        assertTrue(cl1.get(fqn("/e")).containsKey("e-key"));
        assertTrue(cl1.get(fqn("/e/f/g")).containsKey("g-key"));
  
        assertFalse(cl2.exists(fqn("/a")));
        assertFalse(cl2.exists(fqn("/a")));
        assertFalse(cl2.exists(fqn("/a/b")));
        assertFalse(cl2.exists(fqn("/a/b")));
        assertFalse(cl2.exists(fqn("/a/b/c")));
        assertFalse(cl2.exists(fqn("/a/b/d")));
        assertFalse(cl2.exists(fqn("/e")));
        assertFalse(cl2.exists(fqn("/e/f/g")));
  
        assertFalse(cl3.exists(fqn("/a")));
        assertFalse(cl3.exists(fqn("/a")));
        assertFalse(cl3.exists(fqn("/a/b")));
        assertFalse(cl3.exists(fqn("/a/b")));
        assertFalse(cl3.exists(fqn("/a/b/c")));
        assertFalse(cl3.exists(fqn("/a/b/d")));
        assertFalse(cl3.exists(fqn("/e")));
        assertFalse(cl3.exists(fqn("/e/f/g")));
  
        stopCache1();
        Thread.sleep(1000);
  
        SingletonStoreCacheLoader scl2 = (SingletonStoreCacheLoader) cache2.getCacheLoader();
        joinPushThread(scl2.getPushStateThread());
  
        assertTrue(cl2.get(fqn("/a")).containsKey("a-key"));
        assertTrue(cl2.get(fqn("/a")).containsKey("aa-key"));
        assertTrue(cl2.get(fqn("/a/b")).containsKey("b-key"));
        assertTrue(cl2.get(fqn("/a/b")).containsKey("bb-key"));
        assertTrue(cl2.get(fqn("/a/b/c")).containsKey("c-key"));
        assertTrue(cl2.get(fqn("/a/b/d")).containsKey("d-key"));
        assertTrue(cl2.get(fqn("/e")).containsKey("e-key"));
        assertTrue(cl2.get(fqn("/e/f/g")).containsKey("g-key"));
  
        cache2.put(fqn("/e/f/h"), "h-key", "h-value");
        cache3.put(fqn("/i"), "i-key", "i-value");
  
        assertTrue(cl2.get(fqn("/e/f/h")).containsKey("h-key"));
        assertTrue(cl2.get(fqn("/i")).containsKey("i-key"));
  
        assertFalse(cl3.exists(fqn("/a")));
        assertFalse(cl3.exists(fqn("/a")));
        assertFalse(cl3.exists(fqn("/a/b")));
        assertFalse(cl3.exists(fqn("/a/b")));
        assertFalse(cl3.exists(fqn("/a/b/c")));
        assertFalse(cl3.exists(fqn("/a/b/d")));
        assertFalse(cl3.exists(fqn("/e")));
        assertFalse(cl3.exists(fqn("/e/f/g")));
        assertFalse(cl3.exists(fqn("/e/f/h")));
        assertFalse(cl3.exists(fqn("/i")));
  
        stopCache2();
        Thread.sleep(1000);
  
        SingletonStoreCacheLoader scl3 = (SingletonStoreCacheLoader) cache3.getCacheLoader();
        joinPushThread(scl3.getPushStateThread());
  
        assertTrue(cl3.get(fqn("/a")).containsKey("a-key"));
        assertTrue(cl3.get(fqn("/a")).containsKey("aa-key"));
        assertTrue(cl3.get(fqn("/a/b")).containsKey("b-key"));
        assertTrue(cl3.get(fqn("/a/b")).containsKey("bb-key"));
        assertTrue(cl3.get(fqn("/a/b/c")).containsKey("c-key"));
        assertTrue(cl3.get(fqn("/a/b/d")).containsKey("d-key"));
        assertTrue(cl3.get(fqn("/e")).containsKey("e-key"));
        assertTrue(cl3.get(fqn("/e/f/g")).containsKey("g-key"));
        assertTrue(cl3.get(fqn("/e/f/h")).containsKey("h-key"));
        assertTrue(cl3.get(fqn("/i")).containsKey("i-key"));
  
        cache3.put(fqn("/a"), "aaa-key", "aaa-value");
  
        assertTrue(cl3.get(fqn("/a")).containsKey("aaa-key"));
  
        stopCache3();
     }
  
     public void testAvoidConcurrentStatePush() throws InterruptedException
     {
        MockSingletonStoreCacheLoader mscl = new MockSingletonStoreCacheLoader(null, true, 3000);
  
        Thread t1 = new Thread(createActiveStatusChanger(mscl));
        Thread t2 = new Thread(createActiveStatusChanger(mscl));
  
        t1.start();
        Thread.sleep(1000);
        t2.start();
  
        t1.join();
        t2.join();
  
        assertEquals(1, mscl.getNumberCreatedThreads());
     }
  
     private void createCaches() throws Exception
     {
        cache1.create();
        cache2.create();
        cache3.create();
     }
  
     private void statCaches() throws Exception
     {
        cache1.start();
        cache2.start();
        cache3.start();
     }
  
     private void joinPushThread(Thread pushThread) throws InterruptedException
     {
        if (pushThread != null)
        {
           pushThread.join();
        }
     }
  
     private Runnable createActiveStatusChanger(SingletonStoreCacheLoader mscl)
     {
        return new ActiveStatusModifier(mscl);
     }
  
     protected Element getSingletonStoreCacheLoaderConfig(String cacheloaderClass, boolean singleton,
                                                          boolean pushStateWhenCoordinator) throws Exception
     {
        String xml = "<config>\n" +
              "<passivation>false</passivation>\n" +
              "<preload></preload>\n" +
              "<cacheloader>\n" +
              "<class>" + cacheloaderClass + "</class>\n" +
              "<properties></properties>\n" +
              // "<async>false</async>\n" +
              // "<shared>false</shared>\n" +
              // "<fetchPersistentState>false</fetchPersistentState>\n" +
              // "<purgeOnStartup>false</purgeOnStartup>\n" +
              "<singletonStore pushStateWhenCoordinator=\"" + pushStateWhenCoordinator + "\">" + singleton + "</singletonStore>\n" +
              "</cacheloader>\n" +
              "</config>";
        return XmlHelper.stringToElement(xml);
     }
  
     private void initSingletonNonPushCache(CacheSPI cache) throws Exception
     {
        cache.getConfiguration().setCacheLoaderConfiguration(getSingletonStoreCacheLoaderConfig(
              DummyInMemoryCacheLoader.class.getName(), true, false));
     }
  
     private void initSingletonWithPushCache(CacheSPI cache) throws Exception
     {
        cache.getConfiguration().setCacheLoaderConfiguration(getSingletonStoreCacheLoaderConfig(
              DummyInMemoryCacheLoader.class.getName(), true, true));
     }
  
     private CacheLoader getDelegatingCacheLoader(CacheSPI cache)
     {
        AbstractDelegatingCacheLoader acl = (AbstractDelegatingCacheLoader) cache.getCacheLoader();
        return acl.getCacheLoader();
     }
  
     private Fqn fqn(String fqn)
     {
        return Fqn.fromString(fqn);
     }
  
     private void stopCache1()
     {
        if (cache1 != null)
        {
           cache1.stop();
        }
  
        cache1 = null;
     }
  
     private void stopCache2()
     {
        if (cache2 != null)
        {
           cache2.stop();
        }
  
        cache2 = null;
     }
  
     private void stopCache3()
     {
        if (cache3 != null)
        {
           cache3.stop();
        }
  
        cache3 = null;
     }
  
     protected void tearDown()
     {
        stopCache1();
        stopCache2();
        stopCache3();
     }
  
     class MockSingletonStoreCacheLoader extends SingletonStoreCacheLoader
     {
        private int numberCreatedThreads = 0;
        private long busyPeriod;
  
        public MockSingletonStoreCacheLoader(CacheLoader loader, boolean pushConfiguration, long busyPeriodTime)
        {
           super(loader, pushConfiguration);
           busyPeriod = busyPeriodTime;
        }
  
        public int getNumberCreatedThreads()
        {
           return numberCreatedThreads;
        }
  
        public void setNumberCreatedThreads(int numberCreatedThreads)
        {
           this.numberCreatedThreads = numberCreatedThreads;
        }
  
        protected Thread createPushStateThread()
        {
           return new Thread(new Runnable()
           {
              public void run()
              {
                 numberCreatedThreads++;
                 try
                 {
                    Thread.sleep(busyPeriod);
                 }
                 catch (InterruptedException e)
                 {
                    fail("ActiveStatusModifier interrupted");
                 }
              }
           });
        }
     }
  
     class ActiveStatusModifier implements Runnable
     {
        private SingletonStoreCacheLoader scl;
  
        public ActiveStatusModifier(SingletonStoreCacheLoader singleton)
        {
           scl = singleton;
        }
  
        public void run()
        {
           scl.activeStatusChanged(true);
           try
           {
              scl.getPushStateThread().join();
           } catch (InterruptedException e)
           {
              throw new RuntimeException(e);
           }
        }
     }
  }
  
  
  



More information about the jboss-cvs-commits mailing list