private void queueHeal(byte[][] dataBlocks, byte[][] checkBlocks, boolean[] dataBlocksPresent, boolean[] checkBlocksPresent) throws IOException { for(int i=0;i<dataBlocks.length;i++) { if(dataBlocksPresent[i]) continue; if(blockChooser.getRetries(i) == 0) continue; queueHeal(i, dataBlocks[i]); } for(int i=0;i<checkBlocks.length;i++) { if(checkBlocksPresent[i]) continue; if(blockChooser.getRetries(i+dataBlocks.length) == 0) continue; queueHeal(i+dataBlocks.length, checkBlocks[i]); } }
/** Pick a key to fetch. Must not update any persistent field. (Cooldowns etc are fine) */ public int chooseRandomKey() { int chosen; synchronized(this) { if(finished) return -1; if(failedRetries) return -1; if(tryDecode) { if(logMINOR) Logger.minor(this, "Segment decoding so not choosing a key on "+this); return -1; } if(corruptMetadata) return -1; // Will be fetchable after we've found out what blocks we actually have. chosen = blockChooser.chooseKey(); if(chosen != -1) { if(logMINOR) Logger.minor(this, "Chosen key "+chosen+"/"+totalBlocks()+" for "+this+" (retries "+blockChooser.getRetries(chosen)+"/"+blockChooser.maxRetries+")"); } else { if(logMINOR) Logger.minor(this, "No keys chosen for "+this); } } if(chosen == -1) { long cooldownTime = blockChooser.overallCooldownTime(); if(cooldownTime > System.currentTimeMillis()) parent.increaseCooldown(this, cooldownTime); return -1; } else { return chosen; } }
if(logMINOR) Logger.minor(this, "Block "+blockNumber+" on "+this+" : "+blockChooser.getRetries(blockNumber)+"/"+blockChooser.maxRetries); if(blockChooser.overallCooldownTime() < cooldown) wake = true;