asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mb...@apache.org
Subject asterixdb git commit: ASTERIXDB-1611: Improve Thread Names
Date Fri, 30 Sep 2016 01:22:58 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master db6ff7151 -> 102ef590b


ASTERIXDB-1611: Improve Thread Names

Executor threads are now named as follows:

- "Executor-<thread number>:<nodeId|ClusterController>"

Change-Id: Iea54740c51a9ac9388337cf88260a8482ff4a334
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1226
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/102ef590
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/102ef590
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/102ef590

Branch: refs/heads/master
Commit: 102ef590b1475731732feadf8c7e7302b7bb9968
Parents: db6ff71
Author: Michael Blow <mblow@apache.org>
Authored: Thu Sep 29 15:57:24 2016 -0400
Committer: Michael Blow <mblow@apache.org>
Committed: Thu Sep 29 16:13:56 2016 -0700

----------------------------------------------------------------------
 .../bootstrap/CCApplicationEntryPoint.java      |  2 +-
 .../bootstrap/NCApplicationEntryPoint.java      |  3 +-
 .../common/api/AsterixThreadFactory.java        | 17 ++++-----
 .../cc/application/CCApplicationContext.java    |  3 +-
 .../common/application/ApplicationContext.java  | 16 +++------
 .../common/utils/HyracksThreadFactory.java      | 38 ++++++++++++++++++++
 .../nc/application/NCApplicationContext.java    |  3 +-
 7 files changed, 57 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/102ef590/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
index f6dfe4a..9120aa5 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
@@ -95,7 +95,7 @@ public class CCApplicationEntryPoint implements ICCApplicationEntryPoint
{
             LOGGER.info("Starting Asterix cluster controller");
         }
 
-        appCtx.setThreadFactory(new AsterixThreadFactory(new LifeCycleComponentManager()));
+        appCtx.setThreadFactory(new AsterixThreadFactory(appCtx.getThreadFactory(), new LifeCycleComponentManager()));
         GlobalRecoveryManager.instantiate((HyracksConnection) getNewHyracksClientConnection());
         ILibraryManager libraryManager = new ExternalLibraryManager();
         AsterixResourceIdManager resourceIdManager = new AsterixResourceIdManager();

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/102ef590/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
index c678bf3..f26afa8 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
@@ -95,7 +95,8 @@ public class NCApplicationEntryPoint implements INCApplicationEntryPoint
{
             throw e;
         }
 
-        ncAppCtx.setThreadFactory(new AsterixThreadFactory(ncAppCtx.getLifeCycleComponentManager()));
+        ncAppCtx.setThreadFactory(new AsterixThreadFactory(ncAppCtx.getThreadFactory(),
+                ncAppCtx.getLifeCycleComponentManager()));
         ncApplicationContext = ncAppCtx;
         nodeId = ncApplicationContext.getNodeId();
         if (LOGGER.isLoggable(Level.INFO)) {

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/102ef590/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/AsterixThreadFactory.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/AsterixThreadFactory.java
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/AsterixThreadFactory.java
index 6b4bf72..e215d6a 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/AsterixThreadFactory.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/AsterixThreadFactory.java
@@ -24,22 +24,19 @@ import org.apache.hyracks.api.lifecycle.ILifeCycleComponentManager;
 
 public class AsterixThreadFactory implements ThreadFactory {
 
+    private final ThreadFactory delegate;
     private final ILifeCycleComponentManager lccm;
 
-    public AsterixThreadFactory(ILifeCycleComponentManager lifeCycleComponentManager) {
+    public AsterixThreadFactory(ThreadFactory delegate, ILifeCycleComponentManager lifeCycleComponentManager)
{
+        this.delegate = delegate;
         this.lccm = lifeCycleComponentManager;
     }
 
     @Override
-    public Thread newThread(Runnable r) {
-        Thread t;
-        if ((r instanceof Thread)) {
-            t = (Thread) r;
-        } else {
-            t = new Thread(r);
-        }
-        t.setUncaughtExceptionHandler(lccm);
-        return t;
+    public Thread newThread(Runnable runnable) {
+        Thread thread = delegate.newThread(runnable);
+        thread.setUncaughtExceptionHandler(lccm);
+        return thread;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/102ef590/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/application/CCApplicationContext.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/application/CCApplicationContext.java
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/application/CCApplicationContext.java
index ad3ffc1..dfce7b8 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/application/CCApplicationContext.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/application/CCApplicationContext.java
@@ -38,6 +38,7 @@ import org.apache.hyracks.api.service.IControllerService;
 import org.apache.hyracks.control.cc.ClusterControllerService;
 import org.apache.hyracks.control.common.application.ApplicationContext;
 import org.apache.hyracks.control.common.context.ServerContext;
+import org.apache.hyracks.control.common.utils.HyracksThreadFactory;
 import org.apache.hyracks.control.common.work.IResultCallback;
 
 public class CCApplicationContext extends ApplicationContext implements ICCApplicationContext
{
@@ -55,7 +56,7 @@ public class CCApplicationContext extends ApplicationContext implements
ICCAppli
 
     public CCApplicationContext(ClusterControllerService ccs, ServerContext serverCtx, ICCContext
ccContext,
             IApplicationConfig appConfig) throws IOException {
-        super(serverCtx, appConfig);
+        super(serverCtx, appConfig, new HyracksThreadFactory("ClusterController"));
         this.ccContext = ccContext;
         this.ccs = ccs;
         initPendingNodeIds = new HashSet<>();

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/102ef590/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/application/ApplicationContext.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/application/ApplicationContext.java
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/application/ApplicationContext.java
index 23d287c..06bcda3 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/application/ApplicationContext.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/application/ApplicationContext.java
@@ -18,7 +18,6 @@
  */
 package org.apache.hyracks.control.common.application;
 
-import java.io.IOException;
 import java.io.Serializable;
 import java.util.concurrent.ThreadFactory;
 
@@ -30,22 +29,17 @@ import org.apache.hyracks.api.messages.IMessageBroker;
 import org.apache.hyracks.control.common.context.ServerContext;
 
 public abstract class ApplicationContext implements IApplicationContext {
-    protected ServerContext serverCtx;
+    protected final ServerContext serverCtx;
+    protected final IApplicationConfig appConfig;
+    protected ThreadFactory threadFactory;
     protected Serializable distributedState;
     protected IMessageBroker messageBroker;
-    protected final IApplicationConfig appConfig;
     protected IJobSerializerDeserializerContainer jobSerDeContainer = new JobSerializerDeserializerContainer();
-    protected ThreadFactory threadFactory = new ThreadFactory() {
-        public Thread newThread(Runnable r) {
-            Thread t = new Thread(r);
-            t.setDaemon(true);
-            return t;
-        }
-    };
 
-    public ApplicationContext(ServerContext serverCtx, IApplicationConfig appConfig) {
+    public ApplicationContext(ServerContext serverCtx, IApplicationConfig appConfig, ThreadFactory
threadFactory) {
         this.serverCtx = serverCtx;
         this.appConfig = appConfig;
+        this.threadFactory = threadFactory;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/102ef590/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/utils/HyracksThreadFactory.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/utils/HyracksThreadFactory.java
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/utils/HyracksThreadFactory.java
new file mode 100644
index 0000000..52631bf
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/utils/HyracksThreadFactory.java
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+package org.apache.hyracks.control.common.utils;
+
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class HyracksThreadFactory implements ThreadFactory {
+    private final String identifier;
+    private final AtomicInteger threadId = new AtomicInteger();
+
+    public HyracksThreadFactory(String identifier) {
+        this.identifier = identifier;
+    }
+
+    @Override
+    public Thread newThread(Runnable runnable) {
+        Thread t = new Thread(runnable, "Executor-" + threadId.incrementAndGet() + ":" +
identifier);
+        t.setDaemon(true);
+        return t;
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/102ef590/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/application/NCApplicationContext.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/application/NCApplicationContext.java
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/application/NCApplicationContext.java
index a2c3f4c..44549b4 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/application/NCApplicationContext.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/application/NCApplicationContext.java
@@ -32,6 +32,7 @@ import org.apache.hyracks.api.resources.memory.IMemoryManager;
 import org.apache.hyracks.api.service.IControllerService;
 import org.apache.hyracks.control.common.application.ApplicationContext;
 import org.apache.hyracks.control.common.context.ServerContext;
+import org.apache.hyracks.control.common.utils.HyracksThreadFactory;
 import org.apache.hyracks.control.nc.NodeControllerService;
 import org.apache.hyracks.control.nc.resources.memory.MemoryManager;
 
@@ -48,7 +49,7 @@ public class NCApplicationContext extends ApplicationContext implements
INCAppli
     public NCApplicationContext(NodeControllerService ncs, ServerContext serverCtx, IHyracksRootContext
rootCtx,
             String nodeId, MemoryManager memoryManager, ILifeCycleComponentManager lifeCyclecomponentManager,
             IApplicationConfig appConfig) throws IOException {
-        super(serverCtx, appConfig);
+        super(serverCtx, appConfig, new HyracksThreadFactory(nodeId));
         this.lccm = lifeCyclecomponentManager;
         this.nodeId = nodeId;
         this.rootCtx = rootCtx;


Mime
View raw message