@NotThreadSafe public class DefaultBlockWorker extends AbstractWorker implements BlockWorker
BlockMasterSync
(Worker to Master continuous communication)
Logic: DefaultBlockWorker
(Logic for all block related storage operations)Modifier and Type | Class and Description |
---|---|
static class |
DefaultBlockWorker.Metrics
This class contains some metrics related to the block worker.
|
class |
DefaultBlockWorker.StorageChecker
StorageChecker periodically checks the health of each storage path and report missing blocks to
BlockWorker . |
Modifier and Type | Field and Description |
---|---|
protected WorkerNetAddress |
mAddress |
protected BlockStore |
mBlockStore
Block Store manager.
|
protected FileSystemMasterClient |
mFileSystemMasterClient
Client for all file system master communication.
|
protected com.google.common.io.Closer |
mResourceCloser
Used to close resources during stop.
|
protected AtomicReference<Long> |
mWorkerId
The worker ID for this worker.
|
Constructor and Description |
---|
DefaultBlockWorker(BlockMasterClientPool blockMasterClientPool,
FileSystemMasterClient fileSystemMasterClient,
Sessions sessions,
BlockStore blockStore,
AtomicReference<Long> workerId)
Constructs a default block worker.
|
Modifier and Type | Method and Description |
---|---|
void |
abortBlock(long sessionId,
long blockId)
Aborts the temporary block created by the session.
|
void |
askForWorkerId(WorkerNetAddress address)
Ask the master for a workerId.
|
void |
asyncCache(AsyncCacheRequest request)
Deprecated.
|
void |
cache(CacheRequest request)
Submits the cache request to cache manager to execute.
|
void |
cleanupSession(long sessionId)
Cleans up the session.
|
void |
clearMetrics()
Clears the worker metrics.
|
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.
|
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,
Protocol.OpenUfsBlockOptions options)
Closes a UFS block for a client session.
|
BlockWriter |
createBlockWriter(long sessionId,
long blockId)
Creates a
BlockWriter for an existing temporary block which is already created by
BlockWorker.createBlock(long, long, int, alluxio.worker.block.CreateBlockOptions) . |
BlockReader |
createUfsBlockReader(long sessionId,
long blockId,
long offset,
boolean positionShort,
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()
get the LocalBlockStore that manages local blocks.
|
Configuration |
getConfiguration(GetConfigurationPOptions options) |
Set<Class<? extends Server>> |
getDependencies() |
FileInfo |
getFileInfo(long fileId)
Gets the file information.
|
String |
getName() |
BlockHeartbeatReport |
getReport()
Gets a report for the periodic heartbeat to master.
|
Map<ServiceType,GrpcService> |
getServices() |
BlockStoreMeta |
getStoreMeta()
Gets the metadata for the entire block store.
|
BlockStoreMeta |
getStoreMetaFull()
Similar as
BlockWorker.getStoreMeta() except that this also contains full blockId
list. |
List<String> |
getWhiteList() |
WorkerNetAddress |
getWorkerAddress() |
AtomicReference<Long> |
getWorkerId() |
CompletableFuture<List<BlockStatus>> |
load(List<Block> blocks,
UfsReadOptions options)
Load blocks into alluxio.
|
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.
|
protected void |
setupBlockMasterSync() |
void |
start(WorkerNetAddress address)
Runs the block worker.
|
void |
stop()
Stops the block worker.
|
void |
updatePinList(Set<Long> pinnedInodes)
Sets the pinlist for the underlying block store.
|
close, getExecutorService
protected final com.google.common.io.Closer mResourceCloser
protected final FileSystemMasterClient mFileSystemMasterClient
protected final BlockStore mBlockStore
protected final AtomicReference<Long> mWorkerId
start(WorkerNetAddress)
and may
be updated by the block sync thread if the master requests re-registration.protected WorkerNetAddress mAddress
public DefaultBlockWorker(BlockMasterClientPool blockMasterClientPool, FileSystemMasterClient fileSystemMasterClient, Sessions sessions, BlockStore blockStore, AtomicReference<Long> workerId)
blockMasterClientPool
- a client pool for talking to the block masterfileSystemMasterClient
- a client for talking to the file system mastersessions
- an object for tracking and cleaning up client sessionsblockStore
- an Alluxio block storeworkerId
- worker idpublic BlockStore getBlockStore()
getBlockStore
in interface BlockWorker
public WorkerNetAddress getWorkerAddress()
getWorkerAddress
in interface BlockWorker
public Set<Class<? extends Server>> getDependencies()
getDependencies
in interface Server<WorkerNetAddress>
public String getName()
getName
in interface Server<WorkerNetAddress>
public Map<ServiceType,GrpcService> getServices()
getServices
in interface Server<WorkerNetAddress>
public AtomicReference<Long> getWorkerId()
getWorkerId
in interface BlockWorker
public void start(WorkerNetAddress address) throws IOException
start
in interface Server<WorkerNetAddress>
start
in class AbstractWorker
address
- the start optionsIOException
protected void setupBlockMasterSync() throws IOException
IOException
public void askForWorkerId(WorkerNetAddress address)
address
- the address this worker operates onpublic void stop() throws IOException
stop
in interface Server<WorkerNetAddress>
stop
in class AbstractWorker
IOException
public void abortBlock(long sessionId, long blockId) throws IOException
BlockWorker
abortBlock
in interface BlockWorker
sessionId
- the id of the clientblockId
- the id of the block to be abortedIOException
public void commitBlock(long sessionId, long blockId, boolean pinOnCreate)
BlockWorker
commitBlock
in interface BlockWorker
sessionId
- the id of the clientblockId
- the id of the block to commitpinOnCreate
- whether to pin block on createpublic void commitBlockInUfs(long blockId, long length)
BlockWorker
commitBlockInUfs
in interface BlockWorker
blockId
- the id of the block to commitlength
- length of the block to commitpublic String createBlock(long sessionId, long blockId, int tier, CreateBlockOptions createBlockOptions)
BlockWorker
BlockWorker.createBlockWriter(long, long)
to get a writer for writing to the block.
The block will be temporary until it is committed by BlockWorker.commitBlock(long, long, boolean)
.
Throws an IllegalArgumentException
if the location does not belong to tiered storage.createBlock
in interface BlockWorker
sessionId
- the id of the clientblockId
- the id of the block to createtier
- the tier to place the new block in
BlockStoreLocation.ANY_TIER
for any tiercreateBlockOptions
- the createBlockOptionspublic BlockWriter createBlockWriter(long sessionId, long blockId) throws IOException
BlockWorker
BlockWriter
for an existing temporary block which is already created by
BlockWorker.createBlock(long, long, int, alluxio.worker.block.CreateBlockOptions)
.createBlockWriter
in interface BlockWorker
sessionId
- the id of the clientblockId
- the id of the block to be opened for writingIOException
public BlockHeartbeatReport getReport()
BlockWorker
getReport
in interface BlockWorker
public BlockStoreMeta getStoreMeta()
BlockWorker
getStoreMeta
in interface BlockWorker
public BlockStoreMeta getStoreMetaFull()
BlockWorker
BlockWorker.getStoreMeta()
except that this also contains full blockId
list. This function is expensive.getStoreMetaFull
in interface BlockWorker
public List<String> getWhiteList()
getWhiteList
in interface BlockWorker
public BlockReader createUfsBlockReader(long sessionId, long blockId, long offset, boolean positionShort, Protocol.OpenUfsBlockOptions options) throws IOException
BlockWorker
createUfsBlockReader
in interface BlockWorker
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 optionsIOException
- if it fails to get block readerpublic void removeBlock(long sessionId, long blockId) throws IOException
BlockWorker
removeBlock
in interface BlockWorker
sessionId
- the id of the clientblockId
- the id of the block to be freedIOException
public void freeWorker() throws IOException
BlockWorker
freeWorker
in interface BlockWorker
IOException
- if free failspublic void requestSpace(long sessionId, long blockId, long additionalBytes)
BlockWorker
requestSpace
in interface BlockWorker
sessionId
- the id of the clientblockId
- the id of the block to allocate space toadditionalBytes
- the amount of bytes to allocate@Deprecated public void asyncCache(AsyncCacheRequest request)
BlockWorker
asyncCache
in interface BlockWorker
request
- the async cache requestpublic void cache(CacheRequest request) throws AlluxioException, IOException
BlockWorker
cache
in interface BlockWorker
request
- the cache requestAlluxioException
IOException
public CompletableFuture<List<BlockStatus>> load(List<Block> blocks, UfsReadOptions options)
BlockWorker
load
in interface BlockWorker
blocks
- list of fileBlocks, one file blocks contains blocks belong to one fileoptions
- read ufs optionspublic void updatePinList(Set<Long> pinnedInodes)
BlockWorker
updatePinList
in interface BlockWorker
pinnedInodes
- a set of pinned inodespublic FileInfo getFileInfo(long fileId) throws IOException
BlockWorker
getFileInfo
in interface BlockWorker
fileId
- the file idIOException
public BlockReader createBlockReader(long sessionId, long blockId, long offset, boolean positionShort, Protocol.OpenUfsBlockOptions options) throws IOException
createBlockReader
in interface BlockWorker
sessionId
- the session IDblockId
- the block IDoffset
- the offset within the blockpositionShort
- whether the operation is using positioned read to a small buffer sizeoptions
- the optionsIOException
- if it fails to get block readerpublic void clearMetrics()
BlockWorker
clearMetrics
in interface BlockWorker
public Configuration getConfiguration(GetConfigurationPOptions options)
getConfiguration
in interface BlockWorker
options
- method optionspublic void cleanupSession(long sessionId)
SessionCleanable
cleanupSession
in interface SessionCleanable
sessionId
- the session idCopyright © 2023. All Rights Reserved.