* Console:

- Disable zh translation in graphs on windows due to font issues
      - Fix NPE at startup
      - Graph tweaks
This commit is contained in:
zzz
2011-05-23 19:22:33 +00:00
parent 6e4df8830a
commit 592361b1a4
8 changed files with 42 additions and 30 deletions

View File

@ -45,7 +45,7 @@ public class GraphHelper extends FormHandler {
/** /**
* This must be output in the jsp since <meta> must be in the <head> * This must be output in the jsp since <meta> must be in the <head>
* @since 0.8.6 * @since 0.8.7
*/ */
public String getRefreshMeta() { public String getRefreshMeta() {
if (_refreshDelaySeconds <= 8 || if (_refreshDelaySeconds <= 8 ||
@ -85,11 +85,11 @@ public class GraphHelper extends FormHandler {
} catch (NumberFormatException nfe) {} } catch (NumberFormatException nfe) {}
} }
/** @since 0.8.6 */ /** @since 0.8.7 */
public void setPersistent(String foo) { _persistent = true; } public void setPersistent(String foo) { _persistent = true; }
public String getImages() { public String getImages() {
if (StatSummarizer.instance().isDisabled()) if (StatSummarizer.isDisabled())
return ""; return "";
try { try {
List listeners = StatSummarizer.instance().getListeners(); List listeners = StatSummarizer.instance().getListeners();
@ -157,7 +157,7 @@ public class GraphHelper extends FormHandler {
private static final int[] times = { 60, 2*60, 5*60, 10*60, 30*60, 60*60, -1 }; private static final int[] times = { 60, 2*60, 5*60, 10*60, 30*60, 60*60, -1 };
public String getForm() { public String getForm() {
if (StatSummarizer.instance().isDisabled()) if (StatSummarizer.isDisabled())
return ""; return "";
String prev = System.getProperty("net.i2p.router.web.GraphHelper.nonce"); String prev = System.getProperty("net.i2p.router.web.GraphHelper.nonce");
if (prev != null) System.setProperty("net.i2p.router.web.GraphHelper.noncePrev", prev); if (prev != null) System.setProperty("net.i2p.router.web.GraphHelper.noncePrev", prev);
@ -204,11 +204,11 @@ public class GraphHelper extends FormHandler {
/** /**
* We have to do this here because processForm() isn't called unless the nonces are good * We have to do this here because processForm() isn't called unless the nonces are good
* @since 0.8.6 * @since 0.8.7
*/ */
@Override @Override
public String getAllMessages() { public String getAllMessages() {
if (StatSummarizer.instance().isDisabled()) { if (StatSummarizer.isDisabled()) {
addFormError("Graphing not supported with this JVM: " + addFormError("Graphing not supported with this JVM: " +
System.getProperty("java.vendor") + ' ' + System.getProperty("java.vendor") + ' ' +
System.getProperty("java.version") + " (" + System.getProperty("java.version") + " (" +

View File

@ -48,7 +48,7 @@ public class StatSummarizer implements Runnable {
private static final int MAX_CONCURRENT_PNG = 3; private static final int MAX_CONCURRENT_PNG = 3;
private final Semaphore _sem; private final Semaphore _sem;
private volatile boolean _isRunning = true; private volatile boolean _isRunning = true;
private volatile boolean _isDisabled; private boolean _isDisabled;
private Thread _thread; private Thread _thread;
public StatSummarizer() { public StatSummarizer() {
@ -88,9 +88,9 @@ public class StatSummarizer implements Runnable {
} }
} }
/** @since 0.8.6 */ /** @since 0.8.7 */
boolean isDisabled() { static boolean isDisabled() {
return _isDisabled; return _instance == null || _instance._isDisabled;
} }
/** list of SummaryListener instances */ /** list of SummaryListener instances */
@ -305,7 +305,7 @@ public class StatSummarizer implements Runnable {
def.setTitle(title); def.setTitle(title);
long started = _context.router().getWhenStarted(); long started = _context.router().getWhenStarted();
if (started > start && started < end) if (started > start && started < end)
def.vrule(started / 1000, Color.BLACK, null, 4.0f); // no room for legend def.vrule(started / 1000, SummaryRenderer.RESTART_BAR_COLOR, null, 4.0f); // no room for legend
String sendName = SummaryListener.createName(_context, "bw.sendRate.60000"); String sendName = SummaryListener.createName(_context, "bw.sendRate.60000");
String recvName = SummaryListener.createName(_context, "bw.recvRate.60000"); String recvName = SummaryListener.createName(_context, "bw.recvRate.60000");
def.datasource(sendName, txLsnr.getData().getPath(), sendName, SummaryListener.CF, txLsnr.getBackendName()); def.datasource(sendName, txLsnr.getData().getPath(), sendName, SummaryListener.CF, txLsnr.getBackendName());
@ -392,25 +392,27 @@ public class StatSummarizer implements Runnable {
/** /**
* Delete the old rrd dir if we are no longer persistent * Delete the old rrd dir if we are no longer persistent
* @since 0.8.6 * @since 0.8.7
*/ */
private void deleteOldRRDs() { private void deleteOldRRDs() {
File rrdDir = new File(_context.getRouterDir(), SummaryListener.RRD_DIR); File rrdDir = new File(_context.getRouterDir(), SummaryListener.RRD_DIR);
FileUtil.rmdir(rrdDir, false); FileUtil.rmdir(rrdDir, false);
} }
private static final boolean IS_WIN = System.getProperty("os.name").startsWith("Win");
/** translate a string */ /** translate a string */
private String _(String s) { private String _(String s) {
// the RRD font doesn't have zh chars, at least on my system // the RRD font doesn't have zh chars, at least on my system
// Works on 1.5.9 // Works on 1.5.9 except on windows
//if ("zh".equals(Messages.getLanguage(_context))) if (IS_WIN && "zh".equals(Messages.getLanguage(_context)))
// return s; return s;
return Messages.getString(s, _context); return Messages.getString(s, _context);
} }
/** /**
* Make sure any persistent RRDs are closed * Make sure any persistent RRDs are closed
* @since 0.8.6 * @since 0.8.7
*/ */
private class Shutdown implements Runnable { private class Shutdown implements Runnable {
public void run() { public void run() {

View File

@ -131,7 +131,7 @@ public class SummaryBarRenderer {
// .append(_("Jobs")) // .append(_("Jobs"))
// .append("</a>\n" + // .append("</a>\n" +
if (!StatSummarizer.instance().isDisabled()) { if (!StatSummarizer.isDisabled()) {
buf.append("<a href=\"/graphs\" target=\"_top\" title=\"") buf.append("<a href=\"/graphs\" target=\"_top\" title=\"")
.append(_("Graph router performance")) .append(_("Graph router performance"))
.append("\">") .append("\">")

View File

@ -34,6 +34,7 @@ class SummaryRenderer {
private final Log _log; private final Log _log;
private final SummaryListener _listener; private final SummaryListener _listener;
private final I2PAppContext _context; private final I2PAppContext _context;
static final Color RESTART_BAR_COLOR = new Color(255, 144, 0, 224);
public SummaryRenderer(I2PAppContext ctx, SummaryListener lsnr) { public SummaryRenderer(I2PAppContext ctx, SummaryListener lsnr) {
_log = ctx.logManager().getLog(SummaryRenderer.class); _log = ctx.logManager().getLog(SummaryRenderer.class);
@ -101,9 +102,9 @@ class SummaryRenderer {
String title; String title;
String p; String p;
// we want the formatting and translation of formatDuration2(), except not zh, and not the &nbsp; // we want the formatting and translation of formatDuration2(), except not zh, and not the &nbsp;
//if ("zh".equals(Messages.getLanguage(_context))) if (IS_WIN && "zh".equals(Messages.getLanguage(_context)))
// p = DataHelper.formatDuration(_listener.getRate().getPeriod()); p = DataHelper.formatDuration(_listener.getRate().getPeriod());
//else else
p = DataHelper.formatDuration2(_listener.getRate().getPeriod()).replace("&nbsp;", " "); p = DataHelper.formatDuration2(_listener.getRate().getPeriod()).replace("&nbsp;", " ");
if (showEvents) if (showEvents)
title = name + ' ' + _("events in {0}", p); title = name + ' ' + _("events in {0}", p);
@ -130,7 +131,7 @@ class SummaryRenderer {
} }
long started = ((RouterContext)_context).router().getWhenStarted(); long started = ((RouterContext)_context).router().getWhenStarted();
if (started > start && started < end) if (started > start && started < end)
def.vrule(started / 1000, Color.BLACK, _("Restart"), 4.0f); def.vrule(started / 1000, RESTART_BAR_COLOR, _("Restart"), 4.0f);
def.datasource(plotName, path, plotName, SummaryListener.CF, _listener.getBackendName()); def.datasource(plotName, path, plotName, SummaryListener.CF, _listener.getBackendName());
if (descr.length() > 0) if (descr.length() > 0)
def.area(plotName, Color.BLUE, descr + "\\r"); def.area(plotName, Color.BLUE, descr + "\\r");
@ -190,12 +191,14 @@ class SummaryRenderer {
} }
} }
private static final boolean IS_WIN = System.getProperty("os.name").startsWith("Win");
/** translate a string */ /** translate a string */
private String _(String s) { private String _(String s) {
// the RRD font doesn't have zh chars, at least on my system // the RRD font doesn't have zh chars, at least on my system
// Works on 1.5.9 // Works on 1.5.9 except on windows
//if ("zh".equals(Messages.getLanguage(_context))) if (IS_WIN && "zh".equals(Messages.getLanguage(_context)))
// return s; return s;
return Messages.getString(s, _context); return Messages.getString(s, _context);
} }
@ -204,9 +207,9 @@ class SummaryRenderer {
*/ */
private String _(String s, String o) { private String _(String s, String o) {
// the RRD font doesn't have zh chars, at least on my system // the RRD font doesn't have zh chars, at least on my system
// Works on 1.5.9 // Works on 1.5.9 except on windows
//if ("zh".equals(Messages.getLanguage(_context))) if (IS_WIN && "zh".equals(Messages.getLanguage(_context)))
// return s.replace("{0}", o); return s.replace("{0}", o);
return Messages.getString(s, o, _context); return Messages.getString(s, o, _context);
} }
} }

View File

@ -1,3 +1,10 @@
2011-05-23 zzz
* Console:
- Disable zh translation in graphs on windows due to font issues
- Force news refetch after URL change
- Fix NPE at startup
- Graph tweaks
2011-05-23 sponge 2011-05-23 sponge
* mbuild.sh fixups * mbuild.sh fixups
* add new jcpuid/mbuild.sh -- pedantic naming * add new jcpuid/mbuild.sh -- pedantic naming

View File

@ -469,7 +469,7 @@ div.graphspanel img {
text-align: center !important; text-align: center !important;
background: #000; background: #000;
opacity: 0.8; opacity: 0.9;
} }
div.graphspanel img:hover { div.graphspanel img:hover {

View File

@ -477,7 +477,7 @@ div.graphspanel img {
text-align: center !important; text-align: center !important;
background: #001; background: #001;
-moz-box-shadow: inset 0px 0px 1px 1px #99f; -moz-box-shadow: inset 0px 0px 1px 1px #99f;
opacity: 0.8; opacity: 0.9;
} }
div.graphspanel img:hover { div.graphspanel img:hover {

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */ /** deprecated */
public final static String ID = "Monotone"; public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION; public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 3; public final static long BUILD = 4;
/** for example "-test" */ /** for example "-test" */
public final static String EXTRA = ""; public final static String EXTRA = "";