hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject svn commit: r1305722 - /hbase/trunk/src/main/java/org/apache/hadoop/hbase/metrics/histogram/ExponentiallyDecayingSample.java
Date Tue, 27 Mar 2012 03:34:51 GMT
Author: larsh
Date: Tue Mar 27 03:34:51 2012
New Revision: 1305722

URL: http://svn.apache.org/viewvc?rev=1305722&view=rev
Log:
HBASE-5641 decayingSampleTick1 prevents HBase from shutting down.

Modified:
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/metrics/histogram/ExponentiallyDecayingSample.java

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/metrics/histogram/ExponentiallyDecayingSample.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/metrics/histogram/ExponentiallyDecayingSample.java?rev=1305722&r1=1305721&r2=1305722&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/metrics/histogram/ExponentiallyDecayingSample.java
(original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/metrics/histogram/ExponentiallyDecayingSample.java
Tue Mar 27 03:34:51 2012
@@ -22,12 +22,12 @@ import java.util.Random;
 import java.util.concurrent.ConcurrentSkipListMap;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
-import org.apache.hadoop.hbase.util.Threads;
-
 /**
  * An exponentially-decaying random sample of {@code long}s. 
  * Uses Cormode et al's forward-decaying priority reservoir sampling method 
@@ -44,7 +44,7 @@ public class ExponentiallyDecayingSample
 
   private static final ScheduledExecutorService TICK_SERVICE = 
       Executors.newScheduledThreadPool(1, 
-          Threads.getNamedThreadFactory("decayingSampleTick"));
+          getNamedDaemonThreadFactory("decayingSampleTick"));
 
   private static volatile long CURRENT_TICK = 
       TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());
@@ -209,4 +209,18 @@ public class ExponentiallyDecayingSample
   private void unlockForRegularUsage() {
     lock.readLock().unlock();
   }
+
+  private static ThreadFactory getNamedDaemonThreadFactory(final String prefix) {
+    return new ThreadFactory() {
+
+      private final AtomicInteger threadNumber = new AtomicInteger(1);
+      
+      @Override
+      public Thread newThread(Runnable r) {
+        Thread t= new Thread(r, prefix + threadNumber.getAndIncrement());
+        t.setDaemon(true);
+        return t;
+      }
+    };
+  }
 }



Mime
View raw message