-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Support loading plugins from multiple directories #7871
Support loading plugins from multiple directories #7871
Conversation
6b3db36
to
4acfecb
Compare
Codecov Report
@@ Coverage Diff @@
## master #7871 +/- ##
============================================
- Coverage 71.65% 71.38% -0.28%
- Complexity 4080 4082 +2
============================================
Files 1581 1583 +2
Lines 81350 81885 +535
Branches 12128 12242 +114
============================================
+ Hits 58293 58452 +159
- Misses 19117 19475 +358
- Partials 3940 3958 +18
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
aeae4df
to
197bd5e
Compare
@Jackie-Jiang @jadami10 Would you review this when you get a chance? Thanks! |
...in/java/org/apache/pinot/plugin/ingestion/batch/hadoop/HadoopSegmentGenerationJobRunner.java
Show resolved
Hide resolved
File pluginsTarGzFile = new File(PINOT_PLUGINS_TAR_GZ); | ||
try { | ||
File[] files = validPluginDirectories.toArray(new File[0]); | ||
TarGzCompressionUtils.createTarGzFile(files, pluginsTarGzFile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does this untar later? If I have
/a/b
/a/c
/b/c
will it come back out the same way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so the initial createTarGzFile which accepted 1 File obj, also accepted directories with support for recursion too: so let's say I called createTarGzFile with 1 directory (/a/...) that entire one will be tarred and it's children.
now, using the new method if I call it on let's say [ /a/ and /b/ ], the dir name is used as the baseEntryName (see ln 89 in TarGzCompressionUtils.java).
so effectively, if you tar two directories /a/ and /b/, it should come the same way as you pasted above
pinot-spi/src/main/java/org/apache/pinot/spi/plugin/PluginManager.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/utils/TarGzCompressionUtils.java
Show resolved
Hide resolved
assertEquals(untarredFiles.size(), 4); | ||
|
||
File untarredFileDir1 = untarredFiles.get(0); | ||
File untarredFileDir2 = untarredFiles.get(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some comments on why the 1st and 3rd would be fetched.
pinot-spi/src/main/java/org/apache/pinot/spi/plugin/PluginManager.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/utils/TarGzCompressionUtils.java
Outdated
Show resolved
Hide resolved
@VisibleForTesting | ||
public HashMap<String, File> getPluginsToLoad(String pluginsDirectories, String pluginsInclude) throws | ||
IllegalArgumentException { | ||
String[] directories = pluginsDirectories.split(";"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel it is more common to use ,
as the array separator (e.g. in Apache commons configuration). Is there some special reason why picking ;
as the separator here?
(minor) Use StringUtils.split(pluginsDirectories, ',')
for slightly better performance (avoid regex checking)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used ;
as the plugin to include property also used it to be consistent, but I am fine with changing it to ,
, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to priyen. plugins themselves use ;
. and most PATH-like things use ;
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized that the pluginsInclude
separator is changed from ',' to ';' in this PR which can cause backward incompatibility. Does it make sense to allow both as separator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit odd, the master bash code in pinot-tools/src/main/resources/appAssemblerScriptTemplate
is using export IFS=";"
when looping through $PLUGINS_INCLUDE
..now I'm wondering if pinot-spi/src/main/java/org/apache/pinot/spi/plugin/PluginManager.java
ln 157 pluginsToLoad = Arrays.asList(pluginsInclude.split(","));
in master was even working in the first place..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xiangfu0 Can you please take a look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
friendly ping, any ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now Pinot uses appAssemblerScriptTemplate
to set all the plugins into java classpath.
So far let's use semi-colon to make the delimiter.
For PluginManager.java, we should also follow the same delimiter convention to use semi-colon. For pluginInclude
, we can make the colon as backward compatible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for working on the feedback! this looks good!
...in/java/org/apache/pinot/plugin/ingestion/batch/hadoop/HadoopSegmentGenerationJobRunner.java
Show resolved
Hide resolved
@VisibleForTesting | ||
public HashMap<String, File> getPluginsToLoad(String pluginsDirectories, String pluginsInclude) throws | ||
IllegalArgumentException { | ||
String[] directories = pluginsDirectories.split(";"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to priyen. plugins themselves use ;
. and most PATH-like things use ;
as well?
_jarDirFile = new File(jarDir); | ||
_jarDirFile.mkdirs(); | ||
@Test | ||
public void testGetPluginsToLoad() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
solid test!
4bc5353
to
471591e
Compare
BufferedOutputStream bufferedOut = new BufferedOutputStream(fileOut); | ||
OutputStream gzipOut = new GzipCompressorOutputStream(bufferedOut); | ||
TarArchiveOutputStream tarGzOut = new TarArchiveOutputStream(gzipOut)) { | ||
BufferedOutputStream bufferedOut = new BufferedOutputStream(fileOut); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix the indentation?
* Creates a tar.gz file from a list of input file/directories to the output file. The output file must have | ||
* ".tar.gz" as the file extension. | ||
*/ | ||
public static void createTarGzFile(File[] inputFiles, File outputFile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shall we check and skip the nested paths?
E.g. one directory is a/b/c
and one file a/b/c/d.file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xiangfu0 can you clarify what you mean, so a/b/c/d.file
would be skipped since it's included already via a/b/c
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, if the override happens then it's not a problem to worry.
@VisibleForTesting | ||
public HashMap<String, File> getPluginsToLoad(String pluginsDirectories, String pluginsInclude) throws | ||
IllegalArgumentException { | ||
String[] directories = pluginsDirectories.split(";"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now Pinot uses appAssemblerScriptTemplate
to set all the plugins into java classpath.
So far let's use semi-colon to make the delimiter.
For PluginManager.java, we should also follow the same delimiter convention to use semi-colon. For pluginInclude
, we can make the colon as backward compatible.
Description
At Stripe, one of our use cases requires us to see if we can load plugins from more than 1 directory. This change allows Pinot to load plugins from directories other than just the root/default one. The existing plugin java property name,
PLUGINS_DIR_PROPERTY_NAME = "plugins.dir"
, originally is a string of 1 path, but now is a semi-colon delimited string which can have multiple paths.PLUGINS_INCLUDE_PROPERTY_NAME = "plugins.include"
was also updated to be semi-colon delimited to be consistent.Github issue: #7875
Testing performed:
plugins.dir
being set to string with 2 directories: ie; "/etc/plugins1;/etc/plugins2" and from logs can confirm plugins were found and loaded from both. Also confirmed theplugins.include
was respected and only plugins inside this property would be loaded.Upgrade Notes
Does this PR prevent a zero down-time upgrade? (Assume upgrade order: Controller, Broker, Server, Minion)
Does this PR fix a zero-downtime upgrade introduced earlier?
Does this PR otherwise need attention when creating release notes? Things to consider:
New configuration options:
Deprecation of configurations: n/a
Signature changes to public methods/interfaces:
#getPluginsRootDir in PluginManager.java -> #getPluginsDirectories, I've replaced all uses of this as part of this PR
the addition of #createTarGzFile which accepts multiple files instead of just 1 file
New plugins added or old plugins removed
n/a
Release Notes
PLUGINS_DIR_PROPERTY_NAME = "plugins.dir"
, originally is a string of 1 path, but now is a semi-colon delimited string of multiple paths. For example:/dir1/;/dir2
PLUGINS_INCLUDE_PROPERTY_NAME = "plugins.include"
is also a semi-colon delimited string of multiple plugins. For example:plugin1;plugin2
Documentation
Looking for an optimal place to add this new info, but I don't really see it documented anywhere: https://github.com/pinot-contrib/pinot-docs/search?q=plugins.dir
Thoughts?