@@ -0,0 +1,3151 @@
+package tachyon.perf.basic;%0A%0Aimport java.io.File;%0Aimport java.util.HashMap;%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.SAXConfiguration;%0A%0A/**%0A * Manage the configurations for each task.%0A */%0Apublic class TaskConfiguration %7B%0A  public static final boolean DEFAULT_BOOLEAN = false;%0A  public static final int DEFAULT_INTEGER = 0;%0A  public static final long DEFAULT_LONG = 0;%0A  public static final String DEFAULT_STRING = %22%22;%0A  private static final Logger LOG = Logger.getLogger(%22%22);%0A%0A  private static TaskConfiguration sTaskConf = null;%0A%0A  /**%0A   * Get the configuration.%0A   * %0A   * @param type the type of the benchmark task%0A   * @param fromFile if true, it will load the configuration file, otherwise it return an empty%0A   *        configuration.%0A   * @return the task configuration%0A   */%0A  public static synchronized TaskConfiguration get(String type, boolean fromFile) %7B%0A    if (sTaskConf == null) %7B%0A      if (fromFile) %7B%0A        try %7B%0A          sTaskConf =%0A              new TaskConfiguration(PerfConf.get().TACHYON_PERF_HOME + %22/conf/testSuite/%22 + type%0A                  + %22.xml%22);%0A        %7D catch (Exception e) %7B%0A          LOG.error(%22Error when parse conf/testSuite/%22 + type + %22.xml%22, e);%0A          throw new RuntimeException(%22Failed to parse conf/testSuite/%22 + type + %22.xml%22);%0A        %7D%0A      %7D else %7B%0A        sTaskConf = new TaskConfiguration();%0A      %7D%0A    %7D%0A    return sTaskConf;%0A  %7D%0A%0A  private Map%3CString, String%3E mProperties;%0A%0A  protected TaskConfiguration() %7B%0A    mProperties = new HashMap%3CString, String%3E();%0A  %7D%0A%0A  protected TaskConfiguration(String xmlFileName) throws Exception %7B%0A    SAXParserFactory spf = SAXParserFactory.newInstance();%0A    SAXParser saxParser = spf.newSAXParser();%0A    File xmlFile = new File(xmlFileName);%0A    SAXConfiguration saxConfiguration = new SAXConfiguration();%0A    saxParser.parse(xmlFile, saxConfiguration);%0A    mProperties = saxConfiguration.getProperties();%0A  %7D%0A%0A  public synchronized void addProperty(String name, String value) %7B%0A    mProperties.put(name, value);%0A  %7D%0A%0A  public synchronized Map%3CString, String%3E getAllProperties() %7B%0A    Map%3CString, String%3E ret = new HashMap%3CString, String%3E(mProperties.size());%0A    ret.putAll(mProperties);%0A    return ret;%0A  %7D%0A%0A  public synchronized boolean getBooleanProperty(String property) %7B%0A    if (mProperties.containsKey(property)) %7B%0A      return Boolean.valueOf(mProperties.get(property));%0A    %7D%0A    return DEFAULT_BOOLEAN;%0A  %7D%0A%0A  public synchronized int getIntProperty(String property) %7B%0A    if (mProperties.containsKey(property)) %7B%0A      return Integer.valueOf(mProperties.get(property));%0A    %7D%0A    return DEFAULT_INTEGER;%0A  %7D%0A%0A  public synchronized long getLongProperty(String property) %7B%0A    if (mProperties.containsKey(property)) %7B%0A      return Long.valueOf(mProperties.get(property));%0A    %7D%0A    return DEFAULT_LONG;%0A  %7D%0A%0A  public synchronized String getProperty(String property) %7B%0A    if (mProperties.containsKey(property)) %7B%0A      return mProperties.get(property);%0A    %7D%0A    return DEFAULT_STRING;%0A  %7D%0A%7D%0A

Manage the configurations for each task