Author: toad
Date: 2008-06-14 19:45:13 +0000 (Sat, 14 Jun 2008)
New Revision: 20349
Modified:
branches/db4o/freenet/src/freenet/clients/http/QueueToadlet.java
branches/db4o/freenet/src/freenet/node/fcp/FCPClient.java
Log:
Add ,ObjectContainer to any method on FCPClient that accesses non-transient
fields.
Modified: branches/db4o/freenet/src/freenet/clients/http/QueueToadlet.java
===================================================================
--- branches/db4o/freenet/src/freenet/clients/http/QueueToadlet.java
2008-06-14 17:09:41 UTC (rev 20348)
+++ branches/db4o/freenet/src/freenet/clients/http/QueueToadlet.java
2008-06-14 19:45:13 UTC (rev 20349)
@@ -267,7 +267,7 @@
Bucket copiedBucket =
core.persistentEncryptedTempBucketFactory.makeBucket(file.getData().size());
BucketTools.copy(file.getData(), copiedBucket);
try {
- ClientPut clientPut = new
ClientPut(fcp.getGlobalClient(), insertURI, identifier, Integer.MAX_VALUE,
RequestStarter.BULK_SPLITFILE_PRIORITY_CLASS, ClientRequest.PERSIST_FOREVER,
null, false, !compress, -1, ClientPutMessage.UPLOAD_FROM_DIRECT, null,
file.getContentType(), copiedBucket, null, fnam, false);
+ ClientPut clientPut = new
ClientPut(fcp.getGlobalForeverClient(), insertURI, identifier,
Integer.MAX_VALUE, RequestStarter.BULK_SPLITFILE_PRIORITY_CLASS,
ClientRequest.PERSIST_FOREVER, null, false, !compress, -1,
ClientPutMessage.UPLOAD_FROM_DIRECT, null, file.getContentType(), copiedBucket,
null, fnam, false);
clientPut.start();
fcp.forceStorePersistentRequests();
} catch (IdentifierCollisionException e) {
@@ -1141,7 +1141,7 @@
identifiers = (String[])
completedRequestIdentifiers.toArray(new
String[completedRequestIdentifiers.size()]);
}
for(int i=0;i<identifiers.length;i++) {
- ClientRequest req =
fcp.getGlobalClient().getRequest(identifiers[i]);
+ ClientRequest req =
fcp.getGlobalRequest(identifiers[i]);
if(req == null) {
synchronized(completedRequestIdentifiers) {
completedRequestIdentifiers.remove(identifiers[i]);
Modified: branches/db4o/freenet/src/freenet/node/fcp/FCPClient.java
===================================================================
--- branches/db4o/freenet/src/freenet/node/fcp/FCPClient.java 2008-06-14
17:09:41 UTC (rev 20348)
+++ branches/db4o/freenet/src/freenet/node/fcp/FCPClient.java 2008-06-14
19:45:13 UTC (rev 20349)
@@ -6,12 +6,18 @@
import java.util.LinkedList;
import java.util.Vector;
+import com.db4o.ObjectContainer;
+
import freenet.node.RequestClient;
import freenet.support.Logger;
/**
* An FCP client.
- * Identified by its Name which is sent on connection.
+ * Identified by its Name which is sent on connection.
+ * Tracks persistent requests for either PERSISTENCE_REBOOT or
PERSISTENCE_FOREVER.
+ *
+ * Note that anything that modifies a non-transient field on a
PERSISTENCE_FOREVER client should be called in a transaction.
+ * Hence the addition of the ObjectContainer parameter to all such methods.
*/
public class FCPClient {
@@ -68,7 +74,7 @@
private final LinkedList toStart;
final RequestClient lowLevelClientPersistent;
final RequestClient lowLevelClientTransient;
- private RequestCompletionCallback completionCallback;
+ private transient RequestCompletionCallback completionCallback;
/** Connection mode */
private final short persistenceType;
@@ -90,7 +96,7 @@
* Called when a client request has finished, but is persistent. It has
not been
* acked yet, so it should be moved to the unacked-completed-requests
set.
*/
- public void finishedClientRequest(ClientRequest get, FCPServer server) {
+ public void finishedClientRequest(ClientRequest get, FCPServer server,
ObjectContainer container) {
assert(get.persistenceType == persistenceType);
synchronized(this) {
if(runningPersistentRequests.remove(get)) {
@@ -104,7 +110,7 @@
* requests, to be immediately sent. This happens automatically on
startup and hopefully
* will encourage clients to acknowledge persistent requests!
*/
- public void
queuePendingMessagesOnConnectionRestart(FCPConnectionOutputHandler
outputHandler) {
+ public void
queuePendingMessagesOnConnectionRestart(FCPConnectionOutputHandler
outputHandler, ObjectContainer container) {
Object[] reqs;
synchronized(this) {
reqs = completedUnackedRequests.toArray();
@@ -116,7 +122,7 @@
/**
* Queue any and all pending messages from running requests. Happens on
demand.
*/
- public void
queuePendingMessagesFromRunningRequests(FCPConnectionOutputHandler
outputHandler) {
+ public void
queuePendingMessagesFromRunningRequests(FCPConnectionOutputHandler
outputHandler, ObjectContainer container) {
Object[] reqs;
synchronized(this) {
reqs = runningPersistentRequests.toArray();
@@ -125,7 +131,7 @@
((ClientRequest)reqs[i]).sendPendingMessages(outputHandler, true, false, false);
}
- public void register(ClientRequest cg, boolean startLater) throws
IdentifierCollisionException {
+ public void register(ClientRequest cg, boolean startLater,
ObjectContainer container) throws IdentifierCollisionException {
assert(cg.persistenceType == persistenceType);
if(Logger.shouldLog(Logger.MINOR, this))
Logger.minor(this, "Registering
"+cg.getIdentifier()+(startLater ? " to start later" : ""));
@@ -144,7 +150,7 @@
}
}
- public void removeByIdentifier(String identifier, boolean kill,
FCPServer server) throws MessageInvalidException {
+ public void removeByIdentifier(String identifier, boolean kill,
FCPServer server, ObjectContainer container) throws MessageInvalidException {
ClientRequest req;
boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
if(logMINOR) Logger.minor(this,
"removeByIdentifier("+identifier+ ',' +kill+ ')');
@@ -165,11 +171,11 @@
completionCallback.onRemove(req);
}
- public boolean hasPersistentRequests() {
+ public boolean hasPersistentRequests(ObjectContainer container) {
return !(runningPersistentRequests.isEmpty() &&
completedUnackedRequests.isEmpty());
}
- public void addPersistentRequests(Vector v, boolean onlyForever) {
+ public void addPersistentRequests(Vector v, boolean onlyForever,
ObjectContainer container) {
synchronized(this) {
Iterator i = runningPersistentRequests.iterator();
while(i.hasNext()) {
@@ -189,7 +195,7 @@
* @param verbosityMask If so, what verbosity mask to use (to filter
messages
* generated by the global queue).
*/
- public void setWatchGlobal(boolean enabled, int verbosityMask,
FCPServer server) {
+ public void setWatchGlobal(boolean enabled, int verbosityMask,
FCPServer server, ObjectContainer container) {
if(isGlobalQueue) {
Logger.error(this, "Set watch global on global queue!");
return;
@@ -203,8 +209,8 @@
server.globalForeverClient.watch(this);
FCPConnectionHandler connHandler = getConnection();
if(connHandler != null) {
-
server.globalRebootClient.queuePendingMessagesOnConnectionRestart(connHandler.outputHandler);
-
server.globalForeverClient.queuePendingMessagesOnConnectionRestart(connHandler.outputHandler);
+
server.globalRebootClient.queuePendingMessagesOnConnectionRestart(connHandler.outputHandler,
container);
+
server.globalForeverClient.queuePendingMessagesOnConnectionRestart(connHandler.outputHandler,
container);
}
watchGlobal = true;
}
@@ -250,14 +256,14 @@
}
}
- public synchronized ClientRequest getRequest(String identifier) {
+ public synchronized ClientRequest getRequest(String identifier,
ObjectContainer container) {
return (ClientRequest)
clientRequestsByIdentifier.get(identifier);
}
/**
* Start all delayed-start requests.
*/
- public void finishStart() {
+ public void finishStart(ObjectContainer container) {
ClientRequest[] reqs;
synchronized(this) {
reqs = (ClientRequest[]) toStart.toArray(new
ClientRequest[toStart.size()]);