This is an automated email from the ASF dual-hosted git repository.

stoty pushed a commit to branch 5.2
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/5.2 by this push:
     new 8b2da06855 PHOENIX-7520 Use HBASE_OPTS from hbase-env.sh in startup 
scripts (#2072)
8b2da06855 is described below

commit 8b2da06855e62e123270f9aab2f789903d61eb29
Author: Istvan Toth <[email protected]>
AuthorDate: Fri Feb 7 10:06:23 2025 +0100

    PHOENIX-7520 Use HBASE_OPTS from hbase-env.sh in startup scripts (#2072)
    
    also apply all environment variables set in hbase-env.sh to startup shell
---
 bin/performance.py   |  2 +-
 bin/phoenix_utils.py | 25 +++++++++++++------------
 bin/psql.py          |  3 ++-
 bin/sqlline.py       |  3 ++-
 4 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/bin/performance.py b/bin/performance.py
index 11d8b483ee..6ef11c2be8 100755
--- a/bin/performance.py
+++ b/bin/performance.py
@@ -65,7 +65,7 @@ phoenix_utils.setPath()
 
 java_cmd = phoenix_utils.java
 
-execute = ('%s %s $PHOENIX_OPTS -cp "%s%s%s%s%s"' +
+execute = ('%s %s $HBASE_OPTS $PHOENIX_OPTS -cp "%s%s%s%s%s"' +
            ' 
-Djava.util.logging.config.class=org.apache.hadoop.hbase.logging.JulToSlf4jInitializer
 ' +
            ' -Dlog4j2.configurationFile=file:' +
            os.path.join(phoenix_utils.current_dir, "log4j2.properties") +
diff --git a/bin/phoenix_utils.py b/bin/phoenix_utils.py
index ee26bbe933..3ee8014ada 100755
--- a/bin/phoenix_utils.py
+++ b/bin/phoenix_utils.py
@@ -24,6 +24,7 @@ import os
 import fnmatch
 import re
 import subprocess
+import sys
 
 def find(pattern, classPaths):
     paths = classPaths.split(os.pathsep)
@@ -192,7 +193,8 @@ def setPath():
         logging_jar += 
":"+findFileInPathWithoutRecursion(LOGGING_JAR_PATTERN3, 
os.path.join(current_dir, "..","lib"))
         logging_jar += 
":"+findFileInPathWithoutRecursion(LOGGING_JAR_PATTERN4, 
os.path.join(current_dir, "..","lib"))
 
-    __set_java_home()
+    __read_hbase_env()
+    __set_java()
     __set_jvm_flags()
     return ""
 
@@ -211,13 +213,19 @@ def shell_quote(args):
         import pipes
         return " ".join([pipes.quote(tryDecode(v)) for v in args])
 
-
-def __set_java_home():
+def __set_java():
     global java_home
     global java
     java_home = os.getenv('JAVA_HOME')
-    java = 'java'
+    if java_home:
+        java = os.path.join(java_home, 'bin', 'java')
+    else:
+        java = 'java'
+
 
+def __read_hbase_env():
+    if os.getenv("SKIP_HBASE_ENV"):
+        return ""
     # HBase configuration folder path (where hbase-site.xml reside) for
     # HBase/Phoenix client side property override
     hbase_config_path = hbase_conf_dir
@@ -235,18 +243,11 @@ def __set_java_home():
         sys.stderr.write("hbase-env file unknown on platform 
{}{}".format(os.name, os.linesep))
         sys.exit(-1)
 
-    hbase_env = {}
     if os.path.isfile(hbase_env_path):
         p = subprocess.Popen(hbase_env_cmd, stdout = subprocess.PIPE)
         for x in p.stdout:
             (k, _, v) = tryDecode(x).partition('=')
-            hbase_env[k.strip()] = v.strip()
-
-    if 'JAVA_HOME' in hbase_env:
-        java_home = hbase_env['JAVA_HOME']
-
-    if java_home:
-        java = os.path.join(java_home, 'bin', 'java')
+            os.environ[k.strip()] = v.strip()
 
     return ""
 
diff --git a/bin/psql.py b/bin/psql.py
index decf8c2258..b33b888949 100755
--- a/bin/psql.py
+++ b/bin/psql.py
@@ -30,7 +30,8 @@ phoenix_utils.setPath()
 
 args = phoenix_utils.shell_quote(sys.argv[1:])
 
-java_cmd = phoenix_utils.java + ' ' + phoenix_utils.jvm_module_flags + ' 
$PHOENIX_OPTS ' + \
+java_cmd = phoenix_utils.java + ' ' + phoenix_utils.jvm_module_flags + \
+    ' $HBASE_OPTS $PHOENIX_OPTS ' + \
     ' -cp "' + phoenix_utils.hbase_conf_dir + os.pathsep + 
phoenix_utils.hadoop_conf + \
     os.pathsep + phoenix_utils.slf4j_backend_jar + \
     os.pathsep + phoenix_utils.logging_jar + \
diff --git a/bin/sqlline.py b/bin/sqlline.py
index 4f9479b564..17bca8fb45 100755
--- a/bin/sqlline.py
+++ b/bin/sqlline.py
@@ -90,7 +90,8 @@ if os.uname()[4].startswith('ppc'):
 else:
     disable_jna = ""
 
-java_cmd = phoenix_utils.java + ' ' + phoenix_utils.jvm_module_flags + ' 
$PHOENIX_OPTS ' + \
+java_cmd = phoenix_utils.java + ' ' + phoenix_utils.jvm_module_flags + \
+    ' $HBASE_OPTS $PHOENIX_OPTS ' + \
     ' -cp "' + phoenix_utils.hbase_conf_dir + os.pathsep + \
     phoenix_utils.hadoop_conf + os.pathsep + \
     phoenix_utils.sqlline_with_deps_jar + os.pathsep + \

Reply via email to