Package edu.berkeley.xtrace

Examples of edu.berkeley.xtrace.XTraceMetadata


    if (!canTest) return;
   
    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 */
    Iterator<TaskRecord> taskiter = fs.getTasksSince(startTime, 0, Integer.MAX_VALUE).iterator();
    assertTrue(taskiter.hasNext());
    assertEquals(md.getTaskId(), taskiter.next().getTaskId());
    assertFalse(taskiter.hasNext());
  }
View Full Code Here


    XTraceMetadata[] mds = new XTraceMetadata[TOTAL_REPORTS];
    Report[] reports = new Report[TOTAL_REPORTS];
    for (int i = 0; i < taskIds.length; i++) {
      for (int j = 0; j < NUM_STOCHASTIC_REPORTS_PER_TASK; j++) {
        int idx = i*NUM_STOCHASTIC_REPORTS_PER_TASK + j;
        mds[idx] = new XTraceMetadata(taskIds[i], r.nextInt());
        reports[idx] = randomReport(mds[idx]);
        fs.receiveReport(reports[idx].toString());
      }
    }
   
View Full Code Here

    TaskID[] tasks = new TaskID[NUM_STOCHASTIC_TASKS];
    for (int i = 0; i < NUM_STOCHASTIC_TASKS; i++) {
      tasks[i] = new TaskID(8);
      for (int j = 0; j < NUM_STOCHASTIC_REPORTS_PER_TASK; j++) {
        int idx = i*NUM_STOCHASTIC_REPORTS_PER_TASK +j;
        reports[idx] = randomReport(new XTraceMetadata(tasks[i], r.nextInt()));
        if (i < NUM_STOCHASTIC_TASKS / 2) {
          reports[idx].put("Tag", "small");
          reports[idx].put("Title", "smaller");
        } else {
          reports[idx].put("Tag", "big");
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();
   
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 */
 
View Full Code Here

    assertEquals(0L, fs.lastUpdatedByTaskId(TaskID.createFromString("00000000")));
   
    /* 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());
    assertTrue(afterFirstInsertion < afterSecondInsertion);
  }
View Full Code Here

    if (!canTest) return;
   
    /* Create a set of reports */
    Report[] reports = new Report[10];
    for (int i = 0; i < reports.length; i++) {
      reports[i] = randomReport(new XTraceMetadata(new TaskID(8), r.nextInt()));
      fs.receiveReport(reports[i].toString());
      try {
        Thread.sleep(25);
      } catch (InterruptedException e) { }
    }
View Full Code Here

    if (!canTest) return;
   
    /* Create a set of reports */
    Report[] reports = new Report[10];
    for (int i = 0; i < reports.length; i++) {
      reports[i] = randomReport(new XTraceMetadata(new TaskID(8), r.nextInt()));
    }
    reports[2].put("Tag", "tag1");
    reports[4].put("Tag", "tag2");
    reports[5].put("Tag", "tag2");
    reports[6].put("Tag", "tag3");
View Full Code Here

    final int numKeys = r.nextInt(15);
    for (int i = 0; i < numKeys; i++) {
      report.put("Key"+i, randomString(10 + r.nextInt(20)));
    }
   
    report.put("X-Trace", new XTraceMetadata(task, r.nextInt()).toString());
    return report;
  }
View Full Code Here

    List<String> xtrlist = map.get("X-Trace");
    if (xtrlist == null || xtrlist.size() < 1)
      return null;

    String xtrstr = xtrlist.iterator().next();
    XTraceMetadata xtr = null;
    try {
      xtr = XTraceMetadata.createFromString(xtrstr);
    } catch (Exception e) {
      return null;
    }
View Full Code Here

TOP

Related Classes of edu.berkeley.xtrace.XTraceMetadata

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.