public class BlobServer extends Thread implements BlobService, BlobWriter, PermanentBlobService, TransientBlobService, LocallyCleanableResource, GloballyCleanableResource
Thread.State, Thread.UncaughtExceptionHandlerMAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| Constructor and Description |
|---|
BlobServer(org.apache.flink.configuration.Configuration config,
File storageDir,
BlobStore blobStore) |
BlobServer(org.apache.flink.configuration.Configuration config,
org.apache.flink.util.Reference<File> storageDir,
BlobStore blobStore)
Instantiates a new BLOB server and binds it to a free network port.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Shuts down the BLOB server.
|
protected BlobClient |
createClient() |
boolean |
deleteFromCache(org.apache.flink.api.common.JobID jobId,
TransientBlobKey key)
Deletes the file associated with the blob key in the local storage of the blob server.
|
boolean |
deleteFromCache(TransientBlobKey key)
Deletes the (job-unrelated) file associated with the blob key in the local storage of the
blob server.
|
boolean |
deletePermanent(org.apache.flink.api.common.JobID jobId,
PermanentBlobKey key)
Delete the uploaded data with the given
JobID and PermanentBlobKey. |
File |
getFile(org.apache.flink.api.common.JobID jobId,
PermanentBlobKey key)
Returns the path to a local copy of the file associated with the provided job ID and blob
key.
|
File |
getFile(org.apache.flink.api.common.JobID jobId,
TransientBlobKey key)
Retrieves the local path of a file associated with a job and a blob key.
|
File |
getFile(TransientBlobKey key)
Retrieves the local path of a (job-unrelated) file associated with a job and a blob key.
|
int |
getMinOffloadingSize()
Returns the configuration used by the BLOB server.
|
PermanentBlobService |
getPermanentBlobService()
Returns a BLOB service for accessing permanent BLOBs.
|
int |
getPort()
Returns the port on which the server is listening.
|
File |
getStorageDir() |
File |
getStorageLocation(org.apache.flink.api.common.JobID jobId,
BlobKey key)
Returns a file handle to the file associated with the given blob key on the blob server.
|
TransientBlobService |
getTransientBlobService()
Returns a BLOB service for accessing transient BLOBs.
|
CompletableFuture<Void> |
globalCleanupAsync(org.apache.flink.api.common.JobID jobId,
Executor executor)
Removes all BLOBs from local and HA store belonging to the given
JobID. |
boolean |
isShutdown()
Tests whether the BLOB server has been requested to shut down.
|
CompletableFuture<Void> |
localCleanupAsync(org.apache.flink.api.common.JobID jobId,
Executor cleanupExecutor)
Deletes locally stored artifacts for the job represented by the given
JobID. |
PermanentBlobKey |
putPermanent(org.apache.flink.api.common.JobID jobId,
byte[] value)
Uploads the data of the given byte array for the given job to the BLOB server and makes it a
permanent BLOB.
|
PermanentBlobKey |
putPermanent(org.apache.flink.api.common.JobID jobId,
InputStream inputStream)
Uploads the data from the given input stream for the given job to the BLOB server and makes
it a permanent BLOB.
|
TransientBlobKey |
putTransient(byte[] value)
Uploads the (job-unrelated) data of the given byte array to the BLOB server.
|
TransientBlobKey |
putTransient(InputStream inputStream)
Uploads the (job-unrelated) data from the given input stream to the BLOB server.
|
TransientBlobKey |
putTransient(org.apache.flink.api.common.JobID jobId,
byte[] value)
Uploads the data of the given byte array for the given job to the BLOB server.
|
TransientBlobKey |
putTransient(org.apache.flink.api.common.JobID jobId,
InputStream inputStream)
Uploads the data from the given input stream for the given job to the BLOB server.
|
void |
retainJobs(Collection<org.apache.flink.api.common.JobID> jobsToRetain,
Executor ioExecutor) |
void |
run() |
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitoffloadWithException, serializeAndTryOffload, tryOffloadreadFile@VisibleForTesting
public BlobServer(org.apache.flink.configuration.Configuration config,
File storageDir,
BlobStore blobStore)
throws IOException
IOExceptionpublic BlobServer(org.apache.flink.configuration.Configuration config,
org.apache.flink.util.Reference<File> storageDir,
BlobStore blobStore)
throws IOException
config - Configuration to be used to instantiate the BlobServerstorageDir - storage directory for the blobsblobStore - BlobStore to store blobs persistentlyIOException - thrown if the BLOB server cannot bind to a free network port or if the
(local or distributed) file storage cannot be created or is not usablepublic File getStorageDir()
@VisibleForTesting public File getStorageLocation(@Nullable org.apache.flink.api.common.JobID jobId, BlobKey key) throws IOException
This is only called from BlobServerConnection or unit tests.
jobId - ID of the job this blob belongs to (or null if job-unrelated)key - identifying the fileIOException - if creating the directory failspublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionprotected BlobClient createClient() throws IOException
IOExceptionpublic File getFile(TransientBlobKey key) throws IOException
The blob server looks the blob key up in its local storage. If the file exists, it is
returned. If the file does not exist, it is retrieved from the HA blob store (if available)
or a FileNotFoundException is thrown.
getFile in interface TransientBlobServicekey - blob key associated with the requested fileIOException - Thrown if the file retrieval failed.public File getFile(org.apache.flink.api.common.JobID jobId, TransientBlobKey key) throws IOException
The blob server looks the blob key up in its local storage. If the file exists, it is
returned. If the file does not exist, it is retrieved from the HA blob store (if available)
or a FileNotFoundException is thrown.
getFile in interface TransientBlobServicejobId - ID of the job this blob belongs tokey - blob key associated with the requested fileIOException - Thrown if the file retrieval failed.public File getFile(org.apache.flink.api.common.JobID jobId, PermanentBlobKey key) throws IOException
We will first attempt to serve the BLOB from the local storage. If the BLOB is not in there, we will try to download it from the HA store.
getFile in interface PermanentBlobServicejobId - ID of the job this blob belongs tokey - blob key associated with the requested fileFileNotFoundException - if the BLOB does not exist;IOException - if any other error occurs when retrieving the filepublic TransientBlobKey putTransient(byte[] value) throws IOException
TransientBlobServiceputTransient in interface TransientBlobServicevalue - the buffer to uploadIOException - thrown if an I/O error occurs while uploading the data to the BLOB serverpublic TransientBlobKey putTransient(org.apache.flink.api.common.JobID jobId, byte[] value) throws IOException
TransientBlobServiceputTransient in interface TransientBlobServicejobId - the ID of the job the BLOB belongs tovalue - the buffer to uploadIOException - thrown if an I/O error occurs while uploading the data to the BLOB serverpublic TransientBlobKey putTransient(InputStream inputStream) throws IOException
TransientBlobServiceputTransient in interface TransientBlobServiceinputStream - the input stream to read the data fromIOException - thrown if an I/O error occurs while reading the data from the input
stream or uploading the data to the BLOB serverpublic TransientBlobKey putTransient(org.apache.flink.api.common.JobID jobId, InputStream inputStream) throws IOException
TransientBlobServiceputTransient in interface TransientBlobServicejobId - ID of the job this blob belongs toinputStream - the input stream to read the data fromIOException - thrown if an I/O error occurs while reading the data from the input
stream or uploading the data to the BLOB serverpublic PermanentBlobKey putPermanent(org.apache.flink.api.common.JobID jobId, byte[] value) throws IOException
BlobWriterputPermanent in interface BlobWriterjobId - the ID of the job the BLOB belongs tovalue - the buffer to uploadIOException - thrown if an I/O error occurs while writing it to a local file, or
uploading it to the HA storepublic PermanentBlobKey putPermanent(org.apache.flink.api.common.JobID jobId, InputStream inputStream) throws IOException
BlobWriterputPermanent in interface BlobWriterjobId - ID of the job this blob belongs toinputStream - the input stream to read the data fromIOException - thrown if an I/O error occurs while reading the data from the input
stream, writing it to a local file, or uploading it to the HA storepublic boolean deleteFromCache(TransientBlobKey key)
deleteFromCache in interface TransientBlobServicekey - blob key associated with the file to be deletedpublic boolean deleteFromCache(org.apache.flink.api.common.JobID jobId,
TransientBlobKey key)
deleteFromCache in interface TransientBlobServicejobId - ID of the job this blob belongs tokey - blob key associated with the file to be deletedpublic boolean deletePermanent(org.apache.flink.api.common.JobID jobId,
PermanentBlobKey key)
JobID and PermanentBlobKey.deletePermanent in interface BlobWriterjobId - ID of the job this blob belongs tokey - the key of this blobpublic CompletableFuture<Void> localCleanupAsync(org.apache.flink.api.common.JobID jobId, Executor cleanupExecutor)
JobID. This
doesn't touch the job's entry in the BlobStore to enable recovering.localCleanupAsync in interface LocallyCleanableResourcejobId - The JobID of the job that is subject to cleanup.cleanupExecutor - The fallback executor for IO-heavy operations.public CompletableFuture<Void> globalCleanupAsync(org.apache.flink.api.common.JobID jobId, Executor executor)
JobID.globalCleanupAsync in interface GloballyCleanableResourcejobId - ID of the job this blob belongs toexecutor - The fallback executor for IO-heavy operations.public void retainJobs(Collection<org.apache.flink.api.common.JobID> jobsToRetain, Executor ioExecutor) throws IOException
IOExceptionpublic PermanentBlobService getPermanentBlobService()
BlobServicegetPermanentBlobService in interface BlobServicepublic TransientBlobService getTransientBlobService()
BlobServicegetTransientBlobService in interface BlobServicepublic final int getMinOffloadingSize()
getMinOffloadingSize in interface BlobWriterpublic int getPort()
getPort in interface BlobServicepublic boolean isShutdown()
Copyright © 2014–2025 The Apache Software Foundation. All rights reserved.