long decodingTime = 0;
if (crc != null) {
crc.reset();
}
int blockIdx = (int) (errorOffset/blockSize);
LocationPair lp = null;
int erasedLocationToFix;
if (recoverFromStripeStore) {
erasedLocationToFix = si.getBlockIdxInStripe(lostBlock);
} else if (fixSource) {
lp = StripeReader.getBlockLocation(codec, srcFs,
srcFile, blockIdx, conf);
erasedLocationToFix = codec.parityLength + lp.getBlockIdxInStripe();
} else {
lp = StripeReader.getParityBlockLocation(codec, blockIdx);
erasedLocationToFix = lp.getBlockIdxInStripe();
}
FileStatus srcStat = srcFs.getFileStatus(srcFile);
FileStatus parityStat = null;
if (!recoverFromStripeStore) {
parityStat = parityFs.getFileStatus(parityFile);
}
InputStream[] inputs = null;
List<Integer> erasedLocations = new ArrayList<Integer>();
// Start off with one erased location.
erasedLocations.add(erasedLocationToFix);
Set<Integer> locationsToNotRead = new HashSet<Integer>();
int boundedBufferCapacity = 2;
ParallelStreamReader parallelReader = null;
LOG.info("Need to write " + limit +
" bytes for erased location index " + erasedLocationToFix);
long startOffsetInBlock = 0;
if (partial) {
startOffsetInBlock = errorOffset % blockSize;
}
try {
int[] locationsToFix = new int[codec.parityLength];
numReadBytes = 0;
numReadBytesRemoteRack = 0;
remoteRackFlag = new boolean[codec.parityLength + codec.stripeLength];
for (int id = 0 ; id < codec.parityLength + codec.stripeLength ; id++) {
remoteRackFlag[id] = false;
}
boolean stripeVerified = (si == null);
long written;
// Loop while the number of written bytes is less than the max.
for (written = 0; written < limit; ) {
try {
if (parallelReader == null) {
long offsetInBlock = written + startOffsetInBlock;
if (recoverFromStripeStore) {
inputs = StripeReader.buildInputsFromStripeInfo((DistributedFileSystem)srcFs,
srcStat, codec, si, offsetInBlock,
limit, erasedLocations, locationsToNotRead, code);
} else {
StripeReader sReader = StripeReader.getStripeReader(codec,
conf, blockSize, srcFs, lp.getStripeIdx(), srcStat);
inputs = sReader.buildInputs(srcFs, srcFile,
srcStat, parityFs, parityFile, parityStat,
lp.getStripeIdx(), offsetInBlock, erasedLocations,
locationsToNotRead, code);
}
int i = 0;
for (int location : locationsToNotRead) {
locationsToFix[i] = location;