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


Java AMSimulator类代码示例

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


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

示例1: SLSRunner

import org.apache.hadoop.yarn.sls.appmaster.AMSimulator; //导入依赖的package包/类
public SLSRunner(boolean isSLS, String inputTraces[], String nodeFile,
                 String outputDir, Set<String> trackedApps,
                 boolean printsimulation)
        throws IOException, ClassNotFoundException {
  this.isSLS = isSLS;
  this.inputTraces = inputTraces.clone();
  this.nodeFile = nodeFile;
  this.trackedApps = trackedApps;
  this.printSimulation = printsimulation;
  metricsOutputDir = outputDir;
  
  nmMap = new HashMap<NodeId, NMSimulator>();
  queueAppNumMap = new HashMap<String, Integer>();
  amMap = new HashMap<String, AMSimulator>();
  amClassMap = new HashMap<String, Class>();
  
  // runner configuration
  conf = new Configuration(false);
  conf.addResource("sls-runner.xml");
  // runner
  int poolSize = conf.getInt(SLSConfiguration.RUNNER_POOL_SIZE, 
                              SLSConfiguration.RUNNER_POOL_SIZE_DEFAULT); 
  SLSRunner.runner.setQueueSize(poolSize);
  // <AMType, Class> map
  for (Map.Entry e : conf) {
    String key = e.getKey().toString();
    if (key.startsWith(SLSConfiguration.AM_TYPE)) {
      String amType = key.substring(SLSConfiguration.AM_TYPE.length());
      amClassMap.put(amType, Class.forName(conf.get(key)));
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:33,代码来源: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 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

示例3: printSimulationInfo

import org.apache.hadoop.yarn.sls.appmaster.AMSimulator; //导入依赖的package包/类
private void printSimulationInfo() {
  if (printSimulation) {
    // node
    LOG.info("------------------------------------");
    LOG.info(MessageFormat.format("# nodes = {0}, # racks = {1}, capacity " +
            "of each node {2} MB memory and {3} vcores.",
            numNMs, numRacks, nmMemoryMB, nmVCores));
    LOG.info("------------------------------------");
    // job
    LOG.info(MessageFormat.format("# applications = {0}, # total " +
            "tasks = {1}, average # tasks per application = {2}",
            numAMs, numTasks, (int)(Math.ceil((numTasks + 0.0) / numAMs))));
    LOG.info("JobId\tQueue\tAMType\tDuration\t#Tasks");
    for (Map.Entry<String, AMSimulator> entry : amMap.entrySet()) {
      AMSimulator am = entry.getValue();
      LOG.info(entry.getKey() + "\t" + am.getQueue() + "\t" + am.getAMType() 
          + "\t" + am.getDuration() + "\t" + am.getNumTasks());
    }
    LOG.info("------------------------------------");
    // queue
    LOG.info(MessageFormat.format("number of queues = {0}  average " +
            "number of apps = {1}", queueAppNumMap.size(),
            (int)(Math.ceil((numAMs + 0.0) / queueAppNumMap.size()))));
    LOG.info("------------------------------------");
    // runtime
    LOG.info(MessageFormat.format("estimated simulation time is {0}" +
            " seconds", (long)(Math.ceil(maxRuntime / 1000.0))));
    LOG.info("------------------------------------");
  }
  // package these information in the simulateInfoMap used by other places
  simulateInfoMap.put("Number of racks", numRacks);
  simulateInfoMap.put("Number of nodes", numNMs);
  simulateInfoMap.put("Node memory (MB)", nmMemoryMB);
  simulateInfoMap.put("Node VCores", nmVCores);
  simulateInfoMap.put("Number of applications", numAMs);
  simulateInfoMap.put("Number of tasks", numTasks);
  simulateInfoMap.put("Average tasks per applicaion",
          (int)(Math.ceil((numTasks + 0.0) / numAMs)));
  simulateInfoMap.put("Number of queues", queueAppNumMap.size());
  simulateInfoMap.put("Average applications per queue",
          (int)(Math.ceil((numAMs + 0.0) / queueAppNumMap.size())));
  simulateInfoMap.put("Estimated simulate time (s)",
          (long)(Math.ceil(maxRuntime / 1000.0)));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:45,代码来源:SLSRunner.java

示例4: 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类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。