forked from I2P_Developers/i2p.i2p
* Console:
- Disable zh translation in graphs on windows due to font issues - Fix NPE at startup - Graph tweaks
This commit is contained in:
@ -45,7 +45,7 @@ public class GraphHelper extends FormHandler {
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
if (_refreshDelaySeconds <= 8 ||
|
||||
@ -85,11 +85,11 @@ public class GraphHelper extends FormHandler {
|
||||
} catch (NumberFormatException nfe) {}
|
||||
}
|
||||
|
||||
/** @since 0.8.6 */
|
||||
/** @since 0.8.7 */
|
||||
public void setPersistent(String foo) { _persistent = true; }
|
||||
|
||||
public String getImages() {
|
||||
if (StatSummarizer.instance().isDisabled())
|
||||
if (StatSummarizer.isDisabled())
|
||||
return "";
|
||||
try {
|
||||
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 };
|
||||
|
||||
public String getForm() {
|
||||
if (StatSummarizer.instance().isDisabled())
|
||||
if (StatSummarizer.isDisabled())
|
||||
return "";
|
||||
String prev = System.getProperty("net.i2p.router.web.GraphHelper.nonce");
|
||||
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
|
||||
* @since 0.8.6
|
||||
* @since 0.8.7
|
||||
*/
|
||||
@Override
|
||||
public String getAllMessages() {
|
||||
if (StatSummarizer.instance().isDisabled()) {
|
||||
if (StatSummarizer.isDisabled()) {
|
||||
addFormError("Graphing not supported with this JVM: " +
|
||||
System.getProperty("java.vendor") + ' ' +
|
||||
System.getProperty("java.version") + " (" +
|
||||
|
@ -48,7 +48,7 @@ public class StatSummarizer implements Runnable {
|
||||
private static final int MAX_CONCURRENT_PNG = 3;
|
||||
private final Semaphore _sem;
|
||||
private volatile boolean _isRunning = true;
|
||||
private volatile boolean _isDisabled;
|
||||
private boolean _isDisabled;
|
||||
private Thread _thread;
|
||||
|
||||
public StatSummarizer() {
|
||||
@ -88,9 +88,9 @@ public class StatSummarizer implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
/** @since 0.8.6 */
|
||||
boolean isDisabled() {
|
||||
return _isDisabled;
|
||||
/** @since 0.8.7 */
|
||||
static boolean isDisabled() {
|
||||
return _instance == null || _instance._isDisabled;
|
||||
}
|
||||
|
||||
/** list of SummaryListener instances */
|
||||
@ -305,7 +305,7 @@ public class StatSummarizer implements Runnable {
|
||||
def.setTitle(title);
|
||||
long started = _context.router().getWhenStarted();
|
||||
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 recvName = SummaryListener.createName(_context, "bw.recvRate.60000");
|
||||
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
|
||||
* @since 0.8.6
|
||||
* @since 0.8.7
|
||||
*/
|
||||
private void deleteOldRRDs() {
|
||||
File rrdDir = new File(_context.getRouterDir(), SummaryListener.RRD_DIR);
|
||||
FileUtil.rmdir(rrdDir, false);
|
||||
}
|
||||
|
||||
private static final boolean IS_WIN = System.getProperty("os.name").startsWith("Win");
|
||||
|
||||
/** translate a string */
|
||||
private String _(String s) {
|
||||
// the RRD font doesn't have zh chars, at least on my system
|
||||
// Works on 1.5.9
|
||||
//if ("zh".equals(Messages.getLanguage(_context)))
|
||||
// return s;
|
||||
// Works on 1.5.9 except on windows
|
||||
if (IS_WIN && "zh".equals(Messages.getLanguage(_context)))
|
||||
return s;
|
||||
return Messages.getString(s, _context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure any persistent RRDs are closed
|
||||
* @since 0.8.6
|
||||
* @since 0.8.7
|
||||
*/
|
||||
private class Shutdown implements Runnable {
|
||||
public void run() {
|
||||
|
@ -131,7 +131,7 @@ public class SummaryBarRenderer {
|
||||
// .append(_("Jobs"))
|
||||
// .append("</a>\n" +
|
||||
|
||||
if (!StatSummarizer.instance().isDisabled()) {
|
||||
if (!StatSummarizer.isDisabled()) {
|
||||
buf.append("<a href=\"/graphs\" target=\"_top\" title=\"")
|
||||
.append(_("Graph router performance"))
|
||||
.append("\">")
|
||||
|
@ -34,6 +34,7 @@ class SummaryRenderer {
|
||||
private final Log _log;
|
||||
private final SummaryListener _listener;
|
||||
private final I2PAppContext _context;
|
||||
static final Color RESTART_BAR_COLOR = new Color(255, 144, 0, 224);
|
||||
|
||||
public SummaryRenderer(I2PAppContext ctx, SummaryListener lsnr) {
|
||||
_log = ctx.logManager().getLog(SummaryRenderer.class);
|
||||
@ -101,9 +102,9 @@ class SummaryRenderer {
|
||||
String title;
|
||||
String p;
|
||||
// we want the formatting and translation of formatDuration2(), except not zh, and not the
|
||||
//if ("zh".equals(Messages.getLanguage(_context)))
|
||||
// p = DataHelper.formatDuration(_listener.getRate().getPeriod());
|
||||
//else
|
||||
if (IS_WIN && "zh".equals(Messages.getLanguage(_context)))
|
||||
p = DataHelper.formatDuration(_listener.getRate().getPeriod());
|
||||
else
|
||||
p = DataHelper.formatDuration2(_listener.getRate().getPeriod()).replace(" ", " ");
|
||||
if (showEvents)
|
||||
title = name + ' ' + _("events in {0}", p);
|
||||
@ -130,7 +131,7 @@ class SummaryRenderer {
|
||||
}
|
||||
long started = ((RouterContext)_context).router().getWhenStarted();
|
||||
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());
|
||||
if (descr.length() > 0)
|
||||
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 */
|
||||
private String _(String s) {
|
||||
// the RRD font doesn't have zh chars, at least on my system
|
||||
// Works on 1.5.9
|
||||
//if ("zh".equals(Messages.getLanguage(_context)))
|
||||
// return s;
|
||||
// Works on 1.5.9 except on windows
|
||||
if (IS_WIN && "zh".equals(Messages.getLanguage(_context)))
|
||||
return s;
|
||||
return Messages.getString(s, _context);
|
||||
}
|
||||
|
||||
@ -204,9 +207,9 @@ class SummaryRenderer {
|
||||
*/
|
||||
private String _(String s, String o) {
|
||||
// the RRD font doesn't have zh chars, at least on my system
|
||||
// Works on 1.5.9
|
||||
//if ("zh".equals(Messages.getLanguage(_context)))
|
||||
// return s.replace("{0}", o);
|
||||
// Works on 1.5.9 except on windows
|
||||
if (IS_WIN && "zh".equals(Messages.getLanguage(_context)))
|
||||
return s.replace("{0}", o);
|
||||
return Messages.getString(s, o, _context);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user