private USKFetcherTag(USK origUSK, USKFetcherCallback callback, boolean persistent, boolean realTime, FetchContext ctx, boolean keepLastData, long token, boolean hasOwnFetchContext, boolean checkStoreOnly) { this.callback = callback; this.origUSK = origUSK; this.edition = origUSK.suggestedEdition; this.persistent = persistent; this.ctx = ctx; this.keepLastData = keepLastData; this.token = token; this.ownFetchContext = hasOwnFetchContext; this.realTimeFlag = realTime; pollingPriorityNormal = callback.getPollingPriorityNormal(); pollingPriorityProgress = callback.getPollingPriorityProgress(); priority = pollingPriorityNormal; this.checkStoreOnly = checkStoreOnly; this.hashCode = super.hashCode(); if(logMINOR) Logger.minor(this, "Created tag for "+origUSK+" and "+callback+" : "+this); }
private void finishCancelled(ClientContext context) { USKFetcherCallback[] cb; synchronized(this) { completed = true; cb = callbacks.toArray(new USKFetcherCallback[callbacks.size()]); } for(USKFetcherCallback c: cb) c.onCancelled(context); }
@Override public boolean run(ClientContext context) { if(callback instanceof USKFetcherTagCallback) ((USKFetcherTagCallback)callback).setTag(USKFetcherTag.this, context); callback.onFailure(context); return true; }
try { if(ed == -1) c.onFailure(context); else c.onFoundEdition(ed, origUSK.copy(ed), context, lastWasMetadata, lastCompressionCodec, data, false, false); } catch (Exception e) { Logger.error(this, "An exception occured while dealing with a callback:"+c.toString()+"\n"+e.getMessage(),e);
@Override public boolean run(ClientContext context) { if(callback instanceof USKFetcherTagCallback) ((USKFetcherTagCallback)callback).setTag(USKFetcherTag.this, context); callback.onFoundEdition(l, key, context, metadata, codec, data, newKnownGood, newSlotToo); return false; }
if(callback instanceof USKFetcherTagCallback) ((USKFetcherTagCallback)callback).setTag(USKFetcherTag.this, context); callback.onFoundEdition(l, key, context, metadata, codec, data, newKnownGood, newSlotToo);
short prio = cb.getPollingPriorityNormal(); if(logDEBUG) Logger.debug(this, "Normal priority for "+cb+" : "+prio); if(prio < normalPrio) normalPrio = prio; if(logDEBUG) Logger.debug(this, "Progress priority for "+cb+" : "+prio); prio = cb.getPollingPriorityProgress(); if(prio < progressPrio) progressPrio = prio;
@Override public boolean run(ClientContext context) { if(callback instanceof USKFetcherTagCallback) ((USKFetcherTagCallback)callback).setTag(USKFetcherTag.this, context); callback.onCancelled(context); return false; }
if(callback instanceof USKFetcherTagCallback) ((USKFetcherTagCallback)callback).setTag(USKFetcherTag.this, context); callback.onFailure(context);
@Override public void onCancelled(ClientContext context) { if(logMINOR) Logger.minor(this, "Cancelled on "+this); synchronized(this) { finished = true; } if(persistent) { // This can be called from USKFetcher, in which case we want to run on the // PersistentJobRunner. try { context.jobRunner.queue(new PersistentJob() { @Override public boolean run(ClientContext context) { if(callback instanceof USKFetcherTagCallback) ((USKFetcherTagCallback)callback).setTag(USKFetcherTag.this, context); callback.onCancelled(context); return false; } }, NativeThread.HIGH_PRIORITY); } catch (PersistenceDisabledException e) { // Impossible. } } else { if(callback instanceof USKFetcherTagCallback) ((USKFetcherTagCallback)callback).setTag(USKFetcherTag.this, context); callback.onCancelled(context); } }