Package edu.berkeley.xtrace.reporting

Examples of edu.berkeley.xtrace.reporting.Report


    //if we have the reports in topological order, this should be easy.
    //Just take max of all predecessors seen until that point.
   
    //alternatively, could start at the end and walk backwards
    ArrayList<Report> backpath = new ArrayList<Report>();
    Report cur = reports.get(endID);
    do {
      backpath.add(cur);
     
      Report limitingPred = null;
      long latestPrereq = Long.MIN_VALUE;
     
      for(String predID: cur.get("Edge")) {
        Report pred = reports.get(predID);
        long finishTime = metric.dist(pred, cur);
        if( finishTime > latestPrereq) {
          latestPrereq = finishTime;
          limitingPred = pred;
        }
View Full Code Here


   * @return
   */
  public static long onHostTimes(List<Report> path) {
    long time =0;  
    for(int i =0; i < path.size()-1; ++i) {
      Report src = path.get(i+1);
      Report dest = path.get(i);
      List<String> srcHost = src.get("Host"), destHost = dest.get("Host");
      if(srcHost != null && srcHost.size() > 0 && destHost != null && destHost.size() > 0) {
        if(srcHost.get(0).equals(destHost.get(0))){
          long src_ts = getTS(src);
          long dest_ts = getTS(dest);
         
View Full Code Here

  //////IO utils
 
  public void slurpTextFile(File f) throws IOException {
   
    BufferedReader br = new BufferedReader(new FileReader(f));
    Report rep;
    while((rep = getNextReportFromReader(br)) != null ) {
      add(rep);
    }
  }
View Full Code Here

      Counter dupCounter = context.getCounter("app", "duplicate report");

      int edgeCount = 0, dups = 0, numReports = 0;
     
      for(Text rep_text: values) {
        Report r = Report.createFromString(rep_text.toString());
        numReports++;
       
        if(numReports < MAX_IN_MEMORY_REPORTS) {
          if(reports.containsKey(r.getMetadata().getOpIdString()))
            dups++;
          reports.put(r.getMetadata().getOpIdString(), r);
        } else if(numReports == MAX_IN_MEMORY_REPORTS) {
          //bail out, prepare to do an external sort.
          return;
        } else
          ;
    //      do the external sort
      }

      HashMap<String, Integer> counts = new HashMap<String, Integer>();
      Queue<Report> zeroInlinkReports = new LinkedList<Report>();
      reportCounter.increment(reports.size());
      dupCounter.increment(dups);
      //FIXME: could usefully compare reports.size() with numReports;
      //that would measure duplicate reports
     
      //increment link counts for children
      for(Report r: reports.values()){
        String myOpID = r.getMetadata().getOpIdString();
        int parentCount = 0;
        for(String inLink: r.get("Edge")) {
         
            //sanitize data from old, nonconformant C++ implementation
          if(inLink.contains(","))
            inLink = inLink.substring(0, inLink.indexOf(','));
         
          Report parent = reports.get(inLink);
          if(parent != null) {
            parent.put(OUTLINK_FIELD, myOpID);
            parentCount++;
            edgeCount++;
          }
          else { //no match
            if(!inLink.equals("0000000000000000"))  {
              log.info("no sign of parent: " + inLink);
              badEdgeCounter.increment(1);
            }
            //else quietly suppress
          }
        }
         
        //if there weren't any parents, we can dequeue
        if(parentCount == 0)
          zeroInlinkReports.add(r);
        else
          counts.put(myOpID, parentCount);
      }
     
      log.debug(taskIDString+": " + edgeCount + " total edges");
      edgeCounter.increment(edgeCount);
      //at this point, we have a map from metadata to report, and also
      //from report op ID to inlink count.
      //next step is to do a topological sort.

     
      Text[] finalOutput = new Text[reports.size()];
      log.debug(taskIDString+": expecting to sort " + finalOutput.length + " reports");
      int i=0;
      while(!zeroInlinkReports.isEmpty()) {
        Report r = zeroInlinkReports.poll();
        if(r == null) {
          log.warn(taskIDString+": poll returned null but list not empty. This is probably a bug"
              + " fairly deep down");
          break;
        }
        finalOutput[i++] = new Text(r.toString());
        List<String> outLinks =  r.get(OUTLINK_FIELD);
        if(outLinks != null) {
          for(String outLink: outLinks) {
            Integer oldCount = counts.get(outLink);
            if(oldCount == null) {
              oldCount = 0//FIXME: can this happen?
View Full Code Here

    XTraceMetadata meta = new XTraceMetadata(id,1);
   
    XTraceContext.setThreadContext(meta);
    //test case with no end
    XTraceEvent evt = XTraceContext.createEvent("agentStr", "labelStr");
    Report start = evt.createReport();
   
      //try it with empty report first
    reports.put(start.getMetadata().getOpIdString(), start);
    Report end = XtrIndex.findMatchingEnd(reports, start, "theThing");
    assertNull(end);

      //try again, after adding start field
    start.put("Start", "theThing");   
    reports.put(start.getMetadata().getOpIdString(), start);
    end = XtrIndex.findMatchingEnd(reports, start, "theThing");
    assertNull(end);
   
      //now add an end
    //test case with start followed immediately by end
    evt = XTraceContext.createEvent("agentStr", "labelStr2");
    evt.addEdge(start.getMetadata());
    end = evt.createReport();
    end.put("End", "theThing");
    start.put(XtrExtract.OUTLINK_FIELD, end.getMetadata().getOpIdString());
    reports.put(end.getMetadata().getOpIdString(), end);
    Report e = XtrIndex.findMatchingEnd(reports, start, "theThing");
    assertNotNull(e);
    assertTrue(e == end);//should get same report back
    //now how about a event in the middle?
   
  }
View Full Code Here

    XTraceMetadata meta = new XTraceMetadata(id,1);
   
    XTraceContext.setThreadContext(meta);
    //test case with no end
    XTraceEvent evt = XTraceContext.createEvent("agentStr", "labelStr");
    Report start = evt.createReport();
   
      //try it with empty report first
    reports.put(start.getMetadata().getOpIdString(), start);
    Text[] index = XtrIndex.indexGraph(reports);
    assertEquals(0, index.length);

      //try again, after adding start field
    start.put("Start", "theThing");   
    reports.put(start.getMetadata().getOpIdString(), start);
    index = XtrIndex.indexGraph(reports);
    assertEquals(0, index.length);

      //now add an end
    //test case with start followed immediately by end
    evt = XTraceContext.createEvent("agentStr", "labelStr2");
    evt.addEdge(start.getMetadata());
    Report end = evt.createReport();
    end.put("End", "theThing");
    start.put(XtrExtract.OUTLINK_FIELD, end.getMetadata().getOpIdString());
    reports.put(end.getMetadata().getOpIdString(), end);
    index = XtrIndex.indexGraph(reports);
    assertEquals(1, index.length);
    String s = index[0].toString();
    assertTrue(s.startsWith("theThing "));
   
View Full Code Here

    org.apache.commons.collections.MultiHashMap();
      //map from start tag to opIds of nodes containing the ends
   
   
    for(Map.Entry<String, Report> report: reports.entrySet()) {
      Report start = report.getValue();
      List<String> starts = start.get("Start");
      if(starts != null) {
        for(String s: starts) {
          Report end = findMatchingEnd(reports, start, s);
          if(end == null)
            continue;
          List<String> endTL = end.get("Timestamp");
          List<String> staTL = start.get("Timestamp");
          if(staTL != null && endTL != null && staTL.size() > 0 && endTL.size() > 0) {
           
            //FIXME: perhaps parse more cleverly?
            double startT = Double.parseDouble(staTL.get(0));
View Full Code Here

    LinkedList<Report> bfsQ = new LinkedList<Report>();
    Set<String> seen = new HashSet<String>();
    bfsQ.add(start);
   
    while(!bfsQ.isEmpty()) {
      Report cur = bfsQ.poll();
      List<String> ends = cur.get("End");
      if(ends != null && ends.contains(endTag))
        return cur;

      List<String> outlinks = start.get(XtrExtract.OUTLINK_FIELD);
      if(outlinks == null)
        return null;
      for(String s: outlinks) {
        if(seen.contains(s))
          continue;
        else
          seen.add(s);
        Report r = reports.get(s);
        if(r != null)
          bfsQ.add(r);
      }
    }
    return null;
View Full Code Here

        System.out.println("error: bad input.");
        return; //bail out more drastically
      }
      Text[] repts_as_text = (Text[]) repts;
      for(Text t: repts_as_text) {
        Report r = Report.createFromString(t.toString());
        reports.put(r.getMetadata().getOpIdString(), r);
      }
     
      Text[] indexed = indexGraph(reports);
      TextArrayWritable output = new TextArrayWritable();
      output.set(indexed);
View Full Code Here

      Text t;
      BytesWritable bw;
     
      if(k instanceof ChukwaArchiveKey && v instanceof ChunkImpl) {
        ChunkImpl value = (ChunkImpl) v;
        Report xtrReport = Report.createFromString(new String(value.getData()));
        bw = new BytesWritable(xtrReport.getMetadata().getTaskId().get());
        //FIXME: can probably optimize the above lines by doing a search in the raw bytes
        t= new Text(value.getData());
      } else if(k instanceof ChukwaRecordKey && v instanceof ChukwaRecord){
        ChukwaRecord value = (ChukwaRecord) v;
        Report xtrReport = Report.createFromString(value.getValue(Record.bodyField));
        bw = new BytesWritable(xtrReport.getMetadata().getTaskId().get());
        //FIXME: can probably optimize the above lines by doing a search in the raw bytes
        t= new Text(value.getValue(Record.bodyField));
      } else {
        log.error("unexpected key/value types: "+ k.getClass().getCanonicalName()
            + " and " + v.getClass().getCanonicalName() );
View Full Code Here

TOP

Related Classes of edu.berkeley.xtrace.reporting.Report

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.