Skip to content

Commit e3a3726

Browse files
committed
Add launcher and create tar for trino-gateway
1 parent c59bb7d commit e3a3726

File tree

23 files changed

+200
-39
lines changed

23 files changed

+200
-39
lines changed

docker/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ RUN \
4343
mkdir -p /usr/lib/trino-gateway /etc/trino-gateway && \
4444
chown -R "trino:trino" /usr/lib/trino-gateway /etc/trino-gateway
4545

46-
COPY --chown=trino:trino gateway-ha /usr/lib/trino-gateway
46+
ARG TRINO_GATEWAY_VERSION
47+
COPY --chown=trino:trino trino-gateway-server-${TRINO_GATEWAY_VERSION} /usr/lib/trino-gateway
48+
COPY --chown=trino:trino default/etc /etc/trino-gateway
4749

4850
EXPOSE 8080
4951
USER trino:trino
50-
CMD java -jar /usr/lib/trino-gateway/gateway-ha-jar-with-dependencies.jar "/etc/trino-gateway/config.yaml"
52+
CMD ["/usr/lib/trino-gateway/bin/run-trino-gateway"]
5153

5254
HEALTHCHECK --interval=10s --timeout=5s --start-period=10s \
5355
CMD /usr/lib/trino-gateway/bin/health-check

docker/bin/run-trino-gateway

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
set -xeuo pipefail
4+
5+
launcher_opts=(--etc-dir /etc/trino-gateway --config /etc/trino-gateway/config.yaml)
6+
if ! grep -s -q 'node.id' /etc/trino-gateway/node.properties; then
7+
launcher_opts+=("-Dnode.id=${HOSTNAME}")
8+
fi
9+
10+
exec /usr/lib/trino-gateway/bin/launcher run "${launcher_opts[@]}" "$@"

docker/build.sh

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,24 +95,24 @@ function temurin_jdk_link() {
9595
check_environment
9696

9797
if [ -n "$TRINO_GATEWAY_VERSION" ]; then
98-
echo "🎣 Downloading Trino Gateway server artifact for release version ${TRINO_GATEWAY_VERSION}"
99-
"${SOURCE_DIR}/mvnw" -C dependency:get -Dtransitive=false -Dartifact="io.trino.gateway:gateway-ha:${TRINO_GATEWAY_VERSION}:jar:jar-with-dependencies"
98+
echo "🎣 Downloading Gateway server artifact for release version ${TRINO_GATEWAY_VERSION}"
99+
"${SOURCE_DIR}/mvnw" -C dependency:get -Dtransitive=false -Dartifact="io.trino.gateway:trino-gateway-server:${TRINO_GATEWAY_VERSION}:tar.gz"
100100
local_repo=$("${SOURCE_DIR}/mvnw" -B help:evaluate -Dexpression=settings.localRepository -q -DforceStdout)
101-
trino_gateway_ha="$local_repo/io/trino/gateway/gateway-ha/${TRINO_GATEWAY_VERSION}/gateway-ha-${TRINO_GATEWAY_VERSION}-jar-with-dependencies.jar"
101+
trino_gateway_ha="$local_repo/io/trino/gateway/trino-gateway-server/${TRINO_GATEWAY_VERSION}/trino-gateway-server-${TRINO_GATEWAY_VERSION}.tar.gz"
102102
chmod +x "$trino_gateway_ha"
103103
else
104104
TRINO_GATEWAY_VERSION=$("${SOURCE_DIR}/mvnw" -f "${SOURCE_DIR}/pom.xml" --quiet help:evaluate -Dexpression=project.version -DforceStdout)
105-
echo "🎯 Using currently built artifacts from the gateway-ha module with version ${TRINO_GATEWAY_VERSION}"
106-
trino_gateway_ha="${SOURCE_DIR}/gateway-ha/target/gateway-ha-${TRINO_GATEWAY_VERSION}-jar-with-dependencies.jar"
105+
echo "🎯 Using currently built artifacts with version ${TRINO_GATEWAY_VERSION}"
106+
trino_gateway_ha="${SOURCE_DIR}/trino-gateway-server/target/trino-gateway-server-${TRINO_GATEWAY_VERSION}.tar.gz"
107107
fi
108108

109109
echo "🧱 Preparing the image build context directory"
110110
WORK_DIR="$(mktemp -d)"
111-
GATEWAY_WORK_DIR="${WORK_DIR}/gateway-ha"
112-
mkdir "${GATEWAY_WORK_DIR}"
113-
cp "$trino_gateway_ha" "${GATEWAY_WORK_DIR}/gateway-ha-jar-with-dependencies.jar"
114-
cp -R bin "${GATEWAY_WORK_DIR}"
115-
cp "${SCRIPT_DIR}/Dockerfile" "${WORK_DIR}"
111+
cp "$trino_gateway_ha" "${WORK_DIR}/"
112+
tar -C "${WORK_DIR}" -xzf "${WORK_DIR}/trino-gateway-server-${TRINO_GATEWAY_VERSION}.tar.gz"
113+
rm "${WORK_DIR}/trino-gateway-server-${TRINO_GATEWAY_VERSION}.tar.gz"
114+
cp -R bin "${WORK_DIR}/trino-gateway-server-${TRINO_GATEWAY_VERSION}"
115+
cp -R default "${WORK_DIR}/"
116116

117117
TAG_PREFIX="trino-gateway:${TRINO_GATEWAY_VERSION}"
118118
#version file is used by the Helm chart test
@@ -131,7 +131,8 @@ for arch in "${ARCHITECTURES[@]}"; do
131131
--build-arg TRINO_GATEWAY_BASE_IMAGE="${TRINO_GATEWAY_BASE_IMAGE}" \
132132
--platform "linux/$arch" \
133133
-f Dockerfile \
134-
-t "${TAG_PREFIX}-$arch"
134+
-t "${TAG_PREFIX}-$arch" \
135+
--build-arg "TRINO_GATEWAY_VERSION=${TRINO_GATEWAY_VERSION}"
135136
done
136137

137138
echo "🧹 Cleaning up the build context directory"
File renamed without changes.

docker/default/etc/jvm.config

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-server
2+
-XX:InitialRAMPercentage=80
3+
-XX:MaxRAMPercentage=80
4+
-XX:G1HeapRegionSize=32M
5+
-XX:+ExplicitGCInvokesConcurrent
6+
-XX:+HeapDumpOnOutOfMemoryError
7+
-XX:+ExitOnOutOfMemoryError
8+
-XX:-OmitStackTraceInFastThrow
9+
-XX:ReservedCodeCacheSize=256M
10+
-XX:PerMethodRecompilationCutoff=10000
11+
-XX:PerBytecodeRecompilationCutoff=10000
12+
-Djdk.attach.allowAttachSelf=true
13+
-Djdk.nio.maxCachedBufferSize=2000000
14+
# Reduce starvation of threads by GClocker, recommend to set about the number of cpu cores (JDK-8192647)
15+
-XX:+UnlockDiagnosticVMOptions
16+
-XX:GCLockerRetryAllocationCount=32
17+
# Allow loading dynamic agent used by JOL
18+
-XX:+EnableDynamicAgentLoading

docker/default/etc/log.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Enable verbose logging from Trino
2+
#io.trino=DEBUG

docker/default/etc/node.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node.environment=docker
2+
node.data-dir=/data/trino-gateway

docker/docker-compose.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ services:
1212
start_period: 20s
1313
ports:
1414
- "8080:8080"
15-
volumes:
16-
- target: /etc/trino-gateway/config.yaml
17-
source: ./config.yaml
18-
type: bind
1915

2016
postgres:
2117
image: ${TRINO_GATEWAY_POSTGRES_IMAGE:-postgres}

gateway-ha/src/main/java/io/trino/gateway/ha/HaGatewayLauncher.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,11 @@ public static void main(String[] args)
109109
throws Exception
110110
{
111111
ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory());
112-
if (args.length != 1) {
113-
throw new IllegalArgumentException("Expected exactly one argument (path of configuration file)");
112+
String configFile = System.getProperty("config");
113+
if (configFile == null) {
114+
throw new IllegalArgumentException("Configuration file not specified. Use -Dconfig=<config-file>");
114115
}
115-
String config = Files.readString(Path.of(args[0]));
116+
String config = Files.readString(Path.of(configFile));
116117
HaGatewayConfiguration haGatewayConfiguration = objectMapper.readValue(replaceEnvironmentVariables(config), HaGatewayConfiguration.class);
117118
FlywayMigration.migrate(haGatewayConfiguration.getDataStore());
118119
List<Module> modules = addModules(haGatewayConfiguration);

gateway-ha/src/test/java/io/trino/gateway/TrinoGatewayRunner.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ public static void main(String[] args)
6060
mysql.withCopyFileToContainer(forClasspathResource("add_backends_mysql.sql"), "/docker-entrypoint-initdb.d/2-add_backends_mysql.sql");
6161
mysql.setPortBindings(List.of("3306:3306"));
6262
mysql.start();
63-
HaGatewayLauncher.main(new String[] {"gateway-ha/config.yaml"});
63+
System.setProperty("config", "gateway-ha/config.yaml");
64+
HaGatewayLauncher.main(new String[] {});
6465

6566
log.info("======== SERVER STARTED ========");
6667
}

0 commit comments

Comments
 (0)