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

This commit is contained in:
Inigo Goiri 2019-05-30 16:29:18 -07:00 committed by Brahma Reddy Battula
parent b6fff8c81e
commit b062dd462d
4 changed files with 14 additions and 2 deletions

View File

@ -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();
}

View File

@ -77,6 +77,7 @@
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 long getCurrentTokensCount() {
return -1;
}
public boolean isSecurityEnabled() {
return UserGroupInformation.isSecurityEnabled();
}
/**
* Build a set of unique values found in all namespaces.
*

View File

@ -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>

View File

@ -21,6 +21,7 @@
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 @@ private void validateClusterStatsBean(FederationMBean bean)
assertTrue(bean.getCompileInfo().length() > 0);
assertTrue(bean.getRouterStarted().length() > 0);
assertTrue(bean.getHostAndPort().length() > 0);
assertFalse(bean.isSecurityEnabled());
}
}