-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Make sure ufs to only once load a native shared library #14058
base: master-2.x
Are you sure you want to change the base?
Changes from 3 commits
d180809
5b124f1
37139ca
303bd9b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,19 +131,18 @@ public List<T> findAll(String path, S conf) { | |
Preconditions.checkArgument(path != null, "path may not be null"); | ||
|
||
List<T> factories = new ArrayList<>(mFactories); | ||
List<T> eligibleFactories = select(path, conf, factories); | ||
if (!eligibleFactories.isEmpty()) { | ||
return eligibleFactories; | ||
} | ||
|
||
factories.clear(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i don't understand why we can prevent loading native shared lib multiple times by calling clear here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
At this line, we did not find any supported factories from the list of factories. So we clear it to avoid to twicely check them wether support or not. |
||
String libDir = PathUtils.concatPath(conf.get(PropertyKey.HOME), "lib"); | ||
String extensionDir = conf.get(PropertyKey.EXTENSIONS_DIR); | ||
scanLibs(factories, libDir); | ||
scanExtensions(factories, extensionDir); | ||
|
||
List<T> eligibleFactories = new ArrayList<>(); | ||
for (T factory : factories) { | ||
if (factory.supportsPath(path, conf)) { | ||
LOG.debug("Factory implementation {} is eligible for path {}", factory, path); | ||
eligibleFactories.add(factory); | ||
} | ||
} | ||
|
||
eligibleFactories = select(path, conf, factories); | ||
if (eligibleFactories.isEmpty()) { | ||
LOG.warn("No factory implementation supports the path {}", path); | ||
} | ||
|
@@ -201,6 +200,7 @@ private void scan(List<File> files, List<T> factories) { | |
LOG.debug("Discovered a factory implementation {} - {} in jar {}", factory.getClass(), | ||
factory, jarPath); | ||
register(factory, factories); | ||
register(factory); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
we modify the basic assumption of what will it be better to include a new list call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @apc999 What's your thoughts There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yea, i think it sounds better! By the way, may be that we can add a method "boolean supportsDynamicLoad()" in the public interface ExtensionFactory to distinguish the underFileSystemFactories, the default return is true, likes the existed method "boolean supportsPath(String path, S conf)",however, the specific underFileSystemFactories which do not support dynamic load can override the method, so we can still only use mFactories. What's your thoughts? @apc999 @LuQQiu @maobaolong There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer this way, but is it complicated to add the logic? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jiacheliu3 I think we need to make an agreement on how to address this issue. This part is kind of critical and nobody really familiar with it. More eyes need to be pulled in to think of how to load the extension factories |
||
} | ||
} catch (Throwable t) { | ||
LOG.warn("Failed to load jar {}: {}", jar, t.toString()); | ||
|
@@ -270,4 +270,25 @@ private void unregister(T factory, List<T> factories) { | |
LOG.debug("Unregistered factory implementation {} - {}", factory.getClass(), factory); | ||
factories.remove(factory); | ||
} | ||
|
||
/** | ||
* Selects all the factories that support the given path from the given list of factories. | ||
* | ||
* @param path path | ||
* @param conf configuration of the extension | ||
* @param factories list of factories | ||
* @return list of factories that support the given path which may be an empty list | ||
*/ | ||
private List<T> select(String path, S conf, List<T> factories) { | ||
Preconditions.checkNotNull(path, "path may not be null"); | ||
|
||
List<T> eligibleFactories = new ArrayList<>(); | ||
for (T factory : factories) { | ||
if (factory.supportsPath(path, conf)) { | ||
LOG.debug("Factory implementation {} is eligible for path {}", factory, path); | ||
eligibleFactories.add(factory); | ||
} | ||
} | ||
return eligibleFactories; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,6 @@ | |
<groupId>io.github.opendataio</groupId> | ||
<artifactId>libcephfs</artifactId> | ||
<version>0.0.1</version> | ||
<scope>provided</scope> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the purpose you remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, this pr will solve the problem about the libcephfs_jni.so is already loaded in another classloader, so libcephfs can be included. |
||
</dependency> | ||
|
||
<!-- Internal dependencies --> | ||
|
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.
You mean the first time
findAll
invoked, themFactories
should be empty, and this method will run like original logic, later newfindAll
will not load the extension or lib jar at all? So please show the effect.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, the new 'findAll' will not dynamicly load the ext or lib jar after the first load done. However, we can restart the alluxio master or worker to load the new updated jar.
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 highlight add this important limitation to the related issue or the description of this PR. It would be better if you write an approach description shortly to let reviewer know your solution and make it easy to review this PR