added network history in /Network.html?page=5

pull/1/head
Michael Peter Christen 10 years ago
parent 26279b0993
commit 9aebbbebc0

@ -62,6 +62,7 @@
<li><a href="Network.html?page=1&maxCount=1000" class="MenuItemLink">Active&nbsp;Principal&nbsp;and&nbsp;Senior&nbsp;Peers</a></li>
<li><a href="Network.html?page=2&maxCount=1000" class="MenuItemLink">Passive&nbsp;Senior&nbsp;Peers</a></li>
<li><a href="Network.html?page=3&maxCount=1000" class="MenuItemLink">Junior&nbsp;(fragment)&nbsp;Peers</a></li>
<li><a href="Network.html?page=5" class="MenuItemLink">Network History</a></li>
</ul>
</div>
#(/menu)#
@ -85,6 +86,8 @@ document.getElementById("apilink").setAttribute("href", "Network.xml?" + window.
<h2>Junior Peers (a fragment) in '#[networkName]#' Network</h2>
::
<h2>Manually contacting Peer</h2>
::
<h2>Network History</h2>
#(/page)#
#(regexerror)#
::
@ -319,8 +322,8 @@ document.getElementById("apilink").setAttribute("href", "Network.xml?" + window.
</tr>
</table>
</div>
::
::
::
#(comment)#
::
<p style="color:red;">
@ -369,6 +372,29 @@ document.getElementById("apilink").setAttribute("href", "Network.xml?" + window.
<td><input type="button" value="contact current peer from this peer" onclick="top.location.href='http://' + document.getElementById('otherPeerAddress').value + '/Network.html?peerHash=#[my-hash]#&peerIP=#[my-ip]#&peerPort=#[my-port]#&page=4&addPeer=add+Peer'"/></td>
</tr>
</table>
::
<!--
possible column values:
aM activeLastMonth
aW activeLastWeek
aD activeLastDay
aH activeLastHour
cC countConnected (Active Senior)
cD countDisconnected (Passive Senior)
cP countPotential (Junior)
cR count of the RWI entries
cI size of the index (number of documents)
maxtime: number of hours in the past
scale: number of hours per scale unit in the bottom line
-->
<h3><b>Count of Connected Senior Peers</b> in the last two days, scale = 1h</h3>
<img src="/NetworkHistory.png?columns=cC&scale=1&maxtime=24" />
<h3><b>Count of all Active Peers Per Day</b> in the last week, scale = 1d</h3>
<img src="/NetworkHistory.png?columns=aD&scale=24&maxtime=168" />
<h3><b>Count of all Active Peers Per Week</b> in the last 30d, scale = 7d</h3>
<img src="/NetworkHistory.png?columns=aW&scale=168&maxtime=720" />
<h3><b>Count of all Active Peers Per Month</b> in the last 365d, scale = 30d</h3>
<img src="/NetworkHistory.png?columns=aM&scale=720&maxtime=8760" />
#(/table)#
#%env/templates/footer.template%#
</body>

@ -199,7 +199,7 @@ public class Network {
prop.put("table", 2); // triggers overview
prop.put("page", 0);
} else if (post != null && post.getInt("page", 1) == 4) {
prop.put("table", 4); // triggers overview
prop.put("table", 4); // triggers "Manually contacting Peer"
prop.put("page", 4);
if (sb.peers.mySeed() != null) {
@ -258,6 +258,9 @@ public class Network {
prop.put("table_comment",0);
}
} else if (post != null && post.getInt("page", 1) == 5) {
prop.put("page", 5); // triggers stats page
prop.put("table", 5);
} else {
// generate table
final int page = (post == null ? 1 : post.getInt("page", 1));

@ -24,8 +24,10 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.yacy.cora.date.GenericFormatter;
import net.yacy.cora.document.encoding.ASCII;
@ -49,7 +51,7 @@ public class NetworkHistory {
final int maxtime = post.getInt("maxtime", 48); // hours
final int bottomscale = post.getInt("scale", 1); // 1h
final String[] columns = post.get("columns", "cC").split("\\|"); // new String[]{"aM", "aW", "aD", "aH", "cC", "cD", "cP", "cR", "cI"};
final String[] columnsx = post.get("columns", "cC").split("\\|"); // new String[]{"aM", "aW", "aD", "aH", "cC", "cD", "cP", "cR", "cI"};
/*
aM activeLastMonth
aW activeLastWeek
@ -61,11 +63,12 @@ public class NetworkHistory {
cR count of the RWI entries
cI size of the index (number of documents)
*/
final Set<String> columns = new LinkedHashSet<>();
for (String col: columnsx) columns.add(col);
// scan the database and put in values
List<Map<String, Long>> rows = new ArrayList<>(maxtime * 2);
long now = System.currentTimeMillis();
long timelimit = now - maxtime * 60 * 60 * 1000;
long timelimit = now - maxtime * 3600000L;
try {
// BEncodedHeap statTable = sb.tables.getHeap("stats");
// Iterator<byte[]> i = statTable.keys(false, false);
@ -105,8 +108,22 @@ public class NetworkHistory {
final int topborder = 20;
final int bottomborder = 20;
final int vspace = height - topborder - bottomborder;
final int leftscale = (maxpeers / 100) * 10;
ChartPlotter chart = new ChartPlotter(width, height, 0xFFFFFFl, 0x000000l, 0xAAAAAAl, leftborder, rightborder, topborder, bottomborder, "YACY NETWORK HISTORY", "IN THE LAST 48 HOURS");
final int leftscale = maxpeers / 10;
String timestr = maxtime + " HOURS";
if (maxtime > 24 && maxtime % 24 == 0) timestr = (maxtime / 24) + " DAYS";
if (maxtime == 168) timestr = "WEEK";
if (maxtime > 168 && maxtime % 168 == 0) timestr = (maxtime / 168) + " WEEKS";
String headline = "YACY NETWORK HISTORY";
if (columns.contains("aM")) headline += ", ACTIVE PEERS WITHIN THE LAST MONTH";
if (columns.contains("aW")) headline += ", ACTIVE PEERS WITHIN THE LAST WEEK";
if (columns.contains("aD")) headline += ", ACTIVE PEERS WITHIN THE LAST DAY";
if (columns.contains("aH")) headline += ", ACTIVE PEERS WITHIN THE LAST HOUR";
if (columns.contains("cC")) headline += ", ACTIVE SENIOR PEERS";
if (columns.contains("cD")) headline += ", PASSIVE SENIOR PEERS";
if (columns.contains("cP")) headline += ", POTENTIAL JUNIOR PEERS";
if (columns.contains("cI")) headline = "YACY INDEX SIZE HISTORY: NUMBER OF DOCUMENTS";
if (columns.contains("cR")) headline = "YACY INDEX SIZE HISTORY: NUMBER OF RWI ENTRIES";
ChartPlotter chart = new ChartPlotter(width, height, 0xFFFFFFl, 0x000000l, 0xAAAAAAl, leftborder, rightborder, topborder, bottomborder, headline, "IN THE LAST " + timestr);
chart.declareDimension(ChartPlotter.DIMENSION_BOTTOM, bottomscale, hspace / (maxtime / bottomscale), -maxtime, 0x000000l, 0xCCCCCCl, "TIME/HOURS");
chart.declareDimension(ChartPlotter.DIMENSION_LEFT, leftscale, vspace * leftscale / maxpeers, 0, 0x008800l, null , "PEERS");

@ -190,7 +190,7 @@ public class Tables_p {
}
// adding the peer address
prop.put("address", sb.peers.mySeed().getPublicAddress(sb.peers.mySeed().getIP()));
//prop.put("address", sb.peers.mySeed().getPublicAddress(sb.peers.mySeed().getIP()));
// return rewrite properties
return prop;

Loading…
Cancel
Save