Esempio n. 1
0
  /**
   * Build an XML element with the task profile information
   *
   * @param taskProfile the task profile
   * @param doc the XML document
   * @param name the name of the element
   * @return the XML element
   */
  private Element buildTaskProfileElement(MRTaskProfile taskProfile, Document doc, String name) {

    // Add the task attributes
    Element task = doc.createElement(name);
    task.setAttribute(ID, taskProfile.getTaskId());
    task.setAttribute(NUM_TASKS, Integer.toString(taskProfile.getNumTasks()));

    // Add the task enum maps
    task.appendChild(buildEnumMapElement(taskProfile.getCounters(), doc, COUNTERS, COUNTER));
    task.appendChild(buildEnumMapElement(taskProfile.getStatistics(), doc, STATS, STAT));
    task.appendChild(buildEnumMapElement(taskProfile.getCostFactors(), doc, FACTORS, FACTOR));
    task.appendChild(buildEnumMapElement(taskProfile.getTimings(), doc, TIMINGS, TIMING));

    // Add the task auxiliary counters map
    if (taskProfile.containsAuxCounters()) {
      Element counters = doc.createElement(AUX_COUNTERS);
      for (Entry<String, Long> e : taskProfile.getAuxCounters().entrySet()) {
        Element counter = doc.createElement(AUX_COUNTER);
        counters.appendChild(counter);
        counter.setAttribute(KEY, e.getKey());
        counter.setAttribute(VALUE, e.getValue().toString());
      }
      task.appendChild(counters);
    }

    return task;
  }