JBoss Remoting SVN: r4333 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timertask.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-06-27 21:39:06 -0400 (Fri, 27 Jun 2008)
New Revision: 4333
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java
Log:
JBREM-1005: Tests pass trivially if Timer.purge() doesn't exist.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java 2008-06-28 01:35:55 UTC (rev 4332)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java 2008-06-28 01:39:06 UTC (rev 4333)
@@ -68,6 +68,7 @@
private static Logger log = Logger.getLogger(TimerTaskTestCase.class);
private static boolean firstTime = true;
+ private static boolean purgeMethodAvailable;
protected String host;
protected int port;
@@ -87,7 +88,17 @@
String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
PatternLayout layout = new PatternLayout(pattern);
ConsoleAppender consoleAppender = new ConsoleAppender(layout);
- Logger.getRootLogger().addAppender(consoleAppender);
+ Logger.getRootLogger().addAppender(consoleAppender);
+
+ try
+ {
+ Timer.class.getDeclaredMethod("purge", new Class[]{});
+ purgeMethodAvailable = true;
+ }
+ catch (Exception e)
+ {
+ log.info("Timer.purge() is not available: must be running with jdk 1.4");
+ }
}
}
@@ -101,6 +112,12 @@
{
log.info("entering " + getName());
+ if (!purgeMethodAvailable)
+ {
+ log.info(getName() + " PASSES (trivially)");
+ return;
+ }
+
// Start server.
setupServer("0");
@@ -159,6 +176,12 @@
{
log.info("entering " + getName());
+ if (!purgeMethodAvailable)
+ {
+ log.info(getName() + " PASSES (trivially)");
+ return;
+ }
+
// Start server.
setupServer("20");
16 years, 5 months
JBoss Remoting SVN: r4332 - remoting2/branches/2.2/src/main/org/jboss/remoting/transport/bisocket.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-06-27 21:35:55 -0400 (Fri, 27 Jun 2008)
New Revision: 4332
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java
Log:
JBREM-1005: Uses reflection to call Timer.purge().
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java 2008-06-28 01:32:55 UTC (rev 4331)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java 2008-06-28 01:35:55 UTC (rev 4332)
@@ -24,6 +24,7 @@
import java.io.IOException;
import java.io.OutputStream;
+import java.lang.reflect.Method;
import java.net.Socket;
import java.util.Collections;
import java.util.HashMap;
@@ -624,7 +625,15 @@
controlOutputStream = null;
}
cancel();
- timer.purge();
+ try
+ {
+ Method purge = Timer.class.getDeclaredMethod("purge", new Class[]{});
+ purge.invoke(timer, new Object[]{});
+ }
+ catch (Exception e)
+ {
+ log.debug("running with jdk 1.4: unable to purge Timer");
+ }
}
public void run()
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java 2008-06-28 01:32:55 UTC (rev 4331)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java 2008-06-28 01:35:55 UTC (rev 4332)
@@ -25,6 +25,7 @@
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
+import java.lang.reflect.Method;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
@@ -956,7 +957,15 @@
listenerIdToInvokerLocatorMap = null;
controlConnectionThreadMap = null;
cancel();
- timer.purge();
+ try
+ {
+ Method purge = Timer.class.getDeclaredMethod("purge", new Class[]{});
+ purge.invoke(timer, new Object[]{});
+ }
+ catch (Exception e)
+ {
+ log.debug("running with jdk 1.4: unable to purge Timer");
+ }
}
public void run()
16 years, 5 months
JBoss Remoting SVN: r4331 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/timertask.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-06-27 21:32:55 -0400 (Fri, 27 Jun 2008)
New Revision: 4331
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java
Log:
JBREM-1005: setUp() doesn't save purge() method.
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java 2008-06-28 01:30:04 UTC (rev 4330)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java 2008-06-28 01:32:55 UTC (rev 4331)
@@ -94,7 +94,7 @@
try
{
- Method purge = SecurityUtility.getDeclaredMethod(Timer.class, "purge", new Class[]{});
+ SecurityUtility.getDeclaredMethod(Timer.class, "purge", new Class[]{});
purgeMethodAvailable = true;
}
catch (Exception e)
16 years, 5 months
JBoss Remoting SVN: r4330 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/timertask.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-06-27 21:30:04 -0400 (Fri, 27 Jun 2008)
New Revision: 4330
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java
Log:
JBREM-1005: Tests pass trivially if Timer.purge() doesn't exist.
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java 2008-06-28 01:29:29 UTC (rev 4329)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java 2008-06-28 01:30:04 UTC (rev 4330)
@@ -22,6 +22,7 @@
package org.jboss.test.remoting.transport.bisocket.timertask;
import java.lang.reflect.Field;
+import java.lang.reflect.Method;
import java.net.InetAddress;
import java.util.HashMap;
import java.util.Map;
@@ -52,6 +53,7 @@
import org.jboss.remoting.transport.bisocket.Bisocket;
import org.jboss.remoting.transport.bisocket.BisocketClientInvoker;
import org.jboss.remoting.transport.bisocket.BisocketServerInvoker;
+import org.jboss.remoting.util.SecurityUtility;
/**
@@ -68,6 +70,7 @@
private static Logger log = Logger.getLogger(TimerTaskTestCase.class);
private static boolean firstTime = true;
+ private static boolean purgeMethodAvailable;
protected String host;
protected int port;
@@ -87,7 +90,17 @@
String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
PatternLayout layout = new PatternLayout(pattern);
ConsoleAppender consoleAppender = new ConsoleAppender(layout);
- Logger.getRootLogger().addAppender(consoleAppender);
+ Logger.getRootLogger().addAppender(consoleAppender);
+
+ try
+ {
+ Method purge = SecurityUtility.getDeclaredMethod(Timer.class, "purge", new Class[]{});
+ purgeMethodAvailable = true;
+ }
+ catch (Exception e)
+ {
+ log.info("Timer.purge() is not available: must be running with jdk 1.4");
+ }
}
}
@@ -101,6 +114,12 @@
{
log.info("entering " + getName());
+ if (!purgeMethodAvailable)
+ {
+ log.info(getName() + " PASSES (trivially)");
+ return;
+ }
+
// Start server.
setupServer("0");
@@ -159,6 +178,12 @@
{
log.info("entering " + getName());
+ if (!purgeMethodAvailable)
+ {
+ log.info(getName() + " PASSES (trivially)");
+ return;
+ }
+
// Start server.
setupServer("20");
16 years, 5 months
JBoss Remoting SVN: r4329 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-06-27 21:29:29 -0400 (Fri, 27 Jun 2008)
New Revision: 4329
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java
Log:
JBREM-1005: Uses reflection to call Timer.purge().
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java 2008-06-27 05:51:38 UTC (rev 4328)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java 2008-06-28 01:29:29 UTC (rev 4329)
@@ -23,8 +23,8 @@
package org.jboss.remoting.transport.bisocket;
import java.io.IOException;
-import java.io.InterruptedIOException;
import java.io.OutputStream;
+import java.lang.reflect.Method;
import java.net.Socket;
import java.util.Collections;
import java.util.HashMap;
@@ -47,6 +47,7 @@
import org.jboss.remoting.transport.BidirectionalClientInvoker;
import org.jboss.remoting.transport.socket.SocketClientInvoker;
import org.jboss.remoting.transport.socket.SocketWrapper;
+import org.jboss.remoting.util.SecurityUtility;
import EDU.oswego.cs.dl.util.concurrent.Semaphore;
@@ -626,7 +627,16 @@
controlOutputStream = null;
}
cancel();
- timer.purge();
+
+ try
+ {
+ Method purge = SecurityUtility.getDeclaredMethod(Timer.class, "purge", new Class[]{});
+ purge.invoke(timer, new Object[]{});
+ }
+ catch (Exception e)
+ {
+ log.debug("running with jdk 1.4: unable to purge Timer");
+ }
}
public void run()
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java 2008-06-27 05:51:38 UTC (rev 4328)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java 2008-06-28 01:29:29 UTC (rev 4329)
@@ -25,6 +25,7 @@
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
+import java.lang.reflect.Method;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
@@ -59,6 +60,7 @@
import org.jboss.remoting.transport.PortUtil;
import org.jboss.remoting.transport.socket.LRUPool;
import org.jboss.remoting.transport.socket.SocketServerInvoker;
+import org.jboss.remoting.util.SecurityUtility;
/**
@@ -1200,7 +1202,16 @@
listenerIdToInvokerLocatorMap = null;
controlConnectionThreadMap = null;
cancel();
- timer.purge();
+
+ try
+ {
+ Method purge = SecurityUtility.getDeclaredMethod(Timer.class, "purge", new Class[]{});
+ purge.invoke(timer, new Object[]{});
+ }
+ catch (Exception e)
+ {
+ log.debug("running with jdk 1.4: unable to purge Timer");
+ }
}
public void run()
16 years, 5 months
JBoss Remoting SVN: r4328 - in remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket: timertask and 1 other directory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-06-27 01:51:38 -0400 (Fri, 27 Jun 2008)
New Revision: 4328
Added:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java
Log:
JBREM-1005: (1) TimerTasks aren't created if pingFrequency == 0.
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java 2008-06-27 05:51:38 UTC (rev 4328)
@@ -0,0 +1,318 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.timertask;
+
+import java.lang.reflect.Field;
+import java.net.InetAddress;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import javax.management.MBeanServer;
+
+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.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.callback.ServerInvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+import org.jboss.remoting.transport.bisocket.Bisocket;
+import org.jboss.remoting.transport.bisocket.BisocketClientInvoker;
+import org.jboss.remoting.transport.bisocket.BisocketServerInvoker;
+
+
+/**
+ * Unit test for JBREM-1005.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Jun 26, 2008
+ * </p>
+ */
+public class TimerTaskTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(TimerTaskTestCase.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.INFO);
+ 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 testZeroPingFrequency() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer("0");
+
+ // 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();
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Set up callback handler.
+ TestCallbackHandler callbackHandler = new TestCallbackHandler();
+ HashMap metadata = new HashMap();
+ metadata.put(Bisocket.IS_CALLBACK_SERVER, "true");
+ client.addListener(callbackHandler, metadata);
+ assertEquals(1, callbackHandler.counter);
+
+ // Verify ControlMonitorTimerTask is not created.
+ Set callbackConnectors = client.getCallbackConnectors(callbackHandler);
+ assertEquals(1, callbackConnectors.size());
+ Connector callbackConnector = (Connector) callbackConnectors.iterator().next();
+ Field field = BisocketServerInvoker.class.getDeclaredField("controlMonitorTimerTask");
+ field.setAccessible(true);
+ BisocketServerInvoker serverInvoker = (BisocketServerInvoker) callbackConnector.getServerInvoker();
+ TimerTask timerTask = (TimerTask) field.get(serverInvoker);
+ assertNull(timerTask);
+ log.info("ControlMonitorTimerTask was not created");
+
+ // Verify PingTimerTask is not created.
+ field = ServerInvoker.class.getDeclaredField("callbackHandlers");
+ field.setAccessible(true);
+ serverInvoker = (BisocketServerInvoker) connector.getServerInvoker();
+ Map callbackHandlers = (Map) field.get(serverInvoker);
+ assertEquals(1, callbackHandlers.size());
+ Object o = callbackHandlers.values().iterator().next();
+ Client callbackClient = ((ServerInvokerCallbackHandler) o).getCallbackClient();
+ BisocketClientInvoker clientInvoker = (BisocketClientInvoker) callbackClient.getInvoker();
+ field = BisocketClientInvoker.class.getDeclaredField("pingTimerTask");
+ field.setAccessible(true);
+ timerTask = (TimerTask) field.get(clientInvoker);
+ assertNull(timerTask);
+ log.info("PingTimerTask was not created");
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testNonZeroPingFrequency() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer("20");
+
+ // 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();
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Set up callback handler.
+ TestCallbackHandler callbackHandler = new TestCallbackHandler();
+ HashMap metadata = new HashMap();
+ metadata.put(Bisocket.IS_CALLBACK_SERVER, "true");
+ client.addListener(callbackHandler, metadata);
+ assertEquals(1, callbackHandler.counter);
+
+ // Verify ControlMonitorTimerTask is created.
+ Set callbackConnectors = client.getCallbackConnectors(callbackHandler);
+ assertEquals(1, callbackConnectors.size());
+ Connector callbackConnector = (Connector) callbackConnectors.iterator().next();
+ Field field = BisocketServerInvoker.class.getDeclaredField("controlMonitorTimerTask");
+ field.setAccessible(true);
+ BisocketServerInvoker serverInvoker = (BisocketServerInvoker) callbackConnector.getServerInvoker();
+ TimerTask timerTask = (TimerTask) field.get(serverInvoker);
+ assertNotNull(timerTask);
+ log.info("ControlMonitorTimerTask was created");
+
+ // Verify PingTimerTask is created.
+ field = ServerInvoker.class.getDeclaredField("callbackHandlers");
+ field.setAccessible(true);
+ BisocketServerInvoker callbackServerInvoker = (BisocketServerInvoker) connector.getServerInvoker();
+ Map callbackHandlers = (Map) field.get(callbackServerInvoker);
+ assertEquals(1, callbackHandlers.size());
+ Object o = callbackHandlers.values().iterator().next();
+ Client callbackClient = ((ServerInvokerCallbackHandler) o).getCallbackClient();
+ BisocketClientInvoker clientInvoker = (BisocketClientInvoker) callbackClient.getInvoker();
+ field = BisocketClientInvoker.class.getDeclaredField("pingTimerTask");
+ field.setAccessible(true);
+ timerTask = (TimerTask) field.get(clientInvoker);
+ assertNotNull(timerTask);
+ log.info("PingTimerTask was created");
+
+ // Get count of ControlMonitorTimerTasks.
+ field = BisocketServerInvoker.class.getDeclaredField("timer");
+ field.setAccessible(true);
+ Timer timer = (Timer) field.get(null);
+ field = Timer.class.getDeclaredField("queue");
+ field.setAccessible(true);
+ Object taskQueue = field.get(timer);
+ Field serverTimerfield = taskQueue.getClass().getDeclaredField("size");
+ serverTimerfield.setAccessible(true);
+ int serverSize = ((Integer) serverTimerfield.get(taskQueue)).intValue();
+ log.info("ControlMonitorTimerTasks: " + serverSize);
+
+ // Get count of PingTimerTasks.
+ field = BisocketClientInvoker.class.getDeclaredField("timer");
+ field.setAccessible(true);
+ timer = (Timer) field.get(null);
+ field = Timer.class.getDeclaredField("queue");
+ field.setAccessible(true);
+ taskQueue = field.get(timer);
+ Field clientTimerfield = taskQueue.getClass().getDeclaredField("size");
+ clientTimerfield.setAccessible(true);
+ int clientSize = ((Integer) clientTimerfield.get(taskQueue)).intValue();
+ log.info("PingTimerTasks: " + clientSize);
+
+ // Shut down callback connection and verify TimerTasks are removed from
+ // Timer queue.
+ client.removeListener(callbackHandler);
+ serverSize = ((Integer) serverTimerfield.get(taskQueue)).intValue();
+ log.info("ControlMonitorTimerTasks: " + serverSize);
+ assertEquals(0, serverSize);
+ clientSize = ((Integer) clientTimerfield.get(taskQueue)).intValue();
+ log.info("PingTimerTasks: " + clientSize);
+ assertEquals(0, clientSize);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected String getTransport()
+ {
+ return "bisocket";
+ }
+
+
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+
+
+ protected void setupServer(String pingFrequency) throws Exception
+ {
+ host = InetAddress.getLocalHost().getHostAddress();
+ port = PortUtil.findFreePort(host);
+ locatorURI = getTransport() + "://" + host + ":" + port;
+ locatorURI += "/?" + Bisocket.PING_FREQUENCY + "=" + pingFrequency;
+ serverLocator = new InvokerLocator(locatorURI);
+ log.info("Starting remoting server with locator uri of: " + locatorURI);
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ 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
+ {
+ public void addListener(InvokerCallbackHandler callbackHandler)
+ {
+ try
+ {
+ callbackHandler.handleCallback(new Callback("callback"));
+ }
+ catch (HandleCallbackException e)
+ {
+ log.error("Unable to send callback", e);
+ }
+ }
+ 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 TestCallbackHandler implements InvokerCallbackHandler
+ {
+ public int counter;
+ public void handleCallback(Callback callback) throws HandleCallbackException
+ {
+ counter++;
+ log.info("received callback");
+ }
+ }
+}
\ No newline at end of file
16 years, 5 months
JBoss Remoting SVN: r4327 - remoting2/branches/2.2/src/main/org/jboss/remoting/transport/bisocket.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-06-27 01:49:44 -0400 (Fri, 27 Jun 2008)
New Revision: 4327
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java
Log:
JBREM-1005: (1) TimerTasks aren't created if pingFrequency == 0; (2) when TimerTask.cancel() is called, Timer.purge() is also called.
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java 2008-06-27 02:59:50 UTC (rev 4326)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java 2008-06-27 05:49:44 UTC (rev 4327)
@@ -23,7 +23,6 @@
package org.jboss.remoting.transport.bisocket;
import java.io.IOException;
-import java.io.InterruptedIOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Collections;
@@ -283,24 +282,28 @@
throw new ConnectionFailedException("Unable to get control socket output stream");
}
log.debug("got control socket( " + listenerId + "): " + controlSocket);
- pingTimerTask = new PingTimerTask(this);
- synchronized (timerLock)
+ if (pingFrequency > 0)
{
- if (timer == null)
+ pingTimerTask = new PingTimerTask(this);
+
+ synchronized (timerLock)
{
- timer = new Timer(true);
+ if (timer == null)
+ {
+ timer = new Timer(true);
+ }
+ try
+ {
+ timer.schedule(pingTimerTask, pingFrequency, pingFrequency);
+ }
+ catch (IllegalStateException e)
+ {
+ log.debug("Unable to schedule TimerTask on existing Timer", e);
+ timer = new Timer(true);
+ timer.schedule(pingTimerTask, pingFrequency, pingFrequency);
+ }
}
- try
- {
- timer.schedule(pingTimerTask, pingFrequency, pingFrequency);
- }
- catch (IllegalStateException e)
- {
- log.debug("Unable to schedule TimerTask on existing Timer", e);
- timer = new Timer(true);
- timer.schedule(pingTimerTask, pingFrequency, pingFrequency);
- }
}
}
@@ -523,24 +526,27 @@
if (pingTimerTask != null)
pingTimerTask.cancel();
- pingTimerTask = new PingTimerTask(this);
+ if (pingFrequency > 0)
+ {
+ pingTimerTask = new PingTimerTask(this);
- synchronized (timerLock)
- {
- if (timer == null)
+ synchronized (timerLock)
{
- timer = new Timer(true);
+ if (timer == null)
+ {
+ timer = new Timer(true);
+ }
+ try
+ {
+ timer.schedule(pingTimerTask, pingFrequency, pingFrequency);
+ }
+ catch (IllegalStateException e)
+ {
+ log.debug("Unable to schedule TimerTask on existing Timer", e);
+ timer = new Timer(true);
+ timer.schedule(pingTimerTask, pingFrequency, pingFrequency);
+ }
}
- try
- {
- timer.schedule(pingTimerTask, pingFrequency, pingFrequency);
- }
- catch (IllegalStateException e)
- {
- log.debug("Unable to schedule TimerTask on existing Timer", e);
- timer = new Timer(true);
- timer.schedule(pingTimerTask, pingFrequency, pingFrequency);
- }
}
}
@@ -618,6 +624,7 @@
controlOutputStream = null;
}
cancel();
+ timer.purge();
}
public void run()
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java 2008-06-27 02:59:50 UTC (rev 4326)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java 2008-06-27 05:49:44 UTC (rev 4327)
@@ -25,7 +25,6 @@
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
-import java.io.InterruptedIOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
@@ -50,7 +49,6 @@
import org.jboss.remoting.socketfactory.SocketCreationListener;
import org.jboss.remoting.transport.PortUtil;
import org.jboss.remoting.transport.socket.LRUPool;
-import org.jboss.remoting.transport.socket.ServerThread;
import org.jboss.remoting.transport.socket.SocketServerInvoker;
import org.jboss.logging.Logger;
@@ -151,23 +149,26 @@
threadpool = new LinkedList();
checkSocketFactoryWrapper();
- controlMonitorTimerTask = new ControlMonitorTimerTask(this);
- synchronized (timerLock)
+ if (pingFrequency > 0)
{
- if (timer == null)
+ controlMonitorTimerTask = new ControlMonitorTimerTask(this);
+ synchronized (timerLock)
{
- timer = new Timer(true);
+ if (timer == null)
+ {
+ timer = new Timer(true);
+ }
+ try
+ {
+ timer.schedule(controlMonitorTimerTask, pingFrequency, pingFrequency);
+ }
+ catch (IllegalStateException e)
+ {
+ log.debug("Unable to schedule TimerTask on existing Timer", e);
+ timer = new Timer(true);
+ timer.schedule(controlMonitorTimerTask, pingFrequency, pingFrequency);
+ }
}
- try
- {
- timer.schedule(controlMonitorTimerTask, pingFrequency, pingFrequency);
- }
- catch (IllegalStateException e)
- {
- log.debug("Unable to schedule TimerTask on existing Timer", e);
- timer = new Timer(true);
- timer.schedule(controlMonitorTimerTask, pingFrequency, pingFrequency);
- }
}
running = true;
@@ -955,6 +956,7 @@
listenerIdToInvokerLocatorMap = null;
controlConnectionThreadMap = null;
cancel();
+ timer.purge();
}
public void run()
16 years, 5 months
JBoss Remoting SVN: r4326 - in remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket: timertask and 1 other directory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-06-26 22:59:50 -0400 (Thu, 26 Jun 2008)
New Revision: 4326
Added:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java
Log:
JBREM-1005: New unit test.
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java 2008-06-27 02:59:50 UTC (rev 4326)
@@ -0,0 +1,318 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.timertask;
+
+import java.lang.reflect.Field;
+import java.net.InetAddress;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import javax.management.MBeanServer;
+
+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.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.callback.ServerInvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+import org.jboss.remoting.transport.bisocket.Bisocket;
+import org.jboss.remoting.transport.bisocket.BisocketClientInvoker;
+import org.jboss.remoting.transport.bisocket.BisocketServerInvoker;
+
+
+/**
+ * Unit test for JBREM-1005.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Jun 26, 2008
+ * </p>
+ */
+public class TimerTaskTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(TimerTaskTestCase.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.INFO);
+ 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 testZeroPingFrequency() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer("0");
+
+ // 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();
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Set up callback handler.
+ TestCallbackHandler callbackHandler = new TestCallbackHandler();
+ HashMap metadata = new HashMap();
+ metadata.put(Bisocket.IS_CALLBACK_SERVER, "true");
+ client.addListener(callbackHandler, metadata);
+ assertEquals(1, callbackHandler.counter);
+
+ // Verify ControlMonitorTimerTask is not created.
+ Set callbackConnectors = client.getCallbackConnectors(callbackHandler);
+ assertEquals(1, callbackConnectors.size());
+ Connector callbackConnector = (Connector) callbackConnectors.iterator().next();
+ Field field = BisocketServerInvoker.class.getDeclaredField("controlMonitorTimerTask");
+ field.setAccessible(true);
+ BisocketServerInvoker serverInvoker = (BisocketServerInvoker) callbackConnector.getServerInvoker();
+ TimerTask timerTask = (TimerTask) field.get(serverInvoker);
+ assertNull(timerTask);
+ log.info("ControlMonitorTimerTask was not created");
+
+ // Verify PingTimerTask is not created.
+ field = ServerInvoker.class.getDeclaredField("callbackHandlers");
+ field.setAccessible(true);
+ serverInvoker = (BisocketServerInvoker) connector.getServerInvoker();
+ Map callbackHandlers = (Map) field.get(serverInvoker);
+ assertEquals(1, callbackHandlers.size());
+ Object o = callbackHandlers.values().iterator().next();
+ Client callbackClient = ((ServerInvokerCallbackHandler) o).getCallbackClient();
+ BisocketClientInvoker clientInvoker = (BisocketClientInvoker) callbackClient.getInvoker();
+ field = BisocketClientInvoker.class.getDeclaredField("pingTimerTask");
+ field.setAccessible(true);
+ timerTask = (TimerTask) field.get(clientInvoker);
+ assertNull(timerTask);
+ log.info("PingTimerTask was not created");
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testNonZeroPingFrequency() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer("20");
+
+ // 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();
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Set up callback handler.
+ TestCallbackHandler callbackHandler = new TestCallbackHandler();
+ HashMap metadata = new HashMap();
+ metadata.put(Bisocket.IS_CALLBACK_SERVER, "true");
+ client.addListener(callbackHandler, metadata);
+ assertEquals(1, callbackHandler.counter);
+
+ // Verify ControlMonitorTimerTask is created.
+ Set callbackConnectors = client.getCallbackConnectors(callbackHandler);
+ assertEquals(1, callbackConnectors.size());
+ Connector callbackConnector = (Connector) callbackConnectors.iterator().next();
+ Field field = BisocketServerInvoker.class.getDeclaredField("controlMonitorTimerTask");
+ field.setAccessible(true);
+ BisocketServerInvoker serverInvoker = (BisocketServerInvoker) callbackConnector.getServerInvoker();
+ TimerTask timerTask = (TimerTask) field.get(serverInvoker);
+ assertNotNull(timerTask);
+ log.info("ControlMonitorTimerTask was created");
+
+ // Verify PingTimerTask is created.
+ field = ServerInvoker.class.getDeclaredField("callbackHandlers");
+ field.setAccessible(true);
+ BisocketServerInvoker callbackServerInvoker = (BisocketServerInvoker) connector.getServerInvoker();
+ Map callbackHandlers = (Map) field.get(callbackServerInvoker);
+ assertEquals(1, callbackHandlers.size());
+ Object o = callbackHandlers.values().iterator().next();
+ Client callbackClient = ((ServerInvokerCallbackHandler) o).getCallbackClient();
+ BisocketClientInvoker clientInvoker = (BisocketClientInvoker) callbackClient.getInvoker();
+ field = BisocketClientInvoker.class.getDeclaredField("pingTimerTask");
+ field.setAccessible(true);
+ timerTask = (TimerTask) field.get(clientInvoker);
+ assertNotNull(timerTask);
+ log.info("PingTimerTask was created");
+
+ // Get count of ControlMonitorTimerTasks.
+ field = BisocketServerInvoker.class.getDeclaredField("timer");
+ field.setAccessible(true);
+ Timer timer = (Timer) field.get(null);
+ field = Timer.class.getDeclaredField("queue");
+ field.setAccessible(true);
+ Object taskQueue = field.get(timer);
+ Field serverTimerfield = taskQueue.getClass().getDeclaredField("size");
+ serverTimerfield.setAccessible(true);
+ int serverSize = ((Integer) serverTimerfield.get(taskQueue)).intValue();
+ log.info("ControlMonitorTimerTasks: " + serverSize);
+
+ // Get count of PingTimerTasks.
+ field = BisocketClientInvoker.class.getDeclaredField("timer");
+ field.setAccessible(true);
+ timer = (Timer) field.get(null);
+ field = Timer.class.getDeclaredField("queue");
+ field.setAccessible(true);
+ taskQueue = field.get(timer);
+ Field clientTimerfield = taskQueue.getClass().getDeclaredField("size");
+ clientTimerfield.setAccessible(true);
+ int clientSize = ((Integer) clientTimerfield.get(taskQueue)).intValue();
+ log.info("PingTimerTasks: " + clientSize);
+
+ // Shut down callback connection and verify TimerTasks are removed from
+ // Timer queue.
+ client.removeListener(callbackHandler);
+ serverSize = ((Integer) serverTimerfield.get(taskQueue)).intValue();
+ log.info("ControlMonitorTimerTasks: " + serverSize);
+ assertEquals(0, serverSize);
+ clientSize = ((Integer) clientTimerfield.get(taskQueue)).intValue();
+ log.info("PingTimerTasks: " + clientSize);
+ assertEquals(0, clientSize);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected String getTransport()
+ {
+ return "bisocket";
+ }
+
+
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+
+
+ protected void setupServer(String pingFrequency) throws Exception
+ {
+ host = InetAddress.getLocalHost().getHostAddress();
+ port = PortUtil.findFreePort(host);
+ locatorURI = getTransport() + "://" + host + ":" + port;
+ locatorURI += "/?" + Bisocket.PING_FREQUENCY + "=" + pingFrequency;
+ serverLocator = new InvokerLocator(locatorURI);
+ log.info("Starting remoting server with locator uri of: " + locatorURI);
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ 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
+ {
+ public void addListener(InvokerCallbackHandler callbackHandler)
+ {
+ try
+ {
+ callbackHandler.handleCallback(new Callback("callback"));
+ }
+ catch (HandleCallbackException e)
+ {
+ log.error("Unable to send callback", e);
+ }
+ }
+ 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 TestCallbackHandler implements InvokerCallbackHandler
+ {
+ public int counter;
+ public void handleCallback(Callback callback) throws HandleCallbackException
+ {
+ counter++;
+ log.info("received callback");
+ }
+ }
+}
\ No newline at end of file
16 years, 5 months
JBoss Remoting SVN: r4325 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-06-26 22:58:47 -0400 (Thu, 26 Jun 2008)
New Revision: 4325
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java
Log:
JBREM-1005: (1) TimerTasks aren't created if pingFrequency == 0.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java 2008-06-24 02:12:30 UTC (rev 4324)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java 2008-06-27 02:58:47 UTC (rev 4325)
@@ -283,24 +283,28 @@
throw new ConnectionFailedException("Unable to get control socket output stream");
}
log.debug("got control socket( " + listenerId + "): " + controlSocket);
- pingTimerTask = new PingTimerTask(this);
- synchronized (timerLock)
+ if (pingFrequency > 0)
{
- if (timer == null)
+ pingTimerTask = new PingTimerTask(this);
+
+ synchronized (timerLock)
{
- timer = new Timer(true);
+ if (timer == null)
+ {
+ timer = new Timer(true);
+ }
+ try
+ {
+ timer.schedule(pingTimerTask, pingFrequency, pingFrequency);
+ }
+ catch (IllegalStateException e)
+ {
+ log.debug("Unable to schedule TimerTask on existing Timer", e);
+ timer = new Timer(true);
+ timer.schedule(pingTimerTask, pingFrequency, pingFrequency);
+ }
}
- try
- {
- timer.schedule(pingTimerTask, pingFrequency, pingFrequency);
- }
- catch (IllegalStateException e)
- {
- log.debug("Unable to schedule TimerTask on existing Timer", e);
- timer = new Timer(true);
- timer.schedule(pingTimerTask, pingFrequency, pingFrequency);
- }
}
}
@@ -523,24 +527,27 @@
if (pingTimerTask != null)
pingTimerTask.cancel();
- pingTimerTask = new PingTimerTask(this);
+ if (pingFrequency > 0)
+ {
+ pingTimerTask = new PingTimerTask(this);
- synchronized (timerLock)
- {
- if (timer == null)
+ synchronized (timerLock)
{
- timer = new Timer(true);
+ if (timer == null)
+ {
+ timer = new Timer(true);
+ }
+ try
+ {
+ timer.schedule(pingTimerTask, pingFrequency, pingFrequency);
+ }
+ catch (IllegalStateException e)
+ {
+ log.debug("Unable to schedule TimerTask on existing Timer", e);
+ timer = new Timer(true);
+ timer.schedule(pingTimerTask, pingFrequency, pingFrequency);
+ }
}
- try
- {
- timer.schedule(pingTimerTask, pingFrequency, pingFrequency);
- }
- catch (IllegalStateException e)
- {
- log.debug("Unable to schedule TimerTask on existing Timer", e);
- timer = new Timer(true);
- timer.schedule(pingTimerTask, pingFrequency, pingFrequency);
- }
}
}
@@ -619,6 +626,7 @@
controlOutputStream = null;
}
cancel();
+ timer.purge();
}
public void run()
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java 2008-06-24 02:12:30 UTC (rev 4324)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java 2008-06-27 02:58:47 UTC (rev 4325)
@@ -157,23 +157,26 @@
threadpool = new LinkedList();
checkSocketFactoryWrapper();
- controlMonitorTimerTask = new ControlMonitorTimerTask(this);
- synchronized (timerLock)
+ if (pingFrequency > 0)
{
- if (timer == null)
+ controlMonitorTimerTask = new ControlMonitorTimerTask(this);
+ synchronized (timerLock)
{
- timer = new Timer(true);
+ if (timer == null)
+ {
+ timer = new Timer(true);
+ }
+ try
+ {
+ timer.schedule(controlMonitorTimerTask, pingFrequency, pingFrequency);
+ }
+ catch (IllegalStateException e)
+ {
+ log.debug("Unable to schedule TimerTask on existing Timer", e);
+ timer = new Timer(true);
+ timer.schedule(controlMonitorTimerTask, pingFrequency, pingFrequency);
+ }
}
- try
- {
- timer.schedule(controlMonitorTimerTask, pingFrequency, pingFrequency);
- }
- catch (IllegalStateException e)
- {
- log.debug("Unable to schedule TimerTask on existing Timer", e);
- timer = new Timer(true);
- timer.schedule(controlMonitorTimerTask, pingFrequency, pingFrequency);
- }
}
running = true;
@@ -1197,6 +1200,7 @@
listenerIdToInvokerLocatorMap = null;
controlConnectionThreadMap = null;
cancel();
+ timer.purge();
}
public void run()
16 years, 5 months
JBoss Remoting SVN: r4324 - remoting2/tags.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-06-23 22:12:30 -0400 (Mon, 23 Jun 2008)
New Revision: 4324
Added:
remoting2/tags/2.2.2-SP8/
Log:
Copied: remoting2/tags/2.2.2-SP8 (from rev 4323, remoting2/branches/2.2)
16 years, 5 months