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();