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()