forked from I2P_Developers/i2p.i2p
Big refactor of the router console update subsystem, in preparation for
implementing out-of-console updaters like i2psnark. - Add new update interfaces in net.i2p.update - All update implementations moved to routerconsole update/ - Implement an UpdateManager that registers with the RouterContext - UpdateManager handles multiple types of things to update (router, plugins, news, ...) and methods of updating (HTTP, ...) - UpdateManager maintains list of installed, downloaded, and available versions of everything - Define Updaters that can check for a new version and/or download an item - Individual Updaters register with the UpdateManager obtained from I2PAppContext, identifying the type of update item and update method they can handle. - Updaters need only core libs, no router.jar or routerconsole access required. - All checks and updates are initiated via the UpdateManager. - All status on checks and updates in-progress or completed are obtained from the UpdateManager. No more use of System properties to broadcast update state. - All update and checker tasks are intantiated on demand and threaded; no more static references left over. - Split out the Runners and Checkers from the Handlers and make the inheritance more sane. - No more permanent NewsFetcher thread; run on the SimpleScheduler queue and thread a checker task only to fetch the news. - No more static NewsFetcher instance in routerconsole. All helper methods that are still required are moved to NewsHelper. The UpdateManager implements the policy for when to check and download. All requests go through the UpdateManager. For each update type, there's several parts: - The xxxUpdateHandler implements the Updater - The xxxUpdateChecker implements the UpdateTask for checking - The xxxUpdateRunner implements the UpdateTask for downloading New and moved classes: web/ update/ ---- ------- new ConsoleUpdateManager.java new PluginUpdateChecker.java from PluginUpdateChecker PluginUpdateChecker -> PluginUpdateHandler.java PluginUpdateHandler.java -> PluginUpdateRunner new UnsignedUpdateHandler.java UnsignedUpdateHandler -> UnsignedUpdateRunner.java new UnsignedUpdateChecker from NewsFetcher UpdateHandler.java remains new UpdateHandler.java new UpdateRunner.java from UpdateHandler move NewsHandler from NewsFetcher new NewsFetcher new NewsTimerTask new DummyHandler Initial checkin. Unfinished, untested, unpolished.
This commit is contained in:
@ -22,6 +22,7 @@ import net.i2p.router.transport.FIFOBandwidthLimiter;
|
||||
import net.i2p.router.transport.OutboundMessageRegistry;
|
||||
import net.i2p.router.tunnel.TunnelDispatcher;
|
||||
import net.i2p.router.tunnel.pool.TunnelPoolManager;
|
||||
import net.i2p.update.UpdateManager;
|
||||
import net.i2p.util.KeyRing;
|
||||
import net.i2p.util.I2PProperties.I2PPropertyCallback;
|
||||
|
||||
@ -55,11 +56,12 @@ public class RouterContext extends I2PAppContext {
|
||||
private Shitlist _shitlist;
|
||||
private Blocklist _blocklist;
|
||||
private MessageValidator _messageValidator;
|
||||
private UpdateManager _updateManager;
|
||||
//private MessageStateMonitor _messageStateMonitor;
|
||||
private RouterThrottle _throttle;
|
||||
private final Set<Runnable> _finalShutdownTasks;
|
||||
// split up big lock on this to avoid deadlocks
|
||||
private final Object _lock1 = new Object(), _lock2 = new Object();
|
||||
private final Object _lock1 = new Object(), _lock2 = new Object(), _lock3 = new Object();
|
||||
|
||||
private static List<RouterContext> _contexts = new ArrayList(1);
|
||||
|
||||
@ -481,6 +483,7 @@ public class RouterContext extends I2PAppContext {
|
||||
* @return true
|
||||
* @since 0.7.9
|
||||
*/
|
||||
@Override
|
||||
public boolean isRouterContext() {
|
||||
return true;
|
||||
}
|
||||
@ -490,7 +493,44 @@ public class RouterContext extends I2PAppContext {
|
||||
* @return the client manager
|
||||
* @since 0.8.3
|
||||
*/
|
||||
@Override
|
||||
public InternalClientManager internalClientManager() {
|
||||
return _clientManagerFacade;
|
||||
}
|
||||
|
||||
/**
|
||||
* The controller of router, plugin, and other updates.
|
||||
* @return The manager if it is registered, else null
|
||||
* @since 0.9.2
|
||||
*/
|
||||
@Override
|
||||
public UpdateManager updateManager() {
|
||||
return _updateManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register as the update manager.
|
||||
* @throws IllegalStateException if one was already registered
|
||||
* @since 0.9.2
|
||||
*/
|
||||
public void registerUpdateManager(UpdateManager mgr) {
|
||||
synchronized(_lock3) {
|
||||
if (_updateManager != null)
|
||||
throw new IllegalStateException();
|
||||
_updateManager = mgr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister the update manager.
|
||||
* @throws IllegalStateException if it was not registered
|
||||
* @since 0.9.2
|
||||
*/
|
||||
public void unregisterUpdateManager(UpdateManager mgr) {
|
||||
synchronized(_lock3) {
|
||||
if (_updateManager != mgr)
|
||||
throw new IllegalStateException();
|
||||
_updateManager = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user