Skip to content

Commit

Permalink
*) Status.java: showing amount of time since last upload of seed-file
Browse files Browse the repository at this point in the history
*) 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
  • Loading branch information
theli committed Jun 28, 2005
1 parent eee6322 commit 08e4334
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 24 deletions.
6 changes: 4 additions & 2 deletions htroot/Status.html
Expand Up @@ -78,9 +78,11 @@ <h2>System, Index and Peer Status</h2>
#(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>
Expand Down
3 changes: 3 additions & 0 deletions htroot/Status.java
Expand Up @@ -157,6 +157,7 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
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",""));
Expand All @@ -167,6 +168,8 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
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
}
Expand Down
3 changes: 3 additions & 0 deletions htroot/yacy/hello.java
Expand Up @@ -121,6 +121,9 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
// 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 = "";

Expand Down
23 changes: 17 additions & 6 deletions source/de/anomic/http/httpd.java
Expand Up @@ -507,12 +507,25 @@ public Boolean GET(String arg) throws IOException {

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);
Expand Down Expand Up @@ -559,8 +572,7 @@ public Boolean HEAD(String arg) throws IOException {
}
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;
}
}
Expand Down Expand Up @@ -629,8 +641,7 @@ public Boolean POST(String arg) throws IOException {
//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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/de/anomic/http/httpdFileHandler.java
Expand Up @@ -488,7 +488,7 @@ public void doResponse(Properties conProp, httpHeader requestHeader, OutputStrea
}
} 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");
Expand Down
2 changes: 1 addition & 1 deletion source/de/anomic/http/httpdProxyHandler.java
Expand Up @@ -726,7 +726,7 @@ private void fulfillRequestFromWeb(Properties conProp, URL url,String ext, httpH
// 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();
Expand Down
40 changes: 26 additions & 14 deletions source/de/anomic/yacy/yacyCore.java
Expand Up @@ -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;

Expand Down Expand Up @@ -170,7 +174,7 @@ public yacyCore(plasmaSwitchboard sb) throws IOException {
// 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!
Expand Down Expand Up @@ -212,8 +216,7 @@ public void loadSeeds() {

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")))
Expand All @@ -224,12 +227,16 @@ public void publishSeedList() {
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","");
Expand All @@ -247,8 +254,13 @@ public void publishSeedList() {
}
// 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");
Expand All @@ -269,10 +281,10 @@ public void peerPing() {
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");
}

Expand Down
7 changes: 7 additions & 0 deletions source/de/anomic/yacy/yacySeed.java
Expand Up @@ -78,6 +78,13 @@

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;
Expand Down

0 comments on commit 08e4334

Please sign in to comment.