You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by AyolaJayamaha <gi...@git.apache.org> on 2015/08/20 16:48:12 UTC
[GitHub] phoenix pull request: PHOENIX-2186 : Back end services
GitHub user AyolaJayamaha opened a pull request:
https://github.com/apache/phoenix/pull/111
PHOENIX-2186 : Back end services
This will include the following components.
- [x] Main class
- [x] Pom file
- [x] Adding as moduel for root pom
- [x] Launch script
- [x] Backend trace service API
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/AyolaJayamaha/phoenix back-end-services
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/phoenix/pull/111.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #111
----
commit a353dab6d2863a23637b8199f050785a58545455
Author: ayolajayamaha <ra...@gmail.com>
Date: 2015-07-27T16:57:27Z
adding readme
commit a8db9b5b0a555893693792ba28f1d042c216dc65
Author: ayolajayamaha <ra...@gmail.com>
Date: 2015-08-20T14:39:58Z
adding back end services for tracing app
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] phoenix pull request: PHOENIX-2186 : Back end services
Posted by ndimiduk <gi...@git.apache.org>.
Github user ndimiduk commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/111#discussion_r37573194
--- Diff: phoenix-tracing-webapp/src/main/java/org/apache/phoenix/tracingwebapp/http/Main.java ---
@@ -0,0 +1,78 @@
+/*
+ * 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.tracingwebapp.http;
+
+import java.io.File;
+import java.net.URL;
+import java.security.ProtectionDomain;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configured;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.util.Tool;
+import org.apache.hadoop.util.ToolRunner;
+import org.apache.log4j.BasicConfigurator;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.webapp.WebAppContext;
+
+/**
+ * tracing web app runner
+ *
+ * @since 4.5.5
+ */
+public final class Main extends Configured implements Tool {
+
+ protected static final Log LOG = LogFactory.getLog(Main.class);
+ public static final String TRACE_SERVER_HTTP_PORT_KEY =
+ "phoenix.traceserver.http.port";
+ public static final int DEFAULT_HTTP_PORT = 8864;
+ public static final String TRACE_SERVER_HTTP_JETTY_HOME_KEY =
+ "phoenix.traceserver.http.home";
+ public static final String DEFAULT_HTTP_HOME = "";
+
+ public static void main(String[] args) throws Exception {
+ int ret = ToolRunner.run(HBaseConfiguration.create(), new Main(), args);
+ System.exit(ret);
+
+ }
+
+ @Override
+ public int run(String[] arg0) throws Exception {
+ // logProcessInfo(getConf());
+ final int port = getConf().getInt(TRACE_SERVER_HTTP_PORT_KEY,
+ DEFAULT_HTTP_PORT);
+ BasicConfigurator.configure();
+ final String home = getConf().get(TRACE_SERVER_HTTP_JETTY_HOME_KEY,
+ DEFAULT_HTTP_HOME);
+ Server server = new Server(port);
+ ProtectionDomain domain = Main.class.getProtectionDomain();
+ URL location = domain.getCodeSource().getLocation();
+ WebAppContext webapp = new WebAppContext();
+ webapp.setContextPath("/");
+ if (home.length() != 0) {
+ webapp.setTempDirectory(new File(home));
+ }
+
+ String warPath = location.toString().split("target")[0] + "build/trace-webapp-demo.war";
--- End diff --
oh, you are still deploying from war. we'll need to remove this and do to a standard resources-based embedded web app. please open a new JIRA for this as well.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] phoenix pull request: PHOENIX-2186 : Back end services
Posted by AyolaJayamaha <gi...@git.apache.org>.
Github user AyolaJayamaha commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/111#discussion_r38027924
--- Diff: phoenix-tracing-webapp/src/main/java/org/apache/phoenix/tracingwebapp/http/Main.java ---
@@ -0,0 +1,78 @@
+/*
+ * 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.tracingwebapp.http;
+
+import java.io.File;
+import java.net.URL;
+import java.security.ProtectionDomain;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configured;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.util.Tool;
+import org.apache.hadoop.util.ToolRunner;
+import org.apache.log4j.BasicConfigurator;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.webapp.WebAppContext;
+
+/**
+ * tracing web app runner
+ *
+ * @since 4.5.5
+ */
+public final class Main extends Configured implements Tool {
+
+ protected static final Log LOG = LogFactory.getLog(Main.class);
+ public static final String TRACE_SERVER_HTTP_PORT_KEY =
+ "phoenix.traceserver.http.port";
+ public static final int DEFAULT_HTTP_PORT = 8864;
--- End diff --
I will update doc patch on this
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] phoenix pull request: PHOENIX-2186 : Back end services
Posted by AyolaJayamaha <gi...@git.apache.org>.
Github user AyolaJayamaha commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/111#discussion_r38026772
--- Diff: phoenix-tracing-webapp/src/main/java/org/apache/phoenix/tracingwebapp/http/Main.java ---
@@ -0,0 +1,78 @@
+/*
+ * 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.tracingwebapp.http;
+
+import java.io.File;
+import java.net.URL;
+import java.security.ProtectionDomain;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configured;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.util.Tool;
+import org.apache.hadoop.util.ToolRunner;
+import org.apache.log4j.BasicConfigurator;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.webapp.WebAppContext;
+
+/**
+ * tracing web app runner
+ *
+ * @since 4.5.5
+ */
+public final class Main extends Configured implements Tool {
+
+ protected static final Log LOG = LogFactory.getLog(Main.class);
+ public static final String TRACE_SERVER_HTTP_PORT_KEY =
+ "phoenix.traceserver.http.port";
+ public static final int DEFAULT_HTTP_PORT = 8864;
+ public static final String TRACE_SERVER_HTTP_JETTY_HOME_KEY =
+ "phoenix.traceserver.http.home";
+ public static final String DEFAULT_HTTP_HOME = "";
+
+ public static void main(String[] args) throws Exception {
+ int ret = ToolRunner.run(HBaseConfiguration.create(), new Main(), args);
+ System.exit(ret);
+
+ }
+
+ @Override
+ public int run(String[] arg0) throws Exception {
+ // logProcessInfo(getConf());
+ final int port = getConf().getInt(TRACE_SERVER_HTTP_PORT_KEY,
+ DEFAULT_HTTP_PORT);
+ BasicConfigurator.configure();
+ final String home = getConf().get(TRACE_SERVER_HTTP_JETTY_HOME_KEY,
+ DEFAULT_HTTP_HOME);
+ Server server = new Server(port);
+ ProtectionDomain domain = Main.class.getProtectionDomain();
+ URL location = domain.getCodeSource().getLocation();
+ WebAppContext webapp = new WebAppContext();
+ webapp.setContextPath("/");
+ if (home.length() != 0) {
+ webapp.setTempDirectory(new File(home));
+ }
+
+ String warPath = location.toString().split("target")[0] + "build/trace-webapp-demo.war";
--- End diff --
Yes, Currently It is deploying war file. Here I have created jira for it:
https://issues.apache.org/jira/browse/PHOENIX-2212
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] phoenix pull request: PHOENIX-2186 : Back end services
Posted by ndimiduk <gi...@git.apache.org>.
Github user ndimiduk commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/111#discussion_r37572065
--- Diff: phoenix-tracing-webapp/pom.xml ---
@@ -0,0 +1,173 @@
+<?xml version='1.0'?>
+ <!--
+
+ 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.
+
+-->
+
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.phoenix</groupId>
+ <artifactId>phoenix</artifactId>
+ <version>4.4.1-HBase-0.98-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>phoenix-tracing-webapp</artifactId>
+ <name>Phoenix - Tracing Web Application</name>
+ <description>Tracing web application will visualize the phoenix traces</description>
+
+ <properties>
+ <top.dir>${project.basedir}/..</top.dir>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <!-- TODO : pick the same jetty version throughout the project -->
+ <version>${jettyVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-webapp</artifactId>
+ <!-- TODO : pick the same jetty version throughout the project -->
+ <version>${jettyVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-common</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.phoenix</groupId>
+ <artifactId>phoenix-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hbase</groupId>
+ <artifactId>hbase-common</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-core-asl</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
--- End diff --
this can be removed along with the build.xml, right?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] phoenix pull request: PHOENIX-2186 : Back end services
Posted by AyolaJayamaha <gi...@git.apache.org>.
Github user AyolaJayamaha commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/111#discussion_r38028108
--- Diff: phoenix-tracing-webapp/src/build/build.xml ---
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
--- End diff --
Embedded service : https://issues.apache.org/jira/browse/PHOENIX-2212
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] phoenix pull request: PHOENIX-2186 : Back end services
Posted by ndimiduk <gi...@git.apache.org>.
Github user ndimiduk commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/111#discussion_r37573002
--- Diff: phoenix-tracing-webapp/src/main/java/org/apache/phoenix/tracingwebapp/http/Main.java ---
@@ -0,0 +1,78 @@
+/*
+ * 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.tracingwebapp.http;
+
+import java.io.File;
+import java.net.URL;
+import java.security.ProtectionDomain;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configured;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.util.Tool;
+import org.apache.hadoop.util.ToolRunner;
+import org.apache.log4j.BasicConfigurator;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.webapp.WebAppContext;
+
+/**
+ * tracing web app runner
+ *
+ * @since 4.5.5
+ */
+public final class Main extends Configured implements Tool {
+
+ protected static final Log LOG = LogFactory.getLog(Main.class);
+ public static final String TRACE_SERVER_HTTP_PORT_KEY =
+ "phoenix.traceserver.http.port";
+ public static final int DEFAULT_HTTP_PORT = 8864;
+ public static final String TRACE_SERVER_HTTP_JETTY_HOME_KEY =
+ "phoenix.traceserver.http.home";
+ public static final String DEFAULT_HTTP_HOME = "";
+
+ public static void main(String[] args) throws Exception {
+ int ret = ToolRunner.run(HBaseConfiguration.create(), new Main(), args);
+ System.exit(ret);
+
--- End diff --
nit: extraneous newline.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] phoenix pull request: PHOENIX-2186 : Back end services
Posted by ndimiduk <gi...@git.apache.org>.
Github user ndimiduk commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/111#discussion_r37571839
--- Diff: phoenix-tracing-webapp/pom.xml ---
@@ -0,0 +1,173 @@
+<?xml version='1.0'?>
+ <!--
+
+ 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.
+
+-->
+
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.phoenix</groupId>
+ <artifactId>phoenix</artifactId>
+ <version>4.4.1-HBase-0.98-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>phoenix-tracing-webapp</artifactId>
+ <name>Phoenix - Tracing Web Application</name>
+ <description>Tracing web application will visualize the phoenix traces</description>
+
+ <properties>
+ <top.dir>${project.basedir}/..</top.dir>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <!-- TODO : pick the same jetty version throughout the project -->
--- End diff --
You can file a new ticket for the work mentioned by this PR as well.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] phoenix pull request: PHOENIX-2186 : Back end services
Posted by ndimiduk <gi...@git.apache.org>.
Github user ndimiduk commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/111#discussion_r37573414
--- Diff: phoenix-tracing-webapp/src/main/java/org/apache/phoenix/tracingwebapp/http/TraceServlet.java ---
@@ -0,0 +1,160 @@
+/*
+ * 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.tracingwebapp.http;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.codehaus.jackson.map.ObjectMapper;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.PreparedStatement;
+import java.sql.Statement;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ * Server to show trace information
+ *
+ *
+ * @since 4.4.1
+ */
+public class TraceServlet extends HttpServlet {
+
+ protected Connection con;
+ protected String DEFAULT_LIMIT = "25";
+ protected String DEFAULT_COUNTBY = "hostname";
+ protected String LOGIC_AND = "AND";
+ protected String LOGIC_OR = "OR";
+ protected String PHOENIX_HOST = "localhost";
+ protected String TRACING_TABLE = "SYSTEM.TRACING_STATS";
+ protected int PHOENIX_PORT = 2181;
+
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+
+ //reading url params
+ String action = request.getParameter("action");
+ String limit = request.getParameter("limit");
+ String traceid = request.getParameter("traceid");
+ String parentid = request.getParameter("parentid");
+ String jsonObject = "{}";
+ if ("getall".equals(action)) {
+ jsonObject = getAll(limit);
+ } else if ("getCount".equals(action)) {
+ jsonObject = getCount("description");
+ } else if ("getDistribution".equals(action)) {
+ jsonObject = getCount(DEFAULT_COUNTBY);
+ } else if ("searchTrace".equals(action)) {
+ jsonObject = searchTrace(parentid, traceid, LOGIC_OR);
+ } else {
+ jsonObject = "{ \"Server\": \"Phoenix Tracing Web App\", \"API version\": 0.1 }";
+ }
+ //response send as json
+ response.setContentType("application/json");
+ String output = jsonObject;
+ PrintWriter out = response.getWriter();
+ out.print(output);
+ out.flush();
+
+ }
+
+ //get all trace results with limit count
+ protected String getAll(String limit) {
+ String json = null;
+ if(limit == null) {
+ limit = DEFAULT_LIMIT;
+ }
+ String sqlQuery = "SELECT * FROM " + TRACING_TABLE + " LIMIT "+limit;
+ json = getResults(sqlQuery);
+ return getJson(json);
+ }
+
+ //get count on traces can pick on param to count
+ protected String getCount(String countby) {
+ String json = null;
+ if(countby == null) {
+ countby = DEFAULT_COUNTBY;
+ }
+ String sqlQuery = "SELECT "+countby+", COUNT(*) AS count FROM " + TRACING_TABLE + " GROUP BY "+countby+" HAVING COUNT(*) > 1 ";
+ json = getResults(sqlQuery);
+ return json;
+ }
+
+ //search the trace over parent id or trace id
+ protected String searchTrace(String parentId, String traceId,String logic) {
+ String json = null;
+ String query = null;
+ if(parentId != null && traceId != null) {
+ query = "SELECT * FROM " + TRACING_TABLE + " WHERE parent_id="+parentId+" "+logic+" trace_id="+traceId;
+ }else if (parentId != null && traceId == null) {
+ query = "SELECT * FROM " + TRACING_TABLE + " WHERE parent_id="+parentId;
+ }else if(parentId == null && traceId != null) {
+ query = "SELECT * FROM " + TRACING_TABLE + " WHERE trace_id="+traceId;
+ }
+ json = getResults(query);
+ return getJson(json);
+ }
+
+ //return json string
+ protected String getJson(String json) {
+ String output = json.toString().replace("_id\":", "_id\":\"")
+ .replace(",\"hostname", "\",\"hostname")
+ .replace(",\"parent", "\",\"parent")
+ .replace(",\"end", "\",\"end");
+ return output;
+ }
+
+ //get results with passing sql query
+ protected String getResults(String sqlQuery) {
+ String json = null;
+ if(sqlQuery == null){
+ json = "{error:true,msg:'SQL was null'}";
--- End diff --
indentation and formatting here is off.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] phoenix pull request: PHOENIX-2186 : Back end services
Posted by ndimiduk <gi...@git.apache.org>.
Github user ndimiduk commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/111#discussion_r37573572
--- Diff: phoenix-tracing-webapp/src/main/java/org/apache/phoenix/tracingwebapp/http/TraceServlet.java ---
@@ -0,0 +1,160 @@
+/*
+ * 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.tracingwebapp.http;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.codehaus.jackson.map.ObjectMapper;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.PreparedStatement;
+import java.sql.Statement;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ * Server to show trace information
+ *
+ *
+ * @since 4.4.1
+ */
+public class TraceServlet extends HttpServlet {
+
+ protected Connection con;
+ protected String DEFAULT_LIMIT = "25";
+ protected String DEFAULT_COUNTBY = "hostname";
+ protected String LOGIC_AND = "AND";
+ protected String LOGIC_OR = "OR";
+ protected String PHOENIX_HOST = "localhost";
+ protected String TRACING_TABLE = "SYSTEM.TRACING_STATS";
+ protected int PHOENIX_PORT = 2181;
+
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+
+ //reading url params
+ String action = request.getParameter("action");
+ String limit = request.getParameter("limit");
+ String traceid = request.getParameter("traceid");
+ String parentid = request.getParameter("parentid");
+ String jsonObject = "{}";
+ if ("getall".equals(action)) {
+ jsonObject = getAll(limit);
+ } else if ("getCount".equals(action)) {
+ jsonObject = getCount("description");
+ } else if ("getDistribution".equals(action)) {
+ jsonObject = getCount(DEFAULT_COUNTBY);
+ } else if ("searchTrace".equals(action)) {
+ jsonObject = searchTrace(parentid, traceid, LOGIC_OR);
+ } else {
+ jsonObject = "{ \"Server\": \"Phoenix Tracing Web App\", \"API version\": 0.1 }";
+ }
+ //response send as json
+ response.setContentType("application/json");
+ String output = jsonObject;
+ PrintWriter out = response.getWriter();
+ out.print(output);
+ out.flush();
+
+ }
+
+ //get all trace results with limit count
+ protected String getAll(String limit) {
+ String json = null;
+ if(limit == null) {
+ limit = DEFAULT_LIMIT;
+ }
+ String sqlQuery = "SELECT * FROM " + TRACING_TABLE + " LIMIT "+limit;
+ json = getResults(sqlQuery);
+ return getJson(json);
+ }
+
+ //get count on traces can pick on param to count
+ protected String getCount(String countby) {
+ String json = null;
+ if(countby == null) {
+ countby = DEFAULT_COUNTBY;
+ }
+ String sqlQuery = "SELECT "+countby+", COUNT(*) AS count FROM " + TRACING_TABLE + " GROUP BY "+countby+" HAVING COUNT(*) > 1 ";
+ json = getResults(sqlQuery);
+ return json;
+ }
+
+ //search the trace over parent id or trace id
+ protected String searchTrace(String parentId, String traceId,String logic) {
+ String json = null;
+ String query = null;
+ if(parentId != null && traceId != null) {
+ query = "SELECT * FROM " + TRACING_TABLE + " WHERE parent_id="+parentId+" "+logic+" trace_id="+traceId;
+ }else if (parentId != null && traceId == null) {
+ query = "SELECT * FROM " + TRACING_TABLE + " WHERE parent_id="+parentId;
+ }else if(parentId == null && traceId != null) {
+ query = "SELECT * FROM " + TRACING_TABLE + " WHERE trace_id="+traceId;
+ }
+ json = getResults(query);
+ return getJson(json);
+ }
+
+ //return json string
+ protected String getJson(String json) {
+ String output = json.toString().replace("_id\":", "_id\":\"")
+ .replace(",\"hostname", "\",\"hostname")
+ .replace(",\"parent", "\",\"parent")
+ .replace(",\"end", "\",\"end");
+ return output;
+ }
+
+ //get results with passing sql query
+ protected String getResults(String sqlQuery) {
+ String json = null;
+ if(sqlQuery == null){
+ json = "{error:true,msg:'SQL was null'}";
+ }else{
+ try {
+ Class.forName("org.apache.phoenix.jdbc.PhoenixDriver");
+ con = DriverManager.getConnection("jdbc:phoenix:"+PHOENIX_HOST+":"+PHOENIX_PORT);
--- End diff --
connection should be reused, not re-created with every query.
phoenix host and port should be read from a configuration object. It will need to be provided from the parsing done in Main.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] phoenix pull request: PHOENIX-2186 : Back end services
Posted by ndimiduk <gi...@git.apache.org>.
Github user ndimiduk commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/111#discussion_r37572345
--- Diff: phoenix-tracing-webapp/src/main/java/org/apache/phoenix/tracingwebapp/http/EntityFactory.java ---
@@ -0,0 +1,98 @@
+/*
+ * 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.tracingwebapp.http;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class EntityFactory {
+
+ private final String queryString;
+ protected Connection connection;
+
+ public EntityFactory(Connection connection, String queryString) {
+ this.queryString = queryString;
+ this.connection = connection;
+ }
+
+ public Map<String, Object> findSingle(Object[] params) throws SQLException {
+ List<Map<String, Object>> objects = this.findMultiple(params);
+
+ if (objects.size() != 1) {
+ throw new SQLException("Query did not produce one object it produced: "
+ + objects.size() + " objects.");
+ }
+
+ Map<String, Object> object = objects.get(0); // get first record;
+
+ return object;
+ }
+
+ public List<Map<String, Object>> findMultiple(Object[] params)
+ throws SQLException {
+ ResultSet rs = null;
+ PreparedStatement ps = null;
+ try {
+ ps = this.connection.prepareStatement(this.queryString);
+ for (int i = 0; i < params.length; ++i) {
+ ps.setObject(1, params[i]);
+ }
+
+ rs = ps.executeQuery();
+ return getEntitiesFromResultSet(rs);
+ } catch (SQLException e) {
+ throw (e);
+ } finally {
+ if (rs != null) {
+ rs.close();
+ }
+ if (ps != null) {
+ ps.close();
+ }
+ }
+ }
+
+ protected List<Map<String, Object>> getEntitiesFromResultSet(
+ ResultSet resultSet) throws SQLException {
+ ArrayList<Map<String, Object>> entities = new ArrayList<>();
+ while (resultSet.next()) {
+ entities.add(getEntityFromResultSet(resultSet));
+ }
+ return entities;
+ }
+
+ protected Map<String, Object> getEntityFromResultSet(ResultSet resultSet)
--- End diff --
this method does not use member variables and thus can be made a static method.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] phoenix pull request: PHOENIX-2186 : Back end services
Posted by ndimiduk <gi...@git.apache.org>.
Github user ndimiduk commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/111#discussion_r37571986
--- Diff: phoenix-tracing-webapp/src/build/build.xml ---
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
--- End diff --
Do we still need this ant file? We're not building a war anymore, it's an embedded service. I think the whole ant step can be removed.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] phoenix pull request: PHOENIX-2186 : Back end services
Posted by ndimiduk <gi...@git.apache.org>.
Github user ndimiduk commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/111#discussion_r37573048
--- Diff: phoenix-tracing-webapp/src/main/java/org/apache/phoenix/tracingwebapp/http/Main.java ---
@@ -0,0 +1,78 @@
+/*
+ * 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.tracingwebapp.http;
+
+import java.io.File;
+import java.net.URL;
+import java.security.ProtectionDomain;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configured;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.util.Tool;
+import org.apache.hadoop.util.ToolRunner;
+import org.apache.log4j.BasicConfigurator;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.webapp.WebAppContext;
+
+/**
+ * tracing web app runner
+ *
+ * @since 4.5.5
+ */
+public final class Main extends Configured implements Tool {
+
+ protected static final Log LOG = LogFactory.getLog(Main.class);
+ public static final String TRACE_SERVER_HTTP_PORT_KEY =
+ "phoenix.traceserver.http.port";
+ public static final int DEFAULT_HTTP_PORT = 8864;
--- End diff --
please mention the default port number in your readme and in documentation. make sure it's all consistent.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] phoenix pull request: PHOENIX-2186 : Back end services
Posted by ndimiduk <gi...@git.apache.org>.
Github user ndimiduk commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/111#discussion_r37571771
--- Diff: phoenix-tracing-webapp/pom.xml ---
@@ -0,0 +1,173 @@
+<?xml version='1.0'?>
+ <!--
+
+ 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.
+
+-->
+
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.phoenix</groupId>
+ <artifactId>phoenix</artifactId>
+ <version>4.4.1-HBase-0.98-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>phoenix-tracing-webapp</artifactId>
+ <name>Phoenix - Tracing Web Application</name>
+ <description>Tracing web application will visualize the phoenix traces</description>
+
+ <properties>
+ <top.dir>${project.basedir}/..</top.dir>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <!-- TODO : pick the same jetty version throughout the project -->
+ <version>${jettyVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-webapp</artifactId>
+ <!-- TODO : pick the same jetty version throughout the project -->
+ <version>${jettyVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-common</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.phoenix</groupId>
+ <artifactId>phoenix-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hbase</groupId>
+ <artifactId>hbase-common</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-core-asl</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.7</version>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <configuration>
+ <tasks>
+ <ant antfile="src/build/build.xml"/>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>runnable</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <attach>true</attach>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <mainClass>org.apache.phoenix.tracingwebapp.http.Main</mainClass>
+ </manifest>
+ </archive>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ <descriptors>
+ <descriptor>src/build/trace-server-runnable.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <!--plugin>
--- End diff --
all this commented stuff is uncommented by PR112? Will there be some merge that needs to happen between these two PRs?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] phoenix pull request: PHOENIX-2186 : Back end services
Posted by AyolaJayamaha <gi...@git.apache.org>.
Github user AyolaJayamaha commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/111#discussion_r37995853
--- Diff: phoenix-tracing-webapp/pom.xml ---
@@ -0,0 +1,173 @@
+<?xml version='1.0'?>
+ <!--
+
+ 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.
+
+-->
+
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.phoenix</groupId>
+ <artifactId>phoenix</artifactId>
+ <version>4.4.1-HBase-0.98-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>phoenix-tracing-webapp</artifactId>
+ <name>Phoenix - Tracing Web Application</name>
+ <description>Tracing web application will visualize the phoenix traces</description>
+
+ <properties>
+ <top.dir>${project.basedir}/..</top.dir>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <!-- TODO : pick the same jetty version throughout the project -->
+ <version>${jettyVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-webapp</artifactId>
+ <!-- TODO : pick the same jetty version throughout the project -->
+ <version>${jettyVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-common</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.phoenix</groupId>
+ <artifactId>phoenix-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hbase</groupId>
+ <artifactId>hbase-common</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-core-asl</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.7</version>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <configuration>
+ <tasks>
+ <ant antfile="src/build/build.xml"/>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>runnable</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <attach>true</attach>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <mainClass>org.apache.phoenix.tracingwebapp.http.Main</mainClass>
+ </manifest>
+ </archive>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ <descriptors>
+ <descriptor>src/build/trace-server-runnable.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <!--plugin>
--- End diff --
First you have to add the PR#111 and then PR#112. You will have to do a merge for the POM file. Since both needs to built and I have added pom file for both.
I will remove the commented lines in the pom file so it will simplify the merge.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] phoenix pull request: PHOENIX-2186 : Back end services
Posted by AyolaJayamaha <gi...@git.apache.org>.
Github user AyolaJayamaha commented on the pull request:
https://github.com/apache/phoenix/pull/111#issuecomment-133053181
Build Apache Phoenix from root
mvn clean install
Start the backend services
`./bin/traceserver.py start`
Stop the backend services
`./bin/traceserver.py stop`

The services can be viewed by accessing the following location
http://localhost:8864/trace?action=get

---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] phoenix pull request: PHOENIX-2186 : Back end services
Posted by ndimiduk <gi...@git.apache.org>.
Github user ndimiduk commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/111#discussion_r37572962
--- Diff: phoenix-tracing-webapp/src/main/java/org/apache/phoenix/tracingwebapp/http/Main.java ---
@@ -0,0 +1,78 @@
+/*
+ * 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.tracingwebapp.http;
+
+import java.io.File;
+import java.net.URL;
+import java.security.ProtectionDomain;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configured;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.util.Tool;
+import org.apache.hadoop.util.ToolRunner;
+import org.apache.log4j.BasicConfigurator;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.webapp.WebAppContext;
+
+/**
+ * tracing web app runner
+ *
+ * @since 4.5.5
--- End diff --
remove the since annotation.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] phoenix pull request: PHOENIX-2186 : Back end services
Posted by ndimiduk <gi...@git.apache.org>.
Github user ndimiduk commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/111#discussion_r37572381
--- Diff: phoenix-tracing-webapp/src/main/java/org/apache/phoenix/tracingwebapp/http/EntityFactory.java ---
@@ -0,0 +1,98 @@
+/*
+ * 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.tracingwebapp.http;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class EntityFactory {
+
+ private final String queryString;
+ protected Connection connection;
+
+ public EntityFactory(Connection connection, String queryString) {
+ this.queryString = queryString;
+ this.connection = connection;
+ }
+
+ public Map<String, Object> findSingle(Object[] params) throws SQLException {
+ List<Map<String, Object>> objects = this.findMultiple(params);
+
+ if (objects.size() != 1) {
+ throw new SQLException("Query did not produce one object it produced: "
+ + objects.size() + " objects.");
+ }
+
+ Map<String, Object> object = objects.get(0); // get first record;
+
+ return object;
+ }
+
+ public List<Map<String, Object>> findMultiple(Object[] params)
+ throws SQLException {
+ ResultSet rs = null;
+ PreparedStatement ps = null;
+ try {
+ ps = this.connection.prepareStatement(this.queryString);
+ for (int i = 0; i < params.length; ++i) {
+ ps.setObject(1, params[i]);
+ }
+
+ rs = ps.executeQuery();
+ return getEntitiesFromResultSet(rs);
+ } catch (SQLException e) {
+ throw (e);
+ } finally {
+ if (rs != null) {
+ rs.close();
+ }
+ if (ps != null) {
+ ps.close();
+ }
+ }
+ }
+
+ protected List<Map<String, Object>> getEntitiesFromResultSet(
--- End diff --
this can also be made a static method.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] phoenix pull request: PHOENIX-2186 : Back end services
Posted by AyolaJayamaha <gi...@git.apache.org>.
Github user AyolaJayamaha commented on the pull request:
https://github.com/apache/phoenix/pull/111#issuecomment-138435673
@ndimiduk & @jtaylor-sfdc @JamesRTaylor can either of you please take a look at this PR?
Thanks.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] phoenix pull request: PHOENIX-2186 : Back end services
Posted by ndimiduk <gi...@git.apache.org>.
Github user ndimiduk commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/111#discussion_r37572197
--- Diff: phoenix-tracing-webapp/src/main/java/org/apache/phoenix/tracingwebapp/http/EntityFactory.java ---
@@ -0,0 +1,98 @@
+/*
+ * 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.tracingwebapp.http;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class EntityFactory {
--- End diff --
What does this class do? A class-level javadoc will help make this clear.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---