Changeset c4a3159


Ignore:
Timestamp:
Aug 30, 2012 2:06:06 PM (7 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
ee8cd29
Parents:
b01cf32
Message:

Replace ident log with new, general-purpose event log.
Use for stops, starts, and updates, and others.
Mark all restarts on graphs using the event log.

Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/src/net/i2p/router/web/SummaryRenderer.java

    rb01cf32 rc4a3159  
    88import java.text.SimpleDateFormat;
    99import java.util.Date;
     10import java.util.Map;
    1011
    1112import javax.imageio.ImageIO;
     
    1617import net.i2p.data.DataHelper;
    1718import net.i2p.router.RouterContext;
     19import net.i2p.router.util.EventLog;
    1820import net.i2p.util.Log;
    1921
     
    138140                descr = _(_listener.getRate().getRateStat().getDescription());
    139141            }
    140             long started = ((RouterContext)_context).router().getWhenStarted();
    141             if (started > start && started < end)
    142                 def.vrule(started / 1000, RESTART_BAR_COLOR, _("Restart"), 4.0f);
     142
     143            //long started = ((RouterContext)_context).router().getWhenStarted();
     144            //if (started > start && started < end)
     145            //    def.vrule(started / 1000, RESTART_BAR_COLOR, _("Restart"), 4.0f);
     146
    143147            def.datasource(plotName, path, plotName, SummaryListener.CF, _listener.getBackendName());
    144148            if (descr.length() > 0)
     
    152156                // '07-Jul 21:09 UTC' with month name in the system locale
    153157                SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM HH:mm");
     158                Map<Long, String> events = ((RouterContext)_context).router().eventLog().getEvents(EventLog.STARTED, start);
     159                for (Map.Entry<Long, String> event : events.entrySet()) {
     160                    long started = event.getKey().longValue();
     161                    if (started > start && started < end) {
     162                        String legend = _("Restart") + ' ' + sdf.format(new Date(started)) + " UTC " + event.getValue() + "\\r";
     163                        def.vrule(started / 1000, RESTART_BAR_COLOR, legend, 4.0f);
     164                    }
     165                }
    154166                def.comment(sdf.format(new Date(start)) + " -- " + sdf.format(new Date(end)) + " UTC\\r");
    155167            }
  • router/java/src/net/i2p/router/Router.java

    rb01cf32 rc4a3159  
    4141import net.i2p.router.transport.FIFOBandwidthLimiter;
    4242import net.i2p.router.transport.udp.UDPTransport;
     43import net.i2p.router.util.EventLog;
    4344import net.i2p.stat.RateStat;
    4445import net.i2p.stat.StatManager;
     
    7879    private RouterWatchdog _watchdog;
    7980    private Thread _watchdogThread;
     81    private final EventLog _eventLog;
    8082   
    8183    public final static String PROP_CONFIG_FILE = "router.configLocation";
     
    101103    public final static String PROP_SHUTDOWN_IN_PROGRESS = "__shutdownInProgress";
    102104    public final static String DNS_CACHE_TIME = "" + (5*60);
     105    private static final String EVENTLOG = "eventlog.txt";
    103106       
    104107    private static final String originalTimeZoneID;
     
    220223        // i2p.dir.base defaults to user.dir == $CWD
    221224        _context = new RouterContext(this, envProps);
     225        _eventLog = new EventLog(_context, new File(_context.getRouterDir(), EVENTLOG));
    222226
    223227        // This is here so that we can get the directory location from the context
     
    226230        // a NCDFE
    227231        if (!isOnlyRouterRunning()) {
     232            _eventLog.addEvent(EventLog.ABORTED, "Another router running");
    228233            System.err.println("ERROR: There appears to be another router already running!");
    229234            System.err.println("       Please make sure to shut down old instances before starting up");
     
    411416        if (_isAlive)
    412417            throw new IllegalStateException();
     418        _eventLog.addEvent(EventLog.STARTED, RouterVersion.FULL_VERSION);
    413419        startupStuff();
    414420        _isAlive = true;
     
    633639   
    634640    /**
     641     *  @since 0.9.3
     642     */
     643    public EventLog eventLog() {
     644        return _eventLog;
     645    }
     646   
     647    /**
    635648     * Ugly list of files that we need to kill if we are building a new identity
    636649     *
     
    647660                                                               };
    648661
    649     static final String IDENTLOG = "identlog.txt";
    650662    public void killKeys() {
    651663        //new Exception("Clearing identity files").printStackTrace();
     
    672684
    673685        if (remCount > 0) {
    674             FileOutputStream log = null;
    675             try {
    676                 log = new FileOutputStream(new File(_context.getRouterDir(), IDENTLOG), true);
    677                 log.write((new Date() + ": Old router identity keys cleared\n").getBytes());
    678             } catch (IOException ioe) {
    679                 // ignore
    680             } finally {
    681                 if (log != null)
    682                     try { log.close(); } catch (IOException ioe) {}
    683             }
    684         }
    685     }
     686            _eventLog.addEvent(EventLog.REKEYED);
     687        }
     688    }
     689
    686690    /**
    687691     * Rebuild a new identity the hard way - delete all of our old identity
     
    873877        }
    874878        _context.getFinalShutdownTasks().clear();
     879        _eventLog.addEvent(EventLog.STOPPED, Integer.toString(exitCode));
    875880
    876881        if (_killVMOnEnd) {
     
    11411146                _config.put("router.previousVersion", RouterVersion.VERSION);
    11421147                saveConfig();
     1148                _eventLog.addEvent(EventLog.UPDATED);
    11431149                ok = FileUtil.extractZip(updateFile, _context.getBaseDir());
    11441150            }
  • router/java/src/net/i2p/router/tasks/RouterWatchdog.java

    rb01cf32 rc4a3159  
    77import net.i2p.router.Router;
    88import net.i2p.router.RouterContext;
     9import net.i2p.router.util.EventLog;
    910import net.i2p.stat.Rate;
    1011import net.i2p.stat.RateStat;
     
    108109            if (_consecutiveErrors == 1) {
    109110                _log.log(Log.CRIT, "Router appears hung, or there is severe network congestion.  Watchdog starts barking!");
     111                 _context.router().eventLog().addEvent(EventLog.WATCHDOG);
    110112                // This works on linux...
    111113                // It won't on windows, and we can't call i2prouter.bat either, it does something
  • router/java/src/net/i2p/router/tasks/ShutdownHook.java

    rb01cf32 rc4a3159  
    1111import net.i2p.router.Router;
    1212import net.i2p.router.RouterContext;
     13import net.i2p.router.RouterVersion;
     14import net.i2p.router.util.EventLog;
    1315import net.i2p.util.Log;
    1416
     
    3638        // and thinks we haven't shut down, possibly because it
    3739        // prevents other shutdown hooks from running
     40        _context.router().eventLog().addEvent(EventLog.CRASHED, RouterVersion.FULL_VERSION);
    3841        _context.router().setKillVMOnEnd(false);
    3942        _context.router().shutdown2(Router.EXIT_HARD);
Note: See TracChangeset for help on using the changeset viewer.