Search in sources :

Example 1 with YarnApplicationState

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;
    }
}
Also used : ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) ApplicationStatus(org.apache.flink.runtime.clusterframework.ApplicationStatus) YarnApplicationState(org.apache.hadoop.yarn.api.records.YarnApplicationState)

Example 2 with YarnApplicationState

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());
}
Also used : ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) ApplicationResourceUsageReport(org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport) YarnApplicationState(org.apache.hadoop.yarn.api.records.YarnApplicationState) Resource(org.apache.hadoop.yarn.api.records.Resource) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) Test(org.junit.Test)

Example 3 with YarnApplicationState

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);
    }
}
Also used : YarnApplicationState(org.apache.hadoop.yarn.api.records.YarnApplicationState) IOException(java.io.IOException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) HashSet(java.util.HashSet)

Example 4 with YarnApplicationState

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);
}
Also used : YarnApplicationState(org.apache.hadoop.yarn.api.records.YarnApplicationState)

Example 5 with YarnApplicationState

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);
}
Also used : LongRange(org.apache.commons.lang.math.LongRange) ApplicationsRequestScope(org.apache.hadoop.yarn.api.protocolrecords.ApplicationsRequestScope) YarnApplicationState(org.apache.hadoop.yarn.api.records.YarnApplicationState) GetApplicationsRequestPBImpl(org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetApplicationsRequestPBImpl) GetApplicationsRequest(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

YarnApplicationState (org.apache.hadoop.yarn.api.records.YarnApplicationState)41 ApplicationReport (org.apache.hadoop.yarn.api.records.ApplicationReport)27 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)14 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)11 IOException (java.io.IOException)10 FinalApplicationStatus (org.apache.hadoop.yarn.api.records.FinalApplicationStatus)8 HashSet (java.util.HashSet)7 ApplicationSubmissionContext (org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext)7 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)6 ArrayList (java.util.ArrayList)5 ContainerLaunchContext (org.apache.hadoop.yarn.api.records.ContainerLaunchContext)5 YarnClient (org.apache.hadoop.yarn.client.api.YarnClient)5 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)5 Test (org.junit.Test)5 Path (org.apache.hadoop.fs.Path)4 Resource (org.apache.hadoop.yarn.api.records.Resource)4 YarnClientApplication (org.apache.hadoop.yarn.client.api.YarnClientApplication)4 File (java.io.File)3 HashMap (java.util.HashMap)3 FileSystem (org.apache.hadoop.fs.FileSystem)3