public class USKRetriever extends BaseClientGetter implements USKCallback
blockSetFinalized, cancelled, client, creationTime, failedBlocks, fatallyFailedBlocks, latestFailure, latestSuccess, minSuccessBlocks, priorityClass, realTimeFlag, sentToNetwork, successfulBlocks, totalBlocks
Constructor and Description |
---|
USKRetriever(FetchContext fctx,
short prio,
RequestClient client,
USKRetrieverCallback cb,
USK origUSK) |
Modifier and Type | Method and Description |
---|---|
void |
cancel(ClientContext context)
Cancel the request.
|
void |
changeUSKPollParameters(long time,
int tries,
ClientContext context)
Only works if setFetcher() has been called, i.e.
|
protected ClientBaseCallback |
getCallback() |
USK |
getOriginalUSK()
Get the original USK URI which was passed when creating the retriever - not the latest known URI!
|
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.
|
FreenetURI |
getURI()
Get the original USK URI which was passed when creating the retriever - not the latest known URI!
|
protected void |
innerNotifyClients(ClientContext context)
Notify clients, usually via a SplitfileProgressEvent, of the current progress.
|
void |
innerOnResume(ClientContext context)
Called by onResume() once and only once after restarting.
|
protected void |
innerToNetwork(ClientContext context)
Notify clients that a request has gone to the network, for the first time, i.e.
|
boolean |
isFinished()
Is the request or insert completed (succeeded, failed, or
cancelled, which is a kind of failure)?
|
void |
onBlockSetFinished(ClientGetState state,
ClientContext context)
Called when the ClientGetState knows that it knows about
all the blocks it will need to fetch.
|
void |
onExpectedMIME(ClientMetadata meta,
ClientContext context)
Called when we know the MIME type of the final data.
|
void |
onExpectedSize(long size,
ClientContext context)
Called when we know the size of the final data.
|
void |
onExpectedTopSize(long size,
long compressed,
int blocksReq,
int blocksTotal,
ClientContext context)
Called when we know the size of the final file, and the number of blocks needed etc.
|
void |
onFailure(FetchException e,
ClientGetState state,
ClientContext context) |
void |
onFinalizedMetadata() |
void |
onFoundEdition(long l,
USK key,
ClientContext context,
boolean metadata,
short codec,
byte[] data,
boolean newKnownGood,
boolean newSlotToo)
Found the latest edition.
|
void |
onHashes(HashResult[] hashes,
ClientContext context)
Called when we know the HashResult of the final file.
|
void |
onSplitfileCompatibilityMode(InsertContext.CompatibilityMode min,
InsertContext.CompatibilityMode max,
byte[] splitfileKey,
boolean compressed,
boolean bottomLayer,
boolean definitiveAnyway,
ClientContext context)
Called when we know the settings for the splitfile.
|
void |
onSuccess(StreamGenerator streamGenerator,
ClientMetadata clientMetadata,
java.util.List<? extends Compressor> decompressors,
ClientGetState state,
ClientContext context) |
void |
onTransition(ClientGetState oldState,
ClientGetState newState,
ClientContext context)
Called when the ClientGetState handling the request yields control to another
ClientGetState.
|
void |
unsubscribe(USKManager manager) |
addBlock, addBlocks, addMustSucceedBlocks, addRedundantBlocksInsert, blockSetFinalized, cancel, clearCountersOnRestart, completedBlock, failedBlock, failedBlock, fatallyFailedBlock, getAll, getClient, getClientDetail, getClientDetail, getLatestFailure, getLatestSuccess, getPriorityClass, getSchedulerGroup, getTotalBlocks, hashCode, isCancelled, isCurrentState, notifyClients, onResume, onShutdown, persistent, realTimeFlag, resetBlocks, setPriorityClass, toNetwork
public USKRetriever(FetchContext fctx, short prio, RequestClient client, USKRetrieverCallback cb, USK origUSK)
public void onFoundEdition(long l, USK key, ClientContext context, boolean metadata, short codec, byte[] data, boolean newKnownGood, boolean newSlotToo)
USKCallback
onFoundEdition
in interface USKCallback
l
- 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 void onSuccess(StreamGenerator streamGenerator, ClientMetadata clientMetadata, java.util.List<? extends Compressor> decompressors, ClientGetState state, ClientContext context)
onSuccess
in interface GetCompletionCallback
public void onFailure(FetchException e, ClientGetState state, ClientContext context)
onFailure
in interface GetCompletionCallback
public void onBlockSetFinished(ClientGetState state, ClientContext context)
GetCompletionCallback
onBlockSetFinished
in interface GetCompletionCallback
public USK getOriginalUSK()
public FreenetURI getURI()
getURI
in class ClientRequester
public boolean isFinished()
ClientRequester
isFinished
in class ClientRequester
protected void innerNotifyClients(ClientContext context)
ClientRequester
innerNotifyClients
in class ClientRequester
public void onTransition(ClientGetState oldState, ClientGetState newState, ClientContext context)
GetCompletionCallback
onTransition
in interface GetCompletionCallback
onTransition
in class ClientRequester
oldState
- The old ClientGetState.newState
- The new ClientGetState.context
- The database handle. Must not be used by other threads.public void onExpectedMIME(ClientMetadata meta, ClientContext context)
GetCompletionCallback
onExpectedMIME
in interface GetCompletionCallback
meta
- The MIME type, possibly including parameters, as a String.
E.g. "text/html; charset=ISO-8859-1".context
- Utility object containing helpers, mostly not persistent, such as the Ticker, temporary storage factories etc.public void onExpectedSize(long size, ClientContext context)
GetCompletionCallback
onExpectedSize
in interface GetCompletionCallback
size
- The expected size of the final data.context
- Utility object containing helpers, mostly not persistent, such as the Ticker, temporary storage factories etc.public void onFinalizedMetadata()
onFinalizedMetadata
in interface GetCompletionCallback
public short getPollingPriorityNormal()
USKCallback
getPollingPriorityNormal
in interface USKCallback
public short getPollingPriorityProgress()
USKCallback
getPollingPriorityProgress
in interface USKCallback
public void cancel(ClientContext context)
ClientRequester
cancel
in class ClientRequester
context
- The ClientContext object including essential but
non-persistent objects such as the schedulers.protected void innerToNetwork(ClientContext context)
ClientRequester
innerToNetwork
in class ClientRequester
public void onExpectedTopSize(long size, long compressed, int blocksReq, int blocksTotal, ClientContext context)
GetCompletionCallback
onExpectedTopSize
in interface GetCompletionCallback
size
- The final size of the data.compressed
- The size of the data after compression / before decompression.blocksReq
- The number of blocks needed to decode the file.blocksTotal
- The total number of blocks available.context
- Utility object containing helpers, mostly not persistent, such as the Ticker, temporary storage factories etc.public void onSplitfileCompatibilityMode(InsertContext.CompatibilityMode min, InsertContext.CompatibilityMode max, byte[] splitfileKey, boolean compressed, boolean bottomLayer, boolean definitiveAnyway, ClientContext context)
GetCompletionCallback
onSplitfileCompatibilityMode
in interface GetCompletionCallback
min
- The lowest CompatibilityMode that appears to be valid based on what we've fetched so far.max
- The highest CompatibilityMode that appears to be valid based on what we've fetched so far.splitfileKey
- The fixed byte[] encryption key used on insert. On anything recent, we generate a single key, randomly for an SSK,
or based on the content for a CHK, and use it for everything. This saves metadata space and improves security for SSKs.compressed
- Whether the content is compressed. If false, the dontCompress option was used.bottomLayer
- Whether this report originates at the bottom layer of the splitfile pyramid. I.e. the actual file, not the file containing
the metadata to fetch the file (this can recurse for several levels!)definitiveAnyway
- Whether this report is definitive even though it's not from the bottom layer. This is true of recent splitfiles,
where we store all the data in the top key.context
- Utility object containing helpers, mostly not persistent, such as the Ticker, temporary storage factories etc.public void onHashes(HashResult[] hashes, ClientContext context)
GetCompletionCallback
onHashes
in interface GetCompletionCallback
hashes
- A set of hashes for the final file content.context
- Utility object containing helpers, mostly not persistent, such as the Ticker, temporary storage factories etc.public void unsubscribe(USKManager manager)
public void changeUSKPollParameters(long time, int tries, ClientContext context)
time
- The new cooldown time. At least 30 minutes or we throw.tries
- The new number of tries after each cooldown. Greater than 0
and less than 3 or we throw.public void innerOnResume(ClientContext context)
ClientRequester
innerOnResume
in class ClientRequester
protected ClientBaseCallback getCallback()
getCallback
in class ClientRequester