cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cxf git commit: CXF-6360: Integration with Apache HTrace. Evolving HBase support.
Date Sun, 26 Jul 2015 17:48:11 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 84c8ce83f -> ce81b3829


CXF-6360: Integration with Apache HTrace. Evolving HBase support.


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/ce81b382
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/ce81b382
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/ce81b382

Branch: refs/heads/master
Commit: ce81b3829764996aa8d6c006ec2dd5c784e98433
Parents: 84c8ce8
Author: reta <drreta@gmail.com>
Authored: Sun Jul 26 13:47:56 2015 -0400
Committer: reta <drreta@gmail.com>
Committed: Sun Jul 26 13:47:56 2015 -0400

----------------------------------------------------------------------
 .../samples/jax_rs/tracing_htrace/README.txt    | 12 ++++++++
 .../samples/jax_rs/tracing_htrace/pom.xml       | 11 +++++++
 .../tracing/conf/TracingConfiguration.java      | 30 ++++++++++++++++++++
 .../java/demo/jaxrs/tracing/server/Catalog.java |  8 +++++-
 .../demo/jaxrs/tracing/server/CatalogStore.java |  9 +++---
 .../java/demo/jaxrs/tracing/server/Server.java  | 22 +++++++++++++-
 6 files changed, 86 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/ce81b382/distribution/src/main/release/samples/jax_rs/tracing_htrace/README.txt
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_htrace/README.txt b/distribution/src/main/release/samples/jax_rs/tracing_htrace/README.txt
index cbbea95..96adeb3 100644
--- a/distribution/src/main/release/samples/jax_rs/tracing_htrace/README.txt
+++ b/distribution/src/main/release/samples/jax_rs/tracing_htrace/README.txt
@@ -19,6 +19,18 @@ traces:
 A HTTP DELETE request to URL http://localhost:9000/catalog/<id> generates following

 traces:
 
+Running Apache HBase using Docker
+---------------------------------------
+Official repository: https://registry.hub.docker.com/u/nerdammer/hbase/
+docker run -p 2181:2181 -p 60010:60010 -p 60000:60000 -p 60020:60020 -p 60030:60030 -h hbase
nerdammer/hbase
+
+Preparing test dataset
+---------------------------------------
+create 'catalog', {NAME => 'c', VERSIONS => 5}
+put 'catalog', '1', 'c:title', 'Apache CXF Web Service Development'
+put 'catalog', '2', 'c:title', 'HBase: The Definitive Guide'
+put 'catalog', '3', 'c:title', 'HBase in Action'
+
 Building and running the demo using Maven
 ---------------------------------------
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/ce81b382/distribution/src/main/release/samples/jax_rs/tracing_htrace/pom.xml
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_htrace/pom.xml b/distribution/src/main/release/samples/jax_rs/tracing_htrace/pom.xml
index 2ae9065..30a71f6 100644
--- a/distribution/src/main/release/samples/jax_rs/tracing_htrace/pom.xml
+++ b/distribution/src/main/release/samples/jax_rs/tracing_htrace/pom.xml
@@ -139,6 +139,17 @@
         <dependency>
             <groupId>org.apache.hbase</groupId>
             <artifactId>hbase-client</artifactId>
+            <version>1.1.1</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-jdk14</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-log4j12</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
     </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/cxf/blob/ce81b382/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/conf/TracingConfiguration.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/conf/TracingConfiguration.java
b/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/conf/TracingConfiguration.java
new file mode 100644
index 0000000..822c3a5
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/conf/TracingConfiguration.java
@@ -0,0 +1,30 @@
+/**
+ * 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 demo.jaxrs.tracing.conf;
+
+import org.apache.htrace.SpanReceiver;
+import org.apache.htrace.impl.StandardOutSpanReceiver;
+
+public final class TracingConfiguration {
+    public static final Class<? extends SpanReceiver> SPAN_RECEIVER = StandardOutSpanReceiver.class;
+    
+    private TracingConfiguration() {
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/ce81b382/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/server/Catalog.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/server/Catalog.java
b/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/server/Catalog.java
index d2fdc5e..b52cf86 100644
--- a/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/server/Catalog.java
+++ b/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/server/Catalog.java
@@ -43,6 +43,9 @@ import javax.ws.rs.core.UriInfo;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.trace.SpanReceiverHost;
+
+import demo.jaxrs.tracing.conf.TracingConfiguration;
 
 @Path("/catalog")
 public class Catalog {
@@ -51,7 +54,10 @@ public class Catalog {
     
     public Catalog() throws IOException {
         final Configuration configuration = HBaseConfiguration.create();
-        store = new CatalogStore(configuration, "books");
+        configuration.set("hbase.zookeeper.quorum", "hbase");
+        configuration.set("hbase.zookeeper.property.clientPort", "2181");
+        configuration.set(SpanReceiverHost.SPAN_RECEIVERS_CONF_KEY, TracingConfiguration.SPAN_RECEIVER.getName());
+        store = new CatalogStore(configuration, "catalog");
     }
     
     @POST

http://git-wip-us.apache.org/repos/asf/cxf/blob/ce81b382/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/server/CatalogStore.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/server/CatalogStore.java
b/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/server/CatalogStore.java
index 5ab8efa..0960441 100644
--- a/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/server/CatalogStore.java
+++ b/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/server/CatalogStore.java
@@ -28,6 +28,7 @@ import javax.json.JsonObject;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.CellUtil;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.Connection;
 import org.apache.hadoop.hbase.client.ConnectionFactory;
@@ -73,8 +74,8 @@ public class CatalogStore {
                 final Cell cell = result.getColumnLatestCell(Bytes.toBytes("c"), Bytes.toBytes("title"));
                 
                 return Json.createObjectBuilder()
-                    .add("id", Bytes.toString(cell.getRowArray()))
-                    .add("title", Bytes.toString(cell.getValueArray()))
+                    .add("id", Bytes.toString(CellUtil.cloneRow(cell)))
+                    .add("title", Bytes.toString(CellUtil.cloneValue(cell)))
                     .build();
             }
         }
@@ -92,8 +93,8 @@ public class CatalogStore {
                 final Cell cell = result.getColumnLatestCell(Bytes.toBytes("c"), Bytes.toBytes("title"));
                 
                 builder.add(Json.createObjectBuilder()
-                    .add("id", new String(cell.getRowArray()))
-                    .add("title", new String(cell.getValueArray()))
+                    .add("id", Bytes.toString(CellUtil.cloneRow(cell)))
+                    .add("title", Bytes.toString(CellUtil.cloneValue(cell)))
                 );
             }
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/ce81b382/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/server/Server.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/server/Server.java
b/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/server/Server.java
index eda69b6..15ad5bd 100644
--- a/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/server/Server.java
+++ b/distribution/src/main/release/samples/jax_rs/tracing_htrace/src/main/java/demo/jaxrs/tracing/server/Server.java
@@ -19,14 +19,34 @@
 
 package demo.jaxrs.tracing.server;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.cxf.jaxrs.provider.jsrjsonp.JsrJsonpProvider;
 import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet;
 import org.apache.cxf.tracing.htrace.jaxrs.HTraceFeature;
+import org.apache.htrace.HTraceConfiguration;
+import org.apache.htrace.impl.AlwaysSampler;
 import org.eclipse.jetty.servlet.ServletContextHandler;
 import org.eclipse.jetty.servlet.ServletHolder;
 
+import demo.jaxrs.tracing.conf.TracingConfiguration;
+
 public class Server {
+    public static class TracingFeature extends HTraceFeature {
+        public TracingFeature() {
+            super(HTraceConfiguration.fromMap(getTracingProperties()));
+        }
+
+        private static Map<String, String> getTracingProperties() {
+            final Map<String, String> properties = new HashMap<String, String>();
+            properties.put("span.receiver", TracingConfiguration.SPAN_RECEIVER.getName());
+            properties.put("sampler", AlwaysSampler.class.getName());
+            return properties;
+        }
+    }
+    
     protected Server() throws Exception {
         org.eclipse.jetty.server.Server server = new org.eclipse.jetty.server.Server(9000);
 
@@ -37,7 +57,7 @@ public class Server {
         context.addServlet(servletHolder, "/*");
         
         servletHolder.setInitParameter("jaxrs.serviceClasses", Catalog.class.getName());
-        servletHolder.setInitParameter("jaxrs.features", HTraceFeature.class.getName());
+        servletHolder.setInitParameter("jaxrs.features", TracingFeature.class.getName());
         servletHolder.setInitParameter("jaxrs.providers", StringUtils.join(
             new String[] { 
                 JsrJsonpProvider.class.getName()


Mime
View raw message