lhotari commented on code in PR #21402:
URL: https://github.com/apache/pulsar/pull/21402#discussion_r1366887822
##########
pulsar-common/src/main/java/org/apache/pulsar/common/nar/NarClassLoader.java:
##########
@@ -135,21 +143,34 @@ public class NarClassLoader extends URLClassLoader {
* The NAR for which this <tt>ClassLoader</tt> is responsible.
*/
private final File narWorkingDirectory;
+ private final Pair<String, ClassLoader> classLoaderCacheKey;
+ private final AtomicInteger refCnt = new AtomicInteger(1);
private static final String TMP_DIR_PREFIX = "pulsar-nar";
public static final String DEFAULT_NAR_EXTRACTION_DIR =
System.getProperty("nar.extraction.tmpdir") != null
? System.getProperty("nar.extraction.tmpdir") :
System.getProperty("java.io.tmpdir");
- static NarClassLoader getFromArchive(File narPath, Set<String>
additionalJars, ClassLoader parent,
- String narExtractionDirectory)
- throws IOException {
- File unpacked = NarUnpacker.unpackNar(narPath,
getNarExtractionDirectory(narExtractionDirectory));
- return AccessController.doPrivileged(new
PrivilegedAction<NarClassLoader>() {
- @SneakyThrows
- @Override
- public NarClassLoader run() {
- return new NarClassLoader(unpacked, additionalJars, parent);
+ static NarClassLoader getFromArchive(File narFile, Set<String>
additionalJars, ClassLoader parent,
+ String narExtractionDirectory) throws
IOException {
+
+ String md5Sum =
Base64.getUrlEncoder().withoutPadding().encodeToString(NarUnpacker.calculateMd5sum(narFile));
Review Comment:
One of the challenges is that the calculation of the MD5 hash is a CPU
intensive operation since some nar files could be very large. It would be good
if the double calculation of the hash could be eliminated. Now it's also
calculated when the nar file is unpacked.
--
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]