Class DynamicClassLoader

All Implemented Interfaces:
Closeable, AutoCloseable

@Private public class DynamicClassLoader extends ClassLoaderBase
This is a class loader that can load classes dynamically from new jar files under a configured folder. The paths to the jar files are converted to URLs, and URLClassLoader logic is actually used to load classes. This class loader always uses its parent class loader to load a class at first. Only if its parent class loader can not load a class, we will try to load it using the logic here.

The configured folder can be a HDFS path. In this case, the jar files under that folder will be copied to local at first under ${hbase.local.dir}/jars/. The local copy will be updated if the remote copy is updated, according to its last modified timestamp.

We can't unload a class already loaded. So we will use the existing jar files we already know to load any class which can't be loaded using the parent class loader. If we still can't load the class from the existing jar files, we will check if any new jar file is added, if so, we will load the new jar file and try to load the class again. If still failed, a class not found exception will be thrown.

Be careful in uploading new jar files and make sure all classes are consistent, otherwise, we may not be able to load your classes properly.