public class USKFetcher extends java.lang.Object implements ClientGetState, USKCallback, HasKeyListener, KeyListener
Modifier and Type | Method and Description |
---|---|
boolean |
addCallback(USKFetcherCallback cb)
Callbacks are told when the USKFetcher finishes, and unless background poll is
enabled, they are only sent onFoundEdition *once*, on completion.
|
void |
addHintEdition(long suggestedEdition) |
void |
addSubscriber(USKCallback cb,
long hint)
Add a subscriber.
|
void |
cancel(ClientContext context)
Cancel the request, and call onFailure() on the callback in order to tell
downstream (ultimately the client) that cancel has succeeded, and to allow
it to call removeFrom() to avoid a database leak.
|
void |
changeUSKPollParameters(long time,
int tries,
ClientContext context)
FIXME this is a special case hack
For a generic solution see https://bugs.freenetproject.org/view.php?id=4984
|
long |
countKeys() |
short |
definitelyWantKey(Key key,
byte[] saltedKey,
ClientContext context)
Do we want the key? This is called by the ULPR code, because fetching the
key will involve significant work.
|
HasKeyListener |
getHasKeyListener() |
USK |
getOriginalUSK() |
short |
getPollingPriorityNormal()
Priority at which the polling should run normally.
|
short |
getPollingPriorityProgress()
Priority at which the polling should run when starting, or immediately after making some progress.
|
short |
getPriorityClass()
Priority of the associated request.
|
SendableGet[] |
getRequestsForKey(Key key,
byte[] saltedKey,
ClientContext context)
Find the requests related to a specific key, used in retrying after cooldown.
|
long |
getToken()
Get a long value which may be passed around to identify this request (e.g.
|
FreenetURI |
getURI() |
boolean |
handleBlock(Key key,
byte[] saltedKey,
KeyBlock found,
ClientContext context)
Handle the found data, if we really want it.
|
boolean |
hasCallbacks() |
boolean |
hasSubscribers() |
boolean |
isCancelled()
Is it cancelled?
|
boolean |
isEmpty()
Has the request finished? If every key has been found, or enough keys have
been found, return true so that the caller can remove it from the list.
|
boolean |
isFinished() |
boolean |
isSSK() |
KeyListener |
makeKeyListener(ClientContext context,
boolean onStartup)
Create a KeyListener, a transient object used to determine which keys we
want, and to handle any blocks found.
|
void |
onCheckEnteredFiniteCooldown(ClientContext context) |
void |
onDBRsFinished(ClientContext context) |
void |
onFail(freenet.client.async.USKFetcher.USKAttempt attempt,
ClientContext context) |
void |
onFoundEdition(long ed,
USK key,
ClientContext context,
boolean metadata,
short codec,
byte[] data,
boolean newKnownGood,
boolean newSlotToo)
Found the latest edition.
|
void |
onRemove()
Deactivate the request once it has been removed.
|
void |
onResume(ClientContext context)
Called on restarting the node for a persistent request.
|
void |
onShutdown(ClientContext context)
Called just before the final write of client.dat before the node shuts down.
|
boolean |
persistent()
Is this related to a persistent request?
|
boolean |
probablyWantKey(Key key,
byte[] saltedKey)
Fast guess at whether we want a key or not.
|
void |
processDBRHint(long hint,
ClientContext context,
freenet.client.async.USKFetcher.DBRAttempt dbrAttempt) |
void |
removeCallback(USKCallback cb) |
void |
removeSubscriber(USKCallback cb,
ClientContext context) |
void |
schedule(ClientContext context)
Schedule the request on the ClientRequestScheduler.
|
void |
schedule(long delay,
ClientContext context) |
public boolean addCallback(USKFetcherCallback cb)
cb
- public void onDBRsFinished(ClientContext context)
public void processDBRHint(long hint, ClientContext context, freenet.client.async.USKFetcher.DBRAttempt dbrAttempt)
public void onCheckEnteredFiniteCooldown(ClientContext context)
public void onFail(freenet.client.async.USKFetcher.USKAttempt attempt, ClientContext context)
public FreenetURI getURI()
public boolean isFinished()
public USK getOriginalUSK()
public void schedule(long delay, ClientContext context)
public void schedule(ClientContext context)
ClientGetState
schedule
in interface ClientGetState
public void cancel(ClientContext context)
ClientGetState
cancel
in interface ClientGetState
public void addSubscriber(USKCallback cb, long hint)
cb
- public boolean hasSubscribers()
public boolean hasCallbacks()
public void removeSubscriber(USKCallback cb, ClientContext context)
public void removeCallback(USKCallback cb)
public long getToken()
ClientGetState
getToken
in interface ClientGetState
public short getPollingPriorityNormal()
USKCallback
getPollingPriorityNormal
in interface USKCallback
public short getPollingPriorityProgress()
USKCallback
getPollingPriorityProgress
in interface USKCallback
public void onFoundEdition(long ed, USK key, ClientContext context, boolean metadata, short codec, byte[] data, boolean newKnownGood, boolean newSlotToo)
USKCallback
onFoundEdition
in interface USKCallback
ed
- The edition number.key
- A copy of the key with new edition setnewKnownGood
- If the highest known good edition (which has actually been
fetched with what it pointed to) has increased. Otherwise, the highest known
SSK slot has been increased, from which searches will start, but we do not
know whether it can actually be fetched successfully.newSlotToo
- If newKnownGood is set, this indicates whether it is also a
new highest known SSK slot. If newKnownGood is not set, there is always a new
highest known SSK slot.public boolean isCancelled()
HasKeyListener
isCancelled
in interface HasKeyListener
public KeyListener makeKeyListener(ClientContext context, boolean onStartup)
HasKeyListener
makeKeyListener
in interface HasKeyListener
public long countKeys()
countKeys
in interface KeyListener
public short definitelyWantKey(Key key, byte[] saltedKey, ClientContext context)
KeyListener
definitelyWantKey
in interface KeyListener
public HasKeyListener getHasKeyListener()
getHasKeyListener
in interface KeyListener
public short getPriorityClass()
KeyListener
getPriorityClass
in interface KeyListener
public SendableGet[] getRequestsForKey(Key key, byte[] saltedKey, ClientContext context)
KeyListener
getRequestsForKey
in interface KeyListener
public boolean handleBlock(Key key, byte[] saltedKey, KeyBlock found, ClientContext context)
KeyListener
handleBlock
in interface KeyListener
public boolean isEmpty()
KeyListener
isEmpty
in interface KeyListener
public boolean isSSK()
isSSK
in interface KeyListener
public void onRemove()
KeyListener
onRemove
in interface KeyListener
public boolean persistent()
KeyListener
persistent
in interface KeyListener
public boolean probablyWantKey(Key key, byte[] saltedKey)
KeyListener
probablyWantKey
in interface KeyListener
public void changeUSKPollParameters(long time, int tries, ClientContext context)
public void addHintEdition(long suggestedEdition)
public void onResume(ClientContext context)
ClientGetState
onResume
in interface ClientGetState
public void onShutdown(ClientContext context)
ClientGetState
onShutdown
in interface ClientGetState