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

[#2730] Split Iceberg REST service #4005

Merged
merged 11 commits into from
Jul 23, 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
6 changes: 4 additions & 2 deletions .github/workflows/backend-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
- gradle/**
- integration-test/**
- integration-test-common/**
- iceberg/**
- meta/**
- server/**
- server-common/**
Expand Down Expand Up @@ -104,12 +105,13 @@ jobs:
name: integrate-test-reports-${{ matrix.java-version }}-${{ matrix.test-mode }}-${{ matrix.backend }}
path: |
build/reports
iceberg/iceberg-rest-server/build/*.log
integration-test/build/*.log
integration-test/build/*.tar
integration-test/build/trino-ci-container-log/hive/*.*
integration-test/build/trino-ci-container-log/hdfs/*.*
distribution/package/logs/gravitino-server.out
distribution/package/logs/gravitino-server.log
distribution/package/logs/*.out
distribution/package/logs/*.log
catalogs/**/*.log
catalogs/**/*.tar
distribution/**/*.log
6 changes: 4 additions & 2 deletions .github/workflows/cron-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
- core/**
- dev/**
- gradle/**
- iceberg/**
- integration-test/**
- meta/**
- server/**
Expand Down Expand Up @@ -92,12 +93,13 @@ jobs:
name: integrate test reports
path: |
build/reports
iceberg/iceberg-rest-server/build/*.log
integration-test/build/*.log
integration-test/build/*.tar
integration-test/build/trino-ci-container-log/hive/*.*
integration-test/build/trino-ci-container-log/hdfs/*.*
distribution/package/logs/gravitino-server.out
distribution/package/logs/gravitino-server.log
distribution/package/logs/*.out
distribution/package/logs/*.log
catalogs/**/*.log
catalogs/**/*.tar
distribution/**/*.log
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/spark-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
- core/**
- dev/**
- gradle/**
- iceberg/**
- meta/**
- server/**
- server-common/**
Expand Down Expand Up @@ -105,5 +106,5 @@ jobs:
spark-connector/v3.3/spark/build/spark-3.3-integration-test.log
spark-connector/v3.4/spark/build/spark-3.4-integration-test.log
spark-connector/v3.5/spark/build/spark-3.5-integration-test.log
distribution/package/logs/gravitino-server.out
distribution/package/logs/gravitino-server.log
distribution/package/logs/*.out
distribution/package/logs/*.log
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,8 @@
./catalogs/catalog-hive/src/test/java/org/apache/gravitino/catalog/hive/miniHMS/MiniHiveMetastoreService.java
./catalogs/catalog-hive/src/test/java/org/apache/gravitino/catalog/hive/miniHMS/ScriptRunner.java
./catalogs/catalog-hive/src/test/java/org/apache/gravitino/catalog/hive/TestCachedClientPool.java
./catalogs/catalog-lakehouse-iceberg/src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/web/IcebergExceptionMapper.java
./catalogs/catalog-lakehouse-iceberg/src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/converter/DescribeIcebergSortOrderVisitor.java
./catalogs/catalog-lakehouse-iceberg/src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/utils/IcebergTablePropertiesUtil.java
./catalogs/catalog-lakehouse-iceberg/src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/IcebergHiveCachedClientPool.java
./clients/client-java/src/main/java/org/apache/gravitino/client/HTTPClient.java
./clients/client-java/src/main/java/org/apache/gravitino/client/RESTClient.java
./clients/client-java/src/test/java/org/apache/gravitino/client/TestHTTPClient.java
Expand All @@ -245,6 +243,8 @@
./core/src/main/java/org/apache/gravitino/utils/ClientPoolImpl.java
./common/src/main/java/org/apache/gravitino/dto/responses/OAuth2TokenResponse.java
./clients/client-java/src/main/java/org/apache/gravitino/client/OAuth2ClientUtil.java
./iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergExceptionMapper.java
./iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/utils/IcebergHiveCachedClientPool.java
./gradlew

Apache Paimon
Expand Down
206 changes: 206 additions & 0 deletions bin/gravitino-iceberg-rest-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
#!/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.
#
#set -ex
USAGE="-e Usage: bin/gravitino-iceberg-rest-server.sh [--config <conf-dir>]\n\t
{start|run|stop|restart|status}"

if [[ "$1" == "--config" ]]; then
shift
conf_dir="$1"
if [[ ! -d "${conf_dir}" ]]; then
echo "ERROR : ${conf_dir} is not a directory"
echo ${USAGE}
exit 1
else
export GRAVITINO_CONF_DIR="${conf_dir}"
fi
shift
fi

bin="$(dirname "${BASH_SOURCE-$0}")"
bin="$(cd "${bin}">/dev/null; pwd)"

. "${bin}/common.sh"

check_java_version

function check_process_status() {
local pid=$(found_iceberg_rest_server_pid)

if [[ -z "${pid}" ]]; then
echo "GravitinoIcebergRESTServer is not running"
else
echo "GravitinoIcebergRESTServer is running[PID:$pid]"
fi
}

function found_iceberg_rest_server_pid() {
process_name='GravitinoIcebergRESTServer';
RUNNING_PIDS=$(ps x | grep ${process_name} | grep -v grep | awk '{print $1}');

if [[ -z "${RUNNING_PIDS}" ]]; then
return
fi

if ! kill -0 ${RUNNING_PIDS} > /dev/null 2>&1; then
echo "GravitinoIcebergRESTServer running but process is dead"
fi

echo "${RUNNING_PIDS}"
}

function wait_for_iceberg_rest_server_to_die() {
timeout=10
timeoutTime=$(date "+%s")
let "timeoutTime+=$timeout"
currentTime=$(date "+%s")
forceKill=1

while [[ $currentTime -lt $timeoutTime ]]; do
local pid=$(found_iceberg_rest_server_pid)
if [[ -z "${pid}" ]]; then
forceKill=0
break
fi

$(kill ${pid} > /dev/null 2> /dev/null)
if kill -0 ${pid} > /dev/null 2>&1; then
sleep 3
else
forceKill=0
break
fi
currentTime=$(date "+%s")
done

if [[ forceKill -ne 0 ]]; then
$(kill -9 ${pid} > /dev/null 2> /dev/null)
fi
}

function start() {
local pid=$(found_iceberg_rest_server_pid)

if [[ ! -z "${pid}" ]]; then
if kill -0 ${pid} >/dev/null 2>&1; then
echo "GravitinoIcebergRESTServer is already running"
return 0;
fi
fi

if [[ ! -d "${GRAVITINO_LOG_DIR}" ]]; then
echo "Log dir doesn't exist, create ${GRAVITINO_LOG_DIR}"
mkdir -p "${GRAVITINO_LOG_DIR}"
fi

nohup ${JAVA_RUNNER} ${JAVA_OPTS} ${GRAVITINO_DEBUG_OPTS} -cp ${GRAVITINO_CLASSPATH} ${GRAVITINO_SERVER_NAME} >> "${GRAVITINO_OUTFILE}" 2>&1 &

pid=$!
if [[ -z "${pid}" ]]; then
echo "GravitinoIcebergRESTServer start error!"
return 1;
else
echo "GravitinoIcebergRESTServer start success!"
fi

sleep 2
check_process_status
}

function run() {
${JAVA_RUNNER} ${JAVA_OPTS} ${GRAVITINO_DEBUG_OPTS} -cp ${GRAVITINO_CLASSPATH} ${GRAVITINO_SERVER_NAME}
}

function stop() {
local pid

pid=$(found_iceberg_rest_server_pid)

if [[ -z "${pid}" ]]; then
echo "GravitinoIcebergRESTServer is not running"
else
wait_for_iceberg_rest_server_to_die
echo "GravitinoIcebergRESTServer stop"
fi
}

HOSTNAME=$(hostname)
GRAVITINO_OUTFILE="${GRAVITINO_LOG_DIR}/gravitino-iceberg-rest-server.out"
GRAVITINO_SERVER_NAME=org.apache.gravitino.iceberg.server.GravitinoIcebergRESTServer
GRAVITINO_SIMPLE_SERVER_NAME=gravitino-iceberg-rest-server

JAVA_OPTS+=" -Dfile.encoding=UTF-8"
JAVA_OPTS+=" -Dlog4j2.configurationFile=file://${GRAVITINO_CONF_DIR}/log4j2.properties"
JAVA_OPTS+=" -Dgravitino.log.path=${GRAVITINO_LOG_DIR} ${GRAVITINO_MEM}"
JAVA_OPTS+=" -Dgravitino.server.name=${GRAVITINO_SIMPLE_SERVER_NAME}"
if [ "$JVM_VERSION" -eq 17 ]; then
JAVA_OPTS+=" -XX:+IgnoreUnrecognizedVMOptions"
JAVA_OPTS+=" --add-opens java.base/java.io=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/java.lang.invoke=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/java.lang.reflect=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/java.lang=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/java.math=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/java.net=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/java.nio=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/java.text=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/java.time=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/java.util.concurrent=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/java.util.regex=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/java.util=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/jdk.internal.ref=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/jdk.internal.reflect=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.sql/java.sql=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/sun.util.calendar=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/sun.nio.ch=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/sun.nio.cs=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/sun.security.action=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.base/sun.util.calendar=ALL-UNNAMED"
JAVA_OPTS+=" --add-opens java.security.jgss/sun.security.krb5=ALL-UNNAMED"
fi

#JAVA_OPTS+=" -Djava.securit.krb5.conf=/etc/krb5.conf"

if [ -d "${GRAVITINO_HOME}/iceberg-rest-server/libs" ]; then
addJarInDir "${GRAVITINO_HOME}/iceberg-rest-server/libs"
else
addJarInDir "${GRAVITINO_HOME}/libs"
fi

case "${1}" in
start)
start
;;
run)
run
;;
stop)
stop
;;
restart)
stop
start
;;
status)
check_process_status
;;
*)
echo ${USAGE}
esac
2 changes: 2 additions & 0 deletions bin/gravitino.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,12 @@ function stop() {
HOSTNAME=$(hostname)
GRAVITINO_OUTFILE="${GRAVITINO_LOG_DIR}/gravitino-server.out"
GRAVITINO_SERVER_NAME=org.apache.gravitino.server.GravitinoServer
GRAVITINO_SIMPLE_SERVER_NAME=gravitino-server

JAVA_OPTS+=" -Dfile.encoding=UTF-8"
JAVA_OPTS+=" -Dlog4j2.configurationFile=file://${GRAVITINO_CONF_DIR}/log4j2.properties"
JAVA_OPTS+=" -Dgravitino.log.path=${GRAVITINO_LOG_DIR} ${GRAVITINO_MEM}"
JAVA_OPTS+=" -Dgravitino.server.name=${GRAVITINO_SIMPLE_SERVER_NAME}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

used to specify log file name

if [ "$JVM_VERSION" -eq 17 ]; then
JAVA_OPTS+=" -XX:+IgnoreUnrecognizedVMOptions"
JAVA_OPTS+=" --add-opens java.base/java.io=ALL-UNNAMED"
Expand Down
Loading
Loading