From 8ce936bcddb576727d6920518986411c3d95318e Mon Sep 17 00:00:00 2001 From: orbiter Date: Thu, 21 Jan 2010 22:06:03 +0000 Subject: [PATCH] added an api recording function: it shall be possible to record all operations on YaCy in a database that should make it possible 1) to re-create a setting on fresh peers 2) to transmit a setting from one peer to another 3) to re-create crawl starts after a complete deletion of the index This functionality will also support 4) scheduled re-crawls (new implementation) To implement this, a new database structure has been crated that stores maps into blob heaps. to encode maps the b-encoding technique was used (this is the same encoding that torrent files use) - added a b-encoder - enhanced the b-decoder - added a b-encoded map heap data structure - added a table organisation based on b-encoded heaps - added a servlet to maintain such tables (see Tables_p.html) - integrated the servlet into the Advanced Settings menu - added an api recording based on the new tables git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6606 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/Blacklist_p.java | 8 +- htroot/ConfigBasic.java | 5 +- htroot/ConfigLanguage_p.java | 4 + htroot/ConfigNetwork_p.java | 3 + htroot/ConfigPortal.java | 6 +- htroot/Crawler_p.java | 18 +- htroot/Settings_p.html | 5 + htroot/Tables_p.html | 86 +++++ htroot/Tables_p.java | 194 ++++++++++ htroot/env/templates/header.template | 2 - .../anomic/crawler/retrieval/FTPLoader.java | 5 +- source/de/anomic/net/ftpc.java | 4 +- source/de/anomic/search/Switchboard.java | 32 +- source/de/anomic/server/serverSwitch.java | 12 +- source/de/anomic/yacy/yacyClient.java | 2 +- .../net/yacy/kelondro/blob/BEncodedHeap.java | 176 +++++++-- .../yacy/kelondro/blob/BEncodedHeapArray.java | 333 ++++++++++++++++++ source/net/yacy/kelondro/blob/Heap.java | 42 +-- .../net/yacy/kelondro/blob/HeapModifier.java | 10 +- source/net/yacy/kelondro/blob/HeapReader.java | 63 +++- source/net/yacy/kelondro/blob/HeapWriter.java | 6 +- .../net/yacy/kelondro/blob/MapDataMining.java | 96 ++--- source/net/yacy/kelondro/util/BDecoder.java | 64 ++++ source/net/yacy/kelondro/util/BEncoder.java | 70 +++- source/net/yacy/yacy.java | 4 +- 25 files changed, 1089 insertions(+), 161 deletions(-) create mode 100644 htroot/Tables_p.html create mode 100644 htroot/Tables_p.java create mode 100644 source/net/yacy/kelondro/blob/BEncodedHeapArray.java diff --git a/htroot/Blacklist_p.java b/htroot/Blacklist_p.java index e9f73a00d..0e1718e49 100644 --- a/htroot/Blacklist_p.java +++ b/htroot/Blacklist_p.java @@ -250,8 +250,12 @@ public class Blacklist_p { * =========================================================== */ blacklistToUse = post.get("currentBlacklist", "").trim(); - - final String temp = addBlacklistEntry(blacklistToUse, post.get("newEntry", "").trim(), header, supportedBlacklistTypes); + String blentry = post.get("newEntry", "").trim(); + + // store this call as api call + listManager.switchboard.recordAPICall(post, "Blacklist_p.html", "blacklist", "add to blacklist: " + blentry); + + final String temp = addBlacklistEntry(blacklistToUse, blentry, header, supportedBlacklistTypes); if (temp != null) { prop.put("LOCATION", temp); return prop; diff --git a/htroot/ConfigBasic.java b/htroot/ConfigBasic.java index 95714bf51..054247c0d 100644 --- a/htroot/ConfigBasic.java +++ b/htroot/ConfigBasic.java @@ -70,7 +70,10 @@ public class ConfigBasic { return prop; } - // starting a peer ping + // store this call as api call + if (post != null && post.containsKey("set")) { + sb.recordAPICall(post, "ConfigBasic.html", "configuration", "basic settings"); + } //boolean doPeerPing = false; if ((sb.peers.mySeed().isVirgin()) || (sb.peers.mySeed().isJunior())) { diff --git a/htroot/ConfigLanguage_p.java b/htroot/ConfigLanguage_p.java index efcedf281..277897012 100644 --- a/htroot/ConfigLanguage_p.java +++ b/htroot/ConfigLanguage_p.java @@ -46,6 +46,7 @@ import de.anomic.data.translator; import de.anomic.http.client.Client; import de.anomic.http.server.HeaderFramework; import de.anomic.http.server.RequestHeader; +import de.anomic.search.Switchboard; import de.anomic.server.serverObjects; import de.anomic.server.serverSwitch; import java.util.Collections; @@ -72,6 +73,9 @@ public class ConfigLanguage_p { if (post != null){ String selectedLanguage = post.get("language"); + // store this call as api call + ((Switchboard) env).recordAPICall(post, "ConfigLanguage.html", "configuration", "language settings: " + selectedLanguage); + //change language if(post.containsKey("use_button") && selectedLanguage != null){ /* Only change language if filename is contained in list of filesnames diff --git a/htroot/ConfigNetwork_p.java b/htroot/ConfigNetwork_p.java index d7c4ab758..ef0d1c2c2 100644 --- a/htroot/ConfigNetwork_p.java +++ b/htroot/ConfigNetwork_p.java @@ -54,6 +54,9 @@ public class ConfigNetwork_p { if (post != null) { + // store this call as api call + sb.recordAPICall(post, "ConfigNetwork.html", "configuration", "network settings"); + if (post.containsKey("changeNetwork")) { final String networkDefinition = post.get("networkDefinition", "defaults/yacy.network.freeworld.unit"); if (networkDefinition.equals(sb.getConfig("network.unit.definition", ""))) { diff --git a/htroot/ConfigPortal.java b/htroot/ConfigPortal.java index f57872082..4206419fd 100644 --- a/htroot/ConfigPortal.java +++ b/htroot/ConfigPortal.java @@ -57,7 +57,11 @@ public class ConfigPortal { } } if (post.containsKey("searchpage_set")) { - sb.setConfig(SwitchboardConstants.GREETING, post.get(SwitchboardConstants.GREETING, "")); + String newGreeting = post.get(SwitchboardConstants.GREETING, ""); + // store this call as api call + sb.recordAPICall(post, "ConfigPortal.html", "appearance", "new portal design. greeting: " + newGreeting); + + sb.setConfig(SwitchboardConstants.GREETING, newGreeting); sb.setConfig(SwitchboardConstants.GREETING_HOMEPAGE, post.get(SwitchboardConstants.GREETING_HOMEPAGE, "")); sb.setConfig(SwitchboardConstants.GREETING_LARGE_IMAGE, post.get(SwitchboardConstants.GREETING_LARGE_IMAGE, "")); sb.setConfig(SwitchboardConstants.GREETING_SMALL_IMAGE, post.get(SwitchboardConstants.GREETING_SMALL_IMAGE, "")); diff --git a/htroot/Crawler_p.java b/htroot/Crawler_p.java index 070150d54..4dadbc9c4 100644 --- a/htroot/Crawler_p.java +++ b/htroot/Crawler_p.java @@ -130,16 +130,8 @@ public class Crawler_p { if (sb.peers == null) { prop.put("info", "3"); } else { - // log a GET url for this crawl start for possible use in cronjobs - Log.logInfo("CRAWLSTART-URL", "http://localhost:" + sb.getConfig("port", "8080") + "/Crawler_p.html?" + post.toString()); - - // set new properties - final boolean fullDomain = post.get("range", "wide").equals("domain"); // special property in simple crawl start - final boolean subPath = post.get("range", "wide").equals("subpath"); // special property in simple crawl start - String crawlingStart = post.get("crawlingURL","").trim(); // the crawljob start url - - // adding the prefix http:// if necessary + // add the prefix http:// if necessary int pos = crawlingStart.indexOf("://"); if (pos == -1) crawlingStart = "http://" + crawlingStart; @@ -147,6 +139,14 @@ public class Crawler_p { DigestURI crawlingStartURL = null; try {crawlingStartURL = new DigestURI(crawlingStart, null);} catch (final MalformedURLException e1) {} crawlingStart = (crawlingStartURL == null) ? null : crawlingStartURL.toNormalform(true, true); + + // store this call as api call + sb.recordAPICall(post, "Crawler_p.html", "crawler", "crawl start for " + crawlingStartURL.getHost()); + + // set new properties + final boolean fullDomain = post.get("range", "wide").equals("domain"); // special property in simple crawl start + final boolean subPath = post.get("range", "wide").equals("subpath"); // special property in simple crawl start + // set the crawling filter String newcrawlingMustMatch = post.get("mustmatch", CrawlProfile.MATCH_ALL); diff --git a/htroot/Settings_p.html b/htroot/Settings_p.html index a10298134..6b29782f4 100644 --- a/htroot/Settings_p.html +++ b/htroot/Settings_p.html @@ -18,6 +18,11 @@
  • Performance Settings for Memory
  • Performance Settings of Search Sequence
  • +