use of org.apache.hadoop.yarn.api.records.YarnApplicationState in project flink by apache.
the class YarnClusterClient method getApplicationStatus.
public ApplicationStatus getApplicationStatus() {
if (!isConnected) {
throw new IllegalStateException("The cluster has been connected to the ApplicationMaster.");
}
ApplicationReport lastReport = null;
if (pollingRunner == null) {
LOG.warn("YarnClusterClient.getApplicationStatus() has been called on an uninitialized cluster." + "The system might be in an erroneous state");
} else {
lastReport = pollingRunner.getLastReport();
}
if (lastReport == null) {
LOG.warn("YarnClusterClient.getApplicationStatus() has been called on a cluster that didn't receive a status so far." + "The system might be in an erroneous state");
return ApplicationStatus.UNKNOWN;
} else {
YarnApplicationState appState = lastReport.getYarnApplicationState();
ApplicationStatus status = (appState == YarnApplicationState.FAILED || appState == YarnApplicationState.KILLED) ? ApplicationStatus.FAILED : ApplicationStatus.SUCCEEDED;
if (status != ApplicationStatus.SUCCEEDED) {
LOG.warn("YARN reported application state {}", appState);
LOG.warn("Diagnostics: {}", lastReport.getDiagnostics());
}
return status;
}
}
use of org.apache.hadoop.yarn.api.records.YarnApplicationState in project hadoop by apache.
the class TestTypeConverter method testFromYarn.
@Test
public void testFromYarn() throws Exception {
int appStartTime = 612354;
int appFinishTime = 612355;
YarnApplicationState state = YarnApplicationState.RUNNING;
ApplicationId applicationId = ApplicationId.newInstance(0, 0);
ApplicationReport applicationReport = Records.newRecord(ApplicationReport.class);
applicationReport.setApplicationId(applicationId);
applicationReport.setYarnApplicationState(state);
applicationReport.setStartTime(appStartTime);
applicationReport.setFinishTime(appFinishTime);
applicationReport.setUser("TestTypeConverter-user");
applicationReport.setPriority(Priority.newInstance(3));
ApplicationResourceUsageReport appUsageRpt = Records.newRecord(ApplicationResourceUsageReport.class);
Resource r = Records.newRecord(Resource.class);
r.setMemorySize(2048);
appUsageRpt.setNeededResources(r);
appUsageRpt.setNumReservedContainers(1);
appUsageRpt.setNumUsedContainers(3);
appUsageRpt.setReservedResources(r);
appUsageRpt.setUsedResources(r);
applicationReport.setApplicationResourceUsageReport(appUsageRpt);
JobStatus jobStatus = TypeConverter.fromYarn(applicationReport, "dummy-jobfile");
Assert.assertEquals(appStartTime, jobStatus.getStartTime());
Assert.assertEquals(appFinishTime, jobStatus.getFinishTime());
Assert.assertEquals(state.toString(), jobStatus.getState().toString());
Assert.assertEquals(JobPriority.NORMAL, jobStatus.getPriority());
}
use of org.apache.hadoop.yarn.api.records.YarnApplicationState in project hadoop by apache.
the class ResourceMgrDelegate method getAllJobs.
public JobStatus[] getAllJobs() throws IOException, InterruptedException {
try {
Set<String> appTypes = new HashSet<String>(1);
appTypes.add(MRJobConfig.MR_APPLICATION_TYPE);
EnumSet<YarnApplicationState> appStates = EnumSet.noneOf(YarnApplicationState.class);
return TypeConverter.fromYarnApps(client.getApplications(appTypes, appStates), this.conf);
} catch (YarnException e) {
throw new IOException(e);
}
}
use of org.apache.hadoop.yarn.api.records.YarnApplicationState in project hadoop by apache.
the class ApplicationCLI method getAllValidApplicationStates.
private String getAllValidApplicationStates() {
StringBuilder sb = new StringBuilder();
sb.append("The valid application state can be" + " one of the following: ");
sb.append(ALLSTATES_OPTION + ",");
for (YarnApplicationState appState : YarnApplicationState.values()) {
sb.append(appState + ",");
}
String output = sb.toString();
return output.substring(0, output.length() - 1);
}
use of org.apache.hadoop.yarn.api.records.YarnApplicationState in project hadoop by apache.
the class TestGetApplicationsRequest method testGetApplicationsRequest.
@Test
public void testGetApplicationsRequest() {
GetApplicationsRequest request = GetApplicationsRequest.newInstance();
EnumSet<YarnApplicationState> appStates = EnumSet.of(YarnApplicationState.ACCEPTED);
request.setApplicationStates(appStates);
Set<String> tags = new HashSet<String>();
tags.add("tag1");
request.setApplicationTags(tags);
Set<String> types = new HashSet<String>();
types.add("type1");
request.setApplicationTypes(types);
long startBegin = System.currentTimeMillis();
long startEnd = System.currentTimeMillis() + 1;
request.setStartRange(startBegin, startEnd);
long finishBegin = System.currentTimeMillis() + 2;
long finishEnd = System.currentTimeMillis() + 3;
request.setFinishRange(finishBegin, finishEnd);
long limit = 100L;
request.setLimit(limit);
Set<String> queues = new HashSet<String>();
queues.add("queue1");
request.setQueues(queues);
Set<String> users = new HashSet<String>();
users.add("user1");
request.setUsers(users);
ApplicationsRequestScope scope = ApplicationsRequestScope.ALL;
request.setScope(scope);
GetApplicationsRequest requestFromProto = new GetApplicationsRequestPBImpl(((GetApplicationsRequestPBImpl) request).getProto());
// verify the whole record equals with original record
Assert.assertEquals(requestFromProto, request);
// verify all properties are the same as original request
Assert.assertEquals("ApplicationStates from proto is not the same with original request", requestFromProto.getApplicationStates(), appStates);
Assert.assertEquals("ApplicationTags from proto is not the same with original request", requestFromProto.getApplicationTags(), tags);
Assert.assertEquals("ApplicationTypes from proto is not the same with original request", requestFromProto.getApplicationTypes(), types);
Assert.assertEquals("StartRange from proto is not the same with original request", requestFromProto.getStartRange(), new LongRange(startBegin, startEnd));
Assert.assertEquals("FinishRange from proto is not the same with original request", requestFromProto.getFinishRange(), new LongRange(finishBegin, finishEnd));
Assert.assertEquals("Limit from proto is not the same with original request", requestFromProto.getLimit(), limit);
Assert.assertEquals("Queues from proto is not the same with original request", requestFromProto.getQueues(), queues);
Assert.assertEquals("Users from proto is not the same with original request", requestFromProto.getUsers(), users);
}
Aggregations