cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r817928 - in /incubator/cassandra/trunk/src/java/org/apache/cassandra: concurrent/ db/ net/ service/ utils/
Date Wed, 23 Sep 2009 01:57:38 GMT
Author: jbellis
Date: Wed Sep 23 01:57:37 2009
New Revision: 817928

URL: http://svn.apache.org/viewvc?rev=817928&view=rev
Log:
clean up ThreadFactoryImpl and rename to NamedThreadFactory
patch by jbellis; reviewed by goffinet for CASSANDRA-401

Added:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/NamedThreadFactory.java
      - copied, changed from r817927, incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/ThreadFactoryImpl.java
Removed:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/ThreadFactoryImpl.java
Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/DebuggableThreadPoolExecutor.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/MultiThreadedStage.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/HintedHandOffManager.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/PeriodicFlushManager.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/net/MessagingService.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageLoadBalancer.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/FileUtils.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/DebuggableThreadPoolExecutor.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/DebuggableThreadPoolExecutor.java?rev=817928&r1=817927&r2=817928&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/DebuggableThreadPoolExecutor.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/DebuggableThreadPoolExecutor.java
Wed Sep 23 01:57:37 2009
@@ -38,7 +38,7 @@
     private ObjectName objName;
     public DebuggableThreadPoolExecutor(String threadPoolName) 
     {
-        this(1, 1, Integer.MAX_VALUE, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(),
new ThreadFactoryImpl(threadPoolName));
+        this(1, 1, Integer.MAX_VALUE, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(),
new NamedThreadFactory(threadPoolName));
     }
 
     public DebuggableThreadPoolExecutor(int corePoolSize,
@@ -46,7 +46,7 @@
             long keepAliveTime,
             TimeUnit unit,
             BlockingQueue<Runnable> workQueue,
-            ThreadFactoryImpl threadFactory)
+            NamedThreadFactory threadFactory)
     {
         super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory);
         super.prestartAllCoreThreads();
@@ -54,7 +54,7 @@
         MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
         try
         {
-            objName = new ObjectName("org.apache.cassandra.concurrent:type=" + threadFactory.id_);
+            objName = new ObjectName("org.apache.cassandra.concurrent:type=" + threadFactory.id);
             mbs.registerMBean(this, objName);
         }
         catch (Exception e)

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/MultiThreadedStage.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/MultiThreadedStage.java?rev=817928&r1=817927&r2=817928&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/MultiThreadedStage.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/MultiThreadedStage.java
Wed Sep 23 01:57:37 2009
@@ -21,13 +21,6 @@
 
 import java.util.concurrent.*;
 
-import javax.naming.OperationNotSupportedException;
-
-import org.apache.cassandra.net.EndPoint;
-import org.apache.cassandra.net.MessagingService;
-import org.apache.cassandra.utils.LogUtil;
-import org.apache.log4j.Logger;
-
 /**
  * This class is an implementation of the <i>IStage</i> interface. In particular
  * it is for a stage that has a thread pool with multiple threads. For details 
@@ -47,7 +40,7 @@
                 Integer.MAX_VALUE,
                 TimeUnit.SECONDS,
                 new LinkedBlockingQueue<Runnable>(),
-                new ThreadFactoryImpl(name)
+                new NamedThreadFactory(name)
                 );        
     }
     

Copied: incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/NamedThreadFactory.java
(from r817927, incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/ThreadFactoryImpl.java)
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/NamedThreadFactory.java?p2=incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/NamedThreadFactory.java&p1=incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/ThreadFactoryImpl.java&r1=817927&r2=817928&rev=817928&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/ThreadFactoryImpl.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/NamedThreadFactory.java
Wed Sep 23 01:57:37 2009
@@ -20,7 +20,6 @@
 
 import java.util.concurrent.*;
 import java.util.concurrent.atomic.*;
-import org.apache.cassandra.utils.*;
 
 /**
  * This class is an implementation of the <i>ThreadFactory</i> interface. This

@@ -28,23 +27,19 @@
  * a tool like JConsole.
  */
 
-public class ThreadFactoryImpl implements ThreadFactory
+public class NamedThreadFactory implements ThreadFactory
 {
-    protected String id_;
-    protected ThreadGroup threadGroup_;
-    protected final AtomicInteger threadNbr_ = new AtomicInteger(1);
-    
-    public ThreadFactoryImpl(String id)
+    protected final String id;
+    protected final AtomicInteger n = new AtomicInteger(1);
+
+    public NamedThreadFactory(String id)
     {
-        SecurityManager sm = System.getSecurityManager();
-        threadGroup_ = ( sm != null ) ? sm.getThreadGroup() : Thread.currentThread().getThreadGroup();
-        id_ = id;
-    }    
-    
+        this.id = id;
+    }
+
     public Thread newThread(Runnable runnable)
     {        
-        String name = id_ + ":" + threadNbr_.getAndIncrement();       
-        Thread thread = new Thread(threadGroup_, runnable, name);        
-        return thread;
+        String name = id + ":" + n.getAndIncrement();
+        return new Thread(runnable, name);
     }
 }

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=817928&r1=817927&r2=817928&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Wed
Sep 23 01:57:37 2009
@@ -38,7 +38,7 @@
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.*;
 import org.apache.cassandra.concurrent.DebuggableThreadPoolExecutor;
-import org.apache.cassandra.concurrent.ThreadFactoryImpl;
+import org.apache.cassandra.concurrent.NamedThreadFactory;
 import org.apache.cassandra.db.filter.*;
 import org.apache.cassandra.db.marshal.AbstractType;
 
@@ -59,7 +59,7 @@
                                                                                         
   Integer.MAX_VALUE,
                                                                                         
   TimeUnit.SECONDS,
                                                                                         
   new LinkedBlockingQueue<Runnable>(2 * Runtime.getRuntime().availableProcessors()),
-                                                                                        
   new ThreadFactoryImpl("MEMTABLE-FLUSHER-POOL"));
+                                                                                        
   new NamedThreadFactory("MEMTABLE-FLUSHER-POOL"));
     private static ExecutorService commitLogUpdater_ = new DebuggableThreadPoolExecutor("MEMTABLE-POST-FLUSHER");
 
     private final String table_;

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java?rev=817928&r1=817927&r2=817928&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java Wed
Sep 23 01:57:37 2009
@@ -30,7 +30,7 @@
 import javax.management.ObjectName;
 
 import org.apache.cassandra.concurrent.DebuggableScheduledThreadPoolExecutor;
-import org.apache.cassandra.concurrent.ThreadFactoryImpl;
+import org.apache.cassandra.concurrent.NamedThreadFactory;
 import org.apache.cassandra.dht.Range;
 import org.apache.cassandra.net.EndPoint;
 import org.apache.cassandra.io.SSTableReader;
@@ -159,7 +159,7 @@
     }
     
     
-    private ScheduledExecutorService compactor_ = new DebuggableScheduledThreadPoolExecutor(1,
new ThreadFactoryImpl("COMPACTION-POOL"));
+    private ScheduledExecutorService compactor_ = new DebuggableScheduledThreadPoolExecutor(1,
new NamedThreadFactory("COMPACTION-POOL"));
 
     /**
      * Call this whenever a compaction might be needed on the given columnfamily.

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/HintedHandOffManager.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/HintedHandOffManager.java?rev=817928&r1=817927&r2=817928&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/HintedHandOffManager.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/HintedHandOffManager.java Wed
Sep 23 01:57:37 2009
@@ -29,7 +29,7 @@
 import org.apache.log4j.Logger;
 
 import org.apache.cassandra.concurrent.DebuggableScheduledThreadPoolExecutor;
-import org.apache.cassandra.concurrent.ThreadFactoryImpl;
+import org.apache.cassandra.concurrent.NamedThreadFactory;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.gms.FailureDetector;
 import org.apache.cassandra.net.EndPoint;
@@ -55,7 +55,7 @@
     private static Lock lock_ = new ReentrantLock();
     private static Logger logger_ = Logger.getLogger(HintedHandOffManager.class);
     final static long intervalInMins_ = 60;
-    private ScheduledExecutorService executor_ = new DebuggableScheduledThreadPoolExecutor(1,
new ThreadFactoryImpl("HINTED-HANDOFF-POOL"));
+    private ScheduledExecutorService executor_ = new DebuggableScheduledThreadPoolExecutor(1,
new NamedThreadFactory("HINTED-HANDOFF-POOL"));
     public static final String HINTS_CF = "HintsColumnFamily";
 
 

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/PeriodicFlushManager.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/PeriodicFlushManager.java?rev=817928&r1=817927&r2=817928&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/PeriodicFlushManager.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/PeriodicFlushManager.java Wed
Sep 23 01:57:37 2009
@@ -27,7 +27,6 @@
 import org.apache.log4j.Logger;
 
 import org.apache.cassandra.concurrent.*;
-import org.apache.cassandra.service.StorageService;
 
 /**
  *  Background flusher that force-flushes a column family periodically.
@@ -37,7 +36,7 @@
     private static Logger logger_ = Logger.getLogger(PeriodicFlushManager.class);
     private static PeriodicFlushManager instance_;
     private static Lock lock_ = new ReentrantLock();
-    private ScheduledExecutorService flusher_ = new DebuggableScheduledThreadPoolExecutor(1,
new ThreadFactoryImpl("PERIODIC-FLUSHER-POOL"));
+    private ScheduledExecutorService flusher_ = new DebuggableScheduledThreadPoolExecutor(1,
new NamedThreadFactory("PERIODIC-FLUSHER-POOL"));
 
     public static PeriodicFlushManager instance()
     {

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/net/MessagingService.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/net/MessagingService.java?rev=817928&r1=817927&r2=817928&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/net/MessagingService.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/net/MessagingService.java Wed
Sep 23 01:57:37 2009
@@ -26,7 +26,6 @@
 import org.apache.log4j.Logger;
 
 import java.io.IOException;
-import java.net.MulticastSocket;
 import java.net.ServerSocket;
 import java.net.SocketException;
 import java.nio.ByteBuffer;
@@ -144,7 +143,7 @@
                 Integer.MAX_VALUE,
                 TimeUnit.SECONDS,
                 new LinkedBlockingQueue<Runnable>(),
-                new ThreadFactoryImpl("MESSAGING-SERVICE-POOL")
+                new NamedThreadFactory("MESSAGING-SERVICE-POOL")
                 );
 
         messageDeserializerExecutor_ = new DebuggableThreadPoolExecutor( maxSize,
@@ -152,7 +151,7 @@
                 Integer.MAX_VALUE,
                 TimeUnit.SECONDS,
                 new LinkedBlockingQueue<Runnable>(),
-                new ThreadFactoryImpl("MESSAGE-DESERIALIZER-POOL")
+                new NamedThreadFactory("MESSAGE-DESERIALIZER-POOL")
                 ); 
         
         streamExecutor_ = new DebuggableThreadPoolExecutor("MESSAGE-STREAMING-POOL");

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageLoadBalancer.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageLoadBalancer.java?rev=817928&r1=817927&r2=817928&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageLoadBalancer.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageLoadBalancer.java
Wed Sep 23 01:57:37 2009
@@ -22,9 +22,7 @@
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ExecutorService;
-import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.log4j.Logger;
@@ -33,7 +31,7 @@
 import org.apache.cassandra.concurrent.DebuggableThreadPoolExecutor;
 import org.apache.cassandra.concurrent.SingleThreadedStage;
 import org.apache.cassandra.concurrent.StageManager;
-import org.apache.cassandra.concurrent.ThreadFactoryImpl;
+import org.apache.cassandra.concurrent.NamedThreadFactory;
 import org.apache.cassandra.dht.Token;
 import org.apache.cassandra.gms.ApplicationState;
 import org.apache.cassandra.gms.EndPointState;
@@ -188,7 +186,7 @@
     /* This thread pool is used for initiating load balancing operations */
     private ScheduledThreadPoolExecutor lb_ = new DebuggableScheduledThreadPoolExecutor(
             1,
-            new ThreadFactoryImpl("LB-OPERATIONS")
+            new NamedThreadFactory("LB-OPERATIONS")
             );
     /* This thread pool is used by target node to leave the ring. */
     private ExecutorService lbOperations_ = new DebuggableThreadPoolExecutor("LB-TARGET");

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java?rev=817928&r1=817927&r2=817928&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java Wed
Sep 23 01:57:37 2009
@@ -250,7 +250,7 @@
         consistencyManager_ = new DebuggableThreadPoolExecutor(DatabaseDescriptor.getConsistencyThreads(),
                                                                DatabaseDescriptor.getConsistencyThreads(),
                                                                Integer.MAX_VALUE, TimeUnit.SECONDS,
-                                                               new LinkedBlockingQueue<Runnable>(),
new ThreadFactoryImpl("CONSISTENCY-MANAGER"));
+                                                               new LinkedBlockingQueue<Runnable>(),
new NamedThreadFactory("CONSISTENCY-MANAGER"));
         
         StageManager.registerStage(StorageService.mutationStage_,
                                    new MultiThreadedStage(StorageService.mutationStage_,
DatabaseDescriptor.getConcurrentWriters()));

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/FileUtils.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/FileUtils.java?rev=817928&r1=817927&r2=817928&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/FileUtils.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/FileUtils.java Wed Sep 23
01:57:37 2009
@@ -22,11 +22,8 @@
 import java.text.DecimalFormat;
 import java.util.*;
 import java.util.concurrent.ExecutorService;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
 
 import org.apache.cassandra.concurrent.DebuggableThreadPoolExecutor;
-import org.apache.cassandra.concurrent.ThreadFactoryImpl;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.log4j.Logger;
 



Mime
View raw message