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


Java AMSimulator.init方法代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.sls.appmaster.AMSimulator.init方法的典型用法代码示例。如果您正苦于以下问题:Java AMSimulator.init方法的具体用法?Java AMSimulator.init怎么用?Java AMSimulator.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.yarn.sls.appmaster.AMSimulator的用法示例。


在下文中一共展示了AMSimulator.init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startAMFromSLSTraces

import org.apache.hadoop.yarn.sls.appmaster.AMSimulator; //导入方法依赖的package包/类
/**
 * parse workload information from sls trace files
 */
@SuppressWarnings("unchecked")
private void startAMFromSLSTraces(Resource containerResource,
                                  int heartbeatInterval) throws IOException {
  // parse from sls traces
  JsonFactory jsonF = new JsonFactory();
  ObjectMapper mapper = new ObjectMapper();
  for (String inputTrace : inputTraces) {
    Reader input = new FileReader(inputTrace);
    try {
      Iterator<Map> i = mapper.readValues(jsonF.createJsonParser(input),
              Map.class);
      while (i.hasNext()) {
        Map jsonJob = i.next();

        // load job information
        long jobStartTime = Long.parseLong(
                jsonJob.get("job.start.ms").toString());
        long jobFinishTime = Long.parseLong(
                jsonJob.get("job.end.ms").toString());

        String user = (String) jsonJob.get("job.user");
        if (user == null)  user = "default";
        String queue = jsonJob.get("job.queue.name").toString();

        String oldAppId = jsonJob.get("job.id").toString();
        boolean isTracked = trackedApps.contains(oldAppId);
        int queueSize = queueAppNumMap.containsKey(queue) ?
                queueAppNumMap.get(queue) : 0;
        queueSize ++;
        queueAppNumMap.put(queue, queueSize);
        // tasks
        List tasks = (List) jsonJob.get("job.tasks");
        if (tasks == null || tasks.size() == 0) {
          continue;
        }
        List<ContainerSimulator> containerList =
                new ArrayList<ContainerSimulator>();
        for (Object o : tasks) {
          Map jsonTask = (Map) o;
          String hostname = jsonTask.get("container.host").toString();
          long taskStart = Long.parseLong(
                  jsonTask.get("container.start.ms").toString());
          long taskFinish = Long.parseLong(
                  jsonTask.get("container.end.ms").toString());
          long lifeTime = taskFinish - taskStart;
          int priority = Integer.parseInt(
                  jsonTask.get("container.priority").toString());
          String type = jsonTask.get("container.type").toString();
          containerList.add(new ContainerSimulator(containerResource,
                  lifeTime, hostname, priority, type));
        }

        // create a new AM
        String amType = jsonJob.get("am.type").toString();
        AMSimulator amSim = (AMSimulator) ReflectionUtils.newInstance(
                amClassMap.get(amType), new Configuration());
        if (amSim != null) {
          amSim.init(AM_ID++, heartbeatInterval, containerList, rm,
                  this, jobStartTime, jobFinishTime, user, queue,
                  isTracked, oldAppId);
          runner.schedule(amSim);
          maxRuntime = Math.max(maxRuntime, jobFinishTime);
          numTasks += containerList.size();
          amMap.put(oldAppId, amSim);
        }
      }
    } finally {
      input.close();
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:75,代码来源:SLSRunner.java

示例2: startAMFromSLSTraces

import org.apache.hadoop.yarn.sls.appmaster.AMSimulator; //导入方法依赖的package包/类
/**
 * parse workload information from sls trace files
 */
@SuppressWarnings("unchecked")
private void startAMFromSLSTraces(Resource containerResource,
                                  int heartbeatInterval) throws IOException {
  // parse from sls traces
  JsonFactory jsonF = new JsonFactory();
  ObjectMapper mapper = new ObjectMapper();
  for (String inputTrace : inputTraces) {
    Reader input =
        new InputStreamReader(new FileInputStream(inputTrace), "UTF-8");
    try {
      Iterator<Map> i = mapper.readValues(jsonF.createJsonParser(input),
              Map.class);
      while (i.hasNext()) {
        Map jsonJob = i.next();

        // load job information
        long jobStartTime = Long.parseLong(
                jsonJob.get("job.start.ms").toString());
        long jobFinishTime = Long.parseLong(
                jsonJob.get("job.end.ms").toString());

        String user = (String) jsonJob.get("job.user");
        if (user == null)  user = "default";
        String queue = jsonJob.get("job.queue.name").toString();

        String oldAppId = jsonJob.get("job.id").toString();
        boolean isTracked = trackedApps.contains(oldAppId);
        int queueSize = queueAppNumMap.containsKey(queue) ?
                queueAppNumMap.get(queue) : 0;
        queueSize ++;
        queueAppNumMap.put(queue, queueSize);
        // tasks
        List tasks = (List) jsonJob.get("job.tasks");
        if (tasks == null || tasks.size() == 0) {
          continue;
        }
        List<ContainerSimulator> containerList =
                new ArrayList<ContainerSimulator>();
        for (Object o : tasks) {
          Map jsonTask = (Map) o;
          String hostname = jsonTask.get("container.host").toString();
          long taskStart = Long.parseLong(
                  jsonTask.get("container.start.ms").toString());
          long taskFinish = Long.parseLong(
                  jsonTask.get("container.end.ms").toString());
          long lifeTime = taskFinish - taskStart;
          int priority = Integer.parseInt(
                  jsonTask.get("container.priority").toString());
          String type = jsonTask.get("container.type").toString();
          containerList.add(new ContainerSimulator(containerResource,
                  lifeTime, hostname, priority, type));
        }

        // create a new AM
        String amType = jsonJob.get("am.type").toString();
        AMSimulator amSim = (AMSimulator) ReflectionUtils.newInstance(
                amClassMap.get(amType), new Configuration());
        if (amSim != null) {
          amSim.init(AM_ID++, heartbeatInterval, containerList, rm,
                  this, jobStartTime, jobFinishTime, user, queue,
                  isTracked, oldAppId);
          runner.schedule(amSim);
          maxRuntime = Math.max(maxRuntime, jobFinishTime);
          numTasks += containerList.size();
          amMap.put(oldAppId, amSim);
        }
      }
    } finally {
      input.close();
    }
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:76,代码来源:SLSRunner.java


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