Search in sources :

Example 1 with ConfigurationPair

use of org.apache.hadoop.tracing.SpanReceiverInfo.ConfigurationPair in project hadoop by apache.

the class TraceAdminProtocolTranslatorPB method addSpanReceiver.

@Override
public long addSpanReceiver(SpanReceiverInfo info) throws IOException {
    try {
        AddSpanReceiverRequestProto.Builder bld = AddSpanReceiverRequestProto.newBuilder();
        bld.setClassName(info.getClassName());
        for (ConfigurationPair configPair : info.configPairs) {
            ConfigPair tuple = ConfigPair.newBuilder().setKey(configPair.getKey()).setValue(configPair.getValue()).build();
            bld.addConfig(tuple);
        }
        AddSpanReceiverResponseProto resp = rpcProxy.addSpanReceiver(null, bld.build());
        return resp.getId();
    } catch (ServiceException e) {
        throw ProtobufHelper.getRemoteException(e);
    }
}
Also used : ConfigPair(org.apache.hadoop.tracing.TraceAdminPB.ConfigPair) AddSpanReceiverResponseProto(org.apache.hadoop.tracing.TraceAdminPB.AddSpanReceiverResponseProto) ServiceException(com.google.protobuf.ServiceException) AddSpanReceiverRequestProto(org.apache.hadoop.tracing.TraceAdminPB.AddSpanReceiverRequestProto) ConfigurationPair(org.apache.hadoop.tracing.SpanReceiverInfo.ConfigurationPair)

Example 2 with ConfigurationPair

use of org.apache.hadoop.tracing.SpanReceiverInfo.ConfigurationPair 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 ConfigurationPair

use of org.apache.hadoop.tracing.SpanReceiverInfo.ConfigurationPair in project hadoop by apache.

the class TestTraceUtils method testExtraConfig.

@Test
public void testExtraConfig() {
    String key = "test.extra.config";
    String oldValue = "old value";
    String newValue = "new value";
    Configuration conf = new Configuration();
    conf.set(TEST_PREFIX + key, oldValue);
    LinkedList<ConfigurationPair> extraConfig = new LinkedList<ConfigurationPair>();
    extraConfig.add(new ConfigurationPair(TEST_PREFIX + key, newValue));
    HTraceConfiguration wrapped = TraceUtils.wrapHadoopConf(TEST_PREFIX, conf, extraConfig);
    assertEquals(newValue, wrapped.get(key));
}
Also used : HTraceConfiguration(org.apache.htrace.core.HTraceConfiguration) Configuration(org.apache.hadoop.conf.Configuration) HTraceConfiguration(org.apache.htrace.core.HTraceConfiguration) LinkedList(java.util.LinkedList) ConfigurationPair(org.apache.hadoop.tracing.SpanReceiverInfo.ConfigurationPair) Test(org.junit.Test)

Aggregations

ConfigurationPair (org.apache.hadoop.tracing.SpanReceiverInfo.ConfigurationPair)3 ServiceException (com.google.protobuf.ServiceException)1 LinkedList (java.util.LinkedList)1 Configuration (org.apache.hadoop.conf.Configuration)1 AddSpanReceiverRequestProto (org.apache.hadoop.tracing.TraceAdminPB.AddSpanReceiverRequestProto)1 AddSpanReceiverResponseProto (org.apache.hadoop.tracing.TraceAdminPB.AddSpanReceiverResponseProto)1 ConfigPair (org.apache.hadoop.tracing.TraceAdminPB.ConfigPair)1 HTraceConfiguration (org.apache.htrace.core.HTraceConfiguration)1 SpanReceiver (org.apache.htrace.core.SpanReceiver)1 Test (org.junit.Test)1