ApplictionId的生成

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhusirong/article/details/84341650

ApplictionId的生成

ApplicationId主要包括两部分:clusterTimestamp和id.
是在客户端提交应用程序前,随着rpc方法getNewJobID获取jobId时生成的.而JobID只是applicationId的简单包装.

其中clusterTimestamp是ResourceManager的启动时间.而id是一个递增的整数类型.
clusterTimestamp是ResourceManager的启动时间:

void ResourceManager.startActiveServices() throws Exception {
    if (activeServices != null) {
      clusterTimeStamp = System.currentTimeMillis();
      activeServices.start();
    }
  }

id是一个递增的整数类型:

ApplicationId getNewApplicationId() {
    ApplicationId applicationId = org.apache.hadoop.yarn.server.utils.BuilderUtils
        .newApplicationId(recordFactory, ResourceManager.getClusterTimeStamp(),
            applicationCounter.incrementAndGet());
    LOG.info("Allocated new applicationId: " + applicationId.getId());
    return applicationId;
  }

JobID是applicationID的简单包装:

 public JobID getNewJobID() throws IOException, InterruptedException {
    try {
      this.application = client.createApplication().getApplicationSubmissionContext();
      this.applicationId = this.application.getApplicationId();
      return TypeConverter.fromYarn(applicationId);
    } catch (YarnException e) {
      throw new IOException(e);
    }
  }
public static org.apache.hadoop.mapreduce.JobID fromYarn(ApplicationId appID) {
    String identifier = fromClusterTimeStamp(appID.getClusterTimestamp());
    return new org.apache.hadoop.mapred.JobID(identifier, appID.getId());
  }

猜你喜欢

转载自blog.csdn.net/zhusirong/article/details/84341650
今日推荐