@@ -0,0 +1,3246 @@
+package tachyon.perf.basic;%0A%0Aimport java.io.File;%0Aimport java.util.Map;%0A%0Aimport javax.xml.parsers.SAXParser;%0Aimport javax.xml.parsers.SAXParserFactory;%0A%0Aimport org.apache.log4j.Logger;%0A%0Aimport tachyon.perf.conf.PerfConf;%0Aimport tachyon.perf.util.SAXTaskType;%0A%0A/**%0A * Manage the different type of tasks.%0A */%0Apublic class TaskType %7B%0A  private static final Logger LOG = Logger.getLogger(%22%22);%0A%0A  private static TaskType sTaskType = null;%0A%0A  public static synchronized TaskType get() %7B%0A    if (sTaskType == null) %7B%0A      try %7B%0A        sTaskType = new TaskType(PerfConf.get().TACHYON_PERF_HOME + %22/conf/task-type.xml%22);%0A      %7D catch (Exception e) %7B%0A        LOG.error(%22Error when parse conf/task-type.xml%22, e);%0A        throw new RuntimeException(%22Failed to parse conf/task-type.xml%22);%0A      %7D%0A    %7D%0A    return sTaskType;%0A  %7D%0A%0A  private Map%3CString, String%3E mTaskClasses;%0A  private Map%3CString, String%3E mTaskContextClasses;%0A  private Map%3CString, String%3E mTaskThreadClasses;%0A  private Map%3CString, String%3E mTotalReportClasses;%0A%0A  private TaskType(String xmlFileName) throws Exception %7B%0A    SAXParserFactory spf = SAXParserFactory.newInstance();%0A    SAXParser saxParser = spf.newSAXParser();%0A    File xmlFile = new File(xmlFileName);%0A    SAXTaskType saxTaskType = new SAXTaskType();%0A    saxParser.parse(xmlFile, saxTaskType);%0A    mTaskClasses = saxTaskType.getTaskClasses();%0A    mTaskContextClasses = saxTaskType.getTaskContextClasses();%0A    mTaskThreadClasses = saxTaskType.getTaskThreadClasses();%0A    mTotalReportClasses = saxTaskType.getTotalReportClasses();%0A  %7D%0A%0A  /**%0A   * Get the task class of specified task. The class should be a subclass of PerfTask.%0A   * %0A   * @param type the type of the task%0A   * @return the task class%0A   * @throws Exception%0A   */%0A  public PerfTask getTaskClass(String type) throws Exception %7B%0A    String taskClassName = mTaskClasses.get(type);%0A    return (PerfTask) Class.forName(taskClassName).newInstance();%0A  %7D%0A%0A  /**%0A   * Get the task context class of specified task. The class should be a subclass of TaskContext.%0A   * %0A   * @param type the type of the task%0A   * @return the task context class%0A   * @throws Exception%0A   */%0A  public PerfTaskContext getTaskContextClass(String type) throws Exception %7B%0A    String taskContextClassName = mTaskContextClasses.get(type);%0A    return (PerfTaskContext) Class.forName(taskContextClassName).newInstance();%0A  %7D%0A%0A  /**%0A   * Get the task thread class of specified task. The class should be a subclass of PerfThread.%0A   * %0A   * @param type the type of the task%0A   * @return the task thread class%0A   * @throws Exception%0A   */%0A  public PerfThread getTaskThreadClass(String type) throws Exception %7B%0A    String taskThreadClassName = mTaskThreadClasses.get(type);%0A    return (PerfThread) Class.forName(taskThreadClassName).newInstance();%0A  %7D%0A%0A  /**%0A   * Get the task total report of specified task. The class should be a subclass of PerfTotalReport.%0A   * %0A   * @param type the type of the task%0A   * @return the task total report class%0A   * @throws Exception%0A   */%0A  public PerfTotalReport getTotalReportClass(String type) throws Exception %7B%0A    String totalReportClassName = mTotalReportClasses.get(type);%0A    return (PerfTotalReport) Class.forName(totalReportClassName).newInstance();%0A  %7D%0A%7D%0A

Manage the different type of tasks