Changeset 78229227


Ignore:
Timestamp:
Dec 18, 2011 3:17:09 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
cefe20f
Parents:
61810b7
Message:
  • Router: Cleanup startup jobs and router.config reading; javadocs
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • history.txt

    r61810b7 r78229227  
     12011-12-18 zzz
     2  * Addresses: Add utility toString() methods
     3  * Blocklist: Buffer input to speed lookup
     4  * PersistentDataStore: Buffer file writes and reads
     5  * Router: Cleanup startup jobs and router.config reading; javadocs
     6  * Transport: Log tweaks
     7
    182011-12-17 kytv
    29  * Ukrainian translation updates from Transifex
  • router/java/src/net/i2p/router/Router.java

    r61810b7 r78229227  
    382382       
    383383        _context.keyManager().startup();
    384        
    385         // why are we reading this again, it's read in the constructor
    386         readConfig();
    387384       
    388385        setupHandlers();
  • router/java/src/net/i2p/router/RouterVersion.java

    r61810b7 r78229227  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 23;
     21    public final static long BUILD = 24;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/startup/BootCommSystemJob.java

    r61810b7 r78229227  
    4646        getContext().jobQueue().addJob(new StartAcceptingClientsJob(getContext()));
    4747
    48         getContext().jobQueue().addJob(new ReadConfigJob(getContext()));
     48        Job j = new ReadConfigJob(getContext());
     49        j.getTiming().setStartAfter(getContext().clock().now() + 60*1000);
     50        getContext().jobQueue().addJob(j);
    4951        ((RouterClock) getContext().clock()).addShiftListener(getContext().router());
    5052    }
  • router/java/src/net/i2p/router/startup/BuildTrustedLinksJob.java

    r61810b7 r78229227  
    1212import net.i2p.router.JobImpl;
    1313import net.i2p.router.RouterContext;
    14 import net.i2p.util.Log;
    1514
     15/**
     16 *  For future restricted routes. Does nothing now.
     17 */
    1618public class BuildTrustedLinksJob extends JobImpl {
    17     private Log _log;
    18     private Job _next;
     19    private final Job _next;
    1920   
    2021    public BuildTrustedLinksJob(RouterContext context, Job next) {
    2122        super(context);
    22         _log = getContext().logManager().getLog(BuildTrustedLinksJob.class);
    2323        _next = next;
    2424    }
  • router/java/src/net/i2p/router/startup/ClientAppConfig.java

    r61810b7 r78229227  
    7373
    7474    // let's keep this really simple
     75    // Following 4 may be edited in router console
    7576    public String className;
    7677    public String clientName;
    7778    public String args;
    78     public long delay;
    7979    public boolean disabled;
    80     /** @since 0.7.12 */
    81     public String classpath;
    82     /** @since 0.7.12 */
    83     public String stopargs;
    84     /** @since 0.7.12 */
    85     public String uninstallargs;
     80    public final long delay;
     81    /** @since 0.7.12 */
     82    public final String classpath;
     83    /** @since 0.7.12 */
     84    public final String stopargs;
     85    /** @since 0.7.12 */
     86    public final String uninstallargs;
    8687
    8788    public ClientAppConfig(String cl, String client, String a, long d, boolean dis) {
     89        this(cl, client, a, d, dis, null, null, null);
     90    }
     91
     92    /** @since 0.7.12 */
     93    public ClientAppConfig(String cl, String client, String a, long d, boolean dis, String cp, String sa, String ua) {
    8894        className = cl;
    8995        clientName = client;
     
    9197        delay = d;
    9298        disabled = dis;
    93     }
    94 
    95     /** @since 0.7.12 */
    96     public ClientAppConfig(String cl, String client, String a, long d, boolean dis, String cp, String sa, String ua) {
    97         this(cl, client, a, d, dis);
    9899        classpath = cp;
    99100        stopargs = sa;
  • router/java/src/net/i2p/router/startup/CreateRouterInfoJob.java

    r61810b7 r78229227  
    3131
    3232public class CreateRouterInfoJob extends JobImpl {
    33     private static Log _log = new Log(CreateRouterInfoJob.class);
     33    private final Log _log;
    3434    private final Job _next;
    3535   
     
    3737        super(ctx);
    3838        _next = next;
     39        _log = ctx.logManager().getLog(CreateRouterInfoJob.class);
    3940    }
    4041   
     
    125126     */
    126127    static long getCurrentPublishDate(RouterContext context) {
    127         _log.info("Setting published date to /now/");
     128        //_log.info("Setting published date to /now/");
    128129        return context.clock().now();
    129130    }
  • router/java/src/net/i2p/router/startup/LoadClientAppsJob.java

    r61810b7 r78229227  
    1818 */
    1919public class LoadClientAppsJob extends JobImpl {
    20     private Log _log;
     20    private final Log _log;
    2121    private static boolean _loaded = false;
    2222   
     
    5252
    5353    public static class DelayedRunClient extends JobImpl {
    54         private String _className;
    55         private String _clientName;
    56         private String _args[];
    57         private Log _log;
    58         private ThreadGroup _threadGroup;
    59         private ClassLoader _cl;
     54        private final String _className;
     55        private final String _clientName;
     56        private final String _args[];
     57        private final Log _log;
     58        private final ThreadGroup _threadGroup;
     59        private final ClassLoader _cl;
    6060
    6161        public DelayedRunClient(RouterContext enclosingContext, String className, String clientName, String args[], long delay) {
     
    212212
    213213    private final static class RunApp implements Runnable {
    214         private String _className;
    215         private String _appName;
    216         private String _args[];
    217         private Log _log;
    218         private ClassLoader _cl;
     214        private final String _className;
     215        private final String _appName;
     216        private final String _args[];
     217        private final Log _log;
     218        private final ClassLoader _cl;
    219219
    220220        public RunApp(String className, String appName, String args[], Log log, ClassLoader cl) {
     
    247247    public String getName() { return "Load up any client applications"; }
    248248   
     249/****
    249250    public static void main(String args[]) {
    250251        test(null);
     
    263264        System.out.println();
    264265    }
     266****/
    265267}
  • router/java/src/net/i2p/router/startup/ReadConfigJob.java

    r61810b7 r78229227  
    1313import net.i2p.router.JobImpl;
    1414import net.i2p.router.RouterContext;
     15import net.i2p.util.Log;
    1516
    1617/**
    17  * Simply read the router config
     18 * Simply read the router config periodically,
     19 * so that the user may make config changes externally.
     20 * This isn't advertised as a feature,
     21 * but it could be used, for example, to change bandwidth limits
     22 * at certain times of day.
     23 *
     24 * Unfortunately it will also read the file back in every time the
     25 * router writes it.
     26 *
     27 * So maybe this should just be disabled.
    1828 */
    1929public class ReadConfigJob extends JobImpl {
    2030    private final static long DELAY = 30*1000; // reread every 30 seconds
    21     private long _lastRead = -1;
     31    private long _lastRead;
    2232
    2333    public ReadConfigJob(RouterContext ctx) {
    2434        super(ctx);
     35        _lastRead = ctx.clock().now();
    2536    }
    2637   
    2738    public String getName() { return "Read Router Configuration"; }
     39
    2840    public void runJob() {
    29         if (shouldReread()) {
     41        File configFile = new File(getContext().router().getConfigFilename());
     42        if (shouldReread(configFile)) {
    3043            getContext().router().readConfig();
    3144            _lastRead = getContext().clock().now();
     45            Log log = getContext().logManager().getLog(ReadConfigJob.class);
     46            if (log.shouldLog(Log.WARN))
     47                log.warn("Reloaded " + configFile);
    3248        }
    3349        getTiming().setStartAfter(getContext().clock().now() + DELAY);
     
    3551    }
    3652   
    37     private boolean shouldReread() {
    38         File configFile = new File(getContext().router().getConfigFilename());
     53    private boolean shouldReread(File configFile) {
    3954        if (!configFile.exists()) return false;
    4055        if (configFile.lastModified() > _lastRead)
  • router/java/src/net/i2p/router/startup/StartAcceptingClientsJob.java

    r61810b7 r78229227  
    1111import net.i2p.router.JobImpl;
    1212import net.i2p.router.RouterContext;
    13 import net.i2p.util.Log;
    1413
    1514/** start I2CP interface */
    1615public class StartAcceptingClientsJob extends JobImpl {
    17     private Log _log;
    1816   
    1917    public StartAcceptingClientsJob(RouterContext context) {
    2018        super(context);
    21         _log = context.logManager().getLog(StartAcceptingClientsJob.class);
    2219    }
    2320   
  • router/java/src/net/i2p/router/startup/package.html

    r61810b7 r78229227  
    77            The startup consists of a number of different jobs, like loading data from files for the network database, creating new router information (keypairs), and so on.
    88        </p>
     9<p><pre>
     10
     11Calling order:
     12
     13StartupJob
     14        LoadClientAppsJob
     15                starts clients and queues delayed client jobs
     16        start stats publisher
     17        LoadRouterInfoJob
     18                RebuildRouterInfoJob if necessary
     19                        CreateRouterInfoJob if necessary
     20                BootCommSystemJob
     21                        allow parallel operation in job queue
     22                        BootNetworkDbJob
     23                                starts netdb
     24                        BuildTrustedLinksJob (never used)
     25                        BootPeerManagerJob
     26                                starts peer manager
     27                        start comm system
     28                        start tunnel manager
     29                        StartAcceptingClientsJob
     30                                starts client manager
     31                        ReadConfigJob
     32                                loops every 30 seconds
     33
     34</pre></p>
    935    </body>
    1036</html>
Note: See TracChangeset for help on using the changeset viewer.