summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororbiter <orbiter@6c8d7289-2bf4-0310-a012-ef5d649a1542>2007-11-30 03:22:42 +0000
committerorbiter <orbiter@6c8d7289-2bf4-0310-a012-ef5d649a1542>2007-11-30 03:22:42 +0000
commitaefb3f7765294b91235818485a725d79fbf7edbe (patch)
tree8d590a34cb5c5d6946c47a99600815304512762b
parentea81d97cfc6bc616e21750179a9228d6b7e25d46 (diff)
added memory graph picture to PerformanceMemory_p.html
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4241 6c8d7289-2bf4-0310-a012-ef5d649a1542
-rw-r--r--htroot/PerformanceGraph.java87
-rw-r--r--htroot/PerformanceMemory_p.html2
-rw-r--r--source/dbtest.java4
-rw-r--r--source/de/anomic/plasma/plasmaSwitchboard.java65
-rw-r--r--source/de/anomic/ymage/ymageChart.java62
-rw-r--r--source/de/anomic/ymage/ymageGraph.java2
6 files changed, 170 insertions, 52 deletions
diff --git a/htroot/PerformanceGraph.java b/htroot/PerformanceGraph.java
new file mode 100644
index 000000000..5715b7882
--- /dev/null
+++ b/htroot/PerformanceGraph.java
@@ -0,0 +1,87 @@
+// PerformanceGraph.java
+// (C) 2007 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany
+// first published 30.11.2007 on http://yacy.net
+//
+// This is a part of YaCy, a peer-to-peer based web search engine
+//
+// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $
+// $LastChangedRevision: 1986 $
+// $LastChangedBy: orbiter $
+//
+// LICENSE
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import java.util.Iterator;
+import java.util.Map;
+
+import de.anomic.http.httpHeader;
+import de.anomic.plasma.plasmaSwitchboard;
+import de.anomic.server.serverObjects;
+import de.anomic.server.serverSwitch;
+import de.anomic.ymage.ymageChart;
+import de.anomic.ymage.ymageMatrix;
+
+
+public class PerformanceGraph {
+
+ public static ymageMatrix respond(httpHeader header, serverObjects post, serverSwitch env) {
+ plasmaSwitchboard sb = (plasmaSwitchboard) env;
+
+ ymageChart ip = new ymageChart(660, 240, "000010", 30, 30, 20, 20, "PEER PERFORMANCE GRAPH: PAGES/MINUTE and USED MEMORY");
+ ip.declareDimension(ymageChart.DIMENSION_BOTTOM, 60, 60, -600, "000000", "CCCCCC", "TIME/SECONDS");
+ ip.declareDimension(ymageChart.DIMENSION_LEFT, 50, 40, 0, "008800", null , "PPM [PAGES/MINUTE]");
+ ip.declareDimension(ymageChart.DIMENSION_RIGHT, 100, 20, 0, "0000FF", "CCCCCC", "MEMORY/MEGABYTE");
+
+ // draw ppm
+ ip.setColor("008800");
+ Iterator i = sb.ppmHistory.entrySet().iterator();
+ Map.Entry entry;
+ int ppm;
+ long time, now = System.currentTimeMillis();
+ int x0 = 1, x1, y0 = 0, y1;
+ while (i.hasNext()) {
+ entry = (Map.Entry) i.next();
+ time = ((Long) entry.getKey()).longValue() - now;
+ ppm = (int) ((Long) entry.getValue()).longValue();
+ //System.out.println("PPM: time = " + time + ", ppm = " + ppm);
+ x1 = (int) (time/1000);
+ y1 = ppm;
+ ip.chartDot(ymageChart.DIMENSION_BOTTOM, ymageChart.DIMENSION_LEFT, x1, y1, 2);
+ if (x0 < 0) ip.chartLine(ymageChart.DIMENSION_BOTTOM, ymageChart.DIMENSION_LEFT, x0, y0, x1, y1);
+ x0 = x1; y0 = y1;
+ }
+
+ // draw memory
+ ip.setColor("0000FF");
+ i = sb.usedMemoryHistory.entrySet().iterator();
+ long bytes;
+ x0 = 1;
+ while (i.hasNext()) {
+ entry = (Map.Entry) i.next();
+ time = ((Long) entry.getKey()).longValue() - now;
+ bytes = ((Long) entry.getValue()).longValue();
+ //System.out.println("Memory: time = " + time + ", bytes = " + bytes);
+ x1 = (int) (time/1000);
+ y1 = (int) (bytes / 1024 / 1024);
+ ip.chartDot(ymageChart.DIMENSION_BOTTOM, ymageChart.DIMENSION_RIGHT, x1, y1, 2);
+ if (x0 < 0) ip.chartLine(ymageChart.DIMENSION_BOTTOM, ymageChart.DIMENSION_RIGHT, x0, y0, x1, y1);
+ x0 = x1; y0 = y1;
+ }
+
+ return ip;
+ }
+
+} \ No newline at end of file
diff --git a/htroot/PerformanceMemory_p.html b/htroot/PerformanceMemory_p.html
index e13dc0ad8..c162d13ff 100644
--- a/htroot/PerformanceMemory_p.html
+++ b/htroot/PerformanceMemory_p.html
@@ -71,6 +71,8 @@
</fieldset>
</form>
+ <p><img src="PerformanceGraph.png"></p>
+
<p><strong>FlexTable RAM Index:</strong></p>
<table border="0" cellpadding="2" cellspacing="1">
<tr class="TableHeader" valign="bottom">
diff --git a/source/dbtest.java b/source/dbtest.java
index bb94bcc3c..48994287e 100644
--- a/source/dbtest.java
+++ b/source/dbtest.java
@@ -475,8 +475,8 @@ final class memprofiler extends Thread {
memChart = new ymageChart(width, height, "000010", 50, 20, 20, 20, "MEMORY CHART FROM EXECUTION AT " + new Date());
int timescale = 10; // steps with each 10 seconds
int memscale = 1024;
- memChart.declareDimension(ymageChart.DIMENSION_BOTTOM, timescale, (width - 40) * timescale / expectedTimeSeconds, "FFFFFF", "555555", "SECONDS");
- memChart.declareDimension(ymageChart.DIMENSION_LEFT, memscale, (height - 40) * memscale / expectedKilobytes , "FFFFFF", "555555", "KILOBYTES");
+ memChart.declareDimension(ymageChart.DIMENSION_BOTTOM, timescale, (width - 40) * timescale / expectedTimeSeconds, 0, "FFFFFF", "555555", "SECONDS");
+ memChart.declareDimension(ymageChart.DIMENSION_LEFT, memscale, (height - 40) * memscale / expectedKilobytes, 0, "FFFFFF", "555555", "KILOBYTES");
run = true;
start = System.currentTimeMillis();
}
diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java
index 695929f38..c246ed316 100644
--- a/source/de/anomic/plasma/plasmaSwitchboard.java
+++ b/source/de/anomic/plasma/plasmaSwitchboard.java
@@ -1,14 +1,15 @@
// plasmaSwitchboard.java
-// -----------------------
-// part of YaCy
-// (C) by Michael Peter Christen; mc@anomic.de
-// first published on http://www.anomic.de
-// Frankfurt, Germany, 2004, 2005
+// (C) 2004-2007 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany
+// first published 2004 on http://yacy.net
+//
+// This is a part of YaCy, a peer-to-peer based web search engine
//
// $LastChangedDate$
// $LastChangedRevision$
// $LastChangedBy$
//
+// LICENSE
+//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
@@ -22,25 +23,6 @@
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// Using this software in any meaning (reading, learning, copying, compiling,
-// running) means that you agree that the Author(s) is (are) not responsible
-// for cost, loss of data or any harm that may be caused directly or indirectly
-// by usage of this softare or this documentation. The usage of this software
-// is on your own risk. The installation and usage (starting/running) of this
-// software may allow other people or application to access your computer and
-// any attached devices and is highly dependent on the configuration of the
-// software which must be done by the user of the software; the author(s) is
-// (are) also not responsible for proper configuration and usage of the
-// software, even if provoked by documentation provided together with
-// the software.
-//
-// Any changes to this file according to the GPL as documented in the file
-// gpl.txt aside this file in the shipment you received can be done to the
-// lines that follows this copyright notice here, but changes must not be
-// done inside the copyright notive above. A re-distribution must contain
-// the intact and unchanged copyright notice.
-// Contributions and changes to the program code must be marked as such.
/*
This class holds the run-time environment of the plasma
@@ -259,6 +241,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
public boolean acceptLocalURLs, acceptGlobalURLs;
public URLLicense licensedURLs;
public Timer moreMemory;
+ public TreeMap ppmHistory, usedMemoryHistory;
+ public long lastPPMUpdate;
/*
* Remote Proxy configuration
@@ -890,11 +874,17 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
public Hashtable crawlJobsStatus = new Hashtable();
private static plasmaSwitchboard sb;
-
+
public plasmaSwitchboard(String rootPath, String initPath, String configPath, boolean applyPro) {
super(rootPath, initPath, configPath, applyPro);
sb=this;
+ // initialize memory profiling
+ ppmHistory = new TreeMap();
+ usedMemoryHistory = new TreeMap();
+ lastPPMUpdate = System.currentTimeMillis();
+ updateProfiling();
+
// set loglevel and log
setLog(new serverLog("PLASMA"));
if (applyPro) this.log.logInfo("This is the pro-version of YaCy");
@@ -1416,6 +1406,29 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
return sb;
}
+ public void updateProfiling() {
+ Long time = new Long(System.currentTimeMillis());
+ usedMemoryHistory.put(time, new Long(serverMemory.used()));
+ if (time.longValue() - lastPPMUpdate > 30000) {
+ // we don't want to do this too often
+ yacyCore.peerActions.updateMySeed();
+ ppmHistory.put(time, new Long(yacyCore.seedDB.mySeed().getPPM()));
+ lastPPMUpdate = time.longValue();
+ }
+
+ // clean up too old entries
+ while (usedMemoryHistory.size() > 0) {
+ time = (Long) usedMemoryHistory.firstKey();
+ if (System.currentTimeMillis() - time.longValue() < 600000) break;
+ usedMemoryHistory.remove(time);
+ }
+ while (ppmHistory.size() > 0) {
+ time = (Long) ppmHistory.firstKey();
+ if (System.currentTimeMillis() - time.longValue() < 600000) break;
+ ppmHistory.remove(time);
+ }
+ }
+
public boolean isRobinsonMode() {
// we are in robinson mode, if we do not exchange index by dht distribution
// we need to take care that search requests and remote indexing requests go only
@@ -1805,6 +1818,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
}
public boolean deQueue() {
+ updateProfiling();
try {
// work off fresh entries from the proxy or from the crawler
if (onlineCaution()) {
@@ -1898,6 +1912,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
}
// ready & finished
+ updateProfiling();
return true;
} catch (InterruptedException e) {
log.logInfo("DEQUEUE: Shutdown detected.");
diff --git a/source/de/anomic/ymage/ymageChart.java b/source/de/anomic/ymage/ymageChart.java
index dc04ba03e..4ed4cb025 100644
--- a/source/de/anomic/ymage/ymageChart.java
+++ b/source/de/anomic/ymage/ymageChart.java
@@ -41,6 +41,12 @@
package de.anomic.ymage;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+
public class ymageChart extends ymageMatrix {
public static final int DIMENSION_RIGHT = 0;
@@ -54,6 +60,7 @@ public class ymageChart extends ymageMatrix {
int bottomborder;
int[] scales = new int[]{0,0,0,0};
int[] pixels = new int[]{0,0,0,0};
+ int[] offsets = new int[]{0,0,0,0};
String[] colnames = new String[]{"FFFFFF","FFFFFF","FFFFFF","FFFFFF"};
String[] colscale = new String[]{null,null,null,null};
String[] tablenames = new String[]{"","","",""};
@@ -67,43 +74,45 @@ public class ymageChart extends ymageMatrix {
this.topborder = topborder;
this.bottomborder = bottomborder;
if (name != null) {
+ this.setColor("000000");
ymageToolPrint.print(this, width / 2 - name.length() * 3, 6, 0, name, -1);
}
}
- public void declareDimension(int dimensionType, int scale, int pixelperscale, String colorNaming, String colorScale, String name) {
+ public void declareDimension(int dimensionType, int scale, int pixelperscale, int offset, String colorNaming, String colorScale, String name) {
if ((dimensionType == DIMENSION_LEFT) || (dimensionType == DIMENSION_RIGHT)) {
- drawVerticalScale((dimensionType == DIMENSION_LEFT), scale, pixelperscale, colorNaming, colorScale, name);
+ drawVerticalScale((dimensionType == DIMENSION_LEFT), scale, pixelperscale, offset, colorNaming, colorScale, name);
}
if ((dimensionType == DIMENSION_TOP) || (dimensionType == DIMENSION_BOTTOM)) {
- drawHorizontalScale((dimensionType == DIMENSION_TOP), scale, pixelperscale, colorNaming, colorScale, name);
+ drawHorizontalScale((dimensionType == DIMENSION_TOP), scale, pixelperscale, offset, colorNaming, colorScale, name);
}
scales[dimensionType] = scale;
pixels[dimensionType] = pixelperscale;
+ offsets[dimensionType] = offset;
colnames[dimensionType] = colorNaming;
colscale[dimensionType] = colorScale;
tablenames[dimensionType] = name;
}
public void chartDot(int dimension_x, int dimension_y, int coord_x, int coord_y, int dotsize) {
- int x = coord_x * pixels[dimension_x] / scales[dimension_x];
- int y = coord_y * pixels[dimension_y] / scales[dimension_y];
+ int x = (coord_x - offsets[dimension_x]) * pixels[dimension_x] / scales[dimension_x];
+ int y = (coord_y - offsets[dimension_y]) * pixels[dimension_y] / scales[dimension_y];
if (dotsize == 1) plot(leftborder + x, height - bottomborder - y);
else dot(leftborder + x, height - bottomborder - y, dotsize, true);
}
public void chartLine(int dimension_x, int dimension_y, int coord_x1, int coord_y1, int coord_x2, int coord_y2) {
- int x1 = coord_x1 * pixels[dimension_x] / scales[dimension_x];
- int y1 = coord_y1 * pixels[dimension_y] / scales[dimension_y];
- int x2 = coord_x2 * pixels[dimension_x] / scales[dimension_x];
- int y2 = coord_y2 * pixels[dimension_y] / scales[dimension_y];
+ int x1 = (coord_x1 - offsets[dimension_x]) * pixels[dimension_x] / scales[dimension_x];
+ int y1 = (coord_y1 - offsets[dimension_y]) * pixels[dimension_y] / scales[dimension_y];
+ int x2 = (coord_x2 - offsets[dimension_x]) * pixels[dimension_x] / scales[dimension_x];
+ int y2 = (coord_y2 - offsets[dimension_y]) * pixels[dimension_y] / scales[dimension_y];
line(leftborder + x1, height - bottomborder - y1, leftborder + x2, height - bottomborder - y2);
}
- private void drawHorizontalScale(boolean top, int scale, int pixelperscale, String colorNaming, String colorScale, String name) {
+ private void drawHorizontalScale(boolean top, int scale, int pixelperscale, int offset, String colorNaming, String colorScale, String name) {
int y = (top) ? topborder : height - bottomborder;
int x = leftborder;
- int s = 0;
+ int s = offset;
while (x < width - rightborder) {
if ((colorScale != null) && (x > leftborder) && (x < (width - rightborder))) {
setColor(colorScale);
@@ -120,10 +129,10 @@ public class ymageChart extends ymageMatrix {
line(leftborder - 4, y, width - rightborder + 4, y);
}
- private void drawVerticalScale(boolean left, int scale, int pixelperscale, String colorNaming, String colorScale, String name) {
+ private void drawVerticalScale(boolean left, int scale, int pixelperscale, int offset, String colorNaming, String colorScale, String name) {
int x = (left) ? leftborder : width - rightborder;
int y = height - bottomborder;
- int s = 0;
+ int s = offset;
String s1;
int s1max = 0;
while (y > topborder) {
@@ -146,23 +155,28 @@ public class ymageChart extends ymageMatrix {
public static void main(String[] args) {
System.setProperty("java.awt.headless", "true");
- ymageChart ip = new ymageChart(640, 480, "000010", 40, 40, 20, 20, "TESTCHART");
- ip.declareDimension(DIMENSION_BOTTOM, 10, 30, "FFFFFF", "555555", "time");
- ip.declareDimension(DIMENSION_TOP, 10, 40, "FFFFFF", null, "count");
- ip.declareDimension(DIMENSION_LEFT, 100, 30, "FFFFFF", "555555", "money");
- ip.declareDimension(DIMENSION_RIGHT, 100, 50, "FFFFFF", null, "stock");
- ip.setColor("FF0000");
- ip.chartDot(DIMENSION_BOTTOM, DIMENSION_LEFT, 20, 100, 5);
- ip.chartLine(DIMENSION_BOTTOM, DIMENSION_LEFT, 20, 100, 50, 200);
+ ymageChart ip = new ymageChart(660, 240, "000010", 30, 30, 20, 20, "PEER PERFORMANCE GRAPH: PAGES/MINUTE and USED MEMORY");
+ ip.declareDimension(DIMENSION_BOTTOM, 60, 60, -600, "000000", "CCCCCC", "TIME/SECONDS");
+ //ip.declareDimension(DIMENSION_TOP, 10, 40, "000000", null, "count");
+ ip.declareDimension(DIMENSION_LEFT, 50, 40, 0, "008800", null , "PPM [PAGES/MINUTE]");
+ ip.declareDimension(DIMENSION_RIGHT, 100, 20, 0, "0000FF", "CCCCCC", "MEMORY/MEGABYTE");
+ ip.setColor("008800");
+ ip.chartDot(DIMENSION_BOTTOM, DIMENSION_LEFT, -160, 100, 5);
+ ip.chartLine(DIMENSION_BOTTOM, DIMENSION_LEFT, -160, 100, -130, 200);
+ ip.setColor("0000FF");
+ ip.chartDot(DIMENSION_BOTTOM, DIMENSION_RIGHT, -50, 300, 2);
+ ip.chartLine(DIMENSION_BOTTOM, DIMENSION_RIGHT, -80, 100, -50, 300);
//ip.print(100, 100, 0, "TEXT", true);
//ip.print(100, 100, 0, "1234", false);
//ip.print(100, 100, 90, "TEXT", true);
//ip.print(100, 100, 90, "1234", false);
- /*
+
try {
- ip.toPNG(true, new File("/Users/admin/dev/yacy/trunk/testimage.png"));
+ FileOutputStream fos = new FileOutputStream(new File("/Users/admin/Desktop/testimage.png"));
+ ImageIO.write(ip.getImage(), "png", fos);
+ fos.close();
} catch (IOException e) {}
- */
+
}
}
diff --git a/source/de/anomic/ymage/ymageGraph.java b/source/de/anomic/ymage/ymageGraph.java
index 87214bf22..ef0bdd4cc 100644
--- a/source/de/anomic/ymage/ymageGraph.java
+++ b/source/de/anomic/ymage/ymageGraph.java
@@ -32,7 +32,7 @@ import java.util.Iterator;
import java.util.Map;
/* this class is a container for graph coordinates and it can draw such coordinates into a graph
- * all coordinates are given in a artificial corrdinate system, in the range from
+ * all coordinates are given in a artificial coordinate system, in the range from
* -1 to +1. The lower left point of the graph has the coordinate -1, -1 and the upper
* right is 1,1
* 0,0 is the center of the graph