diff --git a/apps/routerconsole/java/src/net/i2p/router/web/StatSummarizer.java b/apps/routerconsole/java/src/net/i2p/router/web/StatSummarizer.java index 75b62819cad98197560347cc6d4992773cc3a823..662df8f54b77204978f13f51528e3a448ea70dc7 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/StatSummarizer.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/StatSummarizer.java @@ -1,23 +1,14 @@ package net.i2p.router.web; -import java.awt.Color; -import java.awt.Graphics; -import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.io.OutputStream; -import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Date; import java.util.List; import java.util.StringTokenizer; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.Semaphore; -import javax.imageio.ImageIO; -import javax.imageio.stream.ImageOutputStream; -import javax.imageio.stream.MemoryCacheImageOutputStream; - import net.i2p.router.RouterContext; import net.i2p.stat.Rate; import net.i2p.stat.RateStat; @@ -25,18 +16,13 @@ import net.i2p.util.FileUtil; import net.i2p.util.Log; import net.i2p.util.SystemVersion; -import org.jrobin.core.RrdException; -import org.jrobin.graph.RrdGraph; -import org.jrobin.graph.RrdGraphDef; - /** * A thread started by RouterConsoleRunner that * checks the configuration for stats to be tracked via jrobin, * and adds or deletes RRDs as necessary. * * This also contains methods to generate xml or png image output. - * The actual png rendering code is here for the special dual-rate graph; - * the rendering for standard graphs is in SummaryRenderer. + * The rendering for graphs is in SummaryRenderer. * * To control memory, the number of simultaneous renderings is limited. * @@ -47,6 +33,7 @@ public class StatSummarizer implements Runnable { private final Log _log; /** list of SummaryListener instances */ private final List<SummaryListener> _listeners; + // TODO remove static instance private static StatSummarizer _instance; private static final int MAX_CONCURRENT_PNG = 3; private final Semaphore _sem; @@ -93,6 +80,18 @@ public class StatSummarizer implements Runnable { static boolean isDisabled() { return _instance == null || _instance._isDisabled; } + + /** + * Disable graph generation until restart + * See SummaryRenderer.render() + * @since 0.9.6 + */ + static void setDisabled() { + if (_instance != null) { + _instance._isDisabled = true; + _instance._isRunning = false; + } + } /** list of SummaryListener instances */ List<SummaryListener> getListeners() { return _listeners; } diff --git a/apps/routerconsole/java/src/net/i2p/router/web/SummaryRenderer.java b/apps/routerconsole/java/src/net/i2p/router/web/SummaryRenderer.java index e35e772d0990fe64b296ea99155e3461e68ebe38..811d160e075ad348b0ccc0bdf4a448b74f75297e 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/SummaryRenderer.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/SummaryRenderer.java @@ -229,7 +229,15 @@ class SummaryRenderer { def.setImageFormat("PNG"); def.setLazy(true); - RrdGraph graph = new RrdGraph(def); + RrdGraph graph; + try { + // NPE here if system is missing fonts - see ticket #915 + graph = new RrdGraph(def); + } catch (NullPointerException npe) { + _log.error("Error rendering", npe); + StatSummarizer.setDisabled(); + throw new IOException("Error rendering - disabling graph generation. Missing font? See http://trac.i2p2.i2p/ticket/915"); + } int totalWidth = graph.getRrdGraphInfo().getWidth(); int totalHeight = graph.getRrdGraphInfo().getHeight(); BufferedImage img = new BufferedImage(totalWidth, totalHeight, BufferedImage.TYPE_USHORT_565_RGB);