public class FCPServer extends java.lang.Object implements java.lang.Runnable, DownloadCache
| Modifier and Type | Field and Description |
|---|---|
NodeClientCore |
core |
static int |
DEFAULT_FCP_PORT |
boolean |
enabled |
static long |
QUEUE_MAX_DATA_SIZE |
static int |
QUEUE_MAX_RETRIES |
| Constructor and Description |
|---|
FCPServer(java.lang.String ipToBindTo,
java.lang.String allowedHosts,
java.lang.String allowedHostsFullAccess,
int port,
Node node,
NodeClientCore core,
boolean isEnabled,
boolean assumeDDADownloadAllowed,
boolean assumeDDAUploadAllowed,
boolean neverDropAMessage,
int maxMessageQueueLength,
PersistentRequestRoot persistentRoot) |
| Modifier and Type | Method and Description |
|---|---|
FCPPluginConnection |
createFCPPluginConnectionForIntraNodeFCP(java.lang.String serverPluginName,
FredPluginFCPMessageHandler.ClientSideFCPMessageHandler messageHandler)
Creates and registers a
FCPPluginConnection object for FCP connections between
plugins running within the same node.In other words, the actual client application is NOT connected to the node by network, it is a plugin running within the node just like the server. |
FetchResult |
getCompletedRequestBlocking(FreenetURI key) |
PersistentRequestClient |
getForeverClient(java.lang.String name,
NodeClientCore core,
FCPConnectionHandler handler) |
PersistentRequestClient |
getGlobalForeverClient()
Returns the global FCP client.
|
ClientRequest |
getGlobalRequest(java.lang.String identifier) |
RequestStatus[] |
getGlobalRequests() |
FCPPluginConnection |
getPluginConnectionByID(java.util.UUID connectionID)
The documentation of
FCPPluginConnectionTracker.getConnection(UUID) applies to
this function. |
protected boolean |
isDownloadDDAAlwaysAllowed() |
protected boolean |
isUploadDDAAlwaysAllowed() |
void |
load() |
CacheFetchResult |
lookup(FreenetURI key,
boolean noFilter,
ClientContext context,
boolean mustCopy,
Bucket preferred) |
CacheFetchResult |
lookupInstant(FreenetURI key,
boolean noFilter,
boolean mustCopy,
Bucket preferred) |
void |
makePersistentGlobalRequest(FreenetURI fetchURI,
boolean filterData,
java.lang.String expectedMimeType,
java.lang.String persistenceTypeString,
java.lang.String returnTypeString,
boolean realTimeFlag) |
void |
makePersistentGlobalRequest(FreenetURI fetchURI,
boolean filterData,
java.lang.String expectedMimeType,
java.lang.String persistenceTypeString,
java.lang.String returnTypeString,
boolean realTimeFlag,
java.io.File downloadsDir)
Create a persistent globally-queued request for a file.
|
void |
makePersistentGlobalRequestBlocking(FreenetURI fetchURI,
boolean filterData,
java.lang.String expectedMimeType,
java.lang.String persistenceTypeString,
java.lang.String returnTypeString,
boolean realTimeFlag,
java.io.File downloadsDir) |
int |
maxMessageQueueLength() |
static FCPServer |
maybeCreate(Node node,
NodeClientCore core,
Config config,
PersistentRequestRoot root) |
void |
maybeStart() |
boolean |
modifyGlobalRequestBlocking(java.lang.String identifier,
java.lang.String newToken,
short newPriority) |
boolean |
neverDropAMessage() |
PersistentRequestClient |
registerForeverClient(java.lang.String name,
NodeClientCore core,
FCPConnectionHandler handler) |
PersistentRequestClient |
registerRebootClient(java.lang.String name,
NodeClientCore core,
FCPConnectionHandler handler) |
boolean |
removeAllGlobalRequestsBlocking() |
boolean |
removeGlobalRequestBlocking(java.lang.String identifier) |
boolean |
restartBlocking(java.lang.String identifier,
boolean disableFilterData) |
void |
run() |
void |
setCompletionCallback(RequestCompletionCallback cb) |
void |
startBlocking(ClientRequest req,
ClientContext context)
Start a request on the global queue.
|
void |
unregisterClient(PersistentRequestClient client) |
public static final int DEFAULT_FCP_PORT
public final NodeClientCore core
public final boolean enabled
public static final int QUEUE_MAX_RETRIES
public static final long QUEUE_MAX_DATA_SIZE
public FCPServer(java.lang.String ipToBindTo,
java.lang.String allowedHosts,
java.lang.String allowedHostsFullAccess,
int port,
Node node,
NodeClientCore core,
boolean isEnabled,
boolean assumeDDADownloadAllowed,
boolean assumeDDAUploadAllowed,
boolean neverDropAMessage,
int maxMessageQueueLength,
PersistentRequestRoot persistentRoot)
throws java.io.IOException,
InvalidConfigValueException
java.io.IOExceptionInvalidConfigValueExceptionpublic void load()
public void maybeStart()
public void run()
run in interface java.lang.Runnablepublic static FCPServer maybeCreate(Node node, NodeClientCore core, Config config, PersistentRequestRoot root) throws java.io.IOException, InvalidConfigValueException
java.io.IOExceptionInvalidConfigValueExceptionpublic boolean neverDropAMessage()
public int maxMessageQueueLength()
public final FCPPluginConnection createFCPPluginConnectionForIntraNodeFCP(java.lang.String serverPluginName, FredPluginFCPMessageHandler.ClientSideFCPMessageHandler messageHandler) throws PluginNotFoundException
Creates and registers a FCPPluginConnection object for FCP connections between
plugins running within the same node.
In other words, the actual client application is NOT connected to the node by network, it is
a plugin running within the node just like the server.
The object is registered at the backend FCPPluginConnectionTracker and thus can be
queried from this server by ID via the frontend getPluginConnectionByID(UUID) as
long as something else keeps a strong reference to it.
Once it becomes weakly reachable, it will be garbage-collected from the backend
FCPPluginConnectionTracker and getPluginConnectionByID(UUID) will not
return it anymore.
In other words, you don't have to take care of registering or unregistering connections.
You only have to take care of keeping a strong reference to them while they are in use.
ATTENTION: Only for internal use by the frontend function
PluginRespirator.connectToOtherPlugin(String,
FredPluginFCPMessageHandler.ClientSideFCPMessageHandler). Plugins must use that instead.
FCPPluginConnection.SendDirection.ToServer.PluginNotFoundExceptionThe class JavaDoc of FCPPluginConnectionImpl explains the code path for both networked
and non-networked FCP.public final FCPPluginConnection getPluginConnectionByID(java.util.UUID connectionID) throws java.io.IOException
The documentation of FCPPluginConnectionTracker.getConnection(UUID) applies to
this function.
PluginRespirator.getPluginConnectionByID(UUID). Plugins must use that instead.FCPPluginConnection.SendDirection.ToClient.java.io.IOExceptionThe JavaDoc of FCPPluginConnectionTracker explains the general purpose of this mechanism.public PersistentRequestClient registerRebootClient(java.lang.String name, NodeClientCore core, FCPConnectionHandler handler)
public PersistentRequestClient registerForeverClient(java.lang.String name, NodeClientCore core, FCPConnectionHandler handler)
public PersistentRequestClient getForeverClient(java.lang.String name, NodeClientCore core, FCPConnectionHandler handler)
public void unregisterClient(PersistentRequestClient client)
public RequestStatus[] getGlobalRequests() throws PersistenceDisabledException
PersistenceDisabledExceptionpublic boolean removeGlobalRequestBlocking(java.lang.String identifier)
throws MessageInvalidException,
PersistenceDisabledException
public boolean removeAllGlobalRequestsBlocking()
throws PersistenceDisabledException
PersistenceDisabledExceptionpublic void makePersistentGlobalRequestBlocking(FreenetURI fetchURI, boolean filterData, java.lang.String expectedMimeType, java.lang.String persistenceTypeString, java.lang.String returnTypeString, boolean realTimeFlag, java.io.File downloadsDir) throws NotAllowedException, java.io.IOException, PersistenceDisabledException
NotAllowedExceptionjava.io.IOExceptionPersistenceDisabledExceptionpublic boolean modifyGlobalRequestBlocking(java.lang.String identifier,
java.lang.String newToken,
short newPriority)
throws PersistenceDisabledException
PersistenceDisabledExceptionpublic void makePersistentGlobalRequest(FreenetURI fetchURI, boolean filterData, java.lang.String expectedMimeType, java.lang.String persistenceTypeString, java.lang.String returnTypeString, boolean realTimeFlag) throws NotAllowedException, java.io.IOException
NotAllowedExceptionjava.io.IOExceptionpublic void makePersistentGlobalRequest(FreenetURI fetchURI, boolean filterData, java.lang.String expectedMimeType, java.lang.String persistenceTypeString, java.lang.String returnTypeString, boolean realTimeFlag, java.io.File downloadsDir) throws NotAllowedException, java.io.IOException
fetchURI - The file to fetch.persistenceTypeString - The persistence type.returnTypeString - The return type.downloadsDir - Target directory if downloading to disk. Must be valid!NotAllowedExceptionjava.io.IOExceptionpublic PersistentRequestClient getGlobalForeverClient()
public ClientRequest getGlobalRequest(java.lang.String identifier)
protected boolean isDownloadDDAAlwaysAllowed()
protected boolean isUploadDDAAlwaysAllowed()
public void setCompletionCallback(RequestCompletionCallback cb)
public void startBlocking(ClientRequest req, ClientContext context) throws IdentifierCollisionException, PersistenceDisabledException
req - The request (insert etc) to start.container - The database handle. This method must be called on a DBJob.context - The client layer context object.IdentifierCollisionException - If there is already a request with that identifier.DatabaseDisabledException - If the database is disabled/broken/turned off,
if we are shutting down, if we are waiting for the user to give us the decryption
password etc.PersistenceDisabledExceptionpublic boolean restartBlocking(java.lang.String identifier,
boolean disableFilterData)
throws PersistenceDisabledException
PersistenceDisabledExceptionpublic FetchResult getCompletedRequestBlocking(FreenetURI key) throws PersistenceDisabledException
PersistenceDisabledExceptionpublic CacheFetchResult lookupInstant(FreenetURI key, boolean noFilter, boolean mustCopy, Bucket preferred)
lookupInstant in interface DownloadCachepublic CacheFetchResult lookup(FreenetURI key, boolean noFilter, ClientContext context, boolean mustCopy, Bucket preferred)
lookup in interface DownloadCache