Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improvement] Support env.sh and add HADOOP_CONF_DIR and HIVE_CONF_DIR to CLASSPATH #3222

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ private void initServiceConfig(Map<String, Object> envConfig) throws Exception {

private Map<String, Object> initEnvConfig() {
LOG.info("initializing system env configuration...");
Map<String, String> envs = System.getenv();
envs.forEach((k, v) -> LOG.info("export {}={}", k, v));
String prefix = AmoroManagementConf.SYSTEM_CONFIG.toUpperCase();
return ConfigHelpers.convertConfigurationKeys(prefix, System.getenv());
}
Expand Down
7 changes: 6 additions & 1 deletion dist/src/main/amoro-bin/bin/ams.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ if [ -z "$JAVA_OPTS" ]; then
fi


export CLASSPATH=$AMORO_HOME/conf:$AMORO_CONF_DIR:$LIB_PATH/:$(find $LIB_PATH/ -type f -name "*.jar" | sort | paste -sd':' -)
export CLASSPATH=$AMORO_CONF_DIR:$LIB_PATH/:$(find $LIB_PATH/ -type f -name "*.jar" | sort | paste -sd':' -)

if [ -n "${AMORO_ADDITION_CLASSPATH}" ]; then
export CLASSPATH=$AMORO_ADDITION_CLASSPATH:$CLASSPATH
fi

CMDS="$JAVA_RUN -Dlog4j.configurationFile=${AMORO_LOG_CONF_FILE} -Dlog.home=${AMORO_LOG_DIR} -Dlog.dir=${AMORO_LOG_DIR} -Duser.dir=${AMORO_HOME} $JAVA_OPTS ${RUN_SERVER}"
#0:pid bad and proc OK; 1:pid ok and proc bad; 2:pid bad
function status(){
Expand Down
19 changes: 19 additions & 0 deletions dist/src/main/amoro-bin/bin/load-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ if [ -z "$AMORO_LOG_CONF_FILE" ]; then
export AMORO_LOG_CONF_FILE="${AMORO_CONF_DIR}/log4j2.xml"
fi

export AMORO_ENV_FILE=${AMORO_CONF_DIR}/env.sh

JVM_PROPERTIES=${AMORO_CONF_DIR}/jvm.properties
JVM_VALUE=
parseJvmArgs() {
Expand All @@ -63,3 +65,20 @@ export JVM_XMX_CONFIG
export JVM_XMS_CONFIG
export JMX_REMOTE_PORT_CONFIG
export JVM_EXTRA_CONFIG

test -f ${AMORO_ENV_FILE} && source ${AMORO_ENV_FILE}

# set env variable amoro-addition-classpath if not exists
if [ -z "${AMORO_ADDITION_CLASSPATH}" ]; then
export AMORO_ADDITION_CLASSPATH=
fi

# add hadoop_conf_dir to amoro addition classpath
if [ -n "${HADOOP_CONF_DIR}" ]; then
export AMORO_ADDITION_CLASSPATH=$AMORO_ADDITION_CLASSPATH:$HADOOP_CONF_DIR
fi

# add hive_conf_dir to amoro addition classpath
if [ -n "${HIVE_CONF_DIR}" ]; then
export AMORO_ADDITION_CLASSPATH=${AMORO_ADDITION_CLASSPATH}:${HIVE_CONF_DIR}
fi
28 changes: 28 additions & 0 deletions dist/src/main/amoro-bin/conf/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
#
# 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.
#
# This file is used to export env variables for AMORO

# set your hadoop conf dir
# export HADOOP_CONF_DIR=

# set your hive conf dir
# export HIVE_CONF_DIR=

# set your addition classpath dir
# export AMORO_ADDITION_CLASSPATH=
4 changes: 2 additions & 2 deletions dist/src/main/assemblies/bin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
<fileMode>0644</fileMode>
</file>
<file>
<source>src/main/amoro-bin/conf/config.yaml</source>
<source>src/main/amoro-bin/conf/env.sh</source>
<outputDirectory>conf</outputDirectory>
<fileMode>0644</fileMode>
<fileMode>0755</fileMode>
</file>
<file>
<source>../LICENSE-binary</source>
Expand Down
Loading