org.apache.hadoop.yarn.server.api.ApplicationTerminationContext Java Examples

The following examples show how to use org.apache.hadoop.yarn.server.api.ApplicationTerminationContext. 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: ShuffleHandler.java    From tez with Apache License 2.0 5 votes vote down vote up
@Override
public void stopApplication(ApplicationTerminationContext context) {
  ApplicationId appId = context.getApplicationId();
  JobID jobId = new JobID(Long.toString(appId.getClusterTimestamp()), appId.getId());
  try {
    removeJobShuffleInfo(jobId);
  } catch (IOException e) {
    LOG.error("Error during stopApp", e);
    // TODO add API to AuxiliaryServices to report failures
  }
}
 
Example #2
Source File: ShuffleHandler.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public void stopApplication(ApplicationTerminationContext context) {
  ApplicationId appId = context.getApplicationId();
  JobID jobId = new JobID(Long.toString(appId.getClusterTimestamp()), appId.getId());
  try {
    removeJobShuffleInfo(jobId);
  } catch (IOException e) {
    LOG.error("Error during stopApp", e);
    // TODO add API to AuxiliaryServices to report failures
  }
}
 
Example #3
Source File: ShuffleHandler.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void stopApplication(ApplicationTerminationContext context) {
  ApplicationId appId = context.getApplicationId();
  JobID jobId = new JobID(Long.toString(appId.getClusterTimestamp()), appId.getId());
  try {
    removeJobShuffleInfo(jobId);
  } catch (IOException e) {
    LOG.error("Error during stopApp", e);
    // TODO add API to AuxiliaryServices to report failures
  }
}
 
Example #4
Source File: TestShuffleProvider.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public void stopApplication(ApplicationTerminationContext context) {
}
 
Example #5
Source File: TestShuffleHandler.java    From tez with Apache License 2.0 4 votes vote down vote up
@Test
public void testRecovery() throws IOException {
  final String user = "someuser";
  final ApplicationId appId = ApplicationId.newInstance(12345, 1);
  final JobID jobId = JobID.downgrade(TypeConverter.fromYarn(appId));
  final File tmpDir = new File(System.getProperty("test.build.data",
      System.getProperty("java.io.tmpdir")),
      TestShuffleHandler.class.getName());
  Configuration conf = new Configuration();
  conf.set(HADOOP_TMP_DIR, TEST_DIR.getAbsolutePath());
  conf.setInt(ShuffleHandler.SHUFFLE_PORT_CONFIG_KEY, 0);
  conf.setInt(ShuffleHandler.MAX_SHUFFLE_CONNECTIONS, 3);
  ShuffleHandler shuffle = new ShuffleHandler();
  // emulate aux services startup with recovery enabled
  shuffle.setRecoveryPath(new Path(tmpDir.toString()));
  tmpDir.mkdirs();
  try {
    shuffle.init(conf);
    shuffle.start();

    // setup a shuffle token for an application
    DataOutputBuffer outputBuffer = new DataOutputBuffer();
    outputBuffer.reset();
    Token<JobTokenIdentifier> jt = new Token<JobTokenIdentifier>(
        "identifier".getBytes(), "password".getBytes(), new Text(user),
        new Text("shuffleService"));
    jt.write(outputBuffer);
    shuffle.initializeApplication(new ApplicationInitializationContext(user,
        appId, ByteBuffer.wrap(outputBuffer.getData(), 0,
          outputBuffer.getLength())));

    // verify we are authorized to shuffle
    int rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_OK, rc);

    // emulate shuffle handler restart
    shuffle.close();
    shuffle = new ShuffleHandler();
    shuffle.setRecoveryPath(new Path(tmpDir.toString()));
    shuffle.init(conf);
    shuffle.start();

    // verify we are still authorized to shuffle to the old application
    rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_OK, rc);

    // shutdown app and verify access is lost
    shuffle.stopApplication(new ApplicationTerminationContext(appId));
    rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, rc);

    // emulate shuffle handler restart
    shuffle.close();
    shuffle = new ShuffleHandler();
    shuffle.setRecoveryPath(new Path(tmpDir.toString()));
    shuffle.init(conf);
    shuffle.start();

    // verify we still don't have access
    rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, rc);
  } finally {
    if (shuffle != null) {
      shuffle.close();
    }
    FileUtil.fullyDelete(tmpDir);
  }
}
 
Example #6
Source File: PullServerAuxService.java    From incubator-tajo with Apache License 2.0 4 votes vote down vote up
@Override
public void stopApplication(ApplicationTerminationContext appStopContext) {
  userRsrc.remove(appStopContext.getApplicationId().toString());
}
 
Example #7
Source File: TajoPullServerService.java    From tajo with Apache License 2.0 4 votes vote down vote up
@Override
public void stopApplication(ApplicationTerminationContext context) {
  userRsrc.remove(context.getApplicationId().toString());
}
 
Example #8
Source File: MyriadExecutorAuxService.java    From incubator-myriad with Apache License 2.0 4 votes vote down vote up
@Override
public void stopApplication(ApplicationTerminationContext stopAppContext) {
  LOGGER.debug("stopApplication");
}
 
Example #9
Source File: TestShuffleHandler.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test
public void testRecovery() throws IOException {
  final String user = "someuser";
  final ApplicationId appId = ApplicationId.newInstance(12345, 1);
  final JobID jobId = JobID.downgrade(TypeConverter.fromYarn(appId));
  final File tmpDir = new File(System.getProperty("test.build.data",
      System.getProperty("java.io.tmpdir")),
      TestShuffleHandler.class.getName());
  Configuration conf = new Configuration();
  conf.setInt(ShuffleHandler.SHUFFLE_PORT_CONFIG_KEY, 0);
  conf.setInt(ShuffleHandler.MAX_SHUFFLE_CONNECTIONS, 3);
  ShuffleHandler shuffle = new ShuffleHandler();
  // emulate aux services startup with recovery enabled
  shuffle.setRecoveryPath(new Path(tmpDir.toString()));
  tmpDir.mkdirs();
  try {
    shuffle.init(conf);
    shuffle.start();

    // setup a shuffle token for an application
    DataOutputBuffer outputBuffer = new DataOutputBuffer();
    outputBuffer.reset();
    Token<JobTokenIdentifier> jt = new Token<JobTokenIdentifier>(
        "identifier".getBytes(), "password".getBytes(), new Text(user),
        new Text("shuffleService"));
    jt.write(outputBuffer);
    shuffle.initializeApplication(new ApplicationInitializationContext(user,
        appId, ByteBuffer.wrap(outputBuffer.getData(), 0,
          outputBuffer.getLength())));

    // verify we are authorized to shuffle
    int rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_OK, rc);

    // emulate shuffle handler restart
    shuffle.close();
    shuffle = new ShuffleHandler();
    shuffle.setRecoveryPath(new Path(tmpDir.toString()));
    shuffle.init(conf);
    shuffle.start();

    // verify we are still authorized to shuffle to the old application
    rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_OK, rc);

    // shutdown app and verify access is lost
    shuffle.stopApplication(new ApplicationTerminationContext(appId));
    rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, rc);

    // emulate shuffle handler restart
    shuffle.close();
    shuffle = new ShuffleHandler();
    shuffle.setRecoveryPath(new Path(tmpDir.toString()));
    shuffle.init(conf);
    shuffle.start();

    // verify we still don't have access
    rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, rc);
  } finally {
    if (shuffle != null) {
      shuffle.close();
    }
    FileUtil.fullyDelete(tmpDir);
  }
}
 
Example #10
Source File: TestShuffleProvider.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public void stopApplication(ApplicationTerminationContext context) {
}
 
Example #11
Source File: TestAuxServices.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public void stopApplication(ApplicationTerminationContext context) {
  stoppedApps.add(context.getApplicationId().getId());
}
 
Example #12
Source File: TestAuxServices.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public void stopApplication(ApplicationTerminationContext stopAppContext) {
}
 
Example #13
Source File: TestAuxServices.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public void stopApplication(ApplicationTerminationContext context) {
  stoppedApps.add(context.getApplicationId().getId());
}
 
Example #14
Source File: TestShuffleHandler.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Test
public void testRecovery() throws IOException {
  final String user = "someuser";
  final ApplicationId appId = ApplicationId.newInstance(12345, 1);
  final JobID jobId = JobID.downgrade(TypeConverter.fromYarn(appId));
  final File tmpDir = new File(System.getProperty("test.build.data",
      System.getProperty("java.io.tmpdir")),
      TestShuffleHandler.class.getName());
  Configuration conf = new Configuration();
  conf.setInt(ShuffleHandler.SHUFFLE_PORT_CONFIG_KEY, 0);
  conf.setInt(ShuffleHandler.MAX_SHUFFLE_CONNECTIONS, 3);
  ShuffleHandler shuffle = new ShuffleHandler();
  // emulate aux services startup with recovery enabled
  shuffle.setRecoveryPath(new Path(tmpDir.toString()));
  tmpDir.mkdirs();
  try {
    shuffle.init(conf);
    shuffle.start();

    // setup a shuffle token for an application
    DataOutputBuffer outputBuffer = new DataOutputBuffer();
    outputBuffer.reset();
    Token<JobTokenIdentifier> jt = new Token<JobTokenIdentifier>(
        "identifier".getBytes(), "password".getBytes(), new Text(user),
        new Text("shuffleService"));
    jt.write(outputBuffer);
    shuffle.initializeApplication(new ApplicationInitializationContext(user,
        appId, ByteBuffer.wrap(outputBuffer.getData(), 0,
          outputBuffer.getLength())));

    // verify we are authorized to shuffle
    int rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_OK, rc);

    // emulate shuffle handler restart
    shuffle.close();
    shuffle = new ShuffleHandler();
    shuffle.setRecoveryPath(new Path(tmpDir.toString()));
    shuffle.init(conf);
    shuffle.start();

    // verify we are still authorized to shuffle to the old application
    rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_OK, rc);

    // shutdown app and verify access is lost
    shuffle.stopApplication(new ApplicationTerminationContext(appId));
    rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, rc);

    // emulate shuffle handler restart
    shuffle.close();
    shuffle = new ShuffleHandler();
    shuffle.setRecoveryPath(new Path(tmpDir.toString()));
    shuffle.init(conf);
    shuffle.start();

    // verify we still don't have access
    rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, rc);
  } finally {
    if (shuffle != null) {
      shuffle.close();
    }
    FileUtil.fullyDelete(tmpDir);
  }
}
 
Example #15
Source File: TestShuffleProvider.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public void stopApplication(ApplicationTerminationContext context) {
}
 
Example #16
Source File: TestShuffleProvider.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public void stopApplication(ApplicationTerminationContext context) {
}
 
Example #17
Source File: TestAuxServices.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public void stopApplication(ApplicationTerminationContext stopAppContext) {
}