Package alluxio.worker.block
Interface BlockWorker
-
- All Superinterfaces:
DataWorker
,Server<WorkerNetAddress>
,SessionCleanable
,Worker
public interface BlockWorker extends DataWorker, SessionCleanable
A block worker in the Alluxio system.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
abortBlock(long sessionId, long blockId)
Aborts the temporary block created by the session.void
accessBlock(long sessionId, long blockId)
Access the block for a given session.void
asyncCache(alluxio.grpc.AsyncCacheRequest request)
Deprecated.This method will be deprecated as of v3.0, usecache(alluxio.grpc.CacheRequest)
void
cache(alluxio.grpc.CacheRequest request)
Submits the cache request to cache manager to execute.void
clearMetrics()
Clears the worker metrics.void
closeUfsBlock(long sessionId, long blockId)
Closes a UFS block for a client session.void
commitBlock(long sessionId, long blockId, boolean pinOnCreate)
Commits a block to Alluxio managed space.void
commitBlockInUfs(long blockId, long length)
Commits a block in UFS.java.lang.String
createBlock(long sessionId, long blockId, int tier, CreateBlockOptions createBlockOptions)
Creates a block in Alluxio managed space.BlockReader
createBlockReader(long sessionId, long blockId, long offset, boolean positionShort, alluxio.proto.dataserver.Protocol.OpenUfsBlockOptions options)
Creates the block reader to read from Alluxio block or UFS block.void
createBlockRemote(long sessionId, long blockId, java.lang.String tierAlias, long initialBytes)
Creates a block.BlockWriter
createBlockWriter(long sessionId, long blockId)
Creates aBlockWriter
for an existing temporary block which is already created bycreateBlock(long, long, int, alluxio.worker.block.CreateBlockOptions)
.BlockReader
createUfsBlockReader(long sessionId, long blockId, long offset, boolean positionShort, alluxio.proto.dataserver.Protocol.OpenUfsBlockOptions options)
Creates a block reader to read a UFS block starting from given block offset.void
freeWorker()
Frees all blocks in the current worker by deleting all block store directories.BlockStore
getBlockStore()
Configuration
getConfiguration(alluxio.grpc.GetConfigurationPOptions options)
FileInfo
getFileInfo(long fileId)
Gets the file information.BlockHeartbeatReport
getReport()
Gets a report for the periodic heartbeat to master.BlockStoreMeta
getStoreMeta()
Gets the metadata for the entire block store.BlockStoreMeta
getStoreMetaFull()
Similar asgetStoreMeta()
except that this also contains full blockId list.BlockWriter
getTempBlockWriterRemote(long sessionId, long blockId)
Opens aBlockWriter
for an existing temporary block.java.util.List<java.lang.String>
getWhiteList()
WorkerNetAddress
getWorkerAddress()
java.util.concurrent.CompletableFuture<java.util.List<alluxio.grpc.BlockStatus>>
load(java.util.List<alluxio.grpc.Block> fileBlocks, alluxio.grpc.UfsReadOptions options)
Load blocks into alluxio.long
lockBlock(long sessionId, long blockId)
Obtains a read lock the block.long
lockBlockNoException(long sessionId, long blockId)
Obtains a read lock the block without throwing an exception.void
moveBlock(long sessionId, long blockId, java.lang.String tierAlias)
Moves a block from its current location to a target location, currently only tier level moves are supported.boolean
openUfsBlock(long sessionId, long blockId, alluxio.proto.dataserver.Protocol.OpenUfsBlockOptions options)
Opens a UFS block.java.lang.String
readBlock(long sessionId, long blockId, long lockId)
Gets the path to the block file in local storage.BlockReader
readBlockRemote(long sessionId, long blockId, long lockId)
Gets the block reader for the block.BlockReader
readUfsBlock(long sessionId, long blockId, long offset)
Gets a block reader to read a UFS block.void
removeBlock(long sessionId, long blockId)
Frees a block from Alluxio managed space.void
requestSpace(long sessionId, long blockId, long additionalBytes)
Request an amount of space for a block in its storage directory.void
unlockBlock(long lockId)
Releases the lock with the specified lock id.boolean
unlockBlock(long sessionId, long blockId)
Releases the lock with the specified session and block id.void
updatePinList(java.util.Set<java.lang.Long> pinnedInodes)
Sets the pinlist for the underlying block store.-
Methods inherited from interface alluxio.worker.DataWorker
getWorkerId
-
Methods inherited from interface alluxio.Server
close, getDependencies, getName, getServices, start, stop
-
Methods inherited from interface alluxio.worker.SessionCleanable
cleanupSession
-
-
-
-
Method Detail
-
abortBlock
void abortBlock(long sessionId, long blockId) throws java.io.IOException
Aborts the temporary block created by the session.- Parameters:
sessionId
- the id of the clientblockId
- the id of the block to be aborted- Throws:
java.io.IOException
-
commitBlock
void commitBlock(long sessionId, long blockId, boolean pinOnCreate)
Commits a block to Alluxio managed space. The block must be temporary. The block will not be persisted or accessible before commitBlock succeeds.- Parameters:
sessionId
- the id of the clientblockId
- the id of the block to commitpinOnCreate
- whether to pin block on create
-
commitBlockInUfs
void commitBlockInUfs(long blockId, long length)
Commits a block in UFS.- Parameters:
blockId
- the id of the block to commitlength
- length of the block to commit
-
createBlock
java.lang.String createBlock(long sessionId, long blockId, int tier, CreateBlockOptions createBlockOptions)
Creates a block in Alluxio managed space. CallscreateBlockWriter(long, long)
to get a writer for writing to the block. The block will be temporary until it is committed bycommitBlock(long, long, boolean)
. Throws anIllegalArgumentException
if the location does not belong to tiered storage.- Parameters:
sessionId
- the id of the clientblockId
- the id of the block to createtier
- the tier to place the new block inBlockStoreLocation.ANY_TIER
for any tiercreateBlockOptions
- the createBlockOptions- Returns:
- a string representing the path to the local file
-
createBlockWriter
BlockWriter createBlockWriter(long sessionId, long blockId) throws java.io.IOException
Creates aBlockWriter
for an existing temporary block which is already created bycreateBlock(long, long, int, alluxio.worker.block.CreateBlockOptions)
.- Parameters:
sessionId
- the id of the clientblockId
- the id of the block to be opened for writing- Returns:
- the block writer for the local block file
- Throws:
java.io.IOException
-
getReport
BlockHeartbeatReport getReport()
Gets a report for the periodic heartbeat to master. Contains the blocks added since the last heart beat and blocks removed since the last heartbeat.- Returns:
- a block heartbeat report
-
getStoreMeta
BlockStoreMeta getStoreMeta()
Gets the metadata for the entire block store. Contains the block mapping per storage dir and the total capacity and used capacity of each tier. This function is cheap.- Returns:
- the block store metadata
-
getStoreMetaFull
BlockStoreMeta getStoreMetaFull()
Similar asgetStoreMeta()
except that this also contains full blockId list. This function is expensive.- Returns:
- the full block store metadata
-
createBlockReader
BlockReader createBlockReader(long sessionId, long blockId, long offset, boolean positionShort, alluxio.proto.dataserver.Protocol.OpenUfsBlockOptions options) throws java.io.IOException
Creates the block reader to read from Alluxio block or UFS block. Owner of this block reader must close it or lock will leak.- Parameters:
sessionId
- the client session IDblockId
- the ID of the UFS block to readoffset
- the offset within the blockpositionShort
- whether the operation is using positioned read to a small buffer sizeoptions
- the options- Returns:
- a block reader to read data from
- Throws:
java.io.IOException
- if it fails to get block reader
-
createUfsBlockReader
BlockReader createUfsBlockReader(long sessionId, long blockId, long offset, boolean positionShort, alluxio.proto.dataserver.Protocol.OpenUfsBlockOptions options) throws java.io.IOException
Creates a block reader to read a UFS block starting from given block offset. Owner of this block reader must close it to cleanup state.- Parameters:
sessionId
- the client session IDblockId
- the ID of the UFS block to readoffset
- the offset within the blockpositionShort
- whether the operation is using positioned read to a small buffer sizeoptions
- the options- Returns:
- the block reader instance
- Throws:
java.io.IOException
- if it fails to get block reader
-
removeBlock
void removeBlock(long sessionId, long blockId) throws java.io.IOException
Frees a block from Alluxio managed space.- Parameters:
sessionId
- the id of the clientblockId
- the id of the block to be freed- Throws:
java.io.IOException
-
freeWorker
void freeWorker() throws java.io.IOException
Frees all blocks in the current worker by deleting all block store directories. Whether this method returns successfully or exceptionally, the worker should not be used in any way.- Throws:
java.io.IOException
- if free fails
-
requestSpace
void requestSpace(long sessionId, long blockId, long additionalBytes)
Request an amount of space for a block in its storage directory. The block must be a temporary block.- Parameters:
sessionId
- the id of the clientblockId
- the id of the block to allocate space toadditionalBytes
- the amount of bytes to allocate
-
asyncCache
@Deprecated void asyncCache(alluxio.grpc.AsyncCacheRequest request)
Deprecated.This method will be deprecated as of v3.0, usecache(alluxio.grpc.CacheRequest)
Submits the async cache request to async cache manager to execute.- Parameters:
request
- the async cache request
-
cache
void cache(alluxio.grpc.CacheRequest request) throws AlluxioException, java.io.IOException
Submits the cache request to cache manager to execute.- Parameters:
request
- the cache request- Throws:
AlluxioException
java.io.IOException
-
load
java.util.concurrent.CompletableFuture<java.util.List<alluxio.grpc.BlockStatus>> load(java.util.List<alluxio.grpc.Block> fileBlocks, alluxio.grpc.UfsReadOptions options)
Load blocks into alluxio.- Parameters:
fileBlocks
- list of fileBlocks, one file blocks contains blocks belong to one fileoptions
- read ufs options- Returns:
- future of load status for failed blocks
-
updatePinList
void updatePinList(java.util.Set<java.lang.Long> pinnedInodes)
Sets the pinlist for the underlying block store.- Parameters:
pinnedInodes
- a set of pinned inodes
-
getFileInfo
FileInfo getFileInfo(long fileId) throws java.io.IOException
Gets the file information.- Parameters:
fileId
- the file id- Returns:
- the file info
- Throws:
java.io.IOException
-
clearMetrics
void clearMetrics()
Clears the worker metrics.
-
getConfiguration
Configuration getConfiguration(alluxio.grpc.GetConfigurationPOptions options)
- Parameters:
options
- method options- Returns:
- configuration information list
-
getWhiteList
java.util.List<java.lang.String> getWhiteList()
- Returns:
- the white list
-
getBlockStore
BlockStore getBlockStore()
- Returns:
- the block store
-
getWorkerAddress
WorkerNetAddress getWorkerAddress()
- Returns:
- the worker address
-
readBlockRemote
BlockReader readBlockRemote(long sessionId, long blockId, long lockId) throws BlockDoesNotExistException, InvalidWorkerStateException, java.io.IOException
Gets the block reader for the block. This method is only called by a data server.- Parameters:
sessionId
- the id of the clientblockId
- the id of the block to readlockId
- the id of the lock on this block- Returns:
- the block reader for the block
- Throws:
BlockDoesNotExistException
- if lockId is not foundInvalidWorkerStateException
- if sessionId or blockId is not the same as that in the LockRecord of lockIdjava.io.IOException
-
openUfsBlock
boolean openUfsBlock(long sessionId, long blockId, alluxio.proto.dataserver.Protocol.OpenUfsBlockOptions options) throws BlockAlreadyExistsException
Opens a UFS block. It registers the block metadata information to the UFS block store. It throws anUfsBlockAccessTokenUnavailableException
if the number of concurrent readers on this block exceeds a threshold.- Parameters:
sessionId
- the session IDblockId
- the block IDoptions
- the options- Returns:
- whether the UFS block is successfully opened
- Throws:
BlockAlreadyExistsException
- if the UFS block already exists in theUnderFileSystemBlockStore
-
closeUfsBlock
void closeUfsBlock(long sessionId, long blockId) throws BlockAlreadyExistsException, BlockDoesNotExistException, java.io.IOException, WorkerOutOfSpaceException
Closes a UFS block for a client session. It also commits the block to Alluxio block store if the UFS block has been cached successfully.- Parameters:
sessionId
- the session IDblockId
- the block ID- Throws:
BlockAlreadyExistsException
- if it fails to commit the block to Alluxio block store because the block exists in the Alluxio block storeBlockDoesNotExistException
- if the UFS block does not exist in theUnderFileSystemBlockStore
WorkerOutOfSpaceException
- the the worker does not have enough space to commit the blockjava.io.IOException
-
accessBlock
void accessBlock(long sessionId, long blockId) throws BlockDoesNotExistException
Access the block for a given session. This should be called to update the evictor when necessary.- Parameters:
sessionId
- the id of the clientblockId
- the id of the block to access- Throws:
BlockDoesNotExistException
- this exception is not thrown in the tiered block store implementation
-
moveBlock
void moveBlock(long sessionId, long blockId, java.lang.String tierAlias) throws BlockDoesNotExistException, BlockAlreadyExistsException, InvalidWorkerStateException, WorkerOutOfSpaceException, java.io.IOException
Moves a block from its current location to a target location, currently only tier level moves are supported. Throws anIllegalArgumentException
if the tierAlias is out of range of tiered storage.- Parameters:
sessionId
- the id of the clientblockId
- the id of the block to movetierAlias
- the alias of the tier to move the block to- Throws:
BlockDoesNotExistException
- if blockId cannot be foundBlockAlreadyExistsException
- if blockId already exists in committed blocks of the newLocationInvalidWorkerStateException
- if blockId has not been committedWorkerOutOfSpaceException
- if newLocation does not have enough extra space to hold the blockjava.io.IOException
-
readBlock
java.lang.String readBlock(long sessionId, long blockId, long lockId) throws BlockDoesNotExistException, InvalidWorkerStateException
Gets the path to the block file in local storage. The block must be a permanent block, and the caller must first obtain the lock on the block.- Parameters:
sessionId
- the id of the clientblockId
- the id of the block to readlockId
- the id of the lock on this block- Returns:
- a string representing the path to this block in local storage
- Throws:
BlockDoesNotExistException
- if the blockId cannot be found in committed blocks or lockId cannot be foundInvalidWorkerStateException
- if sessionId or blockId is not the same as that in the LockRecord of lockId
-
unlockBlock
void unlockBlock(long lockId) throws BlockDoesNotExistException
Releases the lock with the specified lock id.- Parameters:
lockId
- the id of the lock to release- Throws:
BlockDoesNotExistException
- if lock id cannot be found
-
unlockBlock
boolean unlockBlock(long sessionId, long blockId)
Releases the lock with the specified session and block id.- Parameters:
sessionId
- the session idblockId
- the block id- Returns:
- false if it fails to unlock due to the lock is not found
-
lockBlock
long lockBlock(long sessionId, long blockId) throws BlockDoesNotExistException
Obtains a read lock the block.- Parameters:
sessionId
- the id of the clientblockId
- the id of the block to be locked- Returns:
- the lock id that uniquely identifies the lock obtained
- Throws:
BlockDoesNotExistException
- if blockId cannot be found, for example, evicted already
-
lockBlockNoException
long lockBlockNoException(long sessionId, long blockId)
Obtains a read lock the block without throwing an exception. If the lock fails, returnBlockLockManager#INVALID_LOCK_ID
.- Parameters:
sessionId
- the id of the clientblockId
- the id of the block to be locked- Returns:
- the lock id that uniquely identifies the lock obtained or
BlockLockManager#INVALID_LOCK_ID
if it failed to lock
-
createBlockRemote
void createBlockRemote(long sessionId, long blockId, java.lang.String tierAlias, long initialBytes) throws BlockAlreadyExistsException, WorkerOutOfSpaceException, java.io.IOException
Creates a block. This method is only called from a data server. CallsgetTempBlockWriterRemote(long, long)
to get a writer for writing to the block. Throws anIllegalArgumentException
if the location doens not belong to tiered storage.- Parameters:
sessionId
- the id of the clientblockId
- the id of the block to be createdtierAlias
- the alias of the tier to place the new block ininitialBytes
- the initial amount of bytes to be allocated- Throws:
BlockAlreadyExistsException
- if blockId already exists, either temporary or committed, or block in eviction plan already existsWorkerOutOfSpaceException
- if this Store has no more space than the initialBlockSizejava.io.IOException
-
readUfsBlock
BlockReader readUfsBlock(long sessionId, long blockId, long offset) throws BlockDoesNotExistException, java.io.IOException
Gets a block reader to read a UFS block. This method is only called by the data server.- Parameters:
sessionId
- the client session IDblockId
- the ID of the UFS block to readoffset
- the offset within the block- Returns:
- the block reader instance
- Throws:
BlockDoesNotExistException
- if the block does not exist in the UFS block storejava.io.IOException
-
getTempBlockWriterRemote
BlockWriter getTempBlockWriterRemote(long sessionId, long blockId) throws BlockDoesNotExistException, BlockAlreadyExistsException, InvalidWorkerStateException, java.io.IOException
Opens aBlockWriter
for an existing temporary block. This method is only called from a data server. The temporary block must already exist withcreateBlockRemote(long, long, String, long)
.- Parameters:
sessionId
- the id of the clientblockId
- the id of the block to be opened for writing- Returns:
- the block writer for the local block file
- Throws:
BlockDoesNotExistException
- if the block cannot be foundBlockAlreadyExistsException
- if a committed block with the same ID existsInvalidWorkerStateException
- if the worker state is invalidjava.io.IOException
-
-