Class ExternalSPSContext
java.lang.Object
org.apache.hadoop.hdfs.server.sps.ExternalSPSContext
- All Implemented Interfaces:
Context
This class used to connect to Namenode and gets the required information to
SPS from Namenode state.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidorg.apache.hadoop.hdfs.protocol.HdfsFileStatusgetFileInfo(long path) Get the file info for a specific file.org.apache.hadoop.hdfs.server.protocol.DatanodeStorageReport[]Returns all the live datanodes and its storage details.org.apache.hadoop.net.NetworkTopologygetNetworkTopology(StoragePolicySatisfier.DatanodeMap datanodeMap) Gets the network topology.intGets the number of live datanodes in the cluster.org.apache.hadoop.hdfs.protocol.BlockStoragePolicygetStoragePolicy(byte policyId) Gets the storage policy details for the given policy ID.voidbooleanisFileExist(long path) Returns true if the give file exists in the Namespace.booleanReturns true if the Namenode in safe mode, false otherwise.booleanReturns true if the SPS is running, false otherwise.voidnotifyMovementTriedBlocks(org.apache.hadoop.hdfs.protocol.Block[] moveAttemptFinishedBlks) This can be used to notify to the SPS about block movement attempt finished.voidremoveSPSHint(long inodeId) Remove the hint which was added to track SPS call.voidscanAndCollectFiles(long path) Do scan and collects the files under that directory and adds to the given BlockStorageMovementNeeded.voidsubmitMoveTask(BlockStorageMovementCommand.BlockMovingInfo blkMovingInfo) Handles the block move tasks.
-
Field Details
-
LOG
public static final org.slf4j.Logger LOG
-
-
Constructor Details
-
ExternalSPSContext
-
-
Method Details
-
isRunning
public boolean isRunning()Description copied from interface:ContextReturns true if the SPS is running, false otherwise. -
isInSafeMode
public boolean isInSafeMode()Description copied from interface:ContextReturns true if the Namenode in safe mode, false otherwise.- Specified by:
isInSafeModein interfaceContext
-
getNetworkTopology
public org.apache.hadoop.net.NetworkTopology getNetworkTopology(StoragePolicySatisfier.DatanodeMap datanodeMap) Description copied from interface:ContextGets the network topology.- Specified by:
getNetworkTopologyin interfaceContext- Parameters:
datanodeMap- target datanodes- Returns:
- network topology
-
isFileExist
public boolean isFileExist(long path) Description copied from interface:ContextReturns true if the give file exists in the Namespace.- Specified by:
isFileExistin interfaceContext- Parameters:
path- - file info- Returns:
- true if the given file exists, false otherwise.
-
getStoragePolicy
public org.apache.hadoop.hdfs.protocol.BlockStoragePolicy getStoragePolicy(byte policyId) Description copied from interface:ContextGets the storage policy details for the given policy ID.- Specified by:
getStoragePolicyin interfaceContext- Parameters:
policyId- - Storage policy ID- Returns:
- the detailed policy object
-
removeSPSHint
Description copied from interface:ContextRemove the hint which was added to track SPS call.- Specified by:
removeSPSHintin interfaceContext- Parameters:
inodeId- - user invoked satisfier path- Throws:
IOException
-
getNumLiveDataNodes
public int getNumLiveDataNodes()Description copied from interface:ContextGets the number of live datanodes in the cluster.- Specified by:
getNumLiveDataNodesin interfaceContext- Returns:
- number of live datanodes
-
getFileInfo
Description copied from interface:ContextGet the file info for a specific file.- Specified by:
getFileInfoin interfaceContext- Parameters:
path- file path- Returns:
- file status metadata information
- Throws:
IOException
-
getLiveDatanodeStorageReport
public org.apache.hadoop.hdfs.server.protocol.DatanodeStorageReport[] getLiveDatanodeStorageReport() throws IOExceptionDescription copied from interface:ContextReturns all the live datanodes and its storage details.- Specified by:
getLiveDatanodeStorageReportin interfaceContext- Throws:
IOException
-
getNextSPSPath
- Specified by:
getNextSPSPathin interfaceContext- Returns:
- next SPS path info to process.
-
scanAndCollectFiles
Description copied from interface:ContextDo scan and collects the files under that directory and adds to the given BlockStorageMovementNeeded.- Specified by:
scanAndCollectFilesin interfaceContext- Parameters:
path- file path- Throws:
IOExceptionInterruptedException
-
submitMoveTask
public void submitMoveTask(BlockStorageMovementCommand.BlockMovingInfo blkMovingInfo) throws IOException Description copied from interface:ContextHandles the block move tasks. BlockMovingInfo must contain the required info to move the block, that source location, destination location and storage types.- Specified by:
submitMoveTaskin interfaceContext- Throws:
IOException
-
notifyMovementTriedBlocks
public void notifyMovementTriedBlocks(org.apache.hadoop.hdfs.protocol.Block[] moveAttemptFinishedBlks) Description copied from interface:ContextThis can be used to notify to the SPS about block movement attempt finished. Then SPS will re-check whether it needs retry or not.- Specified by:
notifyMovementTriedBlocksin interfaceContext- Parameters:
moveAttemptFinishedBlks- list of movement attempt finished blocks
-
initMetrics
-
closeMetrics
public void closeMetrics() -
getSpsBeanMetrics
-