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