Author: toad
Date: 2007-06-13 17:44:02 +0000 (Wed, 13 Jun 2007)
New Revision: 13564
Modified:
trunk/freenet/src/freenet/node/updater/NodeUpdateManager.java
trunk/freenet/src/freenet/node/updater/NodeUpdater.java
trunk/freenet/src/freenet/node/updater/RevocationChecker.java
Log:
More fixes to UOM
Modified: trunk/freenet/src/freenet/node/updater/NodeUpdateManager.java
===================================================================
--- trunk/freenet/src/freenet/node/updater/NodeUpdateManager.java
2007-06-13 17:27:20 UTC (rev 13563)
+++ trunk/freenet/src/freenet/node/updater/NodeUpdateManager.java
2007-06-13 17:44:02 UTC (rev 13564)
@@ -329,27 +329,33 @@
* Reason: we want to be able to deploy UOM updates on nodes with all
TOO NEW or leaf nodes
* whose peers are overloaded/broken. Note that with UOM, revocation
certs are automatically
* propagated node to node, so this should be *relatively* safe. Any
better ideas, tell us. */
- private static final int REVOCATION_FETCH_TIMEOUT = 5*60*1000;
+ private static final int REVOCATION_FETCH_TIMEOUT = 60*1000;
/** Does the updater have an update ready to deploy? May be called
synchronized(this) */
private boolean isReadyToDeployUpdate(boolean ignoreRevocation) {
long now = System.currentTimeMillis();
long startedMillisAgo;
synchronized(this) {
- if(!(hasNewMainJar || hasNewExtJar)) return false; //
no jar
+ if(!(hasNewMainJar || hasNewExtJar)) {
+ if(logMINOR) Logger.minor(this,
"hasNewMainJar="+hasNewMainJar+" hasNewExtJar="+hasNewExtJar);
+ return false; // no jar
+ }
if(hasBeenBlown) return false; // Duh
if(peersSayBlown) return false;
// Don't immediately deploy if still fetching
startedMillisAgo = now -
Math.max(startedFetchingNextMainJar, startedFetchingNextExtJar);
- if(startedMillisAgo < WAIT_FOR_SECOND_FETCH_TO_COMPLETE)
+ if(startedMillisAgo <
WAIT_FOR_SECOND_FETCH_TO_COMPLETE) {
+ if(logMINOR) Logger.minor(this, "Not ready:
Still fetching");
return false; // Wait for running fetch to
complete
+ }
if(!ignoreRevocation) {
if(now - revocationChecker.lastSucceeded() <
RECENT_REVOCATION_INTERVAL)
return true;
- if(revocationChecker.startedFetch > 0 && now -
revocationChecker.startedFetch > REVOCATION_FETCH_TIMEOUT)
+ if(revocationChecker.startedFetch > 0 && now -
revocationChecker.startedFetch >= REVOCATION_FETCH_TIMEOUT)
return true;
}
}
+ if(logMINOR) Logger.minor(this, "Still here in
isReadyToDeployUpdate");
// Apparently everything is ready except the revocation fetch.
So start it.
revocationChecker.start(true);
if(ignoreRevocation) return true;
@@ -375,10 +381,22 @@
return;
}
- if(!isEnabled()) return;
- if(!(isAutoUpdateAllowed || armed)) return;
- if(!isReadyToDeployUpdate(false)) return;
- if(isDeployingUpdate) return;
+ if(!isEnabled()) {
+ if(logMINOR) Logger.minor(this, "Not
enabled");
+ return;
+ }
+ if(!(isAutoUpdateAllowed || armed)) {
+ if(logMINOR) Logger.minor(this, "Not
armed");
+ return;
+ }
+ if(!isReadyToDeployUpdate(false)) {
+ if(logMINOR) Logger.minor(this, "Not
ready to deploy update");
+ return;
+ }
+ if(isDeployingUpdate) {
+ if(logMINOR) Logger.minor(this,
"Already deploying update");
+ return;
+ }
isDeployingUpdate = true;
}
Modified: trunk/freenet/src/freenet/node/updater/NodeUpdater.java
===================================================================
--- trunk/freenet/src/freenet/node/updater/NodeUpdater.java 2007-06-13
17:27:20 UTC (rev 13563)
+++ trunk/freenet/src/freenet/node/updater/NodeUpdater.java 2007-06-13
17:44:02 UTC (rev 13564)
@@ -184,19 +184,24 @@
logMINOR = Logger.shouldLog(Logger.MINOR, this);
boolean isNew;
synchronized(this) {
+ if(fetchedVersion < this.fetchedVersion) {
+ tempBlobFile.delete();
+ result.asBucket().free();
+ return;
+ }
if(result == null || result.asBucket() == null ||
result.asBucket().size() == 0) {
tempBlobFile.delete();
Logger.error(this, "Cannot update: result
either null or empty for "+availableVersion);
System.err.println("Cannot update: result
either null or empty for "+availableVersion);
// Try again
- if(result == null || result.asBucket() == null
|| availableVersion > fetchingVersion) {
+ if(result == null || result.asBucket() == null
|| availableVersion > fetchedVersion) {
node.ps.queueTimedJob(new Runnable() {
public void run() {
maybeUpdate(); }
}, 0);
}
return;
}
- File blobFile = getBlobFile(fetchingVersion);
+ File blobFile = getBlobFile(fetchedVersion);
if(!tempBlobFile.renameTo(blobFile)) {
blobFile.delete();
if(!tempBlobFile.renameTo(blobFile)) {
@@ -205,8 +210,8 @@
}
this.fetchedVersion = fetchedVersion;
if(fetchedVersion > currentVersion) {
- System.out.println("Found "+fetchingVersion);
- Logger.normal(this, "Found a new version! (" +
fetchingVersion + ", setting up a new UpdatedVersionAvailableUserAlert");
+ System.out.println("Found "+fetchedVersion);
+ Logger.normal(this, "Found a new version! (" +
fetchedVersion + ", setting up a new UpdatedVersionAvailableUserAlert");
}
this.cg = null;
if(this.result != null) this.result.asBucket().free();
Modified: trunk/freenet/src/freenet/node/updater/RevocationChecker.java
===================================================================
--- trunk/freenet/src/freenet/node/updater/RevocationChecker.java
2007-06-13 17:27:20 UTC (rev 13563)
+++ trunk/freenet/src/freenet/node/updater/RevocationChecker.java
2007-06-13 17:44:02 UTC (rev 13564)
@@ -90,9 +90,14 @@
if(revocationGetter != null &&
!(revocationGetter.isCancelled() || revocationGetter.isFinished())) {
if(logMINOR) Logger.minor(this, "Not
queueing another revocation fetcher yet, old one still running");
+ reset = false;
} else {
- if(reset)
+ if(reset) {
+ if(logMINOR) Logger.minor(this,
"Resetting DNF count from "+revocationDNFCounter, new Exception("debug"));
revocationDNFCounter = 0;
+ } else {
+ if(logMINOR) Logger.minor(this,
"Revocation count "+revocationDNFCounter);
+ }
if(logMINOR) Logger.minor(this,
"fetcher="+revocationGetter);
if(revocationGetter != null)
Logger.minor(this, "revocation
fetcher: cancelled="+revocationGetter.isCancelled()+",
finished="+revocationGetter.isFinished());
@@ -105,7 +110,7 @@
core.requestStarters.sskFetchScheduler, manager.revocationURI, ctxRevocation,
aggressive ?
RequestStarter.MAXIMUM_PRIORITY_CLASS :
RequestStarter.IMMEDIATE_SPLITFILE_PRIORITY_CLASS,
this, null, tmpBlobFile
== null ? null : new FileBucket(tmpBlobFile, false, false, false, false,
false));
- if(logMINOR) Logger.minor(this, "Queued
another revocation fetcher");
+ if(logMINOR) Logger.minor(this, "Queued
another revocation fetcher (count="+revocationDNFCounter+")");
}
}
if(toCancel != null)
@@ -113,7 +118,8 @@
if(cg != null) {
cg.start();
if(logMINOR) Logger.minor(this, "Started
revocation fetcher");
- startedFetch = System.currentTimeMillis();
+ if(reset)
+ startedFetch =
System.currentTimeMillis();
}
} catch (FetchException e) {
Logger.error(this, "Not able to start the revocation
fetcher.");