static void checkBlock(FSNamesystem fsn, ExtendedBlock block) throws IOException { String bpId = fsn.getBlockPoolId(); if (block != null && !bpId.equals(block.getBlockPoolId())) { throw new IOException("Unexpected BlockPoolId " + block.getBlockPoolId() + " - expected " + bpId); } }
private void checkBlock(ExtendedBlock block) { Preconditions.checkArgument(block != null, "block is null"); final String bpId = getBlockPoolId(); Preconditions.checkArgument(block.getBlockPoolId().equals(bpId), "block belongs to BP %s instead of BP %s", block.getBlockPoolId(), bpId); }
@Override public DataEncryptionKey newDataEncryptionKey() { return dnConf.encryptDataTransfer ? blockPoolTokenSecretManager.generateDataEncryptionKey( block.getBlockPoolId()) : null; } };
public void notifyNamenodeReceivedBlock(ExtendedBlock block, String delHint, String storageUuid, boolean isOnTransientStorage) { BPOfferService bpos = blockPoolManager.get(block.getBlockPoolId()); if(bpos != null) { bpos.notifyNamenodeReceivedBlock(block, delHint, storageUuid, isOnTransientStorage); } else { LOG.error("Cannot find BPOfferService for reporting block received " + "for bpid={}", block.getBlockPoolId()); } }
/** Notify the corresponding namenode to delete the block. */ public void notifyNamenodeDeletedBlock(ExtendedBlock block, String storageUuid) { BPOfferService bpos = blockPoolManager.get(block.getBlockPoolId()); if (bpos != null) { bpos.notifyNamenodeDeletedBlock(block, storageUuid); } else { LOG.error("Cannot find BPOfferService for reporting block deleted for bpid=" + block.getBlockPoolId()); } }
protected void notifyNamenodeReceivingBlock( ExtendedBlock block, String storageUuid) { BPOfferService bpos = blockPoolManager.get(block.getBlockPoolId()); if(bpos != null) { bpos.notifyNamenodeReceivingBlock(block, storageUuid); } else { LOG.error("Cannot find BPOfferService for reporting block receiving " + "for bpid={}", block.getBlockPoolId()); } }
/** Convert an ExtendedBlock to a Json map. */ private static Map<String, Object> toJsonMap(final ExtendedBlock extendedblock) { if (extendedblock == null) { return null; } final Map<String, Object> m = new TreeMap<String, Object>(); m.put("blockPoolId", extendedblock.getBlockPoolId()); m.put("blockId", extendedblock.getBlockId()); m.put("numBytes", extendedblock.getNumBytes()); m.put("generationStamp", extendedblock.getGenerationStamp()); return m; }
/** * See {@link BlockTokenSecretManager#checkAccess(BlockTokenIdentifier, * String, ExtendedBlock, BlockTokenIdentifier.AccessMode, * StorageType[], String[])} */ public void checkAccess(BlockTokenIdentifier id, String userId, ExtendedBlock block, AccessMode mode, StorageType[] storageTypes, String[] storageIds) throws InvalidToken { get(block.getBlockPoolId()).checkAccess(id, userId, block, mode, storageTypes, storageIds); }
/** * See {@link BlockTokenSecretManager#checkAccess(Token, String, * ExtendedBlock, BlockTokenIdentifier.AccessMode, * StorageType[], String[])} */ public void checkAccess(Token<BlockTokenIdentifier> token, String userId, ExtendedBlock block, AccessMode mode, StorageType[] storageTypes, String[] storageIds) throws InvalidToken { get(block.getBlockPoolId()).checkAccess(token, userId, block, mode, storageTypes, storageIds); }
/** * See {@link BlockTokenSecretManager#generateToken(ExtendedBlock, EnumSet, * StorageType[], String[])}. */ public Token<BlockTokenIdentifier> generateToken(ExtendedBlock b, EnumSet<AccessMode> of, StorageType[] storageTypes, String[] storageIds) throws IOException { return get(b.getBlockPoolId()).generateToken(b, of, storageTypes, storageIds); }
/** * Get File name for a given block. */ private ReplicaInfo getBlockReplica(ExtendedBlock b) throws IOException { return getBlockReplica(b.getBlockPoolId(), b.getBlockId()); }
/** Generate a block token for a specified user */ public Token<BlockTokenIdentifier> generateToken(String userId, ExtendedBlock block, EnumSet<BlockTokenIdentifier.AccessMode> modes, StorageType[] storageTypes, String[] storageIds) throws IOException { BlockTokenIdentifier id = new BlockTokenIdentifier(userId, block .getBlockPoolId(), block.getBlockId(), modes, storageTypes, storageIds, useProto); return new Token<BlockTokenIdentifier>(id, this); }
private static Replica getReplica(ExtendedBlock block, DataNode datanode) throws ReplicaNotFoundException { Replica replica = datanode.data.getReplica(block.getBlockPoolId(), block.getBlockId()); if (replica == null) { throw new ReplicaNotFoundException(block); } return replica; }
@Override public String toString() { // Called in AsyncDiskService.execute for displaying error messages. return "deletion of block " + block.getBlockPoolId() + " " + block.getLocalBlock() + " with block file " + replicaToDelete.getBlockURI() + " and meta file " + replicaToDelete.getMetadataURI() + " from volume " + volume; }
RecoveryTaskContiguous(RecoveringBlock rBlock) { this.rBlock = rBlock; block = rBlock.getBlock(); bpid = block.getBlockPoolId(); locs = rBlock.getLocations(); recoveryId = rBlock.getNewGenerationStamp(); }
@Override public FsVolumeImpl getVolume(final ExtendedBlock b) { try (AutoCloseableLock lock = datasetLock.acquire()) { final ReplicaInfo r = volumeMap.get(b.getBlockPoolId(), b.getLocalBlock()); return r != null ? (FsVolumeImpl) r.getVolume() : null; } }
RecoveryTaskStriped(RecoveringStripedBlock rBlock) { this.rBlock = rBlock; // TODO: support truncate Preconditions.checkArgument(rBlock.getNewBlock() == null); block = rBlock.getBlock(); bpid = block.getBlockPoolId(); locs = rBlock.getLocations(); recoveryId = rBlock.getNewGenerationStamp(); blockIndices = rBlock.getBlockIndices(); ecPolicy = rBlock.getErasureCodingPolicy(); }
@Override // FsDatasetSpi public boolean contains(final ExtendedBlock block) { try (AutoCloseableLock lock = datasetLock.acquire()) { final long blockId = block.getLocalBlock().getBlockId(); final String bpid = block.getBlockPoolId(); final ReplicaInfo r = volumeMap.get(bpid, blockId); return (r != null && r.blockDataExists()); } }
@Override // FsDatasetSpi public ReplicaRecoveryInfo initReplicaRecovery(RecoveringBlock rBlock) throws IOException { return initReplicaRecovery(rBlock.getBlock().getBlockPoolId(), volumeMap, rBlock.getBlock().getLocalBlock(), rBlock.getNewGenerationStamp(), datanode.getDnConf().getXceiverStopTimeout()); }
public ReplicaInPipeline createRbw(ExtendedBlock b) throws IOException { File f = createRbwFile(b.getBlockPoolId(), b.getLocalBlock()); LocalReplicaInPipeline newReplicaInfo = new ReplicaBuilder(ReplicaState.RBW) .setBlockId(b.getBlockId()) .setGenerationStamp(b.getGenerationStamp()) .setFsVolume(this) .setDirectoryToUse(f.getParentFile()) .setBytesToReserve(b.getNumBytes()) .buildLocalReplicaInPipeline(); return newReplicaInfo; }