public void clearCooldown() { synchronized(cooldownLock) { noBlocksToSend = false; } this.callback.clearCooldown(); }
@Override public boolean run(ClientContext context) { synchronized(cooldownLock) { noBlocksToSend = false; } callback.encodingProgress(); if(maybeFail()) return true; if(allFinishedCrossEncoding()) { onCompletedCrossSegmentEncode(); } return false; }
/** Called when we have keys for every block. */ private void onHasKeys() { callback.onHasKeys(); }
status = Status.SUCCEEDED; callback.onSucceeded(metadata); } catch (IOException e) { InsertException e1 = new InsertException(InsertExceptionMode.BUCKET_ERROR); status = Status.FAILED; callback.onFailed(e1); } catch (MissingKeyException e) { status = Status.FAILED; callback.onFailed(e1);
private void startCrossSegmentEncode() { short prio = callback.getPriorityClass(); // Start cross-segment encode. for (SplitFileInserterCrossSegmentStorage segment : crossSegments) segment.startEncode(prio); }
@Override public boolean run(ClientContext context) { // Tell the segments to cancel. boolean allDone = true; for(SplitFileInserterSegmentStorage segment : segments) { if(!segment.cancel()) allDone = false; } if(crossSegments != null) { for(SplitFileInserterCrossSegmentStorage segment : crossSegments) { if(!segment.cancel()) allDone = false; } } if(allDone) { synchronized(this) { // Could have beaten us to it in callback. if(hasFinished()) return false; status = Status.FAILED; } callback.onFailed(e); return true; } else { // Wait for them to finish encoding. return false; } }
private void onCompletedSegmentEncode() { synchronized (this) { if(status == Status.ENCODED) return; // Race condition. if (!(status == Status.ENCODED_CROSS_SEGMENTS || (crossSegments == null && status == Status.STARTED))) { Logger.error(this, "Wrong state " + status+" for "+this, new Exception("error")); return; } status = Status.ENCODED; } callback.onFinishedEncode(); }
/** Called when a block insert succeeds */ public void onInsertedBlock(int blockNo, ClientCHK key) { try { if(parent.hasFinished()) return; this.setKey(blockNo, key); if(blockChooser.onSuccess(blockNo)) parent.callback.onInsertedBlock(); lazyWriteMetadata(); } catch (IOException e) { if(parent.hasFinished()) return; // Race condition possible as this is a callback parent.failOnDiskError(e); } }
private void startSegmentEncode() { short prio = callback.getPriorityClass(); for (SplitFileInserterSegmentStorage segment : segments) segment.startEncode(prio); }
private boolean maybeFail() { // Might have failed. // Have to check segments before checking for failure because of race conditions. if(allSegmentsCompletedOrFailed()) { InsertException e = null; synchronized(this) { if(failing == null) return false; e = failing; if(hasFinished()) { if(logMINOR) Logger.minor(this, "Maybe fail returning true because already finished"); return true; } status = Status.FAILED; } if(logMINOR) Logger.minor(this, "Maybe fail returning true with error "+e); callback.onFailed(e); return true; } else { return false; } }
@Override public boolean run(ClientContext context) { synchronized(cooldownLock) { noBlocksToSend = false; } completed.storeStatus(true); callback.encodingProgress(); if(maybeFail()) return true; if(allFinishedEncoding()) { onCompletedSegmentEncode(); } return false; }