@NotThreadSafe public final class DefaultBlockMaster extends AbstractMaster implements BlockMaster
Modifier and Type | Class and Description |
---|---|
static class |
DefaultBlockMaster.Metrics
Class that contains metrics related to BlockMaster.
|
mBackupManager, mClock, mPauseStateLock, mSafeModeManager, mStateChangeLock
Modifier and Type | Method and Description |
---|---|
void |
commitBlock(long workerId,
long usedBytesOnTier,
String tierAlias,
long blockId,
long length)
Marks a block as committed on a specific worker.
|
void |
commitBlockInUFS(long blockId,
long length)
Marks a block as committed, but without a worker location.
|
BlockInfo |
getBlockInfo(long blockId) |
List<BlockInfo> |
getBlockInfoList(List<Long> blockIds)
Retrieves information for the given list of block ids.
|
long |
getCapacityBytes() |
Set<Class<? extends Server>> |
getDependencies() |
StorageTierAssoc |
getGlobalStorageTierAssoc() |
Iterator<Journal.JournalEntry> |
getJournalEntryIterator() |
Set<Long> |
getLostBlocks() |
int |
getLostWorkerCount() |
List<WorkerInfo> |
getLostWorkersInfoList() |
String |
getName() |
long |
getNewContainerId() |
Map<String,org.apache.thrift.TProcessor> |
getServices() |
Map<String,Long> |
getTotalBytesOnTiers() |
long |
getUsedBytes() |
Map<String,Long> |
getUsedBytesOnTiers() |
int |
getWorkerCount() |
long |
getWorkerId(WorkerNetAddress workerNetAddress)
Returns a worker id for the given worker, creating one if the worker is new.
|
List<WorkerInfo> |
getWorkerInfoList() |
List<WorkerInfo> |
getWorkerReport(GetWorkerReportOptions options)
Gets the worker information list for report CLI.
|
void |
processJournalEntry(Journal.JournalEntry entry)
Applies a journal entry to the state machine.
|
void |
registerLostWorkerFoundListener(java.util.function.Consumer<Address> function)
Registers callback functions to use when lost workers become alive.
|
void |
registerNewWorkerConfListener(java.util.function.BiConsumer<Address,List<ConfigProperty>> function)
Registers callback functions to use when workers register with configuration.
|
void |
registerWorkerLostListener(java.util.function.Consumer<Address> function)
Registers callback functions to use when detecting lost workers.
|
void |
removeBlocks(List<Long> blockIds,
boolean delete)
Removes blocks from workers.
|
void |
reportLostBlocks(List<Long> blockIds)
Reports the ids of the blocks lost on workers.
|
void |
resetState()
Resets the journaled internal state of the state machine.
|
void |
start(Boolean isLeader)
Starts the Alluxio server.
|
void |
validateBlocks(java.util.function.Function<Long,Boolean> validator,
boolean repair)
Validates the integrity of blocks with respect to the validator.
|
Command |
workerHeartbeat(long workerId,
Map<String,Long> usedBytesOnTiers,
List<Long> removedBlockIds,
Map<String,List<Long>> addedBlocksOnTiers,
List<Metric> metrics)
Updates metadata when a worker periodically heartbeats with the master.
|
void |
workerRegister(long workerId,
List<String> storageTiers,
Map<String,Long> totalBytesOnTiers,
Map<String,Long> usedBytesOnTiers,
Map<String,List<Long>> currentBlocksOnTiers,
RegisterWorkerTOptions options)
Updates metadata when a worker registers with the master.
|
createJournalContext, getExecutorService, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createJournalContext
public Map<String,org.apache.thrift.TProcessor> getServices()
getServices
in interface Server<Boolean>
TProcessor
s that serve RPCs for this serverpublic String getName()
getName
in interface JournalEntryStateMachine
getName
in interface Server<Boolean>
public void processJournalEntry(Journal.JournalEntry entry) throws IOException
JournalEntryStateMachine
processJournalEntry
in interface JournalEntryStateMachine
entry
- the entry to process to update the state of the state machineIOException
public void resetState()
JournalEntryStateMachine
resetState
in interface JournalEntryStateMachine
public Iterator<Journal.JournalEntry> getJournalEntryIterator()
getJournalEntryIterator
in interface JournalEntryIterable
Iterator
that iterates all the journal entriespublic void start(Boolean isLeader) throws IOException
Server
start
in interface Server<Boolean>
start
in class AbstractMaster
isLeader
- the start optionsIOException
public int getWorkerCount()
getWorkerCount
in interface BlockMaster
public int getLostWorkerCount()
getLostWorkerCount
in interface BlockMaster
public long getCapacityBytes()
getCapacityBytes
in interface BlockMaster
public StorageTierAssoc getGlobalStorageTierAssoc()
getGlobalStorageTierAssoc
in interface BlockMaster
public long getUsedBytes()
getUsedBytes
in interface BlockMaster
public List<WorkerInfo> getWorkerInfoList() throws UnavailableException
getWorkerInfoList
in interface BlockMaster
WorkerInfo
objects representing the live workers in AlluxioUnavailableException
public List<WorkerInfo> getLostWorkersInfoList() throws UnavailableException
getLostWorkersInfoList
in interface BlockMaster
WorkerInfo
s of lost workersUnavailableException
public List<WorkerInfo> getWorkerReport(GetWorkerReportOptions options) throws UnavailableException, InvalidArgumentException
BlockMaster
getWorkerReport
in interface BlockMaster
options
- the GetWorkerReportOptions defines the info rangeWorkerInfo
objects representing the workers in AlluxioUnavailableException
InvalidArgumentException
public void removeBlocks(List<Long> blockIds, boolean delete) throws UnavailableException
BlockMaster
removeBlocks
in interface BlockMaster
blockIds
- a list of block ids to remove from Alluxio spacedelete
- whether to delete blocks' metadata in MasterUnavailableException
public void validateBlocks(java.util.function.Function<Long,Boolean> validator, boolean repair) throws UnavailableException
BlockMaster
validateBlocks
in interface BlockMaster
validator
- a function returns true if the given block id is validrepair
- if true, deletes the invalid blocksUnavailableException
- if the invalid blocks cannot be deletedpublic long getNewContainerId() throws UnavailableException
getNewContainerId
in interface ContainerIdGenerable
UnavailableException
public void commitBlock(long workerId, long usedBytesOnTier, String tierAlias, long blockId, long length) throws NotFoundException, UnavailableException
BlockMaster
commitBlock
in interface BlockMaster
workerId
- the worker id committing the blockusedBytesOnTier
- the updated used bytes on the tier of the workertierAlias
- the alias of the storage tier where the worker is committing the block toblockId
- the committing block idlength
- the length of the blockNotFoundException
- if the workerId is not activeUnavailableException
public void commitBlockInUFS(long blockId, long length) throws UnavailableException
BlockMaster
commitBlockInUFS
in interface BlockMaster
blockId
- the id of the block to commitlength
- the length of the blockUnavailableException
public BlockInfo getBlockInfo(long blockId) throws BlockInfoException, UnavailableException
getBlockInfo
in interface BlockMaster
blockId
- the block id to get information forBlockInfo
for the given block idBlockInfoException
- if the block info is not foundUnavailableException
public List<BlockInfo> getBlockInfoList(List<Long> blockIds) throws UnavailableException
BlockMaster
getBlockInfoList
in interface BlockMaster
blockIds
- A list of block ids to retrieve the information forBlockInfo
objects corresponding to the input list of block ids. The
list is in the same order as the input listUnavailableException
public Map<String,Long> getTotalBytesOnTiers()
getTotalBytesOnTiers
in interface BlockMaster
public Map<String,Long> getUsedBytesOnTiers()
getUsedBytesOnTiers
in interface BlockMaster
public long getWorkerId(WorkerNetAddress workerNetAddress)
BlockMaster
getWorkerId
in interface BlockMaster
workerNetAddress
- the worker WorkerNetAddress
public void workerRegister(long workerId, List<String> storageTiers, Map<String,Long> totalBytesOnTiers, Map<String,Long> usedBytesOnTiers, Map<String,List<Long>> currentBlocksOnTiers, RegisterWorkerTOptions options) throws NotFoundException
BlockMaster
workerRegister
in interface BlockMaster
workerId
- the worker id of the worker registeringstorageTiers
- a list of storage tier aliases in order of their position in the worker's
hierarchytotalBytesOnTiers
- a mapping from storage tier alias to total bytesusedBytesOnTiers
- a mapping from storage tier alias to the used byescurrentBlocksOnTiers
- a mapping from storage tier alias to a list of blocksoptions
- the options that may contain worker configurationNotFoundException
- if workerId cannot be foundpublic Command workerHeartbeat(long workerId, Map<String,Long> usedBytesOnTiers, List<Long> removedBlockIds, Map<String,List<Long>> addedBlocksOnTiers, List<Metric> metrics)
BlockMaster
workerHeartbeat
in interface BlockMaster
workerId
- the worker idusedBytesOnTiers
- a mapping from tier alias to the used bytesremovedBlockIds
- a list of block ids removed from this workeraddedBlocksOnTiers
- a mapping from tier alias to the added blocksmetrics
- worker metricspublic Set<Long> getLostBlocks()
getLostBlocks
in interface BlockMaster
public void reportLostBlocks(List<Long> blockIds)
BlockMaster
reportLostBlocks
in interface BlockMaster
blockIds
- the ids of the lost blockspublic Set<Class<? extends Server>> getDependencies()
getDependencies
in interface Server<Boolean>
getDependencies
in class AbstractMaster
public void registerLostWorkerFoundListener(java.util.function.Consumer<Address> function)
BlockMaster
registerLostWorkerFoundListener
in interface BlockMaster
function
- the function to registerpublic void registerWorkerLostListener(java.util.function.Consumer<Address> function)
BlockMaster
registerWorkerLostListener
in interface BlockMaster
function
- the function to registerpublic void registerNewWorkerConfListener(java.util.function.BiConsumer<Address,List<ConfigProperty>> function)
BlockMaster
registerNewWorkerConfListener
in interface BlockMaster
function
- the function to registerCopyright © 2023. All Rights Reserved.