Search in sources :

Example 1 with RemoteSpan

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);
    }
}
Also used : RemoteSpan(org.apache.accumulo.tracer.thrift.RemoteSpan) ArrayList(java.util.ArrayList)

Example 2 with RemoteSpan

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;
}
Also used : RemoteSpan(org.apache.accumulo.tracer.thrift.RemoteSpan) HashSet(java.util.HashSet)

Example 3 with RemoteSpan

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;
}
Also used : PrintStream(java.io.PrintStream) Connector(org.apache.accumulo.core.client.Connector) Scanner(org.apache.accumulo.core.client.Scanner) RemoteSpan(org.apache.accumulo.tracer.thrift.RemoteSpan) Value(org.apache.accumulo.core.data.Value) Text(org.apache.hadoop.io.Text) Range(org.apache.accumulo.core.data.Range) Key(org.apache.accumulo.core.data.Key) Date(java.util.Date)

Example 4 with RemoteSpan

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;
    }
}
Also used : RemoteSpan(org.apache.accumulo.tracer.thrift.RemoteSpan) UnknownHostException(java.net.UnknownHostException)

Example 5 with RemoteSpan

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;
}
Also used : Scanner(org.apache.accumulo.core.client.Scanner) Range(org.apache.accumulo.core.data.Range) Entry(java.util.Map.Entry) RemoteSpan(org.apache.accumulo.tracer.thrift.RemoteSpan) DefaultValue(javax.ws.rs.DefaultValue) Value(org.apache.accumulo.core.data.Value) Key(org.apache.accumulo.core.data.Key) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

RemoteSpan (org.apache.accumulo.tracer.thrift.RemoteSpan)13 Key (org.apache.accumulo.core.data.Key)7 Value (org.apache.accumulo.core.data.Value)7 Scanner (org.apache.accumulo.core.client.Scanner)4 Range (org.apache.accumulo.core.data.Range)4 DefaultValue (javax.ws.rs.DefaultValue)3 Date (java.util.Date)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Connector (org.apache.accumulo.core.client.Connector)2 Annotation (org.apache.accumulo.tracer.thrift.Annotation)2 Text (org.apache.hadoop.io.Text)2 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)2 PrintStream (java.io.PrintStream)1 UnknownHostException (java.net.UnknownHostException)1 PrivilegedAction (java.security.PrivilegedAction)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Entry (java.util.Map.Entry)1