Package org.apache.avro.util

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


      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

  /**
   * 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

   * 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

   *        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

   */
  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

   */
  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

    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

    GenericArray<CharSequence> l2 =
      new GenericData.Array<CharSequence>(1,s.getFields().get(0).schema());
    String foo = "foo";
    l0.add(new StringBuffer(foo));
    l1.add(foo);
    l2.add(new Utf8(foo));
    r0.put(0, l0);
    r1.put(0, l1);
    r2.put(0, l2);
    assertEquals(r0, r1);
    assertEquals(r0, r2);
View Full Code Here

  public abstract void reduceFlush(MID record, Collector<OUT> collector)
    throws IOException;

  /** Call to update task status. */
  public void status(String message) {
    outputClient.status(new Utf8(message));
  }
View Full Code Here

TOP

Related Classes of org.apache.avro.util.Utf8

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.