-
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 all 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 |
---|---|---|
|
@@ -144,6 +144,12 @@ public List<T> findAllWithRecorder(String path, S conf, Recorder recorder) { | |
} | ||
|
||
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.getString(PropertyKey.HOME), "lib"); | ||
String extensionDir = conf.getString(PropertyKey.EXTENSIONS_DIR); | ||
scanLibs(factories, libDir); | ||
|
@@ -159,6 +165,7 @@ public List<T> findAllWithRecorder(String path, S conf, Recorder recorder) { | |
recorder.record("alluxio.underfs.version is not set by user"); | ||
} | ||
|
||
eligibleFactories = select(path, conf, factories); | ||
for (T factory : factories) { | ||
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. is select duplicate with the following for loop |
||
// if `getVersion` returns null set the version to "unknown" | ||
String version = UNKNOWN_VERSION; | ||
|
@@ -178,6 +185,7 @@ public List<T> findAllWithRecorder(String path, S conf, Recorder recorder) { | |
+ "isn't eligible for path {}", factory.getClass().getSimpleName(), version, path); | ||
} | ||
} | ||
|
||
if (eligibleFactories.isEmpty()) { | ||
String message = String.format("No factory implementation supports the path %s", path); | ||
recorder.record(message); | ||
|
@@ -320,4 +328,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