Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
*) Adding some logging statements to detect problems with seed upload functionality
thelidff937a9a389
diff --git a/source/de/anomic/yacy/seedUpload/yacySeedUploadFtp.java b/source/de/anomic/yacy/seedUpload/yacySeedUploadFtp.javaindex 13d9d9224..1fd231d71 100644--- a/source/de/anomic/yacy/seedUpload/yacySeedUploadFtp.java+++ b/source/de/anomic/yacy/seedUpload/yacySeedUploadFtp.java@@ -14,7 +14,7 @@ public class yacySeedUploadFtp implements yacySeedUploader {public static final String CONFIG_FTP_PASSWORD = "seedFTPPassword";public static final String CONFIG_FTP_PATH = "seedFTPPath";- public String uploadSeedFile (serverSwitch sb, yacySeedDB seedDB, File seedFile) {+ public String uploadSeedFile (serverSwitch sb, yacySeedDB seedDB, File seedFile) throws Exception {try {if (sb == null) throw new NullPointerException("Reference to serverSwitch nut not be null.");if (seedDB == null) throw new NullPointerException("Reference to seedDB must not be null.");@@ -29,11 +29,11 @@ public class yacySeedUploadFtp implements yacySeedUploader {String log = ftpc.put(seedFTPServer, seedFile, seedFTPPath.getParent(), seedFTPPath.getName(), seedFTPAccount, seedFTPPassword);return log;}- return "Seed upload settings not configured properly. password-len=" ++ throw new Exception ("Seed upload settings not configured properly. password-len=" +seedFTPPassword.length() + ", filePath=" +- seedFTPPath;+ seedFTPPath);} catch (Exception e) {- return "Error: " + e.getMessage();+ throw e;}}diff --git a/source/de/anomic/yacy/yacyCore.java b/source/de/anomic/yacy/yacyCore.javaindex 21fb53d6e..62f389fef 100644--- a/source/de/anomic/yacy/yacyCore.java+++ b/source/de/anomic/yacy/yacyCore.java@@ -227,11 +227,17 @@ public class yacyCore {// getting the seed upload method that should be used ...String seedUploadMethod = this.switchboard.getConfig("seedUploadMethod","");- if (!(seedUploadMethod.equalsIgnoreCase("none")) ||- ((seedUploadMethod.equals("")) &&- (this.switchboard.getConfig("seedFTPPassword","").length() > 0) &&- (this.switchboard.getConfig("seedFilePath", "").length() > 0))) {- if (seedUploadMethod.equals("")) this.switchboard.setConfig("seedUploadMethod","Ftp");+ if (+ (!seedUploadMethod.equalsIgnoreCase("none")) ||+ ((seedUploadMethod.equals("")) && (this.switchboard.getConfig("seedFTPPassword","").length() > 0)) ||+ ((seedUploadMethod.equals("")) && (this.switchboard.getConfig("seedFilePath", "").length() > 0))+ ) {+ if (seedUploadMethod.equals("")) {+ if (this.switchboard.getConfig("seedFTPPassword","").length() > 0)+ this.switchboard.setConfig("seedUploadMethod","Ftp");+ if (this.switchboard.getConfig("seedFilePath","").length() > 0)+ this.switchboard.setConfig("seedUploadMethod","File");+ }// we want to be a principal...saveSeedList();this.seedCacheSizeStamp = seedDB.sizeConnected();@@ -495,28 +501,39 @@ public class yacyCore {// be shure that we have something to sayif (seedDB.mySeed.getAddress() == null) {- throw new Exception ("We have no valid IP address until now");+ String errorMsg = "We have no valid IP address until now";+ log.logWarning("SaveSeedList: " + errorMsg);+ throw new Exception (errorMsg);}// getting the configured seed uploaderString seedUploadMethod = sb.getConfig("seedUploadMethod","");// for backward compatiblity ....- if ((seedUploadMethod.equalsIgnoreCase("Ftp")) ||+ if (+ (seedUploadMethod.equalsIgnoreCase("Ftp")) ||((seedUploadMethod.equals("")) &&- (sb.getConfig("seedFTPPassword","").length() > 0) &&- (sb.getConfig("seedFilePath", "").length() > 0))) {+ (sb.getConfig("seedFTPPassword","").length() > 0))+ ) {seedUploadMethod = "Ftp";sb.setConfig("seedUploadMethod",seedUploadMethod);- }+ } else if (+ (seedUploadMethod.equalsIgnoreCase("File")) ||+ (sb.getConfig("seedFilePath", "").length() > 0)+ ) {+ seedUploadMethod = "File";+ sb.setConfig("seedUploadMethod",seedUploadMethod);+ }// determine the seed uploader that should be used ...if (seedUploadMethod.equalsIgnoreCase("none")) return;yacySeedUploader uploader = getSeedUploader(seedUploadMethod);if (uploader == null) {- throw new Exception("Unable to get the proper uploader-class for seed uploading method '" + seedUploadMethod + "'.");- }+ String errorMsg = "Unable to get the proper uploader-class for seed uploading method '" + seedUploadMethod + "'.";+ log.logWarning("SaveSeedList: " + errorMsg);+ throw new Exception (errorMsg);+ }// ensure that the seed file url is configured properlyURL seedURL;@@ -526,7 +543,9 @@ public class yacyCore {if (!seedURLStr.toLowerCase().startsWith("http://")) throw new MalformedURLException("Unsupported protocol.");seedURL = new URL(seedURLStr);}catch(MalformedURLException e){- throw new Exception("Malformed seed file URL '" + sb.getConfig("seedURL","") + "'. " + e.getMessage());+ String errorMsg = "Malformed seed file URL '" + sb.getConfig("seedURL","") + "'. " + e.getMessage();+ log.logWarning("SaveSeedList: " + errorMsg);+ throw new Exception(errorMsg);}// upload the seed-list using the configured uploader class@@ -536,12 +555,15 @@ public class yacyCore {try {seedDB.mySeed.put("PeerType", "principal"); // this information shall also be uploaded+ log.logDebug("SaveSeedList: Using seed uploading method '" + seedUploadMethod + "' for seed-list uploading." ++ "\n\tPrevious peerType is '" + seedDB.mySeed.get("PeerType", "junior") + "'.");+//logt = seedDB.uploadCache(seedFTPServer, seedFTPAccount, seedFTPPassword, seedFTPPath, seedURL);logt = seedDB.uploadCache(uploader,sb, seedDB, seedURL);if (logt != null) {if (logt.indexOf("Error") >= 0) {seedDB.mySeed.put("PeerType", prevStatus);- log.logError("seed upload failed using " + uploader.getClass().getName() + " (error): " + logt.substring(logt.indexOf("Error") + 6));+ log.logError("SaveSeedList: seed upload failed using " + uploader.getClass().getName() + " (error): " + logt.substring(logt.indexOf("Error") + 6));throw new Exception("Seed-list uploading failed using uploader '" + uploader.getClass().getName() + "'\n(error): " + logt.substring(logt.indexOf("Error") + 6));}log.logInfo(logt);@@ -553,7 +575,7 @@ public class yacyCore {} catch (Exception e) {seedDB.mySeed.put("PeerType", prevStatus);sb.setConfig("yacyStatus", prevStatus);- log.logInfo("Seed upload failed (IO error): " + e.getMessage());+ log.logInfo("SaveSeedList: Seed upload failed (IO error): " + e.getMessage());throw new Exception("Seed-list uploading failed using uploader '" + uploader.getClass().getName() + "'\n(error): " + e.getMessage());}}diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.javaindex b4f4b515b..2ef97e1ee 100644--- a/source/de/anomic/yacy/yacySeedDB.java+++ b/source/de/anomic/yacy/yacySeedDB.java@@ -62,6 +62,7 @@ import de.anomic.net.ftpc;import de.anomic.plasma.plasmaSwitchboard;import de.anomic.server.serverCore;import de.anomic.server.serverSwitch;+import de.anomic.server.logging.serverLog;import de.anomic.tools.disorderHeap;public class yacySeedDB {@@ -534,14 +535,17 @@ public class yacySeedDB {String log = null;File seedFile = null;try {- // create a seed file which for uploading ...+ // create a seed file which for uploading ...seedFile = new File("seedFile.txt");+ serverLog.logDebug("YACY","SaveSeedList: Storing seedlist into tempfile " + seedFile.toString());Vector uv = storeCache(seedFile, true);// uploading the seed file+ serverLog.logDebug("YACY","SaveSeedList: Trying to upload seed-file ...");log = uploader.uploadSeedFile(sb,seedDB,seedFile);// check also if the result can be retrieved again+ serverLog.logDebug("YACY","SaveSeedList: Checking uploading success ...");if (checkCache(uv, seedURL))log = log + "UPLOAD CHECK - Success: the result vectors are equal" + serverCore.crlfString;else {