in util/TransferLogManager.cpp [921:966]
ErrorCode LogParser::processBlockWriteEntry(char *buf, int64_t size) {
if (!headerParsed_) {
WLOG(ERROR)
<< "Invalid log: Block write entry found before transfer log header";
return INVALID_LOG;
}
int64_t timestamp, seqId, offset, blockSize;
if (!encoderDecoder_.decodeBlockWriteEntry(buf, size, timestamp, seqId,
offset, blockSize)) {
return INVALID_LOG;
}
if (parseOnly_) {
std::cout << getFormattedTimestamp(timestamp) << " Block written,"
<< " seq-id " << seqId << " offset " << offset << " block-size "
<< blockSize << std::endl;
return OK;
}
if (options_.resume_using_dir_tree) {
WLOG(ERROR) << "Can not have a block write entry in directory based "
"resumption mode "
<< seqId << " " << offset << " " << blockSize;
return INVALID_LOG;
}
if (invalidSeqIds_.find(seqId) != invalidSeqIds_.end()) {
WLOG(INFO) << "Block entry for an invalid sequence-id " << seqId
<< ", ignoring";
return OK;
}
auto it = fileInfoMap_.find(seqId);
if (it == fileInfoMap_.end()) {
WLOG(ERROR) << "Block entry for unknown sequence-id " << seqId << " "
<< offset << " " << blockSize;
return INVALID_LOG;
}
FileChunksInfo &chunksInfo = it->second;
// check whether the block is within disk size
if (offset + blockSize > chunksInfo.getFileSize()) {
WLOG(ERROR) << "Block end point is greater than file size in disk "
<< chunksInfo.getFileName() << " seq-id " << seqId << " offset "
<< offset << " block-size " << blockSize
<< " file size in disk " << chunksInfo.getFileSize();
return INVALID_LOG;
}
chunksInfo.addChunk(Interval(offset, offset + blockSize));
return OK;
}