JBoss Cache SVN: r7471 - core/trunk/src/test/resources.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-14 11:45:03 -0500 (Wed, 14 Jan 2009)
New Revision: 7471
Modified:
core/trunk/src/test/resources/log4j.xml
Log:
Modified: core/trunk/src/test/resources/log4j.xml
===================================================================
--- core/trunk/src/test/resources/log4j.xml 2009-01-14 16:43:44 UTC (rev 7470)
+++ core/trunk/src/test/resources/log4j.xml 2009-01-14 16:45:03 UTC (rev 7471)
@@ -84,8 +84,8 @@
<root>
<priority value="WARN"/>
- <!--<appender-ref ref="FILE"/>-->
- <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ <!-- <appender-ref ref="CONSOLE"/> -->
</root>
</log4j:configuration>
17 years, 2 months
JBoss Cache SVN: r7470 - in core/trunk/src/test: resources and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-14 11:43:44 -0500 (Wed, 14 Jan 2009)
New Revision: 7470
Modified:
core/trunk/src/test/java/org/jboss/cache/ResourceCleanupTest.java
core/trunk/src/test/resources/log4j.xml
Log:
Fixed os.name
Modified: core/trunk/src/test/java/org/jboss/cache/ResourceCleanupTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/ResourceCleanupTest.java 2009-01-14 15:38:24 UTC (rev 7469)
+++ core/trunk/src/test/java/org/jboss/cache/ResourceCleanupTest.java 2009-01-14 16:43:44 UTC (rev 7470)
@@ -43,7 +43,7 @@
System.setProperty("bind.address","127.0.0.1");
}
System.out.println("java.vm.version = " + System.getProperty("java.vm.version"));
- System.out.println("os.name = " + System.getProperty("java.vm.version"));
+ System.out.println("os.name = " + System.getProperty("os.name"));
System.out.println("os.version = " + System.getProperty("os.version"));
System.out.println("sun.arch.data.model = " + System.getProperty("sun.arch.data.model"));
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~ ENVIRONMENT INFO ~~~~~~~~~~~~~~~~~~~~~~~~~~");
Modified: core/trunk/src/test/resources/log4j.xml
===================================================================
--- core/trunk/src/test/resources/log4j.xml 2009-01-14 15:38:24 UTC (rev 7469)
+++ core/trunk/src/test/resources/log4j.xml 2009-01-14 16:43:44 UTC (rev 7470)
@@ -84,8 +84,8 @@
<root>
<priority value="WARN"/>
- <appender-ref ref="FILE"/>
- <!--<appender-ref ref="CONSOLE"/>-->
+ <!--<appender-ref ref="FILE"/>-->
+ <appender-ref ref="CONSOLE"/>
</root>
</log4j:configuration>
17 years, 2 months
JBoss Cache SVN: r7469 - in core/trunk/src/test/java/org/jboss/cache: api/pfer and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2009-01-14 10:38:24 -0500 (Wed, 14 Jan 2009)
New Revision: 7469
Modified:
core/trunk/src/test/java/org/jboss/cache/AbstractCacheTest.java
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
core/trunk/src/test/java/org/jboss/cache/cluster/ReplicationQueueTest.java
Log:
fix test for jdk6
Modified: core/trunk/src/test/java/org/jboss/cache/AbstractCacheTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/AbstractCacheTest.java 2009-01-14 15:17:34 UTC (rev 7468)
+++ core/trunk/src/test/java/org/jboss/cache/AbstractCacheTest.java 2009-01-14 15:38:24 UTC (rev 7469)
@@ -1,5 +1,7 @@
package org.jboss.cache;
+import org.jboss.cache.loader.CacheLoaderManager;
+
/**
* @author Mircea.Markus(a)jboss.com
*/
@@ -13,20 +15,37 @@
{
clearRunningTx(cache);
if (!cache.getCacheStatus().allowInvocations()) return;
- if (cache.getRoot() != null)
+ removeInMemoryData(cache);
+ clearCacheLoader(cache);
+ //impoortant!!! keep invocation ctxt cleanup as the last line in the cleanup process, prev calls modify
+ // OptionOverrides
+ cache.getInvocationContext().reset();
+ }
+
+ private void clearCacheLoader(CacheSPI<K, V> cache)
+ {
+ CacheLoaderManager cacheLoaderManager = cache.getCacheLoaderManager();
+ if (cacheLoaderManager != null && cacheLoaderManager.getCacheLoader() != null)
{
- cache.getRoot().clearDataDirect();
- //this will also remove from CL if necesarely
- for (Object obj : cache.getRoot().getChildrenNames())
+ try
{
- cache.getRoot().removeChild(obj);
+ cacheLoaderManager.getCacheLoader().remove(Fqn.ROOT);
+ } catch (Exception e)
+ {
+ throw new RuntimeException(e);
}
}
- //impoortant!!! keep invocation ctxt cleanup as the last line in the cleanup process, prev calls modify
- // OptionOverrides
- cache.getInvocationContext().reset();
}
+ private void removeInMemoryData(CacheSPI<K, V> cache)
+ {
+ if (cache.getRoot() != null)
+ {
+ cache.getRoot().clearDataDirect();
+ cache.getRoot().removeChildrenDirect();
+ }
+ }
+
private void clearRunningTx(CacheSPI<K, V> cache)
{
if (cache != null && cache.getTransactionManager() != null)
Modified: core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2009-01-14 15:17:34 UTC (rev 7468)
+++ core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2009-01-14 15:38:24 UTC (rev 7469)
@@ -26,7 +26,6 @@
import java.util.List;
import java.util.Vector;
-@Test(groups = {"functional", "jgroups", "transaction"})
public abstract class PutForExternalReadTestBase extends AbstractMultipleCachesTest
{
protected Configuration.CacheMode cacheMode;
@@ -43,6 +42,7 @@
protected TransactionManager tm1, tm2;
protected boolean useTx;
+ private RPCManager rpcManager1;
protected void createCaches()
{
@@ -66,6 +66,8 @@
replListener1 = ReplicationListener.getReplicationListener(cache1);
replListener2 = ReplicationListener.getReplicationListener(cache2);
+ rpcManager1 = cache1.getRPCManager();
+
TestingUtil.blockUntilViewsReceived(10000, cache1, cache2);
registerCaches(cache1, cache2);
}
@@ -114,8 +116,8 @@
public void testAsyncForce() throws Exception
{
RPCManager rpcManager = EasyMock.createNiceMock(RPCManager.class);
- RPCManager originalRpcManager = cache1.getConfiguration().getRuntimeConfig().getRPCManager();
- List<Address> memberList = originalRpcManager.getMembers();
+
+ List<Address> memberList = rpcManager1.getMembers();
expect(rpcManager.getMembers()).andReturn(memberList).anyTimes();
// inject a mock RPC manager so that we can test whether calls made are sync or async.
ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache1);
@@ -137,7 +139,7 @@
verify(rpcManager);
// cleanup
- TestingUtil.extractComponentRegistry(cache1).registerComponent(originalRpcManager, RPCManager.class);
+ TestingUtil.extractComponentRegistry(cache1).registerComponent(rpcManager1, RPCManager.class);
TestingUtil.extractComponentRegistry(cache1).rewire();
replListener2.expect(RemoveNodeCommand.class);
@@ -229,7 +231,7 @@
}
finally
{
- TestingUtil.extractComponentRegistry(cache1).registerComponent(originalRpcManager, RPCManager.class);
+ TestingUtil.extractComponentRegistry(cache1).registerComponent(rpcManager1, RPCManager.class);
TestingUtil.extractComponentRegistry(cache1).rewire();
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/cluster/ReplicationQueueTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/cluster/ReplicationQueueTest.java 2009-01-14 15:17:34 UTC (rev 7468)
+++ core/trunk/src/test/java/org/jboss/cache/cluster/ReplicationQueueTest.java 2009-01-14 15:38:24 UTC (rev 7469)
@@ -21,7 +21,7 @@
import java.util.Vector;
import java.util.concurrent.CountDownLatch;
-@Test(groups = "functional", sequential = true, testName = "cluster.ReplicationQueueTest")
+@Test(groups = "functional", testName = "cluster.ReplicationQueueTest")
public class ReplicationQueueTest extends AbstractMultipleCachesTest
{
private static final int COUNT = 10;
@@ -63,6 +63,7 @@
public void testQueueHoldAndFlush() throws Exception
{
assert replQ != null;
+ assert replQ.elements.size() == 0 : "expected 0, recieved " + replQ.elements.size();
// mock the RPCManager used in the cache
RPCManager mockRpcManager = EasyMock.createStrictMock(RPCManager.class);
17 years, 2 months
JBoss Cache SVN: r7468 - core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-14 10:17:34 -0500 (Wed, 14 Jan 2009)
New Revision: 7468
Added:
core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/SynchronizedRestarter.java
Log:
Thread safe component restarter
Added: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/SynchronizedRestarter.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/SynchronizedRestarter.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/SynchronizedRestarter.java 2009-01-14 15:17:34 UTC (rev 7468)
@@ -0,0 +1,71 @@
+package org.jboss.starobrno.util.concurrent;
+
+import org.jboss.starobrno.lifecycle.Lifecycle;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.locks.LockSupport;
+
+/**
+ * A class that handles restarts of components via multiple threads. Specifically, if a component needs to be restarted
+ * and several threads may demand a restart but only one thread should be allowed to restart the component, then use this
+ * class.
+ * <p/>
+ * What this class guarantees is that several threads may come in while a component is being restarted, but they will
+ * block until the restart is complete.
+ * <p/>
+ * This is different from other techniques in that:
+ * <ul>
+ * <li>A simple compare-and-swap to check whether another thread is already performing a restart will result in the
+ * requesting thread returning immediately and potentially attempting to use the resource being restarted.</li>
+ * <li>A synchronized method or use of a lock would result in the thread waiting for the restart to complete, but on
+ * completion will attempt to restart the component again.</li>
+ * </ul>
+ * This implementation combines a compare-and-swap to detect a concurrent restart, as well as registering for notification
+ * for when the restart completes and then parking the thread if the CAS variable still indicates a restart in progress,
+ * and finally deregistering itself in the end.
+ *
+ * @author Manik Surtani
+ */
+public class SynchronizedRestarter
+{
+ private AtomicBoolean restartInProgress = new AtomicBoolean(false);
+ private ConcurrentHashSet<Thread> restartWaiters = new ConcurrentHashSet<Thread>();
+
+ public void restartComponent(Lifecycle component) throws Exception
+ {
+ // will only enter this block if no one else is restarting the socket
+ // and will atomically set the flag so others won't enter
+ if (restartInProgress.compareAndSet(false, true))
+ {
+ try
+ {
+ component.stop();
+ component.start();
+ }
+ finally
+ {
+ restartInProgress.set(false);
+ for (Thread waiter : restartWaiters)
+ {
+ try
+ {
+ LockSupport.unpark(waiter);
+ }
+ catch (Throwable t)
+ {
+ // do nothing; continue notifying the rest
+ }
+ }
+ }
+ }
+ else
+ {
+ // register interest in being notified after the restart
+ restartWaiters.add(Thread.currentThread());
+ // check again to ensure the restarting thread hasn't finished, then wait for that thread to finish
+ if (restartInProgress.get()) LockSupport.park();
+ // de-register interest in notification
+ restartWaiters.remove(Thread.currentThread());
+ }
+ }
+}
17 years, 2 months
JBoss Cache SVN: r7467 - core/trunk/src/test/java/org/jboss/cache/loader.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-14 10:13:00 -0500 (Wed, 14 Jan 2009)
New Revision: 7467
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheServerTest.java
Log:
Re-enabled test
Modified: core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheServerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheServerTest.java 2009-01-14 15:07:34 UTC (rev 7466)
+++ core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheServerTest.java 2009-01-14 15:13:00 UTC (rev 7467)
@@ -3,6 +3,7 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.UnitTestConfigurationFactory;
@@ -10,12 +11,14 @@
import org.jboss.cache.jmx.CacheJmxWrapper;
import org.jboss.cache.loader.tcp.TcpCacheServer;
import org.jboss.cache.util.TestingUtil;
-import static org.testng.AssertJUnit.*;
+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 org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import java.net.UnknownHostException;
-import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests various ways of setting up the TcpCacheServer
@@ -23,11 +26,12 @@
* @author Brian Stansberry
* @version $Id$
*/
-@Test(groups = {"functional"}, enabled = false, testName = "loader.TcpCacheServerTest")
-// TODO Re-enable!
+@Test(groups = {"functional"}, enabled = true, testName = "loader.TcpCacheServerTest")
public class TcpCacheServerTest
{
static TcpCacheServer cache_server = null;
+ private static final String SERVER_IP = "127.0.0.1";
+ private static final int SERVER_PORT = 13131;
private CacheSPI<Object, Object> cache;
private CacheLoader loader;
@@ -61,7 +65,7 @@
protected CacheLoaderConfig getCacheLoaderConfig() throws Exception
{
return buildSingleCacheLoaderConfig(false, null, "org.jboss.cache.loader.TcpDelegatingCacheLoader",
- "host=127.0.0.1\nport=12121", false, true, true, false, false);
+ "host=" + SERVER_IP + "\nport=" + SERVER_PORT, false, true, true, false, false);
}
@AfterMethod(alwaysRun = true)
@@ -85,8 +89,8 @@
private static void createTcpCacheServer() throws UnknownHostException
{
cache_server = new TcpCacheServer();
- cache_server.setBindAddress("127.0.0.1");
- cache_server.setPort(12121);
+ cache_server.setBindAddress(SERVER_IP);
+ cache_server.setPort(SERVER_PORT);
}
private void startTcpCacheServer()
17 years, 2 months
JBoss Cache SVN: r7466 - core/trunk/src/test/java/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2009-01-14 10:07:34 -0500 (Wed, 14 Jan 2009)
New Revision: 7466
Modified:
core/trunk/src/test/java/org/jboss/cache/AbstractCacheTest.java
Log:
also remove data from CL
Modified: core/trunk/src/test/java/org/jboss/cache/AbstractCacheTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/AbstractCacheTest.java 2009-01-14 15:05:13 UTC (rev 7465)
+++ core/trunk/src/test/java/org/jboss/cache/AbstractCacheTest.java 2009-01-14 15:07:34 UTC (rev 7466)
@@ -15,7 +15,7 @@
if (!cache.getCacheStatus().allowInvocations()) return;
if (cache.getRoot() != null)
{
- cache.getRoot().clearData();
+ cache.getRoot().clearDataDirect();
//this will also remove from CL if necesarely
for (Object obj : cache.getRoot().getChildrenNames())
{
17 years, 2 months
JBoss Cache SVN: r7465 - core/trunk/src/main/java/org/jboss/cache/loader.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-14 10:05:13 -0500 (Wed, 14 Jan 2009)
New Revision: 7465
Modified:
core/trunk/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoader.java
Log:
Set timeout before creating socket
Modified: core/trunk/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoader.java 2009-01-14 14:54:45 UTC (rev 7464)
+++ core/trunk/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoader.java 2009-01-14 15:05:13 UTC (rev 7465)
@@ -38,6 +38,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.ConnectException;
+import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.List;
import java.util.Map;
@@ -396,8 +397,10 @@
{
try
{
- sock = new Socket(config.getHost(), config.getPort());
+ InetSocketAddress address = new InetSocketAddress(config.getHost(), config.getPort());
+ sock = new Socket();
sock.setSoTimeout(config.getReadTimeout());
+ sock.connect(address, config.getReadTimeout());
out = new ObjectOutputStream(new BufferedOutputStream(sock.getOutputStream()));
out.flush();
in = new ObjectInputStream(new BufferedInputStream(sock.getInputStream()));
17 years, 2 months
JBoss Cache SVN: r7464 - core/trunk/src/test/java/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2009-01-14 09:54:45 -0500 (Wed, 14 Jan 2009)
New Revision: 7464
Modified:
core/trunk/src/test/java/org/jboss/cache/AbstractCacheTest.java
Log:
also remove data from CL
Modified: core/trunk/src/test/java/org/jboss/cache/AbstractCacheTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/AbstractCacheTest.java 2009-01-14 14:49:42 UTC (rev 7463)
+++ core/trunk/src/test/java/org/jboss/cache/AbstractCacheTest.java 2009-01-14 14:54:45 UTC (rev 7464)
@@ -15,8 +15,12 @@
if (!cache.getCacheStatus().allowInvocations()) return;
if (cache.getRoot() != null)
{
- cache.getRoot().clearDataDirect();
- cache.getRoot().removeChildrenDirect();
+ cache.getRoot().clearData();
+ //this will also remove from CL if necesarely
+ for (Object obj : cache.getRoot().getChildrenNames())
+ {
+ cache.getRoot().removeChild(obj);
+ }
}
//impoortant!!! keep invocation ctxt cleanup as the last line in the cleanup process, prev calls modify
// OptionOverrides
17 years, 2 months