Skip to content

Commit

Permalink
*) Adding some logging statements to detect problems with seed upload…
Browse files Browse the repository at this point in the history
… functionality

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@297 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
theli committed Jun 17, 2005
1 parent 98230a6 commit dff937a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 20 deletions.
8 changes: 4 additions & 4 deletions source/de/anomic/yacy/seedUpload/yacySeedUploadFtp.java
Expand Up @@ -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.");
Expand All @@ -29,11 +29,11 @@ public String uploadSeedFile (serverSwitch sb, yacySeedDB seedDB, File seedFile)
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;
}
}

Expand Down
52 changes: 37 additions & 15 deletions source/de/anomic/yacy/yacyCore.java
Expand Up @@ -227,11 +227,17 @@ public void publishSeedList() {
// 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();
Expand Down Expand Up @@ -495,28 +501,39 @@ public static void saveSeedList(serverSwitch sb)

// be shure that we have something to say
if (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 uploader
String 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 properly
URL seedURL;
Expand All @@ -526,7 +543,9 @@ public static void saveSeedList(serverSwitch sb)
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
Expand All @@ -536,12 +555,15 @@ public static void saveSeedList(serverSwitch sb)
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);
Expand All @@ -553,7 +575,7 @@ public static void saveSeedList(serverSwitch sb)
} 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());
}
}
Expand Down
6 changes: 5 additions & 1 deletion source/de/anomic/yacy/yacySeedDB.java
Expand Up @@ -62,6 +62,7 @@
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 {
Expand Down Expand Up @@ -534,14 +535,17 @@ public String uploadCache(yacySeedUploader uploader,
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 {
Expand Down

0 comments on commit dff937a

Please sign in to comment.