@ThreadSafe public class BlockMasterClient extends AbstractMasterClient
AbstractClient.RpcCallable<V>
Modifier and Type | Field and Description |
---|---|
BlockMasterWorkerServiceGrpc.BlockMasterWorkerServiceStub |
mAsyncClient |
BlockMasterWorkerServiceGrpc.BlockMasterWorkerServiceBlockingStub |
mClient |
mAddress, mChannel, mClosed, mConnected, mContext, mServiceVersion, mVersionService
Constructor and Description |
---|
BlockMasterClient(MasterClientContext conf)
Creates a new instance of
BlockMasterClient for the worker. |
Modifier and Type | Method and Description |
---|---|
void |
acquireRegisterLeaseWithBackoff(long workerId,
int estimatedBlockCount,
RetryPolicy retry)
Acquires a
RegisterLease from the master with
the RetryPolicy specified. |
protected void |
afterConnect()
This method is called after the connection is made to the remote.
|
void |
commitBlock(long workerId,
long usedBytesOnTier,
String tierAlias,
String mediumType,
long blockId,
long length)
Commits a block on a worker.
|
void |
commitBlockInUfs(long blockId,
long length)
Commits a block in Ufs.
|
List<LocationBlockIdListEntry> |
convertBlockListMapToProto(Map<BlockStoreLocation,List<Long>> blockListOnLocation)
Converts the block list map to a proto list.
|
long |
getId(WorkerNetAddress address)
Returns a worker id for a workers net address.
|
protected ServiceType |
getRemoteServiceType() |
protected String |
getServiceName() |
protected long |
getServiceVersion() |
Command |
heartbeat(long workerId,
Map<String,Long> capacityBytesOnTiers,
Map<String,Long> usedBytesOnTiers,
List<Long> removedBlocks,
Map<BlockStoreLocation,List<Long>> addedBlocks,
Map<String,List<String>> lostStorage,
List<Metric> metrics)
The method the worker should periodically execute to heartbeat back to the master.
|
void |
register(long workerId,
List<String> storageTierAliases,
Map<String,Long> totalBytesOnTiers,
Map<String,Long> usedBytesOnTiers,
Map<BlockStoreLocation,List<Long>> currentBlocksOnLocation,
Map<String,List<String>> lostStorage,
List<ConfigProperty> configList)
The method the worker should execute to register with the block master.
|
void |
registerWithStream(long workerId,
List<String> storageTierAliases,
Map<String,Long> totalBytesOnTiers,
Map<String,Long> usedBytesOnTiers,
Map<BlockStoreLocation,List<Long>> currentBlocksOnLocation,
Map<String,List<String>> lostStorage,
List<ConfigProperty> configList)
Registers with the master in a stream.
|
getAddress, getConfAddress
afterDisconnect, beforeConnect, beforeDisconnect, checkVersion, close, connect, disconnect, getRemoteServiceVersion, isClosed, isConnected, retryRPC, retryRPC
public BlockMasterWorkerServiceGrpc.BlockMasterWorkerServiceBlockingStub mClient
public BlockMasterWorkerServiceGrpc.BlockMasterWorkerServiceStub mAsyncClient
public BlockMasterClient(MasterClientContext conf)
BlockMasterClient
for the worker.conf
- master client configurationprotected ServiceType getRemoteServiceType()
getRemoteServiceType
in class AbstractClient
protected String getServiceName()
getServiceName
in class AbstractClient
protected long getServiceVersion()
getServiceVersion
in class AbstractClient
protected void afterConnect() throws IOException
AbstractClient
afterConnect
in class AbstractClient
IOException
public void commitBlock(long workerId, long usedBytesOnTier, String tierAlias, String mediumType, long blockId, long length) throws IOException
workerId
- the worker id committing the blockusedBytesOnTier
- the amount of used bytes on the tier the block is committing totierAlias
- the alias of the tier the block is being committed tomediumType
- the medium type the block is being committed toblockId
- the block id being committedlength
- the length of the block being committedIOException
public void commitBlockInUfs(long blockId, long length) throws IOException
blockId
- the block id being committedlength
- the length of the block being committedIOException
public long getId(WorkerNetAddress address) throws IOException
address
- the net address to get a worker id forIOException
public List<LocationBlockIdListEntry> convertBlockListMapToProto(Map<BlockStoreLocation,List<Long>> blockListOnLocation)
LocationBlockIdListEntry
instances shall have the same BlockStoreLocationProto
.
The uniqueness of BlockStoreLocationProto
is determined by tier alias and medium type.
That means directories with the same tier alias and medium type will be merged into the same
LocationBlockIdListEntry
.blockListOnLocation
- a map from block location to the block listpublic Command heartbeat(long workerId, Map<String,Long> capacityBytesOnTiers, Map<String,Long> usedBytesOnTiers, List<Long> removedBlocks, Map<BlockStoreLocation,List<Long>> addedBlocks, Map<String,List<String>> lostStorage, List<Metric> metrics) throws IOException
workerId
- the worker idcapacityBytesOnTiers
- a mapping from storage tier alias to capacity bytesusedBytesOnTiers
- a mapping from storage tier alias to used bytesremovedBlocks
- a list of block removed from this workeraddedBlocks
- a mapping from storage tier alias to added blockslostStorage
- a mapping from storage tier alias to a list of lost storage pathsmetrics
- a list of worker metricsIOException
public void acquireRegisterLeaseWithBackoff(long workerId, int estimatedBlockCount, RetryPolicy retry) throws IOException, FailedToAcquireRegisterLeaseException
RegisterLease
from the master with
the RetryPolicy
specified.
If all the retry attempts have been exhaused, a FailedToAcquireRegisterLeaseException
will be thrown.workerId
- the worker IDestimatedBlockCount
- the number of blocks this worker currently holds
There is a gap between acquiring a lease and generating the RegisterWorkerPRequest
so the real block count may be different. But this is a good hint for the master to
guess how much resource the registration will take.retry
- a retry policyIOException
FailedToAcquireRegisterLeaseException
public void register(long workerId, List<String> storageTierAliases, Map<String,Long> totalBytesOnTiers, Map<String,Long> usedBytesOnTiers, Map<BlockStoreLocation,List<Long>> currentBlocksOnLocation, Map<String,List<String>> lostStorage, List<ConfigProperty> configList) throws IOException
workerId
- the worker id of the worker registeringstorageTierAliases
- a list of storage tier aliases in ordinal ordertotalBytesOnTiers
- mapping from storage tier alias to total bytesusedBytesOnTiers
- mapping from storage tier alias to used bytescurrentBlocksOnLocation
- mapping from storage tier alias to the list of list of blockslostStorage
- mapping from storage tier alias to the list of lost storage pathsconfigList
- a list of configurationsIOException
public void registerWithStream(long workerId, List<String> storageTierAliases, Map<String,Long> totalBytesOnTiers, Map<String,Long> usedBytesOnTiers, Map<BlockStoreLocation,List<Long>> currentBlocksOnLocation, Map<String,List<String>> lostStorage, List<ConfigProperty> configList) throws IOException
workerId
- the worker IDstorageTierAliases
- storage/tier setup from the configurationtotalBytesOnTiers
- the capacity of each tierusedBytesOnTiers
- the current usage of each tiercurrentBlocksOnLocation
- the blocks in each tier/dirlostStorage
- the lost storage pathsconfigList
- the configuration propertiesIOException
Copyright © 2023. All Rights Reserved.