public int getDefaultStorageNum(BlockInfo block) { switch (block.getBlockType()) { case STRIPED: return ((BlockInfoStriped) block).getRealTotalBlockNum(); case CONTIGUOUS: return defaultReplication; default: throw new IllegalArgumentException( "getDefaultStorageNum called with unknown BlockType: " + block.getBlockType()); } }
public short getMinStorageNum(BlockInfo block) { switch(block.getBlockType()) { case STRIPED: return ((BlockInfoStriped) block).getRealDataBlockNum(); case CONTIGUOUS: return minReplication; default: throw new IllegalArgumentException( "getMinStorageNum called with unknown BlockType: " + block.getBlockType()); } }
/** * Add/Update the under construction feature. */ public void convertToBlockUnderConstruction(BlockUCState s, DatanodeStorageInfo[] targets) { if (isComplete()) { uc = new BlockUnderConstructionFeature(this, s, targets, this.getBlockType()); } else { // the block is already under construction uc.setBlockUCState(s); uc.setExpectedLocations(this, targets, this.getBlockType()); } }
INodeFile(long id, byte[] name, PermissionStatus permissions, long mtime, long atime, BlockInfo[] blklist, Short replication, Byte ecPolicyID, long preferredBlockSize, byte storagePolicyID, BlockType blockType) { super(id, name, permissions, mtime, atime); final long layoutRedundancy = HeaderFormat.getBlockLayoutRedundancy( blockType, replication, ecPolicyID); header = HeaderFormat.toLong(preferredBlockSize, layoutRedundancy, storagePolicyID); if (blklist != null && blklist.length > 0) { for (BlockInfo b : blklist) { Preconditions.checkArgument(b.getBlockType() == blockType); } } setBlocks(blklist); }
boolean isPlacementPolicySatisfied(BlockInfo storedBlock) { List<DatanodeDescriptor> liveNodes = new ArrayList<>(); Collection<DatanodeDescriptor> corruptNodes = corruptReplicas .getNodes(storedBlock); for (DatanodeStorageInfo storage : blocksMap.getStorages(storedBlock)) { if (storage.getStorageType() == StorageType.PROVIDED && storage.getState() == State.NORMAL) { // assume the policy is satisfied for blocks on PROVIDED storage // as long as the storage is in normal state. return true; } final DatanodeDescriptor cur = getDatanodeDescriptorFromStorage(storage); // Nodes under maintenance should be counted as valid replicas from // rack policy point of view. if (!cur.isDecommissionInProgress() && !cur.isDecommissioned() && ((corruptNodes == null) || !corruptNodes.contains(cur))) { liveNodes.add(cur); } } DatanodeInfo[] locs = liveNodes.toArray(new DatanodeInfo[liveNodes.size()]); BlockType blockType = storedBlock.getBlockType(); BlockPlacementPolicy placementPolicy = placementPolicies .getPolicy(blockType); int numReplicas = blockType == STRIPED ? ((BlockInfoStriped) storedBlock) .getRealTotalBlockNum() : storedBlock.getReplication(); return placementPolicy.verifyBlockPlacement(locs, numReplicas) .isPlacementPolicySatisfied(); }
placementPolicies.getPolicy(rw.getBlock().getBlockType()); rw.chooseTargets(placementPolicy, storagePolicySuite, excludedNodes);
src, oldBlock, newBlock, clientName); lastBlock.getUnderConstructionFeature().setExpectedLocations(lastBlock, storages, lastBlock.getBlockType());
lastBlock.getBlockType());