|
|
|
@ -39,7 +39,6 @@ import net.yacy.cora.document.UTF8;
|
|
|
|
|
import net.yacy.kelondro.logging.Log;
|
|
|
|
|
import net.yacy.visualization.PrintTool;
|
|
|
|
|
import net.yacy.visualization.RasterPlotter;
|
|
|
|
|
|
|
|
|
|
import de.anomic.search.QueryParams;
|
|
|
|
|
import de.anomic.search.SearchEvent;
|
|
|
|
|
import de.anomic.search.SearchEventCache;
|
|
|
|
@ -135,19 +134,19 @@ public class NetworkGraph {
|
|
|
|
|
int angle;
|
|
|
|
|
|
|
|
|
|
// draw in the primary search peers
|
|
|
|
|
for (int j = 0; j < primarySearches.length; j++) {
|
|
|
|
|
if (primarySearches[j] == null) continue;
|
|
|
|
|
eventPicture.setColor((primarySearches[j].isAlive()) ? RasterPlotter.RED : RasterPlotter.GREEN);
|
|
|
|
|
angle = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(UTF8.getBytes(primarySearches[j].target().hash), null)) / ((double) Long.MAX_VALUE)));
|
|
|
|
|
for (final yacySearch primarySearche : primarySearches) {
|
|
|
|
|
if (primarySearche == null) continue;
|
|
|
|
|
eventPicture.setColor((primarySearche.isAlive()) ? RasterPlotter.RED : RasterPlotter.GREEN);
|
|
|
|
|
angle = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(UTF8.getBytes(primarySearche.target().hash), null)) / ((double) Long.MAX_VALUE)));
|
|
|
|
|
eventPicture.arcLine(cx, cy, cr - 20, cr, angle, true, null, null, -1, -1, -1, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// draw in the secondary search peers
|
|
|
|
|
if (secondarySearches != null) {
|
|
|
|
|
for (int j = 0; j < secondarySearches.length; j++) {
|
|
|
|
|
if (secondarySearches[j] == null) continue;
|
|
|
|
|
eventPicture.setColor((secondarySearches[j].isAlive()) ? RasterPlotter.RED : RasterPlotter.GREEN);
|
|
|
|
|
angle = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(UTF8.getBytes(secondarySearches[j].target().hash), null)) / ((double) Long.MAX_VALUE)));
|
|
|
|
|
for (final yacySearch secondarySearche : secondarySearches) {
|
|
|
|
|
if (secondarySearche == null) continue;
|
|
|
|
|
eventPicture.setColor((secondarySearche.isAlive()) ? RasterPlotter.RED : RasterPlotter.GREEN);
|
|
|
|
|
angle = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(UTF8.getBytes(secondarySearche.target().hash), null)) / ((double) Long.MAX_VALUE)));
|
|
|
|
|
eventPicture.arcLine(cx, cy, cr - 10, cr, angle - 1, true, null, null, -1, -1, -1, false);
|
|
|
|
|
eventPicture.arcLine(cx, cy, cr - 10, cr, angle + 1, true, null, null, -1, -1, -1, false);
|
|
|
|
|
}
|
|
|
|
@ -158,9 +157,9 @@ public class NetworkGraph {
|
|
|
|
|
final Iterator<byte[]> i = query.queryHashes.iterator();
|
|
|
|
|
eventPicture.setColor(RasterPlotter.GREY);
|
|
|
|
|
while (i.hasNext()) {
|
|
|
|
|
long[] positions = seedDB.scheme.dhtPositions(i.next());
|
|
|
|
|
for (int j = 0; j < positions.length; j++) {
|
|
|
|
|
angle = (int) (360.0 * (((double) positions[j]) / ((double) Long.MAX_VALUE)));
|
|
|
|
|
final long[] positions = seedDB.scheme.dhtPositions(i.next());
|
|
|
|
|
for (final long position : positions) {
|
|
|
|
|
angle = (int) (360.0 * (((double) position) / ((double) Long.MAX_VALUE)));
|
|
|
|
|
eventPicture.arcLine(cx, cy, cr - 20, cr, angle, true, null, null, -1, -1, -1, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -177,14 +176,15 @@ public class NetworkGraph {
|
|
|
|
|
final int passiveLimit, final int potentialLimit,
|
|
|
|
|
final int maxCount, final int coronaangle,
|
|
|
|
|
final long communicationTimeout,
|
|
|
|
|
final String networkName, final String networkTitle, final String bgcolor) {
|
|
|
|
|
final String networkName, final String networkTitle, final String color_back) {
|
|
|
|
|
|
|
|
|
|
RasterPlotter networkPicture = new RasterPlotter(width, height, (bgcolor.equals("000000")) ? RasterPlotter.DrawMode.MODE_ADD : RasterPlotter.DrawMode.MODE_SUB, bgcolor);
|
|
|
|
|
final RasterPlotter.DrawMode drawMode = (RasterPlotter.darkColor(color_back)) ? RasterPlotter.DrawMode.MODE_ADD : RasterPlotter.DrawMode.MODE_SUB;
|
|
|
|
|
final RasterPlotter networkPicture = new RasterPlotter(width, height, drawMode, color_back);
|
|
|
|
|
if (seedDB == null) return networkPicture; // no other peers known
|
|
|
|
|
|
|
|
|
|
final int maxradius = Math.min(width, height) / 2;
|
|
|
|
|
final int innerradius = maxradius * 4 / 10;
|
|
|
|
|
int outerradius = maxradius - 20;
|
|
|
|
|
final int outerradius = maxradius - 20;
|
|
|
|
|
|
|
|
|
|
// draw network circle
|
|
|
|
|
networkPicture.setColor(COL_DHTCIRCLE);
|
|
|
|
@ -253,15 +253,15 @@ public class NetworkGraph {
|
|
|
|
|
|
|
|
|
|
// draw DHT activity
|
|
|
|
|
if (communicationTimeout >= 0) {
|
|
|
|
|
Date horizon = new Date(System.currentTimeMillis() - communicationTimeout);
|
|
|
|
|
for (Hit event: yacyChannel.channels(yacyChannel.DHTRECEIVE)) {
|
|
|
|
|
final Date horizon = new Date(System.currentTimeMillis() - communicationTimeout);
|
|
|
|
|
for (final Hit event: yacyChannel.channels(yacyChannel.DHTRECEIVE)) {
|
|
|
|
|
if (event == null || event.getPubDate() == null) continue;
|
|
|
|
|
if (event.getPubDate().after(horizon)) {
|
|
|
|
|
//System.out.println("*** NETWORK-DHTRECEIVE: " + event.getLink());
|
|
|
|
|
drawNetworkPictureDHT(networkPicture, width / 2, height / 2, innerradius, seedDB.mySeed(), seedDB.get(event.getLink()), COL_DHTIN, coronaangle, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (Hit event: yacyChannel.channels(yacyChannel.DHTSEND)) {
|
|
|
|
|
for (final Hit event: yacyChannel.channels(yacyChannel.DHTSEND)) {
|
|
|
|
|
if (event == null || event.getPubDate() == null) continue;
|
|
|
|
|
if (event.getPubDate().after(horizon)) {
|
|
|
|
|
//System.out.println("*** NETWORK-DHTSEND: " + event.getLink());
|
|
|
|
@ -280,7 +280,7 @@ public class NetworkGraph {
|
|
|
|
|
return networkPicture;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void drawNetworkPictureDHT(final RasterPlotter img, final int centerX, final int centerY, final int innerradius, final yacySeed mySeed, final yacySeed otherSeed, final String colorLine, final int coronaangle, boolean out) {
|
|
|
|
|
private static void drawNetworkPictureDHT(final RasterPlotter img, final int centerX, final int centerY, final int innerradius, final yacySeed mySeed, final yacySeed otherSeed, final String colorLine, final int coronaangle, final boolean out) {
|
|
|
|
|
final int angleMy = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(ASCII.getBytes(mySeed.hash), null)) / ((double) Long.MAX_VALUE)));
|
|
|
|
|
final int angleOther = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(ASCII.getBytes(otherSeed.hash), null)) / ((double) Long.MAX_VALUE)));
|
|
|
|
|
// draw line
|
|
|
|
@ -317,31 +317,31 @@ public class NetworkGraph {
|
|
|
|
|
PrintTool.arcPrint(img, centerX, centerY, innerradius + linelength, angle, name);
|
|
|
|
|
|
|
|
|
|
// draw corona around dot for crawling activity
|
|
|
|
|
int ppmx = seed.getPPM() / 30;
|
|
|
|
|
final int ppmx = seed.getPPM() / 30;
|
|
|
|
|
if (coronaangle >= 0 && ppmx > 0) {
|
|
|
|
|
drawCorona(img, centerX, centerY, innerradius, angle, dotsize, ppmx, coronaangle, true, false, 24, 24, 24); // color = 0..63
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// draw corona around dot for query activity
|
|
|
|
|
int qphx = ((int) (seed.getQPM() * 4.0));
|
|
|
|
|
final int qphx = ((int) (seed.getQPM() * 4.0));
|
|
|
|
|
if (coronaangle >= 0 && qphx > 0) {
|
|
|
|
|
drawCorona(img, centerX, centerY, innerradius, angle, dotsize, qphx, coronaangle, false, true, 8, 62, 8); // color = 0..63
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void drawCorona(final RasterPlotter img, final int centerX, final int centerY, final int innerradius, int angle, int dotsize, int strength, int coronaangle, boolean inside, boolean split, int r, int g, int b) {
|
|
|
|
|
double ca = Math.PI * 2.0 * ((double) coronaangle) / 360.0;
|
|
|
|
|
private static void drawCorona(final RasterPlotter img, final int centerX, final int centerY, final int innerradius, final int angle, final int dotsize, int strength, final int coronaangle, final boolean inside, final boolean split, final int r, final int g, final int b) {
|
|
|
|
|
final double ca = Math.PI * 2.0 * (coronaangle) / 360.0;
|
|
|
|
|
if (strength > 4) strength = 4;
|
|
|
|
|
// draw a wave around crawling peers
|
|
|
|
|
double wave;
|
|
|
|
|
final int waveradius = innerradius / 2;
|
|
|
|
|
int segments = 72;
|
|
|
|
|
final int segments = 72;
|
|
|
|
|
for (int radius = 0; radius < waveradius; radius++) {
|
|
|
|
|
wave = ((double) (waveradius - radius) * strength) * (1.0 + Math.sin(Math.PI * 16 * radius / waveradius + ((inside) ? ca : -ca))) / 2.0 / (double) waveradius;
|
|
|
|
|
wave = ((double) (waveradius - radius) * strength) * (1.0 + Math.sin(Math.PI * 16 * radius / waveradius + ((inside) ? ca : -ca))) / 2.0 / waveradius;
|
|
|
|
|
img.setColor(((((long) (r * wave)) & 0xff) << 16) | (((long) ((g * wave)) & 0xff) << 8) | ((((long) (b * wave))) & 0xff));
|
|
|
|
|
if (split) {
|
|
|
|
|
for (int i = 0; i < segments; i++) {
|
|
|
|
|
int a = (coronaangle + 360 * i) / segments;
|
|
|
|
|
final int a = (coronaangle + 360 * i) / segments;
|
|
|
|
|
img.arcArc(centerX, centerY, innerradius, angle, dotsize + radius, dotsize + radius, a, a + 180/segments);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|