Skip to content

Commit

Permalink
fixed some seed selection details
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3685 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed May 7, 2007
1 parent e602436 commit 7f56c8d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
20 changes: 10 additions & 10 deletions source/de/anomic/server/serverDate.java
Expand Up @@ -55,18 +55,18 @@ public final class serverDate {


// statics
private final static long secondMillis = 1000;
private final static long minuteMillis = 60 * secondMillis;
private final static long hourMillis = 60 * minuteMillis;
private final static long dayMillis = 24 * hourMillis;
private final static long normalyearMillis = 365 * dayMillis;
private final static long leapyearMillis = 366 * dayMillis;
private final static int january = 31, normalfebruary = 28, leapfebruary = 29, march = 31,
public final static long secondMillis = 1000;
public final static long minuteMillis = 60 * secondMillis;
public final static long hourMillis = 60 * minuteMillis;
public final static long dayMillis = 24 * hourMillis;
public final static long normalyearMillis = 365 * dayMillis;
public final static long leapyearMillis = 366 * dayMillis;
public final static int january = 31, normalfebruary = 28, leapfebruary = 29, march = 31,
april = 30, may = 31, june = 30, july = 31, august = 31,
september = 30, october = 31, november = 30, december = 31;
private final static int[] dimnormal = {january, normalfebruary, march, april, may, june, july, august, september, october, november, december};
private final static int[] dimleap = {january, leapfebruary, march, april, may, june, july, august, september, october, november, december};
private final static String[] wkday = {"Mon","Tue","Wed","Thu","Fri","Sat","Sun"};
public final static int[] dimnormal = {january, normalfebruary, march, april, may, june, july, august, september, october, november, december};
public final static int[] dimleap = {january, leapfebruary, march, april, may, june, july, august, september, october, november, december};
public final static String[] wkday = {"Mon","Tue","Wed","Thu","Fri","Sat","Sun"};
//private final static String[] month = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};

// find out time zone and DST offset
Expand Down
2 changes: 1 addition & 1 deletion source/de/anomic/yacy/yacyCore.java
Expand Up @@ -458,7 +458,7 @@ private int publishMySeed(boolean force) {
} else {
if (attempts > peerPingMinRunning) { attempts = peerPingMinRunning; }
}
seeds = seedDB.seedsByAge(false, attempts + 10); // best for seed list maintenance/cleaning
seeds = seedDB.seedsByAge(false, attempts); // best for seed list maintenance/cleaning
}

if (seeds == null) { return 0; }
Expand Down
4 changes: 2 additions & 2 deletions source/de/anomic/yacy/yacySeed.java
Expand Up @@ -212,7 +212,7 @@ public yacySeed(String theHash) {
this.dna.put(yacySeed.IPTYPE, "∅");

// settings that can only be computed by visiting peer
this.dna.put(yacySeed.LASTSEEN, yacyCore.universalDateShortString(new Date())); // for last-seen date
this.dna.put(yacySeed.LASTSEEN, yacyCore.universalDateShortString(new Date(System.currentTimeMillis() - serverDate.UTCDiff()))); // for last-seen date
this.dna.put(yacySeed.USPEED, yacySeed.ZERO); // the computated uplink speed of the peer

this.dna.put(yacySeed.CRWCNT, yacySeed.ZERO);
Expand Down Expand Up @@ -652,7 +652,7 @@ public static yacySeed genLocalSeed(plasmaSwitchboard sb) {
} else {
newSeed.dna.put(yacySeed.PORT, Integer.toString(serverCore.getPortNr(sb.getConfig("port", "8080"))));
}
newSeed.dna.put(yacySeed.BDATE, yacyCore.universalDateShortString(new Date()));
newSeed.dna.put(yacySeed.BDATE, yacyCore.universalDateShortString(new Date(System.currentTimeMillis() - serverDate.UTCDiff())) );
newSeed.dna.put(yacySeed.LASTSEEN, newSeed.dna.get(yacySeed.BDATE)); // just as initial setting
newSeed.dna.put(yacySeed.UTC, serverDate.UTCDiffString());
newSeed.dna.put(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN);
Expand Down
6 changes: 4 additions & 2 deletions source/de/anomic/yacy/yacySeedDB.java
Expand Up @@ -71,6 +71,7 @@
import de.anomic.net.URL;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCore;
import de.anomic.server.serverDate;
import de.anomic.server.serverFileUtils;
import de.anomic.server.serverSwitch;
import de.anomic.server.logging.serverLog;
Expand Down Expand Up @@ -315,6 +316,7 @@ public yacySeed anySeedVersion(float minVersion) {

public HashMap seedsByAge(boolean up, int count) {
// returns a peerhash/yacySeed relation
// to get most recent peers, set up = true; for oldest peers, set up = false

if (count > sizeConnected()) count = sizeConnected();

Expand All @@ -329,8 +331,8 @@ public HashMap seedsByAge(boolean up, int count) {
while ((s.hasMoreElements()) && (searchcount-- > 0)) {
ys = (yacySeed) s.nextElement();
if ((ys != null) && (ys.get(yacySeed.LASTSEEN, "").length() > 10)) try {
absage = Math.abs(System.currentTimeMillis() - ys.getLastSeenUTC());
seedScore.addScore(ys.hash, (int) absage);
absage = Math.abs(System.currentTimeMillis() + serverDate.dayMillis - ys.getLastSeenUTC());
seedScore.addScore(ys.hash, (int) absage); // the higher absage, the older is the peer
} catch (Exception e) {}
}

Expand Down

0 comments on commit 7f56c8d

Please sign in to comment.