HDFS-14508. RBF: Clean-up and refactor UI components. Contributed by Takanobu Asanuma.
This commit is contained in:
parent
0c21e81e02
commit
1579136fa7
|
@ -193,66 +193,87 @@ public interface FederationMBean {
|
|||
/**
|
||||
* When the router started.
|
||||
* @return Date as a string the router started.
|
||||
* @deprecated Use {@link RouterMBean#getRouterStarted()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
String getRouterStarted();
|
||||
|
||||
/**
|
||||
* Get the version of the router.
|
||||
* @return Version of the router.
|
||||
* @deprecated Use {@link RouterMBean#getVersion()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
String getVersion();
|
||||
|
||||
/**
|
||||
* Get the compilation date of the router.
|
||||
* @return Compilation date of the router.
|
||||
* @deprecated Use {@link RouterMBean#getCompiledDate()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
String getCompiledDate();
|
||||
|
||||
/**
|
||||
* Get the compilation info of the router.
|
||||
* @return Compilation info of the router.
|
||||
* @deprecated Use {@link RouterMBean#getCompileInfo()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
String getCompileInfo();
|
||||
|
||||
/**
|
||||
* Get the host and port of the router.
|
||||
* @return Host and port of the router.
|
||||
* @deprecated Use {@link RouterMBean#getHostAndPort()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
String getHostAndPort();
|
||||
|
||||
/**
|
||||
* Get the identifier of the router.
|
||||
* @return Identifier of the router.
|
||||
* @deprecated Use {@link RouterMBean#getRouterId()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
String getRouterId();
|
||||
|
||||
/**
|
||||
* Get the host and port of the router.
|
||||
* @return Host and port of the router.
|
||||
* Gets the cluster ids of the namenodes.
|
||||
* @return the cluster ids of the namenodes.
|
||||
* @deprecated Use {@link RouterMBean#getClusterId()} instead.
|
||||
*/
|
||||
String getClusterId();
|
||||
|
||||
/**
|
||||
* Get the host and port of the router.
|
||||
* @return Host and port of the router.
|
||||
* Gets the block pool ids of the namenodes.
|
||||
* @return the block pool ids of the namenodes.
|
||||
* @deprecated Use {@link RouterMBean#getBlockPoolId()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
String getBlockPoolId();
|
||||
|
||||
/**
|
||||
* Get the current state of the router.
|
||||
* @return String label for the current router state.
|
||||
* @deprecated Use {@link RouterMBean#getRouterStatus()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
String getRouterStatus();
|
||||
|
||||
/**
|
||||
* Get the current number of delegation tokens in memory.
|
||||
* @return number of DTs
|
||||
* @deprecated Use {@link RouterMBean#getCurrentTokensCount()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
long getCurrentTokensCount();
|
||||
|
||||
/**
|
||||
* Get the security status of the router.
|
||||
* @return Security status.
|
||||
* @deprecated Use {@link RouterMBean#isSecurityEnabled()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean isSecurityEnabled();
|
||||
}
|
||||
|
|
|
@ -45,7 +45,6 @@ import org.apache.hadoop.hdfs.server.federation.resolver.FederationNamespaceInfo
|
|||
import org.apache.hadoop.hdfs.server.federation.router.RBFConfigKeys;
|
||||
import org.apache.hadoop.hdfs.server.federation.router.Router;
|
||||
import org.apache.hadoop.hdfs.server.federation.router.RouterRpcServer;
|
||||
import org.apache.hadoop.hdfs.server.federation.router.RouterServiceState;
|
||||
import org.apache.hadoop.hdfs.server.federation.router.SubClusterTimeoutException;
|
||||
import org.apache.hadoop.hdfs.server.federation.store.MembershipStore;
|
||||
import org.apache.hadoop.hdfs.server.federation.store.StateStoreService;
|
||||
|
@ -169,8 +168,8 @@ public class NamenodeBeanMetrics
|
|||
}
|
||||
}
|
||||
|
||||
private FederationMetrics getFederationMetrics() throws IOException {
|
||||
FederationMetrics metrics = getRouter().getMetrics();
|
||||
private RBFMetrics getRBFMetrics() throws IOException {
|
||||
RBFMetrics metrics = getRouter().getMetrics();
|
||||
if (metrics == null) {
|
||||
throw new IOException("Federated metrics is not initialized");
|
||||
}
|
||||
|
@ -194,7 +193,7 @@ public class NamenodeBeanMetrics
|
|||
@Override
|
||||
public long getUsed() {
|
||||
try {
|
||||
return getFederationMetrics().getUsedCapacity();
|
||||
return getRBFMetrics().getUsedCapacity();
|
||||
} catch (IOException e) {
|
||||
LOG.debug("Failed to get the used capacity", e.getMessage());
|
||||
}
|
||||
|
@ -204,7 +203,7 @@ public class NamenodeBeanMetrics
|
|||
@Override
|
||||
public long getFree() {
|
||||
try {
|
||||
return getFederationMetrics().getRemainingCapacity();
|
||||
return getRBFMetrics().getRemainingCapacity();
|
||||
} catch (IOException e) {
|
||||
LOG.debug("Failed to get remaining capacity", e.getMessage());
|
||||
}
|
||||
|
@ -214,7 +213,7 @@ public class NamenodeBeanMetrics
|
|||
@Override
|
||||
public long getTotal() {
|
||||
try {
|
||||
return getFederationMetrics().getTotalCapacity();
|
||||
return getRBFMetrics().getTotalCapacity();
|
||||
} catch (IOException e) {
|
||||
LOG.debug("Failed to Get total capacity", e.getMessage());
|
||||
}
|
||||
|
@ -224,7 +223,7 @@ public class NamenodeBeanMetrics
|
|||
@Override
|
||||
public long getProvidedCapacity() {
|
||||
try {
|
||||
return getFederationMetrics().getProvidedSpace();
|
||||
return getRBFMetrics().getProvidedSpace();
|
||||
} catch (IOException e) {
|
||||
LOG.debug("Failed to get provided capacity", e.getMessage());
|
||||
}
|
||||
|
@ -234,29 +233,11 @@ public class NamenodeBeanMetrics
|
|||
@Override
|
||||
public String getSafemode() {
|
||||
try {
|
||||
if (getRouter().isRouterState(RouterServiceState.SAFEMODE)) {
|
||||
return "Safe mode is ON. " + this.getSafeModeTip();
|
||||
}
|
||||
return getRBFMetrics().getSafemode();
|
||||
} catch (IOException e) {
|
||||
return "Failed to get safemode status. Please check router"
|
||||
+ "log for more detail.";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String getSafeModeTip() throws IOException {
|
||||
Router rt = getRouter();
|
||||
String cmd = "Use \"hdfs dfsrouteradmin -safemode leave\" "
|
||||
+ "to turn safe mode off.";
|
||||
if (rt.isRouterState(RouterServiceState.INITIALIZING)
|
||||
|| rt.isRouterState(RouterServiceState.UNINITIALIZED)) {
|
||||
return "Router is in" + rt.getRouterState()
|
||||
+ "mode, the router will immediately return to "
|
||||
+ "normal mode after some time. " + cmd;
|
||||
} else if (rt.isRouterState(RouterServiceState.SAFEMODE)) {
|
||||
return "It was turned on manually. " + cmd;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -309,7 +290,7 @@ public class NamenodeBeanMetrics
|
|||
@Override
|
||||
public long getTotalBlocks() {
|
||||
try {
|
||||
return getFederationMetrics().getNumBlocks();
|
||||
return getRBFMetrics().getNumBlocks();
|
||||
} catch (IOException e) {
|
||||
LOG.debug("Failed to get number of blocks", e.getMessage());
|
||||
}
|
||||
|
@ -319,7 +300,7 @@ public class NamenodeBeanMetrics
|
|||
@Override
|
||||
public long getNumberOfMissingBlocks() {
|
||||
try {
|
||||
return getFederationMetrics().getNumOfMissingBlocks();
|
||||
return getRBFMetrics().getNumOfMissingBlocks();
|
||||
} catch (IOException e) {
|
||||
LOG.debug("Failed to get number of missing blocks", e.getMessage());
|
||||
}
|
||||
|
@ -330,7 +311,7 @@ public class NamenodeBeanMetrics
|
|||
@Deprecated
|
||||
public long getPendingReplicationBlocks() {
|
||||
try {
|
||||
return getFederationMetrics().getNumOfBlocksPendingReplication();
|
||||
return getRBFMetrics().getNumOfBlocksPendingReplication();
|
||||
} catch (IOException e) {
|
||||
LOG.debug("Failed to get number of blocks pending replica",
|
||||
e.getMessage());
|
||||
|
@ -341,7 +322,7 @@ public class NamenodeBeanMetrics
|
|||
@Override
|
||||
public long getPendingReconstructionBlocks() {
|
||||
try {
|
||||
return getFederationMetrics().getNumOfBlocksPendingReplication();
|
||||
return getRBFMetrics().getNumOfBlocksPendingReplication();
|
||||
} catch (IOException e) {
|
||||
LOG.debug("Failed to get number of blocks pending replica",
|
||||
e.getMessage());
|
||||
|
@ -353,7 +334,7 @@ public class NamenodeBeanMetrics
|
|||
@Deprecated
|
||||
public long getUnderReplicatedBlocks() {
|
||||
try {
|
||||
return getFederationMetrics().getNumOfBlocksUnderReplicated();
|
||||
return getRBFMetrics().getNumOfBlocksUnderReplicated();
|
||||
} catch (IOException e) {
|
||||
LOG.debug("Failed to get number of blocks under replicated",
|
||||
e.getMessage());
|
||||
|
@ -364,7 +345,7 @@ public class NamenodeBeanMetrics
|
|||
@Override
|
||||
public long getLowRedundancyBlocks() {
|
||||
try {
|
||||
return getFederationMetrics().getNumOfBlocksUnderReplicated();
|
||||
return getRBFMetrics().getNumOfBlocksUnderReplicated();
|
||||
} catch (IOException e) {
|
||||
LOG.debug("Failed to get number of blocks under replicated",
|
||||
e.getMessage());
|
||||
|
@ -375,7 +356,7 @@ public class NamenodeBeanMetrics
|
|||
@Override
|
||||
public long getPendingDeletionBlocks() {
|
||||
try {
|
||||
return getFederationMetrics().getNumOfBlocksPendingDeletion();
|
||||
return getRBFMetrics().getNumOfBlocksPendingDeletion();
|
||||
} catch (IOException e) {
|
||||
LOG.debug("Failed to get number of blocks pending deletion",
|
||||
e.getMessage());
|
||||
|
@ -620,7 +601,7 @@ public class NamenodeBeanMetrics
|
|||
@Override
|
||||
public long getFilesTotal() {
|
||||
try {
|
||||
return getFederationMetrics().getNumFiles();
|
||||
return getRBFMetrics().getNumFiles();
|
||||
} catch (IOException e) {
|
||||
LOG.debug("Failed to get number of files", e.getMessage());
|
||||
}
|
||||
|
@ -635,7 +616,7 @@ public class NamenodeBeanMetrics
|
|||
@Override
|
||||
public int getNumLiveDataNodes() {
|
||||
try {
|
||||
return getFederationMetrics().getNumLiveNodes();
|
||||
return getRBFMetrics().getNumLiveNodes();
|
||||
} catch (IOException e) {
|
||||
LOG.debug("Failed to get number of live nodes", e.getMessage());
|
||||
}
|
||||
|
@ -645,7 +626,7 @@ public class NamenodeBeanMetrics
|
|||
@Override
|
||||
public int getNumDeadDataNodes() {
|
||||
try {
|
||||
return getFederationMetrics().getNumDeadNodes();
|
||||
return getRBFMetrics().getNumDeadNodes();
|
||||
} catch (IOException e) {
|
||||
LOG.debug("Failed to get number of dead nodes", e.getMessage());
|
||||
}
|
||||
|
@ -655,7 +636,7 @@ public class NamenodeBeanMetrics
|
|||
@Override
|
||||
public int getNumStaleDataNodes() {
|
||||
try {
|
||||
return getFederationMetrics().getNumStaleNodes();
|
||||
return getRBFMetrics().getNumStaleNodes();
|
||||
} catch (IOException e) {
|
||||
LOG.debug("Failed to get number of stale nodes", e.getMessage());
|
||||
}
|
||||
|
@ -665,7 +646,7 @@ public class NamenodeBeanMetrics
|
|||
@Override
|
||||
public int getNumDecomLiveDataNodes() {
|
||||
try {
|
||||
return getFederationMetrics().getNumDecomLiveNodes();
|
||||
return getRBFMetrics().getNumDecomLiveNodes();
|
||||
} catch (IOException e) {
|
||||
LOG.debug("Failed to get the number of live decommissioned datanodes",
|
||||
e.getMessage());
|
||||
|
@ -676,7 +657,7 @@ public class NamenodeBeanMetrics
|
|||
@Override
|
||||
public int getNumDecomDeadDataNodes() {
|
||||
try {
|
||||
return getFederationMetrics().getNumDecomDeadNodes();
|
||||
return getRBFMetrics().getNumDecomDeadNodes();
|
||||
} catch (IOException e) {
|
||||
LOG.debug("Failed to get the number of dead decommissioned datanodes",
|
||||
e.getMessage());
|
||||
|
@ -687,7 +668,7 @@ public class NamenodeBeanMetrics
|
|||
@Override
|
||||
public int getNumDecommissioningDataNodes() {
|
||||
try {
|
||||
return getFederationMetrics().getNumDecommissioningNodes();
|
||||
return getRBFMetrics().getNumDecommissioningNodes();
|
||||
} catch (IOException e) {
|
||||
LOG.debug("Failed to get number of decommissioning nodes",
|
||||
e.getMessage());
|
||||
|
@ -698,7 +679,7 @@ public class NamenodeBeanMetrics
|
|||
@Override
|
||||
public int getNumInMaintenanceLiveDataNodes() {
|
||||
try {
|
||||
return getFederationMetrics().getNumInMaintenanceLiveDataNodes();
|
||||
return getRBFMetrics().getNumInMaintenanceLiveDataNodes();
|
||||
} catch (IOException e) {
|
||||
LOG.debug("Failed to get number of live in maintenance nodes",
|
||||
e.getMessage());
|
||||
|
@ -709,7 +690,7 @@ public class NamenodeBeanMetrics
|
|||
@Override
|
||||
public int getNumInMaintenanceDeadDataNodes() {
|
||||
try {
|
||||
return getFederationMetrics().getNumInMaintenanceDeadDataNodes();
|
||||
return getRBFMetrics().getNumInMaintenanceDeadDataNodes();
|
||||
} catch (IOException e) {
|
||||
LOG.debug("Failed to get number of dead in maintenance nodes",
|
||||
e.getMessage());
|
||||
|
@ -720,7 +701,7 @@ public class NamenodeBeanMetrics
|
|||
@Override
|
||||
public int getNumEnteringMaintenanceDataNodes() {
|
||||
try {
|
||||
return getFederationMetrics().getNumEnteringMaintenanceDataNodes();
|
||||
return getRBFMetrics().getNumEnteringMaintenanceDataNodes();
|
||||
} catch (IOException e) {
|
||||
LOG.debug("Failed to get number of entering maintenance nodes",
|
||||
e.getMessage());
|
||||
|
@ -803,6 +784,12 @@ public class NamenodeBeanMetrics
|
|||
|
||||
@Override
|
||||
public boolean isSecurityEnabled() {
|
||||
try {
|
||||
return getRBFMetrics().isSecurityEnabled();
|
||||
} catch (IOException e) {
|
||||
LOG.debug("Failed to get security status.",
|
||||
e.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ import org.apache.hadoop.hdfs.server.federation.resolver.RemoteLocation;
|
|||
import org.apache.hadoop.hdfs.server.federation.router.RBFConfigKeys;
|
||||
import org.apache.hadoop.hdfs.server.federation.router.Router;
|
||||
import org.apache.hadoop.hdfs.server.federation.router.RouterRpcServer;
|
||||
import org.apache.hadoop.hdfs.server.federation.router.RouterServiceState;
|
||||
import org.apache.hadoop.hdfs.server.federation.router.security.RouterSecurityManager;
|
||||
import org.apache.hadoop.hdfs.server.federation.store.MembershipStore;
|
||||
import org.apache.hadoop.hdfs.server.federation.store.MountTableStore;
|
||||
|
@ -90,10 +91,10 @@ import com.google.common.annotations.VisibleForTesting;
|
|||
/**
|
||||
* Implementation of the Router metrics collector.
|
||||
*/
|
||||
public class FederationMetrics implements FederationMBean {
|
||||
public class RBFMetrics implements RouterMBean, FederationMBean {
|
||||
|
||||
private static final Logger LOG =
|
||||
LoggerFactory.getLogger(FederationMetrics.class);
|
||||
LoggerFactory.getLogger(RBFMetrics.class);
|
||||
|
||||
/** Format for a date. */
|
||||
private static final String DATE_FORMAT = "yyyy/MM/dd HH:mm:ss";
|
||||
|
@ -106,7 +107,8 @@ public class FederationMetrics implements FederationMBean {
|
|||
private final Router router;
|
||||
|
||||
/** FederationState JMX bean. */
|
||||
private ObjectName beanName;
|
||||
private ObjectName routerBeanName;
|
||||
private ObjectName federationBeanName;
|
||||
|
||||
/** Resolve the namenode for each namespace. */
|
||||
private final ActiveNamenodeResolver namenodeResolver;
|
||||
|
@ -121,17 +123,26 @@ public class FederationMetrics implements FederationMBean {
|
|||
private RouterStore routerStore;
|
||||
|
||||
|
||||
public FederationMetrics(Router router) throws IOException {
|
||||
public RBFMetrics(Router router) throws IOException {
|
||||
this.router = router;
|
||||
|
||||
try {
|
||||
StandardMBean bean = new StandardMBean(this, FederationMBean.class);
|
||||
this.beanName = MBeans.register("Router", "FederationState", bean);
|
||||
LOG.info("Registered Router MBean: {}", this.beanName);
|
||||
StandardMBean bean = new StandardMBean(this, RouterMBean.class);
|
||||
this.routerBeanName = MBeans.register("Router", "Router", bean);
|
||||
LOG.info("Registered Router MBean: {}", this.routerBeanName);
|
||||
} catch (NotCompliantMBeanException e) {
|
||||
throw new RuntimeException("Bad Router MBean setup", e);
|
||||
}
|
||||
|
||||
try {
|
||||
StandardMBean bean = new StandardMBean(this, FederationMBean.class);
|
||||
this.federationBeanName = MBeans.register("Router", "FederationState",
|
||||
bean);
|
||||
LOG.info("Registered FederationState MBean: {}", this.federationBeanName);
|
||||
} catch (NotCompliantMBeanException e) {
|
||||
throw new RuntimeException("Bad FederationState MBean setup", e);
|
||||
}
|
||||
|
||||
// Resolve namenode for each nameservice
|
||||
this.namenodeResolver = this.router.getNamenodeResolver();
|
||||
|
||||
|
@ -159,8 +170,11 @@ public class FederationMetrics implements FederationMBean {
|
|||
* Unregister the JMX beans.
|
||||
*/
|
||||
public void close() {
|
||||
if (this.beanName != null) {
|
||||
MBeans.unregister(beanName);
|
||||
if (this.routerBeanName != null) {
|
||||
MBeans.unregister(routerBeanName);
|
||||
}
|
||||
if (this.federationBeanName != null) {
|
||||
MBeans.unregister(federationBeanName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -616,10 +630,34 @@ public class FederationMetrics implements FederationMBean {
|
|||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecurityEnabled() {
|
||||
return UserGroupInformation.isSecurityEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSafemode() {
|
||||
if (this.router.isRouterState(RouterServiceState.SAFEMODE)) {
|
||||
return "Safe mode is ON. " + this.getSafeModeTip();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String getSafeModeTip() {
|
||||
String cmd = "Use \"hdfs dfsrouteradmin -safemode leave\" "
|
||||
+ "to turn safe mode off.";
|
||||
if (this.router.isRouterState(RouterServiceState.INITIALIZING)
|
||||
|| this.router.isRouterState(RouterServiceState.UNINITIALIZED)) {
|
||||
return "Router is in" + this.router.getRouterState()
|
||||
+ "mode, the router will immediately return to "
|
||||
+ "normal mode after some time. " + cmd;
|
||||
} else if (this.router.isRouterState(RouterServiceState.SAFEMODE)) {
|
||||
return "It was turned on manually. " + cmd;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a set of unique values found in all namespaces.
|
||||
*
|
|
@ -0,0 +1,104 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hdfs.server.federation.metrics;
|
||||
|
||||
import org.apache.hadoop.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.classification.InterfaceStability;
|
||||
|
||||
/**
|
||||
* JMX interface for the router specific metrics.
|
||||
*/
|
||||
@InterfaceAudience.Private
|
||||
@InterfaceStability.Evolving
|
||||
public interface RouterMBean {
|
||||
|
||||
/**
|
||||
* When the router started.
|
||||
* @return Date as a string the router started.
|
||||
*/
|
||||
String getRouterStarted();
|
||||
|
||||
/**
|
||||
* Get the version of the router.
|
||||
* @return Version of the router.
|
||||
*/
|
||||
String getVersion();
|
||||
|
||||
/**
|
||||
* Get the compilation date of the router.
|
||||
* @return Compilation date of the router.
|
||||
*/
|
||||
String getCompiledDate();
|
||||
|
||||
/**
|
||||
* Get the compilation info of the router.
|
||||
* @return Compilation info of the router.
|
||||
*/
|
||||
String getCompileInfo();
|
||||
|
||||
/**
|
||||
* Get the host and port of the router.
|
||||
* @return Host and port of the router.
|
||||
*/
|
||||
String getHostAndPort();
|
||||
|
||||
/**
|
||||
* Get the identifier of the router.
|
||||
* @return Identifier of the router.
|
||||
*/
|
||||
String getRouterId();
|
||||
|
||||
/**
|
||||
* Get the current state of the router.
|
||||
*
|
||||
* @return String label for the current router state.
|
||||
*/
|
||||
String getRouterStatus();
|
||||
|
||||
/**
|
||||
* Gets the cluster ids of the namenodes.
|
||||
* @return the cluster ids of the namenodes.
|
||||
*/
|
||||
String getClusterId();
|
||||
|
||||
/**
|
||||
* Gets the block pool ids of the namenodes.
|
||||
* @return the block pool ids of the namenodes.
|
||||
*/
|
||||
String getBlockPoolId();
|
||||
|
||||
/**
|
||||
* Get the current number of delegation tokens in memory.
|
||||
* @return number of DTs
|
||||
*/
|
||||
long getCurrentTokensCount();
|
||||
|
||||
/**
|
||||
* Gets the safemode status.
|
||||
*
|
||||
* @return the safemode status.
|
||||
*/
|
||||
String getSafemode();
|
||||
|
||||
/**
|
||||
* Gets if security is enabled.
|
||||
*
|
||||
* @return true, if security is enabled.
|
||||
*/
|
||||
boolean isSecurityEnabled();
|
||||
}
|
|
@ -39,7 +39,7 @@ import org.apache.hadoop.hdfs.DFSUtil;
|
|||
import org.apache.hadoop.hdfs.HAUtil;
|
||||
import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier;
|
||||
import org.apache.hadoop.hdfs.server.common.TokenVerifier;
|
||||
import org.apache.hadoop.hdfs.server.federation.metrics.FederationMetrics;
|
||||
import org.apache.hadoop.hdfs.server.federation.metrics.RBFMetrics;
|
||||
import org.apache.hadoop.hdfs.server.federation.metrics.NamenodeBeanMetrics;
|
||||
import org.apache.hadoop.hdfs.server.federation.resolver.ActiveNamenodeResolver;
|
||||
import org.apache.hadoop.hdfs.server.federation.resolver.FileSubclusterResolver;
|
||||
|
@ -634,9 +634,9 @@ public class Router extends CompositeService implements
|
|||
*
|
||||
* @return Federation metrics.
|
||||
*/
|
||||
public FederationMetrics getMetrics() {
|
||||
public RBFMetrics getMetrics() {
|
||||
if (this.metrics != null) {
|
||||
return this.metrics.getFederationMetrics();
|
||||
return this.metrics.getRBFMetrics();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.hadoop.hdfs.server.federation.router;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hdfs.server.federation.metrics.FederationMetrics;
|
||||
import org.apache.hadoop.hdfs.server.federation.metrics.RBFMetrics;
|
||||
import org.apache.hadoop.hdfs.server.federation.metrics.NamenodeBeanMetrics;
|
||||
import org.apache.hadoop.metrics2.source.JvmMetrics;
|
||||
import org.apache.hadoop.service.AbstractService;
|
||||
|
@ -34,7 +34,7 @@ public class RouterMetricsService extends AbstractService {
|
|||
/** Router metrics. */
|
||||
private RouterMetrics routerMetrics;
|
||||
/** Federation metrics. */
|
||||
private FederationMetrics federationMetrics;
|
||||
private RBFMetrics rbfMetrics;
|
||||
/** Namenode mock metrics. */
|
||||
private NamenodeBeanMetrics nnMetrics;
|
||||
|
||||
|
@ -55,14 +55,14 @@ public class RouterMetricsService extends AbstractService {
|
|||
this.nnMetrics = new NamenodeBeanMetrics(this.router);
|
||||
|
||||
// Federation MBean JMX interface
|
||||
this.federationMetrics = new FederationMetrics(this.router);
|
||||
this.rbfMetrics = new RBFMetrics(this.router);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void serviceStop() throws Exception {
|
||||
// Remove JMX interfaces
|
||||
if (this.federationMetrics != null) {
|
||||
this.federationMetrics.close();
|
||||
if (this.rbfMetrics != null) {
|
||||
this.rbfMetrics.close();
|
||||
}
|
||||
|
||||
// Remove Namenode JMX interfaces
|
||||
|
@ -90,8 +90,8 @@ public class RouterMetricsService extends AbstractService {
|
|||
*
|
||||
* @return Federation metrics.
|
||||
*/
|
||||
public FederationMetrics getFederationMetrics() {
|
||||
return this.federationMetrics;
|
||||
public RBFMetrics getRBFMetrics() {
|
||||
return this.rbfMetrics;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -75,8 +75,8 @@
|
|||
|
||||
<!-- Overview -->
|
||||
<script type="text/x-dust-template" id="tmpl-federationhealth">
|
||||
<div class="page-header"><h1>Router {#federation}<small>'{HostAndPort}'</small>{/federation}</h1></div>
|
||||
{#federation}
|
||||
<div class="page-header"><h1>Router {#router}<small>'{HostAndPort}'</small>{/router}</h1></div>
|
||||
{#router}
|
||||
<table class="table table-bordered table-striped">
|
||||
<tr><th>Started:</th><td>{RouterStarted}</td></tr>
|
||||
<tr><th>Version:</th><td>{Version}</td></tr>
|
||||
|
@ -85,12 +85,12 @@
|
|||
<tr><th>Block Pool ID:</th><td>{BlockPoolId}</td></tr>
|
||||
<tr><th>Status:</th><td>{RouterStatus}</td></tr>
|
||||
</table>
|
||||
{/federation}
|
||||
{/router}
|
||||
|
||||
<div class="page-header"><h1>Summary</h1></div>
|
||||
{#federation}
|
||||
<p>
|
||||
Security is {#federation}{#SecurityEnabled}on{:else}off{/SecurityEnabled}{/federation}.</p>
|
||||
Security is {#router}{#SecurityEnabled}on{:else}off{/SecurityEnabled}{/router}.</p>
|
||||
<p>{#router}{#Safemode}{.}{:else}Safemode is off.{/Safemode}{/router}</p>
|
||||
|
||||
<p>
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
function load_overview() {
|
||||
var BEANS = [
|
||||
{"name": "federation", "url": "/jmx?qry=Hadoop:service=Router,name=FederationState"},
|
||||
{"name": "routerstat", "url": "/jmx?qry=Hadoop:service=NameNode,name=NameNodeStatus"},
|
||||
{"name": "router", "url": "/jmx?qry=Hadoop:service=NameNode,name=NameNodeInfo"},
|
||||
{"name": "router", "url": "/jmx?qry=Hadoop:service=Router,name=Router"},
|
||||
{"name": "mem", "url": "/jmx?qry=java.lang:type=Memory"}
|
||||
];
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package org.apache.hadoop.fs.contract.router;
|
||||
|
||||
import static org.apache.hadoop.fs.contract.router.SecurityConfUtil.initSecurity;
|
||||
import static org.apache.hadoop.hdfs.server.federation.metrics.TestFederationMetrics.FEDERATION_BEAN;
|
||||
import static org.apache.hadoop.hdfs.server.federation.metrics.TestRBFMetrics.ROUTER_BEAN;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -29,7 +29,7 @@ import org.apache.hadoop.fs.contract.AbstractFSContract;
|
|||
import org.apache.hadoop.fs.contract.AbstractFSContractTestBase;
|
||||
import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier;
|
||||
import org.apache.hadoop.hdfs.server.federation.FederationTestUtils;
|
||||
import org.apache.hadoop.hdfs.server.federation.metrics.FederationMBean;
|
||||
import org.apache.hadoop.hdfs.server.federation.metrics.RouterMBean;
|
||||
import org.apache.hadoop.security.token.SecretManager;
|
||||
import org.apache.hadoop.security.token.Token;
|
||||
import org.junit.AfterClass;
|
||||
|
@ -64,8 +64,8 @@ public class TestRouterHDFSContractDelegationToken
|
|||
|
||||
@Test
|
||||
public void testRouterDelegationToken() throws Exception {
|
||||
FederationMBean bean = FederationTestUtils.getBean(
|
||||
FEDERATION_BEAN, FederationMBean.class);
|
||||
RouterMBean bean = FederationTestUtils.getBean(
|
||||
ROUTER_BEAN, RouterMBean.class);
|
||||
// Initially there is no token in memory
|
||||
assertEquals(0, bean.getCurrentTokensCount());
|
||||
// Generate delegation token
|
||||
|
|
|
@ -44,34 +44,36 @@ import org.junit.Test;
|
|||
/**
|
||||
* Test the JMX interface for the {@link Router}.
|
||||
*/
|
||||
public class TestFederationMetrics extends TestMetricsBase {
|
||||
public class TestRBFMetrics extends TestMetricsBase {
|
||||
|
||||
public static final String FEDERATION_BEAN =
|
||||
"Hadoop:service=Router,name=FederationState";
|
||||
public static final String STATE_STORE_BEAN =
|
||||
"Hadoop:service=Router,name=StateStore";
|
||||
public static final String RPC_BEAN =
|
||||
"Hadoop:service=Router,name=FederationRPC";
|
||||
public static final String ROUTER_BEAN =
|
||||
"Hadoop:service=Router,name=Router";
|
||||
|
||||
@Test
|
||||
public void testClusterStatsJMX()
|
||||
throws MalformedObjectNameException, IOException {
|
||||
|
||||
FederationMBean bean = getBean(FEDERATION_BEAN, FederationMBean.class);
|
||||
validateClusterStatsBean(bean);
|
||||
FederationMBean federationBean = getBean(FEDERATION_BEAN,
|
||||
FederationMBean.class);
|
||||
validateClusterStatsFederationBean(federationBean);
|
||||
RouterMBean routerBean = getBean(ROUTER_BEAN, RouterMBean.class);
|
||||
validateClusterStatsRouterBean(routerBean);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClusterStatsDataSource() throws IOException {
|
||||
FederationMetrics metrics = getRouter().getMetrics();
|
||||
validateClusterStatsBean(metrics);
|
||||
RBFMetrics metrics = getRouter().getMetrics();
|
||||
validateClusterStatsFederationBean(metrics);
|
||||
validateClusterStatsRouterBean(metrics);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMountTableStatsDataSource()
|
||||
throws IOException, JSONException {
|
||||
|
||||
FederationMetrics metrics = getRouter().getMetrics();
|
||||
RBFMetrics metrics = getRouter().getMetrics();
|
||||
String jsonString = metrics.getMountTable();
|
||||
JSONArray jsonArray = new JSONArray(jsonString);
|
||||
assertEquals(jsonArray.length(), getMockMountTable().size());
|
||||
|
@ -117,7 +119,7 @@ public class TestFederationMetrics extends TestMetricsBase {
|
|||
@Test
|
||||
public void testNamenodeStatsDataSource() throws IOException, JSONException {
|
||||
|
||||
FederationMetrics metrics = getRouter().getMetrics();
|
||||
RBFMetrics metrics = getRouter().getMetrics();
|
||||
String jsonString = metrics.getNamenodes();
|
||||
JSONObject jsonObject = new JSONObject(jsonString);
|
||||
Iterator<?> keys = jsonObject.keys();
|
||||
|
@ -166,7 +168,7 @@ public class TestFederationMetrics extends TestMetricsBase {
|
|||
public void testNameserviceStatsDataSource()
|
||||
throws IOException, JSONException {
|
||||
|
||||
FederationMetrics metrics = getRouter().getMetrics();
|
||||
RBFMetrics metrics = getRouter().getMetrics();
|
||||
String jsonString = metrics.getNameservices();
|
||||
JSONObject jsonObject = new JSONObject(jsonString);
|
||||
Iterator<?> keys = jsonObject.keys();
|
||||
|
@ -220,7 +222,7 @@ public class TestFederationMetrics extends TestMetricsBase {
|
|||
@Test
|
||||
public void testRouterStatsDataSource() throws IOException, JSONException {
|
||||
|
||||
FederationMetrics metrics = getRouter().getMetrics();
|
||||
RBFMetrics metrics = getRouter().getMetrics();
|
||||
String jsonString = metrics.getRouters();
|
||||
JSONObject jsonObject = new JSONObject(jsonString);
|
||||
Iterator<?> keys = jsonObject.keys();
|
||||
|
@ -241,10 +243,10 @@ public class TestFederationMetrics extends TestMetricsBase {
|
|||
|
||||
StateStoreVersion version = router.getStateStoreVersion();
|
||||
assertEquals(
|
||||
FederationMetrics.getDateString(version.getMembershipVersion()),
|
||||
RBFMetrics.getDateString(version.getMembershipVersion()),
|
||||
json.get("lastMembershipUpdate"));
|
||||
assertEquals(
|
||||
FederationMetrics.getDateString(version.getMountTableVersion()),
|
||||
RBFMetrics.getDateString(version.getMountTableVersion()),
|
||||
json.get("lastMountTableUpdate"));
|
||||
assertEquals(version.getMembershipVersion(),
|
||||
json.get("membershipVersion"));
|
||||
|
@ -270,8 +272,7 @@ public class TestFederationMetrics extends TestMetricsBase {
|
|||
return null;
|
||||
}
|
||||
|
||||
private void validateClusterStatsBean(FederationMBean bean)
|
||||
throws IOException {
|
||||
private void validateClusterStatsFederationBean(FederationMBean bean) {
|
||||
|
||||
// Determine aggregates
|
||||
long numBlocks = 0;
|
||||
|
@ -314,6 +315,9 @@ public class TestFederationMetrics extends TestMetricsBase {
|
|||
assertEquals(getActiveMemberships().size() + getStandbyMemberships().size(),
|
||||
bean.getNumNamenodes());
|
||||
assertEquals(getNameservices().size(), bean.getNumNameservices());
|
||||
}
|
||||
|
||||
private void validateClusterStatsRouterBean(RouterMBean bean) {
|
||||
assertTrue(bean.getVersion().length() > 0);
|
||||
assertTrue(bean.getCompiledDate().length() > 0);
|
||||
assertTrue(bean.getCompileInfo().length() > 0);
|
|
@ -40,7 +40,7 @@ import org.apache.hadoop.hdfs.server.federation.MiniRouterDFSCluster.NamenodeCon
|
|||
import org.apache.hadoop.hdfs.server.federation.MiniRouterDFSCluster.RouterContext;
|
||||
import org.apache.hadoop.hdfs.server.federation.RouterConfigBuilder;
|
||||
import org.apache.hadoop.hdfs.server.federation.StateStoreDFSCluster;
|
||||
import org.apache.hadoop.hdfs.server.federation.metrics.FederationMetrics;
|
||||
import org.apache.hadoop.hdfs.server.federation.metrics.RBFMetrics;
|
||||
import org.apache.hadoop.hdfs.server.federation.resolver.MembershipNamenodeResolver;
|
||||
import org.apache.hadoop.hdfs.server.federation.resolver.MountTableManager;
|
||||
import org.apache.hadoop.hdfs.server.federation.resolver.MountTableResolver;
|
||||
|
@ -205,7 +205,7 @@ public class TestDisableNameservices {
|
|||
int numActive = 0;
|
||||
int numDisabled = 0;
|
||||
Router router = routerContext.getRouter();
|
||||
FederationMetrics metrics = router.getMetrics();
|
||||
RBFMetrics metrics = router.getMetrics();
|
||||
String jsonString = metrics.getNameservices();
|
||||
JSONObject jsonObject = new JSONObject(jsonString);
|
||||
Iterator<?> keys = jsonObject.keys();
|
||||
|
|
|
@ -38,7 +38,7 @@ import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
|||
import org.apache.hadoop.hdfs.server.federation.MiniRouterDFSCluster.RouterContext;
|
||||
import org.apache.hadoop.hdfs.server.federation.RouterConfigBuilder;
|
||||
import org.apache.hadoop.hdfs.server.federation.StateStoreDFSCluster;
|
||||
import org.apache.hadoop.hdfs.server.federation.metrics.FederationMetrics;
|
||||
import org.apache.hadoop.hdfs.server.federation.metrics.RBFMetrics;
|
||||
import org.apache.hadoop.hdfs.server.federation.resolver.ActiveNamenodeResolver;
|
||||
import org.apache.hadoop.hdfs.server.federation.resolver.MountTableManager;
|
||||
import org.apache.hadoop.hdfs.server.federation.resolver.MountTableResolver;
|
||||
|
@ -761,13 +761,13 @@ public class TestRouterAdminCLI {
|
|||
assertEquals(0,
|
||||
ToolRunner.run(admin, new String[] {"-safemode", "enter" }));
|
||||
|
||||
FederationMetrics metrics = router.getMetrics();
|
||||
RBFMetrics metrics = router.getMetrics();
|
||||
String jsonString = metrics.getRouterStatus();
|
||||
String result = router.getNamenodeMetrics().getSafemode();
|
||||
assertTrue("Wrong safe mode message: " + result,
|
||||
result.startsWith("Safe mode is ON."));
|
||||
|
||||
// verify state using FederationMetrics
|
||||
// verify state using RBFMetrics
|
||||
assertEquals(RouterServiceState.SAFEMODE.toString(), jsonString);
|
||||
assertTrue(routerContext.getRouter().getSafemodeService().isInSafeMode());
|
||||
|
||||
|
|
Loading…
Reference in New Issue