From 031dd3638cff1310d85ce8ba62d2278f5ef1a904 Mon Sep 17 00:00:00 2001 From: "Apekshit(Appy) Sharma" Date: Wed, 22 Apr 2015 20:28:14 -0700 Subject: [PATCH] HBASE-13534 Changed Master UI to promptly display if it is a backup master. (Apekshit) Signed-off-by: Elliott Clark --- .../tmpl/master/BackupMasterStatusTmpl.jamon | 51 ++++++++----------- .../hbase/tmpl/master/MasterStatusTmpl.jamon | 5 +- 2 files changed, 25 insertions(+), 31 deletions(-) diff --git a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/BackupMasterStatusTmpl.jamon b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/BackupMasterStatusTmpl.jamon index f5fa3de937b..9d5c2f90be0 100644 --- a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/BackupMasterStatusTmpl.jamon +++ b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/BackupMasterStatusTmpl.jamon @@ -27,32 +27,23 @@ org.apache.hadoop.hbase.master.HMaster; org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; <%java> -Collection masters = null; MasterAddressTracker masterAddressTracker = master.getMasterAddressTracker(); -if (master.isActiveMaster()) { - ClusterStatus status = master.getClusterStatus(); - masters = status.getBackupMasters(); -} else{ - ServerName sn = masterAddressTracker == null ? null - : masterAddressTracker.getMasterAddress(); - assert sn != null : "Failed to retreive master's ServerName!"; - masters = Collections.singletonList(sn); -} -<%java> -ServerName [] serverNames = masters.toArray(new ServerName[masters.size()]); -int infoPort = masterAddressTracker == null ? 0 : masterAddressTracker.getMasterInfoPort(); - <%if (!master.isActiveMaster()) %> - <%if serverNames[0] != null %> -

Master

- <% - serverNames[0].getHostname() %> - <%else> - Unable to parse master hostname. - + <%java> + ServerName active_master = + (masterAddressTracker == null) ? null : masterAddressTracker.getMasterAddress(); + assert active_master != null : "Failed to retrieve master's ServerName!"; + int infoPort = (masterAddressTracker == null) ? 0 : masterAddressTracker.getMasterInfoPort(); + +
+ +
+

Current Active Master: <% active_master.getHostname() %>

<%else>

Backup Masters

@@ -63,14 +54,16 @@ int infoPort = masterAddressTracker == null ? 0 : masterAddressTracker.getMaster Start Time <%java> - Arrays.sort(serverNames); - for (ServerName serverName : serverNames) { - infoPort = masterAddressTracker == null ? 0 : masterAddressTracker.getBackupMasterInfoPort(serverName); + Collection backup_masters = master.getClusterStatus().getBackupMasters(); + ServerName [] backupServerNames = backup_masters.toArray(new ServerName[backup_masters.size()]); + Arrays.sort(backupServerNames); + for (ServerName serverName : backupServerNames) { + int infoPort = (masterAddressTracker == null) ? 0 : masterAddressTracker + .getBackupMasterInfoPort(serverName); - <% - serverName.getHostname() %> + <% serverName.getHostname() %> <% serverName.getPort() %> <% new Date(serverName.getStartcode()) %> @@ -78,6 +71,6 @@ int infoPort = masterAddressTracker == null ? 0 : masterAddressTracker.getMaster <%java> } - Total:<% (masters != null) ? masters.size() : 0 %> + Total:<% backupServerNames.length %> diff --git a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon index 02bbbd5a89d..fe9c0ada51a 100644 --- a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon +++ b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon @@ -97,7 +97,8 @@ AssignmentManager assignmentManager = master.getAssignmentManager(); - Master: <% master.getServerName().getHostname() %> + <%if master.isActiveMaster() %>Master: <%else>Backup Master: </%if> + <% master.getServerName().getHostname() %> @@ -137,7 +138,7 @@ AssignmentManager assignmentManager = master.getAssignmentManager(); <%if master.isActiveMaster() %>