Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-10-31 03:52:07 -0500
committerEike Stepper2006-10-31 03:52:07 -0500
commit8d2e9ab07ea993aaf72e98c999100ac671e6d80c (patch)
tree92ca7c9fdb22afd56891feb488073585ea4f7ea5 /plugins/org.eclipse.emf.cdo.tests/src
parent83a95492d09d812d39fd2b578a7814615a0a57ee (diff)
downloadcdo-8d2e9ab07ea993aaf72e98c999100ac671e6d80c.tar.gz
cdo-8d2e9ab07ea993aaf72e98c999100ac671e6d80c.tar.xz
cdo-8d2e9ab07ea993aaf72e98c999100ac671e6d80c.zip
waitForSignals()
protocolData profiling TCPSelectorImpl.SELECT_TIMEOUT
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests/src')
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/AbstractTopologyTest.java29
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/ClientServerTopology.java103
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/ITopology.java2
3 files changed, 114 insertions, 20 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/AbstractTopologyTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/AbstractTopologyTest.java
index 295c269122..acfcd2e1c1 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/AbstractTopologyTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/AbstractTopologyTest.java
@@ -22,8 +22,7 @@ import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.net4j.util.om.OMPlatform;
import org.eclipse.net4j.util.om.log.PrintLogHandler;
-import org.eclipse.net4j.util.om.trace.RemoteTraceHandler;
-import org.eclipse.net4j.util.om.trace.RemoteTraceServer;
+import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -42,9 +41,11 @@ public abstract class AbstractTopologyTest extends TestCase implements ITopology
private long startMemory;
- private String label;
+ private long startTime;
+
+ private long runTime;
- private RemoteTraceServer remoteTraceServer;
+ private String label;
public String getMode()
{
@@ -69,13 +70,14 @@ public abstract class AbstractTopologyTest extends TestCase implements ITopology
@Override
protected void setUp() throws Exception
{
+ startTime = System.currentTimeMillis();
// remoteTraceServer = new RemoteTraceServer();
// remoteTraceServer.addListener(RemoteTraceServer.PrintListener.CONSOLE);
OMPlatform.INSTANCE.setDebugging(true);
OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
- OMPlatform.INSTANCE.addTraceHandler(new RemoteTraceHandler());
- // OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
+ // OMPlatform.INSTANCE.addTraceHandler(new RemoteTraceHandler());
+ OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
System.gc();
startMemory = getUsedMemory();
@@ -88,12 +90,19 @@ public abstract class AbstractTopologyTest extends TestCase implements ITopology
super.setUp();
topology.start();
+
+ startTime = System.currentTimeMillis() - startTime;
+ runTime = System.currentTimeMillis();
}
@Override
protected void tearDown() throws Exception
{
- Thread.sleep(200);
+ topology.waitForSignals();
+ runTime = System.currentTimeMillis() - runTime;
+ long stopTime = System.currentTimeMillis();
+
+ Thread.sleep(50);
JdbcTemplate jdbc = jdbc();
wipeDatabase(jdbc);
@@ -103,8 +112,12 @@ public abstract class AbstractTopologyTest extends TestCase implements ITopology
System.gc();
long endMemory = getUsedMemory();
+ stopTime = System.currentTimeMillis() - stopTime;
- System.out.println("Memory-Delta " + getRun() + "\t " + (endMemory - startMemory));
+ String run = getRun();
+ System.out.println("Runtime-Stat " + run + "\t " + startTime + "\t " + runTime + "\t "
+ + stopTime);
+ System.out.println("Memory-Delta " + run + "\t " + (endMemory - startMemory));
System.out.println("=========================================================================");
System.out.println("TC_END " + label);
System.out.println("=========================================================================");
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/ClientServerTopology.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/ClientServerTopology.java
index 5258788e34..ae81733bf5 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/ClientServerTopology.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/ClientServerTopology.java
@@ -25,7 +25,10 @@ import org.eclipse.emf.cdo.server.protocol.ServerCDOResProtocolImpl;
import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.transport.BufferHandler;
import org.eclipse.net4j.transport.BufferProvider;
+import org.eclipse.net4j.transport.Channel;
import org.eclipse.net4j.transport.Connector;
import org.eclipse.net4j.transport.ProtocolFactory;
import org.eclipse.net4j.transport.tcp.TCPAcceptor;
@@ -40,15 +43,39 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.transaction.support.TransactionTemplate;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
import javax.sql.DataSource;
public class ClientServerTopology implements ITopology
{
- public static final ExecutorService THREAD_POOL = Executors.newCachedThreadPool();
+ public static final ThreadGroup ACCEPTOR_GROUP = new ThreadGroup("acceptor");
+
+ public static final ThreadGroup CONNECTOR_GROUP = new ThreadGroup("connector");
+
+ public static final ExecutorService ACCEPTOR_POOL = Executors
+ .newCachedThreadPool(new ThreadFactory()
+ {
+ public Thread newThread(Runnable r)
+ {
+ return new Thread(ACCEPTOR_GROUP, r);
+ }
+ });
+
+ public static final ExecutorService CONNECTOR_POOL = Executors
+ .newCachedThreadPool(new ThreadFactory()
+ {
+ public Thread newThread(Runnable r)
+ {
+ return new Thread(CONNECTOR_GROUP, r);
+ }
+ });
private AttributeConverterImpl attributeConverter;
@@ -82,6 +109,10 @@ public class ClientServerTopology implements ITopology
private JdbcTemplate jdbcTemplate;
+ private MapperImpl mapper;
+
+ private List<ResourceManager> resourceManagers = new ArrayList();
+
public ClientServerTopology()
{
}
@@ -121,7 +152,7 @@ public class ClientServerTopology implements ITopology
jdbcTemplate = new JdbcTemplate();
jdbcTemplate.setDataSource(dataSource);
- MapperImpl mapper = new MapperImpl();
+ mapper = new MapperImpl();
mapper.setColumnConverter(columnConverter);
mapper.setDataSource(dataSource);
mapper.setJdbcTemplate(jdbcTemplate);
@@ -135,6 +166,7 @@ public class ClientServerTopology implements ITopology
transactionManager.setDataSource(dataSource);
transactionTemplate = new TransactionTemplate();
+ transactionTemplate.setTransactionManager(transactionManager);
serverRegistry = new HashMapRegistry();
serverRegistry.register(new ServerCDOResProtocolImpl.Factory(mapper, transactionTemplate));
@@ -142,7 +174,7 @@ public class ClientServerTopology implements ITopology
acceptor = Net4jUtil.createTCPAcceptor(bufferPool, selector);
acceptor.setProtocolFactoryRegistry(serverRegistry);
- acceptor.setReceiveExecutor(THREAD_POOL);
+ acceptor.setReceiveExecutor(ACCEPTOR_POOL);
LifecycleUtil.activate(acceptor);
// Client
@@ -156,34 +188,80 @@ public class ClientServerTopology implements ITopology
LifecycleUtil.activate(clientPackageManager);
clientRegistry = new HashMapRegistry();
- clientRegistry.register(new ClientCDOProtocolImpl.Factory());
+ clientRegistry.register(new ClientCDOProtocolImpl.Factory(clientPackageManager));
clientRegistry.register(new ClientCDOResProtocolImpl.Factory());
connector = Net4jUtil.createTCPConnector(bufferPool, selector, "localhost");
connector.setProtocolFactoryRegistry(clientRegistry);
- connector.setReceiveExecutor(THREAD_POOL);
+ connector.setReceiveExecutor(CONNECTOR_POOL);
LifecycleUtil.activate(connector);
}
public void stop() throws Exception
{
+ for (ResourceManager resourceManager : resourceManagers)
+ {
+ LifecycleUtil.deactivate(resourceManager);
+ }
+
+ resourceManagers.clear();
+ resourceManagers = null;
+
LifecycleUtil.deactivate(connector);
connector = null;
- LifecycleUtil.deactivate(selector);
- selector = null;
-
- LifecycleUtil.deactivate(bufferPool);
- bufferPool = null;
+ clientRegistry = null;
LifecycleUtil.deactivate(clientPackageManager);
clientPackageManager = null;
+ LifecycleUtil.deactivate(attributeConverter);
+ attributeConverter = null;
+
+ LifecycleUtil.deactivate(acceptor);
+ acceptor = null;
+
+ serverRegistry = null;
+ transactionTemplate = null;
+ transactionManager = null;
+
+ LifecycleUtil.deactivate(mapper);
+ mapper = null;
+
+ jdbcTemplate = null;
+ dataSource = null;
+
+ LifecycleUtil.deactivate(serverResourceManager);
+ serverResourceManager = null;
+
+ LifecycleUtil.deactivate(serverPackageManager);
+ serverPackageManager = null;
+
+ LifecycleUtil.deactivate(columnConverter);
+ columnConverter = null;
+
LifecycleUtil.deactivate(oidEncoder);
oidEncoder = null;
- LifecycleUtil.deactivate(attributeConverter);
- attributeConverter = null;
+ LifecycleUtil.deactivate(selector);
+ selector = null;
+
+ LifecycleUtil.deactivate(bufferPool);
+ bufferPool = null;
+ }
+
+ public void waitForSignals()
+ {
+ Collection<Channel> channels = Channel.REGISTRY.getElements();
+ for (Channel channel : channels)
+ {
+ BufferHandler receiveHandler = channel.getReceiveHandler();
+ if (receiveHandler instanceof SignalProtocol)
+ {
+ SignalProtocol signalProtocol = (SignalProtocol) receiveHandler;
+ signalProtocol.waitForSignals(2000);
+ }
+ }
}
public ResourceManager createResourceManager(ResourceSet resourceSet) throws Exception
@@ -193,6 +271,7 @@ public class ClientServerTopology implements ITopology
resourceManager.setPackageManager(clientPackageManager);
resourceManager.setResourceSet(resourceSet);
LifecycleUtil.activate(resourceManager);
+ resourceManagers.add(resourceManager);
return resourceManager;
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/ITopology.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/ITopology.java
index 58aae5f98e..0a8eeba10b 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/ITopology.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/topology/ITopology.java
@@ -29,4 +29,6 @@ public interface ITopology
public ResourceManager createResourceManager(ResourceSet resourceSet) throws Exception;
public DataSource getDataSource();
+
+ public void waitForSignals();
}

Back to the top