Skip to content

Commit 743b038

Browse files
authored
[build][sql] Make pulsar-trino-disto self-contained (apache#17062)
1 parent bbcbf32 commit 743b038

File tree

15 files changed

+49
-34
lines changed

15 files changed

+49
-34
lines changed

.github/workflows/ci-owasp-dep-check.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
docker rmi $(docker images -q) -f
8888
df -h
8989
90-
# Projects dependent on flume, hdfs, hbase, and presto currently excluded from the scan.
90+
# Projects dependent on flume, hdfs, hbase, and trino currently excluded from the scan.
9191
- name: run "clean verify" to trigger dependency check
9292
if: ${{ steps.changes.outputs.poms == 'true' }}
9393
run: mvn -q -B -ntp clean verify -PskipDocker,owasp-dependency-check -DskipTests -pl '!pulsar-sql,!distribution/io,!distribution/offloaders,!tiered-storage/file-system,!pulsar-io/flume,!pulsar-io/hbase,!pulsar-io/hdfs2,!pulsar-io/hdfs3,!pulsar-io/docs,!pulsar-io/jdbc/openmldb'

bin/pulsar

+28-17
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ DEFAULT_PROXY_CONF=$PULSAR_HOME/conf/proxy.conf
3333
DEFAULT_STANDALONE_CONF=$PULSAR_HOME/conf/standalone.conf
3434
DEFAULT_WEBSOCKET_CONF=$PULSAR_HOME/conf/websocket.conf
3535
DEFAULT_LOG_CONF=$PULSAR_HOME/conf/log4j2.yaml
36-
DEFAULT_PULSAR_PRESTO_CONF=${PULSAR_HOME}/conf/presto
3736
DEFAULT_FUNCTIONS_LOG_CONF=$PULSAR_HOME/conf/functions_log4j2.xml
3837

3938
# functions related variables
@@ -46,7 +45,8 @@ PY_INSTANCE_FILE=${PULSAR_PY_INSTANCE_FILE:-"${DEFAULT_PY_INSTANCE_FILE}"}
4645
DEFAULT_FUNCTIONS_EXTRA_DEPS_DIR=$PULSAR_HOME/instances/deps
4746
FUNCTIONS_EXTRA_DEPS_DIR=${PULSAR_FUNCTIONS_EXTRA_DEPS_DIR:-"${DEFAULT_FUNCTIONS_EXTRA_DEPS_DIR}"}
4847
SQL_HOME=$PULSAR_HOME/pulsar-sql
49-
PRESTO_HOME=${PULSAR_HOME}/lib/presto
48+
TRINO_HOME=${PULSAR_HOME}/trino
49+
DEFAULT_PULSAR_TRINO_CONF=${TRINO_HOME}/conf
5050

5151
pulsar_help() {
5252
cat <<EOF
@@ -90,7 +90,7 @@ Environment variables:
9090
PULSAR_PROXY_CONF Configuration file for Pulsar proxy (default: $DEFAULT_PROXY_CONF)
9191
PULSAR_WORKER_CONF Configuration file for functions worker (default: $DEFAULT_WORKER_CONF)
9292
PULSAR_STANDALONE_CONF Configuration file for standalone (default: $DEFAULT_STANDALONE_CONF)
93-
PULSAR_PRESTO_CONF Configuration directory for Pulsar Presto (default: $DEFAULT_PULSAR_PRESTO_CONF)
93+
PULSAR_TRINO_CONF Configuration directory for Pulsar SQL (default: $DEFAULT_PULSAR_TRINO_CONF)
9494
PULSAR_EXTRA_OPTS Extra options to be passed to the jvm
9595
PULSAR_EXTRA_CLASSPATH Add extra paths to the pulsar classpath
9696
PULSAR_PID_DIR Folder where the pulsar server PID file should be stored
@@ -177,17 +177,17 @@ if [ ! -f "${PY_INSTANCE_FILE}" ]; then
177177
PY_INSTANCE_FILE=${BUILT_PY_INSTANCE_FILE}
178178
fi
179179

180-
# find pulsar sql presto distribution location
181-
check_presto_libraries() {
182-
if [ ! -d "${PRESTO_HOME}" ]; then
183-
184-
BUILT_PRESTO_HOME="${SQL_HOME}/presto-distribution/target/pulsar-presto-distribution"
185-
if [ ! -d "${BUILT_PRESTO_HOME}" ]; then
186-
echo "\nCouldn't find presto distribution.";
180+
# find pulsar sql trino distribution location
181+
check_trino_libraries() {
182+
if [ ! -d "${TRINO_HOME}" ]; then
183+
BUILT_TRINO_HOME="${SQL_HOME}/presto-distribution/target/pulsar-presto-distribution"
184+
if [ ! -d "${BUILT_TRINO_HOME}" ]; then
185+
echo "\nCouldn't find trino distribution.";
187186
echo "Make sure you've run 'mvn package'\n";
188187
exit 1;
189188
fi
190-
PRESTO_HOME=${BUILT_PRESTO_HOME}
189+
TRINO_HOME=${BUILT_TRINO_HOME}
190+
PULSAR_TRINO_CONF=${BUILT_TRINO_HOME}/conf
191191
fi
192192
}
193193

@@ -257,8 +257,19 @@ if [ -z "$PULSAR_LOG_CONF" ]; then
257257
PULSAR_LOG_CONF=$DEFAULT_LOG_CONF
258258
fi
259259

260-
if [ -z "$PULSAR_PRESTO_CONF" ]; then
261-
PULSAR_PRESTO_CONF=$DEFAULT_PULSAR_PRESTO_CONF
260+
if [ -z "$PULSAR_TRINO_CONF" ]; then
261+
# TODO: As PIP-200 accepted, this compatibility is not promised. Refactor when we drop this b/w compatibility.
262+
if [ -z "$PULSAR_PRESTO_CONF" ]; then
263+
PULSAR_TRINO_CONF=$DEFAULT_PULSAR_TRINO_CONF
264+
else
265+
PULSAR_TRINO_CONF=$PULSAR_PRESTO_CONF
266+
fi
267+
if [ ! -d "${PULSAR_TRINO_CONF}" ]; then
268+
FALLBACK_PULSAR_PRESTO_CONF=${PULSAR_HOME}/conf/presto
269+
if [ -d "${FALLBACK_PULSAR_PRESTO_CONF}" ]; then
270+
PULSAR_TRINO_CONF=$FALLBACK_PULSAR_PRESTO_CONF
271+
fi
272+
fi
262273
fi
263274

264275
if [ -z "$FUNCTIONS_LOG_CONF"]; then
@@ -387,11 +398,11 @@ elif [ $COMMAND == "broker-tool" ]; then
387398
elif [ $COMMAND == "compact-topic" ]; then
388399
exec $JAVA $OPTS org.apache.pulsar.compaction.CompactorTool --broker-conf $PULSAR_BROKER_CONF $@
389400
elif [ $COMMAND == "sql" ]; then
390-
check_presto_libraries
391-
exec $JAVA -cp "${PRESTO_HOME}/lib/*" io.trino.cli.Trino --server localhost:8081 "${@}"
401+
check_trino_libraries
402+
exec $JAVA -cp "${TRINO_HOME}/lib/*" io.trino.cli.Trino --server localhost:8081 "${@}"
392403
elif [ $COMMAND == "sql-worker" ]; then
393-
check_presto_libraries
394-
exec python3 ${PRESTO_HOME}/bin/launcher.py --etc-dir ${PULSAR_PRESTO_CONF} "${@}"
404+
check_trino_libraries
405+
exec python3 ${TRINO_HOME}/bin/launcher.py --etc-dir ${PULSAR_TRINO_CONF} "${@}"
395406
elif [ $COMMAND == "tokens" ]; then
396407
exec $JAVA $OPTS org.apache.pulsar.utils.auth.tokens.TokensCliUtils $@
397408
elif [ $COMMAND == "version" ]; then

distribution/server/src/assemble/bin.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@
6262
</fileSet>
6363
<fileSet>
6464
<directory>${basedir}/../../pulsar-sql/presto-distribution/target/pulsar-presto-distribution</directory>
65-
<outputDirectory>lib/presto</outputDirectory>
65+
<outputDirectory>trino</outputDirectory>
6666
<excludes>
6767
<exclude>bin</exclude>
6868
<exclude>bin/**</exclude>
6969
</excludes>
7070
</fileSet>
7171
<fileSet>
7272
<directory>${basedir}/../../pulsar-sql/presto-distribution/target/pulsar-presto-distribution</directory>
73-
<outputDirectory>lib/presto</outputDirectory>
73+
<outputDirectory>trino</outputDirectory>
7474
<includes>
7575
<include>bin/**</include>
7676
</includes>

docker-compose/kitchen-sink/docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ services:
368368
image: apachepulsar/pulsar-all:latest
369369
restart: on-failure
370370
command: >
371-
bash -c "bin/apply-config-from-env-with-prefix.py SQL_PREFIX_ conf/presto/catalog/pulsar.properties && \
371+
bash -c "bin/apply-config-from-env-with-prefix.py SQL_PREFIX_ trino/conf/catalog/pulsar.properties && \
372372
bin/apply-config-from-env.py conf/pulsar_env.sh && \
373373
bin/watch-znode.py -z $$zookeeperServers -p /initialized-$$clusterName -w && \
374374
exec bin/pulsar sql-worker run"

docker/pulsar/Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ RUN for SUBDIRECTORY in conf data download logs; do \
4242
chmod -R g+w /pulsar/$SUBDIRECTORY; \
4343
done
4444

45-
# Presto writes logs to this directory (at least during tests), so we need to give the process permission
46-
# to create those log directories. This should be removed when presto is removed.
47-
RUN chmod g+w /pulsar/lib/presto
45+
# Trino writes logs to this directory (at least during tests), so we need to give the process permission
46+
# to create those log directories. This should be removed when Trino is removed.
47+
RUN chmod g+w /pulsar/trino
4848

4949
### Create 2nd stage from Ubuntu image
5050
### and add OpenJDK and Python dependencies (for Pulsar functions)

pulsar-sql/presto-distribution/src/assembly/assembly.xml

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
<directory>${basedir}/../presto-pulsar-plugin/target/pulsar-presto-connector/</directory>
4747
<outputDirectory>plugin/</outputDirectory>
4848
</fileSet>
49+
<fileSet>
50+
<directory>${basedir}/src/main/resources/conf/</directory>
51+
<outputDirectory>conf/</outputDirectory>
52+
</fileSet>
4953
</fileSets>
5054
<dependencySets>
5155
<dependencySet>

src/check-binary-license.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ if [ -z $TARBALL ]; then
4141
exit 1
4242
fi
4343

44-
JARS=$(tar -tf $TARBALL | grep '\.jar' | grep -v 'lib/presto/' | grep -v '/examples/' | grep -v '/instances/' | sed 's!.*/!!' | sort)
44+
JARS=$(tar -tf $TARBALL | grep '\.jar' | grep -v 'trino/' | grep -v '/examples/' | grep -v '/instances/' | sed 's!.*/!!' | sort)
4545

4646
LICENSEPATH=$(tar -tf $TARBALL | awk '/^[^\/]*\/LICENSE/')
4747
LICENSE=$(tar -O -xf $TARBALL "$LICENSEPATH")
@@ -96,7 +96,7 @@ done
9696

9797
if [ "$NO_PRESTO" -ne 1 ]; then
9898
# check pulsar sql jars
99-
JARS=$(tar -tf $TARBALL | grep '\.jar' | grep 'lib/presto/' | grep -v pulsar-client | grep -v bouncy-castle-bc | grep -v pulsar-metadata | grep -v 'managed-ledger' | grep -v 'pulsar-client-admin' | grep -v 'pulsar-client-api' | grep -v 'pulsar-functions-api' | grep -v 'pulsar-presto-connector-original' | grep -v 'pulsar-presto-distribution' | grep -v 'pulsar-common' | grep -v 'pulsar-functions-proto' | grep -v 'pulsar-functions-utils' | grep -v 'pulsar-io-core' | grep -v 'pulsar-transaction-common' | grep -v 'pulsar-package-core' | sed 's!.*/!!' | sort)
99+
JARS=$(tar -tf $TARBALL | grep '\.jar' | grep 'trino/' | grep -v pulsar-client | grep -v bouncy-castle-bc | grep -v pulsar-metadata | grep -v 'managed-ledger' | grep -v 'pulsar-client-admin' | grep -v 'pulsar-client-api' | grep -v 'pulsar-functions-api' | grep -v 'pulsar-presto-connector-original' | grep -v 'pulsar-presto-distribution' | grep -v 'pulsar-common' | grep -v 'pulsar-functions-proto' | grep -v 'pulsar-functions-utils' | grep -v 'pulsar-io-core' | grep -v 'pulsar-transaction-common' | grep -v 'pulsar-package-core' | sed 's!.*/!!' | sort)
100100
if [ -n "$JARS" ]; then
101101
LICENSEPATH=$(tar -tf $TARBALL | awk '/^[^\/]*\/lib\/presto\/LICENSE/')
102102
LICENSE=$(tar -O -xf $TARBALL "$LICENSEPATH")
@@ -111,7 +111,7 @@ if [ "$NO_PRESTO" -ne 1 ]; then
111111

112112
echo "$LICENSE" | grep -q $J
113113
if [ $? != 0 ]; then
114-
echo $J unaccounted for in lib/presto/LICENSE
114+
echo $J unaccounted for in trino/LICENSE
115115
EXIT=1
116116
fi
117117
done
@@ -120,7 +120,7 @@ if [ "$NO_PRESTO" -ne 1 ]; then
120120
for J in $LICENSEJARS; do
121121
echo "$JARS" | grep -q $J
122122
if [ $? != 0 ]; then
123-
echo $J mentioned in lib/presto/LICENSE, but not bundled
123+
echo $J mentioned in trino/LICENSE, but not bundled
124124
EXIT=2
125125
fi
126126
done

tests/docker-images/latest-version-image/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ COPY scripts/init-cluster.sh scripts/run-global-zk.sh scripts/run-local-zk.sh \
8989
scripts/run-standalone.sh \
9090
/pulsar/bin/
9191

92-
COPY conf/presto/jvm.config /pulsar/conf/presto/
92+
COPY conf/presto/jvm.config /pulsar/trino/conf
9393

9494
# copy python test examples
9595
RUN mkdir -p /pulsar/instances/deps

tests/docker-images/latest-version-image/scripts/run-presto-worker.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# under the License.
1919
#
2020

21-
bin/apply-config-from-env-with-prefix.py SQL_PREFIX_ conf/presto/catalog/pulsar.properties && \
21+
bin/apply-config-from-env-with-prefix.py SQL_PREFIX_ trino/conf/catalog/pulsar.properties && \
2222
bin/apply-config-from-env.py conf/pulsar_env.sh
2323

2424
if [ -z "$NO_AUTOSTART" ]; then

tests/integration/src/test/java/org/apache/pulsar/tests/integration/containers/PrestoWorkerContainer.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ public PrestoWorkerContainer(String clusterName, String hostname) {
4343
@Override
4444
protected void afterStart() {
4545
DockerUtils.runCommandAsyncWithLogging(this.dockerClient, this.getContainerId(),
46-
"tail", "-f", "/pulsar/lib/presto/var/log/launcher.log");
46+
"tail", "-f", "/pulsar/trino/var/log/launcher.log");
4747
DockerUtils.runCommandAsyncWithLogging(this.dockerClient, this.getContainerId(),
4848
"tail", "-f", "/var/log/pulsar/presto_worker.log");
4949
DockerUtils.runCommandAsyncWithLogging(this.dockerClient, this.getContainerId(),
50-
"tail", "-f", "/pulsar/lib/presto/var/log/server.log");
50+
"tail", "-f", "/pulsar/trino/var/log/server.log");
5151
}
5252

5353
@Override
@@ -57,7 +57,7 @@ protected void beforeStop() {
5757
DockerUtils.dumpContainerDirToTargetCompressed(
5858
getDockerClient(),
5959
getContainerId(),
60-
"/pulsar/lib/presto/var/log"
60+
"/pulsar/trino/var/log"
6161
);
6262
}
6363
}

tests/integration/src/test/java/org/apache/pulsar/tests/integration/topologies/PulsarCluster.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ private PrestoWorkerContainer buildPrestoWorkerContainer(String hostName, boolea
438438
.withEnv("pulsar.web-service-url", "http://pulsar-broker-0:8080")
439439
.withEnv("SQL_PREFIX_pulsar.max-message-size", "" + spec.maxMessageSize)
440440
.withClasspathResourceMapping(
441-
resourcePath, "/pulsar/conf/presto/config.properties", BindMode.READ_WRITE);
441+
resourcePath, "/pulsar/trino/conf/config.properties", BindMode.READ_WRITE);
442442
if (spec.queryLastMessage) {
443443
container.withEnv("pulsar.bookkeeper-use-v2-protocol", "false")
444444
.withEnv("pulsar.bookkeeper-explicit-interval", "10");

0 commit comments

Comments
 (0)