removing static schedulers - so ActiveMQ will shutdown cleanly - see https://issues.apache.org/activemq/browse/AMQ-2568

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@945524 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2010-05-18 07:23:20 +00:00
parent b09ed031aa
commit 54a00fe5fe
2 changed files with 26 additions and 7 deletions

View File

@ -20,18 +20,32 @@ import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.zip.Adler32;
import java.util.zip.Checksum;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.kahadb.journal.DataFileAppender.WriteCommand;
import org.apache.kahadb.journal.DataFileAppender.WriteKey;
import org.apache.kahadb.util.*;
import org.apache.kahadb.util.ByteSequence;
import org.apache.kahadb.util.DataByteArrayInputStream;
import org.apache.kahadb.util.DataByteArrayOutputStream;
import org.apache.kahadb.util.LinkedNodeList;
import org.apache.kahadb.util.SchedulerTimerTask;
import org.apache.kahadb.util.Sequence;
/**
* Manages DataFiles
@ -103,7 +117,7 @@ public class Journal {
private ReplicationTarget replicationTarget;
protected boolean checksum;
protected boolean checkForCorruptionOnStartup;
private Timer timer = new Timer("KahaDB Scheduler", true);
public synchronized void start() throws IOException {
@ -165,7 +179,9 @@ public class Journal {
cleanup();
}
};
Scheduler.executePeriodically(cleanupTask, DEFAULT_CLEANUP_INTERVAL);
this.timer = new Timer("KahaDB Scheduler", true);
TimerTask task = new SchedulerTimerTask(cleanupTask);
this.timer.scheduleAtFixedRate(task, DEFAULT_CLEANUP_INTERVAL,DEFAULT_CLEANUP_INTERVAL);
long end = System.currentTimeMillis();
LOG.trace("Startup took: "+(end-start)+" ms");
}
@ -345,7 +361,9 @@ public class Journal {
if (!started) {
return;
}
Scheduler.cancel(cleanupTask);
if (this.timer != null) {
this.timer.cancel();
}
accessorPool.close();
appender.close();
fileMap.clear();
@ -429,6 +447,7 @@ public class Journal {
this.maxFileLength = maxFileLength;
}
@Override
public String toString() {
return directory.toString();
}

View File

@ -27,7 +27,7 @@ public final class Scheduler {
public static final Timer CLOCK_DAEMON = new Timer("ActiveMQ Scheduler", true);
public static final Timer CLOCK_DAEMON = new Timer("KahaDB Scheduler", true);
private static final HashMap<Runnable, TimerTask> TIMER_TASKS = new HashMap<Runnable, TimerTask>();
private Scheduler() {