当前位置: 首页>>代码示例>>Java>>正文


Java ApplicationInitializationContext类代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.server.api.ApplicationInitializationContext的典型用法代码示例。如果您正苦于以下问题:Java ApplicationInitializationContext类的具体用法?Java ApplicationInitializationContext怎么用?Java ApplicationInitializationContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ApplicationInitializationContext类属于org.apache.hadoop.yarn.server.api包,在下文中一共展示了ApplicationInitializationContext类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initializeApplication

import org.apache.hadoop.yarn.server.api.ApplicationInitializationContext; //导入依赖的package包/类
@Override
public void initializeApplication(ApplicationInitializationContext context) {

  String user = context.getUser();
  ApplicationId appId = context.getApplicationId();
  ByteBuffer secret = context.getApplicationDataForService();
  // TODO these bytes should be versioned
  try {
    Token<JobTokenIdentifier> jt = deserializeServiceData(secret);
     // TODO: Once SHuffle is out of NM, this can use MR APIs
    JobID jobId = new JobID(Long.toString(appId.getClusterTimestamp()), appId.getId());
    recordJobShuffleInfo(jobId, user, jt);
  } catch (IOException e) {
    LOG.error("Error during initApp", e);
    // TODO add API to AuxiliaryServices to report failures
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:ShuffleHandler.java

示例2: handle

import org.apache.hadoop.yarn.server.api.ApplicationInitializationContext; //导入依赖的package包/类
@Override
public void handle(AuxServicesEvent event) {
  LOG.info("Got event " + event.getType() + " for appId "
      + event.getApplicationID());
  switch (event.getType()) {
  case APPLICATION_INIT:
    LOG.info("Got APPLICATION_INIT for service " + event.getServiceID());
    AuxiliaryService service = serviceMap.get(event.getServiceID());
    if (null == service) {
      LOG.info("service is null");
      // TODO kill all containers waiting on Application
      return;
    }
    service.initializeApplication(new ApplicationInitializationContext(event
      .getUser(), event.getApplicationID(), event.getServiceData()));
    break;
  case APPLICATION_STOP:
    for (AuxiliaryService serv : serviceMap.values()) {
      serv.stopApplication(new ApplicationTerminationContext(event
        .getApplicationID()));
    }
    break;
  default:
    throw new RuntimeException("Unknown type: " + event.getType());
  }
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:27,代码来源:AuxServices.java

示例3: initializeApplication

import org.apache.hadoop.yarn.server.api.ApplicationInitializationContext; //导入依赖的package包/类
@Override
public void initializeApplication(ApplicationInitializationContext context) {

  String user = context.getUser();
  ApplicationId appId = context.getApplicationId();
  ByteBuffer secret = context.getApplicationDataForService();
  // TODO these bytes should be versioned
  try {
    Token<JobTokenIdentifier> jt = deserializeServiceData(secret);
     // TODO: Once SHuffle is out of NM, this can use MR APIs
    JobID jobId = new JobID(Long.toString(appId.getClusterTimestamp()), appId.getId());
    userRsrc.put(jobId.toString(), user);
    LOG.info("Added token for " + jobId.toString());
    secretManager.addTokenForJob(jobId.toString(), jt);
  } catch (IOException e) {
    LOG.error("Error during initApp", e);
    // TODO add API to AuxiliaryServices to report failures
  }
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:20,代码来源:ShuffleHandler.java

示例4: initializeApplication

import org.apache.hadoop.yarn.server.api.ApplicationInitializationContext; //导入依赖的package包/类
@Override
public void initializeApplication(ApplicationInitializationContext context) {

  String user = context.getUser();
  String userFolder = context.getUserFolder();
  ApplicationId appId = context.getApplicationId();
  ByteBuffer secret = context.getApplicationDataForService();
  // TODO these bytes should be versioned
  try {
    Token<JobTokenIdentifier> jt = deserializeServiceData(secret);
     // TODO: Once SHuffle is out of NM, this can use MR APIs
    JobID jobId = new JobID(Long.toString(appId.getClusterTimestamp()), appId.getId());
    recordJobShuffleInfo(jobId, user, jt, userFolder);
  } catch (IOException e) {
    LOG.error("Error during initApp", e);
    // TODO add API to AuxiliaryServices to report failures
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:19,代码来源:ShuffleHandler.java

示例5: initializeApplication

import org.apache.hadoop.yarn.server.api.ApplicationInitializationContext; //导入依赖的package包/类
@Override
public void initializeApplication(ApplicationInitializationContext context) {
  ByteBuffer data = context.getApplicationDataForService();
  assertEquals(idef, data.getChar());
  assertEquals(expected_appId, data.getInt());
  assertEquals(expected_appId, context.getApplicationId().getId());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:8,代码来源:TestAuxServices.java

示例6: initializeApplication

import org.apache.hadoop.yarn.server.api.ApplicationInitializationContext; //导入依赖的package包/类
@Override
public void initializeApplication(ApplicationInitializationContext context) {
  // TODO these bytes should be versioned
  // TODO: Once SHuffle is out of NM, this can use MR APIs
  String user = context.getUser();
  ApplicationId appId = context.getApplicationId();
  //    ByteBuffer secret = context.getApplicationDataForService();
  userRsrc.put(appId.toString(), user);
}
 
开发者ID:apache,项目名称:tajo,代码行数:10,代码来源:TajoPullServerService.java

示例7: initializeApplication

import org.apache.hadoop.yarn.server.api.ApplicationInitializationContext; //导入依赖的package包/类
@Override
public void initializeApplication(ApplicationInitializationContext appInitContext) {
  // TODO these bytes should be versioned
  // TODO: Once SHuffle is out of NM, this can use MR APIs
  this.appId = appInitContext.getApplicationId();
  this.queryId = TajoIdUtils.parseQueryId(appId.toString());
  this.userName = appInitContext.getUser();
  userRsrc.put(this.appId.toString(), this.userName);
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:10,代码来源:PullServerAuxService.java

示例8: initializeApplication

import org.apache.hadoop.yarn.server.api.ApplicationInitializationContext; //导入依赖的package包/类
@Override
public void initializeApplication(ApplicationInitializationContext context) {
}
 
开发者ID:naver,项目名称:hadoop,代码行数:4,代码来源:TestShuffleProvider.java

示例9: testRecovery

import org.apache.hadoop.yarn.server.api.ApplicationInitializationContext; //导入依赖的package包/类
@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);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:68,代码来源:TestShuffleHandler.java


注:本文中的org.apache.hadoop.yarn.server.api.ApplicationInitializationContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。