This commit is contained in:
zzz
2011-03-17 02:07:08 +00:00
parent be4be9716d
commit 8461beba1c
5 changed files with 100 additions and 58 deletions

View File

@ -26,7 +26,7 @@
<pathelement location="../../systray/java/lib/systray4j.jar" />
<pathelement location="../../desktopgui/build" />
<pathelement location="../../../installer/lib/wrapper/win32/wrapper.jar" /> <!-- we dont care if we're not on win32 -->
<pathelement location="../../jrobin/jrobin-1.4.0.jar" />
<pathelement location="../../jrobin/jrobin-1.5.9.jar" />
</classpath>
</depend>
</target>
@ -58,7 +58,7 @@
<pathelement location="../../systray/java/lib/systray4j.jar" />
<pathelement location="../../desktopgui/dist/desktopgui.jar" />
<pathelement location="../../../installer/lib/wrapper/win32/wrapper.jar" /> <!-- we dont care if we're not on win32 -->
<pathelement location="../../jrobin/jrobin-1.4.0.jar" />
<pathelement location="../../jrobin/jrobin-1.5.9.jar" />
</classpath>
</javac>
</target>
@ -92,7 +92,7 @@
</jar>
<!-- jrobin taken out of routerconsole.jar in 0.7.12
<delete dir="./tmpextract" />
<unjar src="../../jrobin/jrobin-1.4.0.jar" dest="./tmpextract" />
<unjar src="../../jrobin/jrobin-1.5.9.jar" dest="./tmpextract" />
<jar destfile="./build/routerconsole.jar" basedir="./tmpextract" update="true" />
<delete dir="./tmpextract" />
-->

View File

@ -23,8 +23,8 @@ public class GraphHelper extends FormHandler {
private static final String PROP_REFRESH = "routerconsole.graphRefresh";
private static final String PROP_PERIODS = "routerconsole.graphPeriods";
private static final String PROP_EVENTS = "routerconsole.graphEvents";
private static final int DEFAULT_X = 250;
private static final int DEFAULT_Y = 100;
public static final int DEFAULT_X = 250;
public static final int DEFAULT_Y = 100;
private static final int DEFAULT_REFRESH = 60;
private static final int DEFAULT_PERIODS = 60;
static final int MAX_X = 2048;
@ -91,12 +91,11 @@ public class GraphHelper extends FormHandler {
+ "&amp;height=" + (3 * _height)
+ "\" target=\"_blank\">");
String title = _("Combined bandwidth graph");
_out.write("<img class=\"statimage\" width=\""
+ (_width + 83) + "\" height=\"" + (_height + 92)
+ "\" src=\"viewstat.jsp?stat=bw.combined"
_out.write("<img class=\"statimage\""
+ " src=\"viewstat.jsp?stat=bw.combined"
+ "&amp;periodCount=" + _periodCount
+ "&amp;width=" + _width
+ "&amp;height=" + (_height - 14)
+ "&amp;height=" + (_height - 13)
+ "\" alt=\"" + title + "\" title=\"" + title + "\"></a>\n");
}
@ -113,9 +112,8 @@ public class GraphHelper extends FormHandler {
+ "&amp;width=" + (3 * _width)
+ "&amp;height=" + (3 * _height)
+ "\" target=\"_blank\">");
_out.write("<img class=\"statimage\" border=\"0\" width=\""
+ (_width + 83) + "\" height=\"" + (_height + 92)
+ "\" src=\"viewstat.jsp?stat="
_out.write("<img class=\"statimage\" border=\"0\""
+ " src=\"viewstat.jsp?stat="
+ r.getRateStat().getName()
+ "&amp;showEvents=" + _showEvents
+ "&amp;period=" + r.getPeriod()

View File

@ -1,6 +1,8 @@
package net.i2p.router.web;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
@ -8,6 +10,10 @@ import java.util.List;
import java.util.StringTokenizer;
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;
@ -122,7 +128,8 @@ public class StatSummarizer implements Runnable {
}
public boolean renderPng(Rate rate, OutputStream out) throws IOException {
return renderPng(rate, out, -1, -1, false, false, false, false, -1, true);
return renderPng(rate, out, GraphHelper.DEFAULT_X, GraphHelper.DEFAULT_Y,
false, false, false, false, -1, true);
}
/**
@ -150,8 +157,12 @@ public class StatSummarizer implements Runnable {
boolean showCredit) throws IOException {
if (width > GraphHelper.MAX_X)
width = GraphHelper.MAX_X;
else if (width <= 0)
width = GraphHelper.DEFAULT_X;
if (height > GraphHelper.MAX_Y)
height = GraphHelper.MAX_Y;
else if (height <= 0)
height = GraphHelper.DEFAULT_Y;
for (int i = 0; i < _listeners.size(); i++) {
SummaryListener lsnr = _listeners.get(i);
if (lsnr.getRate().equals(rate)) {
@ -162,6 +173,7 @@ public class StatSummarizer implements Runnable {
return false;
}
/** @deprecated unused */
public boolean renderPng(OutputStream out, String templateFilename) throws IOException {
SummaryRenderer.render(_context, out, templateFilename);
return true;
@ -206,8 +218,12 @@ public class StatSummarizer implements Runnable {
long end = _context.clock().now() - 60*1000;
if (width > GraphHelper.MAX_X)
width = GraphHelper.MAX_X;
else if (width <= 0)
width = GraphHelper.DEFAULT_X;
if (height > GraphHelper.MAX_Y)
height = GraphHelper.MAX_Y;
else if (height <= 0)
height = GraphHelper.DEFAULT_Y;
if (periodCount <= 0) periodCount = SummaryListener.PERIODS;
if (periodCount > SummaryListener.PERIODS)
periodCount = SummaryListener.PERIODS;
@ -216,9 +232,9 @@ public class StatSummarizer implements Runnable {
//long begin = System.currentTimeMillis();
try {
RrdGraphDef def = new RrdGraphDef();
def.setTimePeriod(start/1000, 0);
def.setLowerLimit(0d);
def.setBaseValue(1024);
def.setTimeSpan(start/1000, end/1000);
def.setMinValue(0d);
def.setBase(1024);
// Note to translators: all runtime zh translation disabled in this file, no font available in RRD
String title = _("Bandwidth usage");
if (!hideTitle)
@ -227,37 +243,41 @@ public class StatSummarizer implements Runnable {
String recvName = SummaryListener.createName(_context, "bw.recvRate.60000");
def.datasource(sendName, sendName, sendName, "AVERAGE", "MEMORY");
def.datasource(recvName, recvName, recvName, "AVERAGE", "MEMORY");
def.area(sendName, Color.BLUE, _("Outbound bytes/sec"));
def.area(sendName, Color.BLUE, _("Outbound Bytes/sec"));
//def.line(sendName, Color.BLUE, "Outbound bytes/sec", 3);
def.line(recvName, Color.RED, _("Inbound bytes/sec") + "@r", 3);
def.line(recvName, Color.RED, _("Inbound Bytes/sec") + "\\r", 3);
//def.area(recvName, Color.RED, "Inbound bytes/sec@r");
if (!hideLegend) {
def.gprint(sendName, "AVERAGE", _("out average") + ": @2@s" + _("bytes/sec"));
def.gprint(sendName, "MAX", ' ' + _("max") + ": @2@s" + _("bytes/sec") + "@r");
def.gprint(recvName, "AVERAGE", _("in average") + ": @2@s" + _("bytes/sec"));
def.gprint(recvName, "MAX", ' ' + _("max") + ": @2@s" + _("bytes/sec") + "@r");
def.gprint(sendName, "AVERAGE", _("Out average") + ": %.2f %s" + _("Bps"));
def.gprint(sendName, "MAX", ' ' + _("max") + ": %.2f %S" + _("Bps") + "\\r");
def.gprint(recvName, "AVERAGE", _("In average") + ": %.2f %S" + _("Bps"));
def.gprint(recvName, "MAX", ' ' + _("max") + ": %.2f %S" + _("Bps") + "\\r");
}
if (!showCredit)
def.setShowSignature(false);
if (hideLegend)
def.setShowLegend(false);
def.setNoLegend(true);
if (hideGrid) {
def.setGridX(false);
def.setGridY(false);
def.setDrawXGrid(false);
def.setDrawYGrid(false);
}
//System.out.println("rendering: path=" + path + " dsNames[0]=" + dsNames[0] + " dsNames[1]=" + dsNames[1] + " lsnr.getName=" + _listener.getName());
def.setAntiAliasing(false);
//System.out.println("Rendering: \n" + def.exportXmlTemplate());
//System.out.println("*****************\nData: \n" + _listener.getData().dump());
def.setWidth(width);
def.setHeight(height);
RrdGraph graph = new RrdGraph(def);
//System.out.println("Graph created");
byte data[] = null;
if ( (width <= 0) || (height <= 0) )
data = graph.getPNGBytes();
else
data = graph.getPNGBytes(width, height);
//long timeToPlot = System.currentTimeMillis() - begin;
out.write(data);
int totalWidth = graph.getRrdGraphInfo().getWidth();
int totalHeight = graph.getRrdGraphInfo().getHeight();
BufferedImage img = new BufferedImage(totalWidth, totalHeight, BufferedImage.TYPE_USHORT_565_RGB);
Graphics gfx = img.getGraphics();
graph.render(gfx);
ImageOutputStream ios = new MemoryCacheImageOutputStream(out);
ImageIO.write(img, "png", ios);
//File t = File.createTempFile("jrobinData", ".xml");
//_listener.getData().dumpXml(new FileOutputStream(t));
//System.out.println("plotted: " + (data != null ? data.length : 0) + " bytes in " + timeToPlot

View File

@ -1,9 +1,16 @@
package net.i2p.router.web;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import javax.imageio.ImageIO;
import javax.imageio.stream.ImageOutputStream;
import javax.imageio.stream.MemoryCacheImageOutputStream;
import net.i2p.I2PAppContext;
import net.i2p.data.DataHelper;
import net.i2p.stat.Rate;
@ -38,6 +45,7 @@ class SummaryRenderer {
* DOM level 3 load and store support. Perhaps we can bundle that, or
* specify who can get it from where, etc.
*
* @deprecated unsed
*/
public static synchronized void render(I2PAppContext ctx, OutputStream out, String filename) throws IOException {
long end = ctx.clock().now() - 60*1000;
@ -45,10 +53,21 @@ class SummaryRenderer {
try {
RrdGraphDefTemplate template = new RrdGraphDefTemplate(filename);
RrdGraphDef def = template.getRrdGraphDef();
def.setTimePeriod(start/1000, end/1000); // ignore the periods in the template
def.setTimeSpan(start/1000, end/1000); // ignore the periods in the template
// FIXME not clear how to get the height and width from the template
int width = GraphHelper.DEFAULT_X;
int height = GraphHelper.DEFAULT_Y;
def.setWidth(width);
def.setHeight(height);
RrdGraph graph = new RrdGraph(def);
byte img[] = graph.getPNGBytes();
out.write(img);
int totalWidth = graph.getRrdGraphInfo().getWidth();
int totalHeight = graph.getRrdGraphInfo().getHeight();
BufferedImage img = new BufferedImage(totalWidth, totalHeight, BufferedImage.TYPE_USHORT_565_RGB);
Graphics gfx = img.getGraphics();
graph.render(gfx);
ImageOutputStream ios = new MemoryCacheImageOutputStream(out);
ImageIO.write(img, "png", ios);
} catch (RrdException re) {
//_log.error("Error rendering " + filename, re);
throw new IOException("Error plotting: " + re.getMessage());
@ -58,7 +77,8 @@ class SummaryRenderer {
}
}
public void render(OutputStream out) throws IOException { render(out, -1, -1, false, false, false, false, -1, false); }
public void render(OutputStream out) throws IOException { render(out, GraphHelper.DEFAULT_X, GraphHelper.DEFAULT_Y,
false, false, false, false, -1, false); }
public void render(OutputStream out, int width, int height, boolean hideLegend, boolean hideGrid, boolean hideTitle, boolean showEvents, int periodCount, boolean showCredit) throws IOException {
long end = _listener.now() - 60*1000;
@ -69,13 +89,13 @@ class SummaryRenderer {
//long begin = System.currentTimeMillis();
try {
RrdGraphDef def = new RrdGraphDef();
def.setTimePeriod(start/1000, 0);
def.setLowerLimit(0d);
def.setTimeSpan(start/1000, end/1000);
def.setMinValue(0d);
String name = _listener.getRate().getRateStat().getName();
// heuristic to set K=1024
if ((name.startsWith("bw.") || name.indexOf("Size") >= 0 || name.indexOf("Bps") >= 0 || name.indexOf("memory") >= 0)
&& !showEvents)
def.setBaseValue(1024);
def.setBase(1024);
if (!hideTitle) {
String title;
String p;
@ -109,11 +129,11 @@ class SummaryRenderer {
descr = _(_listener.getRate().getRateStat().getDescription());
}
def.datasource(plotName, path, plotName, "AVERAGE", "MEMORY");
def.area(plotName, Color.BLUE, descr + "@r");
def.area(plotName, Color.BLUE, descr + "\\r");
if (!hideLegend) {
def.gprint(plotName, "AVERAGE", _("avg") + ": @2@s");
def.gprint(plotName, "MAX", ' ' + _("max") + ": @2@s");
def.gprint(plotName, "LAST", ' ' + _("now") + ": @2@s@r");
def.gprint(plotName, "AVERAGE", _("avg") + ": %.2f %s");
def.gprint(plotName, "MAX", ' ' + _("max") + ": %.2f %S");
def.gprint(plotName, "LAST", ' ' + _("now") + ": %.2f %S\\r");
}
if (!showCredit)
def.setShowSignature(false);
@ -126,24 +146,28 @@ class SummaryRenderer {
def.line(dsNames[1], Color.RED, "Events per period");
*/
if (hideLegend)
def.setShowLegend(false);
def.setNoLegend(true);
if (hideGrid) {
def.setGridX(false);
def.setGridY(false);
def.setDrawXGrid(false);
def.setDrawYGrid(false);
}
//System.out.println("rendering: path=" + path + " dsNames[0]=" + dsNames[0] + " dsNames[1]=" + dsNames[1] + " lsnr.getName=" + _listener.getName());
def.setAntiAliasing(false);
//System.out.println("Rendering: \n" + def.exportXmlTemplate());
//System.out.println("*****************\nData: \n" + _listener.getData().dump());
def.setWidth(width);
def.setHeight(height);
RrdGraph graph = new RrdGraph(def);
int totalWidth = graph.getRrdGraphInfo().getWidth();
int totalHeight = graph.getRrdGraphInfo().getHeight();
BufferedImage img = new BufferedImage(totalWidth, totalHeight, BufferedImage.TYPE_USHORT_565_RGB);
Graphics gfx = img.getGraphics();
graph.render(gfx);
ImageOutputStream ios = new MemoryCacheImageOutputStream(out);
ImageIO.write(img, "png", ios);
//System.out.println("Graph created");
byte data[] = null;
if ( (width <= 0) || (height <= 0) )
data = graph.getPNGBytes();
else
data = graph.getPNGBytes(width, height);
//long timeToPlot = System.currentTimeMillis() - begin;
out.write(data);
//File t = File.createTempFile("jrobinData", ".xml");
//_listener.getData().dumpXml(new FileOutputStream(t));
//System.out.println("plotted: " + (data != null ? data.length : 0) + " bytes in " + timeToPlot

View File

@ -293,7 +293,7 @@
<pathelement location="apps/jetty/jettylib/org.mortbay.jetty.jar" />
<pathelement location="apps/jetty/jettylib/javax.servlet.jar" />
<pathelement location="apps/systray/java/lib/systray4j.jar" />
<pathelement location="apps/jrobin/jrobin-1.4.0.jar" />
<pathelement location="apps/jrobin/jrobin-1.5.9.jar" />
<pathelement location="installer/lib/wrapper/win32/wrapper.jar" />
<pathelement location="core/lib/junit.jar" />
</classpath>
@ -462,7 +462,7 @@
<copy file="build/desktopgui.jar" todir="pkg-temp/lib/" />
<copy file="build/routerconsole.jar" todir="pkg-temp/lib/" />
<!-- pulled out of routerconsole.jar in 0.7.12; name without version so we can overwrite if we upgrade -->
<copy file="apps/jrobin/jrobin-1.4.0.jar" tofile="pkg-temp/lib/jrobin.jar" />
<copy file="apps/jrobin/jrobin-1.5.9.jar" tofile="pkg-temp/lib/jrobin.jar" />
<copy file="build/sam.jar" todir="pkg-temp/lib/" />
<copy file="build/BOB.jar" todir="pkg-temp/lib/" />
<copy file="build/systray.jar" todir="pkg-temp/lib" />
@ -665,7 +665,7 @@
<copy file="build/routerconsole.jar" todir="pkg-temp/lib/" />
<!-- pulled out of routerconsole.jar in 0.7.12, someday we can take out of updater -->
<!-- name without version so we can overwrite if we upgrade -->
<copy file="apps/jrobin/jrobin-1.4.0.jar" tofile="pkg-temp/lib/jrobin.jar" />
<copy file="apps/jrobin/jrobin-1.5.9.jar" tofile="pkg-temp/lib/jrobin.jar" />
<copy file="build/i2ptunnel.war" todir="pkg-temp/webapps/" />
<copy file="build/routerconsole.war" todir="pkg-temp/webapps/" />
<copy file="build/addressbook.war" todir="pkg-temp/webapps/" />
@ -824,7 +824,7 @@
<arg value="-output"/>
<arg value="i2p.fba"/>
<arg value="-auxclasspath"/>
<arg value="build/commons-el.jar:build/commons-logging.jar:build/jasper-compiler.jar:build/jasper-runtime.jar:build/javax.servlet.jar:build/org.mortbay.jetty.jar:apps/jrobin/jrobin-1.4.0.jar:apps/systray/java/lib/systray4j.jar:installer/lib/wrapper/linux/wrapper.jar:apps/susidns/src/WEB-INF/lib/standard.jar:apps/susidns/src/WEB-INF/lib/jstl.jar:apps/jrobin/jrobin-1.4.0.jar"/>
<arg value="build/commons-el.jar:build/commons-logging.jar:build/jasper-compiler.jar:build/jasper-runtime.jar:build/javax.servlet.jar:build/org.mortbay.jetty.jar:apps/jrobin/jrobin-1.5.9.jar:apps/systray/java/lib/systray4j.jar:installer/lib/wrapper/linux/wrapper.jar:apps/susidns/src/WEB-INF/lib/standard.jar:apps/susidns/src/WEB-INF/lib/jstl.jar:apps/jrobin/jrobin-1.5.9.jar"/>
<arg value="-sourcepath"/>
<arg value="apps/BOB/src/:apps/addressbook/java/src/:apps/i2psnark/java/src/:apps/i2ptunnel/java/src/:apps/ministreaming/java/src/:apps/routerconsole/java/src/:apps/sam/java/src/:apps/streaming/java/src/:apps/susidns/src/java/src/:apps/susimail/src/src/:apps/systray/java/src/:core/java/src/:router/java/src/"/>
<!-- start of the files to be analyzed -->
@ -1120,7 +1120,7 @@
</copy>
<!-- 3rd party jars from apps/ -->
<!-- jrobin - without jobin , you lost graph and get a lot error entry in logs -->
<copy file="apps/jrobin/jrobin-1.4.0.jar" tofile="pkg-temp/lib/jrobin.jar" />
<copy file="apps/jrobin/jrobin-1.5.9.jar" tofile="pkg-temp/lib/jrobin.jar" />
</target>
<!-- *3* os dependent procedure/commands -->
<target name = "preppkg-portable-win32" depends="preppkg-portable-win32-jbigi,preppkg-portable-basic">