HBASE-23892 SecureTestCluster should allow its subclasses to pass their Class referen...
[hbase.git] / hbase-common / src / main / java / org / apache / hadoop / hbase / trace / HBaseHTraceConfiguration.java
blob03d03d9fe4e6b39b48238013be0df05af1dc6613
1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 package org.apache.hadoop.hbase.trace;
21 import org.apache.hadoop.conf.Configuration;
22 import org.apache.htrace.core.HTraceConfiguration;
23 import org.apache.yetus.audience.InterfaceAudience;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
27 @InterfaceAudience.Private
28 public class HBaseHTraceConfiguration extends HTraceConfiguration {
29 private static final Logger LOG = LoggerFactory.getLogger(HBaseHTraceConfiguration.class);
31 public static final String KEY_PREFIX = "hbase.htrace.";
33 private Configuration conf;
35 private void handleDeprecation(String key) {
36 String oldKey = "hbase." + key;
37 String newKey = KEY_PREFIX + key;
38 String oldValue = conf.get(oldKey);
39 if (oldValue != null) {
40 LOG.warn("Warning: using deprecated configuration key " + oldKey +
41 ". Please use " + newKey + " instead.");
42 String newValue = conf.get(newKey);
43 if (newValue == null) {
44 conf.set(newKey, oldValue);
45 } else {
46 LOG.warn("Conflicting values for " + newKey + " and " + oldKey +
47 ". Using " + newValue);
52 public HBaseHTraceConfiguration(Configuration conf) {
53 this.conf = conf;
54 handleDeprecation("local-file-span-receiver.path");
55 handleDeprecation("local-file-span-receiver.capacity");
56 handleDeprecation("sampler.frequency");
57 handleDeprecation("sampler.fraction");
58 handleDeprecation("zipkin.collector-hostname");
59 handleDeprecation("zipkin.collector-port");
60 handleDeprecation("zipkin.num-threads");
61 handleDeprecation("zipkin.traced-service-hostname");
62 handleDeprecation("zipkin.traced-service-port");
65 @Override
66 public String get(String key) {
67 return conf.get(KEY_PREFIX + key);
70 @Override
71 public String get(String key, String defaultValue) {
72 return conf.get(KEY_PREFIX + key,defaultValue);
76 @Override
77 public boolean getBoolean(String key, boolean defaultValue) {
78 return conf.getBoolean(KEY_PREFIX + key, defaultValue);