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, toNetwork
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
onResume
protected 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 PutCompletionCallback
public void onFailure(InsertException e, ClientPutState state, ClientContext context)
onFailure
in interface PutCompletionCallback
public void onEncode(BaseClientKey key, ClientPutState state, ClientContext context)
onEncode
in interface PutCompletionCallback
public void onMetadata(Bucket finalMetadata, ClientPutState state, ClientContext context)
onMetadata
in interface PutCompletionCallback
public void cancel(ClientContext context)
cancel
in class ClientRequester
context
- The ClientContext object including essential but
non-persistent objects such as the schedulers.public boolean isFinished()
isFinished
in class ClientRequester
public FreenetURI getTargetURI()
public FreenetURI getURI()
getURI
in class ClientRequester
public byte[] getSplitfileCryptoKey()
public void onTransition(ClientPutState oldState, ClientPutState newState, ClientContext context)
onTransition
in interface PutCompletionCallback
onTransition
in class BaseClientPutter
public void onMetadata(Metadata m, ClientPutState state, ClientContext context)
onMetadata
in interface PutCompletionCallback
public int getMinSuccessFetchBlocks()
getMinSuccessFetchBlocks
in class BaseClientPutter
public void addBlock()
ClientRequester
addBlock
in class ClientRequester
public void addBlocks(int num)
ClientRequester
addBlocks
in class ClientRequester
public void addMustSucceedBlocks(int blocks)
addMustSucceedBlocks
in class ClientRequester
public void addRedundantBlocksInsert(int blocks)
addRedundantBlocksInsert
in class ClientRequester
protected void clearCountersOnRestart()
clearCountersOnRestart
in class ClientRequester
protected void innerNotifyClients(ClientContext context)
ClientRequester
innerNotifyClients
in class ClientRequester
protected void innerToNetwork(ClientContext context)
innerToNetwork
in class ClientRequester
public void onBlockSetFinished(ClientPutState state, ClientContext context)
onBlockSetFinished
in interface PutCompletionCallback
public void onFetchable(ClientPutState state)
onFetchable
in interface PutCompletionCallback
public 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 ClientRequester
public void dump()
dump
in class BaseClientPutter
public byte[] getClientDetail(ChecksumChecker checker) throws java.io.IOException
getClientDetail
in class ClientRequester
checker
- Used to checksum and isolate large components where we can recover if they
fail.java.io.IOException
public void innerOnResume(ClientContext context) throws ResumeFailedException
ClientRequester
innerOnResume
in class ClientRequester
ResumeFailedException
protected ClientBaseCallback getCallback()
getCallback
in class ClientRequester
public void onShutdown(ClientContext context)
ClientRequester
onShutdown
in class ClientRequester