use of org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationMasterResponse in project hadoop by apache.
the class TestOpportunisticContainerAllocatorAMService method createService.
private OpportunisticContainerAllocatorAMService createService(final RecordFactory factory, final RMContext rmContext, final Container c) {
return new OpportunisticContainerAllocatorAMService(rmContext, null) {
@Override
public RegisterApplicationMasterResponse registerApplicationMaster(RegisterApplicationMasterRequest request) throws YarnException, IOException {
RegisterApplicationMasterResponse resp = factory.newRecordInstance(RegisterApplicationMasterResponse.class);
// Dummy Entry to Assert that we get this object back
resp.setQueue("dummyQueue");
return resp;
}
@Override
public FinishApplicationMasterResponse finishApplicationMaster(FinishApplicationMasterRequest request) throws YarnException, IOException {
FinishApplicationMasterResponse resp = factory.newRecordInstance(FinishApplicationMasterResponse.class);
// Dummy Entry to Assert that we get this object back
resp.setIsUnregistered(false);
return resp;
}
@Override
public AllocateResponse allocate(AllocateRequest request) throws YarnException, IOException {
AllocateResponse response = factory.newRecordInstance(AllocateResponse.class);
response.setNumClusterNodes(12345);
response.setAllocatedContainers(Arrays.asList(c));
return response;
}
@Override
public RegisterDistributedSchedulingAMResponse registerApplicationMasterForDistributedScheduling(RegisterApplicationMasterRequest request) throws YarnException, IOException {
RegisterDistributedSchedulingAMResponse resp = factory.newRecordInstance(RegisterDistributedSchedulingAMResponse.class);
resp.setContainerIdStart(54321L);
resp.setMaxContainerResource(Resource.newInstance(4096, 4));
resp.setMinContainerResource(Resource.newInstance(1024, 1));
resp.setIncrContainerResource(Resource.newInstance(2048, 2));
return resp;
}
@Override
public DistributedSchedulingAllocateResponse allocateForDistributedScheduling(DistributedSchedulingAllocateRequest request) throws YarnException, IOException {
List<ResourceRequest> askList = request.getAllocateRequest().getAskList();
List<Container> allocatedContainers = request.getAllocatedContainers();
Assert.assertEquals(1, allocatedContainers.size());
Assert.assertEquals(ExecutionType.OPPORTUNISTIC, allocatedContainers.get(0).getExecutionType());
Assert.assertEquals(1, askList.size());
Assert.assertTrue(askList.get(0).getExecutionTypeRequest().getEnforceExecutionType());
DistributedSchedulingAllocateResponse resp = factory.newRecordInstance(DistributedSchedulingAllocateResponse.class);
resp.setNodesForScheduling(Arrays.asList(RemoteNode.newInstance(NodeId.newInstance("h1", 1234), "http://h1:4321")));
return resp;
}
};
}
use of org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationMasterResponse in project hadoop by apache.
the class TestApplicationMasterServiceProtocolOnHA method testFinishApplicationMasterOnHA.
@Test(timeout = 15000)
public void testFinishApplicationMasterOnHA() throws YarnException, IOException {
FinishApplicationMasterRequest request = FinishApplicationMasterRequest.newInstance(FinalApplicationStatus.SUCCEEDED, "", "");
FinishApplicationMasterResponse response = amClient.finishApplicationMaster(request);
Assert.assertEquals(response, this.cluster.createFakeFinishApplicationMasterResponse());
}
use of org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationMasterResponse in project hadoop by apache.
the class AMRMClientImpl method unregisterApplicationMaster.
@Override
public void unregisterApplicationMaster(FinalApplicationStatus appStatus, String appMessage, String appTrackingUrl) throws YarnException, IOException {
Preconditions.checkArgument(appStatus != null, "AppStatus should not be null.");
FinishApplicationMasterRequest request = FinishApplicationMasterRequest.newInstance(appStatus, appMessage, appTrackingUrl);
try {
while (true) {
FinishApplicationMasterResponse response = rmClient.finishApplicationMaster(request);
if (response.getIsUnregistered()) {
break;
}
LOG.info("Waiting for application to be successfully unregistered.");
Thread.sleep(100);
}
} catch (InterruptedException e) {
LOG.info("Interrupted while waiting for application" + " to be removed from RMStateStore");
} catch (ApplicationMasterNotRegisteredException e) {
LOG.warn("ApplicationMaster is out of sync with ResourceManager," + " hence resyncing.");
// re register with RM
registerApplicationMaster();
unregisterApplicationMaster(appStatus, appMessage, appTrackingUrl);
}
}
use of org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationMasterResponse in project hadoop by apache.
the class TestUnmanagedAMLauncher method main.
// provide main method so this class can act as AM
public static void main(String[] args) throws Exception {
if (args[0].equals("success")) {
ApplicationMasterProtocol client = ClientRMProxy.createRMProxy(conf, ApplicationMasterProtocol.class);
client.registerApplicationMaster(RegisterApplicationMasterRequest.newInstance(NetUtils.getHostname(), -1, ""));
Thread.sleep(1000);
FinishApplicationMasterResponse resp = client.finishApplicationMaster(FinishApplicationMasterRequest.newInstance(FinalApplicationStatus.SUCCEEDED, "success", null));
assertTrue(resp.getIsUnregistered());
System.exit(0);
} else {
System.exit(1);
}
}
use of org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationMasterResponse in project hadoop by apache.
the class TestAMRMProxyService method testFinishOneApplicationMasterWithSuccess.
@Test
public void testFinishOneApplicationMasterWithSuccess() throws Exception {
int testAppId = 1;
RegisterApplicationMasterResponse registerResponse = registerApplicationMaster(testAppId);
Assert.assertNotNull(registerResponse);
Assert.assertEquals(Integer.toString(testAppId), registerResponse.getQueue());
FinishApplicationMasterResponse finshResponse = finishApplicationMaster(testAppId, FinalApplicationStatus.SUCCEEDED);
Assert.assertNotNull(finshResponse);
Assert.assertEquals(true, finshResponse.getIsUnregistered());
}
Aggregations