@Override public void clearCooldown() { if(hasFinished()) return; getter.clearWakeupTime(context); }
@Override public void onFetchedBlock() { boolean dontNotify = true; if(getter.hasQueued()) { dontNotify = false; } else { synchronized(this) { if(storeFetchCounter++ == STORE_NOTIFY_BLOCKS) { storeFetchCounter = 0; dontNotify = false; lastNotifiedStoreFetch = System.currentTimeMillis(); } else { long now = System.currentTimeMillis(); if(now - lastNotifiedStoreFetch >= STORE_NOTIFY_INTERVAL) { dontNotify = false; lastNotifiedStoreFetch = now; } } } } parent.completedBlock(dontNotify, context); }
@Override public void reduceCooldown(long wakeupTime) { getter.reduceWakeupTime(wakeupTime, context); }
@Override public void restartedAfterDataCorruption() { if(hasFinished()) return; Logger.error(this, "Restarting download "+this+" after data corruption"); // We need to fetch more blocks. Some of them may even be in the datastore. getter.unregister(context, getPriorityClass()); getter.schedule(context, false); context.jobRunner.setCheckpointASAP(); }
lastNotifiedStoreFetch = System.currentTimeMillis(); getter = new SplitFileFetcherGet(this, storage); if (storage.start(resumed)) { getter.schedule(context, storage.hasCheckedStore());
public void fail(FetchException e) { synchronized(this) { if(succeeded || failed) return; failed = true; } if(storage != null) context.getChkFetchScheduler(realTimeFlag).removePendingKeys(storage.keyListener, true); if(getter != null) getter.cancel(context); if(storage != null) storage.cancel(); cb.onFailure(e, this, context); }
@Override public void schedule(ClientContext context) { if(storage.start(false)) getter.schedule(context, false); }
public void cancel(ClientContext context) { unregister(context, parent.getPriorityClass()); }
@Override public void onFailure(LowLevelGetException e, SendableRequestItem token, ClientContext context) { FetchException fe = translateException(e); if(fe.isDefinitelyFatal()) { // If the error is definitely-fatal it means there is either a serious local problem // or the inserted data was corrupt. So we fail the entire splitfile immediately. // We don't track which blocks have fatally failed. if(logMINOR) Logger.minor(this, "Fatal failure: "+fe+" for "+token); parent.fail(fe); } else { MyKey key = (MyKey) token; if(key.get != storage) throw new IllegalArgumentException(); storage.onFailure(key, fe); } }
if(eventualLength > 0 && fetchContext.maxOutputLength > 0 && eventualLength > fetchContext.maxOutputLength) throw new FetchException(FetchExceptionMode.TOO_BIG, eventualLength, true, clientMetadata.getMIMEType()); getter = new SplitFileFetcherGet(this, storage); raf = storage.getRAF(); if(logMINOR)
getter.cancel(context); if(this.callbackCompleteViaTruncation != null) { long finalLength = storage.finalLength;