From 7b35d54c6c86d421fadf70c24116959247889705 Mon Sep 17 00:00:00 2001 From: orbiter Date: Tue, 23 Sep 2008 12:11:19 +0000 Subject: [PATCH] fixed some problems with network switching (was not completely 'clean') git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5200 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/ConfigBasic.java | 4 +- htroot/CrawlStart_p.html | 2 +- htroot/CrawlStart_p.java | 4 + source/de/anomic/index/indexRAMRI.java | 2 +- .../de/anomic/plasma/plasmaSwitchboard.java | 74 ++++++++++++------- 5 files changed, 56 insertions(+), 30 deletions(-) diff --git a/htroot/ConfigBasic.java b/htroot/ConfigBasic.java index a1e293392..ed2f6a49a 100644 --- a/htroot/ConfigBasic.java +++ b/htroot/ConfigBasic.java @@ -154,8 +154,8 @@ public class ConfigBasic { // switch to intranet network sb.switchNetwork("defaults/yacy.network.intranet.unit"); // switch to p2p mode: enable ad-hoc networks between intranet users - sb.setConfig(plasmaSwitchboardConstants.INDEX_DIST_ALLOW, true); - sb.setConfig(plasmaSwitchboardConstants.INDEX_RECEIVE_ALLOW, true); + sb.setConfig(plasmaSwitchboardConstants.INDEX_DIST_ALLOW, false); + sb.setConfig(plasmaSwitchboardConstants.INDEX_RECEIVE_ALLOW, false); } } diff --git a/htroot/CrawlStart_p.html b/htroot/CrawlStart_p.html index dc4e67a70..0f9f23740 100644 --- a/htroot/CrawlStart_p.html +++ b/htroot/CrawlStart_p.html @@ -31,7 +31,7 @@ : - + diff --git a/htroot/CrawlStart_p.java b/htroot/CrawlStart_p.java index c649c49dd..f789b154a 100644 --- a/htroot/CrawlStart_p.java +++ b/htroot/CrawlStart_p.java @@ -25,6 +25,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import de.anomic.http.httpRequestHeader; +import de.anomic.plasma.plasmaSwitchboard; import de.anomic.plasma.plasmaSwitchboardConstants; import de.anomic.server.serverObjects; import de.anomic.server.serverSwitch; @@ -33,9 +34,12 @@ public class CrawlStart_p { public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch env) { // return variable that accumulates replacements + final plasmaSwitchboard sb = (plasmaSwitchboard) env; final serverObjects prop = new serverObjects(); // define visible variables + String a = sb.webIndex.seedDB.mySeed().getPublicAddress(); + prop.put("starturl", (sb.getConfig("network.unit.name", "").equals("intranet")) ? "http://" + ((a == null) ? "localhost:" + sb.getConfig("port", "8080") : a) + "/repository/" : "http://"); prop.put("proxyPrefetchDepth", env.getConfig("proxyPrefetchDepth", "0")); prop.put("crawlingDepth", env.getConfig("crawlingDepth", "0")); prop.put("crawlingFilter", env.getConfig("crawlingFilter", "0")); diff --git a/source/de/anomic/index/indexRAMRI.java b/source/de/anomic/index/indexRAMRI.java index e8a014523..ae0aa8a28 100644 --- a/source/de/anomic/index/indexRAMRI.java +++ b/source/de/anomic/index/indexRAMRI.java @@ -157,7 +157,7 @@ public final class indexRAMRI implements indexRI, indexRIReader { public synchronized String maxScoreWordHash() { - if (heap.size() == 0) return null; + if (heap == null || heap.size() == 0) return null; try { return hashScore.getMaxObject(); } catch (final Exception e) { diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java index a87e60ec9..fc1fb6eba 100644 --- a/source/de/anomic/plasma/plasmaSwitchboard.java +++ b/source/de/anomic/plasma/plasmaSwitchboard.java @@ -273,9 +273,6 @@ public final class plasmaSwitchboard extends serverAbstractSwitch ki = configKeys(); + ArrayList d = new ArrayList(); + String k; + while (ki.hasNext()) { + k = ki.next(); + if (k.startsWith("network.unit.update.location")) d.add(k); + if (k.startsWith("network.unit.bootstrap")) d.add(k); } + for (String s:d) this.removeConfig(s); // must be removed afterwards othervise a ki.remove() would not remove the property on file // include additional network definition properties into our settings // note that these properties cannot be set in the application because they are @@ -678,30 +679,32 @@ public final class plasmaSwitchboard extends serverAbstractSwitch initProps; if (networkUnitDefinition.startsWith("http://")) { try { - sb.setConfig(plasmaSwitchboard.loadHashMap(new yacyURL(networkUnitDefinition, null))); + setConfig(plasmaSwitchboard.loadHashMap(new yacyURL(networkUnitDefinition, null))); } catch (final MalformedURLException e) { } } else { - final File networkUnitDefinitionFile = (networkUnitDefinition.startsWith("/")) ? new File(networkUnitDefinition) : new File(sb.getRootPath(), networkUnitDefinition); + final File networkUnitDefinitionFile = (networkUnitDefinition.startsWith("/")) ? new File(networkUnitDefinition) : new File(getRootPath(), networkUnitDefinition); if (networkUnitDefinitionFile.exists()) { initProps = serverFileUtils.loadHashMap(networkUnitDefinitionFile); - sb.setConfig(initProps); + setConfig(initProps); } } if (networkGroupDefinition.startsWith("http://")) { try { - sb.setConfig(plasmaSwitchboard.loadHashMap(new yacyURL(networkGroupDefinition, null))); + setConfig(plasmaSwitchboard.loadHashMap(new yacyURL(networkGroupDefinition, null))); } catch (final MalformedURLException e) { } } else { - final File networkGroupDefinitionFile = new File(sb.getRootPath(), networkGroupDefinition); + final File networkGroupDefinitionFile = new File(getRootPath(), networkGroupDefinition); if (networkGroupDefinitionFile.exists()) { initProps = serverFileUtils.loadHashMap(networkGroupDefinitionFile); - sb.setConfig(initProps); + setConfig(initProps); } } // set release locations + int i = 0; + String location; while (true) { - location = sb.getConfig("network.unit.update.location" + i, ""); + location = getConfig("network.unit.update.location" + i, ""); if (location.length() == 0) break; try { yacyVersion.latestReleaseLocations.add(new yacyURL(location, null)); @@ -712,11 +715,30 @@ public final class plasmaSwitchboard extends serverAbstractSwitch= 0; - sb.acceptLocalURLs = "local.any".indexOf(sb.getConfig("network.unit.domain", "global")) >= 0; + acceptGlobalURLs = "global.any".indexOf(getConfig("network.unit.domain", "global")) >= 0; + acceptLocalURLs = "local.any".indexOf(getConfig("network.unit.domain", "global")) >= 0; + + // in intranet and portal network set robinson mode + if (networkUnitDefinition.equals("defaults/yacy.network.webportal.unit") || + networkUnitDefinition.equals("defaults/yacy.network.intranet.unit")) { + // switch to robinson mode + setConfig("crawlResponse", "false"); + setConfig(plasmaSwitchboardConstants.INDEX_DIST_ALLOW, false); + setConfig(plasmaSwitchboardConstants.INDEX_RECEIVE_ALLOW, false); + webIndex.seedDB.mySeed().setFlagAcceptRemoteIndex(false); + } + + // in freeworld network set full p2p mode + if (networkUnitDefinition.equals("defaults/yacy.network.freeworld.unit")) { + // switch to robinson mode + setConfig("crawlResponse", "true"); + setConfig(plasmaSwitchboardConstants.INDEX_DIST_ALLOW, true); + setConfig(plasmaSwitchboardConstants.INDEX_RECEIVE_ALLOW, true); + webIndex.seedDB.mySeed().setFlagAcceptRemoteIndex(true); + } } @@ -736,7 +758,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch