[jbosscache-commits] JBoss Cache SVN: r7148 - in core/trunk/src: test/java/org/jboss/cache/buddyreplication and 1 other directories.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Mon Nov 17 13:08:06 EST 2008
Author: mircea.markus
Date: 2008-11-17 13:08:06 -0500 (Mon, 17 Nov 2008)
New Revision: 7148
Modified:
core/trunk/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyPoolBroadcastTest.java
core/trunk/src/test/resources/unit-test-cache-service.xml
Log:
fix tests
Modified: core/trunk/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.java 2008-11-17 16:07:21 UTC (rev 7147)
+++ core/trunk/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.java 2008-11-17 18:08:06 UTC (rev 7148)
@@ -29,9 +29,7 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.ComponentRegistry;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
+import javax.management.*;
import java.lang.management.ManagementFactory;
import java.util.ArrayList;
import java.util.List;
@@ -135,7 +133,14 @@
ObjectName objectName = new ObjectName(getObjectName(resourceName));
if (!mBeanServer.isRegistered(objectName))
{
- mBeanServer.registerMBean(resource, objectName);
+ try
+ {
+ mBeanServer.registerMBean(resource, objectName);
+ }
+ catch (InstanceAlreadyExistsException e)
+ {
+ log.warn("There same instance is already registred!", e);
+ }
}
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyPoolBroadcastTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyPoolBroadcastTest.java 2008-11-17 16:07:21 UTC (rev 7147)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyPoolBroadcastTest.java 2008-11-17 18:08:06 UTC (rev 7148)
@@ -138,40 +138,61 @@
public void testConcurrency() throws Exception
{
- log.debug("Running testConcurrency");
- int numCaches = 4;
- List<CacheSPI<Object, Object>> caches = new ArrayList<CacheSPI<Object, Object>>(4);
- cachesTL.set(caches);
- CountDownLatch latch = new CountDownLatch(1);
- CacheStarter[] starters = new CacheStarter[numCaches];
+ int numCaches = 4;
+ List<CacheSPI<Object, Object>> caches = new ArrayList<CacheSPI<Object, Object>>(4);
+ cachesTL.set(caches);
+ CountDownLatch latch = new CountDownLatch(1);
+ CacheStarter[] starters = new CacheStarter[numCaches];
- for (int i = 0; i < numCaches; i++)
- {
- caches.add(createCache(1, new String(new char[]{(char) ('A' + i)}), false, false));
- starters[i] = new CacheStarter("CacheStarter-" + i, latch, caches.get(i));
- starters[i].start();
- }
+ for (int i = 0; i < numCaches; i++)
+ {
+ caches.add(createCache(1, new String(new char[]{(char) ('A' + i)}), false, false));
+ starters[i] = new CacheStarter("CacheStarter-" + i, latch, caches.get(i));
+ starters[i].start();
+ }
- // now have the lot start simultaneously
-// TestingUtil.sleepThread(500);
- latch.countDown();
+ // now have the lot start simultaneously
+ latch.countDown();
- // allow a generous sleep time
- TestingUtil.blockUntilViewsReceived(caches.toArray(new CacheSPI[0]), 240000);
- TestingUtil.sleepThread(1000 * numCaches); // the max timeout we can expect is 2500ms * 10 nodes
+ // allow a generous sleep time
+ TestingUtil.blockUntilViewsReceived(caches.toArray(new CacheSPI[0]), 240000);
- // and now look at the state of things.
- Map map = caches.get(0).getBuddyManager().buddyPool;
- System.out.println(map);
- for (int i = 0; i < numCaches; i++)
- {
- if (caches.get(i) != null)
- assertEquals("Failed on cache " + i + "(" + caches.get(i).getLocalAddress() + ")", new String(new char[]{(char) ('A' + i)}), map.get(caches.get(i).getLocalAddress()));
- else
- System.out.println("Cache " + i + " is null!??");
- }
- checkConsistentPoolState(caches);
+ long timeout = System.currentTimeMillis() + 5000 * numCaches;
+ while (System.currentTimeMillis() < timeout)
+ {
+ boolean allPoolNameBroadcasted = true;
+ for (int i = 0; i < numCaches; i++)
+ {
+ boolean receivedFromAll = caches.get(i).getBuddyManager().buddyPool.size() == numCaches;
+ allPoolNameBroadcasted &= receivedFromAll;
+ }
+ if (allPoolNameBroadcasted)
+ {
+ System.out.println("Received from all!!!");
+ break;
+ }
+ if (System.currentTimeMillis() >= timeout)
+ {
+ log.error("********* pool membership was not brodcasted in " + (timeout - System.currentTimeMillis()) + " millis!");
+
+ assert false : "pool membership was not brodcasted in " + timeout + " millis!";
+ }
+ Thread.sleep(50);
+ }
+
+ //and now look at the state of things.
+ Map map = caches.get(0).getBuddyManager().buddyPool;
+ System.out.println(map);
+ for (int i = 0; i < numCaches; i++)
+ {
+ if (caches.get(i) != null)
+ assertEquals("Failed on cache " + i + "(" + caches.get(i).getLocalAddress() + ")", new String(new char[]{(char) ('A' + i)}), map.get(caches.get(i).getLocalAddress()));
+ else
+ System.out.println("Cache " + i + " is null!??");
+ }
+
+ checkConsistentPoolState(caches);
}
public class CacheStarter extends Thread
Modified: core/trunk/src/test/resources/unit-test-cache-service.xml
===================================================================
--- core/trunk/src/test/resources/unit-test-cache-service.xml 2008-11-17 16:07:21 UTC (rev 7147)
+++ core/trunk/src/test/resources/unit-test-cache-service.xml 2008-11-17 18:08:06 UTC (rev 7148)
@@ -121,7 +121,7 @@
max_bundle_timeout="30"
use_incoming_packet_handler="true"
ip_ttl="2"
- enable_bundling="true"
+ enable_bundling="false"
enable_diagnostics="true"
use_concurrent_stack="true"
@@ -257,7 +257,7 @@
max_bundle_size="64000"
max_bundle_timeout="30"
use_incoming_packet_handler="true"
- enable_bundling="true"
+ enable_bundling="false"
use_send_queues="false"
sock_conn_timeout="300"
skip_suspected_members="true"
More information about the jbosscache-commits
mailing list