Author: toad
Date: 2008-12-12 18:56:20 +0000 (Fri, 12 Dec 2008)
New Revision: 24280
Modified:
trunk/freenet/src/freenet/node/Version.java
trunk/freenet/src/freenet/node/updater/NodeUpdateManager.java
trunk/freenet/src/freenet/node/updater/NodeUpdater.java
Log:
Implement bug #2786: Don't deploy a new main jar until we have a compatible ext
jar.
If we get a new main jar which requires an ext jar we don't have, fetch the new
ext jar.
If we need to, cancel the fetch for the old incompatible ext jar.
Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2008-12-12 18:06:28 UTC (rev
24279)
+++ trunk/freenet/src/freenet/node/Version.java 2008-12-12 18:56:20 UTC (rev
24280)
@@ -24,7 +24,7 @@
public static final String protocolVersion = "1.0";
/** The build number of the current revision */
- private static final int buildNumber = 1193;
+ private static final int buildNumber = 1192;
/** Oldest build of Fred we will talk to */
private static final int oldLastGoodBuild = 1192;
Modified: trunk/freenet/src/freenet/node/updater/NodeUpdateManager.java
===================================================================
--- trunk/freenet/src/freenet/node/updater/NodeUpdateManager.java
2008-12-12 18:06:28 UTC (rev 24279)
+++ trunk/freenet/src/freenet/node/updater/NodeUpdateManager.java
2008-12-12 18:56:20 UTC (rev 24280)
@@ -80,6 +80,9 @@
private long startedFetchingNextExtJar;
private long gotJarTime;
+ private int minExtVersion;
+ private int maxExtVersion;
+
// Revocation alert
private RevocationKeyFoundUserAlert revocationAlert;
// Update alert
@@ -155,6 +158,9 @@
this.uom = new UpdateOverMandatoryManager(this);
this.uom.removeOldTempFiles();
+
+ maxExtVersion = NodeStarter.RECOMMENDED_EXT_BUILD_NUMBER;
+ minExtVersion = NodeStarter.REQUIRED_EXT_BUILD_NUMBER;
}
public void start() throws InvalidConfigValueException {
@@ -235,8 +241,8 @@
throw new
InvalidConfigValueException(l10n("noUpdateWithoutWrapper"));
}
// Start it
- mainUpdater = new NodeUpdater(this, updateURI,
false, Version.buildNumber(), Integer.MAX_VALUE, "main-jar-");
- extUpdater = new NodeUpdater(this, extURI,
true, NodeStarter.extBuildNumber, NodeStarter.RECOMMENDED_EXT_BUILD_NUMBER,
"ext-jar-");
+ mainUpdater = new NodeUpdater(this, updateURI,
false, Version.buildNumber(), -1, Integer.MAX_VALUE, "main-jar-");
+ extUpdater = new NodeUpdater(this, extURI,
true, NodeStarter.extBuildNumber, NodeStarter.REQUIRED_EXT_BUILD_NUMBER,
NodeStarter.RECOMMENDED_EXT_BUILD_NUMBER, "ext-jar-");
}
}
if(!enable) {
@@ -357,6 +363,11 @@
if(logMINOR) Logger.minor(this, "Not ready:
Still fetching");
return false; // Wait for running fetch to
complete
}
+ int extVer = getReadyExt();
+ if(extVer < minExtVersion || extVer > maxExtVersion) {
+ if(logMINOR) Logger.minor(this, "Invalid ext:
current "+extVer+" must be between "+minExtVersion+" and "+maxExtVersion);
+ return false;
+ }
if(!ignoreRevocation) {
if(now - revocationChecker.lastSucceeded() <
RECENT_REVOCATION_INTERVAL)
return true;
@@ -411,6 +422,11 @@
if(logMINOR) Logger.minor(this, "Not
ready to deploy update");
return;
}
+ int extVer = getReadyExt();
+ if(extVer < minExtVersion || extVer >
maxExtVersion) {
+ if(logMINOR) Logger.minor(this,
"Invalid ext: current "+extVer+" must be between "+minExtVersion+" and
"+maxExtVersion);
+ return;
+ }
if(isDeployingUpdate) {
if(logMINOR) Logger.minor(this,
"Already deploying update");
return;
@@ -624,12 +640,28 @@
Logger.minor(this, "Got main
jar: "+mainUpdater.getFetchedVersion());
}
}
+ if(!isExt) {
+ if(requiredExt > -1)
+ minExtVersion = requiredExt;
+ if(recommendedExt > -1)
+ maxExtVersion = recommendedExt;
+ }
}
+ if(!isExt && (requiredExt > -1 || recommendedExt > -1)) {
+ extUpdater.setMinMax(requiredExt, recommendedExt);
+ }
revocationChecker.start(true);
deployOffThread(REVOCATION_FETCH_TIMEOUT);
if(!isAutoUpdateAllowed)
broadcastUOMAnnounces();
}
+
+ private int getReadyExt() {
+ int ver = NodeStarter.extBuildNumber;
+ int fetched = extUpdater.getFetchedVersion();
+ if(fetched > -1) ver = fetched;
+ return ver;
+ }
/**
* Called when the NodeUpdater starts to fetch a new version of the jar.
Modified: trunk/freenet/src/freenet/node/updater/NodeUpdater.java
===================================================================
--- trunk/freenet/src/freenet/node/updater/NodeUpdater.java 2008-12-12
18:06:28 UTC (rev 24279)
+++ trunk/freenet/src/freenet/node/updater/NodeUpdater.java 2008-12-12
18:56:20 UTC (rev 24280)
@@ -45,18 +45,20 @@
private final Node node;
public final NodeUpdateManager manager;
private final int currentVersion;
+ private int realAvailableVersion;
private int availableVersion;
private int fetchingVersion;
private int fetchedVersion;
private int writtenVersion;
private int maxDeployVersion;
+ private int minDeployVersion;
private boolean isRunning;
private boolean isFetching;
public final boolean extUpdate;
private final String blobFilenamePrefix;
private File tempBlobFile;
- NodeUpdater(NodeUpdateManager manager, FreenetURI URI, boolean
extUpdate, int current, int max, String blobFilenamePrefix) {
+ NodeUpdater(NodeUpdateManager manager, FreenetURI URI, boolean
extUpdate, int current, int min, int max, String blobFilenamePrefix) {
logMINOR = Logger.shouldLog(Logger.MINOR, this);
this.manager = manager;
this.node = manager.node;
@@ -71,6 +73,7 @@
this.extUpdate = extUpdate;
this.blobFilenamePrefix = blobFilenamePrefix;
this.maxDeployVersion = max;
+ this.minDeployVersion = min;
FetchContext tempContext = core.makeClient((short) 0,
true).getFetchContext();
tempContext.allowSplitfiles = true;
@@ -94,20 +97,28 @@
logMINOR = Logger.shouldLog(Logger.MINOR, this);
if(logMINOR)
Logger.minor(this, "Found edition " + l);
- System.err.println("Found " + (extUpdate ? "freenet-ext.jar " :
"") + "update edition " + l);
int found;
synchronized(this) {
if(!isRunning)
return;
found = (int) key.suggestedEdition;
- if(found > maxDeployVersion) found = maxDeployVersion;
+ realAvailableVersion = found;
+ if(found > maxDeployVersion) {
+ System.err.println("Ignoring "+(extUpdate ?
"freenet-ext.jar " : "") + "update edition "+l);
+ found = maxDeployVersion;
+ }
if(found <= availableVersion)
return;
+ System.err.println("Found " + (extUpdate ?
"freenet-ext.jar " : "") + "update edition " + found);
Logger.minor(this, "Updating availableVersion from " +
availableVersion + " to " + found + " and queueing an update");
this.availableVersion = found;
}
+ finishOnFoundEdition(found);
+ }
+
+ private void finishOnFoundEdition(int found) {
ticker.queueTimedJob(new Runnable() {
public void run() {
@@ -125,6 +136,7 @@
return;
if(manager.isBlown())
return;
+ ClientGetter cancelled = null;
synchronized(this) {
if(logMINOR)
Logger.minor(this, "maybeUpdate: isFetching=" +
isFetching + ", isRunning=" + isRunning + ", availableVersion=" +
availableVersion);
@@ -134,6 +146,11 @@
return;
if(availableVersion <= fetchedVersion)
return;
+ if(fetchingVersion < minDeployVersion) {
+ Logger.normal(this, "Cancelling previous
fetch");
+ cancelled = cg;
+ cg = null;
+ }
fetchingVersion = availableVersion;
if(availableVersion > currentVersion) {
@@ -157,6 +174,8 @@
uri, ctx,
RequestStarter.IMMEDIATE_SPLITFILE_PRIORITY_CLASS,
this, null, new
FileBucket(tempBlobFile, false, false, false, false, false));
toStart = cg;
+ } else {
+ System.err.println("Already fetching
"+(extUpdate ? "freenet-ext.jar " : "") + "fetch for " + fetchingVersion + "
want "+availableVersion);
}
isFetching = true;
} catch(Exception e) {
@@ -173,6 +192,8 @@
isFetching = false;
}
}
+ if(cancelled != null)
+ cancelled.cancel();
}
File getBlobFile(int availableVersion) {
@@ -263,6 +284,7 @@
String name = ze.getName();
if(name.equals("META-INF/MANIFEST.MF")) {
+ if(logMINOR)
Logger.minor(this, "Found manifest");
long size =
ze.getSize();
if(logMINOR)
Logger.minor(this, "Manifest size: "+size);
if(size >
MAX_MANIFEST_SIZE) {
@@ -446,4 +468,28 @@
public short getPollingPriorityProgress() {
return RequestStarter.INTERACTIVE_PRIORITY_CLASS;
}
+
+ public void setMinMax(int requiredExt, int recommendedExt) {
+ int callFinishedFound = -1;
+ synchronized(this) {
+ if(recommendedExt > -1) {
+ maxDeployVersion = recommendedExt;
+ if(realAvailableVersion != availableVersion &&
realAvailableVersion <= recommendedExt) {
+ // We found a revision but didn't fetch
it because it was after the old range.
+ System.err.println("Have found edition
"+realAvailableVersion+" but ignored it because out of range, fetching as
required by new jar");
+ callFinishedFound = availableVersion =
realAvailableVersion;
+ }
+ }
+ if(requiredExt > -1) {
+ minDeployVersion = requiredExt;
+ if(callFinishedFound == -1 && availableVersion
< requiredExt) { // Including if it hasn't been found at all
+ // Just try it ...
+ callFinishedFound = availableVersion =
requiredExt;
+ System.err.println("Need minimum
edition "+requiredExt+" for new jar, fetching...");
+ }
+ }
+ }
+ if(callFinishedFound > -1)
+ finishOnFoundEdition(callFinishedFound);
+ }
}
_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs