public class SingleBlockInserter extends SendableInsert implements ClientPutState, java.io.Serializable
parentGrabArray, persistent, realTimeFlag
Constructor and Description |
---|
SingleBlockInserter(BaseClientPutter parent,
Bucket data,
short compressionCodec,
FreenetURI uri,
InsertContext ctx,
boolean realTimeFlag,
PutCompletionCallback cb,
boolean isMetadata,
int sourceLength,
int token,
boolean addToParent,
boolean dontSendEncoded,
java.lang.Object tokenObject,
ClientContext context,
boolean persistent,
boolean freeData,
int extraInserts,
byte cryptoAlgorithm,
byte[] cryptoKey)
Create a SingleBlockInserter.
|
Modifier and Type | Method and Description |
---|---|
void |
cancel(ClientContext context)
Cancel the request.
|
boolean |
canWriteClientCache() |
SendableRequestItem |
chooseKey(KeysFetchingLocally ignored,
ClientContext context)
Choose a key to fetch.
|
long |
countAllKeys(ClientContext context)
All key identifiers.
|
long |
countSendableKeys(ClientContext context)
All key identifiers currently eligible to be sent.
|
protected ClientKeyBlock |
encode(ClientContext context,
boolean calledByCB) |
boolean |
forkOnCacheable() |
ClientKeyBlock |
getBlock(ClientContext context,
boolean calledByCB) |
RequestClient |
getClient()
Get client context object.
|
ClientRequester |
getClientRequest()
Get the ClientRequest.
|
ClientKey |
getKeyNoEncode() |
BaseClientPutter |
getParent()
Get the BaseClientPutter responsible for this request state.
|
short |
getPriorityClass()
Get the priority class of the request.
|
SendableRequestSender |
getSender(ClientContext context)
Get or create a SendableRequestSender for this object.
|
java.lang.Object |
getToken()
Get the token, an object which is passed around with the insert and may be
used by callers.
|
FreenetURI |
getURI(ClientContext context) |
FreenetURI |
getURINoEncode() |
long |
getWakeupTime(ClientContext context,
long now)
Unless this is a RandomGrabArrayItem, this will return the wakeup time for the subtree
rooted at this node.
|
protected ClientKeyBlock |
innerEncode(RandomSource random) |
protected static ClientKeyBlock |
innerEncode(RandomSource random,
FreenetURI uri,
Bucket sourceData,
boolean isMetadata,
short compressionCodec,
int sourceLength,
java.lang.String compressorDescriptor,
byte cryptoAlgorithm,
byte[] cryptoKey) |
void |
innerOnResume(ClientContext context) |
boolean |
isCancelled()
If true, the request has been cancelled, or has completed, either way it need not
be registered any more.
|
boolean |
isEmpty() |
boolean |
isSSK()
Is this an SSK? For purposes of determining which scheduler to use.
|
boolean |
localRequestOnly() |
protected void |
onEncode(ClientKey key,
ClientContext context) |
void |
onEncode(SendableRequestItem token,
ClientKey key,
ClientContext context)
Encoded a key
|
void |
onFailure(LowLevelPutException e,
SendableRequestItem keyNum,
ClientContext context)
Called when we don't!
|
void |
onShutdown(ClientContext context)
Called just before the final write of client.dat before the node shuts down.
|
void |
onSuccess(SendableRequestItem keyNum,
ClientKey key,
ClientContext context)
Called when we successfully insert the data
|
void |
schedule(ClientContext context)
Schedule the request.
|
void |
tryEncode(ClientContext context)
Attempt to encode the block, if necessary
|
getScheduler, internalError, isInsert, onResume
clearWakeupTime, getParentGrabArray, getSchedulerGroup, hashCode, knowsParentGrabArray, objectToString, persistent, realTimeFlag, reduceWakeupTime, setParentGrabArray, unregister
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
onResume
public SingleBlockInserter(BaseClientPutter parent, Bucket data, short compressionCodec, FreenetURI uri, InsertContext ctx, boolean realTimeFlag, PutCompletionCallback cb, boolean isMetadata, int sourceLength, int token, boolean addToParent, boolean dontSendEncoded, java.lang.Object tokenObject, ClientContext context, boolean persistent, boolean freeData, int extraInserts, byte cryptoAlgorithm, byte[] cryptoKey)
parent
- The parent. Must be activated.data
- compressionCodec
- The compression codec.uri
- ctx
- realTimeFlag
- cb
- isMetadata
- sourceLength
- The length of the original, uncompressed data.token
- addToParent
- dontSendEncoded
- tokenObject
- context
- persistent
- freeData
- extraInserts
- cryptoAlgorithm
- cryptoKey
- protected ClientKeyBlock innerEncode(RandomSource random) throws InsertException
InsertException
protected static ClientKeyBlock innerEncode(RandomSource random, FreenetURI uri, Bucket sourceData, boolean isMetadata, short compressionCodec, int sourceLength, java.lang.String compressorDescriptor, byte cryptoAlgorithm, byte[] cryptoKey) throws InsertException, CHKEncodeException, java.io.IOException, SSKEncodeException, java.net.MalformedURLException, InvalidCompressionCodecException
InsertException
CHKEncodeException
java.io.IOException
SSKEncodeException
java.net.MalformedURLException
InvalidCompressionCodecException
protected void onEncode(ClientKey key, ClientContext context)
protected ClientKeyBlock encode(ClientContext context, boolean calledByCB) throws InsertException
InsertException
public short getPriorityClass()
SendableRequest
getPriorityClass
in class SendableRequest
public void onFailure(LowLevelPutException e, SendableRequestItem keyNum, ClientContext context)
SendableInsert
onFailure
in class SendableInsert
public ClientKeyBlock getBlock(ClientContext context, boolean calledByCB)
public void schedule(ClientContext context) throws InsertException
ClientPutState
schedule
in interface ClientPutState
InsertException
public boolean isSSK()
SendableRequest
isSSK
in class SendableRequest
public FreenetURI getURI(ClientContext context)
public FreenetURI getURINoEncode()
public ClientKey getKeyNoEncode()
public void onSuccess(SendableRequestItem keyNum, ClientKey key, ClientContext context)
SendableInsert
onSuccess
in class SendableInsert
public BaseClientPutter getParent()
ClientPutState
getParent
in interface ClientPutState
public void cancel(ClientContext context)
ClientPutState
cancel
in interface ClientPutState
public boolean isEmpty()
isEmpty
in class SendableInsert
public boolean isCancelled()
SendableRequest
isCancelled
in class SendableRequest
public SendableRequestSender getSender(ClientContext context)
SendableRequest
getSender
in class SendableRequest
context
- A client context may also be necessary.public RequestClient getClient()
SendableRequest
getClient
in class SendableRequest
public ClientRequester getClientRequest()
SendableRequest
getClientRequest
in class SendableRequest
public java.lang.Object getToken()
ClientPutState
getToken
in interface ClientPutState
public void tryEncode(ClientContext context)
public long countSendableKeys(ClientContext context)
SendableRequest
countSendableKeys
in class SendableRequest
public long countAllKeys(ClientContext context)
SendableRequest
countAllKeys
in class SendableRequest
public SendableRequestItem chooseKey(KeysFetchingLocally ignored, ClientContext context)
SendableRequest
chooseKey
in class SendableRequest
public long getWakeupTime(ClientContext context, long now)
RequestSelectionTreeNode
getWakeupTime
in interface RequestSelectionTreeNode
getWakeupTime
in interface RandomGrabArrayItem
getWakeupTime
in class SendableInsert
public boolean canWriteClientCache()
canWriteClientCache
in class SendableInsert
public boolean localRequestOnly()
localRequestOnly
in class SendableInsert
public boolean forkOnCacheable()
forkOnCacheable
in class SendableInsert
public void onEncode(SendableRequestItem token, ClientKey key, ClientContext context)
SendableInsert
onEncode
in class SendableInsert
public void innerOnResume(ClientContext context) throws InsertException, ResumeFailedException
innerOnResume
in class SendableInsert
InsertException
ResumeFailedException
public void onShutdown(ClientContext context)
ClientPutState
onShutdown
in interface ClientPutState