cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1066890 - in /cassandra/branches/cassandra-0.7: ./ src/java/org/apache/cassandra/concurrent/ src/java/org/apache/cassandra/db/ src/java/org/apache/cassandra/service/
Date Thu, 03 Feb 2011 17:42:07 GMT
Author: jbellis
Date: Thu Feb  3 17:42:07 2011
New Revision: 1066890

URL: http://svn.apache.org/viewvc?rev=1066890&view=rev
Log:
log exceptions on scheduled executors
patch by jbellis; reviewed by stuhood for CASSANDRA-2061

Added:
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/concurrent/DebuggableScheduledThreadPoolExecutor.java
Removed:
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/concurrent/RetryingScheduledThreadPoolExecutor.java
Modified:
    cassandra/branches/cassandra-0.7/CHANGES.txt
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/concurrent/DebuggableThreadPoolExecutor.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageService.java

Modified: cassandra/branches/cassandra-0.7/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/CHANGES.txt?rev=1066890&r1=1066889&r2=1066890&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.7/CHANGES.txt Thu Feb  3 17:42:07 2011
@@ -51,6 +51,8 @@
  * avoid blocking gossip while deleting handoff hints (CASSANDRA-2073)
  * ignore messages from newer versions, keep track of nodes in gossip 
    regardless of version (CASSANDRA-1970)
+ * log exceptions on scheduled executors (CASSANDRA-2061)
+
 
 0.7.0-final
  * fix offsets to ByteBuffer.get (CASSANDRA-1939)

Added: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/concurrent/DebuggableScheduledThreadPoolExecutor.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/concurrent/DebuggableScheduledThreadPoolExecutor.java?rev=1066890&view=auto
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/concurrent/DebuggableScheduledThreadPoolExecutor.java
(added)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/concurrent/DebuggableScheduledThreadPoolExecutor.java
Thu Feb  3 17:42:07 2011
@@ -0,0 +1,53 @@
+package org.apache.cassandra.concurrent;
+/*
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ */
+
+
+import java.util.concurrent.*;
+
+import org.apache.log4j.Logger;
+
+public class DebuggableScheduledThreadPoolExecutor extends ScheduledThreadPoolExecutor
+{
+    protected static Logger logger = Logger.getLogger(DebuggableScheduledThreadPoolExecutor.class);
+
+    public DebuggableScheduledThreadPoolExecutor(String threadPoolName, int priority)
+    {
+        this(1, threadPoolName, priority);
+    }
+
+    public DebuggableScheduledThreadPoolExecutor(int corePoolSize, String threadPoolName,
int priority)
+    {
+        super(corePoolSize, new NamedThreadFactory(threadPoolName, priority));
+    }
+
+    public DebuggableScheduledThreadPoolExecutor(String threadPoolName)
+    {
+        this(1, threadPoolName, Thread.NORM_PRIORITY);
+    }
+
+    @Override
+    public void afterExecute(Runnable r, Throwable t)
+    {
+        super.afterExecute(r,t);
+        DebuggableThreadPoolExecutor.logTaskException(r, t);
+    }
+}

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/concurrent/DebuggableThreadPoolExecutor.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/concurrent/DebuggableThreadPoolExecutor.java?rev=1066890&r1=1066889&r2=1066890&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/concurrent/DebuggableThreadPoolExecutor.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/concurrent/DebuggableThreadPoolExecutor.java
Thu Feb  3 17:42:07 2011
@@ -75,10 +75,15 @@ public class DebuggableThreadPoolExecuto
         }
     }
 
+    @Override
     public void afterExecute(Runnable r, Throwable t)
     {
         super.afterExecute(r,t);
+        logTaskException(r, t);
+    }
 
+    static void logTaskException(Runnable r, Throwable t)
+    {
         // exceptions wrapped by FutureTask
         if (r instanceof FutureTask)
         {
@@ -92,7 +97,9 @@ public class DebuggableThreadPoolExecuto
             }
             catch (ExecutionException e)
             {
-                if (Thread.getDefaultUncaughtExceptionHandler() != null)
+                if (Thread.getDefaultUncaughtExceptionHandler() == null)
+                    logger.error("Error in executor task", e.getCause());
+                else
                     Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(),
e.getCause());
             }
         }
@@ -100,7 +107,10 @@ public class DebuggableThreadPoolExecuto
         // exceptions for non-FutureTask runnables [i.e., added via execute() instead of
submit()]
         if (t != null)
         {
-            logger.error("Error in ThreadPoolExecutor", t);
+            if (Thread.getDefaultUncaughtExceptionHandler() == null)
+                logger.error("Error in executor task", t);
+            else
+                Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(),
t);
         }
     }
 }

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=1066890&r1=1066889&r2=1066890&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
Thu Feb  3 17:42:07 2011
@@ -34,9 +34,9 @@ import org.apache.commons.collections.It
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.cassandra.concurrent.DebuggableScheduledThreadPoolExecutor;
 import org.apache.cassandra.concurrent.JMXEnabledThreadPoolExecutor;
 import org.apache.cassandra.concurrent.NamedThreadFactory;
-import org.apache.cassandra.concurrent.RetryingScheduledThreadPoolExecutor;
 import org.apache.cassandra.concurrent.StageManager;
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.ColumnDefinition;
@@ -62,7 +62,7 @@ public class ColumnFamilyStore implement
     private static Logger logger = LoggerFactory.getLogger(ColumnFamilyStore.class);
 
     private static final ScheduledThreadPoolExecutor cacheSavingExecutor =
-            new RetryingScheduledThreadPoolExecutor("CACHE-SAVER", Thread.MIN_PRIORITY);
+            new DebuggableScheduledThreadPoolExecutor("CACHE-SAVER", Thread.MIN_PRIORITY);
 
     /*
      * submitFlush first puts [Binary]Memtable.getSortedContents on the flushSorter executor,

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageService.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageService.java?rev=1066890&r1=1066889&r2=1066890&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageService.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageService.java
Thu Feb  3 17:42:07 2011
@@ -32,17 +32,17 @@ import javax.management.ObjectName;
 import com.google.common.base.Charsets;
 import com.google.common.collect.HashMultimap;
 import com.google.common.collect.Multimap;
-
-import org.apache.cassandra.db.commitlog.CommitLog;
-import org.apache.cassandra.locator.*;
 import org.apache.log4j.Level;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import org.apache.cassandra.concurrent.*;
+import org.apache.cassandra.concurrent.DebuggableScheduledThreadPoolExecutor;
+import org.apache.cassandra.concurrent.Stage;
+import org.apache.cassandra.concurrent.StageManager;
 import org.apache.cassandra.config.*;
 import org.apache.cassandra.db.*;
+import org.apache.cassandra.db.commitlog.CommitLog;
 import org.apache.cassandra.db.migration.AddKeyspace;
 import org.apache.cassandra.db.migration.Migration;
 import org.apache.cassandra.dht.BootStrapper;
@@ -52,6 +52,10 @@ import org.apache.cassandra.dht.Token;
 import org.apache.cassandra.gms.*;
 import org.apache.cassandra.io.DeletionService;
 import org.apache.cassandra.io.util.FileUtils;
+import org.apache.cassandra.locator.AbstractReplicationStrategy;
+import org.apache.cassandra.locator.DynamicEndpointSnitch;
+import org.apache.cassandra.locator.IEndpointSnitch;
+import org.apache.cassandra.locator.TokenMetadata;
 import org.apache.cassandra.net.IAsyncResult;
 import org.apache.cassandra.net.Message;
 import org.apache.cassandra.net.MessagingService;
@@ -146,7 +150,7 @@ public class StorageService implements I
     }};
 
 
-    public static final RetryingScheduledThreadPoolExecutor scheduledTasks = new RetryingScheduledThreadPoolExecutor("ScheduledTasks");
+    public static final DebuggableScheduledThreadPoolExecutor scheduledTasks = new DebuggableScheduledThreadPoolExecutor("ScheduledTasks");
 
     /* This abstraction maintains the token/endpoint metadata information */
     private TokenMetadata tokenMetadata_ = new TokenMetadata();



Mime
View raw message