From 12f3c82a866eee0436c22136909882581fd19905 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Sat, 3 Feb 2018 09:25:16 -0800 Subject: [PATCH] HBASE-19919 Tidying up logging; ADDENDUM Fix tests w/ mocked Servers --- .../org/apache/hadoop/hbase/master/SplitLogManager.java | 6 +++++- .../hadoop/hbase/master/assignment/AssignmentManager.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java index 63af39854b7..2e2f8bf47d9 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java @@ -121,8 +121,12 @@ public class SplitLogManager { throws IOException { this.server = master; this.conf = conf; + // Get Server Thread name. Sometimes the Server is mocked so may not implement HasThread. + // For example, in tests. + String name = master instanceof HasThread? ((HasThread)master).getName(): + master.getServerName().toShortString(); this.choreService = - new ChoreService(((HasThread)master).getName() + ".splitLogManager."); + new ChoreService(name + ".splitLogManager."); if (server.getCoordinatedStateManager() != null) { SplitLogManagerCoordination coordination = getSplitLogManagerCoordination(); Set failedDeletions = Collections.synchronizedSet(new HashSet()); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java index 1f6523031af..e09b29b7c98 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java @@ -1624,7 +1624,11 @@ public class AssignmentManager implements ServerListener { } private void startAssignmentThread() { - assignThread = new Thread(((HasThread)this.master).getName()) { + // Get Server Thread name. Sometimes the Server is mocked so may not implement HasThread. + // For example, in tests. + String name = master instanceof HasThread? ((HasThread)master).getName(): + master.getServerName().toShortString(); + assignThread = new Thread(name) { @Override public void run() { while (isRunning()) {