diff --git a/htroot/AccessTracker_p.html b/htroot/AccessTracker_p.html index 0e57d6d3f..6010163ff 100644 --- a/htroot/AccessTracker_p.html +++ b/htroot/AccessTracker_p.html @@ -9,7 +9,8 @@ #(page)# -

Server Access Tracker

+

Server Access Overview

+

This is a list of requests to the local http server within the last hour.

+

Showing #[num]# requests.

+ + + + + + + + + + + + #{list}# + + + + + + + + #{/list}# +
HostAccess Count During
last Secondlast Minutelast 10 Minuteslast Hour
#[host]##[countSecond]##[countMinute]##[count10Minutes]##[countHour]#
+ :: +

Server Access Details

This is a list of requests to the local http server within the last hour.

Showing #[num]# requests.

@@ -35,7 +61,6 @@ #{/list}#
:: - ::

Local Searches

This is a list of searches that had been requested from this' peer search interface

Showing #[num]# entries from a total of #[total]# requests.

diff --git a/htroot/AccessTracker_p.java b/htroot/AccessTracker_p.java index e3ecbb4e6..fe3b9e35a 100644 --- a/htroot/AccessTracker_p.java +++ b/htroot/AccessTracker_p.java @@ -30,6 +30,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; +import java.util.TreeMap; import java.util.TreeSet; import de.anomic.http.httpHeader; @@ -38,12 +39,11 @@ import de.anomic.plasma.plasmaSearchQuery; import de.anomic.plasma.plasmaSwitchboard; import de.anomic.server.serverObjects; import de.anomic.server.serverSwitch; -import de.anomic.server.serverTrack; import de.anomic.yacy.yacyCore; import de.anomic.yacy.yacySeed; public class AccessTracker_p { - + public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch sb) { plasmaSwitchboard switchboard = (plasmaSwitchboard) sb; @@ -58,20 +58,51 @@ public class AccessTracker_p { if (page == 0) { Iterator i = switchboard.accessHosts(); String host; - ArrayList access; + TreeMap access; int entCount = 0; - serverTrack track; while ((entCount < maxCount) && (i.hasNext())) { host = (String) i.next(); access = switchboard.accessTrack(host); - - trackl: for (int j = access.size() - 1; j >= 0; j--) { - track = (serverTrack) access.get(j); - if (track == null) continue trackl; - prop.put("page_list_" + entCount + "_host", host); - prop.put("page_list_" + entCount + "_date", yacyCore.universalDateShortString(new Date(track.time))); - prop.put("page_list_" + entCount + "_path", track.path); - entCount++; + prop.put("page_list_" + entCount + "_host", host); + prop.put("page_list_" + entCount + "_countSecond", access.tailMap(new Long(System.currentTimeMillis() - 1000)).size()); + prop.put("page_list_" + entCount + "_countMinute", access.tailMap(new Long(System.currentTimeMillis() - 1000 * 60)).size()); + prop.put("page_list_" + entCount + "_count10Minutes", access.tailMap(new Long(System.currentTimeMillis() - 1000 * 60 * 10)).size()); + prop.put("page_list_" + entCount + "_countHour", access.tailMap(new Long(System.currentTimeMillis() - 1000 * 60 * 60)).size()); + entCount++; + } + prop.put("page_list", entCount); + prop.put("page_num", entCount); + } + if (page == 1) { + String host = post.get("host", ""); + int entCount = 0; + TreeMap access; + Map.Entry entry; + if (host.length() > 0) { + access = switchboard.accessTrack(host); + if (access != null) { + Iterator ii = access.entrySet().iterator(); + while (ii.hasNext()) { + entry = (Map.Entry) ii.next(); + prop.put("page_list_" + entCount + "_host", host); + prop.put("page_list_" + entCount + "_date", yacyCore.universalDateShortString(new Date(((Long) entry.getKey()).longValue()))); + prop.put("page_list_" + entCount + "_path", (String) entry.getValue()); + entCount++; + } + } + } else { + Iterator i = switchboard.accessHosts(); + while ((entCount < maxCount) && (i.hasNext())) { + host = (String) i.next(); + access = switchboard.accessTrack(host); + Iterator ii = access.entrySet().iterator(); + while (ii.hasNext()) { + entry = (Map.Entry) ii.next(); + prop.put("page_list_" + entCount + "_host", host); + prop.put("page_list_" + entCount + "_date", yacyCore.universalDateShortString(new Date(((Long) entry.getKey()).longValue()))); + prop.put("page_list_" + entCount + "_path", (String) entry.getValue()); + entCount++; + } } } prop.put("page_list", entCount); diff --git a/htroot/ConfigNetwork_p.html b/htroot/ConfigNetwork_p.html index 23078a22d..292d4950d 100644 --- a/htroot/ConfigNetwork_p.html +++ b/htroot/ConfigNetwork_p.html @@ -137,6 +137,15 @@ --> +
+ + +
+
+ You are visible to other peers and contact them to distribute your presence.
+ Your peer does not accept any outside index data, but responds on all remote search requests. +

#[cluster.peers.yacydomain.hashes]# -
- - -
-
- You are visible to other peers and contact them to distribute your presence.
- Your peer does not accept any outside index data, but responds on all remote search requests. -
When you allow access from the YaCy network, your data is recognized using keywords.
diff --git a/source/de/anomic/server/serverAbstractSwitch.java b/source/de/anomic/server/serverAbstractSwitch.java index 890039cb1..51258a935 100644 --- a/source/de/anomic/server/serverAbstractSwitch.java +++ b/source/de/anomic/server/serverAbstractSwitch.java @@ -43,7 +43,6 @@ package de.anomic.server; import java.io.File; import java.io.IOException; import java.net.InetAddress; -import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -151,40 +150,37 @@ public abstract class serverAbstractSwitch implements serverSwitch { public void track(String host, String accessPath) { // learn that a specific host has accessed a specific path - ArrayList access = (ArrayList) accessTracker.get(host); - if (access == null) access = new ArrayList(); - access.add(new serverTrack(accessPath)); + if (accessPath == null) accessPath="NULL"; + TreeMap access = (TreeMap) accessTracker.get(host); + if (access == null) access = new TreeMap(); + access.put(new Long(System.currentTimeMillis()), accessPath); - // clear too old entries - clearTooOldAccess(access); - // write back to tracker - accessTracker.put(host, access); + accessTracker.put(host, clearTooOldAccess(access)); } - public ArrayList accessTrack(String host) { + public TreeMap accessTrack(String host) { // returns mapping from Long(accesstime) to path - ArrayList access = (ArrayList) accessTracker.get(host); + TreeMap access = (TreeMap) accessTracker.get(host); if (access == null) return null; // clear too old entries - if (clearTooOldAccess(access)) { + int oldsize = access.size(); + if ((access = clearTooOldAccess(access)).size() != oldsize) { // write back to tracker - accessTracker.put(host, access); + if (access.size() == 0) { + accessTracker.remove(host); + } else { + accessTracker.put(host, access); + } } return access; } - private boolean clearTooOldAccess(ArrayList access) { - boolean changed = false; - while ((access.size() > 0) && - (((serverTrack) access.get(0)).time < (System.currentTimeMillis() - maxTrackingTime))) { - access.remove(0); - changed = true; - } - return changed; + private TreeMap clearTooOldAccess(TreeMap access) { + return new TreeMap(access.tailMap(new Long(System.currentTimeMillis() - maxTrackingTime))); } public Iterator accessHosts() { diff --git a/source/de/anomic/server/serverSwitch.java b/source/de/anomic/server/serverSwitch.java index d4f55e766..f1573e157 100644 --- a/source/de/anomic/server/serverSwitch.java +++ b/source/de/anomic/server/serverSwitch.java @@ -50,9 +50,10 @@ package de.anomic.server; import java.net.InetAddress; -import java.util.ArrayList; import java.util.Iterator; import java.util.Map; +import java.util.TreeMap; + import de.anomic.server.logging.serverLog; public interface serverSwitch { @@ -66,7 +67,7 @@ public interface serverSwitch { // access tracker public void track(String host, String accessPath); // learn that a specific host has accessed a specific path - public ArrayList accessTrack(String host); // returns mapping from Long(accesstime) to path + public TreeMap accessTrack(String host); // returns mapping from Long(accesstime) to path public Iterator accessHosts(); // returns an iterator of hosts in tracker (String) // a switchboard can have action listener diff --git a/source/de/anomic/server/serverTrack.java b/source/de/anomic/server/serverTrack.java deleted file mode 100644 index 49178b8df..000000000 --- a/source/de/anomic/server/serverTrack.java +++ /dev/null @@ -1,39 +0,0 @@ -// serverTrack.java -// (C) 2007 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany -// first published 11.06.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 - -package de.anomic.server; - -public class serverTrack { - - public long time; // access time - public String path; - - public serverTrack(String path) { - this.time = System.currentTimeMillis(); - this.path = path; - } - -}