This is an automated email from the ASF dual-hosted git repository.

zhaijia pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new ec8b10a  Ensure we instantiate threads that extend Netty 
FastThreadLocalThread
ec8b10a is described below

commit ec8b10ae848576654748ba93ac8a5e0533a901a8
Author: Matteo Merli <[email protected]>
AuthorDate: Sun Mar 18 15:59:42 2018 +0800

    Ensure we instantiate threads that extend Netty FastThreadLocalThread
    
    Since we make heavy use of `Recycler` and other `FastThreadLocal` objects 
from Netty, we should make sure that all (critical) threads that we instantiate 
are inheriting from `FastThreadLocalThread`.
    
    `FastThreadLocalThread` has an optimization that makes access to 
`FastThreadLocal` faster. It's a class that extends regular `Thread` and adds a 
field for the thread local access.
    
    There are a couple of places where we're currently not using 
`FastThreadLocal`:
     * `OrderedScheduler` builder
     * `BookieThread` (which is used in `Journal`, `ForceSyncThread`, etc..)
    
    Author: Matteo Merli <[email protected]>
    
    Reviewers: Jia Zhai <None>, Sijie Guo <[email protected]>
    
    This closes #1274 from merlimat/fast-thread-local
---
 .../java/org/apache/bookkeeper/common/util/OrderedScheduler.java    | 6 ++++--
 .../src/main/java/org/apache/bookkeeper/bookie/BookieThread.java    | 4 +++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git 
a/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/util/OrderedScheduler.java
 
b/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/util/OrderedScheduler.java
index 463e292..b24fb95 100644
--- 
a/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/util/OrderedScheduler.java
+++ 
b/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/util/OrderedScheduler.java
@@ -22,13 +22,15 @@ import static 
com.google.common.base.Preconditions.checkArgument;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.ListeningScheduledExecutorService;
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
+
+import io.netty.util.concurrent.DefaultThreadFactory;
+
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Random;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledFuture;
@@ -134,7 +136,7 @@ public class OrderedScheduler implements 
ScheduledExecutorService {
         @SuppressWarnings("unchecked")
         public T build() {
             if (null == threadFactory) {
-                threadFactory = Executors.defaultThreadFactory();
+                threadFactory = new DefaultThreadFactory(name);
             }
             return (T) new OrderedScheduler(
                 name,
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieThread.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieThread.java
index 81cae9e..16bf35c 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieThread.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieThread.java
@@ -17,6 +17,8 @@
  */
 package org.apache.bookkeeper.bookie;
 
+import io.netty.util.concurrent.FastThreadLocalThread;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -25,7 +27,7 @@ import org.slf4j.LoggerFactory;
  * Any common handing that we require for all bookie threads
  * should be implemented here
  */
-public class BookieThread extends Thread implements
+public class BookieThread extends FastThreadLocalThread implements
         Thread.UncaughtExceptionHandler {
 
     private static final Logger LOG = LoggerFactory

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to