@ThreadSafe public class BlockMasterClient extends AbstractMasterClient
AbstractClient.RpcCallable<V>
Modifier and Type | Field and Description |
---|---|
BlockMasterWorkerServiceGrpc.BlockMasterWorkerServiceStub |
mAsyncClient |
BlockMasterWorkerServiceGrpc.BlockMasterWorkerServiceBlockingStub |
mClient |
mAlwaysEnableTLS, mChannel, mClosed, mConnected, mContext, mServerAddress, mServiceVersion, mVersionService
Constructor and Description |
---|
BlockMasterClient(MasterClientContext conf)
Creates a new instance of
BlockMasterClient for the worker. |
BlockMasterClient(MasterClientContext conf,
InetSocketAddress address)
Creates a new instance of
BlockMasterClient for the worker and
connects to a specific master. |
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.
|
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 |
notifyWorkerId(long workerId,
WorkerNetAddress address)
Notify all masters about the worker ID.
|
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.
|
afterDisconnect, beforeConnect, getConfAddress, queryGrpcServerAddress
beforeDisconnect, checkVersion, close, connect, connectWithRuntimeException, createChannel, disconnect, getRemoteHostName, getRemoteServiceVersion, getRemoteSockAddress, isClosed, isConnected, retryRPC, retryRPC
public BlockMasterWorkerServiceGrpc.BlockMasterWorkerServiceBlockingStub mClient
public BlockMasterWorkerServiceGrpc.BlockMasterWorkerServiceStub mAsyncClient
public BlockMasterClient(MasterClientContext conf)
BlockMasterClient
for the worker.conf
- master client configurationpublic BlockMasterClient(MasterClientContext conf, InetSocketAddress address)
BlockMasterClient
for the worker and
connects to a specific master.conf
- master client configurationaddress
- the master addressprotected ServiceType getRemoteServiceType()
getRemoteServiceType
in class AbstractClient
protected String getServiceName()
getServiceName
in class AbstractClient
protected long getServiceVersion()
getServiceVersion
in class AbstractClient
protected void afterConnect()
AbstractClient
afterConnect
in class AbstractClient
public void commitBlock(long workerId, long usedBytesOnTier, String tierAlias, String mediumType, long blockId, long length) throws AlluxioStatusException
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 committedAlluxioStatusException
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
public void notifyWorkerId(long workerId, WorkerNetAddress address) throws IOException
workerId
- the worker idaddress
- the worker addressIOException
Copyright © 2023. All Rights Reserved.