use of org.apache.accumulo.tracer.thrift.RemoteSpan in project accumulo by apache.
the class SpanTree method recurse.
private void recurse(int level, RemoteSpan parent, RemoteSpan node, SpanTreeVisitor visitor, Set<Long> visited) {
// infinite recursion
if (visited.contains(node.spanId))
return;
visited.add(node.spanId);
List<RemoteSpan> children = new ArrayList<>();
List<Long> childrenIds = parentChildren.get(node.spanId);
if (childrenIds != null) {
for (Long childId : childrenIds) {
RemoteSpan child = nodes.get(childId);
if (child != null) {
children.add(child);
}
}
}
children = TraceDump.sortByStart(children);
visitor.visit(level, parent, node, children);
for (RemoteSpan child : children) {
recurse(level + 1, node, child, visitor, visited);
}
}
use of org.apache.accumulo.tracer.thrift.RemoteSpan in project accumulo by apache.
the class SpanTree method visit.
public Set<Long> visit(SpanTreeVisitor visitor) {
Set<Long> visited = new HashSet<>();
List<Long> root = parentChildren.get(Span.ROOT_SPAN_ID);
if (root == null || root.isEmpty())
return visited;
RemoteSpan rootSpan = nodes.get(root.iterator().next());
if (rootSpan == null)
return visited;
recurse(0, null, rootSpan, visitor, visited);
return visited;
}
use of org.apache.accumulo.tracer.thrift.RemoteSpan in project accumulo by apache.
the class TraceDump method listSpans.
private static int listSpans(Opts opts, ScannerOpts scanOpts) throws Exception {
PrintStream out = System.out;
long endTime = System.currentTimeMillis();
long startTime = endTime - opts.length;
Connector conn = opts.getConnector();
Scanner scanner = conn.createScanner(opts.getTableName(), opts.auths);
scanner.setBatchSize(scanOpts.scanBatchSize);
Range range = new Range(new Text("start:" + Long.toHexString(startTime)), new Text("start:" + Long.toHexString(endTime)));
scanner.setRange(range);
out.println("Trace Day/Time (ms) Start");
for (Entry<Key, Value> entry : scanner) {
RemoteSpan span = TraceFormatter.getRemoteSpan(entry);
out.println(String.format("%016x %s %5d %s", span.traceId, TraceFormatter.formatDate(new Date(span.getStart())), span.stop - span.start, span.description));
}
return 0;
}
use of org.apache.accumulo.tracer.thrift.RemoteSpan in project accumulo by apache.
the class AsyncSpanReceiver method sendSpans.
protected void sendSpans() {
while (!sendQueue.isEmpty()) {
boolean sent = false;
RemoteSpan s = sendQueue.peek();
SpanKey dest = getSpanKey(s.data);
Destination client = clients.get(dest);
if (client == null) {
try {
clients.put(dest, createDestination(dest));
} catch (Exception ex) {
log.warn("Exception creating connection to span receiver", ex);
}
}
if (client != null) {
try {
send(client, s);
synchronized (sendQueue) {
sendQueue.remove();
sendQueue.notifyAll();
sendQueueSize.decrementAndGet();
}
sent = true;
} catch (Exception ex) {
log.warn("Got error sending to " + dest + ", refreshing client", ex);
clients.remove(dest);
}
}
if (!sent)
break;
}
}
use of org.apache.accumulo.tracer.thrift.RemoteSpan in project accumulo by apache.
the class TracesResource method getTracesType.
/**
* Generates a list of traces filtered by type and range of minutes
*
* @param type
* Type of the trace
* @param minutes
* Range of minutes, Min of 0 and Max 0f 30 days
* @return List of traces filtered by type and range
*/
@Path("listType/{type}/{minutes}")
@GET
public TraceType getTracesType(@PathParam("type") @NotNull @Pattern(regexp = ALPHA_NUM_REGEX) final String type, @PathParam("minutes") @Min(0) @Max(2592000) int minutes) throws Exception {
TraceType typeTraces = new TraceType(type);
Pair<Scanner, UserGroupInformation> pair = getScanner();
final Scanner scanner = pair.getFirst();
if (scanner == null) {
return typeTraces;
}
Range range = getRangeForTrace(minutes);
scanner.setRange(range);
if (null != pair.getSecond()) {
pair.getSecond().doAs(new PrivilegedAction<Void>() {
@Override
public Void run() {
for (Entry<Key, Value> entry : scanner) {
RemoteSpan span = TraceFormatter.getRemoteSpan(entry);
if (span.description.equals(type)) {
typeTraces.addTrace(new TracesForTypeInformation(span));
}
}
return null;
}
});
} else {
for (Entry<Key, Value> entry : scanner) {
RemoteSpan span = TraceFormatter.getRemoteSpan(entry);
if (span.description.equals(type)) {
typeTraces.addTrace(new TracesForTypeInformation(span));
}
}
}
return typeTraces;
}
Aggregations