gortiz commented on code in PR #19448:
URL: https://github.com/apache/pinot/pull/19448#discussion_r4708436842
##########
pinot-plugins/pinot-stream-ingestion/pinot-kinesis/pom.xml:
##########
@@ -38,6 +38,11 @@
<dependency>
<groupId>org.apache.pinot</groupId>
<artifactId>pinot-common</artifactId>
+ <!-- Pinot's own modules are always present where a plugin is loaded,
from lib/pinot-all.jar or
+ the parent realm, so bundling them into the plugin would ship a
second copy of them and of
+ their dependency tree - here fastutil, calcite-core and
grpc-netty-shaded, none of which
+ this plugin uses directly -->
+ <scope>provided</scope>
Review Comment:
Thanks, good catch. I reproduced it with a small script that reads the
`dependency:tree` of pinot-distribution (that is the order shade sees) and
replays "first copy wins" over the jars, at the base and at this head. It gave
the same result as your CRC diff: 883 Grizzly classes from tyrus, and 85
`javax/servlet` classes from `javax.servlet-api` (via hadoop-common).
The fix moves the `pinot-java-client` dependency of pinot-tools to where
pinot-kinesis used to bring pinot-common, so pinot-common's subtree comes
before hadoop-common and tyrus again. The resolved artifact set does not
change, only the order. With that, the replay shows no winner change against
the base in the default build, and JAXB stays as it was. I left a comment on
the dependency so nobody moves it by accident.
This is still order-dependent, so I'd like a check that catches the next
one. I'll describe it in the main thread.
##########
pinot-common/pom.xml:
##########
@@ -32,6 +32,12 @@
<properties>
<pinot.root>${basedir}/..</pinot.root>
<thrift.bin.path>/usr/local/bin/thrift</thrift.bin.path>
+ <!-- The -shaded jar is for projects outside Pinot and is not part of
pinot-all, so it relocates its
+ libraries in every build mode, including thin-plugins, like the
clients. See shade.jackson.prefix
+ in the root pom. The main jar is not shaded. -->
+
<shade.jackson.prefix>${shade.prefix}.com.fasterxml.jackson</shade.jackson.prefix>
+ <shade.guava.prefix>${shade.prefix}.com.google.common</shade.guava.prefix>
+ <shade.scala.prefix>${shade.prefix}.org.scala-lang</shade.scala.prefix>
Review Comment:
Done. pinot-spi and pinot-core now pin the three prefixes like pinot-common,
so their `-shaded` jars relocate in both modes. `help:evaluate` shows
`org.apache.pinot.shaded.com.fasterxml.jackson` for both modules with and
without `-Pthin-plugins`.
##########
pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/LaunchSparkDataIngestionJobCommand.java:
##########
@@ -213,6 +243,24 @@ public boolean execute()
return true;
}
+ /// Fails when the Pinot installation has the thin plugin layout (a
`plugin-libs/` directory). The
+ /// Spark ingestion jar relocates Jackson and Guava, and links against the
relocated copies in the
+ /// `pinot-all` jar of the default distribution. The thin `pinot-all` does
not relocate them, so the
+ /// job fails with linkage errors on the executors. A remote base directory
is not checked.
+ @VisibleForTesting
+ static void checkNotThinDistribution(String pinotBaseDir) {
+ URI uri = URI.create(pinotBaseDir);
+ if (uri.getScheme() != null && !uri.getScheme().equals("file")) {
Review Comment:
Agreed, that is simpler and covers more. `resolveDepsJars` now refuses as
soon as the listing has a jar under `plugin-libs/` or a
`pinot-plugin.classpath`, so local and remote installations are checked the
same way. I removed `checkNotThinDistribution`, the index reader and their
tests. The test now covers the default selection, an explicit selection, and
the refusal for a store or an index, as a path and as a URI.
##########
pinot-tools/src/main/resources/appAssemblerScriptTemplate:
##########
@@ -112,6 +112,35 @@ fi
# $PLUGINS_DIR is semi-colon separated list of plugin directories, default to
'"$BASEDIR"/plugins' if not set.
# $PLUGINS_INCLUDE is semi-colon separated plugins name, e.g.
pinot-avro;pinot-batch-ingestion-standalone. Default is not set, which means
load all the plugin jars.
# If the same plugin is found in multiple directories, it will only be picked
up from the first directory it was found. The directories in $PLUGINS_DIR are
traversed by their order.
+#
+# A plugin ships as a thin jar plus a pinot-plugin.classpath file listing the
shared-store jars it
+# needs, as paths relative to $BASEDIR. Selecting a subset with
$PLUGINS_INCLUDE therefore
+# means taking each named plugin's jars *and* the store entries its index
names - the store as a
+# whole is not per-plugin, so adding all of it would defeat the selection. The
whole store is added
+# only when every built-in plugin is loaded, after the jars of all
directories, so that a jar in a
+# custom plugin directory still wins over a store jar with the same classes.
+# Paths may contain spaces: find results are read NUL-delimited.
+
+# Appends one entry to $PLUGINS_CLASSPATH.
+add_to_plugins_classpath() {
+ PLUGINS_CLASSPATH=${PLUGINS_CLASSPATH:+$PLUGINS_CLASSPATH:}$1
+}
+
+# Appends the shared-store jars that the pinot-plugin.classpath index $1
names, once each.
+add_plugin_index() {
+ local PLUGIN_DEP
+ # The index is a classpath fragment: entries separated by ':' and/or
newlines. build-classpath
+ # writes no final newline, so the last entry is read when read fails but the
variable is set.
+ while IFS= read -r PLUGIN_DEP || [ -n "$PLUGIN_DEP" ] ; do
+ if [ -n "$PLUGIN_DEP" ] && [ -f "$BASEDIR/$PLUGIN_DEP" ] ; then
+ case ":$PLUGINS_CLASSPATH:" in
+ *":$BASEDIR/$PLUGIN_DEP:"*) ;;
+ *) add_to_plugins_classpath "$BASEDIR/$PLUGIN_DEP" ;;
+ esac
+ fi
+ done < <(tr ':' '\n' < "$1")
Review Comment:
Fixed. The block now uses only POSIX syntax: `find` output and the index go
through here-documents and plain `read`, and the `[[ ]]` checks are `case`.
Paths with spaces still work. I ran the generated script with bash, `sh` (bash
as sh) and dash, with all plugins, `PLUGINS_INCLUDE`, and a custom plus
built-in `PLUGINS_DIR`, and the class path is the same in all three. The
quickstart job now also runs `sh -n` on every `build/bin/*.sh`, and on Ubuntu
`sh` is dash, so this can't come back silently.
##########
pinot-tools/src/main/resources/appAssemblerScriptTemplate:
##########
@@ -112,6 +112,35 @@ fi
# $PLUGINS_DIR is semi-colon separated list of plugin directories, default to
'"$BASEDIR"/plugins' if not set.
# $PLUGINS_INCLUDE is semi-colon separated plugins name, e.g.
pinot-avro;pinot-batch-ingestion-standalone. Default is not set, which means
load all the plugin jars.
# If the same plugin is found in multiple directories, it will only be picked
up from the first directory it was found. The directories in $PLUGINS_DIR are
traversed by their order.
+#
+# A plugin ships as a thin jar plus a pinot-plugin.classpath file listing the
shared-store jars it
+# needs, as paths relative to $BASEDIR. Selecting a subset with
$PLUGINS_INCLUDE therefore
+# means taking each named plugin's jars *and* the store entries its index
names - the store as a
+# whole is not per-plugin, so adding all of it would defeat the selection. The
whole store is added
+# only when every built-in plugin is loaded, after the jars of all
directories, so that a jar in a
+# custom plugin directory still wins over a store jar with the same classes.
+# Paths may contain spaces: find results are read NUL-delimited.
+
+# Appends one entry to $PLUGINS_CLASSPATH.
+add_to_plugins_classpath() {
+ PLUGINS_CLASSPATH=${PLUGINS_CLASSPATH:+$PLUGINS_CLASSPATH:}$1
+}
+
+# Appends the shared-store jars that the pinot-plugin.classpath index $1
names, once each.
+add_plugin_index() {
+ local PLUGIN_DEP
+ # The index is a classpath fragment: entries separated by ':' and/or
newlines. build-classpath
+ # writes no final newline, so the last entry is read when read fails but the
variable is set.
+ while IFS= read -r PLUGIN_DEP || [ -n "$PLUGIN_DEP" ] ; do
+ if [ -n "$PLUGIN_DEP" ] && [ -f "$BASEDIR/$PLUGIN_DEP" ] ; then
Review Comment:
Done. The launcher now uses the PluginManager rule: an entry resolves
against the nearest ancestor of the plugin directory that has it. If no
ancestor has it, it falls back to `$BASEDIR`, which keeps the old behavior for
a custom plugin built against the installation's store. An entry it can't find
prints a warning on stderr. Your example now gives `acme.jar`, `own.jar` and
`both.jar` from `custom/`, and `shared.jar` from the installation.
##########
pinot-distribution/pinot-assembly-thin.xml:
##########
@@ -0,0 +1,526 @@
+<!--
+
+ 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.
+
+-->
+<assembly
+
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2
http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+ <id>bin</id>
+ <formats>
+ <format>tar.gz</format>
+ <format>dir</format>
Review Comment:
Fixed in the bin-dist profile of pinot-distribution, so it covers both
layouts: a `maven-clean-plugin` execution at `prepare-package` removes
`target/apache-pinot-<version>-bin`. The shaded jar is elsewhere in `target/`
and stays. The StarTree distribution has the same execution.
And thanks for the offer on the patch-dependency rule. Yes, please open it
as the follow-up once this merges.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]