BlockManager implements BlockStatsMXBean { @VisibleForTesting public BlockPlacementPolicy getBlockPlacementPolicy() { return placementPolicies.getPolicy(CONTIGUOUS); } BlockManager(final Namesystem namesystem, boolean haEnabled,
      final Configuration conf); long getPendingReconstructionBlocksCount(); long getLowRedundancyBlocksCount(); long getCorruptReplicaBlocksCount(); long getScheduledReplicationBlocksCount(); long getPendingDeletionBlocksCount(); long getStartupDelayBlockDeletionInMs(); long getExcessBlocksCount(); long getPostponedMisreplicatedBlocksCount(); int getPendingDataNodeMessageCount(); long getNumTimedOutPendingReconstructions(); long getLowRedundancyBlocks(); long getCorruptBlocks(); long getMissingBlocks(); long getMissingReplicationOneBlocks(); long getPendingDeletionReplicatedBlocks(); long getTotalReplicatedBlocks(); long getLowRedundancyECBlockGroups(); long getCorruptECBlockGroups(); long getMissingECBlockGroups(); long getPendingDeletionECBlocks(); long getTotalECBlockGroups(); BlockStoragePolicy getStoragePolicy(final String policyName); BlockStoragePolicy getStoragePolicy(final byte policyId); BlockStoragePolicy[] getStoragePolicies(); void setBlockPoolId(String blockPoolId); String getBlockPoolId(); BlockStoragePolicySuite getStoragePolicySuite(); @VisibleForTesting BlockTokenSecretManager getBlockTokenSecretManager(); void activate(Configuration conf, long blockTotal); void close(); DatanodeManager getDatanodeManager(); @VisibleForTesting BlockPlacementPolicy getBlockPlacementPolicy(); void refreshBlockPlacementPolicy(Configuration conf); void metaSave(PrintWriter out); int getMaxReplicationStreams(); void setMaxReplicationStreams(int newVal); int getReplicationStreamsHardLimit(); void setReplicationStreamsHardLimit(int newVal); int getBlocksReplWorkMultiplier(); void setBlocksReplWorkMultiplier(int newVal); int getDefaultStorageNum(BlockInfo block); short getMinReplication(); short getMinStorageNum(BlockInfo block); short getMinReplicationToBeInMaintenance(); boolean hasMinStorage(BlockInfo block); boolean hasMinStorage(BlockInfo block, int liveNum); boolean commitOrCompleteLastBlock(BlockCollection bc,
      Block commitBlock, INodesInPath iip); void addExpectedReplicasToPending(BlockInfo blk); void forceCompleteBlock(final BlockInfo block); LocatedBlock convertLastBlockToUnderConstruction(
      BlockCollection bc, long bytesToRemove); LocatedBlocks createLocatedBlocks(final BlockInfo[] blocks,
      final long fileSizeExcludeBlocksUnderConstruction,
      final boolean isFileUnderConstruction, final long offset,
      final long length, final boolean needBlockToken,
      final boolean inSnapshot, FileEncryptionInfo feInfo,
      ErasureCodingPolicy ecPolicy); ExportedBlockKeys getBlockKeys(); void setBlockToken(final LocatedBlock b,
      final AccessMode mode); DataEncryptionKey generateDataEncryptionKey(); short adjustReplication(short replication); void verifyReplication(String src,
                          short replication,
                          String clientName); boolean isSufficientlyReplicated(BlockInfo b); BlocksWithLocations getBlocksWithLocations(final DatanodeID datanode,
      final long size, final long minBlockSize); void findAndMarkBlockAsCorrupt(final ExtendedBlock blk,
      final DatanodeInfo dn, String storageID, String reason); void setPostponeBlocksFromFuture(boolean postpone); int getUnderReplicatedNotMissingBlocks(); DatanodeStorageInfo[] chooseTarget4WebHDFS(String src,
      DatanodeDescriptor clientnode, Set<Node> excludes, long blocksize); DatanodeStorageInfo[] chooseTarget4AdditionalDatanode(String src,
      int numAdditionalNodes,
      Node clientnode,
      List<DatanodeStorageInfo> chosen,
      Set<Node> excludes,
      long blocksize,
      byte storagePolicyID,
      BlockType blockType); DatanodeStorageInfo[] chooseTarget4NewBlock(final String src,
      final int numOfReplicas, final Node client,
      final Set<Node> excludedNodes,
      final long blocksize,
      final List<String> favoredNodes,
      final byte storagePolicyID,
      final BlockType blockType,
      final ErasureCodingPolicy ecPolicy,
      final EnumSet<AddBlockFlag> flags); long requestBlockReportLeaseId(DatanodeRegistration nodeReg); void registerDatanode(DatanodeRegistration nodeReg); void setBlockTotal(long total); boolean isInSafeMode(); String getSafeModeTip(); boolean leaveSafeMode(boolean force); void checkSafeMode(); long getBytesInFuture(); long getBytesInFutureReplicatedBlocks(); long getBytesInFutureECBlockGroups(); void removeBlocksAndUpdateSafemodeTotal(BlocksMapUpdateInfo blocks); long getProvidedCapacity(); boolean checkBlockReportLease(BlockReportContext context,
      final DatanodeID nodeID); boolean processReport(final DatanodeID nodeID,
      final DatanodeStorage storage,
      final BlockListAsLongs newReport,
      BlockReportContext context); void removeBRLeaseIfNeeded(final DatanodeID nodeID,
      final BlockReportContext context); void markBlockReplicasAsCorrupt(Block oldBlock,
      BlockInfo block,
      long oldGenerationStamp, long oldNumBytes, 
      DatanodeStorageInfo[] newStorages); void processQueuedMessagesForBlock(Block b); void processAllPendingDNMessages(); void processMisReplicatedBlocks(); double getReconstructionQueuesInitProgress(); boolean hasNonEcBlockUsingStripedID(); int processMisReplicatedBlocks(List<BlockInfo> blocks); void setReplication(
      final short oldRepl, final short newRepl, final BlockInfo b); void removeStoredBlock(BlockInfo storedBlock, DatanodeDescriptor node); @VisibleForTesting void addBlock(DatanodeStorageInfo storageInfo, Block block,
      String delHint); void processIncrementalBlockReport(final DatanodeID nodeID,
      final StorageReceivedDeletedBlocks srdb); NumberReplicas countNodes(BlockInfo b); boolean isExcess(DatanodeDescriptor dn, BlockInfo blk); int getActiveBlockCount(); DatanodeStorageInfo[] getStorages(BlockInfo block); Iterable<DatanodeStorageInfo> getStorages(final Block block); int getTotalBlocks(); void removeBlock(BlockInfo block); BlockInfo getStoredBlock(Block block); void updateLastBlock(BlockInfo lastBlock, ExtendedBlock newBlock); void checkRedundancy(BlockCollection bc); @VisibleForTesting boolean containsInvalidateBlock(final DatanodeInfo dn,
      final Block block); short getExpectedLiveRedundancyNum(BlockInfo block,
      NumberReplicas numberReplicas); short getExpectedRedundancyNum(BlockInfo block); long getMissingBlocksCount(); long getMissingReplOneBlocksCount(); long getHighestPriorityReplicatedBlockCount(); long getHighestPriorityECBlockCount(); BlockInfo addBlockCollection(BlockInfo block,
      BlockCollection bc); BlockInfo addBlockCollectionWithCheck(
      BlockInfo block, BlockCollection bc); int numCorruptReplicas(Block block); void removeBlockFromMap(BlockInfo block); int getCapacity(); Iterator<BlockInfo> getCorruptReplicaBlockIterator(); Collection<DatanodeDescriptor> getCorruptReplicas(Block block); String getCorruptReason(Block block, DatanodeDescriptor node); int numOfUnderReplicatedBlocks(); @VisibleForTesting long getLastRedundancyMonitorTS(); void clearQueues(); static LocatedBlock newLocatedBlock(
      ExtendedBlock b, DatanodeStorageInfo[] storages,
      long startOffset, boolean corrupt); static LocatedStripedBlock newLocatedStripedBlock(
      ExtendedBlock b, DatanodeStorageInfo[] storages,
      byte[] indices, long startOffset, boolean corrupt); static LocatedBlock newLocatedBlock(ExtendedBlock eb, BlockInfo info,
      DatanodeStorageInfo[] locs, long offset); void shutdown(); void clear(); BlockReportLeaseManager getBlockReportLeaseManager(); @Override // BlockStatsMXBean Map<StorageType, StorageTypeStats> getStorageTypeStats(); void initializeReplQueues(); boolean isPopulatingReplQueues(); void setInitializedReplQueues(boolean v); boolean shouldPopulateReplQueues(); void enqueueBlockOp(final Runnable action); T runBlockOp(final Callable<T> action); void successfulBlockRecovery(BlockInfo block); boolean addBlockRecoveryAttempt(BlockInfo b); @VisibleForTesting void flushBlockOps(); int getBlockOpQueueLength(); BlockIdManager getBlockIdManager(); long nextGenerationStamp(boolean legacyBlock); boolean isLegacyBlock(Block block); long nextBlockId(BlockType blockType); @VisibleForTesting void setBlockRecoveryTimeout(long blockRecoveryTimeout); @VisibleForTesting ProvidedStorageMap getProvidedStorageMap(); boolean createSPSManager(final Configuration conf,
      final String spsMode); void disableSPS(); StoragePolicySatisfyManager getSPSManager(); static final Logger LOG; static final Logger blockLog; final LowRedundancyBlocks neededReconstruction; final short maxReplication; final short minReplication; final int defaultReplication; }
@Test public void testUseDelHint() { DatanodeStorageInfo delHint = new DatanodeStorageInfo( DFSTestUtil.getLocalDatanodeDescriptor(), new DatanodeStorage("id")); List<DatanodeStorageInfo> moreThan1Racks = Arrays.asList(delHint); List<StorageType> excessTypes = new ArrayList<>(); BlockPlacementPolicyDefault policyDefault = (BlockPlacementPolicyDefault) bm.getBlockPlacementPolicy(); excessTypes.add(StorageType.DEFAULT); Assert.assertTrue(policyDefault.useDelHint(delHint, null, moreThan1Racks, null, excessTypes)); excessTypes.remove(0); excessTypes.add(StorageType.SSD); Assert.assertFalse(policyDefault.useDelHint(delHint, null, moreThan1Racks, null, excessTypes)); }