diff --git a/build.properties b/build.properties
index f04d29585..bf2401545 100644
--- a/build.properties
+++ b/build.properties
@@ -3,7 +3,7 @@ javacSource=1.4
javacTarget=1.4
# Release Configuration
-releaseVersion=0.404
+releaseVersion=0.405
releaseFile=yacy_dev_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz
#releaseFile=yacy_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz
releaseDir=yacy_dev_v${releaseVersion}_${DSTAMP}_${releaseNr}
diff --git a/htroot/Network.html b/htroot/Network.html
index fab9eb9b0..95011abe1 100644
--- a/htroot/Network.html
+++ b/htroot/Network.html
@@ -48,6 +48,7 @@
Release/ SVN |
Contact |
Last Seen < > |
+UTC Offset |
Uptime < > |
#Links < > |
#RWIs < > |
@@ -75,6 +76,7 @@
#[version]# |
#(contact)#passive::direct#(/contact)# |
#[lastSeen]# |
+#[utc]# |
#[uptime]# |
#[links]# |
#[words]# |
@@ -135,6 +137,7 @@ YaCy Cluster Indexing Speed: #[gppm]# Pages Per Minute (Accumulated PPM over Act
Name |
Type |
Version |
+UTC |
Uptime |
#Links |
#RWIs |
@@ -152,6 +155,7 @@ YaCy Cluster Indexing Speed: #[gppm]# Pages Per Minute (Accumulated PPM over Act
#[my-name]# |
#(my-type)#virgin::junior::senior::principal#(/my-type)# |
#[my-version]# |
+#[my-utc]# |
#[my-uptime]# |
#[my-links]# |
#[my-words]# |
diff --git a/htroot/Network.java b/htroot/Network.java
index 4e89c1f1a..e8fa4b2c7 100644
--- a/htroot/Network.java
+++ b/htroot/Network.java
@@ -117,6 +117,7 @@ public class Network {
}
myppm = seed.getPPM();
prop.put("table_my-version", seed.get("Version", "-"));
+ prop.put("table_my-utc", seed.get("UTC", "-"));
prop.put("table_my-uptime", serverDate.intervalToString(60000 * Long.parseLong(seed.get("Uptime", ""))));
prop.put("table_my-links", groupDigits(links));
prop.put("table_my-words", groupDigits(words));
@@ -317,8 +318,9 @@ public class Network {
prop.put(STR_TABLE_LIST+conCount+"_type_url", seed.get("seedURL", "http://nowhere/") );
}
prop.put(STR_TABLE_LIST+conCount+"_version", yacy.combinedVersionString2PrettyString(seed.get("Version", "0.1")));
- prop.put(STR_TABLE_LIST+conCount+"_contact", (seed.getFlagDirectConnect() ? 1 : 0) );
- prop.put(STR_TABLE_LIST+conCount+"_lastSeen", lastSeen(seed.get("LastSeen", "-")) );
+ prop.put(STR_TABLE_LIST+conCount+"_contact", (seed.getFlagDirectConnect() ? 1 : 0));
+ prop.put(STR_TABLE_LIST+conCount+"_lastSeen", (System.currentTimeMillis() - seed.getLastSeenTime()) / 1000 / 60);
+ prop.put(STR_TABLE_LIST+conCount+"_utc", seed.get("UTC", "-"));
prop.put(STR_TABLE_LIST+conCount+"_uptime", serverDate.intervalToString(60000 * Long.parseLong(seed.get("Uptime", "0"))));
prop.put(STR_TABLE_LIST+conCount+"_links", groupDigits(links));
prop.put(STR_TABLE_LIST+conCount+"_words", groupDigits(words));
@@ -354,20 +356,7 @@ public class Network {
// return rewrite properties
return prop;
}
-
- private static String lastSeen(String date) {
- long l = 0;
- if (date.length() == 0) {
- l = 999;
- } else {
- try {
- l = (yacyCore.universalTime() - yacyCore.shortFormatter.parse(date).getTime()) / 1000 / 60;
- } catch (java.text.ParseException e) {
- l = 999;
- }
- }
- if (l == 999) return "-"; else return Long.toString(l);
- }
+
private static String groupDigits(long Number) {
final String s = Long.toString(Number);
diff --git a/htroot/yacy/hello.java b/htroot/yacy/hello.java
index ba71bcf55..42b4fae1c 100644
--- a/htroot/yacy/hello.java
+++ b/htroot/yacy/hello.java
@@ -48,8 +48,10 @@
import java.net.InetAddress;
import java.util.Date;
+
import de.anomic.http.httpHeader;
import de.anomic.server.serverCore;
+import de.anomic.server.serverDate;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.yacy.yacyClient;
@@ -59,15 +61,6 @@ import de.anomic.yacy.yacyVersion;
public class hello {
- private static final String STR_YOURTYPE = "yourtype";
- private static final String STR_LASTSEEN = "LastSeen";
-
- private static final String STR_IP = "IP";
- private static final String STR_YOURIP = "yourip";
- private static final String STR_MYTIME = "mytime";
- private static final String STR_SEED = "seed";
- private static final String STR_EQUAL = "=";
-
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
final serverObjects prop = new serverObjects(); // return variable that accumulates replacements
if ((post == null) ||
@@ -79,20 +72,20 @@ public class hello {
// final String pattern = (String) post.get("pattern", ""); //
// final String mytime = (String) post.get(STR_MYTIME, ""); //
final String key = (String) post.get("key", ""); // transmission key for response
- final String seed = (String) post.get(STR_SEED, ""); //
+ final String seed = (String) post.get(yacySeed.STR_SEED, ""); //
final String countStr = (String) post.get("count", "0"); //
int i;
int count = 0;
try {count = (countStr == null) ? 0 : Integer.parseInt(countStr);} catch (NumberFormatException e) {count = 0;}
- final Date remoteTime = yacyCore.parseUniversalDate((String) post.get(STR_MYTIME)); // read remote time
- final yacySeed remoteSeed = yacySeed.genRemoteSeed(seed, key, remoteTime);
+ //final Date remoteTime = yacyCore.parseUniversalDate((String) post.get(STR_MYTIME)); // read remote time
+ final yacySeed remoteSeed = yacySeed.genRemoteSeed(seed, key);
//System.out.println("YACYHELLO: REMOTESEED=" + ((remoteSeed == null) ? "NULL" : remoteSeed.toString()));
if (remoteSeed == null) { return new serverObjects(); }
// we easily know the caller's IP:
final String clientip = (String) header.get("CLIENTIP", ""); // read an artificial header addendum
- final String reportedip = remoteSeed.get(STR_IP, "");
+ final String reportedip = remoteSeed.get(yacySeed.STR_IP, "");
final String reportedPeerType = remoteSeed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_JUNIOR);
final float clientversion = remoteSeed.getVersion();
@@ -102,8 +95,8 @@ public class hello {
// connect to the reported IP address first
if (reportedip.length() > 0 && !clientip.equals(reportedip) && clientversion >= yacyVersion.YACY_SUPPORTS_PORT_FORWARDING) {
// try first the reportedip, since this may be a connect from a port-forwarding host
- prop.put(STR_YOURIP, reportedip);
- remoteSeed.put(STR_IP, reportedip);
+ prop.put(yacySeed.STR_YOURIP, reportedip);
+ remoteSeed.put(yacySeed.STR_IP, reportedip);
urls = yacyClient.queryUrlCount(remoteSeed);
}
@@ -130,8 +123,8 @@ public class hello {
// we are only allowed to connect to the client IP address if it's not our own address
if (!isLocalIP) {
- prop.put(STR_YOURIP, clientip);
- remoteSeed.put(STR_IP, clientip);
+ prop.put(yacySeed.STR_YOURIP, clientip);
+ remoteSeed.put(yacySeed.STR_IP, clientip);
urls = yacyClient.queryUrlCount(remoteSeed);
}
}
@@ -141,19 +134,19 @@ public class hello {
// assign status
if (urls >= 0) {
if (remoteSeed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_SENIOR) == null) {
- prop.put(STR_YOURTYPE, yacySeed.PEERTYPE_SENIOR);
+ prop.put(yacySeed.STR_YOURTYPE, yacySeed.PEERTYPE_SENIOR);
remoteSeed.put(yacySeed.PEERTYPE, yacySeed.PEERTYPE_SENIOR);
} else if (remoteSeed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_PRINCIPAL).equals(yacySeed.PEERTYPE_PRINCIPAL)) {
- prop.put(STR_YOURTYPE, yacySeed.PEERTYPE_PRINCIPAL);
+ prop.put(yacySeed.STR_YOURTYPE, yacySeed.PEERTYPE_PRINCIPAL);
} else {
- prop.put(STR_YOURTYPE, yacySeed.PEERTYPE_SENIOR);
+ prop.put(yacySeed.STR_YOURTYPE, yacySeed.PEERTYPE_SENIOR);
remoteSeed.put(yacySeed.PEERTYPE, yacySeed.PEERTYPE_SENIOR);
}
// connect the seed
yacyCore.peerActions.peerArrival(remoteSeed, true);
} else {
- prop.put(STR_YOURTYPE, yacySeed.PEERTYPE_JUNIOR);
- remoteSeed.put(STR_LASTSEEN, yacyCore.universalDateShortString());
+ prop.put(yacySeed.STR_YOURTYPE, yacySeed.PEERTYPE_JUNIOR);
+ remoteSeed.put(yacySeed.STR_LASTSEEN, yacyCore.shortFormatter.format(new Date(System.currentTimeMillis() + serverDate.UTCDiff() - remoteSeed.getUTCDiff())) );
yacyCore.peerActions.juniorConnects++; // update statistics
remoteSeed.put(yacySeed.PEERTYPE, yacySeed.PEERTYPE_JUNIOR);
yacyCore.log.logInfo("hello: responded remote junior peer '" + remoteSeed.getName() + "' from " + reportedip);
@@ -162,11 +155,11 @@ public class hello {
yacyCore.peerActions.peerPing(remoteSeed);
}
}
- if (!((String)prop.get(STR_YOURTYPE)).equals(reportedPeerType)) {
+ if (!((String)prop.get(yacySeed.STR_YOURTYPE)).equals(reportedPeerType)) {
yacyCore.log.logInfo("hello: changing remote peer '" + remoteSeed.getName() +
"' [" + reportedip +
"] peerType from '" + reportedPeerType +
- "' to '" + prop.get(STR_YOURTYPE) + "'.");
+ "' to '" + prop.get(yacySeed.STR_YOURTYPE) + "'.");
}
final StringBuffer seeds = new StringBuffer(768);
@@ -181,7 +174,7 @@ public class hello {
count = 1;
for (i = 1; i < ySeeds.length; i++) {
if ((ySeeds[i] != null) && (ySeeds[i].isProper() == null)) {
- seeds.append(STR_SEED).append(count).append(STR_EQUAL).append(ySeeds[i].genSeedStr(key)).append(serverCore.crlfString);
+ seeds.append(yacySeed.STR_SEED).append(count).append(yacySeed.STR_EQUAL).append(ySeeds[i].genSeedStr(key)).append(serverCore.crlfString);
count++;
}
}
@@ -190,7 +183,7 @@ public class hello {
seeds.append("seed0=").append(yacyCore.seedDB.mySeed.genSeedStr(key)).append(serverCore.crlfString);
}
- prop.put(STR_MYTIME, yacyCore.universalDateShortString());
+ prop.put(yacySeed.STR_MYTIME, yacyCore.universalDateShortString(new Date()));
prop.put("seedlist", seeds.toString());
// return rewrite properties
return prop;
diff --git a/htroot/yacy/message.java b/htroot/yacy/message.java
index 6c19b21d8..5f494013a 100644
--- a/htroot/yacy/message.java
+++ b/htroot/yacy/message.java
@@ -115,8 +115,8 @@ public class message {
prop.put("response", "-1"); // request rejected
return prop;
}
- Date remoteTime = yacyCore.parseUniversalDate((String) post.get("mytime")); // read remote time
- yacySeed otherSeed = yacySeed.genRemoteSeed(otherSeedString, key, remoteTime);
+ //Date remoteTime = yacyCore.parseUniversalDate((String) post.get("mytime")); // read remote time
+ yacySeed otherSeed = yacySeed.genRemoteSeed(otherSeedString, key);
String subject = crypt.simpleDecode((String) post.get("subject", ""), key); // message's subject
String message = crypt.simpleDecode((String) post.get("message", ""), key); // message body
diff --git a/htroot/yacy/query.java b/htroot/yacy/query.java
index 456dd1bcb..ad3ac4141 100644
--- a/htroot/yacy/query.java
+++ b/htroot/yacy/query.java
@@ -44,6 +44,7 @@
// if the shell's current path is HTROOT
import java.util.Hashtable;
+import java.util.Date;
import java.io.IOException;
import de.anomic.http.httpHeader;
@@ -69,7 +70,7 @@ public class query {
String obj = (String) post.get("object", ""); // keyword for query subject
String env = (String) post.get("env", ""); // argument to query
- prop.put("mytime", yacyCore.universalDateShortString());
+ prop.put("mytime", yacyCore.universalDateShortString(new Date()));
// check if we are the right target and requester has correct information about this peer
if ((yacyCore.seedDB.mySeed == null) || (!(yacyCore.seedDB.mySeed.hash.equals(youare)))) {
diff --git a/htroot/yacy/search.java b/htroot/yacy/search.java
index 55fbff0ed..c0b34e50a 100644
--- a/htroot/yacy/search.java
+++ b/htroot/yacy/search.java
@@ -75,11 +75,11 @@ public class search {
long duetime= Long.parseLong((String) post.get("duetime", "3000"));
int count = Integer.parseInt((String) post.get("count", "10")); // maximum number of wanted results
boolean global = ((String) post.get("resource", "global")).equals("global"); // if true, then result may consist of answers from other peers
- Date remoteTime = yacyCore.parseUniversalDate((String) post.get("mytime")); // read remote time
+ //Date remoteTime = yacyCore.parseUniversalDate((String) post.get("mytime")); // read remote time
if (yacyCore.seedDB == null) {
yacyCore.log.logSevere("yacy.search: seed cache not initialized");
} else {
- yacyCore.peerActions.peerArrival(yacySeed.genRemoteSeed(oseed, key, remoteTime), true);
+ yacyCore.peerActions.peerArrival(yacySeed.genRemoteSeed(oseed, key), true);
}
HashSet keyhashes = new HashSet();
diff --git a/source/de/anomic/http/httpHeader.java b/source/de/anomic/http/httpHeader.java
index 4dd750389..1f21cd6e3 100644
--- a/source/de/anomic/http/httpHeader.java
+++ b/source/de/anomic/http/httpHeader.java
@@ -340,7 +340,6 @@ public final class httpHeader extends TreeMap implements Map {
Server=Apache/1.3.26
*/
- private static TimeZone GMTTimeZone = TimeZone.getTimeZone("PST");
private static SimpleDateFormat HTTPGMTFormatter = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'");
private static SimpleDateFormat EMLFormatter = new SimpleDateFormat("dd MMM yyyy HH:mm:ss", Locale.US);
diff --git a/source/de/anomic/plasma/plasmaHTCache.java b/source/de/anomic/plasma/plasmaHTCache.java
index 31d536433..1ca9d3073 100644
--- a/source/de/anomic/plasma/plasmaHTCache.java
+++ b/source/de/anomic/plasma/plasmaHTCache.java
@@ -562,10 +562,10 @@ public final class plasmaHTCache {
System.exit(0);
}
- lastModified = serverDate.correctedGMTDate();
+ lastModified = new Date(serverDate.correctedUTCTime());
} else {
lastModified = responseHeader.lastModified();
- if (lastModified == null) lastModified = serverDate.correctedGMTDate(); // does not exist in header
+ if (lastModified == null) lastModified = new Date(serverDate.correctedUTCTime()); // does not exist in header
}
this.doctype = plasmaWordIndexEntry.docType(responseHeader.mime());
if (this.doctype == plasmaWordIndexEntry.DT_UNKNOWN) this.doctype = plasmaWordIndexEntry.docType(url);
@@ -675,7 +675,7 @@ public final class plasmaHTCache {
if (date == null) return "stale_no_date_given_in_response";
try {
long ttl = 1000 * Long.parseLong(cacheControl.substring(8)); // milliseconds to live
- if (serverDate.correctedGMTDate().getTime() - date.getTime() > ttl) {
+ if (serverDate.correctedUTCTime() - date.getTime() > ttl) {
//System.out.println("***not indexed because cache-control");
return "stale_expired";
}
@@ -717,8 +717,8 @@ public final class plasmaHTCache {
if (!(responseHeader.containsKey(httpHeader.LAST_MODIFIED))) return false;
// parse date
Date d1, d2;
- d2 = responseHeader.lastModified(); if (d2 == null) d2 = serverDate.correctedGMTDate();
- d1 = requestHeader.ifModifiedSince(); if (d1 == null) d1 = serverDate.correctedGMTDate();
+ d2 = responseHeader.lastModified(); if (d2 == null) d2 = new Date(serverDate.correctedUTCTime());
+ d1 = requestHeader.ifModifiedSince(); if (d1 == null) d1 = new Date(serverDate.correctedUTCTime());
// finally, we shall treat the cache as stale if the modification time is after the if-.. time
if (d2.after(d1)) return false;
}
@@ -762,7 +762,7 @@ public final class plasmaHTCache {
// the expires value gives us a very easy hint when the cache is stale
if (expires != null) {
//System.out.println("EXPIRES-TEST: expires=" + expires + ", NOW=" + serverDate.correctedGMTDate() + ", url=" + url);
- if (expires.before(serverDate.correctedGMTDate())) return false;
+ if (expires.before(new Date(serverDate.correctedUTCTime()))) return false;
}
// -lastModified in cached response
@@ -772,13 +772,13 @@ public final class plasmaHTCache {
// This would be a TTL factor of 100% we want no more than 10% TTL, so that a 10 month old cache
// file may only be treated as fresh for one more month, not more.
if (lastModified != null) {
- if (date == null) date = serverDate.correctedGMTDate();
+ if (date == null) date = new Date(serverDate.correctedUTCTime());
long age = date.getTime() - lastModified.getTime();
if (age < 0) return false;
// TTL (Time-To-Live) is age/10 = (d2.getTime() - d1.getTime()) / 10
// the actual living-time is serverDate.correctedGMTDate().getTime() - d2.getTime()
// therefore the cache is stale, if serverDate.correctedGMTDate().getTime() - d2.getTime() > age/10
- if (serverDate.correctedGMTDate().getTime() - date.getTime() > age / 10) return false;
+ if (serverDate.correctedUTCTime() - date.getTime() > age / 10) return false;
}
// -cache-control in cached response
@@ -797,7 +797,7 @@ public final class plasmaHTCache {
if (date == null) return false;
try {
long ttl = 1000 * Long.parseLong(cacheControl.substring(8)); // milliseconds to live
- if (serverDate.correctedGMTDate().getTime() - date.getTime() > ttl) {
+ if (serverDate.correctedUTCTime() - date.getTime() > ttl) {
return false;
}
} catch (Exception e) {
diff --git a/source/de/anomic/plasma/plasmaSwitchboardQueue.java b/source/de/anomic/plasma/plasmaSwitchboardQueue.java
index bf834bc77..f42bedb44 100644
--- a/source/de/anomic/plasma/plasmaSwitchboardQueue.java
+++ b/source/de/anomic/plasma/plasmaSwitchboardQueue.java
@@ -314,7 +314,7 @@ public class plasmaSwitchboardQueue {
if ((ifModifiedSince != null) && (responseHeader().containsKey(httpHeader.LAST_MODIFIED))) {
// parse date
Date d = responseHeader().lastModified();
- if (d == null) d = serverDate.correctedGMTDate();
+ if (d == null) d = new Date(serverDate.correctedUTCTime());
// finally, we shall treat the cache as stale if the modification time is after the if-.. time
if (d.after(ifModifiedSince)) {
//System.out.println("***not indexed because if-modified-since");
@@ -343,7 +343,7 @@ public class plasmaSwitchboardQueue {
// sometimes, the expires date is set to the past to prevent that a page is cached
// we use that information to see if we should index it
if (expires != null) {
- if (expires.before(serverDate.correctedGMTDate())) return "Stale_(Expired)";
+ if (expires.before(new Date(serverDate.correctedUTCTime()))) return "Stale_(Expired)";
}
// -lastModified in cached response
@@ -371,7 +371,7 @@ public class plasmaSwitchboardQueue {
if (date == null) return "Stale_(no_date_given_in_response)";
try {
long ttl = 1000 * Long.parseLong(cacheControl.substring(8)); // milliseconds to live
- if (serverDate.correctedGMTDate().getTime() - date.getTime() > ttl) {
+ if (serverDate.correctedUTCTime() - date.getTime() > ttl) {
//System.out.println("***not indexed because cache-control");
return "Stale_(expired_by_cache-control)";
}
diff --git a/source/de/anomic/server/serverDate.java b/source/de/anomic/server/serverDate.java
index 31afb0090..c46f80141 100644
--- a/source/de/anomic/server/serverDate.java
+++ b/source/de/anomic/server/serverDate.java
@@ -70,9 +70,9 @@ public final class serverDate {
// find out time zone and DST offset
private static Calendar thisCalendar = GregorianCalendar.getInstance();
- private static long zoneOffsetHours = thisCalendar.get(Calendar.ZONE_OFFSET);
- private static long DSTOffsetHours = thisCalendar.get(Calendar.DST_OFFSET);
- private static long offsetHours = zoneOffsetHours + DSTOffsetHours; // this must be subtracted from current Date().getTime() to produce a GMT Time
+ //private static long zoneOffsetHours = thisCalendar.get(Calendar.ZONE_OFFSET);
+ //private static long DSTOffsetHours = thisCalendar.get(Calendar.DST_OFFSET);
+ //private static long offsetHours = zoneOffsetHours + DSTOffsetHours; // this must be subtracted from current Date().getTime() to produce a GMT Time
// pre-calculation of time tables
private final static long[] dimnormalacc, dimleapacc;
@@ -103,8 +103,54 @@ public final class serverDate {
private int dow; // day-of-week
private long utime;
- public static Date correctedGMTDate() {
- return new Date(System.currentTimeMillis() - offsetHours);
+ public static String UTCDiffString() {
+ // we express the UTC Difference in 5 digits:
+ // SHHMM
+ // S ::= '+'|'-'
+ // HH ::= '00'|'01'|'02'|'03'|'04'|'05'|'06'|'07'|'08'|'09'|'10'|'11'|'12'
+ // MM ::= '00'|'15'|'30'|'45'
+ // since there are some places on earth where there is a time shift of half an hour
+ // we need too show also the minutes of the time shift
+ // Examples: http://www.timeanddate.com/library/abbreviations/timezones/
+ long offsetHours = UTCDiff();
+ int om = Math.abs((int) (offsetHours / minuteMillis)) % 60;
+ int oh = Math.abs((int) (offsetHours / hourMillis));
+ String diff = Integer.toString(om);
+ if (diff.length() < 2) diff = "0" + diff;
+ diff = Integer.toString(oh) + diff;
+ if (diff.length() < 4) diff = "0" + diff;
+ if (offsetHours >= 0) {
+ return "+" + diff;
+ } else {
+ return "-" + diff;
+ }
+ }
+
+ public static long UTCDiff() {
+ long zoneOffsetHours = thisCalendar.get(Calendar.ZONE_OFFSET);
+ long DSTOffsetHours = thisCalendar.get(Calendar.DST_OFFSET);
+ return zoneOffsetHours + DSTOffsetHours;
+ }
+
+ public static long UTCDiff(String diffString) {
+ if (diffString.length() != 5) throw new RuntimeException("UTC String malformed (wrong size):" + diffString);
+ boolean ahead = true;
+ if (diffString.charAt(0) == '+') ahead = true;
+ else if (diffString.charAt(0) == '-') ahead = false;
+ else throw new RuntimeException("UTC String malformed (wrong sign):" + diffString);
+ long oh = Long.parseLong(diffString.substring(1, 3));
+ long om = Long.parseLong(diffString.substring(3));
+ return ((ahead) ? (long) 1 : (long) -1) * (oh * hourMillis + om * minuteMillis);
+ }
+
+ /*
+ public static Date UTC0Date() {
+ return new Date(UTC0Time());
+ }
+ */
+
+ public static long correctedUTCTime() {
+ return System.currentTimeMillis() - UTCDiff();
}
public serverDate() {
@@ -255,7 +301,7 @@ public final class serverDate {
public static void main(String[] args) {
//System.out.println("kelondroDate is (" + new kelondroDate().toString() + ")");
- System.out.println("offset is " + (offsetHours/1000/60/60/24) + " hours, javaDate is " + new Date() + ", correctedDate is " + correctedGMTDate());
+ System.out.println("offset is " + (UTCDiff()/1000/60/60) + " hours, javaDate is " + new Date() + ", correctedDate is " + new Date(correctedUTCTime()));
System.out.println("serverDate : " + new serverDate().toShortString(false));
System.out.println(" javaDate : " + testSDateShortString());
System.out.println("serverDate : " + new serverDate().toString());
diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.java
index e204ed2ee..6ac849309 100644
--- a/source/de/anomic/yacy/yacyClient.java
+++ b/source/de/anomic/yacy/yacyClient.java
@@ -105,7 +105,7 @@ public class yacyClient {
obj.put("pattern", "");
obj.put("count", "20");
obj.put("key", key);
- obj.put("mytime", yacyCore.universalDateShortString());
+ obj.put("mytime", yacyCore.universalDateShortString(new Date()));
obj.put("seed", yacyCore.seedDB.mySeed.genSeedStr(key));
result = nxTools.table(httpc.wput(url,
105000, null, null,
@@ -126,13 +126,11 @@ public class yacyClient {
return -1;
}
- final Date remoteTime = yacyCore.parseUniversalDate((String) result.get("mytime")); // read remote time
-
// check consistency with expectation
yacySeed otherPeer = null;
float otherPeerVersion = 0;
if (otherHash != null && otherHash.length() > 0) {
- otherPeer = yacySeed.genRemoteSeed((String) result.get("seed0"), key, remoteTime);
+ otherPeer = yacySeed.genRemoteSeed((String) result.get("seed0"), key);
if (otherPeer == null || !otherPeer.hash.equals(otherHash)) {
yacyCore.log.logFine("yacyClient.publishMySeed: consistency error: other peer '" + ((otherPeer==null)?"unknown":otherPeer.getName()) + "' wrong");
return -1; // no success
@@ -199,6 +197,8 @@ public class yacyClient {
return -1;
}
+ //final Date remoteTime = yacyCore.parseUniversalDate((String) result.get("mytime")); // read remote time
+
// read the seeds that the peer returned and integrate them into own database
int i = 0;
int count = 0;
@@ -206,7 +206,7 @@ public class yacyClient {
while ((seedStr = (String) result.get("seed" + i++)) != null) {
// integrate new seed into own database
// the first seed, "seed0" is the seed of the responding peer
- if (yacyCore.peerActions.peerArrival(yacySeed.genRemoteSeed(seedStr, key, remoteTime), (i == 1))) count++;
+ if (yacyCore.peerActions.peerArrival(yacySeed.genRemoteSeed(seedStr, key), (i == 1))) count++;
}
return count;
}
@@ -221,8 +221,8 @@ public class yacyClient {
"&object=seed&env=" + seedHash),
10000, null, null, yacyCore.seedDB.sb.remoteProxyHost, yacyCore.seedDB.sb.remoteProxyPort));
if (result == null || result.size() == 0) { return null; }
- final Date remoteTime = yacyCore.parseUniversalDate((String) result.get("mytime")); // read remote time
- return yacySeed.genRemoteSeed((String) result.get("response"), key, remoteTime);
+ //final Date remoteTime = yacyCore.parseUniversalDate((String) result.get("mytime")); // read remote time
+ return yacySeed.genRemoteSeed((String) result.get("response"), key);
} catch (Exception e) {
yacyCore.log.logSevere("yacyClient.querySeed error:" + e.getMessage());
return null;
@@ -310,7 +310,7 @@ public class yacyClient {
obj.put("query", wordhashes);
obj.put("ttl", "0");
obj.put("duetime", Long.toString(duetime));
- obj.put("mytime", yacyCore.universalDateShortString());
+ obj.put("mytime", yacyCore.universalDateShortString(new Date()));
//yacyCore.log.logDebug("yacyClient.search url=" + url);
final long timestamp = System.currentTimeMillis();
final HashMap result = nxTools.table(httpc.wput(new URL(url),
@@ -401,7 +401,7 @@ public class yacyClient {
post.put("process", "permission");
post.put("iam", yacyCore.seedDB.mySeed.hash);
post.put("youare", targetHash);
- post.put("mytime", yacyCore.universalDateShortString());
+ post.put("mytime", yacyCore.universalDateShortString(new Date()));
String address;
if (targetHash.equals(yacyCore.seedDB.mySeed.hash)) {
address = yacyCore.seedDB.mySeed.getAddress();
@@ -433,7 +433,7 @@ public class yacyClient {
post.put("myseed", yacyCore.seedDB.mySeed.genSeedStr(key));
post.put("youare", targetHash);
post.put("subject", subject);
- post.put("mytime", yacyCore.universalDateShortString());
+ post.put("mytime", yacyCore.universalDateShortString(new Date()));
post.put("message", new String(message));
String address;
if (targetHash.equals(yacyCore.seedDB.mySeed.hash)) {
@@ -467,7 +467,7 @@ public class yacyClient {
post.put("process", "crawl");
post.put("iam", yacyCore.seedDB.mySeed.hash);
post.put("youare", targetSeed.hash);
- post.put("mytime", yacyCore.universalDateShortString());
+ post.put("mytime", yacyCore.universalDateShortString(new Date()));
post.put("url", crypt.simpleEncode(url.toString()));
post.put("referrer", crypt.simpleEncode((referrer == null) ? "" : referrer.toString()));
post.put("depth", "0");
diff --git a/source/de/anomic/yacy/yacyCore.java b/source/de/anomic/yacy/yacyCore.java
index cd4c910d8..614911ee3 100644
--- a/source/de/anomic/yacy/yacyCore.java
+++ b/source/de/anomic/yacy/yacyCore.java
@@ -74,6 +74,7 @@ import de.anomic.net.natLib;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverSemaphore;
import de.anomic.server.serverSwitch;
+import de.anomic.server.serverDate;
import de.anomic.server.logging.serverLog;
public class yacyCore {
@@ -109,6 +110,7 @@ public class yacyCore {
public static String universalDateShortPattern = "yyyyMMddHHmmss";
public static SimpleDateFormat shortFormatter = new SimpleDateFormat(universalDateShortPattern);
+ /*
public static long universalTime() {
return universalDate().getTime();
}
@@ -120,17 +122,21 @@ public class yacyCore {
public static String universalDateShortString() {
return universalDateShortString(universalDate());
}
-
+ */
public static String universalDateShortString(Date date) {
return shortFormatter.format(date);
}
- public static Date parseUniversalDate(String remoteTimeString) {
+ public static Date parseUniversalDate(String remoteTimeString, String remoteUTCOffset) {
if ((remoteTimeString == null) || (remoteTimeString.length() == 0)) return new Date();
+ if ((remoteUTCOffset == null) || (remoteUTCOffset.length() == 0)) return new Date();
try {
- return yacyCore.shortFormatter.parse(remoteTimeString);
+ return new Date(yacyCore.shortFormatter.parse(remoteTimeString).getTime() - serverDate.UTCDiff() + serverDate.UTCDiff(remoteUTCOffset));
} catch (java.text.ParseException e) {
- log.logFinest("parseUniversalDate remoteTimeString=[" + remoteTimeString + "]");
+ log.logFinest("parseUniversalDate " + e.getMessage() + ", remoteTimeString=[" + remoteTimeString + "]");
+ return new Date();
+ } catch (java.lang.NumberFormatException e) {
+ log.logFinest("parseUniversalDate " + e.getMessage() + ", remoteTimeString=[" + remoteTimeString + "]");
return new Date();
}
}
@@ -207,12 +213,12 @@ public class yacyCore {
synchronized static public void triggerOnlineAction() {
- lastOnlineTime = universalTime();
+ lastOnlineTime = System.currentTimeMillis();
}
public boolean online() {
this.onlineMode = Integer.parseInt(switchboard.getConfig("onlineMode", "1"));
- return ((onlineMode == 2) || ((universalTime() - lastOnlineTime) < 10000));
+ return ((onlineMode == 2) || ((System.currentTimeMillis() - lastOnlineTime) < 10000));
}
public void loadSeeds() {
@@ -294,7 +300,7 @@ public class yacyCore {
// if we cannot reach ourself, we call a forced publishMySeed and return false
int urlc = yacyClient.queryUrlCount(seedDB.mySeed);
if (urlc >= 0) {
- seedDB.mySeed.put("LastSeen", universalDateShortString());
+ seedDB.mySeed.put("LastSeen", universalDateShortString(new Date()));
return true;
}
log.logInfo("re-connect own seed");
diff --git a/source/de/anomic/yacy/yacyNewsDB.java b/source/de/anomic/yacy/yacyNewsDB.java
index fa748c917..bb373ccdc 100644
--- a/source/de/anomic/yacy/yacyNewsDB.java
+++ b/source/de/anomic/yacy/yacyNewsDB.java
@@ -50,6 +50,7 @@ import de.anomic.kelondro.kelondroTree;
import de.anomic.kelondro.kelondroException;
import de.anomic.kelondro.kelondroRecords;
import de.anomic.server.serverCodings;
+import de.anomic.server.serverDate;
public class yacyNewsDB {
@@ -167,7 +168,7 @@ public class yacyNewsDB {
return new yacyNewsRecord(
new String(b[0]),
new String(b[1]),
- (b[2] == null) ? null : yacyCore.parseUniversalDate(new String(b[2])),
+ (b[2] == null) ? null : yacyCore.parseUniversalDate(new String(b[2]), serverDate.UTCDiffString()),
(int) serverCodings.enhancedCoder.decodeBase64Long(new String(b[3])),
serverCodings.string2map(new String(b[4]))
);
diff --git a/source/de/anomic/yacy/yacyNewsPool.java b/source/de/anomic/yacy/yacyNewsPool.java
index dbe90337b..f454ec16b 100644
--- a/source/de/anomic/yacy/yacyNewsPool.java
+++ b/source/de/anomic/yacy/yacyNewsPool.java
@@ -171,16 +171,16 @@ public class yacyNewsPool {
private boolean automaticProcessP(yacyNewsRecord record) {
if (record == null) return false;
if (record.category() == null) return true;
- if ((yacyCore.universalTime() - record.created().getTime()) > (1000 * 60 * 60 * 24 * 7) /* 1 Week */) {
+ if ((System.currentTimeMillis() - record.created().getTime()) > (1000 * 60 * 60 * 24 * 7) /* 1 Week */) {
// remove everything after 1 week
return true;
}
if ((record.category().equals("wiki_upd")) &&
- ((yacyCore.universalTime() - record.created().getTime()) > (1000 * 60 * 60 * 24) /* 1 Day */)) {
+ ((System.currentTimeMillis() - record.created().getTime()) > (1000 * 60 * 60 * 24) /* 1 Day */)) {
return true;
}
if ((record.category().equals("crwlstrt")) &&
- ((yacyCore.universalTime() - record.created().getTime()) > (1000 * 60 * 60 * 24) /* 1 Day */)) {
+ ((System.currentTimeMillis() - record.created().getTime()) > (1000 * 60 * 60 * 24) /* 1 Day */)) {
yacySeed seed = yacyCore.seedDB.get(record.originator());
if (seed == null) return false;
try {
diff --git a/source/de/anomic/yacy/yacyNewsRecord.java b/source/de/anomic/yacy/yacyNewsRecord.java
index bf3bf33cc..29490e211 100644
--- a/source/de/anomic/yacy/yacyNewsRecord.java
+++ b/source/de/anomic/yacy/yacyNewsRecord.java
@@ -61,8 +61,8 @@ public class yacyNewsRecord {
public yacyNewsRecord(String newsString) {
this.attributes = serverCodings.string2map(newsString);
- this.received = (attributes.containsKey("rec")) ? yacyCore.parseUniversalDate((String) attributes.get("rec")) : new Date();
- this.created = (attributes.containsKey("cre")) ? yacyCore.parseUniversalDate((String) attributes.get("cre")) : new Date();
+ this.received = (attributes.containsKey("rec")) ? yacyCore.parseUniversalDate((String) attributes.get("rec"), serverDate.UTCDiffString()) : new Date();
+ this.created = (attributes.containsKey("cre")) ? yacyCore.parseUniversalDate((String) attributes.get("cre"), serverDate.UTCDiffString()) : new Date();
this.category = (attributes.containsKey("cat")) ? (String) attributes.get("cat") : null;
this.distributed = (attributes.containsKey("dis")) ? Integer.parseInt((String) attributes.get("dis")) : 0;
this.originator = (attributes.containsKey("ori")) ? (String) attributes.get("ori") : null;
@@ -83,7 +83,7 @@ public class yacyNewsRecord {
protected yacyNewsRecord(String id, String category, Date received, int distributed, Map attributes) {
this.attributes = attributes;
this.received = received;
- this.created = yacyCore.parseUniversalDate(id.substring(0, yacyCore.universalDateShortPattern.length()));
+ this.created = yacyCore.parseUniversalDate(id.substring(0, yacyCore.universalDateShortPattern.length()), serverDate.UTCDiffString());
this.category = category;
this.distributed = distributed;
this.originator = id.substring(yacyCore.universalDateShortPattern.length());
diff --git a/source/de/anomic/yacy/yacyPeerActions.java b/source/de/anomic/yacy/yacyPeerActions.java
index e9c599e1c..c70d83d6d 100644
--- a/source/de/anomic/yacy/yacyPeerActions.java
+++ b/source/de/anomic/yacy/yacyPeerActions.java
@@ -105,7 +105,7 @@ public class yacyPeerActions {
} else {
seedDB.mySeed.put("Port", sb.getConfig("port", "8080"));
}
- long uptime = ((yacyCore.universalTime() - Long.parseLong(sb.getConfig("startupTime", "0"))) / 1000) / 60;
+ long uptime = ((System.currentTimeMillis() - Long.parseLong(sb.getConfig("startupTime", "0"))) / 1000) / 60;
long indexedc = sb.getThread("80_indexing").getBusyCycles();
seedDB.mySeed.put("ISpeed", ((indexedc == 0) || (uptime == 0)) ? "unknown" : Long.toString(indexedc / uptime)); // the speed of indexing (pages/minute) of the peer
seedDB.mySeed.put("Uptime", Long.toString(uptime)); // the number of minutes that the peer is up in minutes/day (moving average MA30)
@@ -120,7 +120,8 @@ public class yacyPeerActions {
seedDB.mySeed.put("seedURL", sb.getConfig("seedURL", ""));
}
seedDB.mySeed.setFlagDirectConnect(true);
- seedDB.mySeed.put("LastSeen", yacyCore.universalDateShortString());
+ seedDB.mySeed.put("LastSeen", yacyCore.universalDateShortString(new Date()));
+ seedDB.mySeed.put("UTC", serverDate.UTCDiffString());
seedDB.mySeed.setFlagAcceptRemoteCrawl(sb.getConfig("crawlResponse", "").equals("true"));
seedDB.mySeed.setFlagAcceptRemoteIndex(sb.getConfig("allowReceiveIndex", "").equals("true"));
//mySeed.setFlagAcceptRemoteIndex(true);
@@ -169,7 +170,7 @@ public class yacyPeerActions {
enu = seedList.elements();
lc = 0;
while (enu.hasMoreElements()) {
- ys = yacySeed.genRemoteSeed((String) enu.nextElement(), null, new Date());
+ ys = yacySeed.genRemoteSeed((String) enu.nextElement(), null);
if ((ys != null) && (ys.isProper() == null) &&
((seedDB.mySeed == null) || (seedDB.mySeed.hash != ys.hash))) {
if (connectPeer(ys, false)) lc++;
@@ -265,45 +266,44 @@ public class yacyPeerActions {
}
// connection time
- long ctime;
- try {
- ctime = yacyCore.shortFormatter.parse(seed.get("LastSeen", "20040101000000")).getTime();
- // maybe correct it slightly
+ long nowUTC0Time = System.currentTimeMillis(); // is better to have this value in a variable for debugging
+ long ctimeUTC0;
+ ctimeUTC0 = seed.getLastSeenTime();
+ // maybe correct it slightly
+ /*
if (ctime > yacyCore.universalTime()) {
ctime = ((2 * ctime) + yacyCore.universalTime()) / 3;
seed.put("LastSeen", yacyCore.shortFormatter.format(new Date(ctime)));
}
- } catch (java.text.ParseException e) {
- ctime = yacyCore.universalTime();
- } catch (java.lang.NumberFormatException e) {
- ctime = yacyCore.universalTime();
- }
-
- if (Math.abs(yacyCore.universalTime() - ctime) > 3600000) {
+ */
+
+ if (Math.abs(nowUTC0Time - ctimeUTC0) > 3600000) {
// the new connection is out-of-age, we reject the connection
- yacyCore.log.logFine("connect: rejecting out-dated peer '" + seed.getName() + "' from " + seed.getAddress());
+ yacyCore.log.logFine("connect: rejecting out-dated peer '" + seed.getName() + "' from " + seed.getAddress() +
+ "; nowUTC0=" + nowUTC0Time + ", seedUTC0=" + ctimeUTC0);
return false;
}
// disconnection time
- long dtime;
+ long dtimeUTC0;
yacySeed disconnectedSeed = seedDB.getDisconnected(seed.hash);
if (disconnectedSeed == null) {
- dtime = 0; // never disconnected: virtually disconnected maximum time ago
+ dtimeUTC0 = 0; // never disconnected: virtually disconnected maximum time ago
} else try {
- dtime = yacyCore.shortFormatter.parse((String) disconnectedSeed.get("disconnected", "20040101000000")).getTime();
+ dtimeUTC0 = yacyCore.shortFormatter.parse((String) disconnectedSeed.get("disconnected", "20040101000000")).getTime() - seed.getUTCDiff();
} catch (java.text.ParseException e) {
- dtime = 0;
+ dtimeUTC0 = 0;
}
if (direct) {
// remember the moment
- ctime = yacyCore.universalTime();
- seed.put("LastSeen", yacyCore.shortFormatter.format(new Date(ctime)));
+ // Date applies the local UTC offset, which is wrong
+ // we correct that by subtracting the local offset and adding the remote offset.
+ seed.setLastSeenTime();
seed.setFlagDirectConnect(true);
} else {
// set connection flag
- if (Math.abs(yacyCore.universalTime() - ctime) > 120000) seed.setFlagDirectConnect(false); // 2 minutes
+ if (Math.abs(nowUTC0Time - ctimeUTC0) > 120000) seed.setFlagDirectConnect(false); // 2 minutes
}
// update latest version number
@@ -316,7 +316,7 @@ public class yacyPeerActions {
// if the new peer has a LastSeen date, and that date is before the disconnection date,
// then we ignore the new peer
if (!(direct)) {
- if (ctime < dtime) {
+ if (ctimeUTC0 < dtimeUTC0) {
// the disconnection was later, we reject the connection
yacyCore.log.logFine("connect: rejecting disconnected peer '" + seed.getName() + "' from " + seed.getAddress());
return false;
@@ -333,7 +333,7 @@ public class yacyPeerActions {
// the seed is known: this is an update
try {
// if the old LastSeen date is later then the other info, then we reject the info
- if ((ctime < yacyCore.shortFormatter.parse(connectedSeed.get("LastSeen", "20040101000000")).getTime()) && (!(direct))) {
+ if ((ctimeUTC0 < (yacyCore.shortFormatter.parse(connectedSeed.get("LastSeen", "20040101000000")).getTime() - connectedSeed.getUTCDiff() + serverDate.UTCDiff())) && (!(direct))) {
yacyCore.log.logFine("connect: rejecting old info about peer '" + seed.getName() + "'");
return false;
}
@@ -364,7 +364,7 @@ public class yacyPeerActions {
// we do this if we did not get contact with the other peer
yacyCore.log.logFine("connect: no contact to a " + seed.get("PeerType", "virgin") + " peer '" + seed.getName() + "' at " + seed.getAddress());
if (!(seedDB.hasDisconnected(seed.hash))) disconnects++;
- seed.put("disconnected", yacyCore.universalDateShortString());
+ seed.put("disconnected", yacyCore.universalDateShortString(new Date()));
seedDB.addDisconnected(seed); // update info
}
diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.java
index c45aff360..0412836a6 100644
--- a/source/de/anomic/yacy/yacySeed.java
+++ b/source/de/anomic/yacy/yacySeed.java
@@ -69,9 +69,11 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
+
import de.anomic.net.natLib;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCodings;
+import de.anomic.server.serverDate;
import de.anomic.server.serverCore;
import de.anomic.tools.bitfield;
import de.anomic.tools.crypt;
@@ -89,6 +91,16 @@ public class yacySeed {
public static final String PEERTYPE_PRINCIPAL = "principal";
public static final String PEERTYPE = "PeerType";
+ public static final String STR_YOURTYPE = "yourtype";
+ public static final String STR_LASTSEEN = "LastSeen";
+
+ public static final String STR_IP = "IP";
+ public static final String STR_YOURIP = "yourip";
+ public static final String STR_MYTIME = "mytime";
+ public static final String STR_SEED = "seed";
+ public static final String STR_EQUAL = "=";
+
+
// class variables
public String hash;
private Map dna;
@@ -110,6 +122,7 @@ public class yacySeed {
this.hash = hash; // the hash key of the peer - very important. should be static somehow, even after restart
dna.put("Name", "∅"); // the name that the peer has given itself
dna.put("BDate", "∅"); // birthdate - first startup
+ dna.put("UTC", "+0000");
// later during operation -
dna.put("ISpeed", "0"); // the speed of indexing (pages/minute) of the peer
dna.put("Uptime", "0"); // the number of minutes that the peer is up in minutes/day (moving average MA30)
@@ -127,7 +140,7 @@ public class yacySeed {
dna.put("IPType", "∅"); // static/dynamic (if the ip changes often for any reason)
// settings that can only be computed by visiting peer
- dna.put("LastSeen", yacyCore.universalDateShortString()); // for last-seen date
+ dna.put("LastSeen", yacyCore.universalDateShortString(new Date())); // for last-seen date
dna.put("USpeed", "0"); // the computated uplink speed of the peer
// settings that are needed to organize the seed round-trip
@@ -209,7 +222,34 @@ public class yacySeed {
String port = (String) dna.get("Port");
if (ip != null && ip.length() >= 8 && port != null && port.length() >= 2) return ip + ":" + port; else return null;
}
+
+ public long getUTCDiff() {
+ String utc = (String) dna.get("UTC");
+ if (utc == null) utc = "+0200";
+ return serverDate.UTCDiff(utc);
+ }
+ public long getLastSeenTime() {
+ try {
+ long t = yacyCore.shortFormatter.parse(get("LastSeen", "20040101000000")).getTime();
+ // the problem here is: getTime applies a time shift according to local time zone:
+ // it substracts the local UTF offset, but it should substract the remote UTC offset
+ // so we correct it by first adding the local UTF offset and then subtractibg the remote
+ // but the time zone was originally the seeds time zone
+ // we correct this here
+ return t - getUTCDiff() + serverDate.UTCDiff();
+ } catch (java.text.ParseException e) {
+ return System.currentTimeMillis();
+ } catch (java.lang.NumberFormatException e) {
+ return System.currentTimeMillis();
+ }
+ }
+
+ public void setLastSeenTime() {
+ // if we set a last seen time, then we need to respect the seeds UTC offset
+ put("LastSeen", yacyCore.shortFormatter.format(new Date(System.currentTimeMillis() - serverDate.UTCDiff() + getUTCDiff())));
+ }
+
public int getPPM() {
try {
return Integer.parseInt(get("ISpeed", "0"));
@@ -352,21 +392,22 @@ public class yacySeed {
} else {
newSeed.dna.put("Port", sb.getConfig("port", "8080"));
}
- newSeed.dna.put("BDate", yacyCore.universalDateShortString());
+ newSeed.dna.put("BDate", yacyCore.universalDateShortString(new Date()));
newSeed.dna.put("LastSeen", newSeed.dna.get("BDate")); // just as initial setting
+ newSeed.dna.put("UTC", serverDate.UTCDiffString());
newSeed.dna.put(PEERTYPE, PEERTYPE_VIRGIN);
return newSeed;
}
- public static yacySeed genRemoteSeed(String seedStr, String key, Date remoteTime) {
- // this method is used to convert the external representation of a seed into a seed object
- if (seedStr == null) return null;
- String seed = crypt.simpleDecode(seedStr, key);
- if (seed == null) return null;
- HashMap dna = serverCodings.string2map(seed);
- String hash = (String) dna.remove("Hash");
- return new yacySeed(hash, dna);
+ public static yacySeed genRemoteSeed(String seedStr, String key) {
+ // this method is used to convert the external representation of a seed into a seed object
+ if (seedStr == null) return null;
+ String seed = crypt.simpleDecode(seedStr, key);
+ if (seed == null) return null;
+ HashMap dna = serverCodings.string2map(seed);
+ String hash = (String) dna.remove("Hash");
+ return new yacySeed(hash, dna);
}
public String toString() {
@@ -416,7 +457,7 @@ public class yacySeed {
char[] b = new char[(int) f.length()];
fr.read(b, 0, b.length);
fr.close();
- return genRemoteSeed(new String(b), null, new Date());
+ return genRemoteSeed(new String(b), null);
}
public Object clone() {
diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.java
index a7f5c2095..6d960e0bf 100644
--- a/source/de/anomic/yacy/yacySeedDB.java
+++ b/source/de/anomic/yacy/yacySeedDB.java
@@ -298,7 +298,6 @@ public final class yacySeedDB {
// fill a score object
kelondroMScoreCluster seedScore = new kelondroMScoreCluster();
yacySeed ys;
- String t;
long absage;
Enumeration s = seedsConnected(true, false, null);
int searchcount = 1000;
@@ -306,8 +305,8 @@ public final class yacySeedDB {
try {
while ((s.hasMoreElements()) && (searchcount-- > 0)) {
ys = (yacySeed) s.nextElement();
- if ((ys != null) && ((t = ys.get("LastSeen", "")).length() > 10)) try {
- absage = Math.abs(yacyCore.universalTime() - yacyCore.shortFormatter.parse(t).getTime());
+ if ((ys != null) && (ys.get("LastSeen", "").length() > 10)) try {
+ absage = Math.abs(System.currentTimeMillis() - ys.getLastSeenTime());
seedScore.addScore(ys.hash, (int) absage);
} catch (Exception e) {}
}
diff --git a/source/yacy.java b/source/yacy.java
index ef60034dd..84f769807 100644
--- a/source/yacy.java
+++ b/source/yacy.java
@@ -59,6 +59,7 @@ import java.util.Properties;
import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+
import de.anomic.data.translator;
import de.anomic.http.httpHeader;
import de.anomic.http.httpc;
@@ -72,8 +73,9 @@ import de.anomic.plasma.plasmaWordIndexEntity;
import de.anomic.plasma.plasmaWordIndexEntry;
import de.anomic.plasma.plasmaWordIndexClassicDB;
import de.anomic.plasma.plasmaWordIndexCache;
-import de.anomic.server.serverCodings;
import de.anomic.server.serverCore;
+import de.anomic.server.serverDate;
+import de.anomic.server.serverCodings;
import de.anomic.server.serverFileUtils;
import de.anomic.server.serverSystem;
import de.anomic.server.logging.serverLog;
@@ -166,7 +168,7 @@ public final class yacy {
* @param startupFree free memory at startup time, to be used later for statistics
*/
private static void startup(String homePath, long startupMemFree, long startupMemTotal) {
- long startup = yacyCore.universalTime();
+ long startup = System.currentTimeMillis();
try {
// start up
@@ -181,14 +183,19 @@ public final class yacy {
Thread.currentThread().sleep(3000);
System.exit(-1);
}
-
+
+ // ensure that there is a DATA directory
+ File f = new File(homePath); if (!(f.exists())) f.mkdirs();
+ f = new File(homePath, "DATA/"); if (!(f.exists())) f.mkdirs();
+
// setting up logging
- if (!((new File(homePath, "DATA/LOG/yacy.logging")).exists())) try {
- serverFileUtils.copy(new File(homePath, "yacy.logging"), new File(homePath, "DATA/LOG/yacy.logging"));
- }catch (IOException e){
- System.out.println("could not copy yacy.logging");
- }
- try{
+ f = new File(homePath, "DATA/LOG/"); if (!(f.exists())) f.mkdirs();
+ if (!((new File(homePath, "DATA/LOG/yacy.logging")).exists())) try {
+ serverFileUtils.copy(new File(homePath, "yacy.logging"), new File(homePath, "DATA/LOG/yacy.logging"));
+ }catch (IOException e){
+ System.out.println("could not copy yacy.logging");
+ }
+ try{
serverLog.configureLogging(new File(homePath, "DATA/LOG/yacy.logging"));
} catch (IOException e) {
System.out.println("could not find logging properties in homePath=" + homePath);
@@ -198,6 +205,7 @@ public final class yacy {
serverLog.logConfig("STARTUP", hline);
serverLog.logConfig("STARTUP", "java version " + System.getProperty("java.version", "no-java-version"));
serverLog.logConfig("STARTUP", "Application Root Path: " + homePath);
+ serverLog.logConfig("STARTUP", "Time Zone: UTC" + serverDate.UTCDiffString() + "; UTC+0000 is " + System.currentTimeMillis());
// create data folder
final File dataFolder = new File(homePath, "DATA");