@Override public short getPollingPriorityNormal() { return target.getPollingPriorityNormal(); }
@Override public short getPollingPriorityProgress() { return target.getPollingPriorityProgress(); }
@Override public void run() { callback.onFoundEdition(number, usk, // non-persistent context, false, (short)-1, null, true, newSlotToo); } }, "USKManager callback executor for " +callback);
@Test public void callbackForNormalUskUsesDifferentPriorities() { Callback callback = mock(Callback.class); FreenetURI soneUri = createRandom(randomSource, "test-0").getURI().uskForSSK(); freenetInterface.registerUsk(soneUri, callback); assertThat(callbackCaptor.getValue().getPollingPriorityNormal(), is(PREFETCH_PRIORITY_CLASS)); assertThat(callbackCaptor.getValue().getPollingPriorityProgress(), is(INTERACTIVE_PRIORITY_CLASS)); }
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 void run() { callback.onFoundEdition(number, usk, // non-persistent context, false, (short)-1, null, false, false); } }, "USKManager callback executor for " +callback);
@Override public void onFoundEdition(long l, USK key, ClientContext context, boolean metadata, short codec, byte[] data, boolean newKnownGood, boolean newSlotToo) { synchronized(this) { if(l < lastEdition) { if(!roundFinished) return; if(!newKnownGood) return; } else if(l == lastEdition) { if(newKnownGood) lastWasKnownGoodToo = true; } else { lastEdition = l; lastMetadata = metadata; lastCodec = codec; lastData = data; lastWasKnownGoodToo = newKnownGood; } if(!roundFinished) return; } target.onFoundEdition(l, key, context, metadata, codec, data, newKnownGood, newSlotToo); }
private void innerRoundFinished(ClientContext context, boolean finishedRound) { long ed; boolean meta; short codec; byte[] data; boolean wasKnownGood; synchronized(this) { if(finishedRound) roundFinished = true; if(lastSent == lastEdition) return; lastSent = ed = lastEdition; meta = lastMetadata; codec = lastCodec; data = lastData; wasKnownGood = lastWasKnownGoodToo; } if(ed == -1) { ed = context.uskManager.lookupLatestSlot(key); if(ed == -1) return; meta = false; codec = -1; data = null; wasKnownGood = false; } if(ed == -1) return; target.onFoundEdition(ed, key, context, meta, codec, data, wasKnownGood, wasKnownGood); }
@Test public void callbackForNormalUskForwardsImportantParameters() throws MalformedURLException { Callback callback = mock(Callback.class); FreenetURI uri = createRandom(randomSource, "test-0").getURI().uskForSSK(); freenetInterface.registerUsk(uri, callback); USK key = mock(USK.class); when(key.getURI()).thenReturn(uri); callbackCaptor.getValue().onFoundEdition(3, key, null, false, (short) 0, null, true, true); verify(callback).editionFound(eq(uri), eq(3L), eq(true), eq(true)); }
cb.onFoundEdition(goodEd, origUSK.copy(curEd), context, false, (short)-1, null, true, curEd > ed); else if(curEd > ed) cb.onFoundEdition(curEd, origUSK.copy(curEd), context, false, (short)-1, null, false, false); final USKFetcher fetcher = sched; if(fetcher != null) {