本文整理汇总了Java中org.apache.hadoop.yarn.client.api.async.AMRMClientAsync.stop方法的典型用法代码示例。如果您正苦于以下问题:Java AMRMClientAsync.stop方法的具体用法?Java AMRMClientAsync.stop怎么用?Java AMRMClientAsync.stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.yarn.client.api.async.AMRMClientAsync
的用法示例。
在下文中一共展示了AMRMClientAsync.stop方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAMRMClientAsyncShutDown
import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入方法依赖的package包/类
@Test (timeout = 10000)
public void testAMRMClientAsyncShutDown() throws Exception {
Configuration conf = new Configuration();
TestCallbackHandler callbackHandler = new TestCallbackHandler();
@SuppressWarnings("unchecked")
AMRMClient<ContainerRequest> client = mock(AMRMClientImpl.class);
createAllocateResponse(new ArrayList<ContainerStatus>(),
new ArrayList<Container>(), null);
when(client.allocate(anyFloat())).thenThrow(
new ApplicationAttemptNotFoundException("app not found, shut down"));
AMRMClientAsync<ContainerRequest> asyncClient =
AMRMClientAsync.createAMRMClientAsync(client, 10, callbackHandler);
asyncClient.init(conf);
asyncClient.start();
asyncClient.registerApplicationMaster("localhost", 1234, null);
Thread.sleep(50);
verify(client, times(1)).allocate(anyFloat());
asyncClient.stop();
}
示例2: testAMRMClientAsyncShutDown
import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入方法依赖的package包/类
@Test (timeout = 10000)
public void testAMRMClientAsyncShutDown() throws Exception {
Configuration conf = new Configuration();
TestCallbackHandler callbackHandler = new TestCallbackHandler();
@SuppressWarnings("unchecked")
AMRMClient<ContainerRequest> client = mock(AMRMClientImpl.class);
final AllocateResponse shutDownResponse = createAllocateResponse(
new ArrayList<ContainerStatus>(), new ArrayList<Container>(), null);
shutDownResponse.setAMCommand(AMCommand.AM_SHUTDOWN);
when(client.allocate(anyFloat())).thenReturn(shutDownResponse);
AMRMClientAsync<ContainerRequest> asyncClient =
AMRMClientAsync.createAMRMClientAsync(client, 10, callbackHandler);
asyncClient.init(conf);
asyncClient.start();
asyncClient.registerApplicationMaster("localhost", 1234, null);
Thread.sleep(50);
verify(client, times(1)).allocate(anyFloat());
asyncClient.stop();
}
示例3: runHeartBeatThrowOutException
import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入方法依赖的package包/类
private void runHeartBeatThrowOutException(Exception ex) throws Exception{
Configuration conf = new Configuration();
TestCallbackHandler callbackHandler = new TestCallbackHandler();
@SuppressWarnings("unchecked")
AMRMClient<ContainerRequest> client = mock(AMRMClientImpl.class);
when(client.allocate(anyFloat())).thenThrow(ex);
AMRMClientAsync<ContainerRequest> asyncClient =
AMRMClientAsync.createAMRMClientAsync(client, 20, callbackHandler);
asyncClient.init(conf);
asyncClient.start();
synchronized (callbackHandler.notifier) {
asyncClient.registerApplicationMaster("localhost", 1234, null);
while(callbackHandler.savedException == null) {
try {
callbackHandler.notifier.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
Assert.assertTrue(callbackHandler.savedException.getMessage().contains(
ex.getMessage()));
asyncClient.stop();
// stopping should have joined all threads and completed all callbacks
Assert.assertTrue(callbackHandler.callbackCount == 0);
}
示例4: testAMRMClientAsyncShutDownWithWaitFor
import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入方法依赖的package包/类
@Test (timeout = 10000)
public void testAMRMClientAsyncShutDownWithWaitFor() throws Exception {
Configuration conf = new Configuration();
final TestCallbackHandler callbackHandler = new TestCallbackHandler();
@SuppressWarnings("unchecked")
AMRMClient<ContainerRequest> client = mock(AMRMClientImpl.class);
when(client.allocate(anyFloat())).thenThrow(
new ApplicationAttemptNotFoundException("app not found, shut down"));
AMRMClientAsync<ContainerRequest> asyncClient =
AMRMClientAsync.createAMRMClientAsync(client, 10, callbackHandler);
asyncClient.init(conf);
asyncClient.start();
Supplier<Boolean> checker = new Supplier<Boolean>() {
@Override
public Boolean get() {
return callbackHandler.reboot;
}
};
asyncClient.registerApplicationMaster("localhost", 1234, null);
asyncClient.waitFor(checker);
asyncClient.stop();
// stopping should have joined all threads and completed all callbacks
Assert.assertTrue(callbackHandler.callbackCount == 0);
verify(client, times(1)).allocate(anyFloat());
asyncClient.stop();
}
示例5: testAMRMClientAsyncException
import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入方法依赖的package包/类
@Test(timeout=10000)
public void testAMRMClientAsyncException() throws Exception {
Configuration conf = new Configuration();
TestCallbackHandler callbackHandler = new TestCallbackHandler();
@SuppressWarnings("unchecked")
AMRMClient<ContainerRequest> client = mock(AMRMClientImpl.class);
String exStr = "TestException";
YarnException mockException = mock(YarnException.class);
when(mockException.getMessage()).thenReturn(exStr);
when(client.allocate(anyFloat())).thenThrow(mockException);
AMRMClientAsync<ContainerRequest> asyncClient =
AMRMClientAsync.createAMRMClientAsync(client, 20, callbackHandler);
asyncClient.init(conf);
asyncClient.start();
synchronized (callbackHandler.notifier) {
asyncClient.registerApplicationMaster("localhost", 1234, null);
while(callbackHandler.savedException == null) {
try {
callbackHandler.notifier.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
Assert.assertTrue(callbackHandler.savedException.getMessage().contains(exStr));
asyncClient.stop();
// stopping should have joined all threads and completed all callbacks
Assert.assertTrue(callbackHandler.callbackCount == 0);
}
示例6: testAMRMClientAsyncReboot
import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入方法依赖的package包/类
@Test//(timeout=10000)
public void testAMRMClientAsyncReboot() throws Exception {
Configuration conf = new Configuration();
TestCallbackHandler callbackHandler = new TestCallbackHandler();
@SuppressWarnings("unchecked")
AMRMClient<ContainerRequest> client = mock(AMRMClientImpl.class);
final AllocateResponse rebootResponse = createAllocateResponse(
new ArrayList<ContainerStatus>(), new ArrayList<Container>(), null);
rebootResponse.setAMCommand(AMCommand.AM_RESYNC);
when(client.allocate(anyFloat())).thenReturn(rebootResponse);
AMRMClientAsync<ContainerRequest> asyncClient =
AMRMClientAsync.createAMRMClientAsync(client, 20, callbackHandler);
asyncClient.init(conf);
asyncClient.start();
synchronized (callbackHandler.notifier) {
asyncClient.registerApplicationMaster("localhost", 1234, null);
while(callbackHandler.reboot == false) {
try {
callbackHandler.notifier.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
asyncClient.stop();
// stopping should have joined all threads and completed all callbacks
Assert.assertTrue(callbackHandler.callbackCount == 0);
}
示例7: runHeartBeatThrowOutException
import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入方法依赖的package包/类
private void runHeartBeatThrowOutException(Exception ex) throws Exception{
Configuration conf = new Configuration();
TestCallbackHandler callbackHandler = new TestCallbackHandler();
@SuppressWarnings("unchecked")
AMRMClient<ContainerRequest> client = mock(AMRMClientImpl.class);
when(client.allocate(anyFloat())).thenThrow(ex);
AMRMClientAsync<ContainerRequest> asyncClient =
AMRMClientAsync.createAMRMClientAsync(client, 20, callbackHandler);
asyncClient.init(conf);
asyncClient.start();
synchronized (callbackHandler.notifier) {
asyncClient.registerApplicationMaster("localhost", 1234, null);
while(callbackHandler.savedException == null) {
try {
callbackHandler.notifier.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
Assert.assertTrue(callbackHandler.savedException.getMessage().contains(
ex.getMessage()));
asyncClient.stop();
// stopping should have joined all threads and completed all callbacks
Assert.assertTrue(callbackHandler.callbackCount == 0);
}
示例8: testAmShutdown
import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; //导入方法依赖的package包/类
@Test
public void testAmShutdown() throws IOException, YarnException {
Assume.assumeTrue(
"This test requires a YARN Resource Manager to connect to",
Boolean.parseBoolean(System.getenv("REEF_TEST_YARN")));
final YarnConfiguration yarnConfig = new YarnConfiguration();
// Start YARN client and register the application
final YarnClient yarnClient = YarnClient.createYarnClient();
yarnClient.init(yarnConfig);
yarnClient.start();
final ContainerLaunchContext containerContext = Records.newRecord(ContainerLaunchContext.class);
containerContext.setCommands(Collections.<String>emptyList());
containerContext.setLocalResources(Collections.<String, LocalResource>emptyMap());
containerContext.setEnvironment(Collections.<String, String>emptyMap());
containerContext.setTokens(getTokens());
final ApplicationSubmissionContext appContext = yarnClient.createApplication().getApplicationSubmissionContext();
appContext.setApplicationName("REEF_Unmanaged_AM_Test");
appContext.setAMContainerSpec(containerContext);
appContext.setUnmanagedAM(true);
appContext.setQueue("default");
final ApplicationId applicationId = appContext.getApplicationId();
LOG.log(Level.INFO, "Registered YARN application: {0}", applicationId);
yarnClient.submitApplication(appContext);
LOG.log(Level.INFO, "YARN application submitted: {0}", applicationId);
addToken(yarnClient.getAMRMToken(applicationId));
// Start the AM
final AMRMClientAsync<AMRMClient.ContainerRequest> rmClient = AMRMClientAsync.createAMRMClientAsync(1000, this);
rmClient.init(yarnConfig);
rmClient.start();
final NMClientAsync nmClient = new NMClientAsyncImpl(this);
nmClient.init(yarnConfig);
nmClient.start();
final RegisterApplicationMasterResponse registration =
rmClient.registerApplicationMaster(NetUtils.getHostname(), -1, null);
LOG.log(Level.INFO, "Unmanaged AM is running: {0}", registration);
rmClient.unregisterApplicationMaster(FinalApplicationStatus.SUCCEEDED, "Success!", null);
LOG.log(Level.INFO, "Unregistering AM: state {0}", rmClient.getServiceState());
// Shutdown the AM
rmClient.stop();
nmClient.stop();
// Get the final application report
final ApplicationReport appReport = yarnClient.getApplicationReport(applicationId);
final YarnApplicationState appState = appReport.getYarnApplicationState();
final FinalApplicationStatus finalAttemptStatus = appReport.getFinalApplicationStatus();
LOG.log(Level.INFO, "Application {0} final attempt {1} status: {2}/{3}", new Object[] {
applicationId, appReport.getCurrentApplicationAttemptId(), appState, finalAttemptStatus});
Assert.assertEquals("Application must be in FINISHED state", YarnApplicationState.FINISHED, appState);
Assert.assertEquals("Final status must be SUCCEEDED", FinalApplicationStatus.SUCCEEDED, finalAttemptStatus);
// Shutdown YARN client
yarnClient.stop();
}