1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.trace;
20
21 import org.apache.hadoop.conf.Configuration;
22 import org.apache.hadoop.hbase.classification.InterfaceAudience;
23 import org.apache.htrace.HTraceConfiguration;
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26
27 @InterfaceAudience.Private
28 public class HBaseHTraceConfiguration extends HTraceConfiguration {
29 private static final Log LOG =
30 LogFactory.getLog(HBaseHTraceConfiguration.class);
31
32 public static final String KEY_PREFIX = "hbase.htrace.";
33
34 private Configuration conf;
35
36 private void handleDeprecation(String key) {
37 String oldKey = "hbase." + key;
38 String newKey = KEY_PREFIX + key;
39 String oldValue = conf.get(oldKey);
40 if (oldValue != null) {
41 LOG.warn("Warning: using deprecated configuration key " + oldKey +
42 ". Please use " + newKey + " instead.");
43 String newValue = conf.get(newKey);
44 if (newValue == null) {
45 conf.set(newKey, oldValue);
46 } else {
47 LOG.warn("Conflicting values for " + newKey + " and " + oldKey +
48 ". Using " + newValue);
49 }
50 }
51 }
52
53 public HBaseHTraceConfiguration(Configuration conf) {
54 this.conf = conf;
55 handleDeprecation("local-file-span-receiver.path");
56 handleDeprecation("local-file-span-receiver.capacity");
57 handleDeprecation("sampler.frequency");
58 handleDeprecation("sampler.fraction");
59 handleDeprecation("zipkin.collector-hostname");
60 handleDeprecation("zipkin.collector-port");
61 handleDeprecation("zipkin.num-threads");
62 handleDeprecation("zipkin.traced-service-hostname");
63 handleDeprecation("zipkin.traced-service-port");
64 }
65
66 @Override
67 public String get(String key) {
68 return conf.get(KEY_PREFIX +key);
69 }
70
71 @Override
72 public String get(String key, String defaultValue) {
73 return conf.get(KEY_PREFIX + key,defaultValue);
74
75 }
76
77 @Override
78 public boolean getBoolean(String key, boolean defaultValue) {
79 return conf.getBoolean(KEY_PREFIX + key, defaultValue);
80 }
81 }