Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

added network history graph image /NetworkHistory.png which can show many different statistics about the history of the peer.

Michael Peter Christenbc275dca0719
diff --git a/source/net/yacy/dbtest.java b/source/net/yacy/dbtest.java
index de1f68c8b..5ec42f0fa 100644
--- a/source/net/yacy/dbtest.java
+++ b/source/net/yacy/dbtest.java
@@ -458,8 +458,8 @@ final class memprofiler extends Thread {
@Override
public void run() {
try {
- int seconds0 = 0, kilobytes0 = 0;
- int seconds1 = 0, kilobytes1 = 0;
+ float seconds0 = 0, seconds1 = 0;
+ int kilobytes0 = 0, kilobytes1 = 0;
while (this.run) {
this.memChart.setColor(Long.parseLong("FF0000", 16));
seconds1 = (int) ((System.currentTimeMillis() - this.start) / 1000);
diff --git a/source/net/yacy/kelondro/blob/BEncodedHeap.java b/source/net/yacy/kelondro/blob/BEncodedHeap.java
index 58b4867e3..96d4f55cd 100644
--- a/source/net/yacy/kelondro/blob/BEncodedHeap.java
+++ b/source/net/yacy/kelondro/blob/BEncodedHeap.java
@@ -562,6 +562,18 @@ public class BEncodedHeap implements MapStore {
public Iterator<byte[]> keys() throws IOException {
return this.table.keys(true, false);
}
+
+ /**
+ * iteratore all keys of the table
+ *
+ * @param up
+ * @param rotating
+ * @return an iterator of byte[]
+ * @throws IOException
+ */
+ public Iterator<byte[]> keys(final boolean up, final boolean rotating) throws IOException {
+ return this.table.keys(up, rotating);
+ }
/**
* the values() method is not implemented in this class because it does not make sense to use such a
diff --git a/source/net/yacy/kelondro/blob/Tables.java b/source/net/yacy/kelondro/blob/Tables.java
index 57418e880..1718bca0b 100644
--- a/source/net/yacy/kelondro/blob/Tables.java
+++ b/source/net/yacy/kelondro/blob/Tables.java
@@ -454,7 +454,7 @@ public class Tables implements Iterable<String> {
return new RowIterator(table, wherePattern);
}
- public Collection<Row> orderByPK(final Iterator<Row> rowIterator, int maxcount, boolean reverse) {
+ public static Collection<Row> orderByPK(final Iterator<Row> rowIterator, int maxcount, boolean reverse) {
final TreeMap<String, Row> sortTree = new TreeMap<String, Row>();
Row row;
while ((maxcount < 0 || maxcount-- > 0) && rowIterator.hasNext()) {
@@ -464,7 +464,7 @@ public class Tables implements Iterable<String> {
return reverse ? sortTree.descendingMap().values() : sortTree.values();
}
- public Collection<Row> orderBy(final Iterator<Row> rowIterator, int maxcount, final String sortColumn) {
+ public static Collection<Row> orderBy(final Iterator<Row> rowIterator, int maxcount, final String sortColumn) {
final TreeMap<String, Row> sortTree = new TreeMap<String, Row>();
Row row;
byte[] r;
diff --git a/source/net/yacy/peers/graphics/ProfilingGraph.java b/source/net/yacy/peers/graphics/ProfilingGraph.java
index a78ce5d30..d581dd0d0 100644
--- a/source/net/yacy/peers/graphics/ProfilingGraph.java
+++ b/source/net/yacy/peers/graphics/ProfilingGraph.java
@@ -90,7 +90,8 @@ public class ProfilingGraph {
long time;
final long now = System.currentTimeMillis();
long bytes;
- int x0, x1, y0, y1;
+ float x0, x1;
+ int y0, y1;
try {
// draw urls
/*
@@ -112,18 +113,18 @@ public class ProfilingGraph {
// draw memory
if (showMemory) {
events = EventTracker.getHistory(EventTracker.EClass.MEMORY);
- x0 = 1; y0 = 0;
+ x0 = 1.0f; y0 = 0;
if (events != null) {
EventTracker.Event event;
while (events.hasNext()) {
event = events.next();
time = event.getTime() - now;
bytes = ((Long) event.payload).longValue();
- x1 = (int) (time/1000);
+ x1 = time / 1000.0f;
y1 = (int) (bytes / 1024 / 1024);
-// the dots don't chart.setColor(Long.parseLong("AAAAFF", 16));
+// the dots don't chart.setColor(0xAAAAFF);
// very nice chart.chartDot(ChartPlotter.DIMENSION_BOTTOM, ChartPlotter.DIMENSION_RIGHT, x1, y1, 2, null, 0);
- chart.setColor(Long.parseLong("0000FF", 16));
+ chart.setColor(0x0000FF);
if (x0 < 0) chart.chartLine(ChartPlotter.DIMENSION_BOTTOM, ChartPlotter.DIMENSION_RIGHT, x0, y0, x1, y1);
x0 = x1; y0 = y1;
}
@@ -132,7 +133,7 @@ public class ProfilingGraph {
// draw wordcache
events = EventTracker.getHistory(EventTracker.EClass.WORDCACHE);
- x0 = 1; y0 = 0;
+ x0 = 1.0f; y0 = 0;
if (events != null) {
EventTracker.Event event;
int words;
@@ -140,11 +141,11 @@ public class ProfilingGraph {
event = events.next();
time = event.getTime() - now;
words = (int) ((Long) event.payload).longValue();
- x1 = (int) (time/1000);
+ x1 = time / 1000.0f;
y1 = words;
- chart.setColor(Long.parseLong("228822", 16));
+ chart.setColor(0x228822);
chart.chartDot(ChartPlotter.DIMENSION_BOTTOM, ChartPlotter.DIMENSION_LEFT, x1, y1, 2, null, 315);
- chart.setColor(Long.parseLong("008800", 16));
+ chart.setColor(0x008800);
if (x0 < 0) chart.chartLine(ChartPlotter.DIMENSION_BOTTOM, ChartPlotter.DIMENSION_LEFT, x0, y0, x1, y1);
x0 = x1; y0 = y1;
}
@@ -152,7 +153,7 @@ public class ProfilingGraph {
// draw ppm
events = EventTracker.getHistory(EventTracker.EClass.PPM);
- x0 = 1; y0 = 0;
+ x0 = 1.0f; y0 = 0;
if (events != null) {
EventTracker.Event event;
int ppm;
@@ -160,11 +161,11 @@ public class ProfilingGraph {
event = events.next();
time = event.getTime() - now;
ppm = (int) ((Long) event.payload).longValue();
- x1 = (int) (time/1000);
+ x1 = time / 1000.0f;
y1 = ppm;
- chart.setColor(Long.parseLong("AA8888", 16));
+ chart.setColor(0xAA8888);
if (x0 < 0) chart.chartLine(ChartPlotter.DIMENSION_BOTTOM, ChartPlotter.DIMENSION_ANOT0, x0, y0, x1, y1);
- chart.setColor(Long.parseLong("AA2222", 16));
+ chart.setColor(0xAA2222);
chart.chartDot(ChartPlotter.DIMENSION_BOTTOM, ChartPlotter.DIMENSION_ANOT0, x1, y1, 2, ppm + " PPM", 0);
x0 = x1; y0 = y1;
}
@@ -173,7 +174,7 @@ public class ProfilingGraph {
// draw peer ping
if (showPeers) {
events = EventTracker.getHistory(EventTracker.EClass.PEERPING);
- x0 = 1; y0 = 0;
+ x0 = 1.0f; y0 = 0;
if (events != null) {
EventTracker.Event event;
EventPing ping;
@@ -182,10 +183,10 @@ public class ProfilingGraph {
event = events.next();
time = event.getTime() - now;
ping = (EventPing) event.payload;
- x1 = (int) (time/1000);
+ x1 = time / 1000.0f;
y1 = Math.abs((ping.outgoing ? ping.toPeer : ping.fromPeer).hashCode()) % vspace;
pingPeer = ping.outgoing ? "-> " + ping.toPeer.toUpperCase() : "<- " + ping.fromPeer.toUpperCase();
- chart.setColor(Long.parseLong("9999AA", 16));
+ chart.setColor(0x9999AA);
chart.chartDot(ChartPlotter.DIMENSION_BOTTOM, ChartPlotter.DIMENSION_ANOT2, x1, y1, 2, pingPeer + (ping.newPeers > 0 ? "(+" + ping.newPeers + ")" : ""), 0);
x0 = x1; y0 = y1;
}
diff --git a/source/net/yacy/visualization/ChartPlotter.java b/source/net/yacy/visualization/ChartPlotter.java
index 17a69e3d4..72f03642f 100644
--- a/source/net/yacy/visualization/ChartPlotter.java
+++ b/source/net/yacy/visualization/ChartPlotter.java
@@ -75,37 +75,57 @@ public class ChartPlotter extends RasterPlotter {
}
}
+ /**
+ * assign a metric to a graph. The dimension can be left or right (the measure at the side-border of the graph)
+ * @param dimensionType
+ * @param scale is the measure (the number) to be printed on the border per pixelscale
+ * @param pixelperscale is the number of pixel points per scale
+ * @param offset is an offset on the 'scale' number
+ * @param colorNaming the colour of the legend for the scale
+ * @param colorScale the colour of the line drawing for the vertical scale
+ * @param name printed on the vertical bar
+ */
public void declareDimension(final int dimensionType, final int scale, final int pixelperscale, final int offset, final String colorNaming, final String colorScale, final String name) {
- if ((dimensionType == DIMENSION_LEFT) || (dimensionType == DIMENSION_RIGHT)) {
- drawVerticalScale((dimensionType == DIMENSION_LEFT), scale, pixelperscale, offset, colorNaming, colorScale, name);
- }
- if ((dimensionType == DIMENSION_TOP) || (dimensionType == DIMENSION_BOTTOM)) {
- drawHorizontalScale((dimensionType == DIMENSION_TOP), scale, pixelperscale, offset, colorNaming, colorScale, name);
- }
this.scales[dimensionType] = scale;
this.pixels[dimensionType] = pixelperscale;
this.offsets[dimensionType] = offset;
this.colnames[dimensionType] = colorNaming;
this.colscale[dimensionType] = colorScale;
this.tablenames[dimensionType] = name;
+ if ((dimensionType == DIMENSION_LEFT) || (dimensionType == DIMENSION_RIGHT)) {
+ drawVerticalScale((dimensionType == DIMENSION_LEFT), scale, pixelperscale, offset, colorNaming, colorScale, name);
+ }
+ if ((dimensionType == DIMENSION_TOP) || (dimensionType == DIMENSION_BOTTOM)) {
+ drawHorizontalScale((dimensionType == DIMENSION_TOP), scale, pixelperscale, offset, colorNaming, colorScale, name);
+ }
}
- public void chartDot(final int dimension_x, final int dimension_y, final int coord_x, final int coord_y, final int dotsize, final String anot, final int anotAngle) {
- final int x = (coord_x - this.offsets[dimension_x]) * this.pixels[dimension_x] / this.scales[dimension_x];
+ public void chartDot(final int dimension_x, final int dimension_y, final float coord_x, final int coord_y, final int dotsize, final String anot, final int anotAngle) {
+ final int x = (int) ((coord_x - this.offsets[dimension_x]) * this.pixels[dimension_x] / this.scales[dimension_x]);
final int y = (coord_y - this.offsets[dimension_y]) * this.pixels[dimension_y] / this.scales[dimension_y];
if (dotsize == 1) plot(this.leftborder + x, this.height - this.bottomborder - y, 100);
else dot(this.leftborder + x, this.height - this.bottomborder - y, dotsize, true, 100);
if (anot != null) PrintTool.print(this, this.leftborder + x + dotsize + 2 + ((anotAngle == 315) ? -9 : 0), this.height - this.bottomborder - y + ((anotAngle == 315) ? -3 : 0), anotAngle, anot, (anotAngle == 0) ? (anot.length() * 6 + x > this.width ? 1 : -1) : ((anotAngle == 315) ? 1 : 0));
}
- public void chartLine(final int dimension_x, final int dimension_y, final int coord_x1, final int coord_y1, final int coord_x2, final int coord_y2) {
- final int x1 = (coord_x1 - this.offsets[dimension_x]) * this.pixels[dimension_x] / this.scales[dimension_x];
+ public void chartLine(final int dimension_x, final int dimension_y, final float coord_x1, final int coord_y1, final float coord_x2, final int coord_y2) {
+ final int x1 = (int) ((coord_x1 - this.offsets[dimension_x]) * this.pixels[dimension_x] / this.scales[dimension_x]);
final int y1 = (coord_y1 - this.offsets[dimension_y]) * this.pixels[dimension_y] / this.scales[dimension_y];
- final int x2 = (coord_x2 - this.offsets[dimension_x]) * this.pixels[dimension_x] / this.scales[dimension_x];
+ final int x2 = (int) ((coord_x2 - this.offsets[dimension_x]) * this.pixels[dimension_x] / this.scales[dimension_x]);
final int y2 = (coord_y2 - this.offsets[dimension_y]) * this.pixels[dimension_y] / this.scales[dimension_y];
line(this.leftborder + x1, this.height - this.bottomborder - y1, this.leftborder + x2, this.height - this.bottomborder - y2, 100);
}
+ /**
+ * draw a horizontal scale border
+ * @param top - if true, this the top-horizontal scale, otherwise it is at the bottom
+ * @param scale is the measure (the number) to be printed on the vertical border per pixelscale
+ * @param pixelperscale is the number of vertical pixel points per scale
+ * @param offset is an offset on the 'scale' number
+ * @param colorNaming the colour of the legend for the scale
+ * @param colorScale the colour of the line drawing for the vertical scale
+ * @param name printed on the vertical bar
+ */
private void drawHorizontalScale(final boolean top, final int scale, final int pixelperscale, final int offset, final String colorNaming, final String colorScale, final String name) {
final int y = (top) ? this.topborder : this.height - this.bottomborder;
int x = this.leftborder;
@@ -128,6 +148,16 @@ public class ChartPlotter extends RasterPlotter {
line(this.leftborder - 4, y, this.width - this.rightborder + 4, y, 100);
}
+ /**
+ * draw the vertical scale of the graph
+ * @param left if true this is the vertical bar on the left, otherwise it is the one on the right
+ * @param scale is the measure (the number) to be printed on the vertical border per pixelscale
+ * @param pixelperscale is the number of vertical pixel points per scale
+ * @param offset is an offset on the 'scale' number
+ * @param colorNaming the colour of the legend for the scale
+ * @param colorScale the colour of the line drawing for the vertical scale
+ * @param name printed on the vertical bar
+ */
private void drawVerticalScale(final boolean left, final int scale, final int pixelperscale, final int offset, final String colorNaming, final String colorScale, final String name) {
assert pixelperscale > 0;
assert scale > 0;