Search in sources :

Example 1 with SpanReceiver

use of org.apache.htrace.core.SpanReceiver in project hadoop by apache.

the class TracerConfigurationManager method listSpanReceivers.

public synchronized SpanReceiverInfo[] listSpanReceivers() throws IOException {
    TracerPool pool = TracerPool.getGlobalTracerPool();
    SpanReceiver[] receivers = pool.getReceivers();
    SpanReceiverInfo[] info = new SpanReceiverInfo[receivers.length];
    for (int i = 0; i < receivers.length; i++) {
        SpanReceiver receiver = receivers[i];
        info[i] = new SpanReceiverInfo(receiver.getId(), receiver.getClass().getName());
    }
    return info;
}
Also used : SpanReceiver(org.apache.htrace.core.SpanReceiver) TracerPool(org.apache.htrace.core.TracerPool)

Example 2 with SpanReceiver

use of org.apache.htrace.core.SpanReceiver in project hadoop by apache.

the class TracerConfigurationManager method addSpanReceiver.

public synchronized long addSpanReceiver(SpanReceiverInfo info) throws IOException {
    StringBuilder configStringBuilder = new StringBuilder();
    String prefix = "";
    for (ConfigurationPair pair : info.configPairs) {
        configStringBuilder.append(prefix).append(pair.getKey()).append(" = ").append(pair.getValue());
        prefix = ", ";
    }
    SpanReceiver rcvr = null;
    try {
        rcvr = new SpanReceiver.Builder(TraceUtils.wrapHadoopConf(confPrefix, conf, info.configPairs)).className(info.getClassName().trim()).build();
    } catch (RuntimeException e) {
        LOG.info("Failed to add SpanReceiver " + info.getClassName() + " with configuration " + configStringBuilder.toString(), e);
        throw e;
    }
    TracerPool.getGlobalTracerPool().addReceiver(rcvr);
    LOG.info("Successfully added SpanReceiver " + info.getClassName() + " with configuration " + configStringBuilder.toString());
    return rcvr.getId();
}
Also used : SpanReceiver(org.apache.htrace.core.SpanReceiver) ConfigurationPair(org.apache.hadoop.tracing.SpanReceiverInfo.ConfigurationPair)

Example 3 with SpanReceiver

use of org.apache.htrace.core.SpanReceiver in project hadoop by apache.

the class TracerConfigurationManager method removeSpanReceiver.

public synchronized void removeSpanReceiver(long spanReceiverId) throws IOException {
    SpanReceiver[] receivers = TracerPool.getGlobalTracerPool().getReceivers();
    for (SpanReceiver receiver : receivers) {
        if (receiver.getId() == spanReceiverId) {
            TracerPool.getGlobalTracerPool().removeAndCloseReceiver(receiver);
            LOG.info("Successfully removed SpanReceiver " + spanReceiverId + " with class " + receiver.getClass().getName());
            return;
        }
    }
    throw new IOException("There is no span receiver with id " + spanReceiverId);
}
Also used : SpanReceiver(org.apache.htrace.core.SpanReceiver) IOException(java.io.IOException)

Aggregations

SpanReceiver (org.apache.htrace.core.SpanReceiver)3 IOException (java.io.IOException)1 ConfigurationPair (org.apache.hadoop.tracing.SpanReceiverInfo.ConfigurationPair)1 TracerPool (org.apache.htrace.core.TracerPool)1