Search in sources :

Example 1 with YarnApplicationAttemptState

use of org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState in project hadoop by apache.

the class ApplicationHistoryManagerOnTimelineStore method convertToApplicationAttemptReport.

private static ApplicationAttemptReport convertToApplicationAttemptReport(TimelineEntity entity) {
    String host = null;
    int rpcPort = -1;
    ContainerId amContainerId = null;
    String trackingUrl = null;
    String originalTrackingUrl = null;
    String diagnosticsInfo = null;
    YarnApplicationAttemptState state = null;
    List<TimelineEvent> events = entity.getEvents();
    if (events != null) {
        for (TimelineEvent event : events) {
            if (event.getEventType().equals(AppAttemptMetricsConstants.REGISTERED_EVENT_TYPE)) {
                Map<String, Object> eventInfo = event.getEventInfo();
                if (eventInfo == null) {
                    continue;
                }
                if (eventInfo.containsKey(AppAttemptMetricsConstants.HOST_INFO)) {
                    host = eventInfo.get(AppAttemptMetricsConstants.HOST_INFO).toString();
                }
                if (eventInfo.containsKey(AppAttemptMetricsConstants.RPC_PORT_INFO)) {
                    rpcPort = (Integer) eventInfo.get(AppAttemptMetricsConstants.RPC_PORT_INFO);
                }
                if (eventInfo.containsKey(AppAttemptMetricsConstants.MASTER_CONTAINER_INFO)) {
                    amContainerId = ContainerId.fromString(eventInfo.get(AppAttemptMetricsConstants.MASTER_CONTAINER_INFO).toString());
                }
            } else if (event.getEventType().equals(AppAttemptMetricsConstants.FINISHED_EVENT_TYPE)) {
                Map<String, Object> eventInfo = event.getEventInfo();
                if (eventInfo == null) {
                    continue;
                }
                if (eventInfo.containsKey(AppAttemptMetricsConstants.TRACKING_URL_INFO)) {
                    trackingUrl = eventInfo.get(AppAttemptMetricsConstants.TRACKING_URL_INFO).toString();
                }
                if (eventInfo.containsKey(AppAttemptMetricsConstants.ORIGINAL_TRACKING_URL_INFO)) {
                    originalTrackingUrl = eventInfo.get(AppAttemptMetricsConstants.ORIGINAL_TRACKING_URL_INFO).toString();
                }
                if (eventInfo.containsKey(AppAttemptMetricsConstants.DIAGNOSTICS_INFO)) {
                    diagnosticsInfo = eventInfo.get(AppAttemptMetricsConstants.DIAGNOSTICS_INFO).toString();
                }
                if (eventInfo.containsKey(AppAttemptMetricsConstants.STATE_INFO)) {
                    state = YarnApplicationAttemptState.valueOf(eventInfo.get(AppAttemptMetricsConstants.STATE_INFO).toString());
                }
                if (eventInfo.containsKey(AppAttemptMetricsConstants.MASTER_CONTAINER_INFO)) {
                    amContainerId = ContainerId.fromString(eventInfo.get(AppAttemptMetricsConstants.MASTER_CONTAINER_INFO).toString());
                }
            }
        }
    }
    return ApplicationAttemptReport.newInstance(ApplicationAttemptId.fromString(entity.getEntityId()), host, rpcPort, trackingUrl, originalTrackingUrl, diagnosticsInfo, state, amContainerId);
}
Also used : TimelineEvent(org.apache.hadoop.yarn.api.records.timeline.TimelineEvent) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) YarnApplicationAttemptState(org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState)

Example 2 with YarnApplicationAttemptState

use of org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState in project hadoop by apache.

the class TestUnmanagedAMLauncher method testUMALauncher.

@Test(timeout = 30000)
public void testUMALauncher() throws Exception {
    String classpath = getTestRuntimeClasspath();
    String javaHome = System.getenv("JAVA_HOME");
    if (javaHome == null) {
        LOG.fatal("JAVA_HOME not defined. Test not running.");
        return;
    }
    String[] args = { "--classpath", classpath, "--queue", "default", "--cmd", javaHome + "/bin/java -Xmx512m " + TestUnmanagedAMLauncher.class.getCanonicalName() + " success" };
    LOG.info("Initializing Launcher");
    UnmanagedAMLauncher launcher = new UnmanagedAMLauncher(new Configuration(yarnCluster.getConfig())) {

        public void launchAM(ApplicationAttemptId attemptId) throws IOException, YarnException {
            YarnApplicationAttemptState attemptState = rmClient.getApplicationAttemptReport(attemptId).getYarnApplicationAttemptState();
            Assert.assertTrue(attemptState.equals(YarnApplicationAttemptState.LAUNCHED));
            super.launchAM(attemptId);
        }
    };
    boolean initSuccess = launcher.init(args);
    Assert.assertTrue(initSuccess);
    LOG.info("Running Launcher");
    boolean result = launcher.run();
    LOG.info("Launcher run completed. Result=" + result);
    Assert.assertTrue(result);
}
Also used : YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) YarnApplicationAttemptState(org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState) Test(org.junit.Test)

Aggregations

YarnApplicationAttemptState (org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Configuration (org.apache.hadoop.conf.Configuration)1 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)1 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)1 TimelineEvent (org.apache.hadoop.yarn.api.records.timeline.TimelineEvent)1 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)1 Test (org.junit.Test)1