JBoss Remoting SVN: r5461 - remoting2/branches/2.2/docs/guide/en.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-09-12 17:03:11 -0400 (Sat, 12 Sep 2009)
New Revision: 5461
Modified:
remoting2/branches/2.2/docs/guide/en/chap4.xml
Log:
JBREM-1151: Updated dependencies.
Modified: remoting2/branches/2.2/docs/guide/en/chap4.xml
===================================================================
--- remoting2/branches/2.2/docs/guide/en/chap4.xml 2009-09-12 16:27:21 UTC (rev 5460)
+++ remoting2/branches/2.2/docs/guide/en/chap4.xml 2009-09-12 21:03:11 UTC (rev 5461)
@@ -9,7 +9,8 @@
<para><emphasis role="bold">jboss-remoting.jar</emphasis> - this binary
contains all the remoting classes. This is the only remoting jar that is
- needed to perform any remoting function within JBoss Remoting.</para>
+ needed to perform any remoting function within JBoss Remoting. Of course,
+ third party jars will be required.</para>
<para>Since some may want to better control size of the binary footprint
needed to use remoting, the remoting classes have been broken out into
@@ -63,8 +64,7 @@
<para><emphasis role="bold">jboss-remoting-multiplex.jar</emphasis> -
contains all the classes needed for the multiplex and sslmultiplex
- transports to function as a client and a server. Use of this jar also
- requires jboss-remoting-socket.jar be on classpath as well.</para>
+ transports to function as a client and a server.</para>
<para><emphasis role="bold">jboss-remoting-bisocket.jar</emphasis> -
contains all the classes needed for the bisocket and sslbisocket transports
@@ -87,72 +87,194 @@
functions.</para>
<section>
- <title>Thirdparty libraries</title>
+ <title>Third party libraries</title>
<para>This section covers which thirdparty jars are required based on
- the feature or transport to be used. Remember, whenever see
- jboss-remoting-XXX.jar mentioned, they can all be replaced with just the
+ the feature or transport to be used. Remember, any
+ jboss-remoting-XXX.jar can be replaced with just the
jboss-remoting.jar.</para>
+
+ <para> Table 1 gives the direct dependencies of the Remoting jars on
+ third party jars (and jboss-remoting-core.jar, in most cases). Table 2
+ gives the transitive closure of Table 1.</para>
- <para><emphasis role="bold">All remoting servers:</emphasis>
- jboss-remoting-core.jar, jboss-common.jar, jboss-jmx.jar,
- log4j.jar</para>
+ <table frame="all" id="JarDependencyTable" xreflabel="Table 1">
+ <title>Jar dependencies.</title>
- <para><emphasis role="bold">All remoting clients:
- </emphasis>jboss-remoting-core.jar, jboss-common.jar, jboss-jmx.jar,
- log4j.jar, concurrent.jar</para>
+ <tgroup cols="2">
+ <colspec align="left" colname="c1" colnum="1" />
+ <colspec align="left" colname="c2" colnum="2" />
- <para>Note: concurrent.jar needed because of org.jboss.util.id.GUID used
- to create session id within Client
- (http://jira.jboss.com/jira/browse/JBREM-549)</para>
+ <thead>
+ <row>
+ <entry align="center"><para>jar</para></entry>
+ <entry align="center"><para>depends on</para></entry>
+ </row>
+ </thead>
- <para>Remoting requires the use of JMX classes. It does not require the
+ <tbody>
+ <row>
+ <entry><para>jboss-remoting-bisocket-client.jar:</para></entry>
+ <entry><para>concurrent.jar, jboss-common.jar, jboss-remoting-core.jar, jboss-serialization.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting-bisocket.jar:</para></entry>
+ <entry><para>concurrent.jar, jboss-common.jar, jboss-remoting-core.jar, jboss-serialization.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting-core.jar:</para></entry>
+ <entry><para>concurrent.jar, jboss-common.jar, jboss-jmx.jar, jboss-serialization.jar, log4j.jar, saxon.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting-detection.jar:</para></entry>
+ <entry><para>jboss-common.jar, jboss-jmx.jar, jboss-remoting-core.jar, jnpserver.jar, log4j.jar, saxon.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting-http-client.jar:</para></entry>
+ <entry><para>jboss-common.jar, jboss-remoting-core.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting-http.jar:</para></entry>
+ <entry><para>commons-httpclient.jar, jboss-common.jar, jboss-jmx.jar, jboss-remoting-core.jar, tomcat-coyote.jar, tomcat-util.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting-multiplex.jar:</para></entry>
+ <entry><para>concurrent.jar, jboss-common.jar, jboss-jmx.jar, jboss-remoting-core.jar, jboss-serialization.jar, log4j.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting-rmi.jar:</para></entry>
+ <entry><para>jboss-common.jar, jboss-remoting-core.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting-samples.jar:</para></entry>
+ <entry><para>dom4j.jar, jboss-common.jar, jboss-jmx.jar, jboss-remoting-core.jar, jboss-remoting-detection.jar, jboss-remoting-multiplex.jar, jnpserver.jar, junit.jar, saxon.jar, servlet-api.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting-serialization.jar:</para></entry>
+ <entry><para>jboss-common.jar, jboss-remoting-core.jar, jboss-serialization.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting-servlet.jar:</para></entry>
+ <entry><para>jboss-common.jar, jboss-remoting-core.jar, servlet-api.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting-socket-client.jar:</para></entry>
+ <entry><para>concurrent.jar, jboss-common.jar, jboss-remoting-core.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting-socket.jar:</para></entry>
+ <entry><para>concurrent.jar, jboss-common.jar, jboss-remoting-core.jar, jboss-serialization.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting.jar:</para></entry>
+ <entry><para>commons-httpclient.jar, concurrent.jar, dom4j.jar, jboss-common.jar, jboss-jmx.jar, jboss-serialization.jar, jnpserver.jar, junit.jar, log4j.jar, saxon.jar, servlet-api.jar, tomcat-coyote.jar, tomcat-util.jar</para></entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </table>
+
+
+ <table frame="all" id="JarTransitiveDependencyTable" xreflabel="Table 1">
+ <title>Transitive closure of jar dependencies.</title>
+
+ <tgroup cols="2">
+ <colspec align="left" colname="c1" colnum="1" />
+ <colspec align="left" colname="c2" colnum="2" />
+
+ <thead>
+ <row>
+ <entry align="center"><para>jar</para></entry>
+ <entry align="center"><para>depends on</para></entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><para>jboss-remoting-bisocket-client.jar:</para></entry>
+ <entry><para>commons-httpclient.jar, commons-logging-api.jar, concurrent.jar, dom4j.jar, jboss-common.jar, jboss-jmx.jar, jboss-remoting-core.jar, [jboss-remoting-detection.jar], jboss-serialization.jar, [jnpserver.jar], log4j.jar, trove.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting-bisocket.jar:</para></entry>
+ <entry><para>commons-httpclient.jar, commons-logging-api.jar, concurrent.jar, dom4j.jar, jboss-common.jar, jboss-jmx.jar, jboss-remoting-core.jar, [jboss-remoting-detection.jar], jboss-serialization.jar, [jnpserver.jar], log4j.jar, trove.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting-core.jar:</para></entry>
+ <entry><para>commons-httpclient.jar, commons-logging-api.jar, concurrent.jar, dom4j.jar, jboss-common.jar, jboss-jmx.jar, [jboss-remoting-detection.jar], jboss-serialization.jar, [jnpserver.jar], log4j.jar, trove.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting-detection.jar:</para></entry>
+ <entry><para>commons-httpclient.jar, commons-logging-api.jar, concurrent.jar, dom4j.jar, jboss-common.jar, jboss-jmx.jar, jboss-remoting-core.jar, jboss-serialization.jar, jnpserver.jar, log4j.jar, trove.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting-http-client.jar:</para></entry>
+ <entry><para>commons-httpclient.jar, commons-logging-api.jar, concurrent.jar, dom4j.jar, jboss-common.jar, jboss-jmx.jar, jboss-remoting-core.jar, [jboss-remoting-detection.jar], jboss-serialization.jar, [jnpserver.jar], log4j.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting-http.jar:</para></entry>
+ <entry><para>commons-httpclient.jar, commons-logging-api.jar, concurrent.jar, dom4j.jar, jboss-common.jar, jboss-jmx.jar, jboss-remoting-core.jar, [jboss-remoting-detection.jar], jboss-serialization.jar, [jnpserver.jar], log4j.jar, trove.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting-multiplex.jar:</para></entry>
+ <entry><para>commons-httpclient.jar, commons-logging-api.jar, concurrent.jar, dom4j.jar, jboss-common.jar, jboss-jmx.jar, jboss-remoting-core.jar, [jboss-remoting-detection.jar], jboss-serialization.jar, [jnpserver.jar], log4j.jar, trove.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting-rmi.jar:</para></entry>
+ <entry><para>commons-httpclient.jar, commons-logging-api.jar, concurrent.jar, dom4j.jar, jboss-common.jar, jboss-jmx.jar, jboss-remoting-core.jar, [jboss-remoting-detection.jar], jboss-serialization.jar, [jnpserver.jar], log4j.jar, trove.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting-samples.jar:</para></entry>
+ <entry><para>commons-httpclient.jar, commons-logging-api.jar, concurrent.jar, dom4j.jar, jboss-common.jar, jboss-jmx.jar, jboss-remoting-core.jar, jboss-remoting-detection.jar, jboss-remoting-multiplex.jar, jboss-serialization.jar, jnpserver.jar, junit.jar, log4j.jar, servlet-api.jar, trove.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting-serialization.jar:</para></entry>
+ <entry><para>commons-httpclient.jar, commons-logging-api.jar, concurrent.jar, dom4j.jar, jboss-common.jar, jboss-jmx.jar, jboss-remoting-core.jar, [jboss-remoting-detection.jar], jboss-serialization.jar, [jnpserver.jar], log4j.jar, trove.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting-servlet.jar:</para></entry>
+ <entry><para>commons-httpclient.jar, commons-logging-api.jar, concurrent.jar, dom4j.jar, jboss-common.jar, jboss-jmx.jar, jboss-remoting-core.jar, [jboss-remoting-detection.jar], jboss-serialization.jar, [jnpserver.jar], log4j.jar, servlet-api.jar, trove.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting-socket-client.jar:</para></entry>
+ <entry><para>commons-httpclient.jar, commons-logging-api.jar, concurrent.jar, dom4j.jar, jboss-common.jar, jboss-jmx.jar, jboss-remoting-core.jar, [jboss-remoting-detection.jar], jboss-serialization.jar, [jnpserver.jar], log4j.jar, trove.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting-socket.jar:</para></entry>
+ <entry><para>commons-httpclient.jar, commons-logging-api.jar, concurrent.jar, dom4j.jar, jboss-common.jar, jboss-jmx.jar, jboss-remoting-core.jar, [jboss-remoting-detection.jar], jboss-serialization.jar, [jnpserver.jar], log4j.jar, trove.jar</para></entry>
+ </row>
+ <row>
+ <entry><para>jboss-remoting.jar:</para></entry>
+ <entry><para>commons-httpclient.jar, commons-logging-api.jar, concurrent.jar, dom4j.jar, jboss-common.jar, jboss-jmx.jar, jboss-remoting-detection.jar, jboss-serialization.jar, jnpserver.jar, junit.jar, log4j.jar, servlet-api.jar, tomcat-apr.jar, tomcat-coyote.jar, tomcat-util.jar, trove.jar</para></entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para><emphasis role="bold">Notes.</emphasis></para>
+
+ <para>1. jboss-common.jar needs commons-httpclient.jar, which explains
+ the transitive dependency of all Remoting jars on commons-httpclient.jar.
+ Also, commons-httpclient.jar needs commons-logging-api.jar.</para>
+
+ <para>2. Remoting requires the use of JMX classes. It does not require the
JBoss implementation (jboss-jmx.jar) of JMX in order to function
correctly, so can replace jboss-jmx.jar with another JMX implementation
library (or exclude it if using jdk 1.5 or higher, which has JMX
implementation built in).</para>
-
- <para><emphasis role="bold">Multicast detection:
- </emphasis>jboss-remoting-detection.jar, concurrent.jar,
- dom4j.jar</para>
-
- <para><emphasis role="bold">JNDI detection:</emphasis>
+
+ <para>3. Multicast detection requires jboss-remoting-detection.jar, concurrent.jar,
+ dom4j.jar. JNDI detection: requires
jboss-remoting-detection.jar, concurrent.jar, dom4j.jar, jnpserver.jar
- (for jndi api classes)</para>
-
- <para>The dom4j.jar for use of detection is required because using
+ (for jndi api classes). dom4j.jar for use of detection is required by
jboss-jmx.jar.</para>
+
+ <para>4. jboss-remoting-core contains the transporter classes, and some of those
+ need jboss-remoting-detection.jar, which explains the proliferation of
+ jboss-remoting-detection.jar in Table 2. If transporters are not used,
+ then jboss-remoting-detection.jar can be omitted. Moreover, JNDI detection
+ requires jnpserver.jar, so that, if transporters are not used, jnpserver.jar
+ can be omitted.</para>
- <para><emphasis role="bold">Socket server:</emphasis>
- jboss-remoting-socket.jar</para>
-
- <para><emphasis role="bold">Socket client:</emphasis>
- jboss-remoting-socket-client.jar</para>
-
- <para><emphasis role="bold">HTTP server:</emphasis>
- jboss-remoting-http.jar, tomcat-coyote.jar, tomcat-util.jar,
- commons-logging-api.jar, tomcat-http.jar</para>
-
- <para>Note: need tomcat-apr.jar and tcnative-1.dll/tcnative-1.so on
- system path if want to use APR based tomcat connector</para>
-
- <para><emphasis role="bold">HTTP client:</emphasis>
- jboss-remoting-http-client.jar</para>
-
- <para><emphasis role="bold">Servlet server:</emphasis>
- servlet-invoker.war (deployed in web container),
- jboss-remoting-servlet.jar</para>
-
- <para><emphasis role="bold">Servlet client:</emphasis>
- jboss-remoting-http-client.jar</para>
-
- <para><emphasis role="bold">RMI server and client:</emphasis>
- jboss-remoting-rmi.jar</para>
-
- <para><emphasis role="bold">Multiplex server and client:</emphasis>
- jboss-remoting-socket.jar, jboss-remoting-multiplex.jar</para>
-
- <para><emphasis role="bold">JBoss serialization:</emphasis>
- jboss-serialization.jar, trove.jar</para>
</section>
</chapter>
\ No newline at end of file
15 years, 3 months
JBoss Remoting SVN: r5460 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/lease.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-09-12 12:27:21 -0400 (Sat, 12 Sep 2009)
New Revision: 5460
Added:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/lease/LeaseCreationFailureTestCase.java
Log:
JBREM-1154: New unit test.
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/lease/LeaseCreationFailureTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/lease/LeaseCreationFailureTestCase.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/lease/LeaseCreationFailureTestCase.java 2009-09-12 16:27:21 UTC (rev 5460)
@@ -0,0 +1,360 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.remoting.lease;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+import javax.net.SocketFactory;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.remoting.CannotConnectException;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.ConnectionListener;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.Remoting;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+
+
+/**
+ * Unit test for JBREM-1154.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Sep 11, 2009
+ * </p>
+ */
+public class LeaseCreationFailureTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(LeaseCreationFailureTestCase.class);
+
+ private static boolean firstTime = true;
+
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected InvokerLocator serverLocator;
+ protected Connector connector;
+ protected TestInvocationHandler invocationHandler;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(Level.TRACE);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testLeaseCreationFailure() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(Remoting.SOCKET_FACTORY_NAME, TestSocketFactory.class.getName());
+ clientConfig.put(Client.ENABLE_LEASE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+
+ // Verify that Client.connect() throws Exception if LeasePinger.addClient() fails.
+ try
+ {
+ client.connect();
+ fail("expected exception");
+ }
+ catch (CannotConnectException e)
+ {
+ log.info("got exception", e);
+ assertEquals("got wrong exception", "Error setting up client lease upon performing connect.", e.getMessage());
+ }
+ catch (Throwable t)
+ {
+ log.info("got wrong exception", t);
+ fail("got wrong exception");
+ }
+ assertFalse(client.isConnected());
+
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected String getTransport()
+ {
+ return "socket";
+ }
+
+
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+
+
+ protected void setupServer() throws Exception
+ {
+ host = InetAddress.getLocalHost().getHostAddress();
+ port = PortUtil.findFreePort(host);
+ locatorURI = getTransport() + "://" + host + ":" + port;
+ String metadata = System.getProperty("remoting.metadata");
+ if (metadata != null)
+ {
+ locatorURI += "/?" + metadata;
+ }
+ serverLocator = new InvokerLocator(locatorURI);
+ log.info("Starting remoting server with locator uri of: " + locatorURI);
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ config.put("clientLeasePeriod", "1000");
+ addExtraServerConfig(config);
+ connector = new Connector(serverLocator, config);
+ connector.create();
+ invocationHandler = new TestInvocationHandler();
+ connector.addInvocationHandler("test", invocationHandler);
+ connector.addConnectionListener(new TestConnectionListener());
+ connector.start();
+ }
+
+
+ protected void shutdownServer() throws Exception
+ {
+ if (connector != null)
+ connector.stop();
+ }
+
+
+ static class TestInvocationHandler implements ServerInvocationHandler
+ {
+ public void addListener(InvokerCallbackHandler callbackHandler) {}
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ return invocation.getParameter();
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
+
+
+ static class TestConnectionListener implements ConnectionListener
+ {
+ public void handleConnectionException(Throwable throwable, Client client)
+ {
+ }
+ }
+
+
+ public static class TestSocketFactory extends SocketFactory
+ {
+ int initialSuccesses = 2;
+
+ public TestSocketFactory()
+ {
+ }
+ public TestSocketFactory(int initialSuccesses)
+ {
+ this.initialSuccesses = initialSuccesses;
+ }
+ public Socket createSocket()
+ {
+ Socket s = new TestSocket(initialSuccesses);
+ log.info("returning " + s);
+ return s;
+ }
+ public Socket createSocket(String arg0, int arg1) throws IOException, UnknownHostException
+ {
+ Socket s = new TestSocket(arg0, arg1, initialSuccesses);
+ log.info("returning " + s);
+ return s;
+ }
+
+ public Socket createSocket(InetAddress arg0, int arg1) throws IOException
+ {
+ Socket s = new TestSocket(arg0, arg1, initialSuccesses);
+ log.info("returning " + s);
+ return s;
+ }
+
+ public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) throws IOException, UnknownHostException
+ {
+ Socket s = new TestSocket(arg0, arg1, arg2, arg3, initialSuccesses);
+ log.info("returning " + s);
+ return s;
+ }
+
+ public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3) throws IOException
+ {
+ Socket s = new TestSocket(arg0, arg1, arg2, arg3, initialSuccesses);
+ log.info("returning " + s);
+ return s;
+ }
+ }
+
+
+ static class TestSocket extends Socket
+ {
+ int initialSuccesses;
+
+ public TestSocket(int initialWrites)
+ {
+ this.initialSuccesses = initialWrites;
+ }
+ public TestSocket(String host, int port, int initialWrites) throws UnknownHostException, IOException
+ {
+ super(host, port);
+ this.initialSuccesses = initialWrites;
+ }
+ public TestSocket(InetAddress address, int port, int initialWrites) throws IOException
+ {
+ super(address, port);
+ this.initialSuccesses = initialWrites;
+ }
+ public TestSocket(String host, int port, InetAddress localAddr, int localPort, int initialWrites) throws IOException
+ {
+ super(host, port, localAddr, localPort);
+ this.initialSuccesses = initialWrites;
+ }
+ public TestSocket(InetAddress address, int port, InetAddress localAddr, int localPort, int initialWrites) throws IOException
+ {
+ super(address, port, localAddr, localPort);
+ this.initialSuccesses = initialWrites;
+ }
+ public OutputStream getOutputStream() throws IOException
+ {
+ return new TestOutputStream(super.getOutputStream(), initialSuccesses);
+ }
+ public String toString()
+ {
+ return "TestSocket[" + getLocalPort() + "->" + getPort() + "]";
+ }
+ }
+
+
+ static class TestOutputStream extends OutputStream
+ {
+ OutputStream os;
+ boolean closed;
+ int initialWrites;
+ boolean doThrow = true;
+ public static int counter;
+
+ public TestOutputStream(OutputStream os, int initialWrites)
+ {
+ this.os = os;
+ this.initialWrites = initialWrites;
+ }
+ public void close()throws IOException
+ {
+ closed = true;
+ super.close();
+ log.info(this + " closed");
+ }
+ public void write(int b) throws IOException
+ {
+ System.out.print("b: " + b);
+ if (closed)
+ {
+ log.info("TestOutputStream closed, cannot write");
+ throw new IOException("closed");
+ }
+ if (doThrow && ++counter > initialWrites)
+ {
+ log.info("throwing exception");
+ throw new IOException("");
+ }
+ os.write(b);
+ }
+ public void write(byte b[], int off, int len) throws IOException
+ {
+ System.out.print("b: ");
+ for (int i = 0; i < len; i++)
+ {
+ System.out.print(b[i] + " ");
+ }
+ System.out.println("");
+ if (closed)
+ {
+ log.info("TestOutputStream closed, cannot write");
+ throw new IOException("closed");
+ }
+ log.info("TestOutputStream: counter = " + ++counter + ", initialWrites = " + initialWrites);
+ if (counter > initialWrites)
+ {
+ log.info("throwing exception");
+ throw new IOException("");
+ }
+ if (closed)
+ {
+ log.info("TestOutputStream closed, cannot write");
+ throw new IOException("closed");
+ }
+ try
+ {
+ log.info(this + " calling write()");
+ doThrow = false;
+ os.write(b, off, len);
+ os.flush();
+ doThrow = true;
+ log.info(this + " back from write()");
+ }
+ catch (IOException e)
+ {
+ log.info("exception: ", e);
+ throw e;
+ }
+ }
+ }
+}
\ No newline at end of file
15 years, 3 months
JBoss Remoting SVN: r5459 - remoting2/branches/2.x/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-09-12 12:27:00 -0400 (Sat, 12 Sep 2009)
New Revision: 5459
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/LeasePinger.java
Log:
JBREM-1154: sendClientPing() and addClient() throw exceptions instead of swallowing them.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/LeasePinger.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/LeasePinger.java 2009-09-12 16:26:15 UTC (rev 5458)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/LeasePinger.java 2009-09-12 16:27:00 UTC (rev 5459)
@@ -205,8 +205,16 @@
ClientHolder newClient = new ClientHolder(sessionID, configuration, leasePeriod);
clientSessionIds.put(sessionID, newClient);
- sendClientPing();
-
+ try
+ {
+ sendClientPing();
+ }
+ catch (Throwable t)
+ {
+ log.debug(this + " failed to ping to server", t);
+ log.warn(this + " failed to ping to server: " + t.getMessage());
+ throw new RuntimeException(t);
+ }
// if new client lease period is less than the current ping period, need to refresh to new one
if (leasePeriod < pingPeriod)
{
@@ -372,53 +380,44 @@
// Private --------------------------------------------------------------------------------------
- private void sendClientPing()
+ private void sendClientPing() throws Throwable
{
- try
+ if(trace)
{
- if(trace)
+ StringBuffer sb = new StringBuffer();
+ if(clientSessionIds != null)
{
- StringBuffer sb = new StringBuffer();
- if(clientSessionIds != null)
+ for(Iterator i = clientSessionIds.values().iterator(); i.hasNext(); )
{
- for(Iterator i = clientSessionIds.values().iterator(); i.hasNext(); )
- {
- ClientHolder h = (ClientHolder)i.next();
- sb.append(" ").append(h.getSessionId()).append('\n');
- }
+ ClientHolder h = (ClientHolder)i.next();
+ sb.append(" ").append(h.getSessionId()).append('\n');
}
-
- log.trace(this + " sending ping to server. Currently managing lease " +
- "for following clients:\n" + sb.toString());
}
- Map clientsClone = new ConcurrentHashMap(clientSessionIds);
- Map requestClients = new ConcurrentHashMap();
- requestClients.put(ClientHolder.CLIENT_HOLDER_KEY, clientsClone);
- requestClients.put(LeasePinger.LEASE_PINGER_ID, leasePingerId);
- requestClients.put(TIME_STAMP, Long.toString(System.currentTimeMillis()));
+ log.trace(this + " sending ping to server. Currently managing lease " +
+ "for following clients:\n" + sb.toString());
+ }
- if (leasePingerTimeout >= 0)
- {
- requestClients.put(ServerInvoker.TIMEOUT, Integer.toString(leasePingerTimeout));
- }
-
- InvocationRequest ir = new InvocationRequest(invokerSessionID, null, "$PING$", requestClients, null, null);
-
- pingSucceeded = false;
- pingInvoked = true;
- invoker.invoke(ir);
+ Map clientsClone = new ConcurrentHashMap(clientSessionIds);
+ Map requestClients = new ConcurrentHashMap();
+ requestClients.put(ClientHolder.CLIENT_HOLDER_KEY, clientsClone);
+ requestClients.put(LeasePinger.LEASE_PINGER_ID, leasePingerId);
+ requestClients.put(TIME_STAMP, Long.toString(System.currentTimeMillis()));
- pingSucceeded = true;
- pingInvoked = false;
- if(trace) { log.trace(this + " successfully pinged the server"); }
- }
- catch (Throwable t)
+ if (leasePingerTimeout >= 0)
{
- pingInvoked = false;
- log.debug(this + " failed to ping to server", t);
- log.warn(this + " failed to ping to server: " + t.getMessage());
+ requestClients.put(ServerInvoker.TIMEOUT, Integer.toString(leasePingerTimeout));
}
+
+ InvocationRequest ir = new InvocationRequest(invokerSessionID, null, "$PING$", requestClients, null, null);
+
+ pingSucceeded = false;
+ pingInvoked = true;
+ invoker.invoke(ir);
+
+ pingSucceeded = true;
+ pingInvoked = false;
+ if(trace) { log.trace(this + " successfully pinged the server"); }
}
// Inner classes --------------------------------------------------------------------------------
@@ -442,7 +441,15 @@
if (currentPinger != null)
{
- currentPinger.sendClientPing();
+ try
+ {
+ currentPinger.sendClientPing();
+ }
+ catch (Throwable t)
+ {
+ log.debug(this + " failed to ping to server", t);
+ log.warn(this + " failed to ping to server: " + t.getMessage());
+ }
}
}
15 years, 3 months
JBoss Remoting SVN: r5458 - remoting2/branches/2.x/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-09-12 12:26:15 -0400 (Sat, 12 Sep 2009)
New Revision: 5458
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/Client.java
Log:
JBREM-1154: connect() throws CannotConnectException instead of plain RuntimeException.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/Client.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/Client.java 2009-09-12 16:24:49 UTC (rev 5457)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/Client.java 2009-09-12 16:26:15 UTC (rev 5458)
@@ -1793,8 +1793,7 @@
}
catch (Throwable throwable)
{
- RuntimeException e =
- new RuntimeException("Error setting up client lease upon performing connect.");
+ RuntimeException e = new CannotConnectException("Error setting up client lease upon performing connect.");
e.initCause(throwable);
throw e;
}
15 years, 3 months
JBoss Remoting SVN: r5457 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/lease.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-09-12 12:24:49 -0400 (Sat, 12 Sep 2009)
New Revision: 5457
Added:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/lease/LeaseCreationFailureTestCase.java
Log:
JBREM-1154: New unit test.
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/lease/LeaseCreationFailureTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/lease/LeaseCreationFailureTestCase.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/lease/LeaseCreationFailureTestCase.java 2009-09-12 16:24:49 UTC (rev 5457)
@@ -0,0 +1,361 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.remoting.lease;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+import javax.net.SocketFactory;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.logging.XLevel;
+import org.jboss.remoting.CannotConnectException;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.ConnectionListener;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.Remoting;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+
+
+/**
+ * Unit test for JBREM-1154.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Sep 11, 2009
+ * </p>
+ */
+public class LeaseCreationFailureTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(LeaseCreationFailureTestCase.class);
+
+ private static boolean firstTime = true;
+
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected InvokerLocator serverLocator;
+ protected Connector connector;
+ protected TestInvocationHandler invocationHandler;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(XLevel.TRACE);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testLeaseCreationFailure() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(Remoting.SOCKET_FACTORY_NAME, TestSocketFactory.class.getName());
+ clientConfig.put(Client.ENABLE_LEASE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+
+ // Verify that Client.connect() throws Exception if LeasePinger.addClient() fails.
+ try
+ {
+ client.connect();
+ fail("expected exception");
+ }
+ catch (CannotConnectException e)
+ {
+ log.info("got exception", e);
+ assertEquals("got wrong exception", "Error setting up client lease upon performing connect.", e.getMessage());
+ }
+ catch (Throwable t)
+ {
+ log.info("got wrong exception", t);
+ fail("got wrong exception");
+ }
+ assertFalse(client.isConnected());
+
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected String getTransport()
+ {
+ return "socket";
+ }
+
+
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+
+
+ protected void setupServer() throws Exception
+ {
+ host = InetAddress.getLocalHost().getHostAddress();
+ port = PortUtil.findFreePort(host);
+ locatorURI = getTransport() + "://" + host + ":" + port;
+ String metadata = System.getProperty("remoting.metadata");
+ if (metadata != null)
+ {
+ locatorURI += "/?" + metadata;
+ }
+ serverLocator = new InvokerLocator(locatorURI);
+ log.info("Starting remoting server with locator uri of: " + locatorURI);
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ config.put("clientLeasePeriod", "1000");
+ addExtraServerConfig(config);
+ connector = new Connector(serverLocator, config);
+ connector.create();
+ invocationHandler = new TestInvocationHandler();
+ connector.addInvocationHandler("test", invocationHandler);
+ connector.addConnectionListener(new TestConnectionListener());
+ connector.start();
+ }
+
+
+ protected void shutdownServer() throws Exception
+ {
+ if (connector != null)
+ connector.stop();
+ }
+
+
+ static class TestInvocationHandler implements ServerInvocationHandler
+ {
+ public void addListener(InvokerCallbackHandler callbackHandler) {}
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ return invocation.getParameter();
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
+
+
+ static class TestConnectionListener implements ConnectionListener
+ {
+ public void handleConnectionException(Throwable throwable, Client client)
+ {
+ }
+ }
+
+
+ public static class TestSocketFactory extends SocketFactory
+ {
+ int initialSuccesses = 2;
+
+ public TestSocketFactory()
+ {
+ }
+ public TestSocketFactory(int initialSuccesses)
+ {
+ this.initialSuccesses = initialSuccesses;
+ }
+ public Socket createSocket()
+ {
+ Socket s = new TestSocket(initialSuccesses);
+ log.info("returning " + s);
+ return s;
+ }
+ public Socket createSocket(String arg0, int arg1) throws IOException, UnknownHostException
+ {
+ Socket s = new TestSocket(arg0, arg1, initialSuccesses);
+ log.info("returning " + s);
+ return s;
+ }
+
+ public Socket createSocket(InetAddress arg0, int arg1) throws IOException
+ {
+ Socket s = new TestSocket(arg0, arg1, initialSuccesses);
+ log.info("returning " + s);
+ return s;
+ }
+
+ public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) throws IOException, UnknownHostException
+ {
+ Socket s = new TestSocket(arg0, arg1, arg2, arg3, initialSuccesses);
+ log.info("returning " + s);
+ return s;
+ }
+
+ public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3) throws IOException
+ {
+ Socket s = new TestSocket(arg0, arg1, arg2, arg3, initialSuccesses);
+ log.info("returning " + s);
+ return s;
+ }
+ }
+
+
+ static class TestSocket extends Socket
+ {
+ int initialSuccesses;
+
+ public TestSocket(int initialWrites)
+ {
+ this.initialSuccesses = initialWrites;
+ }
+ public TestSocket(String host, int port, int initialWrites) throws UnknownHostException, IOException
+ {
+ super(host, port);
+ this.initialSuccesses = initialWrites;
+ }
+ public TestSocket(InetAddress address, int port, int initialWrites) throws IOException
+ {
+ super(address, port);
+ this.initialSuccesses = initialWrites;
+ }
+ public TestSocket(String host, int port, InetAddress localAddr, int localPort, int initialWrites) throws IOException
+ {
+ super(host, port, localAddr, localPort);
+ this.initialSuccesses = initialWrites;
+ }
+ public TestSocket(InetAddress address, int port, InetAddress localAddr, int localPort, int initialWrites) throws IOException
+ {
+ super(address, port, localAddr, localPort);
+ this.initialSuccesses = initialWrites;
+ }
+ public OutputStream getOutputStream() throws IOException
+ {
+ return new TestOutputStream(super.getOutputStream(), initialSuccesses);
+ }
+ public String toString()
+ {
+ return "TestSocket[" + getLocalPort() + "->" + getPort() + "]";
+ }
+ }
+
+
+ static class TestOutputStream extends OutputStream
+ {
+ OutputStream os;
+ boolean closed;
+ int initialWrites;
+ boolean doThrow = true;
+ public static int counter;
+
+ public TestOutputStream(OutputStream os, int initialWrites)
+ {
+ this.os = os;
+ this.initialWrites = initialWrites;
+ }
+ public void close()throws IOException
+ {
+ closed = true;
+ super.close();
+ log.info(this + " closed");
+ }
+ public void write(int b) throws IOException
+ {
+ System.out.print("b: " + b);
+ if (closed)
+ {
+ log.info("TestOutputStream closed, cannot write");
+ throw new IOException("closed");
+ }
+ if (doThrow && ++counter > initialWrites)
+ {
+ log.info("throwing exception");
+ throw new IOException("");
+ }
+ os.write(b);
+ }
+ public void write(byte b[], int off, int len) throws IOException
+ {
+ System.out.print("b: ");
+ for (int i = 0; i < len; i++)
+ {
+ System.out.print(b[i] + " ");
+ }
+ System.out.println("");
+ if (closed)
+ {
+ log.info("TestOutputStream closed, cannot write");
+ throw new IOException("closed");
+ }
+ log.info("TestOutputStream: counter = " + ++counter + ", initialWrites = " + initialWrites);
+ if (counter > initialWrites)
+ {
+ log.info("throwing exception");
+ throw new IOException("");
+ }
+ if (closed)
+ {
+ log.info("TestOutputStream closed, cannot write");
+ throw new IOException("closed");
+ }
+ try
+ {
+ log.info(this + " calling write()");
+ doThrow = false;
+ os.write(b, off, len);
+ os.flush();
+ doThrow = true;
+ log.info(this + " back from write()");
+ }
+ catch (IOException e)
+ {
+ log.info("exception: ", e);
+ throw e;
+ }
+ }
+ }
+}
\ No newline at end of file
15 years, 3 months
JBoss Remoting SVN: r5456 - remoting2/branches/2.2/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-09-12 12:23:59 -0400 (Sat, 12 Sep 2009)
New Revision: 5456
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java
Log:
JBREM-1154: establishLease() extracts cause from exception thrown by LeasePinger.addClient() and throws cause.
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java 2009-09-12 16:21:04 UTC (rev 5455)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java 2009-09-12 16:23:59 UTC (rev 5456)
@@ -445,7 +445,14 @@
// lease and just need to update the lease pinger
if (leasePinger != null)
{
- leasePinger.addClient(clientSessionID, configuration, leasePeriod);
+ try
+ {
+ leasePinger.addClient(clientSessionID, configuration, leasePeriod);
+ }
+ catch (RuntimeException e)
+ {
+ throw e.getCause();
+ }
if (trace) log.trace(this + " added client with session ID " + clientSessionID + " to " + leasePinger);
}
else
15 years, 3 months
JBoss Remoting SVN: r5455 - remoting2/branches/2.2/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-09-12 12:21:04 -0400 (Sat, 12 Sep 2009)
New Revision: 5455
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/LeasePinger.java
Log:
JBREM-1154: sendClientPing() and addClient() throw exceptions instead of swallowing them.
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/LeasePinger.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/LeasePinger.java 2009-09-12 16:19:00 UTC (rev 5454)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/LeasePinger.java 2009-09-12 16:21:04 UTC (rev 5455)
@@ -172,8 +172,16 @@
ClientHolder newClient = new ClientHolder(sessionID, configuration, leasePeriod);
clientSessionIds.put(sessionID, newClient);
- sendClientPing();
-
+ try
+ {
+ sendClientPing();
+ }
+ catch (Throwable t)
+ {
+ log.debug(this + " failed to ping to server", t);
+ log.warn(this + " failed to ping to server: " + t.getMessage());
+ throw new RuntimeException(t);
+ }
// if new client lease period is less than the current ping period, need to refresh to new one
if (leasePeriod < pingPeriod)
{
@@ -339,42 +347,34 @@
// Private --------------------------------------------------------------------------------------
- private void sendClientPing()
+ private void sendClientPing() throws Throwable
{
- try
+ if(trace)
{
- if(trace)
+ StringBuffer sb = new StringBuffer();
+ if(clientSessionIds != null)
{
- StringBuffer sb = new StringBuffer();
- if(clientSessionIds != null)
+ for(Iterator i = clientSessionIds.values().iterator(); i.hasNext(); )
{
- for(Iterator i = clientSessionIds.values().iterator(); i.hasNext(); )
- {
- ClientHolder h = (ClientHolder)i.next();
- sb.append(" ").append(h.getSessionId()).append('\n');
- }
+ ClientHolder h = (ClientHolder)i.next();
+ sb.append(" ").append(h.getSessionId()).append('\n');
}
+ }
- log.trace(this + " sending ping to server. Currently managing lease " +
+ log.trace(this + " sending ping to server. Currently managing lease " +
"for following clients:\n" + sb.toString());
- }
+ }
- Map clientsClone = new ConcurrentHashMap(clientSessionIds);
- Map requestClients = new ConcurrentHashMap();
- requestClients.put(ClientHolder.CLIENT_HOLDER_KEY, clientsClone);
- requestClients.put(LeasePinger.LEASE_PINGER_ID, leasePingerId);
- requestClients.put(TIME_STAMP, Long.toString(System.currentTimeMillis()));
-
- InvocationRequest ir = new InvocationRequest(invokerSessionID, null, "$PING$", requestClients, null, null);
- invoker.invoke(ir);
+ Map clientsClone = new ConcurrentHashMap(clientSessionIds);
+ Map requestClients = new ConcurrentHashMap();
+ requestClients.put(ClientHolder.CLIENT_HOLDER_KEY, clientsClone);
+ requestClients.put(LeasePinger.LEASE_PINGER_ID, leasePingerId);
+ requestClients.put(TIME_STAMP, Long.toString(System.currentTimeMillis()));
- if(trace) { log.trace(this + " successfully pinged the server"); }
- }
- catch (Throwable t)
- {
- log.debug(this + " failed to ping to server", t);
- log.warn(this + " failed to ping to server: " + t.getMessage());
- }
+ InvocationRequest ir = new InvocationRequest(invokerSessionID, null, "$PING$", requestClients, null, null);
+ invoker.invoke(ir);
+
+ if(trace) { log.trace(this + " successfully pinged the server"); }
}
// Inner classes --------------------------------------------------------------------------------
@@ -398,7 +398,15 @@
if (currentPinger != null)
{
- currentPinger.sendClientPing();
+ try
+ {
+ currentPinger.sendClientPing();
+ }
+ catch (Throwable t)
+ {
+ log.debug(this + " failed to ping to server", t);
+ log.warn(this + " failed to ping to server: " + t.getMessage());
+ }
}
}
15 years, 3 months
JBoss Remoting SVN: r5454 - remoting2/branches/2.2/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-09-12 12:19:00 -0400 (Sat, 12 Sep 2009)
New Revision: 5454
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/Client.java
Log:
JBREM-1154: connect() throws CannotConnectException instead of plain RuntimeException.
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/Client.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/Client.java 2009-09-10 16:05:36 UTC (rev 5453)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/Client.java 2009-09-12 16:19:00 UTC (rev 5454)
@@ -1801,8 +1801,7 @@
}
catch (Throwable throwable)
{
- RuntimeException e =
- new RuntimeException("Error setting up client lease upon performing connect.");
+ RuntimeException e = new CannotConnectException("Error setting up client lease upon performing connect.");
e.initCause(throwable);
throw e;
}
15 years, 3 months
JBoss Remoting SVN: r5453 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/config.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-09-10 12:05:36 -0400 (Thu, 10 Sep 2009)
New Revision: 5453
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestMarshaller.java
Log:
JBREM-1102: Turned wrote from a boolean to an int.
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestMarshaller.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestMarshaller.java 2009-09-10 16:01:03 UTC (rev 5452)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestMarshaller.java 2009-09-10 16:05:36 UTC (rev 5453)
@@ -40,13 +40,13 @@
protected static Logger log = Logger.getLogger(ConfigTestMarshaller.class);
private static final long serialVersionUID = 1L;
private static volatile int cloned;
- private static volatile boolean wrote;
+ private static volatile int wrote;
public void write(Object dataObject, OutputStream output, int version) throws IOException
{
log.info(this + "writing Wrapper");
super.write(new Wrapper(dataObject), output, version);
- wrote = true;
+ wrote++;
}
public Marshaller cloneMarshaller() throws CloneNotSupportedException
@@ -60,13 +60,13 @@
public static boolean ok(boolean b, int count)
{
log.info("wrote: " + wrote + ", cloned: " + cloned);
- return wrote == b && cloned == count;
+ return (b ? wrote > 0 : wrote == 0) && cloned == count;
}
public static void reset()
{
cloned = 0;
- wrote = false;
+ wrote = 0;
log.info("reset(): wrote: " + wrote + ", cloned: " + cloned);
}
}
15 years, 3 months
JBoss Remoting SVN: r5452 - in remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport: bisocket/socketexception and 1 other directories.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-09-10 12:01:03 -0400 (Thu, 10 Sep 2009)
New Revision: 5452
Added:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/socketexception/
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/socketexception/BisocketSocketCreationExceptionTestCase.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/socket/socketexception/SocketCreationExceptionTestCase.java
Log:
JBREM-1152: New unit tests.
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/socketexception/BisocketSocketCreationExceptionTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/socketexception/BisocketSocketCreationExceptionTestCase.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/socketexception/BisocketSocketCreationExceptionTestCase.java 2009-09-10 16:01:03 UTC (rev 5452)
@@ -0,0 +1,231 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, 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.test.remoting.transport.bisocket.socketexception;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.net.ServerSocketFactory;
+
+import org.apache.log4j.Logger;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.callback.Callback;
+import org.jboss.remoting.callback.HandleCallbackException;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.socket.LRUPool;
+import org.jboss.remoting.transport.socket.ServerThread;
+import org.jboss.remoting.transport.socket.SocketServerInvoker;
+import org.jboss.test.remoting.transport.socket.socketexception.SocketCreationExceptionTestCase;
+
+/**
+ * Unit tests for JBREM-1152.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Rev$
+ * <p>
+ * Copyright Sep 9, 2009
+ * </p>
+ */
+public class BisocketSocketCreationExceptionTestCase extends SocketCreationExceptionTestCase
+{
+ private static Logger log = Logger.getLogger(BisocketSocketCreationExceptionTestCase.class);
+
+
+ public void testCallbackException() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(new TestServerSocketFactory(2, new SocketException(getName())));
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connection.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ TestCallbackHandler callbackHandler = new TestCallbackHandler();
+ client.addListener(callbackHandler, new HashMap());
+
+ // Get client side ServerThread pool.
+ Set callbackConnectors = client.getCallbackConnectors(callbackHandler);
+ Connector callbackConnector = (Connector) callbackConnectors.iterator().next();
+ SocketServerInvoker serverInvoker = (SocketServerInvoker) callbackConnector.getServerInvoker();
+ Field field = SocketServerInvoker.class.getDeclaredField("clientpool");
+ field.setAccessible(true);
+ LRUPool clientpool = (LRUPool) field.get(serverInvoker);
+
+ // Verify MicroSocketClientInvoker retries invocation after failure to get a connection.
+ client.invoke(SEND_CALLBACK);
+ assertEquals(1, callbackHandler.received);
+ Set serverThreads = clientpool.getContents();
+ Iterator it = serverThreads.iterator();
+ while (it.hasNext())
+ {
+ ServerThread st = (ServerThread) it.next();
+ st.shutdown();
+ }
+ client.invoke(SEND_CALLBACK);
+ assertEquals(2, callbackHandler.received);
+ serverThreads = clientpool.getContents();
+ it = serverThreads.iterator();
+ while (it.hasNext())
+ {
+ ServerThread st = (ServerThread) it.next();
+ st.shutdown();
+ }
+ client.invoke(SEND_CALLBACK);
+ assertEquals(3, callbackHandler.received);
+
+ client.removeListener(callbackHandler);
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected String getTransport()
+ {
+ return "bisocket";
+ }
+
+
+ static class TestCallbackHandler implements InvokerCallbackHandler
+ {
+ public int received;
+
+ public void handleCallback(Callback callback) throws HandleCallbackException
+ {
+ log.info("received callback");
+ received++;
+ }
+ }
+
+ static public class TestServerSocketFactory extends ServerSocketFactory
+ {
+ int initialSuccesses;
+ IOException exception;
+
+ public TestServerSocketFactory()
+ {
+ this.initialSuccesses = -1;
+ this.exception = new IOException();
+ }
+ public TestServerSocketFactory(int initialSuccesses, IOException exception)
+ {
+ this.initialSuccesses = initialSuccesses;
+ this.exception = exception;
+ }
+ public ServerSocket createServerSocket() throws IOException
+ {
+ ServerSocket ss = new TestServerSocket(initialSuccesses, exception);
+ log.info(this + " returning: " + ss);
+ return ss;
+ }
+ public ServerSocket createServerSocket(int port) throws IOException
+ {
+ ServerSocket ss = new TestServerSocket(port, initialSuccesses, exception);
+ log.info(this + " returning: " + ss);
+ return ss;
+ }
+
+ public ServerSocket createServerSocket(int port, int backlog) throws IOException
+ {
+ ServerSocket ss = new TestServerSocket(port, backlog, initialSuccesses, exception);
+ log.info(this + " returning: " + ss);
+ return ss;
+ }
+
+ public ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress) throws IOException
+ {
+ ServerSocket ss = new TestServerSocket(port, backlog, ifAddress, initialSuccesses, exception);
+ log.info(this + " returning: " + ss);
+ return ss;
+ }
+ }
+
+
+ static class TestServerSocket extends ServerSocket
+ {
+ int initialSuccesses;
+ IOException exception;
+ int counter;
+
+ public TestServerSocket(int initialSuccesses, IOException exception) throws IOException
+ {
+ super();
+ this.initialSuccesses = initialSuccesses;
+ this.exception = exception;
+ }
+ public TestServerSocket(int port, int initialSuccesses, IOException exception) throws IOException
+ {
+ super(port);
+ this.initialSuccesses = initialSuccesses;
+ this.exception = exception;
+ }
+ public TestServerSocket(int port, int backlog, int initialSuccesses, IOException exception) throws IOException
+ {
+ super(port, backlog);
+ this.initialSuccesses = initialSuccesses;
+ this.exception = exception;
+ }
+ public TestServerSocket(int port, int backlog, InetAddress bindAddr, int initialSuccesses, IOException exception) throws IOException
+ {
+ super(port, backlog, bindAddr);
+ this.initialSuccesses = initialSuccesses;
+ this.exception = exception;
+ }
+ public Socket accept() throws IOException
+ {
+ ++counter;
+ Socket s = super.accept();
+ log.info(this + " counter: " + counter);
+ if (counter > initialSuccesses && counter <= initialSuccesses + 2)
+ {
+ throw exception;
+ }
+ log.info(this + " returning: " + s);
+ return s;
+ }
+ public String toString()
+ {
+ return "TestServerSocket[" + getLocalPort() + "]";
+ }
+ }
+
+}
\ No newline at end of file
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/socket/socketexception/SocketCreationExceptionTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/socket/socketexception/SocketCreationExceptionTestCase.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/socket/socketexception/SocketCreationExceptionTestCase.java 2009-09-10 16:01:03 UTC (rev 5452)
@@ -0,0 +1,300 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, 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.test.remoting.transport.socket.socketexception;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.SocketException;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+import javax.net.ServerSocketFactory;
+import javax.net.SocketFactory;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.logging.XLevel;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.Remoting;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.Callback;
+import org.jboss.remoting.callback.HandleCallbackException;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+
+/**
+ * Unit tests for JBREM-1152.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Rev$
+ * <p>
+ * Copyright Sep 9, 2009
+ * </p>
+ */
+public class SocketCreationExceptionTestCase extends TestCase
+{
+ protected static String SEND_CALLBACK = "sendCallback";
+ private static Logger log = Logger.getLogger(SocketCreationExceptionTestCase.class);
+ private static boolean firstTime = true;
+
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected InvokerLocator serverLocator;
+ protected Connector connector;
+ protected TestInvocationHandler invocationHandler;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(XLevel.TRACE);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testInvocationWithSocketException() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(null);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(Remoting.CUSTOM_SOCKET_FACTORY, new TestSocketFactory(new SocketException(getName()), 2));
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connection.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testInvocationWithIOException() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(null);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(Remoting.CUSTOM_SOCKET_FACTORY, new TestSocketFactory(new IOException("Connection reset"), 2));
+ clientConfig.put("generalizeSocketException", "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connection.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected String getTransport()
+ {
+ return "socket";
+ }
+
+
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+
+
+ protected void setupServer(ServerSocketFactory ssf) throws Exception
+ {
+ host = InetAddress.getLocalHost().getHostAddress();
+ port = PortUtil.findFreePort(host);
+ locatorURI = getTransport() + "://" + host + ":" + port;
+ String metadata = System.getProperty("remoting.metadata");
+ if (metadata != null)
+ {
+ locatorURI += "&" + metadata;
+ }
+ serverLocator = new InvokerLocator(locatorURI);
+ log.info("Starting remoting server with locator uri of: " + locatorURI);
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ config.put("timeout", "5000");
+ if (ssf != null)
+ {
+ config.put(Remoting.CUSTOM_SERVER_SOCKET_FACTORY, ssf);
+ }
+ addExtraServerConfig(config);
+ connector = new Connector(serverLocator, config);
+ connector.create();
+ invocationHandler = new TestInvocationHandler();
+ connector.addInvocationHandler("test", invocationHandler);
+ connector.start();
+ }
+
+
+ protected void shutdownServer() throws Exception
+ {
+ if (connector != null)
+ connector.stop();
+ }
+
+
+ static class TestInvocationHandler implements ServerInvocationHandler
+ {
+ InvokerCallbackHandler callbackHandler;
+
+ public void addListener(InvokerCallbackHandler callbackHandler)
+ {
+ this.callbackHandler = callbackHandler;
+ }
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ Object parameter = invocation.getParameter();
+ if (SEND_CALLBACK.equals(parameter))
+ {
+ try
+ {
+ callbackHandler.handleCallback(new Callback("callback"));
+ }
+ catch (HandleCallbackException e)
+ {
+ log.error("unable to send callback", e);
+ }
+ }
+ return parameter;
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
+
+
+ public static class TestSocketFactory extends SocketFactory
+ {
+ int counter;
+ int limit;
+ IOException exception;
+
+ public TestSocketFactory()
+ {
+ }
+ public TestSocketFactory(IOException exception, int limit)
+ {
+ this.exception = exception;
+ this.limit = limit;
+ }
+ public Socket createSocket() throws IOException
+ {
+ counter++;
+ log.info("counter: " + counter);
+ if (counter <= limit)
+ {
+ log.info("throwing exception");
+ throw exception;
+ }
+ log.info("returning socket");
+ return new Socket();
+ }
+ public Socket createSocket(String arg0, int arg1) throws IOException, UnknownHostException
+ {
+ counter++;
+ log.info("counter: " + counter);
+ if (counter <= limit)
+ {
+ throw exception;
+ }
+ log.info("returning socket");
+ return new Socket(arg0, arg1);
+ }
+ public Socket createSocket(InetAddress arg0, int arg1) throws IOException
+ {
+ counter++;
+ log.info("counter: " + counter);
+ if (counter <= limit)
+ {
+ throw exception;
+ }
+ log.info("returning socket");
+ return new Socket(arg0, arg1);
+ }
+ public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) throws IOException, UnknownHostException
+ {
+ counter++;
+ log.info("counter: " + counter);
+ if (counter <= limit)
+ {
+ throw exception;
+ }
+ log.info("returning socket");
+ return new Socket(arg0, arg1, arg2, arg3);
+ }
+
+ public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3) throws IOException
+ {
+ counter++;
+ log.info("counter: " + counter);
+ if (counter <= limit)
+ {
+ throw exception;
+ }
+ log.info("returning socket");
+ return new Socket(arg0, arg1, arg2, arg3);
+ }
+ }
+}
\ No newline at end of file
15 years, 3 months