Package org.apache.flink.runtime.blob
Class AbstractBlobCache
java.lang.Object
org.apache.flink.runtime.blob.AbstractBlobCache
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
PermanentBlobCache,TransientBlobCache
Abstract base class for permanent and transient BLOB files.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.apache.flink.configuration.ConfigurationConfiguration for the blob client like ssl parameters required to connect to the blob server.protected final BlobViewBlob store for distributed file storage, e.g. in HA.protected final org.slf4j.LoggerThe log object used for debugging.protected final intThe number of retries when the transfer fails.protected final ReadWriteLockLock guarding concurrent file accesses.protected InetSocketAddressprotected final ThreadShutdown hook thread to ensure deletion of the local storage directory.protected final AtomicBooleanprotected final org.apache.flink.util.Reference<File>Root directory for local file storage.protected final AtomicLongCounter to generate unique names for temporary files. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractBlobCache(org.apache.flink.configuration.Configuration blobClientConfig, org.apache.flink.util.Reference<File> storageDir, BlobView blobView, org.slf4j.Logger logger, InetSocketAddress serverAddress) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidCancels any cleanup task that subclasses may be executing.voidclose()protected FilegetFileInternal(org.apache.flink.api.common.JobID jobId, BlobKey blobKey) Returns local copy of the file for the BLOB with the given key.intgetPort()Returns the port the BLOB server is listening on.voidsetBlobServerAddress(InetSocketAddress blobServerAddress) Sets the address of theBlobServer.
-
Field Details
-
log
protected final org.slf4j.Logger logThe log object used for debugging. -
tempFileCounter
Counter to generate unique names for temporary files. -
storageDir
Root directory for local file storage. -
blobView
Blob store for distributed file storage, e.g. in HA. -
shutdownRequested
-
shutdownHook
Shutdown hook thread to ensure deletion of the local storage directory. -
numFetchRetries
protected final int numFetchRetriesThe number of retries when the transfer fails. -
blobClientConfig
protected final org.apache.flink.configuration.Configuration blobClientConfigConfiguration for the blob client like ssl parameters required to connect to the blob server. -
readWriteLock
Lock guarding concurrent file accesses. -
serverAddress
-
-
Constructor Details
-
AbstractBlobCache
public AbstractBlobCache(org.apache.flink.configuration.Configuration blobClientConfig, org.apache.flink.util.Reference<File> storageDir, BlobView blobView, org.slf4j.Logger logger, @Nullable InetSocketAddress serverAddress) throws IOException - Throws:
IOException
-
-
Method Details
-
getStorageDir
-
getFileInternal
protected File getFileInternal(@Nullable org.apache.flink.api.common.JobID jobId, BlobKey blobKey) throws IOException Returns local copy of the file for the BLOB with the given key.The method will first attempt to serve the BLOB from its local cache. If the BLOB is not in the cache, the method will try to download it from this cache's BLOB server via a distributed BLOB store (if available) or direct end-to-end download.
- Parameters:
jobId- ID of the job this blob belongs to (or null if job-unrelated)blobKey- The key of the desired BLOB.- Returns:
- file referring to the local storage location of the BLOB.
- Throws:
IOException- Thrown if an I/O error occurs while downloading the BLOBs from the BLOB server.
-
getPort
public int getPort()Returns the port the BLOB server is listening on.- Returns:
- BLOB server port or
-1if no server address
-
setBlobServerAddress
Sets the address of theBlobServer.- Parameters:
blobServerAddress- address of theBlobServer.
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
cancelCleanupTask
protected abstract void cancelCleanupTask()Cancels any cleanup task that subclasses may be executing.This is called during
close().
-