Package org.apache.avro.ipc

Examples of org.apache.avro.ipc.HttpServer


    TracePlugin dPlugin = new TracePlugin(conf);
   
    // Responders
    Responder bRes = new RecursingResponder(TestBasicTracing.advancedProtocol, bPlugin);
    bRes.addRPCPlugin(bPlugin);
    HttpServer server1 = new HttpServer(bRes, 21005);
    server1.start();

    Responder cRes = new EndpointResponder(TestBasicTracing.advancedProtocol);
    cRes.addRPCPlugin(cPlugin);
    HttpServer server2 = new HttpServer(cRes, 21006);
    server2.start();
   
    Responder dRes = new EndpointResponder(TestBasicTracing.advancedProtocol);
    dRes.addRPCPlugin(dPlugin);
    HttpServer server3 = new HttpServer(dRes, 21007);
    server3.start();
   
    // Root requestor
    HttpTransceiver trans = new HttpTransceiver(
        new URL("http://localhost:21005"));
   
    GenericRequestor r = new GenericRequestor(TestBasicTracing.advancedProtocol, trans);
    r.addRPCPlugin(aPlugin);
   
    GenericRecord params = new GenericData.Record(
        TestBasicTracing.advancedProtocol.getMessages().get("w").getRequest());
    params.put("req", 1);
   
    for (int i = 0; i < 40; i++) {
      r.request("w", params)
    }
   
    List<Span> allSpans = new ArrayList<Span>();
    allSpans.addAll(aPlugin.storage.getAllSpans());
    allSpans.addAll(bPlugin.storage.getAllSpans());
    allSpans.addAll(cPlugin.storage.getAllSpans());
    allSpans.addAll(dPlugin.storage.getAllSpans());

    SpanAggregationResults results = SpanAggregator.getFullSpans(allSpans);
   
    assertEquals(0, results.incompleteSpans.size());
    List<Span> merged = results.completeSpans;
    List<Trace> traces = SpanAggregator.getTraces(merged).traces;
   
    assertEquals(40, traces.size());
    TraceCollection collection = new TraceCollection(traces.get(0));
    for (Trace t: traces) {
      collection.addTrace(t);
    }
    server1.close();
    server2.close();
    server3.close();
    aPlugin.httpServer.close();
    aPlugin.clientFacingServer.stop();
    bPlugin.httpServer.close();
    bPlugin.clientFacingServer.stop();
    cPlugin.httpServer.close();
View Full Code Here


    TracePlugin requestorPlugin = new TracePlugin(conf);
   
    Responder res = new TestResponder(protocol);
    res.addRPCPlugin(responderPlugin);
   
    HttpServer server = new HttpServer(res, 50000);
    server.start();
   
    HttpTransceiver trans = new HttpTransceiver(
        new URL("http://localhost:50000"));
   
    GenericRequestor r = new GenericRequestor(protocol, trans);
    r.addRPCPlugin(requestorPlugin);
   
    GenericRecord params = new GenericData.Record(protocol.getMessages().get(
    "m").getRequest());
    params.put("x", 0);
    r.request("m", params);
   
    List<Span> responderSpans = responderPlugin.storage.getAllSpans();
    assertEquals(1, responderSpans.size());
   
    List<Span> requestorSpans = requestorPlugin.storage.getAllSpans();
    assertEquals(1, requestorSpans.size());
   
    if ((responderSpans.size() == 1 && requestorSpans.size() == 1)) {
      Span responderSpan = responderSpans.get(0);
      Span requestorSpan = requestorSpans.get(0);
     
      // Check meta propagation    
      assertEquals(null, requestorSpan.parentSpanID);
      assertEquals(responderSpan.parentSpanID, requestorSpan.parentSpanID);
      assertEquals(responderSpan.traceID, requestorSpan.traceID);
     
      // Check other data
      assertEquals(2, requestorSpan.events.size());
      assertEquals(2, responderSpan.events.size());
      assertTrue("m".equals(requestorSpan.messageName.toString()));
      assertTrue("m".equals(responderSpan.messageName.toString()));
      assertFalse(requestorSpan.complete);
      assertFalse(responderSpan.complete);
    }
   
    server.close();
   
    requestorPlugin.clientFacingServer.stop();
    requestorPlugin.httpServer.close();
   
    responderPlugin.clientFacingServer.stop();
View Full Code Here

    TracePlugin dPlugin = new TracePlugin(conf);
   
    // Responders
    Responder bRes = new RecursingResponder(advancedProtocol, bPlugin);
    bRes.addRPCPlugin(bPlugin);
    HttpServer server1 = new HttpServer(bRes, 21005);
    server1.start();

    Responder cRes = new EndpointResponder(advancedProtocol);
    cRes.addRPCPlugin(cPlugin);
    HttpServer server2 = new HttpServer(cRes, 21006);
    server2.start();
   
    Responder dRes = new EndpointResponder(advancedProtocol);
    dRes.addRPCPlugin(dPlugin);
    HttpServer server3 = new HttpServer(dRes, 21007);
    server3.start();
   
    // Root requestor
    HttpTransceiver trans = new HttpTransceiver(
        new URL("http://localhost:21005"));
   
    GenericRequestor r = new GenericRequestor(advancedProtocol, trans);
    r.addRPCPlugin(aPlugin);
   
    GenericRecord params = new GenericData.Record(
        advancedProtocol.getMessages().get("w").getRequest());
    params.put("req", 1);
    r.request("w", params);
   
    // Verify counts
    assertEquals(1, aPlugin.storage.getAllSpans().size());
    assertEquals(3, bPlugin.storage.getAllSpans().size());
    assertEquals(1, cPlugin.storage.getAllSpans().size());
    assertEquals(1, dPlugin.storage.getAllSpans().size());
   
    ID traceID = aPlugin.storage.getAllSpans().get(0).traceID;
    ID rootSpanID = null;
   
    // Verify event counts and trace ID propagation
    for (Span s: aPlugin.storage.getAllSpans()) {
      assertEquals(2, s.events.size());
      assertTrue(Util.idsEqual(traceID, s.traceID));
      assertFalse(s.complete);
      rootSpanID = s.spanID;
    }
   
    for (Span s: bPlugin.storage.getAllSpans()) {
      assertEquals(2, s.events.size());
      assertEquals(traceID, s.traceID);
      assertFalse(s.complete);
    }
   
    for (Span s: cPlugin.storage.getAllSpans()) {
      assertEquals(2, s.events.size());
      assertEquals(traceID, s.traceID);
      assertFalse(s.complete);
    }
    for (Span s: dPlugin.storage.getAllSpans()) {
      assertEquals(2, s.events.size());
      assertEquals(traceID, s.traceID);
      assertFalse(s.complete);
    }
   
    // Verify span propagation.
    ID firstSpanID = aPlugin.storage.getAllSpans().get(0).spanID;
    ID secondSpanID = cPlugin.storage.getAllSpans().get(0).spanID;
    ID thirdSpanID = dPlugin.storage.getAllSpans().get(0).spanID;
   
    boolean firstFound = false, secondFound = false, thirdFound = false;
    for (Span s: bPlugin.storage.getAllSpans()) {
      if (Util.idsEqual(s.spanID, firstSpanID)) {
        firstFound = true;
      }
      else if (Util.idsEqual(s.spanID, secondSpanID)) {
        secondFound = true;
      }
      else if (Util.idsEqual(s.spanID, thirdSpanID)) {
        thirdFound = true;
      }
    }
    assertTrue(firstFound);
    assertTrue(secondFound);
    assertTrue(thirdFound);
   
    server1.close();
    server2.close();
    server3.close();
    aPlugin.httpServer.close();
    aPlugin.clientFacingServer.stop();
    bPlugin.httpServer.close();
    bPlugin.clientFacingServer.stop();
    cPlugin.httpServer.close();
View Full Code Here

    TracePlugin fPlugin = new TracePlugin(conf);
   
    // Responders
    Responder bRes = new RecursingResponder(advancedProtocol, bPlugin);
    bRes.addRPCPlugin(bPlugin);
    HttpServer server1 = new HttpServer(bRes, 21005);
    server1.start();

    Responder cRes = new EndpointResponder(advancedProtocol);
    cRes.addRPCPlugin(cPlugin);
    HttpServer server2 = new HttpServer(cRes, 21006);
    server2.start();
   
    Responder dRes = new EndpointResponder(advancedProtocol);
    dRes.addRPCPlugin(dPlugin);
    HttpServer server3 = new HttpServer(dRes, 21007);
    server3.start();
   
   
    // Root requestors
    HttpTransceiver trans1 = new HttpTransceiver(
        new URL("http://localhost:21005")); // recurse
View Full Code Here

    TracePlugin dPlugin = new TracePlugin(conf);
   
    // Responders
    Responder bRes = new RecursingResponder(advancedProtocol, bPlugin);
    bRes.addRPCPlugin(bPlugin);
    HttpServer server1 = new HttpServer(bRes, 21005);
    server1.start();

    Responder cRes = new EndpointResponder(advancedProtocol);
    cRes.addRPCPlugin(cPlugin);
    HttpServer server2 = new HttpServer(cRes, 21006);
    server2.start();
   
    Responder dRes = new EndpointResponder(advancedProtocol);
    dRes.addRPCPlugin(dPlugin);
    HttpServer server3 = new HttpServer(dRes, 21007);
    server3.start();
   
    // Root requestor
    HttpTransceiver trans = new HttpTransceiver(
        new URL("http://localhost:21005"));
   
    GenericRequestor r = new GenericRequestor(advancedProtocol, trans);
    r.addRPCPlugin(aPlugin);
   
    GenericRecord params = new GenericData.Record(
        advancedProtocol.getMessages().get("w").getRequest());
    params.put("req", 1);
    r.request("w", params);
    Thread.sleep(1000);
    ArrayList<Span> allSpans = new ArrayList<Span>();
   
    allSpans.addAll(aPlugin.storage.getAllSpans());
    allSpans.addAll(bPlugin.storage.getAllSpans());
    allSpans.addAll(cPlugin.storage.getAllSpans());
    allSpans.addAll(dPlugin.storage.getAllSpans());
   
    SpanAggregationResults results = SpanAggregator.getFullSpans(allSpans);
   
    TraceFormationResults traces = SpanAggregator.getTraces(results.completeSpans);
   
    assertEquals(1, traces.traces.size());
    assertEquals(0, traces.rejectedSpans.size());
   
    // Test debug printing of traces
    String string1 = traces.traces.get(0).printWithTiming();
    assertTrue(string1.contains("w"));
    assertTrue(string1.contains("x"));
    assertTrue(string1.indexOf("x") != string1.lastIndexOf("x")); // assure two x's
   
    String string2 = traces.traces.get(0).printBrief();
    assertTrue(string2.contains("w"));
    assertTrue(string2.contains("x"));
    assertTrue(string2.indexOf("x") != string2.lastIndexOf("x")); // assure two x's
   
    // Just for fun, print to console
    System.out.println(traces.traces.get(0).printWithTiming());
    System.out.println(traces.traces.get(0).printBrief());
   
    server1.close();
    server2.close();
    server3.close();
    aPlugin.httpServer.close();
    aPlugin.clientFacingServer.stop();
    bPlugin.httpServer.close();
    bPlugin.clientFacingServer.stop();
    cPlugin.httpServer.close();
View Full Code Here

  @Before @Override
  public void testStartServer() throws Exception {
    if (server != null) return;
    server =
      new HttpServer(new SpecificResponder(Simple.class, new TestImpl()), 0);
    server.start();
    client =
      new HttpTransceiver(new URL("http://127.0.0.1:"+server.getPort()+"/"));
    proxy = (Simple)SpecificRequestor.getClient(Simple.class, client);
  }
View Full Code Here

        1000*without/COUNT));
  }

  /** Sends RPCs and returns nanos elapsed. */
  private static long sendRpcs(boolean withPlugin) throws IOException {
    HttpServer server = createServer(withPlugin);
    Transceiver t =
      new HttpTransceiver(new URL("http://127.0.0.1:"+server.getPort()+"/"));
    GenericRequestor requestor = new GenericRequestor(NULL_PROTOCOL, t);

    long now = System.nanoTime();
    for (int i = 0; i < COUNT; ++i) {
      requestor.request("null", null);
    }
    long elapsed = System.nanoTime() - now;
    t.close();
    server.close();
    return elapsed;
  }
View Full Code Here

    Responder r = new IdentityResponder(NULL_PROTOCOL);
    if (withPlugin) {
      r.addRPCPlugin(new StatsPlugin());
    }
    // Start Avro server
    HttpServer server = new HttpServer(r, 0);
    server.start();
    return server;
  }
View Full Code Here

    Responder r = new SleepyResponder(protocol);
    StatsPlugin p = new StatsPlugin();
    r.addRPCPlugin(p);

    // Start Avro server
    HttpServer avroServer = new HttpServer(r, Integer.parseInt(args[0]));
    avroServer.start();

    StatsServer ss = new StatsServer(p, 8080);
   
    HttpTransceiver trans = new HttpTransceiver(
        new URL("http://localhost:" + Integer.parseInt(args[0])));
View Full Code Here

  @Before
  public void startServer() throws Exception {
    if (server != null) return;
    server =
      new HttpServer(new SpecificResponder(BulkData.class, new BulkDataImpl()),
                     0);
    server.start();
    client =
      new HttpTransceiver(new URL("http://127.0.0.1:"+server.getPort()+"/"));
    proxy = (BulkData)SpecificRequestor.getClient(BulkData.class, client);
View Full Code Here

TOP

Related Classes of org.apache.avro.ipc.HttpServer

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.