*) Status.java: showing amount of time since last upload of seed-file

*) hello.java: adding additional output for principal-downgrade bug
*) httpd.java, httpdFileHandler.java, httpdProxyHandler.java: improved errorhandling
*) yacyCore.java: trying to fix principal-downgrade bug
*) yacySeed.java: adding some constants

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@329 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 20 years ago
parent eee6322aaf
commit 08e4334c1d

@ -78,9 +78,11 @@ You can of course <a href="index.html">search the internet</a> using the other p
#(seedServer)#
Disabled. To enable this you need a ftp account where you can upload files to a web space. If you do that, you become a YaCy root server. You can configure your account details on the <a href="Settings_p.html">Settings page</a>.
::
Enabled: Updating periodically to server #[seedServer]#
Enabled: Updating periodically to server #[seedServer]#.
Last upload: #[lastUpload]# ago.
::
Enabled: Updating periodically to file #[seedFile]#
Enabled: Updating periodically to file #[seedFile]#.
Last upload: #[lastUpload]# ago.
#(/seedServer)#
</td></tr>
<tr class="TableCellLight"><td>Auto-popup on start-up</td><td>

@ -157,6 +157,7 @@ public class Status {
if (env.getConfig("seedFilePath","").length() > 0)
env.setConfig("seedUploadMethod","File");
}
if (seedUploadMethod.equalsIgnoreCase("ftp")) {
prop.put("seedServer", 1);//enabled
prop.put("seedServer_seedServer", env.getConfig("seedFTPServer",""));
@ -167,6 +168,8 @@ public class Status {
prop.put("seedServer", 2);//enabled
prop.put("seedServer_seedFile", env.getConfig("seedFilePath",""));
}
prop.put("seedServer_lastUpload",
serverDate.intervalToString(System.currentTimeMillis()-yacyCore.lastSeedUpload_timeStamp));
} else {
prop.put("seedServer", 0);//disabled
}

@ -121,6 +121,9 @@ public class hello {
// no connection here, instead store junior in connection cache
if ((remoteSeed.hash != null) && (remoteSeed.isProper())) yacyCore.peerActions.peerPing(remoteSeed);
}
if (!((String)prop.get("yourtype")).equals(remoteSeed.get("PeerType", "junior"))) {
yacyCore.log.logInfo("hello: changing remote peer '" + remoteSeed.getName() + "' [" + reportedip + "] peerType to '" + prop.get("yourtype") + "'.");
}
String seeds = "";

@ -507,12 +507,25 @@ public final class httpd implements serverHandler {
return this.prop.getProperty(CONNECTION_PROP_PERSISTENT).equals("keep-alive") ? serverCore.RESUME_CONNECTION : serverCore.TERMINATE_CONNECTION;
} catch (Exception e) {
String errorMsg = "Unexpected Error. " + e.getClass().getName() + ": " + e.getMessage();
this.log.logError(errorMsg,e);
logUnexpectedError(e);
return serverCore.TERMINATE_CONNECTION;
}
}
private void logUnexpectedError(Exception e) {
if (e instanceof InterruptedException) {
this.log.logInfo("Interruption detected");
} else {
String errorMsg = e.getMessage();
if ((errorMsg != null) && (errorMsg.startsWith("Broken pipe") || errorMsg.startsWith("Connection reset"))) {
// client closed the connection, so we just end silently
this.log.logInfo("Client unexpectedly closed connection");
} else {
this.log.logError("Unexpected Error. " + e.getClass().getName() + ": " + e.getMessage(),e);
}
}
}
public Boolean HEAD(String arg) throws IOException {
try {
parseQuery(httpHeader.METHOD_HEAD,arg);
@ -559,8 +572,7 @@ public final class httpd implements serverHandler {
}
return this.prop.getProperty(CONNECTION_PROP_PERSISTENT).equals("keep-alive") ? serverCore.RESUME_CONNECTION : serverCore.TERMINATE_CONNECTION;
} catch (Exception e) {
String errorMsg = "Unexpected Error. " + e.getClass().getName() + ": " + e.getMessage();
this.log.logError(errorMsg,e);
logUnexpectedError(e);
return serverCore.TERMINATE_CONNECTION;
}
}
@ -629,8 +641,7 @@ public final class httpd implements serverHandler {
//return serverCore.RESUME_CONNECTION;
return this.prop.getProperty(CONNECTION_PROP_PERSISTENT).equals("keep-alive") ? serverCore.RESUME_CONNECTION : serverCore.TERMINATE_CONNECTION;
} catch (Exception e) {
String errorMsg = "Unexpected Error. " + e.getClass().getName() + ": " + e.getMessage();
this.log.logError(errorMsg,e);
logUnexpectedError(e);
return serverCore.TERMINATE_CONNECTION;
}
}

@ -488,7 +488,7 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
}
} else {
String errorMsg = e.getMessage();
if ((errorMsg != null) && (errorMsg.startsWith("Broken pipe") || errorMsg.startsWith("Connection reset by peer"))) {
if ((errorMsg != null) && (errorMsg.startsWith("Broken pipe") || errorMsg.startsWith("Connection reset"))) {
// client closed the connection, so we just end silently
this.theLogger.logInfo("Client unexpectedly closed connection while processing query: " + path + "; '" + e.toString() + ":" + errorMsg + "'");
conProp.put(httpd.CONNECTION_PROP_PERSISTENT,"close");

@ -726,7 +726,7 @@ public final class httpdProxyHandler extends httpdAbstractHandler implements htt
// just do nothing, we leave it this way
this.theLogger.logDebug("ignoring bad gzip trail for URL " + url + " (" + e.getMessage() + ")",e);
this.forceConnectionClose();
} else if ((remote != null)&&(remote.isClosed())) {
} else if ((remote != null)&&(remote.isClosed())) { // TODO: query for broken pipe
errorMessage = "destination host unexpectedly closed connection";
} else {
errorMessage = "Unexpected Error. " + e.getClass().getName() + ": " + e.getMessage();

@ -99,8 +99,12 @@ public class yacyCore {
//public static boolean terminate = false;
// class variables
private int seedCacheSizeStamp = 0;
private String oldIPStamp = "";
private int lastSeedUpload_seedDBSize = 0;
public static long lastSeedUpload_timeStamp = System.currentTimeMillis();
private String lastSeedUpload_myPeerType = "";
private String lastSeedUpload_myIP = "";
private int onlineMode = 1;
private plasmaSwitchboard switchboard;
@ -170,7 +174,7 @@ public class yacyCore {
// create or init index sharing
//shareManager = new yacyShare(switchboard);
seedCacheSizeStamp = seedDB.sizeConnected();
lastSeedUpload_seedDBSize = seedDB.sizeConnected();
log.logSystem("CORE INITIALIZED");
// ATTENTION, VERY IMPORTANT: before starting the thread, the httpd yacy server must be running!
@ -212,8 +216,7 @@ public class yacyCore {
public void publishSeedList() {
log.logDebug("triggered Seed Publish");
log.logDebug("yacyCore.publishSeedList: Triggered Seed Publish");
/*
if (oldIPStamp.equals((String) seedDB.mySeed.get("IP", "127.0.0.1")))
@ -224,12 +227,16 @@ public class yacyCore {
System.out.println("***DEBUG publishSeedList: I can reach myself");
*/
if (!(!(oldIPStamp.equals(seedDB.mySeed.get("IP", "127.0.0.1")))) ||
(seedCacheSizeStamp != seedDB.sizeConnected()) ||
(!(canReachMyself()))) {
log.logDebug("not necessary to publish: oldIP is equal, sizeConnected is equal and I can reach myself under the old IP.");
if (
(this.lastSeedUpload_myIP.equals(seedDB.mySeed.get("IP", "127.0.0.1"))) &&
(this.lastSeedUpload_seedDBSize == seedDB.sizeConnected()) &&
(canReachMyself()) &&
(System.currentTimeMillis() - yacyCore.lastSeedUpload_timeStamp < 1000*60*60*24) &&
(seedDB.mySeed.isPrincipal())
) {
log.logDebug("yacyCore.publishSeedList: not necessary to publish: oldIP is equal, sizeConnected is equal and I can reach myself under the old IP.");
return;
}
}
// getting the seed upload method that should be used ...
String seedUploadMethod = this.switchboard.getConfig("seedUploadMethod","");
@ -247,8 +254,13 @@ public class yacyCore {
}
// we want to be a principal...
saveSeedList();
this.seedCacheSizeStamp = seedDB.sizeConnected();
this.oldIPStamp = seedDB.mySeed.get("IP", "127.0.0.1");
this.lastSeedUpload_seedDBSize = seedDB.sizeConnected();
this.lastSeedUpload_timeStamp = System.currentTimeMillis();
this.lastSeedUpload_myIP = seedDB.mySeed.get("IP", "127.0.0.1");
this.lastSeedUpload_myPeerType = seedDB.mySeed.get("PeerType", yacySeed.PEERTYPE_JUNIOR);
} else {
if (seedUploadMethod.equals("")) this.switchboard.setConfig("seedUploadMethod","none");
log.logDebug("yacyCore.publishSeedList: No uploading method configured");
@ -269,10 +281,10 @@ public class yacyCore {
if (oldSize == 0) {
// reload the seed lists
peerActions.loadSeedLists();
log.logInfo("re-initialized seed list. received " + seedDB.sizeConnected() + " new peers");
log.logInfo("re-initialized seed list. received " + seedDB.sizeConnected() + " new peer(s)");
}
int newSeeds = publishMySeed(false);
if (newSeeds > 0) log.logInfo("received " + newSeeds + " new peers, know a total of " +
if (newSeeds > 0) log.logInfo("received " + newSeeds + " new peer(s), know a total of " +
seedDB.sizeConnected() + " different peers");
}

@ -78,6 +78,13 @@ import de.anomic.tools.crypt;
public class yacySeed {
public static final String PEERTYPE_VIRGIN = "virgin";
public static final String PEERTYPE_JUNIOR = "junior";
public static final String PEERTYPE_SENIOR = "senior";
public static final String PEERTYPE_PRINCIPAL = "principal";
public static final String PEERTYPE = "PeerType";
// class variables
public String hash;
private Map dna;

Loading…
Cancel
Save