Class StoragePolicySatisfier
java.lang.Object
org.apache.hadoop.hdfs.server.namenode.sps.StoragePolicySatisfier
- All Implemented Interfaces:
Runnable,SPSService
Setting storagePolicy on a file after the file write will only update the new
storage policy type in Namespace, but physical block storage movement will
not happen until user runs "Mover Tool" explicitly for such files. The
StoragePolicySatisfier Daemon thread implemented for addressing the case
where users may want to physically move the blocks by a dedicated daemon (can
run inside Namenode or stand alone) instead of running mover tool explicitly.
Just calling client API to satisfyStoragePolicy on a file/dir will
automatically trigger to move its physical storage locations as expected in
asynchronous manner. Here SPS will pick the file blocks which are expecting
to change its storages, then it will build the mapping of source block
location and expected storage type and location to move. After that this
class will also prepare requests to send to Datanode for processing the
physical block movements.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classThis class contains information of an attempted blocks and its last attempted or reported time stamp.static classMaintains storage type map with the available datanodes in the cluster.static final classKeeps datanode with its respective set of supported storage types. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAllFilesToProcess(long startPath, List<ItemInfo> itemInfoList, boolean scanCompleted) Adds all the Item information(file etc) to processing queue.voidaddFileToProcess(ItemInfo trackInfo, boolean scanCompleted) Adds the Item information(file etc) to processing queue.voidClear the queues from to be storage movement needed lists and items tracked in storage movement monitor.org.apache.hadoop.conf.ConfigurationgetConf()voidInitializes the helper services.booleanCheck whether StoragePolicySatisfier is running.voidjoin()Join main SPS thread.voidmarkScanCompletedForPath(long inodeId) Marks the scanning of directory if finished.voidnotifyStorageMovementAttemptFinishedBlk(org.apache.hadoop.hdfs.protocol.DatanodeInfo dnInfo, org.apache.hadoop.fs.StorageType storageType, org.apache.hadoop.hdfs.protocol.Block block) Receives storage movement attempt finished block report.intvoidrun()voidstart(org.apache.hadoop.hdfs.protocol.HdfsConstants.StoragePolicySatisfierMode serviceMode) Start storage policy satisfier demon thread.voidstop(boolean forceStop) Stops the SPS service.voidStops the SPS service gracefully.
-
Field Details
-
LOG
public static final org.slf4j.Logger LOG
-
-
Constructor Details
-
StoragePolicySatisfier
public StoragePolicySatisfier(org.apache.hadoop.conf.Configuration conf)
-
-
Method Details
-
init
Description copied from interface:SPSServiceInitializes the helper services.- Specified by:
initin interfaceSPSService- Parameters:
context- - context is an helper service to provide communication channel between NN and SPS
-
start
public void start(org.apache.hadoop.hdfs.protocol.HdfsConstants.StoragePolicySatisfierMode serviceMode) Start storage policy satisfier demon thread. Also start block storage movements monitor for retry the attempts if needed.- Specified by:
startin interfaceSPSService- Parameters:
serviceMode- sps service mode
-
stop
public void stop(boolean forceStop) Description copied from interface:SPSServiceStops the SPS service.- Specified by:
stopin interfaceSPSService- Parameters:
forceStop- true represents to clear all the sps path's hint, false otherwise.
-
stopGracefully
public void stopGracefully()Description copied from interface:SPSServiceStops the SPS service gracefully. Timed wait to stop storage policy satisfier daemon threads.- Specified by:
stopGracefullyin interfaceSPSService
-
isRunning
public boolean isRunning()Description copied from interface:SPSServiceCheck whether StoragePolicySatisfier is running.- Specified by:
isRunningin interfaceSPSService- Returns:
- true if running
-
run
public void run() -
notifyStorageMovementAttemptFinishedBlk
public void notifyStorageMovementAttemptFinishedBlk(org.apache.hadoop.hdfs.protocol.DatanodeInfo dnInfo, org.apache.hadoop.fs.StorageType storageType, org.apache.hadoop.hdfs.protocol.Block block) Receives storage movement attempt finished block report.- Specified by:
notifyStorageMovementAttemptFinishedBlkin interfaceSPSService- Parameters:
dnInfo- reported datanodestorageType- - storage typeblock- movement attempt finished block.
-
getAttemptedItemsMonitor
-
clearQueues
public void clearQueues()Clear the queues from to be storage movement needed lists and items tracked in storage movement monitor. -
addFileToProcess
Description copied from interface:SPSServiceAdds the Item information(file etc) to processing queue.- Specified by:
addFileToProcessin interfaceSPSService- Parameters:
trackInfo- file info object for which need to satisfy the policy
-
addAllFilesToProcess
public void addAllFilesToProcess(long startPath, List<ItemInfo> itemInfoList, boolean scanCompleted) Description copied from interface:SPSServiceAdds all the Item information(file etc) to processing queue.- Specified by:
addAllFilesToProcessin interfaceSPSService- Parameters:
startPath- - directoryId/fileId, on which SPS was called.itemInfoList- - list of item infosscanCompleted- - whether the scanning of directory fully done with itemInfoList
-
processingQueueSize
public int processingQueueSize()- Specified by:
processingQueueSizein interfaceSPSService- Returns:
- current processing queue size.
-
getConf
public org.apache.hadoop.conf.Configuration getConf()- Specified by:
getConfin interfaceSPSService- Returns:
- the configuration.
-
getStorageMovementQueue
-
markScanCompletedForPath
public void markScanCompletedForPath(long inodeId) Description copied from interface:SPSServiceMarks the scanning of directory if finished.- Specified by:
markScanCompletedForPathin interfaceSPSService- Parameters:
inodeId- - satisfier path id
-
join
Join main SPS thread.- Throws:
InterruptedException
-