OOZIE-2603 Give thread pools a meaningful name in CallableQueueService and SchedulerService (pbacsko via rkanter)
diff --git a/core/src/main/java/org/apache/oozie/service/CallableQueueService.java b/core/src/main/java/org/apache/oozie/service/CallableQueueService.java
index 3333c77..a86a8d0 100644
--- a/core/src/main/java/org/apache/oozie/service/CallableQueueService.java
+++ b/core/src/main/java/org/apache/oozie/service/CallableQueueService.java
@@ -26,8 +26,8 @@
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.Map.Entry;
+import java.util.Set;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
@@ -41,11 +41,12 @@
 import org.apache.oozie.client.OozieClient.SYSTEM_MODE;
 import org.apache.oozie.util.Instrumentable;
 import org.apache.oozie.util.Instrumentation;
+import org.apache.oozie.util.NamedThreadFactory;
 import org.apache.oozie.util.PollablePriorityDelayQueue;
 import org.apache.oozie.util.PriorityDelayQueue;
+import org.apache.oozie.util.PriorityDelayQueue.QueueElement;
 import org.apache.oozie.util.XCallable;
 import org.apache.oozie.util.XLog;
-import org.apache.oozie.util.PriorityDelayQueue.QueueElement;
 
 /**
  * The callable queue service queues {@link XCallable}s for asynchronous execution.
@@ -503,7 +504,8 @@
         // minimum size equals to the maximum size (thus threads are keep always
         // running) and we are warming up
         // all those threads (the for loop that runs dummy runnables).
-        executor = new ThreadPoolExecutor(threads, threads, 10, TimeUnit.SECONDS, (BlockingQueue) queue){
+        executor = new ThreadPoolExecutor(threads, threads, 10, TimeUnit.SECONDS, (BlockingQueue) queue,
+                new NamedThreadFactory("CallableQueue")) {
             protected void beforeExecute(Thread t, Runnable r) {
                 super.beforeExecute(t,r);
                 XLog.Info.get().clear();
diff --git a/core/src/main/java/org/apache/oozie/service/SchedulerService.java b/core/src/main/java/org/apache/oozie/service/SchedulerService.java
index dc9e76c..81fbc0d 100644
--- a/core/src/main/java/org/apache/oozie/service/SchedulerService.java
+++ b/core/src/main/java/org/apache/oozie/service/SchedulerService.java
@@ -18,15 +18,16 @@
 
 package org.apache.oozie.service;
 
-import org.apache.hadoop.conf.Configuration;
-import org.apache.oozie.client.OozieClient.SYSTEM_MODE;
-import org.apache.oozie.util.XLog;
-
 import java.util.concurrent.Callable;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.hadoop.conf.Configuration;
+import org.apache.oozie.client.OozieClient.SYSTEM_MODE;
+import org.apache.oozie.util.NamedThreadFactory;
+import org.apache.oozie.util.XLog;
+
 /**
  * This service executes scheduled Runnables and Callables at regular intervals. <p> It uses a
  * java.util.concurrent.ScheduledExecutorService. <p> The {@link #SCHEDULER_THREADS} configuration property indicates
@@ -49,7 +50,7 @@
      */
     @Override
     public void init(Services services) {
-        scheduler = new ScheduledThreadPoolExecutor(getSchedulableThreads(services.getConf()));
+        scheduler = new ScheduledThreadPoolExecutor(getSchedulableThreads(services.getConf()), new NamedThreadFactory("Scheduler"));
     }
 
     /**
diff --git a/core/src/main/java/org/apache/oozie/util/NamedThreadFactory.java b/core/src/main/java/org/apache/oozie/util/NamedThreadFactory.java
new file mode 100644
index 0000000..ac424a7
--- /dev/null
+++ b/core/src/main/java/org/apache/oozie/util/NamedThreadFactory.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.oozie.util;
+
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class NamedThreadFactory implements ThreadFactory {
+    private final AtomicInteger counter = new AtomicInteger();
+    private final String threadPrefix;
+
+    public NamedThreadFactory(String threadPrefix) {
+        this.threadPrefix = ParamChecker.notEmpty(threadPrefix, "threadPrefix");
+    }
+
+    @Override
+    public Thread newThread(Runnable r) {
+        Thread t = new Thread(r);
+        t.setName(threadPrefix + "-" + counter.getAndIncrement());
+        return t;
+    }
+}
diff --git a/release-log.txt b/release-log.txt
index ab44c24..e0a1841 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -1,5 +1,6 @@
 -- Oozie 4.3.0 release (trunk - unreleased)
 
+OOZIE-2603 Give thread pools a meaningful name in CallableQueueService and SchedulerService (pbacsko via rkanter)
 OOZIE-2436 Fork/join workflow fails with "oozie.action.yarn.tag must not be null" (puru)
 OOZIE-2578 Oozie example distcp job fails to run within an encrypted zone with checksum match error (pbacsko via rkanter)
 OOZIE-2362 SQL injection in BulkJPAExecutor (pbacsko via rkanter)