Skip to content

Commit

Permalink
PHOENIX-6378 Unbunldle sqqline from phoenix-client-embedded, and use …
Browse files Browse the repository at this point in the history
…it in sqlline.py

Change-Id: Ifd31e25b303ab3d2872b53f4a503219539777544
  • Loading branch information
richardantal committed May 31, 2021
1 parent 3231aad commit 8ce80c3
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 20 deletions.
43 changes: 29 additions & 14 deletions bin/phoenix_utils.py
Expand Up @@ -77,10 +77,16 @@ def findClasspath(command_name):
return tryDecode(subprocess.Popen(command, shell=True, stdout=subprocess.PIPE).stdout.read())

def setPath():
PHOENIX_CLIENT_JAR_PATTERN = "phoenix-client-hbase-*[!s].jar"
PHOENIX_CLIENT_EMBEDDED_JAR_PATTERN = "phoenix-client-embedded-hbase-*[!s].jar"
PHOENIX_TRACESERVER_JAR_PATTERN = "phoenix-tracing-webapp-*-runnable.jar"
PHOENIX_TESTS_JAR_PATTERN = "phoenix-core-*-tests*.jar"
PHOENIX_PHERF_JAR_PATTERN = "phoenix-pherf-*[!s].jar"
SLF4J_LOG4J12_JAR_PATTERN = "slf4j-log4j12-*[!s].jar"
SQLLINE_WITH_DEPS_PATTERN = "sqlline-*-jar-with-dependencies.jar"


OVERRIDE_SLF4J_BACKEND = "OVERRIDE_SLF4J_BACKEND_JAR_LOCATION"
OVERRIDE_SQLLINE = "OVERRIDE_SQLLINE_JAR_LOCATION"

# Backward support old env variable PHOENIX_LIB_DIR replaced by PHOENIX_CLASS_PATH
global phoenix_class_path
Expand Down Expand Up @@ -113,15 +119,15 @@ def setPath():
if pherf_properties_file == "":
pherf_conf_path = os.path.join(current_dir, "..", "phoenix-pherf", "config")

global phoenix_jar_path
phoenix_jar_path = os.path.join(current_dir, "..", "phoenix-client-parent" , "phoenix-client", "target","*")
global phoenix_embedded_jar_path
phoenix_embedded_jar_path = os.path.join(current_dir, "..", "phoenix-client-parent" , "phoenix-client-embedded", "target","*")

global phoenix_client_jar
phoenix_client_jar = find(PHOENIX_CLIENT_JAR_PATTERN, phoenix_jar_path)
if phoenix_client_jar == "":
phoenix_client_jar = findFileInPathWithoutRecursion(PHOENIX_CLIENT_JAR_PATTERN, os.path.join(current_dir, ".."))
if phoenix_client_jar == "":
phoenix_client_jar = find(PHOENIX_CLIENT_JAR_PATTERN, phoenix_class_path)
global phoenix_client_embedded_jar
phoenix_client_embedded_jar = find(PHOENIX_CLIENT_EMBEDDED_JAR_PATTERN, phoenix_embedded_jar_path)
if phoenix_client_embedded_jar == "":
phoenix_client_embedded_jar = findFileInPathWithoutRecursion(PHOENIX_CLIENT_EMBEDDED_JAR_PATTERN, os.path.join(current_dir, ".."))
if phoenix_client_embedded_jar == "":
phoenix_client_embedded_jar = find(PHOENIX_CLIENT_EMBEDDED_JAR_PATTERN, phoenix_class_path)

global phoenix_test_jar_path
phoenix_test_jar_path = os.path.join(current_dir, "..", "phoenix-core", "target","*")
Expand Down Expand Up @@ -176,6 +182,16 @@ def setPath():
if phoenix_pherf_jar == "":
phoenix_pherf_jar = findFileInPathWithoutRecursion(PHOENIX_PHERF_JAR_PATTERN, os.path.join(current_dir, ".."))

global sqlline_with_deps_jar
sqlline_with_deps_jar = os.environ.get(OVERRIDE_SQLLINE)
if sqlline_with_deps_jar is None or sqlline_with_deps_jar == "":
sqlline_with_deps_jar = findFileInPathWithoutRecursion(SQLLINE_WITH_DEPS_PATTERN, os.path.join(current_dir, "..","lib"))

global slf4j_backend_jar
slf4j_backend_jar = os.environ.get(OVERRIDE_SLF4J_BACKEND)
if slf4j_backend_jar is None or slf4j_backend_jar == "":
slf4j_backend_jar = findFileInPathWithoutRecursion(SLF4J_LOG4J12_JAR_PATTERN, os.path.join(current_dir, "..","lib"))

return ""

def shell_quote(args):
Expand Down Expand Up @@ -204,15 +220,14 @@ def common_sqlline_args(parser):
print("hbase_conf_dir:", hbase_conf_dir)
print("hbase_conf_path:", hbase_conf_path)
print("current_dir:", current_dir)
print("phoenix_jar_path:", phoenix_jar_path)
print("phoenix_client_jar:", phoenix_client_jar)
print("phoenix_embedded_jar_path:", phoenix_embedded_jar_path)
print("phoenix_client_embedded_jar:", phoenix_client_embedded_jar)
print("phoenix_test_jar_path:", phoenix_test_jar_path)
print("hadoop_common_jar_path:", hadoop_common_jar_path)
print("hadoop_common_jar:", hadoop_common_jar)
print("hadoop_hdfs_jar_path:", hadoop_hdfs_jar_path)
print("hadoop_hdfs_jar:", hadoop_hdfs_jar)
print("testjar:", testjar)
print("phoenix_queryserver_jar:", phoenix_queryserver_jar)
print("phoenix_loadbalancer_jar:", phoenix_loadbalancer_jar)
print("phoenix_thin_client_jar:", phoenix_thin_client_jar)
print("hadoop_classpath:", hadoop_classpath)
print("sqlline_with_deps_jar:", sqlline_with_deps_jar)
print("slf4j_backend_jar:", slf4j_backend_jar)
4 changes: 3 additions & 1 deletion bin/sqlline.py
Expand Up @@ -108,7 +108,9 @@ def kill_child():
colorSetting = "false"

java_cmd = java + ' $PHOENIX_OPTS ' + \
' -cp "' + hbase_config_path + os.pathsep + phoenix_utils.hbase_conf_dir + os.pathsep + phoenix_utils.phoenix_client_jar + \
' -cp "' + phoenix_utils.sqlline_with_deps_jar + os.pathsep + hbase_config_path + os.pathsep + \
phoenix_utils.slf4j_backend_jar + os.pathsep + \
phoenix_utils.hbase_conf_dir + os.pathsep + phoenix_utils.phoenix_client_embedded_jar + \
os.pathsep + phoenix_utils.hadoop_common_jar + os.pathsep + phoenix_utils.hadoop_hdfs_jar + \
os.pathsep + phoenix_utils.hadoop_conf + os.pathsep + phoenix_utils.hadoop_classpath + '" -Dlog4j.configuration=file:' + \
os.path.join(phoenix_utils.current_dir, "log4j.properties") + \
Expand Down
11 changes: 11 additions & 0 deletions phoenix-assembly/pom.xml
Expand Up @@ -132,6 +132,10 @@
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-client-${hbase.suffix}</artifactId>
</dependency>
<dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-client-embedded-${hbase.suffix}</artifactId>
</dependency>
<dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-pherf</artifactId>
Expand Down Expand Up @@ -184,5 +188,12 @@
<artifactId>htrace-core</artifactId>
</dependency>

<dependency>
<groupId>sqlline</groupId>
<artifactId>sqlline</artifactId>
<version>${sqlline.version}</version>
<classifier>jar-with-dependencies</classifier>
</dependency>

</dependencies>
</project>
30 changes: 30 additions & 0 deletions phoenix-assembly/src/build/components/all-common-dependencies.xml
@@ -0,0 +1,30 @@
<?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.
-->
<component>
<!-- All of our dependencies -->
<dependencySets>
<dependencySet>
<unpack>false</unpack>
<outputDirectory>/lib</outputDirectory>
<includes>
<include>sqlline:sqlline:jar:jar-with-dependencies</include>
</includes>
</dependencySet>
</dependencySets>
</component>
7 changes: 7 additions & 0 deletions phoenix-assembly/src/build/components/all-common-jars.xml
Expand Up @@ -30,6 +30,13 @@
<include>phoenix-client-${hbase.suffix}-${project.version}.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/../phoenix-client-parent/phoenix-client-embedded/target</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>phoenix-client-embedded-${hbase.suffix}-${project.version}.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/../phoenix-server/target</directory>
<outputDirectory>/</outputDirectory>
Expand Down
12 changes: 12 additions & 0 deletions phoenix-assembly/src/build/package-to-tar-all.xml
Expand Up @@ -30,8 +30,20 @@
</formats>
<includeBaseDirectory>true</includeBaseDirectory>

<!-- Components that we don't want in jars that are used with other libraries, but we want for a standalone client -->
<dependencySets>
<dependencySet>
<unpack>false</unpack>
<outputDirectory>/lib</outputDirectory>
<includes>
<include>org.slf4j:slf4j-log4j12</include>
</includes>
</dependencySet>
</dependencySets>

<componentDescriptors>
<componentDescriptor>src/build/components/all-common-jars.xml</componentDescriptor>
<componentDescriptor>src/build/components/all-common-files.xml</componentDescriptor>
<componentDescriptor>src/build/components/all-common-dependencies.xml</componentDescriptor>
</componentDescriptors>
</assembly>
5 changes: 0 additions & 5 deletions phoenix-client-parent/phoenix-client-embedded/pom.xml
Expand Up @@ -81,10 +81,5 @@
<artifactId>phoenix-hbase-compat-${hbase.compat.version}</artifactId>
<optional>false</optional>
</dependency>
<dependency>
<groupId>sqlline</groupId>
<artifactId>sqlline</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>
25 changes: 25 additions & 0 deletions pom.xml
Expand Up @@ -639,6 +639,31 @@
<artifactId>phoenix-client-hbase-2.4</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-client-embedded-hbase-2.1</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-client-embedded-hbase-2.2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-client-embedded-hbase-2.3</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-client-embedded-hbase-2.4.0</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-client-embedded-hbase-2.4</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-server-hbase-2.1</artifactId>
Expand Down

0 comments on commit 8ce80c3

Please sign in to comment.