activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r945524 - in /activemq/trunk/kahadb/src/main/java/org/apache/kahadb: journal/Journal.java util/Scheduler.java
Date Tue, 18 May 2010 07:23:20 GMT
Author: rajdavies
Date: Tue May 18 07:23:20 2010
New Revision: 945524

URL: http://svn.apache.org/viewvc?rev=945524&view=rev
Log:
removing static schedulers - so ActiveMQ will shutdown cleanly - see https://issues.apache.org/activemq/browse/AMQ-2568

Modified:
    activemq/trunk/kahadb/src/main/java/org/apache/kahadb/journal/Journal.java
    activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/Scheduler.java

Modified: activemq/trunk/kahadb/src/main/java/org/apache/kahadb/journal/Journal.java
URL: http://svn.apache.org/viewvc/activemq/trunk/kahadb/src/main/java/org/apache/kahadb/journal/Journal.java?rev=945524&r1=945523&r2=945524&view=diff
==============================================================================
--- activemq/trunk/kahadb/src/main/java/org/apache/kahadb/journal/Journal.java (original)
+++ activemq/trunk/kahadb/src/main/java/org/apache/kahadb/journal/Journal.java Tue May 18
07:23:20 2010
@@ -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();
     }

Modified: activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/Scheduler.java
URL: http://svn.apache.org/viewvc/activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/Scheduler.java?rev=945524&r1=945523&r2=945524&view=diff
==============================================================================
--- activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/Scheduler.java (original)
+++ activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/Scheduler.java Tue May 18 07:23:20
2010
@@ -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() {



Mime
View raw message