Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HADOOP-11498. Bump the version of HTrace to 3.1.0-incubating (Masatak…
…e Iwasaki via Colin P. McCabe)
- Loading branch information
Colin Patrick Mccabe
committed
Jan 31, 2015
1 parent
8dc59cb
commit 09ad9a8
Showing
34 changed files
with
219 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 0 additions & 53 deletions
53
...on-project/hadoop-common/src/main/java/org/apache/hadoop/tracing/TraceSamplerFactory.java
This file was deleted.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/tracing/TraceUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.hadoop.tracing; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
import org.apache.hadoop.classification.InterfaceAudience; | ||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.tracing.SpanReceiverInfo.ConfigurationPair; | ||
import org.apache.htrace.HTraceConfiguration; | ||
|
||
/** | ||
* This class provides utility functions for tracing. | ||
*/ | ||
@InterfaceAudience.Private | ||
public class TraceUtils { | ||
public static final String HTRACE_CONF_PREFIX = "hadoop.htrace."; | ||
private static List<ConfigurationPair> EMPTY = Collections.emptyList(); | ||
|
||
public static HTraceConfiguration wrapHadoopConf(final Configuration conf) { | ||
return wrapHadoopConf(conf, EMPTY); | ||
} | ||
|
||
public static HTraceConfiguration wrapHadoopConf(final Configuration conf, | ||
List<ConfigurationPair> extraConfig) { | ||
final HashMap<String, String> extraMap = new HashMap<String, String>(); | ||
for (ConfigurationPair pair : extraConfig) { | ||
extraMap.put(pair.getKey(), pair.getValue()); | ||
} | ||
return new HTraceConfiguration() { | ||
@Override | ||
public String get(String key) { | ||
if (extraMap.containsKey(key)) { | ||
return extraMap.get(key); | ||
} | ||
return conf.get(HTRACE_CONF_PREFIX + key, ""); | ||
} | ||
|
||
@Override | ||
public String get(String key, String defaultValue) { | ||
if (extraMap.containsKey(key)) { | ||
return extraMap.get(key); | ||
} | ||
return conf.get(HTRACE_CONF_PREFIX + key, defaultValue); | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...-common-project/hadoop-common/src/test/java/org/apache/hadoop/tracing/TestTraceUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.hadoop.tracing; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import java.util.LinkedList; | ||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.tracing.SpanReceiverInfo.ConfigurationPair; | ||
import org.apache.htrace.HTraceConfiguration; | ||
import org.junit.Test; | ||
|
||
public class TestTraceUtils { | ||
@Test | ||
public void testWrappedHadoopConf() { | ||
String key = "sampler"; | ||
String value = "ProbabilitySampler"; | ||
Configuration conf = new Configuration(); | ||
conf.set(TraceUtils.HTRACE_CONF_PREFIX + key, value); | ||
HTraceConfiguration wrapped = TraceUtils.wrapHadoopConf(conf); | ||
assertEquals(value, wrapped.get(key)); | ||
} | ||
|
||
@Test | ||
public void testExtraConfig() { | ||
String key = "test.extra.config"; | ||
String oldValue = "old value"; | ||
String newValue = "new value"; | ||
Configuration conf = new Configuration(); | ||
conf.set(TraceUtils.HTRACE_CONF_PREFIX + key, oldValue); | ||
LinkedList<ConfigurationPair> extraConfig = | ||
new LinkedList<ConfigurationPair>(); | ||
extraConfig.add(new ConfigurationPair(key, newValue)); | ||
HTraceConfiguration wrapped = TraceUtils.wrapHadoopConf(conf, extraConfig); | ||
assertEquals(newValue, wrapped.get(key)); | ||
} | ||
} |
Oops, something went wrong.