本文整理汇总了Java中org.apache.htrace.core.HTraceConfiguration.fromMap方法的典型用法代码示例。如果您正苦于以下问题:Java HTraceConfiguration.fromMap方法的具体用法?Java HTraceConfiguration.fromMap怎么用?Java HTraceConfiguration.fromMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.htrace.core.HTraceConfiguration
的用法示例。
在下文中一共展示了HTraceConfiguration.fromMap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
}
示例2: 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();
}
}
示例3: 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();
}
}
示例4: 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();
}
}
示例5: 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();
}
}
示例6: 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();
}
}
示例7: testRestThreadHandlesFlushFailure
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 testRestThreadHandlesFlushFailure() 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, "testRestThreadHandlesFlushFailure");
put(Conf.ADDRESS_KEY, ht.getHttpAddr());
put(Conf.PACKED_KEY, "false");
}});
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();
}
}
示例8: testPackedRetryAfterFlushError
import org.apache.htrace.core.HTraceConfiguration; //导入方法依赖的package包/类
/**
* Test that the packed code works when performing multiple flushes.
*/
@Test(timeout = 60000)
public void testPackedRetryAfterFlushError() 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, "testPackedRetryAfterFlushError");
put(Conf.ADDRESS_KEY, ht.getHrpcAddr());
put(Conf.PACKED_KEY, "true");
put(Conf.MAX_FLUSH_INTERVAL_MS_KEY, "1000");
put(Conf.FLUSH_RETRY_DELAYS_KEY, "100,100,100,100,100,100,100");
}});
TestInjectFlushFaults injector = new TestInjectFlushFaults(5);
HTracedSpanReceiver rcvr = new HTracedSpanReceiver(conf, injector);
Span[] spans = TestUtil.randomSpans(rand, 3);
for (Span span : spans) {
rcvr.receiveSpan(span);
}
waitForSpans(ht, spans);
rcvr.close();
} finally {
ht.destroy();
}
}
示例9: testRestRetryAfterFlushError
import org.apache.htrace.core.HTraceConfiguration; //导入方法依赖的package包/类
/**
* Test that the REST code works when performing multiple flushes.
*/
@Test(timeout = 60000)
public void testRestRetryAfterFlushError() 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, "testRestRetryAfterFlushError");
put(Conf.ADDRESS_KEY, ht.getHttpAddr());
put(Conf.PACKED_KEY, "false");
put(Conf.MAX_FLUSH_INTERVAL_MS_KEY, "1000");
put(Conf.FLUSH_RETRY_DELAYS_KEY, "100,100,100,100,100,100,100");
}});
TestInjectFlushFaults injector = new TestInjectFlushFaults(5);
HTracedSpanReceiver rcvr = new HTracedSpanReceiver(conf, injector);
Span[] spans = TestUtil.randomSpans(rand, 3);
for (Span span : spans) {
rcvr.receiveSpan(span);
}
waitForSpans(ht, spans);
rcvr.close();
} finally {
ht.destroy();
}
}
示例10: getHTraceConfiguration
import org.apache.htrace.core.HTraceConfiguration; //导入方法依赖的package包/类
private static HTraceConfiguration getHTraceConfiguration(Properties props) {
final Map<String, String> filteredProperties = new HashMap<>();
for (String key : props.stringPropertyNames()) {
if (key.startsWith(HTRACE_KEY_PREFIX)) {
filteredProperties.put(key.substring(HTRACE_KEY_PREFIX.length()), props.getProperty(key));
}
}
return HTraceConfiguration.fromMap(filteredProperties);
}
示例11: testWriteToDroppedSpansLog
import org.apache.htrace.core.HTraceConfiguration; //导入方法依赖的package包/类
/**
* Test that we can write to the dropped spans log.
*/
@Test(timeout = 60000)
public void testWriteToDroppedSpansLog() throws Exception {
final String logPath = new File(
tempDir.toFile(), "testWriteToDroppedSpansLog").getAbsolutePath();
HTraceConfiguration conf = HTraceConfiguration.fromMap(
new HashMap<String, String>() {{
put(Conf.ADDRESS_KEY, "127.0.0.1:8080");
put(TracerId.TRACER_ID_KEY, "testWriteToDroppedSpansLog");
put(Conf.DROPPED_SPANS_LOG_PATH_KEY, logPath);
put(Conf.DROPPED_SPANS_LOG_MAX_SIZE_KEY, "128");
}});
HTracedSpanReceiver rcvr = new HTracedSpanReceiver(conf);
try {
final String LINE1 = "This is a test of the dropped spans log.";
rcvr.appendToDroppedSpansLog(LINE1 + "\n");
final String LINE2 = "These lines should appear in the log.";
rcvr.appendToDroppedSpansLog(LINE2 + "\n");
try {
rcvr.appendToDroppedSpansLog("This line won't be written because we're " +
"out of space.");
Assert.fail("expected append to fail because of lack of space");
} catch (IOException e) {
// ignore
}
List<String> lines =
Files.readAllLines(Paths.get(logPath), StandardCharsets.UTF_8);
Assert.assertEquals(2, lines.size());
Assert.assertEquals(LINE1, lines.get(0).substring(25));
Assert.assertEquals(LINE2, lines.get(1).substring(25));
} finally {
rcvr.close();
}
}
示例12: testSpansDroppedBecauseOfUnreachableHTraced
import org.apache.htrace.core.HTraceConfiguration; //导入方法依赖的package包/类
/**
* Test that we write to the dropped spans log when htraced is unreachable.
*/
@Test(timeout = 60000)
public void testSpansDroppedBecauseOfUnreachableHTraced() throws Exception {
final String logPath = new File(tempDir.toFile(),
"testSpansDroppedBecauseOfUnreachableHTraced").getAbsolutePath();
// Open a local socket. We know that nobody is listening on this socket, so
// all attempts to send to it will fail.
final ServerSocket serverSocket = new ServerSocket(0);
HTracedSpanReceiver rcvr = null;
try {
HTraceConfiguration conf = HTraceConfiguration.fromMap(
new HashMap<String, String>() {{
put(Conf.ADDRESS_KEY, "127.0.0.1:" + serverSocket.getLocalPort());
put(TracerId.TRACER_ID_KEY,
"testSpansDroppedBecauseOfUnreachableHTraced");
put(Conf.DROPPED_SPANS_LOG_PATH_KEY, logPath);
put(Conf.DROPPED_SPANS_LOG_MAX_SIZE_KEY, "78");
put(Conf.CONNECT_TIMEOUT_MS_KEY, "1");
put(Conf.IO_TIMEOUT_MS_KEY, "1");
put(Conf.FLUSH_RETRY_DELAYS_KEY, "1,1");
}});
rcvr = new HTracedSpanReceiver(conf);
rcvr.receiveSpan(new MilliSpan.Builder().
begin(123).end(456).description("FooBar").build());
HTracedSpanReceiver tmpRcvr = rcvr;
rcvr = null;
tmpRcvr.close();
List<String> lines =
Files.readAllLines(Paths.get(logPath), StandardCharsets.UTF_8);
Assert.assertTrue(lines.size() >= 1);
Assert.assertTrue(lines.get(0).contains("Failed to flush "));
} finally {
serverSocket.close();
if (rcvr != null) {
rcvr.close();
}
}
}
示例13: testFullBufferCausesPackedThreadTrigger
import org.apache.htrace.core.HTraceConfiguration; //导入方法依赖的package包/类
/**
* Test that filling up one of the buffers causes us to trigger a flush and
* start using the other buffer, when using PackedBufferManager.
* This also tests that PackedBufferManager can correctly handle a buffer
* getting full.
*/
@Test(timeout = 60000)
public void testFullBufferCausesPackedThreadTrigger() 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,
"testFullBufferCausesPackedThreadTrigger");
put(Conf.ADDRESS_KEY, ht.getHrpcAddr());
put(Conf.PACKED_KEY, "true");
put(Conf.BUFFER_SIZE_KEY, "16384");
put(Conf.BUFFER_SEND_TRIGGER_FRACTION_KEY, "0.95");
}});
TestHandleContentLengthTriggerInjector injector =
new TestHandleContentLengthTriggerInjector();
HTracedSpanReceiver rcvr = new HTracedSpanReceiver(conf, injector);
Span[] spans = TestUtil.randomSpans(rand, 47);
for (Span span : spans) {
rcvr.receiveSpan(span);
}
Assert.assertTrue("The wakePostSpansThread should have been " +
"triggered by the spans added so far. " +
"contentLengthOnTrigger = " + injector.getContentLengthOnTrigger(),
injector.getContentLengthOnTrigger() > 16000);
injector.threadStartSem.release();
rcvr.close();
waitForSpans(ht, spans, 45);
} finally {
ht.destroy();
}
}
示例14: testFullBufferCausesRestThreadTrigger
import org.apache.htrace.core.HTraceConfiguration; //导入方法依赖的package包/类
/**
* Test that filling up one of the buffers causes us to trigger a flush and
* start using the other buffer, when using RestBufferManager.
* This also tests that RestBufferManager can correctly handle a buffer
* getting full.
*/
@Test(timeout = 60000)
public void testFullBufferCausesRestThreadTrigger() 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,
"testFullBufferCausesRestThreadTrigger");
put(Conf.ADDRESS_KEY, ht.getHttpAddr());
put(Conf.PACKED_KEY, "false");
put(Conf.BUFFER_SIZE_KEY, "16384");
put(Conf.BUFFER_SEND_TRIGGER_FRACTION_KEY, "0.95");
}});
TestHandleContentLengthTriggerInjector injector =
new TestHandleContentLengthTriggerInjector();
HTracedSpanReceiver rcvr = new HTracedSpanReceiver(conf, injector);
Span[] spans = TestUtil.randomSpans(rand, 34);
for (Span span : spans) {
rcvr.receiveSpan(span);
}
Assert.assertTrue("The wakePostSpansThread should have been " +
"triggered by the spans added so far. " +
"contentLengthOnTrigger = " + injector.getContentLengthOnTrigger(),
injector.getContentLengthOnTrigger() > 16000);
injector.threadStartSem.release();
rcvr.close();
waitForSpans(ht, spans, 33);
} finally {
ht.destroy();
}
}
示例15: testMultiplePackedFlushes
import org.apache.htrace.core.HTraceConfiguration; //导入方法依赖的package包/类
/**
* Test that the packed code works when performing multiple flushes.
*/
@Test(timeout = 60000)
public void testMultiplePackedFlushes() 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, "testMultiplePackedFlushes");
put(Conf.ADDRESS_KEY, ht.getHrpcAddr());
put(Conf.PACKED_KEY, "true");
put(Conf.MAX_FLUSH_INTERVAL_MS_KEY, "1");
}});
WaitForFlushes injector = new WaitForFlushes(5);
HTracedSpanReceiver rcvr = new HTracedSpanReceiver(conf, injector);
Span[] spans = TestUtil.randomSpans(rand, 3);
while (true) {
for (Span span : spans) {
rcvr.receiveSpan(span);
}
if (injector.flushSem.availablePermits() >= 0) {
break;
}
Thread.sleep(1);
}
waitForSpans(ht, spans, 3);
rcvr.close();
} finally {
ht.destroy();
}
}