IMPALA-7383: Configurable HMS and Sentry policy DB Some developers keep multiple impala repos on their disk. Isolating METASTORE_DB and SENTRY_POLICY_DB may help with switching between those repos without reloading the data. This patch makes those DB names configurable and default to an escaped IMPALA_HOME path.
Change-Id: I190d657cb95dfdf73ebd05e5dd24ef2a8e3156b8 Reviewed-on: http://gerrit.cloudera.org:8080/11104 Reviewed-by: Impala Public Jenkins <impala-public-jenk...@cloudera.com> Tested-by: Impala Public Jenkins <impala-public-jenk...@cloudera.com> Project: http://git-wip-us.apache.org/repos/asf/impala/repo Commit: http://git-wip-us.apache.org/repos/asf/impala/commit/2868bf56 Tree: http://git-wip-us.apache.org/repos/asf/impala/tree/2868bf56 Diff: http://git-wip-us.apache.org/repos/asf/impala/diff/2868bf56 Branch: refs/heads/master Commit: 2868bf569afaf950b79a79a05893f314a9c51387 Parents: 4976ff3 Author: Tianyi Wang <tia...@apache.org> Authored: Wed Aug 1 15:26:17 2018 -0700 Committer: Tianyi Wang <tw...@cloudera.com> Committed: Thu Aug 9 18:07:40 2018 +0000 ---------------------------------------------------------------------- bin/create-test-configuration.sh | 4 ++-- bin/impala-config.sh | 4 +++- fe/src/test/resources/sentry-site.xml.template | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/impala/blob/2868bf56/bin/create-test-configuration.sh ---------------------------------------------------------------------- diff --git a/bin/create-test-configuration.sh b/bin/create-test-configuration.sh index 812154d..e68af9c 100755 --- a/bin/create-test-configuration.sh +++ b/bin/create-test-configuration.sh @@ -105,8 +105,8 @@ fi if [ $CREATE_SENTRY_POLICY_DB -eq 1 ]; then echo "Creating Sentry Policy Server DB" - dropdb -U hiveuser sentry_policy 2> /dev/null || true - createdb -U hiveuser sentry_policy + dropdb -U hiveuser $SENTRY_POLICY_DB 2> /dev/null || true + createdb -U hiveuser $SENTRY_POLICY_DB fi # Perform search-replace on $1, output to $2. http://git-wip-us.apache.org/repos/asf/impala/blob/2868bf56/bin/impala-config.sh ---------------------------------------------------------------------- diff --git a/bin/impala-config.sh b/bin/impala-config.sh index 0940df6..0fc3516 100755 --- a/bin/impala-config.sh +++ b/bin/impala-config.sh @@ -319,7 +319,9 @@ export ISILON_NAMENODE="${ISILON_NAMENODE-}" export DEFAULT_FS="${DEFAULT_FS-hdfs://localhost:20500}" export WAREHOUSE_LOCATION_PREFIX="${WAREHOUSE_LOCATION_PREFIX-}" export LOCAL_FS="file:${WAREHOUSE_LOCATION_PREFIX}" -export METASTORE_DB="hive_impala" +ESCAPED_IMPALA_HOME=$(sed "s/[^0-9a-zA-Z]/_/g" <<< "$IMPALA_HOME") +export METASTORE_DB=${METASTORE_DB-$(cut -c-63 <<< HMS$ESCAPED_IMPALA_HOME)} +export SENTRY_POLICY_DB=${SENTRY_POLICY_DB-$(cut -c-63 <<< SP$ESCAPED_IMPALA_HOME)} # Environment variables carrying AWS security credentials are prepared # according to the following rules: http://git-wip-us.apache.org/repos/asf/impala/blob/2868bf56/fe/src/test/resources/sentry-site.xml.template ---------------------------------------------------------------------- diff --git a/fe/src/test/resources/sentry-site.xml.template b/fe/src/test/resources/sentry-site.xml.template index b569c5f..9d721ef 100644 --- a/fe/src/test/resources/sentry-site.xml.template +++ b/fe/src/test/resources/sentry-site.xml.template @@ -51,7 +51,7 @@ </property> <property> <name>sentry.store.jdbc.url</name> - <value>jdbc:postgresql://localhost:5432/sentry_policy/;create=true</value> + <value>jdbc:postgresql://localhost:5432/${SENTRY_POLICY_DB}/;create=true</value> </property> <property> <name>sentry.store.jdbc.user</name>