本文整理汇总了Java中org.apache.hadoop.ha.HealthCheckFailedException类的典型用法代码示例。如果您正苦于以下问题:Java HealthCheckFailedException类的具体用法?Java HealthCheckFailedException怎么用?Java HealthCheckFailedException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HealthCheckFailedException类属于org.apache.hadoop.ha包,在下文中一共展示了HealthCheckFailedException类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import org.apache.hadoop.ha.HealthCheckFailedException; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test(timeout=60000)
public void test() throws Exception {
JobTrackerHAServiceProtocol haServiceProtocol =
cluster.getJobTrackerHaDaemon(0).getJobTrackerHAServiceProtocol();
// Should not throw error, which indicates healthy.
haServiceProtocol.monitorHealth();
// Forcibly stop JT thread
haServiceProtocol.getJobTrackerThread().stop();
haServiceProtocol.getJobTrackerThread().join();
try {
// Should throw error - JT is unhealthy.
haServiceProtocol.monitorHealth();
fail("Should not have succeeded in calling monitorHealth");
} catch (HealthCheckFailedException hcfe) {
GenericTestUtils.assertExceptionContains(
"The JobTracker thread is not running", hcfe);
}
}
示例2: isHealthCheckFailedException
import org.apache.hadoop.ha.HealthCheckFailedException; //导入依赖的package包/类
private boolean isHealthCheckFailedException(Throwable t) {
return ((t instanceof HealthCheckFailedException) ||
(t instanceof RemoteException &&
((RemoteException)t).unwrapRemoteException(
HealthCheckFailedException.class) instanceof
HealthCheckFailedException));
}
示例3: monitorHealth
import org.apache.hadoop.ha.HealthCheckFailedException; //导入依赖的package包/类
@Override
public synchronized void monitorHealth()
throws IOException {
checkAccess("monitorHealth");
if (isRMActive() && !rm.areActiveServicesRunning()) {
throw new HealthCheckFailedException(
"Active ResourceManager services are not running!");
}
}
示例4: checkMonitorHealth
import org.apache.hadoop.ha.HealthCheckFailedException; //导入依赖的package包/类
private void checkMonitorHealth() throws IOException {
try {
rm.adminService.monitorHealth();
} catch (HealthCheckFailedException e) {
fail("The RM is in bad health: it is Active, but the active services " +
"are not running");
}
}
示例5: monitorHealth
import org.apache.hadoop.ha.HealthCheckFailedException; //导入依赖的package包/类
synchronized void monitorHealth()
throws HealthCheckFailedException, AccessControlException {
namesystem.checkSuperuserPrivilege();
if (!haEnabled) {
return; // no-op, if HA is not enabled
}
getNamesystem().checkAvailableResources();
if (!getNamesystem().nameNodeHasResourcesAvailable()) {
throw new HealthCheckFailedException(
"The NameNode has no resources available");
}
}
示例6: doNNHealthCheckTest
import org.apache.hadoop.ha.HealthCheckFailedException; //导入依赖的package包/类
private void doNNHealthCheckTest() throws IOException {
NameNodeResourceChecker mockResourceChecker = Mockito.mock(
NameNodeResourceChecker.class);
Mockito.doReturn(true).when(mockResourceChecker).hasAvailableDiskSpace();
cluster.getNameNode(0).getNamesystem()
.setNNResourceChecker(mockResourceChecker);
NNHAServiceTarget haTarget = new NNHAServiceTarget(conf,
DFSUtil.getNamenodeNameServiceId(conf), "nn1");
HAServiceProtocol rpc = haTarget.getHealthMonitorProxy(conf, conf.getInt(
HA_HM_RPC_TIMEOUT_KEY, HA_HM_RPC_TIMEOUT_DEFAULT));
// Should not throw error, which indicates healthy.
rpc.monitorHealth();
Mockito.doReturn(false).when(mockResourceChecker).hasAvailableDiskSpace();
try {
// Should throw error - NN is unhealthy.
rpc.monitorHealth();
fail("Should not have succeeded in calling monitorHealth");
} catch (HealthCheckFailedException hcfe) {
GenericTestUtils.assertExceptionContains(
"The NameNode has no resources available", hcfe);
} catch (RemoteException re) {
GenericTestUtils.assertExceptionContains(
"The NameNode has no resources available",
re.unwrapRemoteException(HealthCheckFailedException.class));
}
}
示例7: testCheckHealth
import org.apache.hadoop.ha.HealthCheckFailedException; //导入依赖的package包/类
@Test
public void testCheckHealth() throws Exception {
assertEquals(0, runTool("-checkHealth", "nn1"));
Mockito.verify(mockProtocol).monitorHealth();
Mockito.doThrow(new HealthCheckFailedException("fake health check failure"))
.when(mockProtocol).monitorHealth();
assertEquals(-1, runTool("-checkHealth", "nn1"));
assertOutputContains("Health check failed: fake health check failure");
}
示例8: testNNHealthCheck
import org.apache.hadoop.ha.HealthCheckFailedException; //导入依赖的package包/类
@Test
public void testNNHealthCheck() throws IOException {
MiniDFSCluster cluster = null;
try {
Configuration conf = new Configuration();
cluster = new MiniDFSCluster.Builder(conf)
.numDataNodes(0)
.nnTopology(MiniDFSNNTopology.simpleHATopology())
.build();
NameNodeResourceChecker mockResourceChecker = Mockito.mock(
NameNodeResourceChecker.class);
Mockito.doReturn(true).when(mockResourceChecker).hasAvailableDiskSpace();
cluster.getNameNode(0).getNamesystem()
.setNNResourceChecker(mockResourceChecker);
NamenodeProtocols rpc = cluster.getNameNodeRpc(0);
// Should not throw error, which indicates healthy.
rpc.monitorHealth();
Mockito.doReturn(false).when(mockResourceChecker).hasAvailableDiskSpace();
try {
// Should throw error - NN is unhealthy.
rpc.monitorHealth();
fail("Should not have succeeded in calling monitorHealth");
} catch (HealthCheckFailedException hcfe) {
GenericTestUtils.assertExceptionContains(
"The NameNode has no resources available", hcfe);
}
} finally {
if (cluster != null) {
cluster.shutdown();
}
}
}
示例9: doHealthChecks
import org.apache.hadoop.ha.HealthCheckFailedException; //导入依赖的package包/类
private void doHealthChecks() throws InterruptedException {
while (shouldRun) {
HAServiceStatus status = null;
boolean healthy = false;
try {
status = proxy.getServiceStatus();
proxy.monitorHealth();
healthy = true;
} catch (HealthCheckFailedException e) {
LOG.warn("Service health check failed for " + targetToMonitor
+ ": " + e.getMessage());
enterState(State.SERVICE_UNHEALTHY);
} catch (Throwable t) {
LOG.warn("Transport-level exception trying to monitor health of " +
targetToMonitor + ": " + t.getLocalizedMessage());
RPC.stopProxy(proxy);
proxy = null;
enterState(State.SERVICE_NOT_RESPONDING);
Thread.sleep(sleepAfterDisconnectMillis);
return;
}
if (status != null) {
setLastServiceStatus(status);
}
if (healthy) {
enterState(State.SERVICE_HEALTHY);
}
Thread.sleep(checkIntervalMillis);
}
}
示例10: monitorHealth
import org.apache.hadoop.ha.HealthCheckFailedException; //导入依赖的package包/类
@Override
public synchronized void monitorHealth()
throws IOException {
checkAccess("monitorHealth");
if (isRMActive() && !rm.areSchedulerServicesRunning()) {
throw new HealthCheckFailedException(
"Active ResourceManager services are not running!");
}
}
示例11: monitorHealth
import org.apache.hadoop.ha.HealthCheckFailedException; //导入依赖的package包/类
@Override
public synchronized void monitorHealth() throws IOException {
checkAccess("monitorHealth");
if (isRMActive() && !rm.areSchedulerServicesRunning()) {
throw new HealthCheckFailedException(
"Active ResourceManager services are not running!");
}
}