org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.event.RMAppAttemptRegistrationEvent Java Examples

The following examples show how to use org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.event.RMAppAttemptRegistrationEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MiniYARNCluster.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private synchronized void initResourceManager(int index, Configuration conf) {
  if (HAUtil.isHAEnabled(conf)) {
    conf.set(YarnConfiguration.RM_HA_ID, rmIds[index]);
  }
  resourceManagers[index].init(conf);
  resourceManagers[index].getRMContext().getDispatcher().register(
      RMAppAttemptEventType.class,
      new EventHandler<RMAppAttemptEvent>() {
        public void handle(RMAppAttemptEvent event) {
          if (event instanceof RMAppAttemptRegistrationEvent) {
            appMasters.put(event.getApplicationAttemptId(),
                event.getTimestamp());
          } else if (event instanceof RMAppAttemptUnregistrationEvent) {
            appMasters.remove(event.getApplicationAttemptId());
          }
        }
      });
}
 
Example #2
Source File: TestRMAppAttemptTransitions.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testUnmanagedAMUnexpectedRegistration() {
  unmanagedAM = true;
  when(submissionContext.getUnmanagedAM()).thenReturn(true);

  // submit AM and check it goes to SUBMITTED state
  submitApplicationAttempt();
  assertEquals(RMAppAttemptState.SUBMITTED,
      applicationAttempt.getAppAttemptState());

  // launch AM and verify attempt failed
  applicationAttempt.handle(new RMAppAttemptRegistrationEvent(
      applicationAttempt.getAppAttemptId(), "host", 8042, "oldtrackingurl"));
  assertEquals(YarnApplicationAttemptState.SUBMITTED,
      applicationAttempt.createApplicationAttemptState());
  testAppAttemptSubmittedToFailedState(
      "Unmanaged AM must register after AM attempt reaches LAUNCHED state.");
}
 
Example #3
Source File: TestRMAppAttemptTransitions.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testUnmanagedAMContainersCleanup() {
  unmanagedAM = true;
  when(submissionContext.getUnmanagedAM()).thenReturn(true);
  when(submissionContext.getKeepContainersAcrossApplicationAttempts())
    .thenReturn(true);
  // submit AM and check it goes to SUBMITTED state
  submitApplicationAttempt();
  // launch AM and verify attempt failed
  applicationAttempt.handle(new RMAppAttemptRegistrationEvent(
    applicationAttempt.getAppAttemptId(), "host", 8042, "oldtrackingurl"));
  assertEquals(YarnApplicationAttemptState.SUBMITTED,
      applicationAttempt.createApplicationAttemptState());
  sendAttemptUpdateSavedEvent(applicationAttempt);
  assertFalse(transferStateFromPreviousAttempt);
}
 
Example #4
Source File: MiniYARNCluster.java    From big-c with Apache License 2.0 6 votes vote down vote up
private synchronized void initResourceManager(int index, Configuration conf) {
  if (HAUtil.isHAEnabled(conf)) {
    conf.set(YarnConfiguration.RM_HA_ID, rmIds[index]);
  }
  resourceManagers[index].init(conf);
  resourceManagers[index].getRMContext().getDispatcher().register(
      RMAppAttemptEventType.class,
      new EventHandler<RMAppAttemptEvent>() {
        public void handle(RMAppAttemptEvent event) {
          if (event instanceof RMAppAttemptRegistrationEvent) {
            appMasters.put(event.getApplicationAttemptId(),
                event.getTimestamp());
          } else if (event instanceof RMAppAttemptUnregistrationEvent) {
            appMasters.remove(event.getApplicationAttemptId());
          }
        }
      });
}
 
Example #5
Source File: TestRMAppAttemptTransitions.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testUnmanagedAMUnexpectedRegistration() {
  unmanagedAM = true;
  when(submissionContext.getUnmanagedAM()).thenReturn(true);

  // submit AM and check it goes to SUBMITTED state
  submitApplicationAttempt();
  assertEquals(RMAppAttemptState.SUBMITTED,
      applicationAttempt.getAppAttemptState());

  // launch AM and verify attempt failed
  applicationAttempt.handle(new RMAppAttemptRegistrationEvent(
      applicationAttempt.getAppAttemptId(), "host", 8042, "oldtrackingurl"));
  assertEquals(YarnApplicationAttemptState.SUBMITTED,
      applicationAttempt.createApplicationAttemptState());
  testAppAttemptSubmittedToFailedState(
      "Unmanaged AM must register after AM attempt reaches LAUNCHED state.");
}
 
Example #6
Source File: TestRMAppAttemptTransitions.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testUnmanagedAMContainersCleanup() {
  unmanagedAM = true;
  when(submissionContext.getUnmanagedAM()).thenReturn(true);
  when(submissionContext.getKeepContainersAcrossApplicationAttempts())
    .thenReturn(true);
  // submit AM and check it goes to SUBMITTED state
  submitApplicationAttempt();
  // launch AM and verify attempt failed
  applicationAttempt.handle(new RMAppAttemptRegistrationEvent(
    applicationAttempt.getAppAttemptId(), "host", 8042, "oldtrackingurl"));
  assertEquals(YarnApplicationAttemptState.SUBMITTED,
      applicationAttempt.createApplicationAttemptState());
  sendAttemptUpdateSavedEvent(applicationAttempt);
  assertFalse(transferStateFromPreviousAttempt);
}
 
Example #7
Source File: RMAppAttemptImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public void transition(RMAppAttemptImpl appAttempt,
    RMAppAttemptEvent event) {
  long delay = System.currentTimeMillis() - appAttempt.launchAMEndTime;
  ClusterMetrics.getMetrics().addAMRegisterDelay(delay);
  RMAppAttemptRegistrationEvent registrationEvent
      = (RMAppAttemptRegistrationEvent) event;
  appAttempt.host = registrationEvent.getHost();
  appAttempt.rpcPort = registrationEvent.getRpcport();
  appAttempt.originalTrackingUrl =
      sanitizeTrackingUrl(registrationEvent.getTrackingurl());

  // Let the app know
  appAttempt.eventHandler.handle(new RMAppEvent(appAttempt
      .getAppAttemptId().getApplicationId(),
      RMAppEventType.ATTEMPT_REGISTERED));

  // TODO:FIXME: Note for future. Unfortunately we only do a state-store
  // write at AM launch time, so we don't save the AM's tracking URL anywhere
  // as that would mean an extra state-store write. For now, we hope that in
  // work-preserving restart, AMs are forced to reregister.

  appAttempt.rmContext.getRMApplicationHistoryWriter()
      .applicationAttemptStarted(appAttempt);
  appAttempt.rmContext.getSystemMetricsPublisher()
      .appAttemptRegistered(appAttempt, System.currentTimeMillis());
}
 
Example #8
Source File: TestRMAppAttemptTransitions.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void runApplicationAttempt(Container container,
    String host, 
    int rpcPort, 
    String trackingUrl, boolean unmanagedAM) {
  applicationAttempt.handle(
      new RMAppAttemptRegistrationEvent(
          applicationAttempt.getAppAttemptId(),
          host, rpcPort, trackingUrl));
  
  testAppAttemptRunningState(container, host, rpcPort, trackingUrl, 
      unmanagedAM);
}
 
Example #9
Source File: RMAppAttemptImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void transition(RMAppAttemptImpl appAttempt,
    RMAppAttemptEvent event) {
  long delay = System.currentTimeMillis() - appAttempt.launchAMEndTime;
  ClusterMetrics.getMetrics().addAMRegisterDelay(delay);
  RMAppAttemptRegistrationEvent registrationEvent
      = (RMAppAttemptRegistrationEvent) event;
  appAttempt.host = registrationEvent.getHost();
  appAttempt.rpcPort = registrationEvent.getRpcport();
  appAttempt.originalTrackingUrl =
      sanitizeTrackingUrl(registrationEvent.getTrackingurl());

  // Let the app know
  appAttempt.eventHandler.handle(new RMAppEvent(appAttempt
      .getAppAttemptId().getApplicationId(),
      RMAppEventType.ATTEMPT_REGISTERED));

  // TODO:FIXME: Note for future. Unfortunately we only do a state-store
  // write at AM launch time, so we don't save the AM's tracking URL anywhere
  // as that would mean an extra state-store write. For now, we hope that in
  // work-preserving restart, AMs are forced to reregister.

  appAttempt.rmContext.getRMApplicationHistoryWriter()
      .applicationAttemptStarted(appAttempt);
  appAttempt.rmContext.getSystemMetricsPublisher()
      .appAttemptRegistered(appAttempt, System.currentTimeMillis());
}
 
Example #10
Source File: TestRMAppAttemptTransitions.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void runApplicationAttempt(Container container,
    String host, 
    int rpcPort, 
    String trackingUrl, boolean unmanagedAM) {
  applicationAttempt.handle(
      new RMAppAttemptRegistrationEvent(
          applicationAttempt.getAppAttemptId(),
          host, rpcPort, trackingUrl));
  
  testAppAttemptRunningState(container, host, rpcPort, trackingUrl, 
      unmanagedAM);
}
 
Example #11
Source File: MiniYARNClusterSplice.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
private synchronized void initResourceManager(int index, Configuration conf) {
    if (HAUtil.isHAEnabled(conf)) {
        conf.set(YarnConfiguration.RM_HA_ID, rmIds[index]);
    }

    if (conf.get(YarnConfiguration.RM_HOSTNAME) == null) {
        conf.set(YarnConfiguration.RM_HOSTNAME, "0.0.0.0");
    }
    LOG.info("*** "+YarnConfiguration.RM_HOSTNAME+" is set to: "+conf.get(YarnConfiguration.RM_HOSTNAME));

    if (conf.get(YarnConfiguration.RM_ADDRESS) == null) {
        conf.set(YarnConfiguration.RM_ADDRESS,
                   YarnConfiguration.DEFAULT_RM_ADDRESS);
    }
    LOG.info("*** "+YarnConfiguration.RM_ADDRESS+" is set to: "+conf.get(YarnConfiguration.RM_ADDRESS));

    if (conf.get(YarnConfiguration.RM_WEBAPP_ADDRESS) == null) {
        WebAppUtils
            .setNMWebAppHostNameAndPort(conf,
                                        MiniYARNClusterSplice.getHostname(), 0);
    }
    LOG.info("*** "+YarnConfiguration.RM_WEBAPP_ADDRESS+" is set to: "+conf.get(YarnConfiguration.RM_WEBAPP_ADDRESS));

    resourceManagers[index].init(conf);
    resourceManagers[index].getRMContext().getDispatcher().register(
        RMAppAttemptEventType.class,
        new EventHandler<RMAppAttemptEvent>() {
            public void handle(RMAppAttemptEvent event) {
                if (event instanceof RMAppAttemptRegistrationEvent) {
                    appMasters.put(event.getApplicationAttemptId(),
                                   event.getTimestamp());
                } else if (event instanceof RMAppAttemptUnregistrationEvent) {
                    appMasters.remove(event.getApplicationAttemptId());
                }
            }
        });
}