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(); }
private SpanReceiver newSpanReceiver() { if ((className == null) || className.isEmpty()) { throwError("No span receiver class specified."); cls = classLoader.loadClass(str); } catch (ClassNotFoundException e) { throwError("Cannot find SpanReceiver class " + str); ctor = cls.getConstructor(HTraceConfiguration.class); } catch (NoSuchMethodException e) { throwError("Cannot find a constructor for class " + str + "which takes an HTraceConfiguration."); receiver = ctor.newInstance(conf); } catch (ReflectiveOperationException e) { throwError("Reflection error when constructing " + str + ".", e); } catch (Throwable t) { throwError("NewInstance error when constructing " + str + ".", t);
private SpanReceiver newSpanReceiver() { if ((className == null) || className.isEmpty()) { throwError("No span receiver class specified."); cls = classLoader.loadClass(str); } catch (ClassNotFoundException e) { throwError("Cannot find SpanReceiver class " + str); ctor = cls.getConstructor(HTraceConfiguration.class); } catch (NoSuchMethodException e) { throwError("Cannot find a constructor for class " + str + "which takes an HTraceConfiguration."); receiver = ctor.newInstance(conf); } catch (ReflectiveOperationException e) { throwError("Reflection error when constructing " + str + ".", e); } catch (Throwable t) { throwError("NewInstance error when constructing " + str + ".", t);
SpanReceiver receiver = new SpanReceiver.Builder(conf). className(className). classLoader(classLoader). build(); addReceiver(receiver); return receiver;
private SpanReceiver newSpanReceiver() { if ((className == null) || className.isEmpty()) { throwError("No span receiver class specified."); cls = classLoader.loadClass(str); } catch (ClassNotFoundException e) { throwError("Cannot find SpanReceiver class " + str); ctor = cls.getConstructor(HTraceConfiguration.class); } catch (NoSuchMethodException e) { throwError("Cannot find a constructor for class " + str + "which takes an HTraceConfiguration."); receiver = ctor.newInstance(conf); } catch (ReflectiveOperationException e) { throwError("Reflection error when constructing " + str + ".", e); } catch (Throwable t) { throwError("NewInstance error when constructing " + str + ".", t);
SpanReceiver receiver = new SpanReceiver.Builder(conf). className(className). classLoader(classLoader). build(); addReceiver(receiver); return receiver;
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(); }
/** * Given a SpanReceiver class name, return the existing instance of that span * receiver, if possible; otherwise, invoke the callable to create a new * instance. * * @param className The span receiver class name. * @param conf The HTrace configuration. * @param classLoader The class loader to use. * * @return The SpanReceiver. */ public synchronized SpanReceiver loadReceiverType(String className, HTraceConfiguration conf, ClassLoader classLoader) { SpanReceiver[] receivers = curReceivers; for (SpanReceiver receiver : receivers) { if (receiver.getClass().getName().equals(className)) { LOG.trace(toString() + ": returning a reference to receiver " + receiver.toString()); return receiver; } } LOG.trace(toString() + ": creating a new SpanReceiver of type " + className); SpanReceiver receiver = new SpanReceiver.Builder(conf). className(className). classLoader(classLoader). build(); addReceiver(receiver); return receiver; }
/** * Reads the names of classes specified in the {@code hbase.trace.spanreceiver.classes} property * and instantiates and registers them with the Tracer. * */ public void loadSpanReceivers() { String[] receiverNames = conf.getStrings(SPAN_RECEIVERS_CONF_KEY); if (receiverNames == null || receiverNames.length == 0) { return; } SpanReceiver.Builder builder = new SpanReceiver.Builder(new HBaseHTraceConfiguration(conf)); for (String className : receiverNames) { className = className.trim(); SpanReceiver receiver = builder.className(className).build(); if (receiver != null) { receivers.add(receiver); LOG.info("SpanReceiver " + className + " was loaded successfully."); } } for (SpanReceiver rcvr : receivers) { TraceUtil.addReceiver(rcvr); } }
/** * Reads the names of classes specified in the {@code hbase.trace.spanreceiver.classes} property * and instantiates and registers them with the Tracer. * */ public void loadSpanReceivers() { String[] receiverNames = conf.getStrings(SPAN_RECEIVERS_CONF_KEY); if (receiverNames == null || receiverNames.length == 0) { return; } SpanReceiver.Builder builder = new SpanReceiver.Builder(new HBaseHTraceConfiguration(conf)); for (String className : receiverNames) { className = className.trim(); SpanReceiver receiver = builder.className(className).build(); if (receiver != null) { receivers.add(receiver); LOG.info("SpanReceiver " + className + " was loaded successfully."); } } for (SpanReceiver rcvr : receivers) { TraceUtil.addReceiver(rcvr); } }
public static SpanReceiver startReceiver(Configuration conf) { return new SpanReceiver.Builder( new HBaseHTraceConfiguration(conf)).build(); }
public Builder(HTraceConfiguration conf) { this.conf = conf; reset(); }
public SpanReceiver build() { SpanReceiver spanReceiver = newSpanReceiver(); if (LOG.isTraceEnabled()) { LOG.trace("Created new span receiver of type " + spanReceiver.getClass().getName()); } return spanReceiver; }
public SpanReceiver build() { SpanReceiver spanReceiver = newSpanReceiver(); if (LOG.isTraceEnabled()) { LOG.trace("Created new span receiver of type " + spanReceiver.getClass().getName()); } return spanReceiver; }
public void addThenLoadReceiverType(String className) { TracerPool pool = new TracerPool(className); SpanReceiver receiver = new SpanReceiver.Builder(conf). className(className). build(); pool.addReceiver(receiver); assertTrue(receiver == pool.loadReceiverType(className, conf, loader)); } }
public SpanReceiver build() { SpanReceiver spanReceiver = newSpanReceiver(); if (LOG.isTraceEnabled()) { LOG.trace("Created new span receiver of type " + spanReceiver.getClass().getName()); } return spanReceiver; }
public Builder(HTraceConfiguration conf) { this.conf = conf; reset(); }
public Builder(HTraceConfiguration conf) { this.conf = conf; reset(); }
/** * Reads the names of classes specified in the {@code hbase.trace.spanreceiver.classes} property * and instantiates and registers them with the Tracer. * */ public void loadSpanReceivers() { String[] receiverNames = conf.getStrings(SPAN_RECEIVERS_CONF_KEY); if (receiverNames == null || receiverNames.length == 0) { return; } SpanReceiver.Builder builder = new SpanReceiver.Builder(new HBaseHTraceConfiguration(conf)); for (String className : receiverNames) { className = className.trim(); SpanReceiver receiver = builder.className(className).build(); if (receiver != null) { receivers.add(receiver); LOG.info("SpanReceiver " + className + " was loaded successfully."); } } for (SpanReceiver rcvr : receivers) { TraceUtil.addReceiver(rcvr); } }