git commit: PHOENIX-1226 Exception in Tracing
Repository: phoenix Updated Branches: refs/heads/master 4a1ec7ec4 -> 284435b5a PHOENIX-1226 Exception in Tracing Phoenix tracing expects annotation values to be integers, but HBase writes non-integer values in its traces (which end up in the phoenix sink) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/284435b5 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/284435b5 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/284435b5 Branch: refs/heads/master Commit: 284435b5ab4e749febf13ad00f9050f6f25f9e15 Parents: 4a1ec7e Author: Jesse Yates Authored: Fri Sep 5 16:44:15 2014 -0700 Committer: Jesse Yates Committed: Fri Sep 5 16:44:36 2014 -0700 -- .../org/apache/phoenix/trace/TracingCompat.java | 4 +- .../phoenix/trace/TraceMetricsSourceTest.java | 96 2 files changed, 98 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/284435b5/phoenix-hadoop-compat/src/main/java/org/apache/phoenix/trace/TracingCompat.java -- diff --git a/phoenix-hadoop-compat/src/main/java/org/apache/phoenix/trace/TracingCompat.java b/phoenix-hadoop-compat/src/main/java/org/apache/phoenix/trace/TracingCompat.java index 783bfd6..032e38a 100644 --- a/phoenix-hadoop-compat/src/main/java/org/apache/phoenix/trace/TracingCompat.java +++ b/phoenix-hadoop-compat/src/main/java/org/apache/phoenix/trace/TracingCompat.java @@ -49,11 +49,11 @@ public class TracingCompat { public static final String METRICS_MARKER_CONTEXT = "marker"; public static void addAnnotation(Span span, String message, int value) { -span.addKVAnnotation(message.getBytes(), Bytes.toBytes(value)); +span.addKVAnnotation(message.getBytes(), Bytes.toBytes(Integer.toString(value))); } public static Pair readAnnotation(byte[] key, byte[] value) { -return new Pair(new String(key), Integer.toString(Bytes.toInt(value))); +return new Pair(new String(key), Bytes.toString(value)); } public static MetricsWriter initializeWriter(String clazz) { http://git-wip-us.apache.org/repos/asf/phoenix/blob/284435b5/phoenix-hadoop2-compat/src/test/java/org/apache/phoenix/trace/TraceMetricsSourceTest.java -- diff --git a/phoenix-hadoop2-compat/src/test/java/org/apache/phoenix/trace/TraceMetricsSourceTest.java b/phoenix-hadoop2-compat/src/test/java/org/apache/phoenix/trace/TraceMetricsSourceTest.java new file mode 100644 index 000..3258e8a --- /dev/null +++ b/phoenix-hadoop2-compat/src/test/java/org/apache/phoenix/trace/TraceMetricsSourceTest.java @@ -0,0 +1,96 @@ +/** + * 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.phoenix.trace; + +import org.apache.hadoop.hbase.util.Bytes; +import org.apache.hadoop.metrics2.MetricsCollector; +import org.apache.hadoop.metrics2.MetricsRecordBuilder; +import org.apache.hadoop.metrics2.MetricsTag; +import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem; +import org.cloudera.htrace.Span; +import org.cloudera.htrace.impl.MilliSpan; +import org.junit.BeforeClass; +import org.junit.Test; +import org.mockito.Mockito; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * Test that the @{link TraceMetricSource} correctly handles different kinds of traces + */ +public class TraceMetricsSourceTest { + + @BeforeClass + public static void setup() throws Exception{ +DefaultMetricsSystem.setMiniClusterMode(true); + } + + /** + * For PHOENIX-1126, Phoenix originally assumed all the annotation values were integers, + * but HBase writes some strings as well, so we need to be able to handle that too + */ + @Test + public void testNonIntegerAnnotations(){ +Span span = getSpan(); +// make sure its less than the length of an integer +byte[] value = Bytes.toBytes("a"); +byte[] someInt = Bytes.toBytes(1); +assertTrue(someInt.
git commit: PHOENIX-1226 Exception in Tracing
Repository: phoenix Updated Branches: refs/heads/4.0 a9a128bfa -> 4c8441b5f PHOENIX-1226 Exception in Tracing Phoenix tracing expects annotation values to be integers, but HBase writes non-integer values in its traces (which end up in the phoenix sink) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/4c8441b5 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/4c8441b5 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/4c8441b5 Branch: refs/heads/4.0 Commit: 4c8441b5f3813e4ed5ff6d0522e946bf1892bd29 Parents: a9a128b Author: Jesse Yates Authored: Fri Sep 5 16:44:15 2014 -0700 Committer: Jesse Yates Committed: Fri Sep 5 16:44:43 2014 -0700 -- .../org/apache/phoenix/trace/TracingCompat.java | 4 +- .../phoenix/trace/TraceMetricsSourceTest.java | 96 2 files changed, 98 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/4c8441b5/phoenix-hadoop-compat/src/main/java/org/apache/phoenix/trace/TracingCompat.java -- diff --git a/phoenix-hadoop-compat/src/main/java/org/apache/phoenix/trace/TracingCompat.java b/phoenix-hadoop-compat/src/main/java/org/apache/phoenix/trace/TracingCompat.java index 783bfd6..032e38a 100644 --- a/phoenix-hadoop-compat/src/main/java/org/apache/phoenix/trace/TracingCompat.java +++ b/phoenix-hadoop-compat/src/main/java/org/apache/phoenix/trace/TracingCompat.java @@ -49,11 +49,11 @@ public class TracingCompat { public static final String METRICS_MARKER_CONTEXT = "marker"; public static void addAnnotation(Span span, String message, int value) { -span.addKVAnnotation(message.getBytes(), Bytes.toBytes(value)); +span.addKVAnnotation(message.getBytes(), Bytes.toBytes(Integer.toString(value))); } public static Pair readAnnotation(byte[] key, byte[] value) { -return new Pair(new String(key), Integer.toString(Bytes.toInt(value))); +return new Pair(new String(key), Bytes.toString(value)); } public static MetricsWriter initializeWriter(String clazz) { http://git-wip-us.apache.org/repos/asf/phoenix/blob/4c8441b5/phoenix-hadoop2-compat/src/test/java/org/apache/phoenix/trace/TraceMetricsSourceTest.java -- diff --git a/phoenix-hadoop2-compat/src/test/java/org/apache/phoenix/trace/TraceMetricsSourceTest.java b/phoenix-hadoop2-compat/src/test/java/org/apache/phoenix/trace/TraceMetricsSourceTest.java new file mode 100644 index 000..3258e8a --- /dev/null +++ b/phoenix-hadoop2-compat/src/test/java/org/apache/phoenix/trace/TraceMetricsSourceTest.java @@ -0,0 +1,96 @@ +/** + * 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.phoenix.trace; + +import org.apache.hadoop.hbase.util.Bytes; +import org.apache.hadoop.metrics2.MetricsCollector; +import org.apache.hadoop.metrics2.MetricsRecordBuilder; +import org.apache.hadoop.metrics2.MetricsTag; +import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem; +import org.cloudera.htrace.Span; +import org.cloudera.htrace.impl.MilliSpan; +import org.junit.BeforeClass; +import org.junit.Test; +import org.mockito.Mockito; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * Test that the @{link TraceMetricSource} correctly handles different kinds of traces + */ +public class TraceMetricsSourceTest { + + @BeforeClass + public static void setup() throws Exception{ +DefaultMetricsSystem.setMiniClusterMode(true); + } + + /** + * For PHOENIX-1126, Phoenix originally assumed all the annotation values were integers, + * but HBase writes some strings as well, so we need to be able to handle that too + */ + @Test + public void testNonIntegerAnnotations(){ +Span span = getSpan(); +// make sure its less than the length of an integer +byte[] value = Bytes.toBytes("a"); +byte[] someInt = Bytes.toBytes(1); +assertTrue(someInt.length