Package edu.berkeley.xtrace.reporting

Examples of edu.berkeley.xtrace.reporting.Report


    assertFalse(iter.hasNext());
    assertFalse(iter2.hasNext());
  }
 
  private Report randomReport() {
    Report report = new Report();
   
    final int numKeys = r.nextInt(15);
    for (int i = 0; i < numKeys; i++) {
      report.put("Key"+i, randomString(10 + r.nextInt(20)));
    }
    return report;
  }
View Full Code Here


   
    long startTime = System.currentTimeMillis();
   
    /* Insert a single report into the file store */
    XTraceMetadata md = new XTraceMetadata(new TaskID(8), 0);
    Report report = randomReport(md);
    fs.receiveReport(report.toString());
   
    /* Sync() the report */
    fs.sync();
   
    /* Test the interface */
    assertEquals(1, fs.numReports());
    assertEquals(1, fs.numTasks());
   
    /* test getByTask and countByTaskID */
    assertEquals(1, fs.countByTaskId(md.getTaskId()));
    Iterator<Report> iter = fs.getReportsByTask(md.getTaskId());
    assertTrue(iter.hasNext());
    Report report2 = iter.next();
    assertNotNull(report2);
    assertEquals(report, report2);
    assertFalse(iter.hasNext());
   
    /* test getTasksSince */
 
View Full Code Here

  public void TODOtestDuplicateTags() throws XTraceException {
    if (!canTest) return;
   
    /* Insert a single report into the file store */
    TaskID taskId = new TaskID(8);
    Report report = randomReport(new XTraceMetadata(taskId, 0));
    report.put("Tag", "tag1");
    report.put("Tag", "tag1");
    fs.receiveReport(report.toString());
    fs.sync();
   
    /* Test that a single copy of the tag is seen */
    assertEquals(1, fs.getTasksByTag("tag1", 0, Integer.MAX_VALUE).size());
    List<String> tags = fs.getTasksByTag("tag1", 0, Integer.MAX_VALUE).get(0).getTags();
    assertEquals(1, tags.size());
    assertEquals("tag1", tags.get(0));
    assertEquals(0, fs.getTasksByTag("tag1,tag1", 0, Integer.MAX_VALUE).size());
    // Substring of "tag1" should not return any tasks
    assertEquals(0, fs.getTasksByTag("ta", 0, Integer.MAX_VALUE).size());
   
    /* Insert another report in the same task */
    report = randomReport(new XTraceMetadata(taskId, 1));
    report.put("Tag", "tag1");
    report.put("Tag", "tag2");
    fs.receiveReport(report.toString());
    fs.sync();
   
    /* Test that a single task is returned for both tags */
    assertEquals(1, fs.getTasksByTag("tag1", 0, Integer.MAX_VALUE).size());
    assertEquals(1, fs.getTasksByTag("tag2", 0, Integer.MAX_VALUE).size());
View Full Code Here

  public void TODOtestTitleOperations() throws XTraceException {
    if (!canTest) return;
   
    /* Insert a single report into the file store */
    TaskID taskId = new TaskID(8);
    Report report = randomReport(new XTraceMetadata(taskId, 0));
    fs.receiveReport(report.toString());
    fs.sync();
   
    /* Test that the title is the taskID (since no title field was given) */
    assertEquals(taskId.toString(), fs.getLatestTasks(0, 1).get(0).getTitle());
    assertEquals(1, fs.getTasksByTitle(taskId.toString(), 0, Integer.MAX_VALUE).size());
   
    /* Insert another report in the same task, with no title */
    report = randomReport(new XTraceMetadata(taskId, 1));
    fs.receiveReport(report.toString());
    fs.sync();
   
    /* Test that the title is the taskID (since no title field was given) */
    assertEquals(taskId.toString(), fs.getLatestTasks(0, 1).get(0).getTitle());
    assertEquals(1, fs.getTasksByTitle(taskId.toString(), 0, Integer.MAX_VALUE).size());
   
    /* Insert another report in the same task, with a title */
    report = randomReport(new XTraceMetadata(taskId, 2));
    report.put("Title", "title1");
    fs.receiveReport(report.toString());
    fs.sync();
   
    /* Test that the title is title1 */
    assertEquals("title1", fs.getLatestTasks(0, 1).get(0).getTitle());
    assertEquals(0, fs.getTasksByTitle(taskId.toString(), 0, Integer.MAX_VALUE).size());
    assertEquals(1, fs.getTasksByTitle("title1", 0, Integer.MAX_VALUE).size());
   
    /* Insert another report in the same task, with another title */
    report = randomReport(new XTraceMetadata(taskId, 3));
    report.put("Title", "title2");
    fs.receiveReport(report.toString());
    fs.sync();
   
    /* Test that the title is title1 */
    assertEquals("title2", fs.getLatestTasks(0, 1).get(0).getTitle());
    assertEquals(0, fs.getTasksByTitle(taskId.toString(), 0, Integer.MAX_VALUE).size());
View Full Code Here

   
    /* Test if an insertion updates the time */
    long startTime = System.currentTimeMillis();
   
    XTraceMetadata md = new XTraceMetadata(new TaskID(8), 0);
    Report report = randomReport(md);
    fs.receiveReport(report.toString());
   
    /* Sync() the report */
    fs.sync();
   
    long afterFirstInsertion = fs.lastUpdatedByTaskId(md.getTaskId());
    assertTrue(afterFirstInsertion > startTime);
   
    md = new XTraceMetadata(new TaskID(8), 0);
    report = randomReport(md);
    fs.receiveReport(report.toString());
   
    /* Sync() the report */
    fs.sync();
   
    long afterSecondInsertion = fs.lastUpdatedByTaskId(md.getTaskId());
View Full Code Here

        // The directory is now empty so delete it
        return dir.delete();
    }
   
    private Report randomReport(XTraceMetadata md) {
    Report report = new Report();
    report.put("X-Trace", md.toString());
   
    final int numKeys = r.nextInt(15);
    for (int i = 0; i < numKeys; i++) {
      report.put("Key"+i, randomString(10 + r.nextInt(20)));
    }
    return report;
  }
View Full Code Here

   * Initialize a new XTraceEvent.  This should be done for each
   * request or task processed by this node.
   *
   */
  public XTraceEvent(int opIdLength) {
    report = new Report();
    myOpId = new byte[opIdLength];
    random.get().nextBytes(myOpId);
    willReport = true;
  }
View Full Code Here

        return;
      }
      try {
        Iterator<Report> iter = reportstore.getReportsByTask(task.get(0).getTaskId());
        while (iter.hasNext()) {
          Report r = iter.next();
          out.write(r.toString());
          out.write("\n");
        }
      } catch (XTraceException e) {
        LOG.warn("Internal error", e);
        out.write("Internal error: " + e);
View Full Code Here

  }

  void receiveReport(String msg) {
    Matcher matcher = XTRACE_LINE.matcher(msg);
    if (matcher.find()) {
      Report r = Report.createFromString(msg);
      String xtraceLine = matcher.group(1);
      XTraceMetadata meta = XTraceMetadata.createFromString(xtraceLine);

      if (meta.getTaskId() != null) {
        TaskID task = meta.getTaskId();
        String taskId = task.toString().toUpperCase();
        BufferedWriter fout = fileCache.getHandle(task);
        if (fout == null) {
          LOG
              .warn("Discarding a report due to internal fileCache error: "
                  + msg);
          return;
        }
        try {
          fout.write(msg);
          fout.newLine();
          fout.newLine();
          LOG.debug("Wrote " + msg.length() + " bytes to the stream");
        } catch (IOException e) {
          LOG.warn("I/O error while writing the report", e);
        }

        // Update index
        try {
          // Extract title
          String title = null;
          List<String> titleVals = r.get("Title");
          if (titleVals != null && titleVals.size() > 0) {
            // There should be only one title field, but if there
            // are more, just
            // arbitrarily take the first one.
            title = titleVals.get(0);
          }

          // Extract tags
          TreeSet<String> newTags = null;
          List<String> list = r.get("Tag");
          if (list != null) {
            newTags = new TreeSet<String>(list);
          }

          // Find out whether to do an insert or an update
View Full Code Here

     * (non-Javadoc)
     *
     * @see java.util.Iterator#next()
     */
    public Report next() {
      Report ret = nextReport;
      nextReport = calcNext();
      return ret;
    }
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.