Browse Source

HDFS-14475. RBF: Expose router security enabled status on the UI. Contributed by CR Hota.

Inigo Goiri 6 years ago
parent
commit
90f4887dcc

+ 6 - 1
hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationMBean.java

@@ -240,7 +240,6 @@ public interface FederationMBean {
 
   /**
    * Get the current state of the router.
-   *
    * @return String label for the current router state.
    */
   String getRouterStatus();
@@ -250,4 +249,10 @@ public interface FederationMBean {
    * @return number of DTs
    */
   long getCurrentTokensCount();
+
+  /**
+   * Get the security status of the router.
+   * @return Security status.
+   */
+  boolean isSecurityEnabled();
 }

+ 5 - 0
hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationMetrics.java

@@ -77,6 +77,7 @@ import org.apache.hadoop.hdfs.server.federation.store.records.MountTable;
 import org.apache.hadoop.hdfs.server.federation.store.records.RouterState;
 import org.apache.hadoop.hdfs.server.federation.store.records.StateStoreVersion;
 import org.apache.hadoop.metrics2.util.MBeans;
+import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.hadoop.util.VersionInfo;
 import org.codehaus.jettison.json.JSONObject;
@@ -615,6 +616,10 @@ public class FederationMetrics implements FederationMBean {
     return -1;
   }
 
+  public boolean isSecurityEnabled() {
+    return UserGroupInformation.isSecurityEnabled();
+  }
+
   /**
    * Build a set of unique values found in all namespaces.
    *

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/webapps/router/federationhealth.html

@@ -90,7 +90,7 @@
 <div class="page-header"><h1>Summary</h1></div>
 {#federation}
 <p>
-  Security is {#routerstat}{#SecurityEnabled}on{:else}off{/SecurityEnabled}{/routerstat}.</p>
+  Security is {#federation}{#SecurityEnabled}on{:else}off{/SecurityEnabled}{/federation}.</p>
 <p>{#router}{#Safemode}{.}{:else}Safemode is off.{/Safemode}{/router}</p>
 
 <p>

+ 2 - 0
hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/metrics/TestFederationMetrics.java

@@ -21,6 +21,7 @@ import static org.apache.hadoop.hdfs.server.federation.FederationTestUtils.getBe
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
 
 import java.io.IOException;
 import java.util.Iterator;
@@ -318,5 +319,6 @@ public class TestFederationMetrics extends TestMetricsBase {
     assertTrue(bean.getCompileInfo().length() > 0);
     assertTrue(bean.getRouterStarted().length() > 0);
     assertTrue(bean.getHostAndPort().length() > 0);
+    assertFalse(bean.isSecurityEnabled());
   }
 }