public class SplitFileFetcher extends java.lang.Object implements ClientGetState, SplitFileFetcherStorageCallback, java.io.Serializable
| Modifier | Constructor and Description |
|---|---|
protected |
SplitFileFetcher() |
|
SplitFileFetcher(ClientGetter getter,
java.io.DataInputStream dis,
ClientContext context) |
|
SplitFileFetcher(Metadata metadata,
GetCompletionCallback rcb,
ClientRequester parent,
FetchContext fetchContext,
boolean realTimeFlag,
java.util.List<Compressor.COMPRESSOR_TYPE> decompressors,
ClientMetadata clientMetadata,
long token,
boolean topDontCompress,
short topCompatibilityMode,
boolean persistent,
FreenetURI thisKey,
boolean isFinalFetch,
ClientContext context) |
| Modifier and Type | Method and Description |
|---|---|
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 |
clearCooldown()
Called when the fetcher may have exited cooldown early.
|
void |
fail(FetchException e)
Called when the fetch failed, e.g.
|
void |
failOnDiskError(ChecksumFailedException e)
Fail the whole splitfile request when we get unrecoverable data corruption, e.g.
|
void |
failOnDiskError(java.io.IOException e)
Fail the whole splitfile request when we get an IOException on writing to or reading from
the on-disk storage.
|
HasKeyListener |
getHasKeyListener()
Can be null.
|
short |
getPriorityClass()
Get the priority class of the request.
|
KeySalter |
getSalter() |
BaseSendableGet |
getSendableGet()
Can be null.
|
long |
getToken()
Get a long value which may be passed around to identify this request (e.g.
|
boolean |
hasFinished() |
boolean |
localRequestOnly() |
void |
maybeAddToBinaryBlob(ClientCHKBlock block)
Called whenever we successfully download, decode or encode a block and it matches the
expected key.
|
void |
onClosed()
Called when the storage layer has finished, the higher level code has finished, and the
storage has been freed, i.e.
|
void |
onFailedBlock()
Called when the splitfile fetcher gives up on a block.
|
void |
onFetchedBlock() |
void |
onResume(ClientContext context)
Called on restarting the node for a persistent request.
|
void |
onResume(int succeededBlocks,
int failedBlocks,
ClientMetadata meta,
long finalSize) |
void |
onShutdown(ClientContext context)
Called just before the final write of client.dat before the node shuts down.
|
void |
onSplitfileCompatibilityMode(InsertContext.CompatibilityMode min,
InsertContext.CompatibilityMode max,
byte[] customSplitfileKey,
boolean compressed,
boolean bottomLayer,
boolean definitiveAnyway)
Called during construction, when we know the settings for the splitfile.
|
void |
onSuccess()
The splitfile download succeeded.
|
void |
queueHeal(byte[] data,
byte[] cryptoKey,
byte cryptoAlgorithm)
Queue a block to be healed.
|
void |
reduceCooldown(long wakeupTime)
Called when the wakeup time reduces but it is still not fetchable.
|
void |
restartedAfterDataCorruption()
Called when we recover from disk corruption, and have to re-download some blocks that we
had already downloaded but which were corrupted on disk.
|
void |
schedule(ClientContext context)
Schedule the request on the ClientRequestScheduler.
|
void |
setSplitfileBlocks(int requiredBlocks,
int remainingBlocks)
Called during construction to tell other layers how many blocks to expect.
|
void |
toNetwork() |
boolean |
wantBinaryBlob()
Do we want maybeAddToBinaryBlob() to be called?? LOCKING: Should not take any locks.
|
boolean |
writeTrivialProgress(java.io.DataOutputStream dos) |
public SplitFileFetcher(Metadata metadata, GetCompletionCallback rcb, ClientRequester parent, FetchContext fetchContext, boolean realTimeFlag, java.util.List<Compressor.COMPRESSOR_TYPE> decompressors, ClientMetadata clientMetadata, long token, boolean topDontCompress, short topCompatibilityMode, boolean persistent, FreenetURI thisKey, boolean isFinalFetch, ClientContext context) throws FetchException, MetadataParseException
FetchExceptionMetadataParseExceptionprotected SplitFileFetcher()
public SplitFileFetcher(ClientGetter getter, java.io.DataInputStream dis, ClientContext context) throws StorageFormatException, ResumeFailedException, java.io.IOException
StorageFormatExceptionResumeFailedExceptionjava.io.IOExceptionpublic void schedule(ClientContext context)
ClientGetStateschedule in interface ClientGetStatepublic void failOnDiskError(java.io.IOException e)
failOnDiskError in interface SplitFileFetcherStorageCallbacke - The IOException, generated when accessing the on-disk storage.public void failOnDiskError(ChecksumFailedException e)
failOnDiskError in interface SplitFileFetcherStorageCallbackpublic void fail(FetchException e)
SplitFileFetcherStorageCallbackfail in interface SplitFileFetcherStorageCallbackpublic void cancel(ClientContext context)
ClientGetStatecancel in interface ClientGetStatepublic long getToken()
ClientGetStategetToken in interface ClientGetStatepublic void onSuccess()
onSuccess in interface SplitFileFetcherStorageCallbackpublic void onClosed()
SplitFileFetcherStorageCallbackonClosed in interface SplitFileFetcherStorageCallbackpublic short getPriorityClass()
SplitFileFetcherStorageCallbackgetPriorityClass in interface SplitFileFetcherStorageCallbackpublic void setSplitfileBlocks(int requiredBlocks,
int remainingBlocks)
SplitFileFetcherStorageCallbacksetSplitfileBlocks in interface SplitFileFetcherStorageCallbackrequiredBlocks - The number of blocks that must be fetched to complete the download.remainingBlocks - The total number of blocks minus requiredBlocks.public void onSplitfileCompatibilityMode(InsertContext.CompatibilityMode min, InsertContext.CompatibilityMode max, byte[] customSplitfileKey, boolean compressed, boolean bottomLayer, boolean definitiveAnyway)
SplitFileFetcherStorageCallbackonSplitfileCompatibilityMode in interface SplitFileFetcherStorageCallbackmin - 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.customSplitfileKey - 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.public void queueHeal(byte[] data,
byte[] cryptoKey,
byte cryptoAlgorithm)
SplitFileFetcherStorageCallbackqueueHeal in interface SplitFileFetcherStorageCallbackpublic boolean localRequestOnly()
public void toNetwork()
public boolean hasFinished()
public void onFetchedBlock()
onFetchedBlock in interface SplitFileFetcherStorageCallbackpublic void onFailedBlock()
SplitFileFetcherStorageCallbackonFailedBlock in interface SplitFileFetcherStorageCallbackpublic void onResume(int succeededBlocks,
int failedBlocks,
ClientMetadata meta,
long finalSize)
onResume in interface SplitFileFetcherStorageCallbackpublic void maybeAddToBinaryBlob(ClientCHKBlock block)
SplitFileFetcherStorageCallbackmaybeAddToBinaryBlob in interface SplitFileFetcherStorageCallbackpublic boolean wantBinaryBlob()
SplitFileFetcherStorageCallbackwantBinaryBlob in interface SplitFileFetcherStorageCallbackpublic BaseSendableGet getSendableGet()
SplitFileFetcherStorageCallbackgetSendableGet in interface SplitFileFetcherStorageCallbackpublic void restartedAfterDataCorruption()
SplitFileFetcherStorageCallbackrestartedAfterDataCorruption in interface SplitFileFetcherStorageCallbackpublic void clearCooldown()
SplitFileFetcherStorageCallbackclearCooldown in interface SplitFileFetcherStorageCallbackpublic void reduceCooldown(long wakeupTime)
SplitFileFetcherStorageCallbackreduceCooldown in interface SplitFileFetcherStorageCallbackpublic HasKeyListener getHasKeyListener()
SplitFileFetcherStorageCallbackgetHasKeyListener in interface SplitFileFetcherStorageCallbackpublic void onResume(ClientContext context) throws FetchException
ClientGetStateonResume in interface ClientGetStateFetchExceptionpublic KeySalter getSalter()
getSalter in interface SplitFileFetcherStorageCallbackpublic boolean writeTrivialProgress(java.io.DataOutputStream dos)
throws java.io.IOException
java.io.IOExceptionpublic void onShutdown(ClientContext context)
ClientGetStateonShutdown in interface ClientGetState