This commit is contained in:
zzz
2012-10-18 01:29:14 +00:00
parent f9b8f0528d
commit af4786ce0e

View File

@ -74,6 +74,7 @@ public class ConsoleUpdateManager implements UpdateManager {
private volatile String _status; private volatile String _status;
private static final long DEFAULT_MAX_TIME = 3*60*60*1000L; private static final long DEFAULT_MAX_TIME = 3*60*60*1000L;
private static final long DEFAULT_CHECK_TIME = 60*1000;
public ConsoleUpdateManager(RouterContext ctx) { public ConsoleUpdateManager(RouterContext ctx) {
_context = ctx; _context = ctx;
@ -162,7 +163,12 @@ public class ConsoleUpdateManager implements UpdateManager {
for (RegisteredChecker r : _registeredCheckers) { for (RegisteredChecker r : _registeredCheckers) {
if (r.type == type) { if (r.type == type) {
String current = getDownloadedOrInstalledVersion(type, id); String current = getDownloadedOrInstalledVersion(type, id);
UpdateTask t = r.checker.check(type, r.method, id, current, maxWait); UpdateTask t;
synchronized(_activeCheckers) {
t = r.checker.check(type, r.method, id, current, maxWait);
if (t != null)
_activeCheckers.add(t);
}
if (t != null) { if (t != null) {
synchronized(t) { synchronized(t) {
try { try {
@ -189,9 +195,13 @@ public class ConsoleUpdateManager implements UpdateManager {
for (RegisteredChecker r : _registeredCheckers) { for (RegisteredChecker r : _registeredCheckers) {
if (r.type == type) { if (r.type == type) {
String current = getDownloadedOrInstalledVersion(type, id); String current = getDownloadedOrInstalledVersion(type, id);
UpdateTask t = r.checker.check(type, r.method, id, current, 5*60*1000); synchronized(_activeCheckers) {
if (t != null) UpdateTask t = r.checker.check(type, r.method, id, current, DEFAULT_CHECK_TIME);
break; if (t != null) {
_activeCheckers.add(t);
break;
}
}
} }
} }
} }
@ -340,10 +350,12 @@ public class ConsoleUpdateManager implements UpdateManager {
* Stop all checks in progress * Stop all checks in progress
*/ */
public void stopChecks() { public void stopChecks() {
for (UpdateTask t : _activeCheckers) { synchronized(_activeCheckers) {
t.shutdown(); for (UpdateTask t : _activeCheckers) {
t.shutdown();
}
_activeCheckers.clear();
} }
_activeCheckers.clear();
} }
/** /**
@ -458,11 +470,13 @@ public class ConsoleUpdateManager implements UpdateManager {
// check in case unregistered later // check in case unregistered later
if (!_registeredUpdaters.contains(r)) if (!_registeredUpdaters.contains(r))
continue; continue;
VersionAvailable va = _available.get(ui);
String newVer = va != null ? va.version : "";
for (Map.Entry<UpdateMethod, List<URI>> e : sourceMap.entrySet()) { for (Map.Entry<UpdateMethod, List<URI>> e : sourceMap.entrySet()) {
UpdateMethod meth = e.getKey(); UpdateMethod meth = e.getKey();
if (r.type == ui.type && r.method == meth) { if (r.type == ui.type && r.method == meth) {
// fixme UpdateTask t = r.updater.update(ui.type, meth, e.getValue(),
UpdateTask t = r.updater.update(ui.type, meth, e.getValue(), ui.id, "", maxTime); ui.id, newVer, maxTime);
if (t != null) { if (t != null) {
// race window here // race window here
// store the remaining ones for retrying // store the remaining ones for retrying
@ -602,7 +616,9 @@ public class ConsoleUpdateManager implements UpdateManager {
public void notifyCheckComplete(UpdateTask task, boolean newer, boolean success) { public void notifyCheckComplete(UpdateTask task, boolean newer, boolean success) {
if (_log.shouldLog(Log.INFO)) if (_log.shouldLog(Log.INFO))
_log.info(task.toString() + " complete"); _log.info(task.toString() + " complete");
_activeCheckers.remove(task); synchronized(_activeCheckers) {
_activeCheckers.remove(task);
}
String msg = null; String msg = null;
switch (task.getType()) { switch (task.getType()) {
case NEWS: case NEWS: