Exemplo n.º 1
1
 /**
  * JobTracker.submitJob() kicks off a new job.
  *
  * <p>Create a 'JobInProgress' object, which contains both JobProfile and JobStatus. Those two
  * sub-objects are sometimes shipped outside of the JobTracker. But JobInProgress adds info that's
  * useful for the JobTracker alone.
  *
  * <p>We add the JIP to the jobInitQueue, which is processed asynchronously to handle
  * split-computation and build up the right TaskTracker/Block mapping.
  */
 public synchronized JobStatus submitJob(String jobFile) throws IOException {
   totalSubmissions++;
   JobInProgress job = new JobInProgress(jobFile, this, this.conf);
   synchronized (jobs) {
     synchronized (jobsByArrival) {
       synchronized (jobInitQueue) {
         jobs.put(job.getProfile().getJobId(), job);
         jobsByArrival.add(job);
         jobInitQueue.add(job);
         jobInitQueue.notifyAll();
       }
     }
   }
   return job.getStatus();
 }
Exemplo n.º 2
0
  ///////////////////////////////////////////////////////
  // Maintain lookup tables; called by JobInProgress
  // and TaskInProgress
  ///////////////////////////////////////////////////////
  void createTaskEntry(String taskid, String taskTracker, TaskInProgress tip) {
    LOG.info(
        "Adding task '"
            + taskid
            + "' to tip "
            + tip.getTIPId()
            + ", for tracker '"
            + taskTracker
            + "'");

    // taskid --> tracker
    taskidToTrackerMap.put(taskid, taskTracker);

    // tracker --> taskid
    TreeSet taskset = (TreeSet) trackerToTaskMap.get(taskTracker);
    if (taskset == null) {
      taskset = new TreeSet();
      trackerToTaskMap.put(taskTracker, taskset);
    }
    taskset.add(taskid);

    // taskid --> TIP
    taskidToTIPMap.put(taskid, tip);
  }
Exemplo n.º 3
0
 /**
  * Update the last recorded status for the given task tracker. It assumes that the taskTrackers
  * are locked on entry.
  *
  * @author Owen O'Malley
  * @param trackerName The name of the tracker
  * @param status The new status for the task tracker
  * @return Was an old status found?
  */
 private boolean updateTaskTrackerStatus(String trackerName, TaskTrackerStatus status) {
   TaskTrackerStatus oldStatus = (TaskTrackerStatus) taskTrackers.get(trackerName);
   if (oldStatus != null) {
     totalMaps -= oldStatus.countMapTasks();
     totalReduces -= oldStatus.countReduceTasks();
     if (status == null) {
       taskTrackers.remove(trackerName);
     }
   }
   if (status != null) {
     totalMaps += status.countMapTasks();
     totalReduces += status.countReduceTasks();
     taskTrackers.put(trackerName, status);
   }
   return oldStatus != null;
 }
  // Used for debugging in main.
  private static void printDataMap(Map map) throws Exception {
    TreeMap res = new TreeMap(map);
    Iterator key_itr = map.keySet().iterator();
    while (key_itr.hasNext()) {
      Object key = key_itr.next();
      Object val = map.get(key);
      if (val instanceof byte[]) {
        String as_bytes = ByteFormatter.nicePrint((byte[]) val);
        String as_text = new String((byte[]) val, Constants.BYTE_ENCODING);
        res.put(key, as_text + " [" + as_bytes + "]");
      }
    }

    Iterator entries = res.entrySet().iterator();
    Map.Entry entry;
    while (entries.hasNext()) {
      entry = (Map.Entry) entries.next();
      System.out.print("  ");
      System.out.print(entry.getKey());
      System.out.print(": ");
      System.out.print(entry.getValue());
      System.out.println();
    }
  }
Exemplo n.º 5
0
  /**
   * Process an HTML get or post.
   *
   * @exception ServletException From inherited class.
   * @exception IOException From inherited class.
   */
  public void scanOutXML(
      PrintWriter out,
      String strDirectory,
      String strFilename,
      String[] strPlus,
      String[] strMinus,
      boolean bExcludeParams,
      boolean bAnalyzeParams)
      throws IOException {
    File dir = new File(strDirectory + '/' + strFilename);
    if (dir.isDirectory()) return;

    try {
      FileReader is = new FileReader(strDirectory + '/' + strFilename);
      BufferedReader r = new BufferedReader(is);
      String string = null;
      Hashtable ht = new Hashtable();
      Set setstrExtensions = new HashSet();
      int iCount = 0;
      int iBytes = 0;
      while ((string = r.readLine()) != null) {
        StringTokenizer st = new StringTokenizer(string, " \"", false);
        Data data = new Data();
        int iTokenCount = 0;
        while (st.hasMoreTokens()) {
          iTokenCount++;
          string = st.nextToken();
          if (iTokenCount == IP) data.m_IP = string;
          if (iTokenCount == URL) {
            if (bExcludeParams)
              if (string.indexOf('?') != -1) string = string.substring(0, string.indexOf('?'));
            if (bAnalyzeParams)
              if (string.indexOf('?') != -1) string = string.substring(string.indexOf('?') + 1);
            data.m_URL = string;
          }
          if (iTokenCount == PROTOCOL)
            if (!string.startsWith("HTTP")) {
              data.m_URL += " " + string;
              iTokenCount--;
            }
          if (iTokenCount == BYTES) data.m_iBytes = Integer.parseInt(string);
        }
        if (!this.filterURL(data.m_URL, strPlus, strMinus, setstrExtensions)) continue;
        iCount++;
        iBytes += data.m_iBytes;
        if (ht.get(data.m_URL) == null) ht.put(data.m_URL, data);
        else {
          int iThisBytes = data.m_iBytes;
          data = (Data) ht.get(data.m_URL);
          data.m_iCount++;
          data.m_iBytes += iThisBytes;
        }
      }
      Comparator comparator = new Test();
      TreeMap tm = new TreeMap(comparator);
      Iterator iterator = ht.values().iterator();
      while (iterator.hasNext()) {
        Data data = (Data) iterator.next();
        tm.put(new Integer(data.m_iCount), data);
      }
      out.println("<file>");
      this.printXML(out, "directory", strDirectory);
      this.printXML(out, "name", strFilename);
      iterator = tm.values().iterator();
      while (iterator.hasNext()) {
        out.println("<data>");
        Data data = (Data) iterator.next();
        this.printXML(out, "url", data.m_URL);
        this.printXML(out, "count", Integer.toString(data.m_iCount));
        out.println("</data>");
      }
      this.printXML(out, "hits", Integer.toString(iCount));
      this.printXML(out, "bytes", Integer.toString(iBytes));
      this.printXML(out, "unique", Integer.toString(tm.size()));

      iterator = setstrExtensions.iterator();
      out.println("<extensions>");
      while (iterator.hasNext()) {
        this.printXML(out, "extension", (String) iterator.next());
      }
      out.println("</extensions>");

      out.println("</file>");
    } catch (FileNotFoundException ex) {
      ex.printStackTrace();
    } catch (IOException ex) {
      ex.printStackTrace();
    }
  }