public abstract class BaseManifestPutter extends ManifestPutter
Base class for site insertion. This class contains all the insert logic, but not any 'pack logic'. The pack logic have to be implement in a subclass in makePutHandlers.
Internal container redirect URIs: The internal container URIs should be always redirects to CHKs, not just include the metadata into manifest only. The (assumed) default behavior is the reuse of containers between editions, also ArchiveManger want to have a URI given, not Metadata. This rule also makes site update code/logic much more easier.
Modifier and Type | Class and Description |
---|---|
protected class |
BaseManifestPutter.ContainerBuilder |
protected class |
BaseManifestPutter.FreeFormBuilder |
protected class |
BaseManifestPutter.ManifestBuilder |
Modifier and Type | Field and Description |
---|---|
protected int |
minSuccessFetchBlocks
The number of blocks that will be needed to fetch the data.
|
blockSetFinalized, cancelled, client, creationTime, failedBlocks, fatallyFailedBlocks, latestFailure, latestSuccess, minSuccessBlocks, priorityClass, realTimeFlag, sentToNetwork, successfulBlocks, totalBlocks
Constructor and Description |
---|
BaseManifestPutter(ClientPutCallback cb,
java.util.HashMap<java.lang.String,java.lang.Object> manifestElements,
short prioClass,
FreenetURI target,
java.lang.String defaultName,
InsertContext ctx,
boolean randomiseCryptoKeys,
byte[] forceCryptoKey,
ClientContext context) |
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 |
blockSetFinalized(ClientContext context)
The set of blocks has been finalised, total will not change any
more.
|
static java.util.HashMap<java.lang.String,java.lang.Object> |
bucketsByNameToManifestEntries(java.util.HashMap<java.lang.String,java.lang.Object> bucketsByName) |
void |
cancel(ClientContext context)
Cancel the request.
|
int |
countFiles() |
static ManifestElement[] |
flatten(java.util.HashMap<java.lang.String,java.lang.Object> manifestElements) |
static void |
flatten(java.util.HashMap<java.lang.String,java.lang.Object> manifestElements,
java.util.List<ManifestElement> v,
java.lang.String prefix) |
protected ClientBaseCallback |
getCallback() |
int |
getMinSuccessFetchBlocks() |
protected BaseManifestPutter.FreeFormBuilder |
getRootBuilder() |
protected BaseManifestPutter.ContainerBuilder |
getRootContainer() |
byte[] |
getSplitfileCryptoKey() |
FreenetURI |
getURI()
Get the URI for the request or insert.
|
protected ClientMetadata |
guessMime(java.lang.String name,
ManifestElement me) |
protected ClientMetadata |
guessMime(java.lang.String name,
java.lang.String mimetype) |
void |
innerNotifyClients(ClientContext context)
Notify clients, usually via a SplitfileProgressEvent, of the current progress.
|
protected 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)?
|
BaseManifestPutter.ContainerBuilder |
makeArchive() |
protected abstract void |
makePutHandlers(java.util.HashMap<java.lang.String,java.lang.Object> manifestElements,
java.lang.String defaultName)
Implement the pack logic.
|
protected void |
onFetchable(freenet.client.async.BaseManifestPutter.PutHandler handler) |
void |
onShutdown(ClientContext context)
Called just before the final write when shutting down the node.
|
void |
onTransition(ClientGetState oldState,
ClientGetState newState,
ClientContext context) |
void |
onTransition(ClientPutState from,
ClientPutState to,
ClientContext context) |
void |
start(ClientContext context) |
long |
totalSize() |
dump
cancel, clearCountersOnRestart, completedBlock, failedBlock, failedBlock, fatallyFailedBlock, getAll, getClient, getClientDetail, getClientDetail, getLatestFailure, getLatestSuccess, getPriorityClass, getSchedulerGroup, getTotalBlocks, hashCode, isCancelled, isCurrentState, notifyClients, onResume, persistent, realTimeFlag, resetBlocks, setPriorityClass, toNetwork
protected int minSuccessFetchBlocks
public BaseManifestPutter(ClientPutCallback cb, java.util.HashMap<java.lang.String,java.lang.Object> manifestElements, short prioClass, FreenetURI target, java.lang.String defaultName, InsertContext ctx, boolean randomiseCryptoKeys, byte[] forceCryptoKey, ClientContext context) throws TooManyFilesInsertException
TooManyFilesInsertException
public void start(ClientContext context) throws InsertException
start
in class ManifestPutter
InsertException
protected abstract void makePutHandlers(java.util.HashMap<java.lang.String,java.lang.Object> manifestElements, java.lang.String defaultName) throws TooManyFilesInsertException
manifestElements
- A map from String to either ManifestElement or another String. This is the
site structure, which will be split into containers and/or external inserts by the method.TooManyFilesInsertException
public FreenetURI getURI()
ClientRequester
getURI
in class ClientRequester
public boolean isFinished()
ClientRequester
isFinished
in class ClientRequester
public byte[] getSplitfileCryptoKey()
getSplitfileCryptoKey
in class ManifestPutter
public void cancel(ClientContext context)
ClientRequester
cancel
in class ClientRequester
context
- The ClientContext object including essential but
non-persistent objects such as the schedulers.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
public void innerNotifyClients(ClientContext context)
ClientRequester
innerNotifyClients
in class ClientRequester
public int getMinSuccessFetchBlocks()
getMinSuccessFetchBlocks
in class BaseClientPutter
public void blockSetFinalized(ClientContext context)
ClientRequester
blockSetFinalized
in class ClientRequester
context
- The ClientContext object including essential but
non-persistent objects such as the schedulers.public int countFiles()
countFiles
in class ManifestPutter
public long totalSize()
totalSize
in class ManifestPutter
protected void onFetchable(freenet.client.async.BaseManifestPutter.PutHandler handler)
public void onTransition(ClientGetState oldState, ClientGetState newState, ClientContext context)
onTransition
in class ClientRequester
public void onTransition(ClientPutState from, ClientPutState to, ClientContext context)
onTransition
in class BaseClientPutter
protected void innerToNetwork(ClientContext context)
ClientRequester
innerToNetwork
in class ClientRequester
protected final ClientMetadata guessMime(java.lang.String name, ManifestElement me)
protected final ClientMetadata guessMime(java.lang.String name, java.lang.String mimetype)
public BaseManifestPutter.ContainerBuilder makeArchive()
protected BaseManifestPutter.ContainerBuilder getRootContainer()
protected BaseManifestPutter.FreeFormBuilder getRootBuilder()
protected ClientBaseCallback getCallback()
getCallback
in class ClientRequester
public static java.util.HashMap<java.lang.String,java.lang.Object> bucketsByNameToManifestEntries(java.util.HashMap<java.lang.String,java.lang.Object> bucketsByName)
public static ManifestElement[] flatten(java.util.HashMap<java.lang.String,java.lang.Object> manifestElements)
public static void flatten(java.util.HashMap<java.lang.String,java.lang.Object> manifestElements, java.util.List<ManifestElement> v, java.lang.String prefix)
public void onShutdown(ClientContext context)
ClientRequester
onShutdown
in class ClientRequester
protected void innerOnResume(ClientContext context) throws ResumeFailedException
ClientRequester
innerOnResume
in class ClientRequester
ResumeFailedException