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

Manik Surtani msurtani at jboss.com
Wed Sep 6 11:30:56 EDT 2006


  User: msurtani
  Date: 06/09/06 11:30:56

  Modified:    tests/functional/org/jboss/cache/aop/statetransfer 
                        StateTransferAopTestBase.java
  Log:
  Removed TreeCache dependency on ServiceMBeanSupport
  
  Revision  Changes    Path
  1.17      +130 -117  JBossCache/tests/functional/org/jboss/cache/aop/statetransfer/StateTransferAopTestBase.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: StateTransferAopTestBase.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/aop/statetransfer/StateTransferAopTestBase.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -b -r1.16 -r1.17
  --- StateTransferAopTestBase.java	20 Jul 2006 06:04:56 -0000	1.16
  +++ StateTransferAopTestBase.java	6 Sep 2006 15:30:56 -0000	1.17
  @@ -60,7 +60,7 @@
      public static final Integer TWENTYFIVE = new Integer(25);
      public static final Integer FORTY = new Integer(40);
   
  -   private Log log=LogFactory.getLog(StateTransferAopTestBase.class);
  +   private Log log = LogFactory.getLog(StateTransferAopTestBase.class);
   
      public void testInitialStateTransfer() throws Exception
      {
  @@ -189,7 +189,8 @@
         ab1  = (Person) cache1.getObject(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.getAddress().getCity());
  -      ab2 = (Person) cache1.getObject(A_B_2);;
  +      ab2 = (Person) cache1.getObject(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.getAddress().getCity());
         assertTrue("Address for Joe and Jane is the same object", ab1.getAddress() == ab2.getAddress());
  @@ -285,7 +286,8 @@
         ab1  = (Person) cache1.getObject(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.getAddress().getCity());
  -      ab2 = (Person) cache1.getObject(A_B_2);;
  +      ab2 = (Person) cache1.getObject(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.getAddress().getCity());
         assertTrue("Address for Joe and Jane is the same object", ab1.getAddress() == ab2.getAddress());
  @@ -299,7 +301,6 @@
      }
   
   
  -
      /**
       * 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 
  @@ -334,7 +335,7 @@
       * As soon as each cache has activated its region, it does a put to a node
       * in the region, thus complicating the lives of the other caches trying
       * to get partial state.
  -    * <p>
  +    * <p/>
       * Failure condition is if any node sees an exception or if the final state
       * of all caches is not consistent.
       * 
  @@ -343,21 +344,24 @@
       */
      private void concurrentActivationTest(boolean sync) throws Exception
      {
  -      String[] names = { "A", "B", "C", "D", "E" };
  +      String[] names = {"A", "B", "C", "D", "E"};
         int count = names.length;
         CacheActivator[] activators = new CacheActivator[count];
   
   
  -      try {
  +      try
  +      {
            // Create a semaphore and take all its tickets
            Semaphore semaphore = new Semaphore(count);
  -         for (int i = 0; i < count; i++) {
  +         for (int i = 0; i < count; i++)
  +         {
               semaphore.acquire();
            }
   
            // Create activation threads that will block on the semaphore
            TreeCache[] caches = new TreeCache[count];
  -         for (int i = 0; i < count; i++) {
  +         for (int i = 0; i < count; i++)
  +         {
               activators[i] = new CacheActivator(semaphore, names[i], sync);
               caches[i] = activators[i].getTreeCache();
               activators[i].start();
  @@ -374,7 +378,8 @@
   
            // Reacquire the semaphore tickets; when we have them all
            // we know the threads are done         
  -         for (int i = 0; i < count; i++) {
  +         for (int i = 0; i < count; i++)
  +         {
               boolean acquired = semaphore.attempt(60000);
               if (!acquired)
                  fail("failed to acquire semaphore " + i);
  @@ -404,15 +409,18 @@
   
            }
         }
  -      catch (Exception ex) {
  +      catch (Exception ex)
  +      {
            fail(ex.getLocalizedMessage());
         }
  -      finally {
  +      finally
  +      {
            for (int i = 0; i < count; i++)
               activators[i].cleanup();
         }
   
      }
  +
      /**
       * Tests partial state transfer under heavy concurrent load and REPL_SYNC.
       * See <code>concurrentUseTest</code> for details.
  @@ -447,16 +455,16 @@
       * that each node has consistent state.
       * 
       * @param sync whether to use REPL_SYNC or REPL_ASYNCE
  -    * 
       * @throws Exception
       */
      private void concurrentUseTest(boolean sync) throws Exception
      {
  -      String[] names = { "B", "C", "D", "E" };
  +      String[] names = {"B", "C", "D", "E"};
         int count = names.length;
         CacheStressor[] stressors = new CacheStressor[count];
   
  -      try {
  +      try
  +      {
   
            PojoCache cacheA = createCache("cacheA", sync, true, false, false);
   
  @@ -465,7 +473,8 @@
   
            // Create a semaphore and take all its tickets
            Semaphore semaphore = new Semaphore(count);
  -         for (int i = 0; i < count; i++) {
  +         for (int i = 0; i < count; i++)
  +         {
               semaphore.acquire();
            }
   
  @@ -554,7 +563,7 @@
                  for (int j = 0; j < SUBTREE_SIZE; j++)
                  {
   
  -                  String fqn = "/" + names[i] +"/" + j;
  +                  String fqn = "/" + names[i] + "/" + j;
                     log.info("TEST: Getting A:" + fqn);
                     p1 = (Person) cacheA.getObject(fqn);
                     boolean p1Null = p1 == null;
  @@ -581,7 +590,8 @@
               stressors[i].stopThread();
   
         }
  -      finally {
  +      finally
  +      {
            for (int i = 0; i < count; i++)
            {
               if (stressors[i] != null)
  @@ -609,7 +619,7 @@
         PojoCache tree = new PojoCache();
   
         XmlConfigurationParser parser = new XmlConfigurationParser();
  -      Configuration c = parser.parseFile( sync ? "META-INF/replSync-service.xml" : "META-INF/replAsync-service.xml");
  +      Configuration c = parser.parseFile(sync ? "META-INF/replSync-service.xml" : "META-INF/replAsync-service.xml");
         c.setClusterName("StateTransferTestBase");
         c.setReplVersionString(getReplicationVersion());
         // Use a long timeout to facilitate setting debugger breakpoints
  @@ -628,8 +638,8 @@
         // start it can still be destroyed later
         caches.put(cacheID, tree);
   
  -      tree.createService();
  -      tree.startService();
  +      tree.create();
  +      tree.start();
   
         return tree;
      }
  @@ -661,7 +671,7 @@
                   "                <preload></preload>\n" +
                   "\n" +
                   "                <cacheloader>\n" +
  -                "                    <class>"+cl+"</class>\n" +
  +              "                    <class>" + cl + "</class>\n" +
                   "                    <properties>\n" +
                   "                        location=" + loc + "\n" +
                   "                    </properties>\n" +
  @@ -774,8 +784,8 @@
         {
            try
            {
  -            cache.stopService();
  -            cache.destroyService();
  +            cache.stop();
  +            cache.destroy();
            }
            catch (Exception e)
            {
  @@ -912,14 +922,15 @@
   
                  int lastIndex = -1;
                  int index = -1;
  -               while(!putsStopped)
  +               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 expose it
  -                  while (index % 2 == lastIndex % 2) {
  +                  while (index % 2 == lastIndex % 2)
  +                  {
                        factor = random.nextInt(50);
                        index = factor % SUBTREE_SIZE;
                     }
  @@ -928,21 +939,24 @@
   
                     TestingUtil.sleepThread(factor);
   
  -                  fqn = "/" + name +"/" + String.valueOf(index);
  +                  fqn = "/" + name + "/" + String.valueOf(index);
   
   //                  tm.begin();
   //                  try
   //                  {
  -                     if (loaded[index] == false) {
  +                  if (loaded[index] == false)
  +                  {
                           cache.putObject(fqn, people[index]);
                           loaded[index] = true;
                           log.info("TEST: " + name + " put Person at " + fqn);
                        }
  -                     else if (i % 2 == 0){
  +                  else if (i % 2 == 0)
  +                  {
                           int newAge = factor / SUBTREE_SIZE;
                           people[index].setAge(newAge);
                        }
  -                     else {
  +                  else
  +                  {
                           people[index].getAddress().setStreet(factor + " Test Street");
                        }
   //                  }
  @@ -959,7 +973,7 @@
                     i++;
                  }
   
  -               log.info("TEST: " + name + ": last put [#"+ i + "] -- " + fqn + " = " + (factor / SUBTREE_SIZE));
  +               log.info("TEST: " + name + ": last put [#" + i + "] -- " + fqn + " = " + (factor / SUBTREE_SIZE));
   
                  semaphore.release();
                  acquired = false;
  @@ -969,14 +983,13 @@
                     TestingUtil.sleepThread(100);
               }
            }
  -         finally {
  +         finally
  +         {
               if (acquired)
                  semaphore.release();
            }
         }
   
  -
  -
   //      public void start() throws Exception
   //      {
   //         super.start();
  
  
  



More information about the jboss-cvs-commits mailing list