@Internal public class ResourceManager extends Object implements Closeable
| Modifier and Type | Field and Description |
|---|---|
protected Map<org.apache.flink.table.resource.ResourceUri,URL> |
resourceInfos |
protected org.apache.flink.util.MutableURLClassLoader |
userClassLoader |
| Constructor and Description |
|---|
ResourceManager(org.apache.flink.configuration.ReadableConfig config,
org.apache.flink.util.MutableURLClassLoader userClassLoader) |
| Modifier and Type | Method and Description |
|---|---|
void |
addJarConfiguration(TableConfig tableConfig)
Adds the local jar resources to the given
TableConfig. |
protected void |
checkPath(org.apache.flink.core.fs.Path path,
org.apache.flink.table.resource.ResourceType expectedType) |
void |
close() |
static ResourceManager |
createResourceManager(URL[] urls,
ClassLoader parent,
org.apache.flink.configuration.ReadableConfig config) |
boolean |
exists(org.apache.flink.core.fs.Path filePath)
Check whether the
Path exists. |
Set<URL> |
getLocalJarResources()
Get the local jars' URL.
|
Map<org.apache.flink.table.resource.ResourceUri,URL> |
getResources() |
protected URL |
getURLFromPath(org.apache.flink.core.fs.Path path) |
URLClassLoader |
getUserClassLoader() |
String |
registerFileResource(org.apache.flink.table.resource.ResourceUri resourceUri)
Register a file resource into
ResourceManager and return the absolute local file path
without the scheme. |
void |
registerJarResources(List<org.apache.flink.table.resource.ResourceUri> resourceUris)
Due to anyone of the resource in list maybe fail during register, so we should stage it
before actual register to guarantee transaction process.
|
void |
syncFileResource(org.apache.flink.table.resource.ResourceUri resourceUri,
java.util.function.Consumer<String> resourceGenerator)
Generate a local file resource by the given resource generator and then synchronize to the
path identified by the given
ResourceUri. |
protected final org.apache.flink.util.MutableURLClassLoader userClassLoader
public ResourceManager(org.apache.flink.configuration.ReadableConfig config,
org.apache.flink.util.MutableURLClassLoader userClassLoader)
public static ResourceManager createResourceManager(URL[] urls, ClassLoader parent, org.apache.flink.configuration.ReadableConfig config)
public void registerJarResources(List<org.apache.flink.table.resource.ResourceUri> resourceUris) throws IOException
ResourceManager.IOExceptionpublic String registerFileResource(org.apache.flink.table.resource.ResourceUri resourceUri) throws IOException
ResourceManager and return the absolute local file path
without the scheme.
If the file is remote, it will be copied to a local file, with file name suffixed with a UUID.
resourceUri - resource with type as ResourceType.FILE, the resource uri might or
might not contain the uri scheme, or it could be a relative path.IOExceptionpublic URLClassLoader getUserClassLoader()
public Set<URL> getLocalJarResources()
public void addJarConfiguration(TableConfig tableConfig)
TableConfig. It implicitly considers the
TableConfig.getRootConfiguration() and stores the merged result into TableConfig.getConfiguration().public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic boolean exists(org.apache.flink.core.fs.Path filePath)
throws IOException
Path exists.IOExceptionpublic void syncFileResource(org.apache.flink.table.resource.ResourceUri resourceUri,
java.util.function.Consumer<String> resourceGenerator)
throws IOException
ResourceUri. The path passed to resource generator
should be a local path retrieved from the given ResourceUri.
NOTE: if the given ResourceUri represents a remote file path like
"hdfs://path/to/file.json", then the retrieved local path will be
"/localResourceDir/file-${uuid}.json"
resourceUri - the file resource uri to synchronize toresourceGenerator - a consumer that generates a local copy of the file resourceIOExceptionprotected void checkPath(org.apache.flink.core.fs.Path path,
org.apache.flink.table.resource.ResourceType expectedType)
throws IOException
IOException@VisibleForTesting protected URL getURLFromPath(org.apache.flink.core.fs.Path path) throws IOException
IOExceptionCopyright © 2014–2023 The Apache Software Foundation. All rights reserved.