public class GraphListener extends Object implements RateSummaryListener
| Modifier and Type | Field and Description |
|---|---|
(package private) static ConsolFun | CFConsolidation function used for RRD archives. |
(package private) static DsType | DSData source type used for RRD datasources. |
(package private) static int | GRAPH_END_OFFSET_SECONDSOffset (seconds) subtracted from "now" when computing the fetch window end,
so a clock skewed slightly ahead of system time does not yield NaNs. |
static int | MAX_ROWS |
(package private) static int | PERIODSNumber of periods in one day (1440 = 60 minutes * 24 hours at 1-minute resolution). |
static String | PROP_PERSISTENT |
(package private) static String | RRD_DIRnote that .jrb files are NOT compatible with .rrd files |
(package private) static String | RRD_PREFIXR r d p r e f i x |
(package private) static String | RRD_SUFFIXR r d s u f f i x |
| Constructor and Description |
|---|
GraphListener(Rate r)Create a listener for the given rate stat. |
| Modifier and Type | Method and Description |
|---|---|
void | add(double totalValue,
long eventCount,
double totalEventTime,
long period)Add a new data point to the RRD database. |
(package private) static String | createName(I2PAppContext ctx,
String wanted)JRobin can only deal with 20 character data source names, so we need to create a unique,
munged version from the user/developer-visible name. |
boolean | equals(Object obj)Compare with another listener by the underlying rate. |
(package private) RrdBackendFactory | getBackendFactory() |
(package private) RrdDb | getData()Get the RRD database instance. |
(package private) String | getEventName()Get the RRD datasource name for the event count. |
double[] | getLastValues(int count)Fetch the last count data points from the RRD database for use by the
dual-baseline minigraph renderer (data-rx/data-tx attributes on the canvas). |
(package private) String | getName()Get the RRD datasource name for the primary stat. |
Rate | getRate()Retrieve the tracked rate. |
(package private) int | getRows()Get the number of rows in the RRD archive. |
int | hashCode()Hash code based on the underlying rate. |
(package private) long | now()Get the current time from the router clock. |
void | renderGraph(OutputStream out)Render a graph of the stat data using default settings. |
void | renderGraph(OutputStream out,
int width,
int height,
boolean hideLegend,
boolean hideGrid,
boolean hideTitle,
boolean showEvents,
int periodCount,
int end,
boolean showCredit)Single graph. |
void | renderGraph(OutputStream out,
int width,
int height,
boolean hideLegend,
boolean hideGrid,
boolean hideTitle,
boolean showEvents,
int periodCount,
int end,
boolean showCredit,
GraphListener lsnr2,
String titleOverride,
boolean showRestarts)Single or two-data-source graph. |
boolean | startListening() |
void | stopListening()Stop listening and close the RRD database. |
static final ConsolFun CF
static final DsType DS
static final int GRAPH_END_OFFSET_SECONDS
public static final int MAX_ROWS
static final int PERIODS
public static final String PROP_PERSISTENT
static final String RRD_DIR
static final String RRD_PREFIX
static final String RRD_SUFFIX
public GraphListener(Rate r)
r - the rate to trackpublic void add(double totalValue,
long eventCount,
double totalEventTime,
long period)add in interface RateSummaryListenertotalValue - the total value for the periodeventCount - the number of events in the periodtotalEventTime - the total event time for the periodperiod - the period duration in millisecondsstatic String createName(I2PAppContext ctx, String wanted)
public boolean equals(Object obj)
RrdBackendFactory getBackendFactory()
RrdDb getData()
String getEventName()
public double[] getLastValues(int count)
count data points from the RRD database for use by the
dual-baseline minigraph renderer (data-rx/data-tx attributes on the canvas).
Points are right-aligned; the returned array is NaN-padded on the left when
fewer points are available.getLastValues in interface RateSummaryListenercount - number of most recent data points to retrieveString getName()
public Rate getRate()
int getRows()
public int hashCode()
long now()
public void renderGraph(OutputStream out) throws IOException
out - the output stream to write the graph toIOException - if rendering failspublic void renderGraph(OutputStream out, int width, int height, boolean hideLegend, boolean hideGrid, boolean hideTitle, boolean showEvents, int periodCount, int end, boolean showCredit) throws IOException
end - number of periods before nowIOExceptionpublic void renderGraph(OutputStream out, int width, int height, boolean hideLegend, boolean hideGrid, boolean hideTitle, boolean showEvents, int periodCount, int end, boolean showCredit, GraphListener lsnr2, String titleOverride, boolean showRestarts) throws IOException
lsnr2 - 2nd data source to plot on same graph, or null. Not recommended for events.titleOverride - If non-null, overrides the titleshowRestarts - if true, draw the vertical restart lines and "Router restarted" labelIOExceptionpublic boolean startListening()
public void stopListening()