Changeset 1324eaf


Ignore:
Timestamp:
Mar 17, 2011 5:16:28 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
033dee0
Parents:
2e5e3b9
Message:

cleanups and javadoc

Location:
apps/routerconsole/java/src/net/i2p/router/web
Files:
3 edited

Legend:

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

    r2e5e3b9 r1324eaf  
    2525
    2626/**
     27 *  A thread started by RouterConsoleRunner that
     28 *  checks the configuration for stats to be tracked via jrobin,
     29 *  and adds or deletes RRDs as necessary.
    2730 *
     31 *  This also contains methods to generate xml or png image output.
     32 *  The actual png rendering code is here for the special dual-rate graph;
     33 *  the rendering for standard graphs is in SummaryRenderer.
     34 *
     35 *  To control memory, the number of simultaneous renderings is limited.
     36 *
     37 *  @since 0.6.1.13
    2838 */
    2939public class StatSummarizer implements Runnable {
     
    149159                                    periodCount, showCredit);
    150160        } finally {
    151                 _sem.release();
     161            _sem.release();
    152162        }
    153163    }
     
    181191
    182192    public boolean getXML(Rate rate, OutputStream out) throws IOException {
     193        try {
     194            try {
     195                _sem.acquire();
     196            } catch (InterruptedException ie) {}
     197            return locked_getXML(rate, out);
     198        } finally {
     199            _sem.release();
     200        }
     201    }
     202
     203    private boolean locked_getXML(Rate rate, OutputStream out) throws IOException {
    183204        for (int i = 0; i < _listeners.size(); i++) {
    184205            SummaryListener lsnr = _listeners.get(i);
     
    209230                                        periodCount, showCredit);
    210231        } finally {
    211                 _sem.release();
     232            _sem.release();
    212233        }
    213234    }
  • apps/routerconsole/java/src/net/i2p/router/web/SummaryListener.java

    r2e5e3b9 r1324eaf  
    11package net.i2p.router.web;
    22
    3 import java.awt.Color;
    43import java.io.IOException;
    54import java.io.OutputStream;
     
    2221import org.jrobin.graph.RrdGraphDefTemplate;
    2322
     23/**
     24 *  Creates and updates the in-memory RRD database,
     25 *  and provides methods to generate graphs of the data
     26 *
     27 *  @since 0.6.1.13
     28 */
    2429class SummaryListener implements RateSummaryListener {
    25     private I2PAppContext _context;
    26     private Log _log;
    27     private Rate _rate;
     30    private final I2PAppContext _context;
     31    private final Log _log;
     32    private final Rate _rate;
    2833    private String _name;
    2934    private String _eventName;
     
    8792   
    8893    public Rate getRate() { return _rate; }
     94
    8995    public void startListening() {
    9096        RateStat rs = _rate.getRateStat();
     
    109115            _renderer = new SummaryRenderer(_context, this);
    110116            _rate.setSummaryListener(this);
     117            // Typical usage is 23456 bytes ~= 1440 * 16
     118            if (_log.shouldLog(Log.INFO))
     119                _log.info("New RRD " + baseName + " consuming " + _db.getRrdBackend().getLength() + " bytes");
    111120        } catch (RrdException re) {
    112121            _log.error("Error starting", re);
     
    115124        }
    116125    }
     126
    117127    public void stopListening() {
    118128        if (_db == null) return;
     
    126136        _db = null;
    127137    }
     138
    128139    public void renderPng(OutputStream out, int width, int height, boolean hideLegend, boolean hideGrid, boolean hideTitle, boolean showEvents, int periodCount, boolean showCredit) throws IOException {
    129140        _renderer.render(out, width, height, hideLegend, hideGrid, hideTitle, showEvents, periodCount, showCredit);
    130141    }
     142
    131143    public void renderPng(OutputStream out) throws IOException { _renderer.render(out); }
    132144 
    133145    String getName() { return _name; }
     146
    134147    String getEventName() { return _eventName; }
     148
    135149    RrdDb getData() { return _db; }
     150
    136151    long now() { return _context.clock().now(); }
    137152   
     
    140155        return ((obj instanceof SummaryListener) && ((SummaryListener)obj)._rate.equals(_rate));
    141156    }
     157
    142158    @Override
    143159    public int hashCode() { return _rate.hashCode(); }
  • apps/routerconsole/java/src/net/i2p/router/web/SummaryRenderer.java

    r2e5e3b9 r1324eaf  
    1919import net.i2p.util.Log;
    2020
    21 import org.jrobin.core.RrdBackendFactory;
    22 import org.jrobin.core.RrdDb;
    23 import org.jrobin.core.RrdDef;
    2421import org.jrobin.core.RrdException;
    25 import org.jrobin.core.RrdMemoryBackendFactory;
    26 import org.jrobin.core.Sample;
    2722import org.jrobin.graph.RrdGraph;
    2823import org.jrobin.graph.RrdGraphDef;
    2924import org.jrobin.graph.RrdGraphDefTemplate;
    3025
     26/**
     27 *  Generate the RRD graph png images,
     28 *  except for the combined rate graph, which is
     29 *  generated in StatSummarizer.
     30 *
     31 *  @since 0.6.1.13
     32 */
    3133class SummaryRenderer {
    32     private Log _log;
    33     private SummaryListener _listener;
    34     private I2PAppContext _context;
     34    private final Log _log;
     35    private final SummaryListener _listener;
     36    private final I2PAppContext _context;
    3537
    3638    public SummaryRenderer(I2PAppContext ctx, SummaryListener lsnr) {
Note: See TracChangeset for help on using the changeset viewer.