本文整理汇总了Java中org.apache.htrace.core.HTraceConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java HTraceConfiguration类的具体用法?Java HTraceConfiguration怎么用?Java HTraceConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HTraceConfiguration类属于org.apache.htrace.core包,在下文中一共展示了HTraceConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: HBaseSpanReceiver
import org.apache.htrace.core.HTraceConfiguration; //导入依赖的package包/类
public HBaseSpanReceiver(HTraceConfiguration conf) {
this.queue = new ArrayBlockingQueue<Span>(1000);
this.hconf = HBaseConfiguration.create();
this.table = Bytes.toBytes(conf.get(TABLE_KEY, DEFAULT_TABLE));
this.cf = Bytes.toBytes(conf.get(COLUMNFAMILY_KEY, DEFAULT_COLUMNFAMILY));
this.icf = Bytes.toBytes(conf.get(INDEXFAMILY_KEY, DEFAULT_INDEXFAMILY));
this.maxSpanBatchSize = conf.getInt(MAX_SPAN_BATCH_SIZE_KEY,
DEFAULT_MAX_SPAN_BATCH_SIZE);
String quorum = conf.get(COLLECTOR_QUORUM_KEY, DEFAULT_COLLECTOR_QUORUM);
hconf.set(HConstants.ZOOKEEPER_QUORUM, quorum);
String znodeParent = conf.get(ZOOKEEPER_ZNODE_PARENT_KEY, DEFAULT_ZOOKEEPER_ZNODE_PARENT);
hconf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, znodeParent);
int clientPort = conf.getInt(ZOOKEEPER_CLIENT_PORT_KEY, DEFAULT_ZOOKEEPER_CLIENT_PORT);
hconf.setInt(HConstants.ZOOKEEPER_CLIENT_PORT, clientPort);
// If there are already threads runnnig tear them down.
if (this.service != null) {
this.service.shutdownNow();
this.service = null;
}
int numThreads = conf.getInt(NUM_THREADS_KEY, DEFAULT_NUM_THREADS);
this.service = Executors.newFixedThreadPool(numThreads, tf);
for (int i = 0; i < numThreads; i++) {
this.service.submit(new WriteSpanRunnable());
}
}
示例2: configure
import org.apache.htrace.core.HTraceConfiguration; //导入依赖的package包/类
private void configure(HTraceConfiguration conf) {
this.conf = conf;
// initialize the endpoint. This endpoint is used while writing the Span.
initConverter();
int numThreads = conf.getInt(NUM_THREAD_KEY, DEFAULT_NUM_THREAD);
// If there are already threads runnnig tear them down.
if (this.service != null) {
this.service.shutdownNow();
this.service = null;
}
this.service = Executors.newFixedThreadPool(numThreads, tf);
for (int i = 0; i < numThreads; i++) {
this.service.submit(new WriteSpanRunnable());
}
}
示例3: newProducer
import org.apache.htrace.core.HTraceConfiguration; //导入依赖的package包/类
public Producer<byte[], byte[]> newProducer(HTraceConfiguration conf) {
// https://kafka.apache.org/083/configuration.html
Properties producerProps = new Properties();
// Essential producer configurations
producerProps.put("metadata.broker.list",
conf.get("zipkin.kafka.metadata.broker.list", "localhost:9092"));
producerProps.put("request.required.acks",
conf.get("zipkin.kafka.request.required.acks", "0"));
producerProps.put("producer.type",
conf.get("zipkin.kafka.producer.type", "async"));
producerProps.put("serializer.class",
conf.get("zipkin.kafka.serializer.class", "kafka.serializer.DefaultEncoder"));
producerProps.put("compression.codec",
conf.get("zipkin.kafka.compression.codec", "1"));
Producer<byte[], byte[]> producer = new Producer<>(new ProducerConfig(producerProps));
LOG.info("Connected to Kafka transport \n" + producerProps);
return producer;
}
示例4: open
import org.apache.htrace.core.HTraceConfiguration; //导入依赖的package包/类
@Override
public void open(HTraceConfiguration conf) throws IOException {
if (!isOpen()) {
checkDeprecation(conf, DEPRECATED_HOSTNAME_KEY, HOSTNAME_KEY);
checkDeprecation(conf, DEPRECATED_PORT_KEY, PORT_KEY);
String collectorHostname = conf.get(HOSTNAME_KEY,
conf.get(DEPRECATED_HOSTNAME_KEY,
DEFAULT_COLLECTOR_HOSTNAME));
int collectorPort = conf.getInt(PORT_KEY,
conf.getInt(DEPRECATED_PORT_KEY,
DEFAULT_COLLECTOR_PORT));
scribe = newScribe(collectorHostname, collectorPort);
LOG.info("Opened transport " + collectorHostname + ":" + collectorPort);
} else {
LOG.warn("Attempted to open an already opened transport");
}
}
示例5: configure
import org.apache.htrace.core.HTraceConfiguration; //导入依赖的package包/类
private void configure (HTraceConfiguration conf) {
// Read configuration
int numThreads = conf.getInt(NUM_THREADS_KEY, DEFAULT_NUM_THREADS);
this.flumeHostName = conf.get(FLUME_HOSTNAME_KEY, DEFAULT_FLUME_HOSTNAME);
this.flumePort = conf.getInt(FLUME_PORT_KEY, 0);
if (this.flumePort == 0) {
throw new IllegalArgumentException(FLUME_PORT_KEY + " is required in configuration.");
}
this.maxSpanBatchSize = conf.getInt(FLUME_BATCHSIZE_KEY, DEFAULT_FLUME_BATCHSIZE);
// Initialize executors
// If there are already threads running tear them down.
if (this.service != null) {
this.service.shutdownNow();
this.service = null;
}
this.service = Executors.newFixedThreadPool(numThreads, tf);
for (int i = 0; i < numThreads; i++) {
this.service.submit(new WriteSpanRunnable());
}
}
示例6: HTracedSpanReceiver
import org.apache.htrace.core.HTraceConfiguration; //导入依赖的package包/类
HTracedSpanReceiver(HTraceConfiguration c,
FaultInjector faultInjector) throws Exception {
this.faultInjector = faultInjector;
this.conf = new Conf(c);
if (this.conf.packed) {
for (int i = 0; i < bufferManager.length; i++) {
bufferManager[i] = new PackedBufferManager(conf);
}
} else {
for (int i = 0; i < bufferManager.length; i++) {
bufferManager[i] = new RestBufferManager(conf);
}
}
this.flushErrorLog = new RateLimitedLogger(LOG, conf.errorLogPeriodMs);
this.spanDropLog = new RateLimitedLogger(LOG, conf.errorLogPeriodMs);
this.thread = new PostSpansThread();
LOG.debug("Created new HTracedSpanReceiver with " + conf.toString());
}
示例7: getBoundedLong
import org.apache.htrace.core.HTraceConfiguration; //导入依赖的package包/类
private static long getBoundedLong(final HTraceConfiguration conf,
String key, long defaultValue, long minValue, long maxValue) {
String strVal = conf.get(key, Long.toString(defaultValue));
long val = 0;
try {
val = Long.parseLong(strVal);
} catch (NumberFormatException nfe) {
throw new IllegalArgumentException("Bad value for '" + key +
"': should be long");
}
if (val < minValue) {
LOG.warn("Can't set " + key + " to " + val + ". Using minimum value " +
"of " + minValue + " instead.");
return minValue;
} else if (val > maxValue) {
LOG.warn("Can't set " + key + " to " + val + ". Using maximum value " +
"of " + maxValue + " instead.");
return maxValue;
}
return val;
}
示例8: getBoundedDouble
import org.apache.htrace.core.HTraceConfiguration; //导入依赖的package包/类
private static double getBoundedDouble(final HTraceConfiguration conf,
String key, double defaultValue, double minValue, double maxValue) {
String strVal = conf.get(key, Double.toString(defaultValue));
double val = 0;
try {
val = Double.parseDouble(strVal);
} catch (NumberFormatException nfe) {
throw new IllegalArgumentException("Bad value for '" + key +
"': should be double");
}
if (val < minValue) {
LOG.warn("Can't set " + key + " to " + val + ". Using minimum value " +
"of " + minValue + " instead.");
return minValue;
}
if (val > maxValue) {
LOG.warn("Can't set " + key + " to " + val + ". Using maximum value " +
"of " + maxValue + " instead.");
return maxValue;
}
return val;
}
示例9: testParseHostPort
import org.apache.htrace.core.HTraceConfiguration; //导入依赖的package包/类
@Test(timeout = 60000)
public void testParseHostPort() throws Exception {
InetSocketAddress addr = new Conf(
HTraceConfiguration.fromKeyValuePairs(
Conf.ADDRESS_KEY, "example.com:8080")).endpoint;
Assert.assertEquals("example.com", addr.getHostName());
Assert.assertEquals(8080, addr.getPort());
addr = new Conf(
HTraceConfiguration.fromKeyValuePairs(
Conf.ADDRESS_KEY, "127.0.0.1:8081")).endpoint;
Assert.assertEquals("127.0.0.1", addr.getHostName());
Assert.assertEquals(8081, addr.getPort());
addr = new Conf(
HTraceConfiguration.fromKeyValuePairs(
Conf.ADDRESS_KEY, "[ff02:0:0:0:0:0:0:12]:9096")).endpoint;
Assert.assertEquals("ff02:0:0:0:0:0:0:12", addr.getHostName());
Assert.assertEquals(9096, addr.getPort());
}
示例10: testDisableDroppedSpansLog
import org.apache.htrace.core.HTraceConfiguration; //导入依赖的package包/类
/**
* Test that we can disable the dropped spans log.
*/
@Test(timeout = 60000)
public void testDisableDroppedSpansLog() throws Exception {
HTraceConfiguration conf = HTraceConfiguration.fromMap(
new HashMap<String, String>() {{
put(Conf.ADDRESS_KEY, "127.0.0.1:8080");
put(TracerId.TRACER_ID_KEY, "testAppendToDroppedSpansLog");
put(Conf.DROPPED_SPANS_LOG_PATH_KEY, "/");
put(Conf.DROPPED_SPANS_LOG_MAX_SIZE_KEY, "0");
}});
HTracedSpanReceiver rcvr = new HTracedSpanReceiver(conf);
try {
rcvr.appendToDroppedSpansLog("this won't get written");
} finally {
rcvr.close();
}
}
示例11: testSendSpansViaPacked
import org.apache.htrace.core.HTraceConfiguration; //导入依赖的package包/类
/**
* Test that we can send spans via the HRPC interface.
*/
@Test(timeout = 10000) //60000)
public void testSendSpansViaPacked() throws Exception {
final Random rand = new Random(123);
final HTracedProcess ht = new HTracedProcess.Builder().build();
try {
HTraceConfiguration conf = HTraceConfiguration.fromMap(
new HashMap<String, String>() {{
put(TracerId.TRACER_ID_KEY, "testSendSpansViaPacked");
put(Conf.ADDRESS_KEY, ht.getHrpcAddr());
put(Conf.PACKED_KEY, "true");
put(Conf.MAX_FLUSH_INTERVAL_MS_KEY, "100");
put(Conf.ERROR_LOG_PERIOD_MS_KEY, "0");
}});
HTracedSpanReceiver rcvr = new HTracedSpanReceiver(conf);
Span[] spans = TestUtil.randomSpans(rand, 10);
for (Span span : spans) {
rcvr.receiveSpan(span);
}
waitForSpans(ht, spans);
rcvr.close();
} finally {
ht.destroy();
}
}
示例12: testSendSpansViaPackedAndClose
import org.apache.htrace.core.HTraceConfiguration; //导入依赖的package包/类
/**
* Test that when the SpanReceiver is closed, we send any spans we have
* buffered via the HRPC interface.
*/
@Test(timeout = 60000)
public void testSendSpansViaPackedAndClose() throws Exception {
final Random rand = new Random(456);
final HTracedProcess ht = new HTracedProcess.Builder().build();
try {
HTraceConfiguration conf = HTraceConfiguration.fromMap(
new HashMap<String, String>() {{
put(TracerId.TRACER_ID_KEY, "testSendSpansViaPackedAndClose");
put(Conf.ADDRESS_KEY, ht.getHrpcAddr());
put(Conf.PACKED_KEY, "true");
put(Conf.MAX_FLUSH_INTERVAL_MS_KEY, "60000");
}});
HTracedSpanReceiver rcvr = new HTracedSpanReceiver(conf);
Span[] spans = TestUtil.randomSpans(rand, 10);
for (Span span : spans) {
rcvr.receiveSpan(span);
}
rcvr.close();
waitForSpans(ht, spans);
} finally {
ht.destroy();
}
}
示例13: testSendSpansViaRest
import org.apache.htrace.core.HTraceConfiguration; //导入依赖的package包/类
/**
* Test that we can send spans via the REST interface.
*/
@Test(timeout = 60000)
public void testSendSpansViaRest() throws Exception {
final Random rand = new Random(789);
final HTracedProcess ht = new HTracedProcess.Builder().build();
try {
HTraceConfiguration conf = HTraceConfiguration.fromMap(
new HashMap<String, String>() {{
put(TracerId.TRACER_ID_KEY, "testSendSpansViaRest");
put(Conf.ADDRESS_KEY, ht.getHttpAddr());
put(Conf.PACKED_KEY, "false");
put(Conf.MAX_FLUSH_INTERVAL_MS_KEY, "100");
}});
HTracedSpanReceiver rcvr = new HTracedSpanReceiver(conf);
Span[] spans = TestUtil.randomSpans(rand, 10);
for (Span span : spans) {
rcvr.receiveSpan(span);
}
waitForSpans(ht, spans);
rcvr.close();
} finally {
ht.destroy();
}
}
示例14: testSendSpansViaRestAndClose
import org.apache.htrace.core.HTraceConfiguration; //导入依赖的package包/类
/**
* Test that when the SpanReceiver is closed, we send any spans we have
* buffered via the REST interface.
*/
@Test(timeout = 60000)
public void testSendSpansViaRestAndClose() throws Exception {
final Random rand = new Random(321);
final HTracedProcess ht = new HTracedProcess.Builder().build();
try {
HTraceConfiguration conf = HTraceConfiguration.fromMap(
new HashMap<String, String>() {{
put(TracerId.TRACER_ID_KEY, "testSendSpansViaRestAndClose");
put(Conf.ADDRESS_KEY, ht.getHttpAddr());
put(Conf.PACKED_KEY, "false");
put(Conf.MAX_FLUSH_INTERVAL_MS_KEY, "60000");
}});
HTracedSpanReceiver rcvr = new HTracedSpanReceiver(conf);
Span[] spans = TestUtil.randomSpans(rand, 10);
for (Span span : spans) {
rcvr.receiveSpan(span);
}
rcvr.close();
waitForSpans(ht, spans);
} finally {
ht.destroy();
}
}
示例15: testPackedThreadHandlesFlushFailure
import org.apache.htrace.core.HTraceConfiguration; //导入依赖的package包/类
/**
* Test that even if the flush fails, the system stays stable and we can
* still close the span receiver.
*/
@Test(timeout = 60000)
public void testPackedThreadHandlesFlushFailure() throws Exception {
final Random rand = new Random(321);
final HTracedProcess ht = new HTracedProcess.Builder().build();
try {
HTraceConfiguration conf = HTraceConfiguration.fromMap(
new HashMap<String, String>() {{
put(TracerId.TRACER_ID_KEY, "testPackedThreadHandlesFlushFailure");
put(Conf.ADDRESS_KEY, ht.getHrpcAddr());
put(Conf.PACKED_KEY, "true");
}});
TestInjectFlushFaults injector = new TestInjectFlushFaults(Long.MAX_VALUE);
HTracedSpanReceiver rcvr = new HTracedSpanReceiver(conf, injector);
Span[] spans = TestUtil.randomSpans(rand, 15);
for (Span span : spans) {
rcvr.receiveSpan(span);
}
rcvr.close();
} finally {
ht.destroy();
}
}