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
FetchException
MetadataParseException
protected SplitFileFetcher()
public SplitFileFetcher(ClientGetter getter, java.io.DataInputStream dis, ClientContext context) throws StorageFormatException, ResumeFailedException, java.io.IOException
StorageFormatException
ResumeFailedException
java.io.IOException
public void schedule(ClientContext context)
ClientGetState
schedule
in interface ClientGetState
public void failOnDiskError(java.io.IOException e)
failOnDiskError
in interface SplitFileFetcherStorageCallback
e
- The IOException, generated when accessing the on-disk storage.public void failOnDiskError(ChecksumFailedException e)
failOnDiskError
in interface SplitFileFetcherStorageCallback
public void fail(FetchException e)
SplitFileFetcherStorageCallback
fail
in interface SplitFileFetcherStorageCallback
public void cancel(ClientContext context)
ClientGetState
cancel
in interface ClientGetState
public long getToken()
ClientGetState
getToken
in interface ClientGetState
public void onSuccess()
onSuccess
in interface SplitFileFetcherStorageCallback
public void onClosed()
SplitFileFetcherStorageCallback
onClosed
in interface SplitFileFetcherStorageCallback
public short getPriorityClass()
SplitFileFetcherStorageCallback
getPriorityClass
in interface SplitFileFetcherStorageCallback
public void setSplitfileBlocks(int requiredBlocks, int remainingBlocks)
SplitFileFetcherStorageCallback
setSplitfileBlocks
in interface SplitFileFetcherStorageCallback
requiredBlocks
- 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)
SplitFileFetcherStorageCallback
onSplitfileCompatibilityMode
in interface SplitFileFetcherStorageCallback
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.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)
SplitFileFetcherStorageCallback
queueHeal
in interface SplitFileFetcherStorageCallback
public boolean localRequestOnly()
public void toNetwork()
public boolean hasFinished()
public void onFetchedBlock()
onFetchedBlock
in interface SplitFileFetcherStorageCallback
public void onFailedBlock()
SplitFileFetcherStorageCallback
onFailedBlock
in interface SplitFileFetcherStorageCallback
public void onResume(int succeededBlocks, int failedBlocks, ClientMetadata meta, long finalSize)
onResume
in interface SplitFileFetcherStorageCallback
public void maybeAddToBinaryBlob(ClientCHKBlock block)
SplitFileFetcherStorageCallback
maybeAddToBinaryBlob
in interface SplitFileFetcherStorageCallback
public boolean wantBinaryBlob()
SplitFileFetcherStorageCallback
wantBinaryBlob
in interface SplitFileFetcherStorageCallback
public BaseSendableGet getSendableGet()
SplitFileFetcherStorageCallback
getSendableGet
in interface SplitFileFetcherStorageCallback
public void restartedAfterDataCorruption()
SplitFileFetcherStorageCallback
restartedAfterDataCorruption
in interface SplitFileFetcherStorageCallback
public void clearCooldown()
SplitFileFetcherStorageCallback
clearCooldown
in interface SplitFileFetcherStorageCallback
public void reduceCooldown(long wakeupTime)
SplitFileFetcherStorageCallback
reduceCooldown
in interface SplitFileFetcherStorageCallback
public HasKeyListener getHasKeyListener()
SplitFileFetcherStorageCallback
getHasKeyListener
in interface SplitFileFetcherStorageCallback
public void onResume(ClientContext context) throws FetchException
ClientGetState
onResume
in interface ClientGetState
FetchException
public KeySalter getSalter()
getSalter
in interface SplitFileFetcherStorageCallback
public boolean writeTrivialProgress(java.io.DataOutputStream dos) throws java.io.IOException
java.io.IOException
public void onShutdown(ClientContext context)
ClientGetState
onShutdown
in interface ClientGetState