Examples of Utf8


Examples of org.apache.avro.util.Utf8

  @Test
  public void testBasicStorage() {
    TracePluginConfiguration conf = new TracePluginConfiguration();
    FileSpanStorage test = new FileSpanStorage(false, conf);
    Span s = Util.createEventlessSpan(Util.idValue(1), Util.idValue(1), null);
    s.messageName = new Utf8("message");
    test.addSpan(s);
    try {
      Thread.sleep(100);
    } catch (InterruptedException e) {
      e.printStackTrace();
View Full Code Here

Examples of org.apache.avro.util.Utf8

    FileSpanStorage test = new FileSpanStorage(false, conf);
    test.setMaxSpans(100000);
    List<Span> spans = new ArrayList<Span>(50000);
    for (int i = 0; i < 50000; i++) {
      Span s = Util.createEventlessSpan(Util.idValue(i), Util.idValue(i), null);
      s.messageName = new Utf8("message");
      test.addSpan(s);
      spans.add(s);
    }
    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    assertEquals(50000, test.getAllSpans().size());

    // Test fewer spans but explicitly call containsAll
    TracePluginConfiguration conf2 = new TracePluginConfiguration();
    FileSpanStorage test2 = new FileSpanStorage(false, conf2);
    test.setMaxSpans(100000);
    spans.clear();
    for (int i = 0; i < 5000; i++) {
      Span s = Util.createEventlessSpan(Util.idValue(i), Util.idValue(i), null);
      s.messageName = new Utf8("message");
      test2.addSpan(s);
      spans.add(s);
    }
    try {
      Thread.sleep(100);
View Full Code Here

Examples of org.apache.avro.util.Utf8

    test.setMaxSpans(10);
   
    // Add a bunch of spans
    for (int i = 0; i < 100; i++) {
      Span s = Util.createEventlessSpan(Util.idValue(i), Util.idValue(i), null);
      s.messageName = new Utf8("message");
      test.addSpan(s);
    }
   
    List<Span> lastNine = new LinkedList<Span>();
    for (int i = 0; i < 9; i++) {
      Span s = Util.createEventlessSpan(Util.idValue(100 + i), Util.idValue(100 + i), null);
      s.messageName = new Utf8("message");
      lastNine.add(s);
      test.addSpan(s);
    }
    try {
      Thread.sleep(100);
View Full Code Here

Examples of org.apache.avro.util.Utf8

      te2.timeStamp = System.currentTimeMillis() * 1000000;
      te2.event = SpanEvent.CLIENT_RECV;
      s.events.add(te1);
      s.events.add(te2);
     
      s.messageName = new Utf8("message");
      test.addSpan(s);
      spans[i] = s;
     
      try {
        Thread.sleep(1000);
View Full Code Here

Examples of org.apache.avro.util.Utf8

  /**
   * Test merging of two basic spans.
   */
  @Test
  public void testSpanCompletion1() {
    Span span1a = createClientSpan(idValue(1), idValue(1), null, new Utf8("a"));
    span1a.requestPayloadSize = 10;
    span1a.responsePayloadSize = 0;
   
    Span span1b = createServerSpan(idValue(1), idValue(1), null, new Utf8("a"));
    span1b.requestPayloadSize = 0;
    span1b.responsePayloadSize = 11;
   
    List<Span> partials = new ArrayList<Span>();
    partials.add(span1a);
View Full Code Here

Examples of org.apache.avro.util.Utf8

   * Test span merging with some extra invalid spans;
   */
  @Test
  public void testInvalidSpanCompletion() {
    // Trace: 1, Span: 1, Parent: null
    Span span1a = createClientSpan(idValue(1), idValue(1), null, new Utf8("a"));
    Span span1b = createServerSpan(idValue(1), idValue(1), null, new Utf8("a"));
   
    // Trace: 1, Span: 10, Parent: 3
    Span spanBogus1 = createClientSpan(idValue(1), idValue(10), idValue(3), new Utf8("not"));
    Span spanBogus2 = createServerSpan(idValue(1), idValue(10), idValue(3), new Utf8("equal"));
   
    // Trace: 1, Span: 5, Parent: (2/3)
    Span spanBogus3 = createClientSpan(idValue(1), idValue(5), idValue(2), new Utf8("equal"));
    Span spanBogus4 = createServerSpan(idValue(1), idValue(5), idValue(3), new Utf8("equal"));
   
    // Trace:1, Span: 4, Parent: 1
    Span spanBogus5 = createClientSpan(idValue(1), idValue(4), idValue(1), new Utf8("alone"));
   
    List<Span> partials = new ArrayList<Span>();
    partials.add(span1a);
    partials.add(span1b);
    partials.add(spanBogus1);
    partials.add(spanBogus2);
    partials.add(spanBogus3);
    partials.add(spanBogus4);
    partials.add(spanBogus5);
   
    SpanAggregationResults results = SpanAggregator.getFullSpans(partials);
    assertNotNull(results.completeSpans);
    assertNotNull(results.incompleteSpans);

    assertTrue(results.incompleteSpans.size() == 5);
    assertTrue(results.incompleteSpans.contains(spanBogus1));
    assertTrue(results.incompleteSpans.contains(spanBogus2));
    assertTrue(results.incompleteSpans.contains(spanBogus3));
    assertTrue(results.incompleteSpans.contains(spanBogus4));
    assertTrue(results.incompleteSpans.contains(spanBogus5));
   
    assertTrue(results.completeSpans.size() == 1);
    Span result = results.completeSpans.get(0);
    assertTrue(result.complete);
    assertTrue(idsEqual(idValue(1), result.spanID));
    assertEquals(new Utf8("requestorHostname"), result.requestorHostname);
    assertEquals(new Utf8("responderHostname"), result.responderHostname);
    assertNull(result.parentSpanID);
    assertEquals(new Utf8("a"), result.messageName);
  }
View Full Code Here

Examples of org.apache.avro.util.Utf8

   *        e                   
   */
  @Test
  @SuppressWarnings("unchecked")
  public void testTraceFormation1() {
    Span a1 = createClientSpan(idValue(1), idValue(1), null, new Utf8("a"));
    Span a2 = createServerSpan(idValue(1), idValue(1), null, new Utf8("a"));
   
    Span b1 = createClientSpan(idValue(1), idValue(2), idValue(1), new Utf8("b"));
    Span b2 = createServerSpan(idValue(1), idValue(2), idValue(1), new Utf8("b"));

    Span c1 = createClientSpan(idValue(1), idValue(3), idValue(2), new Utf8("c"));
    Span c2 = createServerSpan(idValue(1), idValue(3), idValue(2), new Utf8("c"));
   
    Span d1 = createClientSpan(idValue(1), idValue(4), idValue(2), new Utf8("d"));
    Span d2 = createServerSpan(idValue(1), idValue(4), idValue(2), new Utf8("d"));
   
    Span e1 = createClientSpan(idValue(1), idValue(5), idValue(4), new Utf8("e"));
    Span e2 = createServerSpan(idValue(1), idValue(5), idValue(4), new Utf8("e"));
   
    List<Span> spans = new LinkedList<Span>();
    spans.addAll(Arrays.asList(new Span[] {a1, a2, b1, b2, c1, c2, d1, d2, e1, e2}));
   
    List<Span> merged = SpanAggregator.getFullSpans(spans).completeSpans;
   
    assertEquals(5, merged.size());
    for (Span s: merged) {
      assertEquals(new Utf8("requestorHostname"), s.requestorHostname);
      assertEquals(new Utf8("responderHostname"), s.responderHostname);
    }
   
    List<Trace> traces = SpanAggregator.getTraces(merged).traces;
    assertEquals(1, traces.size());
   
View Full Code Here

Examples of org.apache.avro.util.Utf8

   */
  public Span createClientSpan(ID traceID, ID spanID, ID parentID, Utf8 msgName) {
    Span out = new Span();
    out.spanID = spanID;
    out.traceID = traceID;
    out.requestorHostname = new Utf8("requestorHostname");
   
    if (parentID != null) {
      out.parentSpanID = parentID;
    }
    out.messageName = msgName;
View Full Code Here

Examples of org.apache.avro.util.Utf8

   */
  public Span createServerSpan(ID traceID, ID spanID, ID parentID, Utf8 msgName) {
    Span out = new Span();
    out.spanID = spanID;
    out.traceID = traceID;
    out.responderHostname = new Utf8("responderHostname");
   
    if (parentID != null) {
      out.parentSpanID = parentID;
    }
    out.messageName = msgName;
View Full Code Here

Examples of org.apache.avro.util.Utf8

    DatumWriter<Utf8> writer = new GenericDatumWriter<Utf8>();
    DataFileWriter<Utf8> out = new DataFileWriter<Utf8>(writer);
    LINES_FILE.getParentFile().mkdirs();
    out.create(Schema.create(Schema.Type.STRING), LINES_FILE);
    for (String line : LINES)
      out.append(new Utf8(line));
    out.close();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.