當前位置: 首頁>>代碼示例>>Java>>正文


Java SimulatorJobClient類代碼示例

本文整理匯總了Java中org.apache.hadoop.mapred.SimulatorJobClient的典型用法代碼示例。如果您正苦於以下問題:Java SimulatorJobClient類的具體用法?Java SimulatorJobClient怎麽用?Java SimulatorJobClient使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SimulatorJobClient類屬於org.apache.hadoop.mapred包,在下文中一共展示了SimulatorJobClient類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import org.apache.hadoop.mapred.SimulatorJobClient; //導入依賴的package包/類
/**
 * Initiate components in the simulation.
 * @throws InterruptedException
 * @throws IOException if trace or topology files cannot be open
 */
@SuppressWarnings("deprecation")
void init() throws InterruptedException, IOException {
  long now = System.currentTimeMillis();

  JobConf jobConf = new JobConf(getConf());
  jobConf.setClass("topology.node.switch.mapping.impl",
      StaticMapping.class, DNSToSwitchMapping.class);
  jobConf.set("fs.default.name", "file:///");
  jobConf.set("mapred.job.tracker", "localhost:8012");
  jobConf.setInt("mapred.jobtracker.job.history.block.size", 512);
  jobConf.setInt("mapred.jobtracker.job.history.buffer.size", 512);
  jobConf.setLong("mapred.tasktracker.expiry.interval", 5000);
  jobConf.setInt("mapred.reduce.copy.backoff", 4);
  jobConf.setLong("mapred.job.reuse.jvm.num.tasks", -1);
  jobConf.setUser("mumak");
  jobConf.set("mapred.system.dir", 
      jobConf.get("hadoop.log.dir", "/tmp/hadoop-"+jobConf.getUser()) + "/mapred/system");
  jobConf.set("mapred.jobtracker.taskScheduler", JobQueueTaskScheduler.class.getName());
  
  FileSystem lfs = FileSystem.getLocal(getConf());
  Path logPath =
    new Path(System.getProperty("hadoop.log.dir")).makeQualified(lfs);
  jobConf.set("mapred.system.dir", logPath.toString());
  jobConf.set("hadoop.job.history.location", (new Path(logPath, "history")
      .toString()));
  
  jt = SimulatorJobTracker.startTracker(jobConf, now, this);
  jt.offerService();
  
  // max Map/Reduce tasks per node
  int maxMaps = getConf().getInt("mapred.tasktracker.map.tasks.maximum",
      DEFAULT_MAP_SLOTS_PER_NODE);
  int maxReduces = getConf().getInt(
      "mapred.tasktracker.reduce.tasks.maximum",
      DEFAULT_REDUCE_SLOTS_PER_NODE);

  MachineNode defaultNode = new MachineNode.Builder("default", 2)
      .setMapSlots(maxMaps).setReduceSlots(maxReduces).build();
  ZombieCluster cluster = new ZombieCluster(new Path(topologyFile), 
      defaultNode, jobConf);
  long firstJobStartTime = now + 60000;
  JobStoryProducer jobStoryProducer = new SimulatorJobStoryProducer(
      new Path(traceFile), cluster, firstJobStartTime, jobConf);
  
  jc = new SimulatorJobClient(jt, jobStoryProducer);
  queue.addAll(jc.init(firstJobStartTime));

  // create TTs based on topology.json     
  startTaskTrackers(cluster, now);
  
  terminateTime = getConf().getLong("mumak.terminate.time", Long.MAX_VALUE);
  if (terminateTime <= 0) {
    throw new IllegalArgumentException("Terminate time must be positive: "
        + terminateTime);
  }
}
 
開發者ID:rhli,項目名稱:hadoop-EAR,代碼行數:62,代碼來源:SimulatorEngine.java

示例2: init

import org.apache.hadoop.mapred.SimulatorJobClient; //導入依賴的package包/類
/**
 * Initiate components in the simulation. The JobConf is
 * create separately and passed to the init().
 * @param JobConf: The configuration for the jobtracker.
 * @throws InterruptedException
 * @throws IOException if trace or topology files cannot be opened.
 */
@SuppressWarnings("deprecation")
void init(JobConf jobConf) throws InterruptedException, IOException {
  
  FileSystem lfs = FileSystem.getLocal(getConf());
  Path logPath =
    new Path(System.getProperty("hadoop.log.dir")).makeQualified(lfs);
  jobConf.set("mapred.system.dir", logPath.toString());
  jobConf.set("hadoop.job.history.location", (new Path(logPath, "history")
      .toString()));
  
  // start time for virtual clock
  // possible improvement: set default value to sth more meaningful based on
  // the 1st job
  long now = getTimeProperty(jobConf, "mumak.start.time", 
                             System.currentTimeMillis());

  jt = SimulatorJobTracker.startTracker(jobConf, now, this);
  jt.offerService();
  
  masterRandomSeed = jobConf.getLong("mumak.random.seed", System.nanoTime()); 
  
  // max Map/Reduce tasks per node
  int maxMaps = getConf().getInt(
      "mapred.tasktracker.map.tasks.maximum",
      SimulatorTaskTracker.DEFAULT_MAP_SLOTS);
  int maxReduces = getConf().getInt(
      "mapred.tasktracker.reduce.tasks.maximum",
  
    SimulatorTaskTracker.DEFAULT_REDUCE_SLOTS);

  MachineNode defaultNode = new MachineNode.Builder("default", 2)
      .setMapSlots(maxMaps).setReduceSlots(maxReduces).build();
          
  LoggedNetworkTopology topology = new ClusterTopologyReader(new Path(
      topologyFile), jobConf).get();
  // Setting the static mapping before removing numeric IP hosts.
  setStaticMapping(topology);
  if (getConf().getBoolean("mumak.topology.filter-numeric-ips", true)) {
    removeIpHosts(topology);
  }
  ZombieCluster cluster = new ZombieCluster(topology, defaultNode);
  
  // create TTs based on topology.json  
  long firstJobStartTime = startTaskTrackers(cluster, jobConf, now);

  long subRandomSeed = RandomSeedGenerator.getSeed("forSimulatorJobStoryProducer",
                                                   masterRandomSeed);
  JobStoryProducer jobStoryProducer = new SimulatorJobStoryProducer(
      new Path(traceFile), cluster, firstJobStartTime, jobConf, subRandomSeed);

  final SimulatorJobSubmissionPolicy submissionPolicy = SimulatorJobSubmissionPolicy
      .getPolicy(jobConf);

  jc = new SimulatorJobClient(jt, jobStoryProducer, submissionPolicy);
  queue.addAll(jc.init(firstJobStartTime));

  //if the taskScheduler is CapacityTaskScheduler start off the JobInitialization
  //threads too
  if (jobConf.get("mapred.jobtracker.taskScheduler").equals
     (CapacityTaskScheduler.class.getName())) {
    LOG.info("CapacityScheduler used: starting simulatorThreads");
    startSimulatorThreadsCapSched(now);
  }
  terminateTime = getTimeProperty(jobConf, "mumak.terminate.time",
                                  Long.MAX_VALUE);
}
 
開發者ID:rekhajoshm,項目名稱:mapreduce-fork,代碼行數:74,代碼來源:SimulatorEngine.java


注:本文中的org.apache.hadoop.mapred.SimulatorJobClient類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。