/** * Look up the latest known working version of the given USK. * @return The latest known edition number, or -1. */ public synchronized long lookupKnownGood(USK usk) { Long l = latestKnownGoodByClearUSK.get(usk.clearCopy()); if(l != null) return l.longValue(); else return -1; }
/** * Look up the latest SSK slot, whether the data it links to has been successfully * fetched or not, of the given USK. * @return The latest known edition number, or -1. */ public synchronized long lookupLatestSlot(USK usk) { Long l = latestSlotByClearUSK.get(usk.clearCopy()); if(l != null) return l.longValue(); else return -1; }
public void onFinished(USKFetcher fetcher, boolean ignoreError) { USK orig = fetcher.getOriginalUSK(); USK clear = orig.clearCopy(); synchronized(this) { if(backgroundFetchersByClearUSK.get(clear) == fetcher) { backgroundFetchersByClearUSK.remove(clear); if(!ignoreError) { // This shouldn't happen, it's a sanity check: the only way we get cancelled is from USKManager, which removes us before calling cancel(). Logger.error(this, "onCancelled for "+fetcher+" - was still registered, how did this happen??", new Exception("debug")); } } if(temporaryBackgroundFetchersLRU.get(clear) == fetcher) { temporaryBackgroundFetchersLRU.removeKey(clear); temporaryBackgroundFetchersPrefetch.remove(clear); } } }
void updateSlot(final USK origUSK, final long number, final ClientContext context) { if(logMINOR) Logger.minor(this, "Updating (slot) "+origUSK.getURI()+" : "+number); USK clear = origUSK.clearCopy(); final USKCallback[] callbacks; synchronized(this) {
public void unsubscribe(USK origUSK, USKCallback cb) { USKFetcher toCancel = null; synchronized(this) { USK clear = origUSK.clearCopy(); USKCallback[] callbacks = subscribersByClearUSK.get(clear); if(callbacks == null){ // maybe we should throw something ? shall we allow multiple unsubscriptions ?
void updateKnownGood(final USK origUSK, final long number, final ClientContext context) { if(logMINOR) Logger.minor(this, "Updating (known good) "+origUSK.getURI()+" : "+number); USK clear = origUSK.clearCopy(); final USKCallback[] callbacks; boolean newSlot = false;
goodEd = lookupKnownGood(origUSK); synchronized(this) { USK clear = origUSK.clearCopy(); USKCallback[] callbacks = subscribersByClearUSK.get(clear); if(callbacks == null) {
public void startTemporaryBackgroundFetcher(USK usk, ClientContext context, final FetchContext fctx, boolean prefetchContent, boolean realTimeFlag) { final USK clear = usk.clearCopy(); USKFetcher sched = null; ArrayList<USKFetcher> toCancel = null; while(temporaryBackgroundFetchersLRU.size() > NodeClientCore.getMaxBackgroundUSKFetchers()) { USKFetcher fetcher = temporaryBackgroundFetchersLRU.popValue(); temporaryBackgroundFetchersPrefetch.remove(fetcher.getOriginalUSK().clearCopy()); if(!fetcher.hasSubscribers()) { if(toCancel == null) toCancel = new ArrayList<USKFetcher>(2);