HBASE-19919 Tidying up logging; ADDENDUM Fix tests w/ mocked Servers

Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/12f3c82a
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/12f3c82a
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/12f3c82a

Branch: refs/heads/HBASE-19064
Commit: 12f3c82a866eee0436c22136909882581fd19905
Parents: 06dec20
Author: Michael Stack <st...@apache.org>
Authored: Sat Feb 3 09:25:16 2018 -0800
Committer: Michael Stack <st...@apache.org>
Committed: Sat Feb 3 09:25:16 2018 -0800

----------------------------------------------------------------------
 .../java/org/apache/hadoop/hbase/master/SplitLogManager.java   | 6 +++++-
 .../hadoop/hbase/master/assignment/AssignmentManager.java      | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/12f3c82a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java
----------------------------------------------------------------------
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 63af398..2e2f8bf 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<String> failedDeletions = Collections.synchronizedSet(new 
HashSet<String>());

http://git-wip-us.apache.org/repos/asf/hbase/blob/12f3c82a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java
----------------------------------------------------------------------
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 1f65230..e09b29b 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()) {

Reply via email to