World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
#!/usr/bin/env 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.
#
# Referred from Apache Submarine's common.sh implementation
# bin/common.sh
if [ -L "${BASH_SOURCE-$0}" ]; then
FWDIR=$(dirname "$(readlink "${BASH_SOURCE-$0}")")
else
FWDIR=$(dirname "${BASH_SOURCE-$0}")
fi
echo ${GRAVITINO_HOME}
if [[ -z "${GRAVITINO_HOME}" ]]; then
export GRAVITINO_HOME="$(cd "${FWDIR}/.." || exit; pwd)"
fi
if [[ -z "${GRAVITINO_CONF_DIR}" ]]; then
export GRAVITINO_CONF_DIR="${GRAVITINO_HOME}/conf"
fi
if [[ -z "${GRAVITINO_LOG_DIR}" ]]; then
export GRAVITINO_LOG_DIR="${GRAVITINO_HOME}/logs"
fi
if [[ -f "${GRAVITINO_CONF_DIR}/gravitino-env.sh" ]]; then
. "${GRAVITINO_CONF_DIR}/gravitino-env.sh"
fi
if [[ -z "${GRAVITINO_VERSION}" ]]; then
echo -e "GRAVITINO_VERSION is not set, you may need to:\n" \
"1. Ensure that a compiled version of Gravitino is available at " \
"\${GRAVITINO_HOME}/distribution/package. You may need to compile it first, " \
"if you are installing the software from source code.\n" \
"2. Execute gravitino.sh in the \${GRAVITINO_HOME}/distribution/package/bin directory."
exit 1
fi
if [[ -n "${GRAVITINO_CLASSPATH}" ]]; then
GRAVITINO_CLASSPATH="${GRAVITINO_CLASSPATH}:${GRAVITINO_CONF_DIR}"
else
GRAVITINO_CLASSPATH="${GRAVITINO_CONF_DIR}"
fi
JVM_VERSION=8
function check_java_version() {
if [[ -n "${JAVA_HOME+x}" ]]; then
JAVA="$JAVA_HOME/bin/java"
fi
if ! command -v "${JAVA:-java}" > /dev/null 2>&1; then
echo "Error: Java not found. Please install Java 17 or newer and set JAVA_HOME or add java to PATH."
exit 1
fi
java_ver_output=$("${JAVA:-java}" -version 2>&1)
jvmver=$(echo "$java_ver_output" | grep '[openjdk|java] version' | awk -F'"' 'NR==1 {print $2}' | cut -d\- -f1)
JVM_VERSION=$(echo "$jvmver"|sed -e 's|^\([0-9][0-9]*\)\..*$|\1|')
if [[ "$JVM_VERSION" = "1" ]]; then
JVM_VERSION=$(echo "$jvmver"|sed -e 's|^1\.\([0-9][0-9]*\)\..*$|\1|')
fi
if [[ "$JVM_VERSION" -lt 17 ]]; then
echo "Error: Gravitino requires Java 17 or newer, but found Java ${JVM_VERSION}."
exit 1
fi
}
function addEachJarInDir(){
if [[ -d "${1}" ]]; then
for jar in "${1}"/*.jar ; do
GRAVITINO_CLASSPATH="${jar}:${GRAVITINO_CLASSPATH}"
done
fi
}
function addEachJarInDirRecursive(){
if [[ -d "${1}" ]]; then
for jar in "${1}"/**/*.jar ; do
GRAVITINO_CLASSPATH="${jar}:${GRAVITINO_CLASSPATH}"
done
fi
}
function addJarInDir(){
if [[ -d "${1}" ]]; then
GRAVITINO_CLASSPATH="${1}/*:${GRAVITINO_CLASSPATH}"
fi
}
function addDirToClasspath(){
if [[ -d "${1}" ]]; then
GRAVITINO_CLASSPATH="${1}:${GRAVITINO_CLASSPATH}"
fi
}
# Rotate a launch script's .out file before the process starts, so the file does not grow across
# restarts. The previous files are kept as <file>.1 (newest) to <file>.N (oldest), where N is
# GRAVITINO_OUT_FILE_KEEP (default 5). Set it to 0 to keep no previous file.
function rotate_out_file() {
local out_file="$1"
local keep="${GRAVITINO_OUT_FILE_KEEP:-5}"
local rotated index
if ! [[ "${keep}" =~ ^[0-9]+$ ]]; then
echo "Invalid GRAVITINO_OUT_FILE_KEEP '${keep}', use 5 instead"
keep=5
fi
# Remove files beyond the limit, including those left by a larger earlier limit.
for rotated in "${out_file}".*; do
index="${rotated##*.}"
if [[ -f "${rotated}" && "${index}" =~ ^[0-9]+$ ]] && (( 10#${index} >= keep )); then
rm -f "${rotated}"
fi
done
if [[ ! -f "${out_file}" ]]; then
return 0
fi
if (( keep == 0 )); then
rm -f "${out_file}"
return 0
fi
for (( index = keep - 1; index >= 1; index-- )); do
if [[ -f "${out_file}.${index}" ]]; then
mv -f "${out_file}.${index}" "${out_file}.$((index + 1))"
fi
done
mv -f "${out_file}" "${out_file}.1"
}
if [[ -z "${GRAVITINO_MEM}" ]]; then
export GRAVITINO_MEM="-Xms1024m -Xmx1024m -XX:MaxMetaspaceSize=512m"
fi
if [[ -n "${JAVA_HOME}" ]]; then
export JAVA_RUNNER="${JAVA_HOME}/bin/java"
else
export JAVA_RUNNER=java
fi
function printArt() {
local lineLength=70
local versionText="Version: ${GRAVITINO_VERSION} "
local versionTextLength=${#versionText}
local paddingLength=$((lineLength - versionTextLength - 3))
local versionLine=$(printf "#%${paddingLength}s%s#" "" "$versionText")
echo "#####################################################################"
echo "# ____ ____ _ ___ ___ ___ _____ ___ _ _ ___ #"
echo "# / ___| | _ \ / \ \ \ / / |_ _||_ _||_ _|| \ | | / _ \ #"
echo "# | | __ | |_) | / _ \ \ \ / / | | | | | | | \| || | | | #"
echo "# | |_| | | _ < / ___ \ \ V / | | | | | | | |\ || |_| | #"
echo "# \____| |_| \_\/_/ \_\ \_/ |___| |_| |___||_| \_| \___/ #"
echo "$versionLine"
echo "#####################################################################"
}