add buffering for the performance graph to avoid ConcurrentModificationException

closes: http://forum.yacy-websuche.de/viewtopic.php?f=6&t=628

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4281 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
fuchsi 17 years ago
parent 814aff60bd
commit a52681dd49

@ -26,6 +26,7 @@
package de.anomic.plasma; package de.anomic.plasma;
import java.util.ConcurrentModificationException;
import java.util.Iterator; import java.util.Iterator;
import de.anomic.server.serverProfiling; import de.anomic.server.serverProfiling;
@ -35,6 +36,8 @@ import de.anomic.ymage.ymageMatrix;
public class plasmaProfiling { public class plasmaProfiling {
private static ymageChart bufferChart = null;
public static long lastPPMUpdate = System.currentTimeMillis()- 30000; public static long lastPPMUpdate = System.currentTimeMillis()- 30000;
public static void updateIndexedPage(plasmaSwitchboardQueue.Entry entry) { public static void updateIndexedPage(plasmaSwitchboardQueue.Entry entry) {
@ -85,33 +88,38 @@ public class plasmaProfiling {
long time, now = System.currentTimeMillis(), bytes; long time, now = System.currentTimeMillis(), bytes;
int x0 = 1, x1, y0 = 0, y1, ppm; int x0 = 1, x1, y0 = 0, y1, ppm;
serverProfiling.Event event; serverProfiling.Event event;
while (i.hasNext()) { try {
event = (serverProfiling.Event) i.next(); while (i.hasNext()) {
time = event.time - now; event = (serverProfiling.Event) i.next();
ppm = (int) ((Long) event.payload).longValue(); time = event.time - now;
x1 = (int) (time/1000); ppm = (int) ((Long) event.payload).longValue();
y1 = ppm; x1 = (int) (time/1000);
chart.setColor("228822"); y1 = ppm;
chart.chartDot(ymageChart.DIMENSION_BOTTOM, ymageChart.DIMENSION_LEFT, x1, y1, 2); chart.setColor("228822");
chart.setColor("008800"); chart.chartDot(ymageChart.DIMENSION_BOTTOM, ymageChart.DIMENSION_LEFT, x1, y1, 2);
if (x0 < 0) chart.chartLine(ymageChart.DIMENSION_BOTTOM, ymageChart.DIMENSION_LEFT, x0, y0, x1, y1); chart.setColor("008800");
x0 = x1; y0 = y1; if (x0 < 0) chart.chartLine(ymageChart.DIMENSION_BOTTOM, ymageChart.DIMENSION_LEFT, x0, y0, x1, y1);
} x0 = x1; y0 = y1;
}
// draw memory // draw memory
i = serverProfiling.history("memory"); i = serverProfiling.history("memory");
x0 = 1; x0 = 1;
while (i.hasNext()) { while (i.hasNext()) {
event = (serverProfiling.Event) i.next(); event = (serverProfiling.Event) i.next();
time = event.time - now; time = event.time - now;
bytes = ((Long) event.payload).longValue(); bytes = ((Long) event.payload).longValue();
x1 = (int) (time/1000); x1 = (int) (time/1000);
y1 = (int) (bytes / 1024 / 1024); y1 = (int) (bytes / 1024 / 1024);
chart.setColor("AAAAFF"); chart.setColor("AAAAFF");
chart.chartDot(ymageChart.DIMENSION_BOTTOM, ymageChart.DIMENSION_RIGHT, x1, y1, 2); chart.chartDot(ymageChart.DIMENSION_BOTTOM, ymageChart.DIMENSION_RIGHT, x1, y1, 2);
chart.setColor("0000FF"); chart.setColor("0000FF");
if (x0 < 0) chart.chartLine(ymageChart.DIMENSION_BOTTOM, ymageChart.DIMENSION_RIGHT, x0, y0, x1, y1); if (x0 < 0) chart.chartLine(ymageChart.DIMENSION_BOTTOM, ymageChart.DIMENSION_RIGHT, x0, y0, x1, y1);
x0 = x1; y0 = y1; x0 = x1; y0 = y1;
}
bufferChart = chart;
} catch (ConcurrentModificationException cme) {
chart = bufferChart;
} }
return chart; return chart;

Loading…
Cancel
Save