From 8ce80c383037116f441673be097b20d7f652354b Mon Sep 17 00:00:00 2001 From: Richard Antal Date: Mon, 31 May 2021 10:32:41 +0200 Subject: [PATCH] PHOENIX-6378 Unbunldle sqqline from phoenix-client-embedded, and use it in sqlline.py Change-Id: Ifd31e25b303ab3d2872b53f4a503219539777544 --- bin/phoenix_utils.py | 43 +++++++++++++------ bin/sqlline.py | 4 +- phoenix-assembly/pom.xml | 11 +++++ .../components/all-common-dependencies.xml | 30 +++++++++++++ .../src/build/components/all-common-jars.xml | 7 +++ .../src/build/package-to-tar-all.xml | 12 ++++++ .../phoenix-client-embedded/pom.xml | 5 --- pom.xml | 25 +++++++++++ 8 files changed, 117 insertions(+), 20 deletions(-) create mode 100644 phoenix-assembly/src/build/components/all-common-dependencies.xml diff --git a/bin/phoenix_utils.py b/bin/phoenix_utils.py index 126139dc00e..d5cfab6574c 100755 --- a/bin/phoenix_utils.py +++ b/bin/phoenix_utils.py @@ -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 @@ -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","*") @@ -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): @@ -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) diff --git a/bin/sqlline.py b/bin/sqlline.py index 23e54c5d3f6..be0637d5e3a 100755 --- a/bin/sqlline.py +++ b/bin/sqlline.py @@ -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") + \ diff --git a/phoenix-assembly/pom.xml b/phoenix-assembly/pom.xml index 9ee6ddace42..3a9e5d7ebca 100644 --- a/phoenix-assembly/pom.xml +++ b/phoenix-assembly/pom.xml @@ -132,6 +132,10 @@ org.apache.phoenix phoenix-client-${hbase.suffix} + + org.apache.phoenix + phoenix-client-embedded-${hbase.suffix} + org.apache.phoenix phoenix-pherf @@ -184,5 +188,12 @@ htrace-core + + sqlline + sqlline + ${sqlline.version} + jar-with-dependencies + + diff --git a/phoenix-assembly/src/build/components/all-common-dependencies.xml b/phoenix-assembly/src/build/components/all-common-dependencies.xml new file mode 100644 index 00000000000..5381c88529b --- /dev/null +++ b/phoenix-assembly/src/build/components/all-common-dependencies.xml @@ -0,0 +1,30 @@ + + + + + + + false + /lib + + sqlline:sqlline:jar:jar-with-dependencies + + + + \ No newline at end of file diff --git a/phoenix-assembly/src/build/components/all-common-jars.xml b/phoenix-assembly/src/build/components/all-common-jars.xml index a7b3a340420..d75915ae1d0 100644 --- a/phoenix-assembly/src/build/components/all-common-jars.xml +++ b/phoenix-assembly/src/build/components/all-common-jars.xml @@ -30,6 +30,13 @@ phoenix-client-${hbase.suffix}-${project.version}.jar + + ${project.basedir}/../phoenix-client-parent/phoenix-client-embedded/target + / + + phoenix-client-embedded-${hbase.suffix}-${project.version}.jar + + ${project.basedir}/../phoenix-server/target / diff --git a/phoenix-assembly/src/build/package-to-tar-all.xml b/phoenix-assembly/src/build/package-to-tar-all.xml index fa945f8ec42..f64ace90cbf 100644 --- a/phoenix-assembly/src/build/package-to-tar-all.xml +++ b/phoenix-assembly/src/build/package-to-tar-all.xml @@ -30,8 +30,20 @@ true + + + + false + /lib + + org.slf4j:slf4j-log4j12 + + + + src/build/components/all-common-jars.xml src/build/components/all-common-files.xml + src/build/components/all-common-dependencies.xml \ No newline at end of file diff --git a/phoenix-client-parent/phoenix-client-embedded/pom.xml b/phoenix-client-parent/phoenix-client-embedded/pom.xml index e832704f29b..980f4c044ba 100644 --- a/phoenix-client-parent/phoenix-client-embedded/pom.xml +++ b/phoenix-client-parent/phoenix-client-embedded/pom.xml @@ -81,10 +81,5 @@ phoenix-hbase-compat-${hbase.compat.version} false - - sqlline - sqlline - runtime - diff --git a/pom.xml b/pom.xml index 605062a0b99..8643a0604fb 100644 --- a/pom.xml +++ b/pom.xml @@ -639,6 +639,31 @@ phoenix-client-hbase-2.4 ${project.version} + + org.apache.phoenix + phoenix-client-embedded-hbase-2.1 + ${project.version} + + + org.apache.phoenix + phoenix-client-embedded-hbase-2.2 + ${project.version} + + + org.apache.phoenix + phoenix-client-embedded-hbase-2.3 + ${project.version} + + + org.apache.phoenix + phoenix-client-embedded-hbase-2.4.0 + ${project.version} + + + org.apache.phoenix + phoenix-client-embedded-hbase-2.4 + ${project.version} + org.apache.phoenix phoenix-server-hbase-2.1