r243@34: chirino | 2007-02-23 14:49:23 -0500

Disconnect failed connections quicker
 


git-svn-id: https://svn.apache.org/repos/asf/activemq/branches/activemq-4.1@511087 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2007-02-23 20:25:02 +00:00
parent e0a8dede18
commit 043edbe4a0
4 changed files with 27 additions and 6 deletions

View File

@ -882,14 +882,15 @@ public class TransportConnection implements Service, Connection, Task, CommandVi
// Clear out what's on the queue so that we can send the Shutdown command quicker.
dispatchQueue.clear();
dispatchAsync(new ShutdownInfo());
// Wait up to 10 seconds for the shutdown command to be sent to
// the client.
dispatchStopped.await(10, TimeUnit.SECONDS);
if( transportException==null ) {
// Wait up to 10 seconds for the shutdown command to be sent to
// the client.
dispatchAsync(new ShutdownInfo());
dispatchStopped.await(10, TimeUnit.SECONDS);
}
if( taskRunner!=null )
taskRunner.shutdown();
taskRunner.shutdownNoWait();
// Clear out the dispatch queue to release any memory that
// is being held on to.

View File

@ -73,6 +73,19 @@ class DedicatedTaskRunner implements TaskRunner {
}
}
/**
* shut down the task
* @throws InterruptedException
*/
public void shutdownNoWait() throws InterruptedException{
synchronized(mutex){
shutdown=true;
pending=true;
mutex.notifyAll();
}
}
private void runTask() {
try {

View File

@ -90,6 +90,12 @@ class PooledTaskRunner implements TaskRunner {
}
}
}
}
public void shutdownNoWait() throws InterruptedException{
synchronized(runable){
shutdown=true;
}
}
private void runTask() {

View File

@ -25,4 +25,5 @@ package org.apache.activemq.thread;
public interface TaskRunner {
public abstract void wakeup() throws InterruptedException;
public abstract void shutdown() throws InterruptedException;
public abstract void shutdownNoWait() throws InterruptedException;
}