Skip to content

Commit b91d5fa

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

File tree

17 files changed

+160
-27
lines changed

17 files changed

+160
-27
lines changed

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ COPY --chown=trino:trino gateway-ha /usr/lib/trino-gateway
4747

4848
EXPOSE 8080
4949
USER trino:trino
50-
CMD java -jar /usr/lib/trino-gateway/gateway-ha-jar-with-dependencies.jar "/etc/trino-gateway/config.yaml"
50+
CMD /usr/lib/trino-gateway/gateway-server/bin/launcher start --config "/etc/trino-gateway/config.yaml"
5151

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

docker/build.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,18 @@ if [ -n "$TRINO_GATEWAY_VERSION" ]; then
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}/gateway-server/target/gateway-server-${TRINO_GATEWAY_VERSION}.tar.gz"
107107
fi
108108

109109
echo "🧱 Preparing the image build context directory"
110110
WORK_DIR="$(mktemp -d)"
111111
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"
112+
GATEWAY_SERVER_DIR="${WORK_DIR}/gateway-ha/gateway-server"
113+
mkdir -p "${GATEWAY_SERVER_DIR}/etc"
114+
touch "${GATEWAY_SERVER_DIR}/etc/jvm.config"
115+
tar -zx --strip 1 -C "${GATEWAY_SERVER_DIR}" -f "${trino_gateway_ha}"
116+
#cp "$trino_gateway_ha" "${GATEWAY_WORK_DIR}/gateway-ha-jar-with-dependencies.jar"
114117
cp -R bin "${GATEWAY_WORK_DIR}"
115118
cp "${SCRIPT_DIR}/Dockerfile" "${WORK_DIR}"
116119

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
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ public MockResponse dispatch(RecordedRequest request)
120120
HaGatewayTestUtils.buildGatewayConfig(postgresql, routerPort, "test-config-template.yml");
121121

122122
// Start Gateway
123-
String[] args = {testConfigFile.getAbsolutePath()};
124-
HaGatewayLauncher.main(args);
123+
System.setProperty("config", testConfigFile.getAbsolutePath());
124+
HaGatewayLauncher.main(new String[] {});
125125
// Now populate the backend
126126
HaGatewayTestUtils.setUpBackend(
127127
"trino1", "http://localhost:" + backend1Port, "externalUrl", true, "adhoc", routerPort);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ void setup()
5858
File testConfigFile =
5959
HaGatewayTestUtils.buildGatewayConfig(postgresql, routerPort, "test-config-template.yml");
6060
// Start Gateway
61-
String[] args = {testConfigFile.getAbsolutePath()};
62-
HaGatewayLauncher.main(args);
61+
System.setProperty("config", testConfigFile.getAbsolutePath());
62+
HaGatewayLauncher.main(new String[] {});
6363
// Now populate the backend
6464
HaGatewayTestUtils.setUpBackend(
6565
"trino1", "http://localhost:" + backendPort, "externalUrl", true, "adhoc", routerPort);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ void setup()
5555
File testConfigFile =
5656
HaGatewayTestUtils.buildGatewayConfig(postgresql, routerPort, "test-config-with-routing-template.yml");
5757
// Start Gateway
58-
String[] args = {testConfigFile.getAbsolutePath()};
59-
HaGatewayLauncher.main(args);
58+
System.setProperty("config", testConfigFile.getAbsolutePath());
59+
HaGatewayLauncher.main(new String[] {});
6060
// Now populate the backend
6161
HaGatewayTestUtils.setUpBackend(
6262
"trino1", "http://localhost:" + backendPort, "externalUrl", true, "system", routerPort);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ void setup()
5757
File testConfigFile =
5858
HaGatewayTestUtils.buildGatewayConfig(postgresql, routerPort, "test-config-without-x-forwarded-template.yml");
5959
// Start Gateway
60-
String[] args = {testConfigFile.getAbsolutePath()};
61-
HaGatewayLauncher.main(args);
60+
System.setProperty("config", testConfigFile.getAbsolutePath());
61+
HaGatewayLauncher.main(new String[] {});
6262
// Now populate the backend
6363
HaGatewayTestUtils.setUpBackend(
6464
"trino1", "http://localhost:" + backendPort, "externalUrl", true, "adhoc", routerPort);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ void setup()
7070
resourceGroupManager = new HaResourceGroupsManager(connectionManager);
7171

7272
// Start Trino Gateway so migrations are run to create tables before inserting test data
73-
String[] args = {testConfigFile.getAbsolutePath()};
74-
HaGatewayLauncher.main(args);
73+
System.setProperty("config", testConfigFile.getAbsolutePath());
74+
HaGatewayLauncher.main(new String[] {});
7575

7676
prepareData();
7777
}

gateway-ha/src/test/java/io/trino/gateway/ha/router/TestRoutingAPI.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ void setup()
6363
File testConfigFile =
6464
HaGatewayTestUtils.buildGatewayConfig(postgresql, routerPort, "test-config-with-routing-rules-api.yml");
6565
// Start Gateway
66-
String[] args = {testConfigFile.getAbsolutePath()};
67-
HaGatewayLauncher.main(args);
66+
System.setProperty("config", testConfigFile.getAbsolutePath());
67+
HaGatewayLauncher.main(new String[] {});
6868
// Now populate the backend
6969
HaGatewayTestUtils.setUpBackend(
7070
"trino1", "http://localhost:" + backendPort, "externalUrl", true, "adhoc", routerPort);

0 commit comments

Comments
 (0)