JBoss Remoting SVN: r6088 - remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-09-07 15:37:19 -0400 (Tue, 07 Sep 2010)
New Revision: 6088
Modified:
remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/EndpointConfigurationTestCase.java
Log:
JBREM-1228: Extends RemotingLocalTestBase instead of RemotingTestBase.
Modified: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/EndpointConfigurationTestCase.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/EndpointConfigurationTestCase.java 2010-09-07 19:35:59 UTC (rev 6087)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/EndpointConfigurationTestCase.java 2010-09-07 19:37:19 UTC (rev 6088)
@@ -73,7 +73,7 @@
* Copyright Jun 21, 2010
*/
@Test(suiteName = "EndpointConfiguration")
-public class EndpointConfigurationTestCase extends RemotingTestBase {
+public class EndpointConfigurationTestCase extends RemotingLocalTestBase {
private static final Logger log = Logger.getLogger(EndpointConfigurationTestCase.class);
14 years, 2 months
JBoss Remoting SVN: r6087 - remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-09-07 15:35:59 -0400 (Tue, 07 Sep 2010)
New Revision: 6087
Modified:
remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/CopyOnWriteHashMapTestCase.java
Log:
JBREM-1228: Extends RemotingRootTestBase instead of RemotingTestBase.
Modified: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/CopyOnWriteHashMapTestCase.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/CopyOnWriteHashMapTestCase.java 2010-09-07 19:34:04 UTC (rev 6086)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/CopyOnWriteHashMapTestCase.java 2010-09-07 19:35:59 UTC (rev 6087)
@@ -48,7 +48,7 @@
* Copyright Aug 28, 2010
*/
@Test(suiteName = "CopyOnWriteHashMap")
-public class CopyOnWriteHashMapTestCase extends RemotingTestBase {
+public class CopyOnWriteHashMapTestCase extends RemotingRootTestBase {
private static final Logger log = Logger.getLogger(CopyOnWriteHashMapTestCase.class);
14 years, 2 months
JBoss Remoting SVN: r6086 - remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-09-07 15:34:04 -0400 (Tue, 07 Sep 2010)
New Revision: 6086
Modified:
remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ClientServerRemoteConfigurationTestCase.java
Log:
JBREM-1228: Changes due to reorganization of RemotingTestBase; other corrections.
Modified: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ClientServerRemoteConfigurationTestCase.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ClientServerRemoteConfigurationTestCase.java 2010-09-07 19:28:13 UTC (rev 6085)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ClientServerRemoteConfigurationTestCase.java 2010-09-07 19:34:04 UTC (rev 6086)
@@ -27,44 +27,19 @@
import static org.testng.Assert.assertSame;
import java.io.IOException;
-import java.net.InetSocketAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashSet;
-import java.util.Properties;
import java.util.ServiceLoader;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import org.jboss.marshalling.river.RiverProviderDescriptor;
import org.jboss.remoting3.Client;
-import org.jboss.remoting3.ClientContext;
-import org.jboss.remoting3.ClientListener;
-import org.jboss.remoting3.CloseHandler;
import org.jboss.remoting3.Connection;
import org.jboss.remoting3.Endpoint;
-import org.jboss.remoting3.Registration;
import org.jboss.remoting3.RemoteExecutionException;
import org.jboss.remoting3.Remoting;
import org.jboss.remoting3.RequestContext;
import org.jboss.remoting3.RequestListener;
-import org.jboss.remoting3.Endpoint.ServiceBuilder;
-import org.jboss.remoting3.remote.RemoteProtocolDescriptor;
-import org.jboss.remoting3.security.SimpleServerAuthenticationProvider;
-import org.jboss.remoting3.spi.ConnectionProviderFactory;
-import org.jboss.remoting3.spi.NetworkServerProvider;
-import org.jboss.remoting3.spi.ProtocolServiceType;
import org.jboss.remoting3.spi.RemotingServiceDescriptor;
-import org.jboss.xnio.AcceptingServer;
-import org.jboss.xnio.ChannelListener;
-import org.jboss.xnio.IoFuture;
-import org.jboss.xnio.OptionMap;
-import org.jboss.xnio.Options;
-import org.jboss.xnio.TcpServer;
-import org.jboss.xnio.Xnio;
-import org.jboss.xnio.channels.BoundChannel;
-import org.jboss.xnio.channels.ConnectedStreamChannel;
import org.jboss.xnio.log.Logger;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -113,8 +88,10 @@
int id1 = counter++;
// Set up services.
- sp0 = setupServer(null, id0, null, "test", "test", 4444);
- sp1 = setupServer(null, id1, null, "test", "test", 5555);
+ TestRequestListener testRequestListener0 = new TestRequestListener(id0);
+ TestRequestListener testRequestListener1 = new TestRequestListener(id1);
+ sp0 = setupServer(null, id0, testRequestListener0, "test", "test");
+ sp1 = setupServer(null, id1, testRequestListener1, "test", "test");
// Verify configuration.
assertNotSame(sp0.executor, sp1.executor, "Should be distinct");
@@ -124,10 +101,10 @@
assertNotSame(sp0.requestListener, sp1.requestListener, "Should be distinct");
// Set up connections and clients.
- Connection connection00 = setupConnection(4444); connections.add(connection00);
- Connection connection01 = setupConnection(4444); connections.add(connection01);
- Connection connection10 = setupConnection(5555); connections.add(connection10);
- Connection connection11 = setupConnection(5555); connections.add(connection11);
+ Connection connection00 = setupConnection(sp0.port); connections.add(connection00);
+ Connection connection01 = setupConnection(sp0.port); connections.add(connection01);
+ Connection connection10 = setupConnection(sp1.port); connections.add(connection10);
+ Connection connection11 = setupConnection(sp1.port); connections.add(connection11);
Client<Object, Object> client000 = setupClient(connection00, "test", "test"); clients.add(client000);
Client<Object, Object> client001 = setupClient(connection00, "test", "test"); clients.add(client001);
Client<Object, Object> client010 = setupClient(connection01, "test", "test"); clients.add(client010);
@@ -148,14 +125,22 @@
assertEquals(id1, client110.invoke("dummy"), "Should be equal");
assertEquals(id1, client111.invoke("dummy"), "Should be equal");
}
- assertEquals(20, sp0.requestListener.counter, "Should be equal");
- assertEquals(20, sp1.requestListener.counter, "Should be equal");
- log.info(getName() + " PASSES");
+ assertEquals(20, ((TestRequestListener)(sp0.requestListener)).counter, "Should be equal");
+ assertEquals(20, ((TestRequestListener)(sp1.requestListener)).counter, "Should be equal");
+ log.debug(getName() + " PASSES");
} finally {
- clients.close();
- connections.close();
- sp0.close();
- sp1.close();
+ if (clients != null) {
+ clients.close();
+ }
+ if (connections != null) {
+ connections.close();
+ }
+ if (sp0 != null) {
+ sp0.close();
+ }
+ if (sp1 != null) {
+ sp1.close();
+ }
exit();
}
}
@@ -182,9 +167,11 @@
String instanceName1 = serviceType1;
// Set up services.
- sp0 = setupServer(null, id0, null, serviceType0, instanceName0, 0);
+ TestRequestListener testRequestListener0 = new TestRequestListener(id0);
+ sp0 = setupServer(null, id0, testRequestListener0, serviceType0, instanceName0);
+ TestRequestListener testRequestListener1 = new TestRequestListener(id1);
sp1 = new ServerPackage(sp0.executor, null, null, null, null, null, -1);
- setupServer(sp1, id1, null, serviceType1, instanceName1, 0);
+ setupServer(sp1, id1, testRequestListener1, serviceType1, instanceName1);
// Verify configuration.
assertSame(sp0.executor, sp1.executor, "Should be same");
@@ -218,14 +205,22 @@
assertEquals(id1, client110.invoke("dummy"), "Should be equal");
assertEquals(id1, client111.invoke("dummy"), "Should be equal");
}
- assertEquals(20, sp0.requestListener.counter, "Should be equal");
- assertEquals(20, sp1.requestListener.counter, "Should be equal");
- log.info(getName() + " PASSES");
+ assertEquals(20, ((TestRequestListener)(sp0.requestListener)).counter, "Should be equal");
+ assertEquals(20, ((TestRequestListener)(sp1.requestListener)).counter, "Should be equal");
+ log.debug(getName() + " PASSES");
} finally {
- clients.close();
- connections.close();
- sp0.close();
- sp1.close();
+ if (clients != null) {
+ clients.close();
+ }
+ if (connections != null) {
+ connections.close();
+ }
+ if (sp0 != null) {
+ sp0.close();
+ }
+ if (sp1 != null) {
+ sp1.close();
+ }
exit();
}
}
@@ -251,9 +246,11 @@
String instanceName1 = serviceType1;
// Set up services.
- sp0 = setupServer(null, id0, null, serviceType0, instanceName0, 0);
+ TestRequestListener testRequestListener0 = new TestRequestListener(id0);
+ sp0 = setupServer(null, id0, testRequestListener0, serviceType0, instanceName0);
sp1 = new ServerPackage(sp0.executor, sp0.endpoint, null, null, null, null, -1);
- setupServer(sp1, id1, null, serviceType1, instanceName1, 0);
+ TestRequestListener testRequestListener1 = new TestRequestListener(id1);
+ setupServer(sp1, id1, testRequestListener1, serviceType1, instanceName1);
// Verify configuration.
assertSame(sp0.executor, sp1.executor, "Should be same");
@@ -287,14 +284,22 @@
assertEquals(id0, client110.invoke("dummy"), "Should be equal");
assertEquals(id1, client111.invoke("dummy"), "Should be equal");
}
- assertEquals(20, sp0.requestListener.counter, "Should be equal");
- assertEquals(20, sp1.requestListener.counter, "Should be equal");
- log.info(getName() + " PASSES");
+ assertEquals(20, ((TestRequestListener)(sp0.requestListener)).counter, "Should be equal");
+ assertEquals(20, ((TestRequestListener)(sp1.requestListener)).counter, "Should be equal");
+ log.debug(getName() + " PASSES");
} finally {
- clients.close();
- connections.close();
- sp0.close();
- sp1.close();
+ if (clients != null) {
+ clients.close();
+ }
+ if (connections != null) {
+ connections.close();
+ }
+ if (sp0 != null) {
+ sp0.close();
+ }
+ if (sp1 != null) {
+ sp1.close();
+ }
exit();
}
}
@@ -320,9 +325,11 @@
String instanceName1 = serviceType1;
// Set up services.
- sp0 = setupServer(null, id0, null, serviceType0, instanceName0, 0);
+ TestRequestListener testRequestListener0 = new TestRequestListener(id0);
+ sp0 = setupServer(null, id0, testRequestListener0, serviceType0, instanceName0);
sp1 = new ServerPackage(sp0.executor, sp0.endpoint, sp0.xnio, null, null, null, -1);
- setupServer(sp1, id1, null, serviceType1, instanceName1, 0);
+ TestRequestListener testRequestListener1 = new TestRequestListener(id1);
+ setupServer(sp1, id1, testRequestListener1, serviceType1, instanceName1);
// Verify configuration.
assertSame(sp0.executor, sp1.executor, "Should be same");
@@ -356,14 +363,22 @@
assertEquals(id0, client110.invoke("dummy"), "Should be equal");
assertEquals(id1, client111.invoke("dummy"), "Should be equal");
}
- assertEquals(20, sp0.requestListener.counter, "Should be equal");
- assertEquals(20, sp1.requestListener.counter, "Should be equal");
- log.info(getName() + " PASSES");
+ assertEquals(20, ((TestRequestListener)(sp0.requestListener)).counter, "Should be equal");
+ assertEquals(20, ((TestRequestListener)(sp1.requestListener)).counter, "Should be equal");
+ log.debug(getName() + " PASSES");
} finally {
- clients.close();
- connections.close();
- sp0.close();
- sp1.close();
+ if (clients != null) {
+ clients.close();
+ }
+ if (connections != null) {
+ connections.close();
+ }
+ if (sp0 != null) {
+ sp0.close();
+ }
+ if (sp1 != null) {
+ sp1.close();
+ }
exit();
}
}
@@ -391,13 +406,17 @@
String instanceName1 = "instance1";
// Set up services.
- sp00 = setupServer(null, id0, null, serviceType0, instanceName0, 0);
+ TestRequestListener testRequestListener00 = new TestRequestListener(id0);
+ sp00 = setupServer(null, id0, testRequestListener00, serviceType0, instanceName0);
sp01 = new ServerPackage(sp00.executor, sp00.endpoint, sp00.xnio, sp00.tcpServer, null, null, -1);
- setupServer(sp01, id0, null, serviceType0, instanceName1, 0);
+ TestRequestListener testRequestListener01 = new TestRequestListener(id0);
+ setupServer(sp01, id0, testRequestListener01, serviceType0, instanceName1);
sp10 = new ServerPackage(sp00.executor, sp00.endpoint, sp00.xnio, sp00.tcpServer, null, null, -1);
- setupServer(sp10, id1, null, serviceType1, instanceName0, 0);
+ TestRequestListener testRequestListener10 = new TestRequestListener(id1);
+ setupServer(sp10, id1, testRequestListener10, serviceType1, instanceName0);
sp11 = new ServerPackage(sp00.executor, sp00.endpoint, sp00.xnio, sp00.tcpServer, null, null, -1);
- setupServer(sp11, id1, null, serviceType1, instanceName1, 0);
+ TestRequestListener testRequestListener11 = new TestRequestListener(id1);
+ setupServer(sp11, id1, testRequestListener11, serviceType1, instanceName1);
// Verify configuration.
assertSame(sp00.executor, sp01.executor, "Should be same");
@@ -442,18 +461,30 @@
assertEquals(id1, client110.invoke("dummy"), "Should be equal");
assertEquals(id1, client111.invoke("dummy"), "Should be equal");
}
- assertEquals(10, sp00.requestListener.counter, "Should be equal");
- assertEquals(10, sp01.requestListener.counter, "Should be equal");
- assertEquals(10, sp10.requestListener.counter, "Should be equal");
- assertEquals(10, sp11.requestListener.counter, "Should be equal");
- log.info(getName() + " PASSES");
+ assertEquals(10, ((TestRequestListener)(sp00.requestListener)).counter, "Should be equal");
+ assertEquals(10, ((TestRequestListener)(sp01.requestListener)).counter, "Should be equal");
+ assertEquals(10, ((TestRequestListener)(sp10.requestListener)).counter, "Should be equal");
+ assertEquals(10, ((TestRequestListener)(sp11.requestListener)).counter, "Should be equal");
+ log.debug(getName() + " PASSES");
} finally {
- clients.close();
- connections.close();
- sp00.close();
- sp01.close();
- sp10.close();
- sp11.close();
+ if (clients != null) {
+ clients.close();
+ }
+ if (connections != null) {
+ connections.close();
+ }
+ if (sp00 != null) {
+ sp00.close();
+ }
+ if (sp01 != null) {
+ sp01.close();
+ }
+ if (sp10 != null) {
+ sp10.close();
+ }
+ if (sp11 != null) {
+ sp11.close();
+ }
exit();
}
}
@@ -481,13 +512,14 @@
String instanceName1 = "instance1";
// Set up services.
- sp00 = setupServer(null, id0, null, serviceType0, instanceName0, 0);
+ TestRequestListener testRequestListener = new TestRequestListener(id0);
+ sp00 = setupServer(null, id0, testRequestListener, serviceType0, instanceName0);
sp01 = new ServerPackage(sp00.executor, sp00.endpoint, sp00.xnio, sp00.tcpServer, null, null, -1);
- setupServer(sp01, -1, sp00.requestListener, serviceType0, instanceName1, 0);
+ setupServer(sp01, -1, sp00.requestListener, serviceType0, instanceName1);
sp10 = new ServerPackage(sp00.executor, sp00.endpoint, sp00.xnio, sp00.tcpServer, null, null, -1);
- setupServer(sp10, -1, sp00.requestListener, serviceType1, instanceName0, 0);
+ setupServer(sp10, -1, sp00.requestListener, serviceType1, instanceName0);
sp11 = new ServerPackage(sp00.executor, sp00.endpoint, sp00.xnio, sp00.tcpServer, null, null, -1);
- setupServer(sp11, -1, sp00.requestListener, serviceType1, instanceName1, 0);
+ setupServer(sp11, -1, sp00.requestListener, serviceType1, instanceName1);
// Verify configuration.
assertSame(sp00.executor, sp01.executor, "Should be same");
@@ -529,81 +561,31 @@
assertEquals(id0, client110.invoke("dummy"), "Should be equal");
assertEquals(id0, client111.invoke("dummy"), "Should be equal");
}
- assertEquals(40, sp00.requestListener.counter, "Should be equal");
- log.info(getName() + " PASSES");
+ assertEquals(40, ((TestRequestListener)(sp00.requestListener)).counter, "Should be equal");
+ log.debug(getName() + " PASSES");
} finally {
- clients.close();
- connections.close();
- sp00.close();
- sp01.close();
- sp10.close();
- sp11.close();
+ if (clients != null) {
+ clients.close();
+ }
+ if (connections != null) {
+ connections.close();
+ }
+ if (sp00 != null) {
+ sp00.close();
+ }
+ if (sp01 != null) {
+ sp01.close();
+ }
+ if (sp10 != null) {
+ sp10.close();
+ }
+ if (sp11 != null) {
+ sp11.close();
+ }
exit();
}
}
-
- protected String getRemotingScheme() {
- return "remote";
- }
-
- protected RemotingServiceDescriptor<ConnectionProviderFactory> getProtocolDescriptor() {
- return new RemoteProtocolDescriptor();
- }
- protected ServerPackage setupServer(ServerPackage sp, int id, TestRequestListener requestListener, String serviceType, String instanceName, int port) throws IOException {
-
- if (sp == null) {
- sp = new ServerPackage();
- }
-
- // Create and configure endpoint.
- if (sp.endpoint == null) {
- if (sp.executor == null) {
- sp.executor = new ThreadPoolExecutor(8, 64, 30, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(64));
- }
- sp.endpoint = Remoting.createEndpoint("endpoint" + id, sp.executor, OptionMap.EMPTY);
- final Registration reg1 = sp.endpoint.addProtocolService(ProtocolServiceType.MARSHALLER_PROVIDER_DESCRIPTOR, "river", new RiverProviderDescriptor());
- final Registration reg2 = sp.endpoint.addConnectionProvider(getRemotingScheme(), getProtocolDescriptor().getService(new Properties()));
- sp.endpoint.addCloseHandler(new CloseHandler<Endpoint>() {
- public void handleClose(final Endpoint closed) {
- reg1.close();
- reg2.close();
- }});
- }
-
- // Set up XNIO layer.
- OptionMap serverOptions = OptionMap.builder().setSequence(Options.SASL_MECHANISMS, "EXTERNAL", "DIGEST-MD5").getMap();
- SimpleServerAuthenticationProvider authenticationProvider = new SimpleServerAuthenticationProvider();
- authenticationProvider.addUser("user", sp.endpoint.getName(), "password".toCharArray());
- NetworkServerProvider provider = sp.endpoint.getConnectionProviderInterface(getRemotingScheme(), NetworkServerProvider.class);
- ChannelListener<ConnectedStreamChannel<InetSocketAddress>> listener = provider.getServerListener(serverOptions, authenticationProvider);
- if (sp.xnio == null) {
- sp.xnio = Xnio.getInstance(String.valueOf(id));
- }
- if (sp.tcpServer == null) {
- createTcpServer(sp, listener, port);
- }
-
- // Register service with endpoint.
- sp.requestListener = (requestListener == null) ? new TestRequestListener(id) : requestListener;
- if (sp.registration == null) {
- ServiceBuilder<Object, Object> sb = sp.endpoint.serviceBuilder(Object.class, Object.class);
- sb.setInstanceName(instanceName).setServiceType(serviceType);
- sb.setClientListener(new TestClientListener(sp.requestListener));
- sp.registration = sb.register();
- }
- return sp;
- }
-
- protected void createTcpServer(ServerPackage sp, ChannelListener<ConnectedStreamChannel<InetSocketAddress>> listener, int port) throws IOException {
- log.info(this + " creating TcpServer");
- TcpServer tcpServer = sp.xnio.createTcpServer(listener, OptionMap.EMPTY);
- IoFuture<? extends BoundChannel<InetSocketAddress>> future = tcpServer.bind(new InetSocketAddress("localhost", port));
- getFutureResult(future, "unable to bind " + sp.tcpServer);
- sp.tcpServer = tcpServer;
- sp.port = tcpServer.getChannels().iterator().next().getLocalAddress().getPort();
- }
-
protected Connection setupConnection(int port) throws IOException, URISyntaxException {
Endpoint endpoint = Remoting.getConfiguredEndpoint();
URI uri = new URI(getRemotingScheme() + "://localhost:" + port);
@@ -611,10 +593,6 @@
return connection;
}
- protected OptionMap getConnectionOptionMap() {
- return OptionMap.EMPTY;
- }
-
protected Client<Object, Object> setupClient(Connection connection, String serviceType, String instanceName) throws IOException, URISyntaxException {
Client<Object, Object> client = getFutureResult(connection.openClient(serviceType, instanceName, Object.class, Object.class), "unable to open client to " + serviceType + ":" + instanceName);
return client;
@@ -643,76 +621,6 @@
}
}
- static class TestClientListener implements ClientListener<Object, Object> {
- private RequestListener<Object, Object> requestListener;
-
- TestClientListener(RequestListener<Object, Object> requestListener) {
- this.requestListener = requestListener;
- }
-
- public RequestListener<Object, Object> handleClientOpen(final ClientContext clientContext, final OptionMap optionMap) {
- clientContext.addCloseHandler(new CloseHandler<ClientContext>() {
- public void handleClose(final ClientContext closed) {
- log.info("Client closed");
- }
- });
- return requestListener;
- }
- }
-
- static class ServerPackage {
- public ThreadPoolExecutor executor;
- public Endpoint endpoint;
- public Xnio xnio;
- public AcceptingServer<?, ?, ?> tcpServer;
- public TestRequestListener requestListener;
- public Registration registration;
- public int port;
-
- public ServerPackage(ThreadPoolExecutor executor, Endpoint endpoint, Xnio xnio, AcceptingServer<?, ?, ?> tcpServer, TestRequestListener requestListener, Registration registration, int port) {
- this.executor = executor;
- this.endpoint = endpoint;
- this.xnio = xnio;
- this.tcpServer = tcpServer;
- this.requestListener = requestListener;
- this.registration = registration;
- this.port = port;
- }
-
- public ServerPackage() {
- }
-
- public void close() {
- if (executor != null) {
- executor.shutdown();
- }
- if (endpoint != null) {
- try {
- endpoint.close();
- } catch (IOException e) {
- log.error("unable to close " + endpoint);
- }
- }
- if (xnio != null) {
- try {
- xnio.close();
- } catch (IOException e) {
- log.error("unable to close " + xnio);
- }
- }
- if (tcpServer != null) {
- try {
- tcpServer.close();
- } catch (IOException e) {
- log.error("unable to close " + tcpServer);
- }
- }
- if (registration != null) {
- registration.close();
- }
- }
- }
-
static class ConnectionSet extends HashSet<Connection> {
private static final long serialVersionUID = 1L;
14 years, 2 months
JBoss Remoting SVN: r6085 - remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-09-07 15:28:13 -0400 (Tue, 07 Sep 2010)
New Revision: 6085
Modified:
remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/AttachmentsTestCase.java
Log:
JBREM-1228: Extends RemotingRootTestBase instead of RemotingTestBase.
Modified: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/AttachmentsTestCase.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/AttachmentsTestCase.java 2010-09-07 19:27:15 UTC (rev 6084)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/AttachmentsTestCase.java 2010-09-07 19:28:13 UTC (rev 6085)
@@ -51,7 +51,7 @@
* Copyright August 27, 2010
*/
@Test(suiteName = "Attachments")
-public class AttachmentsTestCase extends RemotingTestBase {
+public class AttachmentsTestCase extends RemotingRootTestBase {
private static final Logger log = Logger.getLogger(AttachmentsTestCase.class);
14 years, 2 months
JBoss Remoting SVN: r6084 - remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-09-07 15:27:15 -0400 (Tue, 07 Sep 2010)
New Revision: 6084
Added:
remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/RemotingLocalTestBase.java
remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/RemotingRootTestBase.java
Modified:
remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/RemotingTestBase.java
Log:
JBREM-1228: Broke RemotingTestBase into RemotingRootTestBase, RemotingLocalTestBase, and RemotingTestBase.
Added: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/RemotingLocalTestBase.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/RemotingLocalTestBase.java (rev 0)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/RemotingLocalTestBase.java 2010-09-07 19:27:15 UTC (rev 6084)
@@ -0,0 +1,170 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting3.test;
+
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNotSame;
+import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import org.jboss.marshalling.river.RiverProviderDescriptor;
+import org.jboss.remoting3.ClientContext;
+import org.jboss.remoting3.ClientListener;
+import org.jboss.remoting3.CloseHandler;
+import org.jboss.remoting3.Endpoint;
+import org.jboss.remoting3.Registration;
+import org.jboss.remoting3.Remoting;
+import org.jboss.remoting3.RequestListener;
+import org.jboss.remoting3.Endpoint.ServiceBuilder;
+import org.jboss.remoting3.spi.ProtocolServiceType;
+import org.jboss.remoting3.test.ClientServerRemoteConfigurationTestCase.TestRequestListener;
+import org.jboss.xnio.AcceptingServer;
+import org.jboss.xnio.IoFuture;
+import org.jboss.xnio.OptionMap;
+import org.jboss.xnio.Xnio;
+import org.jboss.xnio.IoFuture.Status;
+import org.jboss.xnio.log.Logger;
+
+/**
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Jun 23, 2010
+ */
+@SuppressWarnings("unused")
+public class RemotingLocalTestBase extends RemotingRootTestBase {
+ private static final Logger log = Logger.getLogger(RemotingLocalTestBase.class);
+
+ protected ServerPackage setupServer(ServerPackage sp, int id, RequestListener<Object, Object> requestListener, String serviceType, String instanceName) throws IOException {
+
+ if (sp == null) {
+ sp = new ServerPackage();
+ }
+
+ // Create and configure endpoint.
+ if (sp.endpoint == null) {
+ if (sp.executor == null) {
+ sp.executor = new ThreadPoolExecutor(8, 64, 30, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(64));
+ }
+ sp.endpoint = Remoting.createEndpoint("endpoint" + id, sp.executor, OptionMap.EMPTY);
+ final Registration reg = sp.endpoint.addProtocolService(ProtocolServiceType.MARSHALLER_PROVIDER_DESCRIPTOR, "river", new RiverProviderDescriptor());
+ sp.endpoint.addCloseHandler(new CloseHandler<Endpoint>() {
+ public void handleClose(final Endpoint closed) {
+ reg.close();
+ }});
+ addConnectionProvider(sp, id);
+ }
+
+ // Register service with endpoint.
+ sp.requestListener = requestListener;
+ if (sp.registration == null) {
+ ServiceBuilder<Object, Object> sb = sp.endpoint.serviceBuilder(Object.class, Object.class);
+ sb.setInstanceName(instanceName).setServiceType(serviceType);
+ sb.setClientListener(new TestClientListener(sp.requestListener));
+ sp.registration = sb.register();
+ }
+ return sp;
+ }
+
+ protected void addConnectionProvider(ServerPackage sp, int id) throws IOException {
+ }
+
+ public static class ServerPackage {
+ public ThreadPoolExecutor executor;
+ public Endpoint endpoint;
+ public Xnio xnio;
+ public AcceptingServer<?, ?, ?> tcpServer;
+ public RequestListener<Object, Object> requestListener;
+ public Registration registration;
+ public int port;
+
+ public ServerPackage(ThreadPoolExecutor executor, Endpoint endpoint, Xnio xnio, AcceptingServer<?, ?, ?> tcpServer, RequestListener<Object, Object> requestListener, Registration registration, int port) {
+ this.executor = executor;
+ this.endpoint = endpoint;
+ this.xnio = xnio;
+ this.tcpServer = tcpServer;
+ this.requestListener = requestListener;
+ this.registration = registration;
+ this.port = port;
+ }
+
+ public ServerPackage() {
+ }
+
+ public void close() {
+ if (executor != null) {
+ executor.shutdown();
+ }
+ if (endpoint != null) {
+ try {
+ endpoint.close();
+ } catch (IOException e) {
+ log.error("unable to close " + endpoint);
+ }
+ }
+ if (xnio != null) {
+ try {
+ xnio.close();
+ } catch (IOException e) {
+ log.error("unable to close " + xnio);
+ }
+ }
+ if (tcpServer != null) {
+ try {
+ tcpServer.close();
+ } catch (IOException e) {
+ log.error("unable to close " + tcpServer);
+ }
+ }
+ if (registration != null) {
+ registration.close();
+ }
+ }
+ }
+
+ static class TestClientListener implements ClientListener<Object, Object> {
+ private RequestListener<Object, Object> requestListener;
+
+ TestClientListener(RequestListener<Object, Object> requestListener) {
+ this.requestListener = requestListener;
+ }
+
+ public RequestListener<Object, Object> handleClientOpen(final ClientContext clientContext, final OptionMap optionMap) {
+ clientContext.addCloseHandler(new CloseHandler<ClientContext>() {
+ public void handleClose(final ClientContext closed) {
+ log.debug("Client closed");
+ }
+ });
+ return requestListener;
+ }
+ }
+}
Added: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/RemotingRootTestBase.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/RemotingRootTestBase.java (rev 0)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/RemotingRootTestBase.java 2010-09-07 19:27:15 UTC (rev 6084)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting3.test;
+
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNotSame;
+import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import org.jboss.marshalling.river.RiverProviderDescriptor;
+import org.jboss.remoting3.ClientContext;
+import org.jboss.remoting3.ClientListener;
+import org.jboss.remoting3.CloseHandler;
+import org.jboss.remoting3.Endpoint;
+import org.jboss.remoting3.Registration;
+import org.jboss.remoting3.Remoting;
+import org.jboss.remoting3.RequestListener;
+import org.jboss.remoting3.Endpoint.ServiceBuilder;
+import org.jboss.remoting3.spi.ProtocolServiceType;
+import org.jboss.remoting3.test.ClientServerRemoteConfigurationTestCase.TestRequestListener;
+import org.jboss.xnio.AcceptingServer;
+import org.jboss.xnio.IoFuture;
+import org.jboss.xnio.OptionMap;
+import org.jboss.xnio.Xnio;
+import org.jboss.xnio.IoFuture.Status;
+import org.jboss.xnio.log.Logger;
+
+/**
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Jun 23, 2010
+ */
+@SuppressWarnings("unused")
+public class RemotingRootTestBase {
+ private static final Logger log = Logger.getLogger(RemotingRootTestBase.class);
+
+ protected String getName() {
+ final StackTraceElement e = new Throwable().getStackTrace()[1];
+ return e.getMethodName();
+ }
+
+ protected static void enter() {
+ final StackTraceElement e = new Throwable().getStackTrace()[1];
+ log.info("Entering: %s#%s", e.getClassName(), e.getMethodName());
+ }
+
+ protected static void exit() {
+ final StackTraceElement e = new Throwable().getStackTrace()[1];
+ log.info("Exiting: %s#%s", e.getClassName(), e.getMethodName());
+ log.info("-------------------------------------------------------------");
+ }
+
+ protected static <T> T getFutureResult(IoFuture<T> future, String errorMessage) throws IOException {
+ return getFutureResult(future, 5000, errorMessage);
+ }
+
+ protected static <T> T getFutureResult(IoFuture<T> future, int timeout, String errorMessage) throws IOException {
+ Status status = null;
+ switch (status = future.await(timeout, TimeUnit.MILLISECONDS)) {
+ case DONE: {
+ return future.get();
+ }
+ case FAILED: {
+ log.error(errorMessage);
+ throw future.getException();
+ }
+ default: {
+ throw new RuntimeException("unexpected future state: " + status);
+ }
+ }
+ }
+}
Modified: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/RemotingTestBase.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/RemotingTestBase.java 2010-09-07 17:38:21 UTC (rev 6083)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/RemotingTestBase.java 2010-09-07 19:27:15 UTC (rev 6084)
@@ -22,11 +22,49 @@
package org.jboss.remoting3.test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNotSame;
+import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Properties;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+import org.jboss.marshalling.river.RiverProviderDescriptor;
+import org.jboss.remoting3.CloseHandler;
+import org.jboss.remoting3.Connection;
+import org.jboss.remoting3.Endpoint;
+import org.jboss.remoting3.Registration;
+import org.jboss.remoting3.Remoting;
+import org.jboss.remoting3.RequestListener;
+import org.jboss.remoting3.Endpoint.ServiceBuilder;
+import org.jboss.remoting3.remote.RemoteProtocolDescriptor;
+import org.jboss.remoting3.security.SimpleServerAuthenticationProvider;
+import org.jboss.remoting3.spi.ConnectionProviderFactory;
+import org.jboss.remoting3.spi.NetworkServerProvider;
+import org.jboss.remoting3.spi.ProtocolServiceType;
+import org.jboss.remoting3.spi.RemotingServiceDescriptor;
+import org.jboss.remoting3.test.ClientServerRemoteConfigurationTestCase.TestRequestListener;
+import org.jboss.remoting3.test.RemotingLocalTestBase.ServerPackage;
+import org.jboss.xnio.AcceptingServer;
+import org.jboss.xnio.ChannelListener;
import org.jboss.xnio.IoFuture;
+import org.jboss.xnio.OptionMap;
+import org.jboss.xnio.Options;
+import org.jboss.xnio.TcpServer;
+import org.jboss.xnio.Xnio;
import org.jboss.xnio.IoFuture.Status;
+import org.jboss.xnio.channels.BoundChannel;
+import org.jboss.xnio.channels.ConnectedStreamChannel;
import org.jboss.xnio.log.Logger;
/**
@@ -36,42 +74,65 @@
* <p>
* Copyright Jun 23, 2010
*/
-public class RemotingTestBase {
+@SuppressWarnings("unused")
+public class RemotingTestBase extends RemotingLocalTestBase {
private static final Logger log = Logger.getLogger(RemotingTestBase.class);
- protected String getName() {
- final StackTraceElement e = new Throwable().getStackTrace()[1];
- return e.getMethodName();
+ protected ServerPackage setupServer(ServerPackage sp, int id, RequestListener<Object, Object> requestListener, String serviceType, String instanceName) throws IOException {
+
+ ServerPackage sp2 = super.setupServer(sp, id, requestListener, serviceType, instanceName);
+
+// Set up XNIO layer.
+ OptionMap serverOptions = OptionMap.builder().setSequence(Options.SASL_MECHANISMS, "EXTERNAL", "DIGEST-MD5").getMap();
+ SimpleServerAuthenticationProvider authenticationProvider = new SimpleServerAuthenticationProvider();
+ authenticationProvider.addUser("user", sp2.endpoint.getName(), "password".toCharArray());
+ NetworkServerProvider provider = sp2.endpoint.getConnectionProviderInterface(getRemotingScheme(), NetworkServerProvider.class);
+ ChannelListener<ConnectedStreamChannel<InetSocketAddress>> listener = provider.getServerListener(serverOptions, authenticationProvider);
+ if (sp2.xnio == null) {
+ sp2.xnio = Xnio.getInstance(String.valueOf(id));
+ }
+ if (sp2.tcpServer == null) {
+ createTcpServer(sp2, listener);
+ }
+
+ return sp2;
}
- protected static void enter() {
- final StackTraceElement e = new Throwable().getStackTrace()[1];
- log.info("Entering: %s#%s", e.getClassName(), e.getMethodName());
+ protected void addConnectionProvider(ServerPackage sp, int id) throws IOException {
+ Properties props = new Properties();
+ props.put("remote.xnio.provider", String.valueOf(id));
+ final Registration reg = sp.endpoint.addConnectionProvider(getRemotingScheme(), getProtocolDescriptor().getService(props));
+ sp.endpoint.addCloseHandler(new CloseHandler<Endpoint>() {
+ public void handleClose(final Endpoint closed) {
+ reg.close();
+ }});
}
-
- protected static void exit() {
- final StackTraceElement e = new Throwable().getStackTrace()[1];
- log.info("Exiting: %s#%s", e.getClassName(), e.getMethodName());
- log.info("-------------------------------------------------------------");
+
+ protected String getRemotingScheme() {
+ return "remote";
}
- protected static <T> T getFutureResult(IoFuture<T> future, String errorMessage) throws IOException {
- return getFutureResult(future, 5000, errorMessage);
+ protected RemotingServiceDescriptor<ConnectionProviderFactory> getProtocolDescriptor() {
+ return new RemoteProtocolDescriptor();
}
- protected static <T> T getFutureResult(IoFuture<T> future, int timeout, String errorMessage) throws IOException {
- Status status = null;
- switch (status = future.await(timeout, TimeUnit.MILLISECONDS)) {
- case DONE: {
- return future.get();
- }
- case FAILED: {
- log.error(errorMessage);
- throw future.getException();
- }
- default: {
- throw new RuntimeException("unexpected future state: " + status);
- }
- }
+ protected OptionMap getConnectionOptionMap() {
+ return OptionMap.EMPTY;
}
+
+ protected void createTcpServer(ServerPackage sp, ChannelListener<ConnectedStreamChannel<InetSocketAddress>> listener) throws IOException {
+ log.debug(this + " creating TcpServer");
+ TcpServer tcpServer = sp.xnio.createTcpServer(listener, OptionMap.EMPTY);
+ IoFuture<? extends BoundChannel<InetSocketAddress>> future = tcpServer.bind(new InetSocketAddress("localhost", 0));
+ getFutureResult(future, "unable to bind " + sp.tcpServer);
+ sp.tcpServer = tcpServer;
+ sp.port = tcpServer.getChannels().iterator().next().getLocalAddress().getPort();
+ }
+
+ protected Connection setupConnection(ServerPackage localServerPackage, ServerPackage remoteServerPackage) throws IOException, URISyntaxException {
+ Endpoint endpoint = localServerPackage.endpoint;
+ URI uri = new URI(getRemotingScheme() + "://localhost:" + remoteServerPackage.port);
+ Connection connection = getFutureResult(endpoint.connect(uri, getConnectionOptionMap(), "user", null, "password".toCharArray()), "unable to connect to " + uri);
+ return connection;
+ }
}
14 years, 2 months
JBoss Remoting SVN: r6083 - remoting2/branches/2.x/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-09-07 13:38:21 -0400 (Tue, 07 Sep 2010)
New Revision: 6083
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/Client.java
Log:
JBREM-1242: In setupClientLease(), synchronized call to invoker.establishLease() on connectionValidatorLock.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/Client.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/Client.java 2010-09-07 17:18:29 UTC (rev 6082)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/Client.java 2010-09-07 17:38:21 UTC (rev 6083)
@@ -2018,7 +2018,26 @@
temp.put(CONNECTION_LISTENER, listener);
}
if (trace) log.trace(this + " calling MicroRemoteClientInvoker.establishLease()");
- invoker.establishLease(sessionId, temp, leasePeriod);
+
+ // Synchronizing on connectionValidatorLock to prevent a deadlock:
+ //
+ // 1. a. This method calls MicroRemoteClientInvoker.establishLease()
+ // b. MicroRemoteClientInvoker.establishLease() synchronizes on MicroRemoteClientInvoker.clientLeaseLock
+ // and calls Client.addConnectionListener()
+ // c. Client.addConnectionListener() synchronizes on Client.connectionValidatorLock
+ //
+ // 2. a. Client.addConnectionListener() synchronizes on Client.connectionValidatorLock and calls
+ // new ConnectionValidator()
+ // b. new ConnectionValidator() calls MicroRemoteClientInvoker.getLeasePinger(), which
+ // synchronizes on MicroRemoteClientInvoker.clientLeaseLock
+ //
+ // By synchronizing on connectionValidatorLock here, we assure that both sequences acquire
+ // Client.connectionValidatorLock first and then acquire MicroRemoteClientInvoker.clientLeaseLock.
+ //
+ synchronized(connectionValidatorLock)
+ {
+ invoker.establishLease(sessionId, temp, leasePeriod);
+ }
}
else if (listener != null)
{
14 years, 2 months
JBoss Remoting SVN: r6082 - remoting2/branches/2.2/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-09-07 13:18:29 -0400 (Tue, 07 Sep 2010)
New Revision: 6082
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/Client.java
Log:
JBREM-1242: In setupClientLease(), synchronized call to invoker.establishLease() on connectionValidatorLock.
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/Client.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/Client.java 2010-09-07 13:27:25 UTC (rev 6081)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/Client.java 2010-09-07 17:18:29 UTC (rev 6082)
@@ -1920,7 +1920,26 @@
temp.put(CONNECTION_LISTENER, listener);
}
if (trace) log.trace(this + " calling MicroRemoteClientInvoker.establishLease()");
- invoker.establishLease(sessionId, temp, leasePeriod);
+
+ // Synchronizing on connectionValidatorLock to prevent a deadlock:
+ //
+ // 1. a. This method calls MicroRemoteClientInvoker.establishLease()
+ // b. MicroRemoteClientInvoker.establishLease() synchronizes on MicroRemoteClientInvoker.clientLeaseLock
+ // and calls Client.addConnectionListener()
+ // c. Client.addConnectionListener() synchronizes on Client.connectionValidatorLock
+ //
+ // 2. a. Client.addConnectionListener() synchronizes on Client.connectionValidatorLock and calls
+ // new ConnectionValidator()
+ // b. new ConnectionValidator() calls MicroRemoteClientInvoker.getLeasePinger(), which
+ // synchronizes on MicroRemoteClientInvoker.clientLeaseLock
+ //
+ // By synchronizing on connectionValidatorLock here, we assure that both sequences acquire
+ // Client.connectionValidatorLock first and then acquire MicroRemoteClientInvoker.clientLeaseLock.
+ //
+ synchronized(connectionValidatorLock)
+ {
+ invoker.establishLease(sessionId, temp, leasePeriod);
+ }
}
else if (listener != null)
{
14 years, 2 months
JBoss Remoting SVN: r6081 - remoting2/branches.
by jboss-remoting-commits@lists.jboss.org
Author: jbertram(a)redhat.com
Date: 2010-09-07 09:27:25 -0400 (Tue, 07 Sep 2010)
New Revision: 6081
Added:
remoting2/branches/2.2.3-SP2_JBREM-1242/
Log:
JBPAPP-5030
Copied: remoting2/branches/2.2.3-SP2_JBREM-1242 (from rev 6080, remoting2/tags/2.2.3-SP2)
14 years, 2 months