@Override // ReplicaInPipeline public synchronized ChunkChecksum getLastChecksumAndDataLen() { return new ChunkChecksum(getBytesOnDisk(), lastChecksum); }
byte[] updatedChecksum = lastChunkChecksum.getChecksum(); if (updatedChecksum != null) { System.arraycopy(updatedChecksum, 0, buf, start, checksumSize);
long end = chunkChecksum != null ? chunkChecksum.getDataLength() : replica.getBytesOnDisk(); if (startOffset < 0 || startOffset > end
private ChunkChecksum getPartialChunkChecksumForFinalized( FinalizedReplica finalized) throws IOException { // There are a number of places in the code base where a finalized replica // object is created. If last partial checksum is loaded whenever a // finalized replica is created, it would increase latency in DataNode // initialization. Therefore, the last partial chunk checksum is loaded // lazily. // Load last checksum in case the replica is being written concurrently final long replicaVisibleLength = replica.getVisibleLength(); if (replicaVisibleLength % CHUNK_SIZE != 0 && finalized.getLastPartialChunkChecksum() == null) { // the finalized replica does not have precomputed last partial // chunk checksum. Recompute now. try { finalized.loadLastPartialChunkChecksum(); return new ChunkChecksum(finalized.getVisibleLength(), finalized.getLastPartialChunkChecksum()); } catch (FileNotFoundException e) { // meta file is lost. Continue anyway to preserve existing behavior. DataNode.LOG.warn( "meta file " + finalized.getMetaFile() + " is missing!"); return null; } } else { // If the checksum is null, BlockSender will use on-disk checksum. return new ChunkChecksum(finalized.getVisibleLength(), finalized.getLastPartialChunkChecksum()); } }
/** * * @param bytesReserved Space that was reserved during * block creation. Now that the block is being finalized we * can free up this space. * @return * @throws IOException */ ReplicaInfo addFinalizedBlock(String bpid, Block b, ReplicaInfo replicaInfo, long bytesReserved) throws IOException { releaseReservedSpace(bytesReserved); File dest = getBlockPoolSlice(bpid).addFinalizedBlock(b, replicaInfo); byte[] checksum = null; // copy the last partial checksum if the replica is originally // in finalized or rbw state. if (replicaInfo.getState() == ReplicaState.FINALIZED) { FinalizedReplica finalized = (FinalizedReplica)replicaInfo; checksum = finalized.getLastPartialChunkChecksum(); } else if (replicaInfo.getState() == ReplicaState.RBW) { ReplicaBeingWritten rbw = (ReplicaBeingWritten)replicaInfo; checksum = rbw.getLastChecksumAndDataLen().getChecksum(); } return new ReplicaBuilder(ReplicaState.FINALIZED) .setBlock(replicaInfo) .setFsVolume(this) .setDirectoryToUse(dest.getParentFile()) .setLastPartialChunkChecksum(checksum) .build(); }
long end = chunkChecksum != null ? chunkChecksum.getDataLength() : replica.getBytesOnDisk(); if (startOffset < 0 || startOffset > end
@Override public ChunkChecksum getLastChecksumAndDataLen() { return new ChunkChecksum(oStream.getLength(), null); } }
byte[] updatedChecksum = lastChunkChecksum.getChecksum(); if (updatedChecksum != null) { System.arraycopy(updatedChecksum, 0, buf, start, checksumSize);
long end = chunkChecksum != null ? chunkChecksum.getDataLength() : replica.getBytesOnDisk(); if (startOffset < 0 || startOffset > end
@Override // ReplicaInPipelineInterface public synchronized ChunkChecksum getLastChecksumAndDataLen() { return new ChunkChecksum(getBytesOnDisk(), lastChecksum); }
byte[] updatedChecksum = lastChunkChecksum.getChecksum(); if (updatedChecksum != null) { System.arraycopy(updatedChecksum, 0, buf, start, checksumSize);
@Override public ChunkChecksum getLastChecksumAndDataLen() { return new ChunkChecksum(0, null); }
@Override // ReplicaInPipelineInterface public synchronized ChunkChecksum getLastChecksumAndDataLen() { return new ChunkChecksum(getBytesOnDisk(), lastChecksum); }
@Override public ChunkChecksum getLastChecksumAndDataLen() { return new ChunkChecksum(oStream.getLength(), null); }
@Override public ChunkChecksum getLastChecksumAndDataLen() { return new ChunkChecksum(oStream.getLength(), null); }
/** * gets the last chunk checksum and the length of the block corresponding * to that checksum. * Note, need to be called with the FsDataset lock acquired. May improve to * lock only the FsVolume in the future. * @throws IOException */ public ChunkChecksum getLastChecksumAndDataLen() throws IOException { ChunkChecksum chunkChecksum = null; try { byte[] lastChecksum = getVolume().loadLastPartialChunkChecksum( getBlockFile(), getMetaFile()); if (lastChecksum != null) { chunkChecksum = new ChunkChecksum(getVisibleLength(), lastChecksum); } } catch (FileNotFoundException e) { // meta file is lost. Try to continue anyway. DataNode.LOG.warn("meta file " + getMetaFile() + " is missing!"); } catch (IOException ioe) { DataNode.LOG.warn("Unable to read checksum from meta file " + getMetaFile(), ioe); } return chunkChecksum; } }
/** * gets the last chunk checksum and the length of the block corresponding * to that checksum. * Note, need to be called with the FsDataset lock acquired. May improve to * lock only the FsVolume in the future. * @throws IOException */ public ChunkChecksum getLastChecksumAndDataLen() throws IOException { ChunkChecksum chunkChecksum = null; try { byte[] lastChecksum = getVolume().loadLastPartialChunkChecksum( getBlockFile(), getMetaFile()); if (lastChecksum != null) { chunkChecksum = new ChunkChecksum(getVisibleLength(), lastChecksum); } } catch (FileNotFoundException e) { // meta file is lost. Try to continue anyway. DataNode.LOG.warn("meta file " + getMetaFile() + " is missing!"); } catch (IOException ioe) { DataNode.LOG.warn("Unable to read checksum from meta file " + getMetaFile(), ioe); } return chunkChecksum; } }