public class ClientPutter extends BaseClientPutter implements PutCompletionCallback
| Modifier and Type | Field and Description |
|---|---|
protected int |
minSuccessFetchBlocks
The number of blocks that will be needed to fetch the data.
|
blockSetFinalized, cancelled, creationTime, failedBlocks, fatallyFailedBlocks, latestFailure, latestSuccess, minSuccessBlocks, priorityClass, realTimeFlag, sentToNetwork, successfulBlocks, totalBlocks| Constructor and Description |
|---|
ClientPutter(ClientPutCallback client,
RandomAccessBucket data,
FreenetURI targetURI,
ClientMetadata cm,
InsertContext ctx,
short priorityClass,
boolean isMetadata,
java.lang.String targetFilename,
boolean binaryBlob,
ClientContext context,
byte[] overrideSplitfileCrypto,
long metadataThreshold) |
| Modifier and Type | Method and Description |
|---|---|
void |
addBlock()
Add a block to our estimate of the total.
|
void |
addBlocks(int num)
Add several blocks to our estimate of the total.
|
void |
addMustSucceedBlocks(int blocks)
Add one or more blocks to the number of requires blocks, and don't notify the clients.
|
void |
addRedundantBlocksInsert(int blocks)
Add one or more blocks to the number of requires blocks, and don't notify the clients.
|
void |
cancel(ClientContext context)
Cancel the insert.
|
boolean |
canRestart()
Can we restart the insert?
|
protected void |
clearCountersOnRestart() |
void |
dump() |
protected ClientBaseCallback |
getCallback() |
byte[] |
getClientDetail(ChecksumChecker checker) |
Bucket |
getData() |
int |
getMinSuccessFetchBlocks() |
byte[] |
getSplitfileCryptoKey()
Get used splitfile cryptokey.
|
FreenetURI |
getTargetURI()
Get the target URI with which this insert was started.
|
FreenetURI |
getURI()
Get the final URI to the inserted data
|
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 listening clients that an insert has been sent to the network.
|
boolean |
isFinished()
Has the insert completed already?
|
void |
onBlockSetFinished(ClientPutState state,
ClientContext context)
Called when we know exactly how many blocks will be needed.
|
void |
onEncode(BaseClientKey key,
ClientPutState state,
ClientContext context)
Called when we know the final URI of the insert.
|
void |
onFailure(InsertException e,
ClientPutState state,
ClientContext context)
Called when the insert fails.
|
void |
onFetchable(ClientPutState state)
Called (sometimes) when enough of the data has been inserted that the file can now be fetched.
|
void |
onMetadata(Bucket finalMetadata,
ClientPutState state,
ClientContext context)
Called when metadataThreshold was specified and metadata is being returned
instead of a URI.
|
void |
onMetadata(Metadata m,
ClientPutState state,
ClientContext context)
Called when we have generated metadata for the insert.
|
void |
onShutdown(ClientContext context)
Called just before the final write when shutting down the node.
|
void |
onSuccess(ClientPutState state,
ClientContext context)
Called when the insert succeeds.
|
void |
onTransition(ClientGetState oldState,
ClientGetState newState,
ClientContext context) |
void |
onTransition(ClientPutState oldState,
ClientPutState newState,
ClientContext context)
Called when a ClientPutState transitions to a new state.
|
static boolean |
randomiseSplitfileKeys(FreenetURI targetURI,
InsertContext ctx,
boolean persistent) |
boolean |
restart(ClientContext context)
Restart the insert.
|
boolean |
start(boolean restart,
ClientContext context)
Start the insert.
|
void |
start(ClientContext context)
Start the insert.
|
blockSetFinalized, cancel, completedBlock, failedBlock, failedBlock, fatallyFailedBlock, getAll, getClient, getClientDetail, getLatestFailure, getLatestSuccess, getPriorityClass, getSchedulerGroup, getTotalBlocks, hashCode, isCancelled, isCurrentState, notifyClients, onResume, persistent, realTimeFlag, resetBlocks, setPriorityClass, toNetworkclone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, waitonResumeprotected int minSuccessFetchBlocks
public ClientPutter(ClientPutCallback client, RandomAccessBucket data, FreenetURI targetURI, ClientMetadata cm, InsertContext ctx, short priorityClass, boolean isMetadata, java.lang.String targetFilename, boolean binaryBlob, ClientContext context, byte[] overrideSplitfileCrypto, long metadataThreshold)
client - The object to call back when we complete, or don't.data - The data to insert. This will be freed when the insert has completed, whether
it succeeds or not, so wrap it in a @link freenet.support.io.NoFreeBucket if you don't want
it to be freed.targetURI - cm - ctx - priorityClass - isMetadata - targetFilename - If set, create a one-file manifest containing this filename pointing to this file.binaryBlob - context - The client object for purposs of round-robin client balancing.overrideSplitfileCrypto - metadataThreshold - public void start(ClientContext context) throws InsertException
earlyEncode - If true, try to find the final URI as quickly as possible, and insert the upper
layers as soon as we can, rather than waiting for the lower layers. The default behaviour is safer,
because an attacker can usually only identify the datastream once he has the top block, or once you
have announced the key.context - Contains some useful transient fields such as the schedulers.InsertException - If the insert cannot be started for some reason.public boolean start(boolean restart,
ClientContext context)
throws InsertException
restart - If true, restart the insert even though it has completed before.context - Contains some useful transient fields such as the schedulers.InsertException - If the insert cannot be started for some reason.public static boolean randomiseSplitfileKeys(FreenetURI targetURI, InsertContext ctx, boolean persistent)
public void onSuccess(ClientPutState state, ClientContext context)
onSuccess in interface PutCompletionCallbackpublic void onFailure(InsertException e, ClientPutState state, ClientContext context)
onFailure in interface PutCompletionCallbackpublic void onEncode(BaseClientKey key, ClientPutState state, ClientContext context)
onEncode in interface PutCompletionCallbackpublic void onMetadata(Bucket finalMetadata, ClientPutState state, ClientContext context)
onMetadata in interface PutCompletionCallbackpublic void cancel(ClientContext context)
cancel in class ClientRequestercontext - The ClientContext object including essential but
non-persistent objects such as the schedulers.public boolean isFinished()
isFinished in class ClientRequesterpublic FreenetURI getTargetURI()
public FreenetURI getURI()
getURI in class ClientRequesterpublic byte[] getSplitfileCryptoKey()
public void onTransition(ClientPutState oldState, ClientPutState newState, ClientContext context)
onTransition in interface PutCompletionCallbackonTransition in class BaseClientPutterpublic void onMetadata(Metadata m, ClientPutState state, ClientContext context)
onMetadata in interface PutCompletionCallbackpublic int getMinSuccessFetchBlocks()
getMinSuccessFetchBlocks in class BaseClientPutterpublic void addBlock()
ClientRequesteraddBlock in class ClientRequesterpublic void addBlocks(int num)
ClientRequesteraddBlocks in class ClientRequesterpublic void addMustSucceedBlocks(int blocks)
addMustSucceedBlocks in class ClientRequesterpublic void addRedundantBlocksInsert(int blocks)
addRedundantBlocksInsert in class ClientRequesterprotected void clearCountersOnRestart()
clearCountersOnRestart in class ClientRequesterprotected void innerNotifyClients(ClientContext context)
ClientRequesterinnerNotifyClients in class ClientRequesterprotected void innerToNetwork(ClientContext context)
innerToNetwork in class ClientRequesterpublic void onBlockSetFinished(ClientPutState state, ClientContext context)
onBlockSetFinished in interface PutCompletionCallbackpublic void onFetchable(ClientPutState state)
onFetchable in interface PutCompletionCallbackpublic boolean canRestart()
public boolean restart(ClientContext context) throws InsertException
InsertException - If the insert could not be restarted for some reason.public void onTransition(ClientGetState oldState, ClientGetState newState, ClientContext context)
onTransition in class ClientRequesterpublic void dump()
dump in class BaseClientPutterpublic byte[] getClientDetail(ChecksumChecker checker) throws java.io.IOException
getClientDetail in class ClientRequesterchecker - Used to checksum and isolate large components where we can recover if they
fail.java.io.IOExceptionpublic void innerOnResume(ClientContext context) throws ResumeFailedException
ClientRequesterinnerOnResume in class ClientRequesterResumeFailedExceptionprotected ClientBaseCallback getCallback()
getCallback in class ClientRequesterpublic void onShutdown(ClientContext context)
ClientRequesteronShutdown in class ClientRequester