Repository: oozie Updated Branches: refs/heads/master 2322d496c -> 1cb23a554
OOZIE-2603 Give thread pools a meaningful name in CallableQueueService and SchedulerService (pbacsko via rkanter) Project: http://git-wip-us.apache.org/repos/asf/oozie/repo Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/321bb527 Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/321bb527 Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/321bb527 Branch: refs/heads/master Commit: 321bb52788b2868ee3671330eb4ffaeadbc6d338 Parents: 2322d49 Author: Robert Kanter <[email protected]> Authored: Tue Jul 12 17:11:55 2016 -0700 Committer: Robert Kanter <[email protected]> Committed: Tue Jul 12 17:11:55 2016 -0700 ---------------------------------------------------------------------- .../oozie/service/CallableQueueService.java | 8 +++-- .../apache/oozie/service/SchedulerService.java | 11 +++--- .../apache/oozie/util/NamedThreadFactory.java | 38 ++++++++++++++++++++ release-log.txt | 1 + 4 files changed, 50 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/oozie/blob/321bb527/core/src/main/java/org/apache/oozie/service/CallableQueueService.java ---------------------------------------------------------------------- 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.HashSet; 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.hadoop.conf.Configuration; 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 @@ public class CallableQueueService implements Service, Instrumentable { // 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(); http://git-wip-us.apache.org/repos/asf/oozie/blob/321bb527/core/src/main/java/org/apache/oozie/service/SchedulerService.java ---------------------------------------------------------------------- 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 @@ public class SchedulerService implements Service { */ @Override public void init(Services services) { - scheduler = new ScheduledThreadPoolExecutor(getSchedulableThreads(services.getConf())); + scheduler = new ScheduledThreadPoolExecutor(getSchedulableThreads(services.getConf()), new NamedThreadFactory("Scheduler")); } /** http://git-wip-us.apache.org/repos/asf/oozie/blob/321bb527/core/src/main/java/org/apache/oozie/util/NamedThreadFactory.java ---------------------------------------------------------------------- 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; + } +} http://git-wip-us.apache.org/repos/asf/oozie/blob/321bb527/release-log.txt ---------------------------------------------------------------------- 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)
