Thaw FCP implementation
homepage
FCP
FCP (version 2) is the protocol used by Thaw to talk to the node. This protocol is simple and efficient.
See
FreenetFCPSpec2Point0.
Thaw implementation
All the classes for Thaw FCP Implementation are in the package 'thaw.fcp'. But these classes may also need 'thaw.core.Logger' (should be fixed later).
The whole implementation is based on the model Observable/Observer(s). See
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Observable.html∞ and
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Observer.html∞.
Note: The word "query" is misused here. The correct word would be "request". But I'm too lazy to fix it :p
FCPTransferQuery is an abstract class extended by:
-
FCPClientPut
-
FCPClientGet
FCPQuery is an interface implemented by
- All the classes extending
FCPTransferQuery
-
FCPGenerateSSK
-
FCPListPersistentRequests
-
FCPWatchGlobal
- ...
Most of the FCPQuery are Observable and notify their observers at each (even minor) change.
-------------------
| FCPQueueManager | <----------------> FCPTransferQuery
-------------------
|
|
\/
------------------- FCPMessage
| FCPQueryManager | <----------------> FCPQuery / FCPTransferQuery (FCPClientGet, FCPClientPut, etc)
-------------------
|
|
\/
-------------------
| FCPConnection |
-------------------
|
|
\/
Socket (---> Node ---> Freenet)
FCPConnection manages the connection to the node at a low level (connect(), read(), write(), disconnect()).
FCPQueryManager transforms what is read by FCPConnection into FCPMessages and then notify its Observers with as parameter the FCPMessage.
FCPQueueManager manages a queue of transfers (some of them can be only on Thaw side (not started ; waiting), some of them can be running on the node). Its job is to start waiting transfers when possible, and to keep track of the running ones (
FCPQueueManager is optional if you want to use this implementation in another software than Thaw). All the transfers managed by the
FCPQueueManager are displayed by the plugin
QueueWatcher of Thaw.
FCPQueueManager doesn't read
PersistentGet/
PersistentPut messages (and so doesn't load the queue from the node by itself). This job is done by
FCPQueueLoader.
Initialisation & connection process
This part is a little tricky. I think the easiest way to understand how to do it is to look at thaw.core.Core.initConnection() and thaw.core.Core.
ConnectionProcess.process().
See
http://freenet.googlecode.com/svn/trunk/apps/Thaw/src/thaw/core/Core.java∞
Utilization
Use "
FCPQueueManager.addQueryToThePendingQueue(
FCPTransferQuery)" to add a query to the queue of pending queries (see 'Transfers' tab in Thaw). The number of simultaneous requests can be limited (see the configuration in advanced mode), so if it is, the query will be queued, else it will started immediatly.
You can also use
FCPQueueManager.addQueryToTheRunningQueue(
FCPTransferQueue) if you want it to start immediatly (even if it should be queued) and to be visible to the plugin "
QueueWatcher".
Use "
FCPTransferQuery.start(
FCPQueueManager)" to start a query without making this query visible to the user (-> will never be queued).
Note: In the future, it's possible that
FCPTransferQuery.start(
FCPQueueManager) becomes
FCPTransferQuery.start(
FCPQueryManager).
Note: the constructor of
FCPClientPut sucks and will probably be modified later.