last cleanup bits to serverDate before the release. only safe refactoring (method renaming) changes outside of serverDate.

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4289 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
fuchsi 18 years ago
parent 4748d5c1ab
commit d517e96714

@ -99,7 +99,7 @@ public class AccessTracker_p {
while (ii.hasNext()) {
entry = (Map.Entry) ii.next();
prop.putHTML("page_list_" + entCount + "_host", host);
prop.put("page_list_" + entCount + "_date", serverDate.shortSecondTime(new Date(((Long) entry.getKey()).longValue())));
prop.put("page_list_" + entCount + "_date", serverDate.formatShortSecond(new Date(((Long) entry.getKey()).longValue())));
prop.putHTML("page_list_" + entCount + "_path", (String) entry.getValue());
entCount++;
}
@ -115,7 +115,7 @@ public class AccessTracker_p {
while (ii.hasNext()) {
entry = (Map.Entry) ii.next();
prop.putHTML("page_list_" + entCount + "_host", host);
prop.put("page_list_" + entCount + "_date", serverDate.shortSecondTime(new Date(((Long) entry.getKey()).longValue())));
prop.put("page_list_" + entCount + "_date", serverDate.formatShortSecond(new Date(((Long) entry.getKey()).longValue())));
prop.putHTML("page_list_" + entCount + "_path", (String) entry.getValue());
entCount++;
}
@ -145,7 +145,7 @@ public class AccessTracker_p {
prop.put("page_list_" + entCount + "_dark", ((dark) ? 1 : 0) );
dark =! dark;
prop.putHTML("page_list_" + entCount + "_host", (String) searchProfile.get("host"));
prop.put("page_list_" + entCount + "_date", serverDate.shortSecondTime(new Date(trackerHandle.longValue())));
prop.put("page_list_" + entCount + "_date", serverDate.formatShortSecond(new Date(trackerHandle.longValue())));
prop.put("page_list_" + entCount + "_timestamp", trackerHandle.longValue());
if (page == 2) {
// local search
@ -199,7 +199,7 @@ public class AccessTracker_p {
Iterator ii = handles.iterator();
while (ii.hasNext()) {
Long timestamp = (Long) ii.next();
prop.put("page_list_" + entCount + "_dates_" + dateCount + "_date", serverDate.shortSecondTime(new Date(timestamp.longValue())));
prop.put("page_list_" + entCount + "_dates_" + dateCount + "_date", serverDate.formatShortSecond(new Date(timestamp.longValue())));
prop.put("page_list_" + entCount + "_dates_" + dateCount + "_timestamp", timestamp.toString());
dateCount++;
}

@ -214,7 +214,7 @@ public final class Connections_p {
prop.put("list_" + idx + "_proto", prot);
if (sessionTime > 1000*60) {
prop.put("list_" + idx + "_ms", "0");
prop.put("list_" + idx + "_ms_duration",serverDate.intervalToString(sessionTime));
prop.put("list_" + idx + "_ms_duration",serverDate.formatInterval(sessionTime));
} else {
prop.put("list_" + idx + "_ms", "1");
prop.putNum("list_" + idx + "_ms_duration", sessionTime);

@ -63,7 +63,7 @@ public class IndexControlURLs_p {
prop.put("lurlexport_urlcount", sb.wordIndex.loadedURL.export_count());
} else {
prop.put("lurlexport", 1);
prop.put("lurlexport_exportfile", sb.getRootPath() + "/DATA/EXPORT/" + serverDate.shortSecondTime());
prop.put("lurlexport_exportfile", sb.getRootPath() + "/DATA/EXPORT/" + serverDate.formatShortSecond());
prop.put("lurlexportfinished", 0);
prop.put("lurlexporterror", 0);

@ -181,8 +181,8 @@ public final class IndexImport_p {
// other information
prop.putNum("running.jobs_" + i + "_percent", currThread.getProcessingStatusPercent());
prop.put("running.jobs_" + i + "_elapsed", serverDate.intervalToString(currThread.getElapsedTime()));
prop.put("running.jobs_" + i + "_estimated", serverDate.intervalToString(currThread.getEstimatedTime()));
prop.put("running.jobs_" + i + "_elapsed", serverDate.formatInterval(currThread.getElapsedTime()));
prop.put("running.jobs_" + i + "_estimated", serverDate.formatInterval(currThread.getEstimatedTime()));
prop.putHTML("running.jobs_" + i + "_status", currThread.getStatus().replaceAll("\n", "<br>"));
// job number of the importer thread
@ -209,7 +209,7 @@ public final class IndexImport_p {
prop.put("finished.jobs_" + i + "_runningStatus", "0");
}
prop.putNum("finished.jobs_" + i + "_percent", currThread.getProcessingStatusPercent());
prop.put("finished.jobs_" + i + "_elapsed", serverDate.intervalToString(currThread.getElapsedTime()));
prop.put("finished.jobs_" + i + "_elapsed", serverDate.formatInterval(currThread.getElapsedTime()));
prop.putHTML("finished.jobs_" + i + "_status", currThread.getStatus().replaceAll("\n", "<br>"));
}
prop.put("finished.jobs",finishedJobs.length);

@ -146,7 +146,7 @@ public class Network {
myqph = 60d * seed.getQPM();
prop.put("table_my-version", seed.get(yacySeed.VERSION, "-"));
prop.put("table_my-utc", seed.get(yacySeed.UTC, "-"));
prop.put("table_my-uptime", serverDate.intervalToString(60000 * Long.parseLong(seed.get(yacySeed.UPTIME, ""))));
prop.put("table_my-uptime", serverDate.formatInterval(60000 * Long.parseLong(seed.get(yacySeed.UPTIME, ""))));
prop.putNum("table_my-LCount", LCount);
prop.putNum("table_my-ICount", ICount);
prop.putNum("table_my-RCount", RCount);
@ -452,7 +452,7 @@ public class Network {
prop.putHTML(STR_TABLE_LIST + conCount + "_version", yacyVersion.combined2prettyVersion(seed.get(yacySeed.VERSION, "0.1"), shortname));
prop.putNum(STR_TABLE_LIST + conCount + "_lastSeen", /*seed.getLastSeenString() + " " +*/ lastseen);
prop.put(STR_TABLE_LIST + conCount + "_utc", seed.get(yacySeed.UTC, "-"));
prop.putHTML(STR_TABLE_LIST + conCount + "_uptime", serverDate.intervalToString(60000 * Long.parseLong(seed.get(yacySeed.UPTIME, "0"))));
prop.putHTML(STR_TABLE_LIST + conCount + "_uptime", serverDate.formatInterval(60000 * Long.parseLong(seed.get(yacySeed.UPTIME, "0"))));
prop.putNum(STR_TABLE_LIST + conCount + "_LCount", seed.getLong(yacySeed.LCOUNT, 0));
prop.putNum(STR_TABLE_LIST + conCount + "_ICount", seed.getLong(yacySeed.ICOUNT, 0));
prop.putNum(STR_TABLE_LIST + conCount + "_RCount", seed.getLong(yacySeed.RCOUNT, 0));

@ -138,10 +138,10 @@ public class News {
String category = record.category();
prop.put("table_list_" + i + "_id", record.id());
prop.putHTML("table_list_" + i + "_ori", (seed == null) ? record.originator() : seed.getName());
prop.put("table_list_" + i + "_cre", serverDate.shortSecondTime(record.created()));
prop.put("table_list_" + i + "_cre", serverDate.formatShortSecond(record.created()));
prop.put("table_list_" + i + "_crerfcdate", httpc.dateString(record.created()));
prop.put("table_list_" + i + "_cat", category);
prop.put("table_list_" + i + "_rec", (record.received() == null) ? "-" : serverDate.shortSecondTime(record.received()));
prop.put("table_list_" + i + "_rec", (record.received() == null) ? "-" : serverDate.formatShortSecond(record.received()));
prop.put("table_list_" + i + "_dis", record.distributed());
Map attributeMap = record.attributes();

@ -652,7 +652,7 @@ public class SettingsAck_p {
}
// everything is ok
prop.put("info_crawler.clientTimeout",(crawlerTimeout==0) ? "0" :serverDate.intervalToString(crawlerTimeout));
prop.put("info_crawler.clientTimeout",(crawlerTimeout==0) ? "0" :serverDate.formatInterval(crawlerTimeout));
prop.put("info_crawler.http.maxFileSize",(maxHttpSize==-1)? "-1":serverMemory.bytesToString(maxHttpSize));
prop.put("info_crawler.ftp.maxFileSize", (maxFtpSize==-1) ? "-1":serverMemory.bytesToString(maxFtpSize));
prop.put("info", "28");

@ -198,7 +198,7 @@ public class Status {
} else {
final long uptime = 60000 * Long.parseLong(yacyCore.seedDB.mySeed().get(yacySeed.UPTIME, "0"));
prop.put("peerStatistics", "1");
prop.put("peerStatistics_uptime", serverDate.intervalToString(uptime));
prop.put("peerStatistics_uptime", serverDate.formatInterval(uptime));
prop.putNum("peerStatistics_pagesperminute", yacyCore.seedDB.mySeed().getPPM());
prop.putNum("peerStatistics_queriesperhour", Math.round(6000d * yacyCore.seedDB.mySeed().getQPM()) / 100d);
prop.putNum("peerStatistics_links", yacyCore.seedDB.mySeed().getLinkCount());
@ -261,7 +261,7 @@ public class Status {
prop.put("seedServer_seedFile", sb.getConfig("seedFilePath", ""));
}
prop.put("seedServer_lastUpload",
serverDate.intervalToString(System.currentTimeMillis() - sb.yc.lastSeedUpload_timeStamp));
serverDate.formatInterval(System.currentTimeMillis() - sb.yc.lastSeedUpload_timeStamp));
} else {
prop.put(SEEDSERVER, "0"); // disabled
}

@ -68,7 +68,7 @@ public class rct_p {
}
Date loaddate;
try {
loaddate = serverDate.parseShortSecondTime(item.getPubDate());
loaddate = serverDate.parseShortSecond(item.getPubDate());
} catch (ParseException e) {
loaddate = new Date();
}

@ -85,7 +85,7 @@ public final class query {
final String obj = post.get("object", ""); // keyword for query subject
final String env = post.get("env", ""); // argument to query
prop.put("mytime", serverDate.shortSecondTime());
prop.put("mytime", serverDate.formatShortSecond());
// 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)) {

@ -66,7 +66,7 @@ public final class transferURL {
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) throws InterruptedException {
long start = System.currentTimeMillis();
long freshdate = 0;
try {freshdate = serverDate.parseShortDayTime("20061101").getTime();} catch (ParseException e1) {}
try {freshdate = serverDate.parseShortDay("20061101").getTime();} catch (ParseException e1) {}
// return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) env;

@ -79,7 +79,7 @@ public class urls {
prop.putHTML("item_" + c + "_referrer", (referrer == null) ? "" : referrer.toNormalform(true, false));
prop.putHTML("item_" + c + "_description", entry.name());
prop.put("item_" + c + "_author", "");
prop.put("item_" + c + "_pubDate", serverDate.shortSecondTime(entry.appdate()));
prop.put("item_" + c + "_pubDate", serverDate.formatShortSecond(entry.appdate()));
prop.put("item_" + c + "_guid", entry.url().hash());
c++;
count--;
@ -109,7 +109,7 @@ public class urls {
prop.putHTML("item_" + c + "_referrer", (referrer == null) ? "" : referrer.toNormalform(true, false));
prop.putHTML("item_" + c + "_description", comp.title());
prop.put("item_" + c + "_author", comp.author());
prop.put("item_" + c + "_pubDate", serverDate.shortSecondTime(entry.moddate()));
prop.put("item_" + c + "_pubDate", serverDate.formatShortSecond(entry.moddate()));
prop.put("item_" + c + "_guid", entry.hash());
c++;
}

@ -123,7 +123,7 @@ public class blogBoard {
key = nkey;
if (key.length() > keyLength) key = key.substring(0, keyLength);
if(date == null) date = new Date();
record.put("date", serverDate.shortSecondTime(date));
record.put("date", serverDate.formatShortSecond(date));
if (subject == null) record.put("subject","");
else record.put("subject", kelondroBase64Order.enhancedCoder.encode(subject));
if (author == null) record.put("author","");
@ -167,7 +167,7 @@ public class blogBoard {
System.out.println("DEBUG - ERROR: date field missing in blogBoard");
return new Date();
}
return serverDate.parseShortSecondTime(c);
return serverDate.parseShortSecond(c);
} catch (ParseException e) {
return new Date();
}
@ -177,7 +177,7 @@ public class blogBoard {
String c = (String) record.get("date");
if (c == null) {
System.out.println("DEBUG - ERROR: date field missing in blogBoard");
return serverDate.shortSecondTime();
return serverDate.formatShortSecond();
}
return c;
}
@ -305,7 +305,7 @@ public class blogBoard {
}
try {
date = serverDate.parseShortSecondTime(StrDate);
date = serverDate.parseShortSecond(StrDate);
} catch (ParseException e1) {
date = new Date();
}

@ -615,7 +615,7 @@ public final class httpdFileHandler {
tp.put(servletProperties.PEER_STAT_VERSION, switchboard.getConfig("version", ""));
tp.put(servletProperties.PEER_STAT_UPTIME, ((System.currentTimeMillis() - serverCore.startupTime) / 1000) / 60); // uptime in minutes
tp.put(servletProperties.PEER_STAT_CLIENTNAME, switchboard.getConfig("peerName", "anomic"));
tp.put(servletProperties.PEER_STAT_MYTIME, serverDate.shortSecondTime());
tp.put(servletProperties.PEER_STAT_MYTIME, serverDate.formatShortSecond());
//System.out.println("respond props: " + ((tp == null) ? "null" : tp.toString())); // debug
} catch (InvocationTargetException e) {
if (e.getCause() instanceof InterruptedException) {

@ -212,17 +212,17 @@ public class indexURLEntry {
this.entry.setCol(col_hash, url.hash(), null);
this.entry.setCol(col_comp, encodeComp(url, descr, author, tags, ETag));
try {
encodeDate(col_mod, serverDate.parseShortDayTime(prop.getProperty("mod", "20000101")));
encodeDate(col_mod, serverDate.parseShortDay(prop.getProperty("mod", "20000101")));
} catch (ParseException e) {
encodeDate(col_mod, new Date());
}
try {
encodeDate(col_load, serverDate.parseShortDayTime(prop.getProperty("load", "20000101")));
encodeDate(col_load, serverDate.parseShortDay(prop.getProperty("load", "20000101")));
} catch (ParseException e) {
encodeDate(col_load, new Date());
}
try {
encodeDate(col_fresh, serverDate.parseShortDayTime(prop.getProperty("fresh", "20000101")));
encodeDate(col_fresh, serverDate.parseShortDay(prop.getProperty("fresh", "20000101")));
} catch (ParseException e) {
encodeDate(col_fresh, new Date());
}

@ -304,7 +304,7 @@ public class plasmaCrawlQueues {
referrer = null;
}
try {
loaddate = serverDate.parseShortSecondTime(item.getPubDate());
loaddate = serverDate.parseShortSecond(item.getPubDate());
} catch (ParseException e) {
loaddate = new Date();
}

@ -237,8 +237,8 @@ public class plasmaDbImporter extends AbstractImporter implements dbImporter {
"[" + this.wordChunkStartHash + " .. " + this.wordChunkEndHash + "] " +
this.getProcessingStatusPercent() + "%\n" +
"Speed: "+ 500*1000/duration + " word entities/s" +
" | Elapsed time: " + serverDate.intervalToString(getElapsedTime()) +
" | Estimated time: " + serverDate.intervalToString(getEstimatedTime()) + "\n" +
" | Elapsed time: " + serverDate.formatInterval(getElapsedTime()) +
" | Estimated time: " + serverDate.formatInterval(getEstimatedTime()) + "\n" +
"Home Words = " + homeWordIndex.size() +
" | Import Words = " + this.importWordIndex.size());
this.wordChunkStart = this.wordChunkEnd;

@ -138,9 +138,7 @@ public final class serverDate {
for(int i = 0; i < FORMATS_HTTP.length; i++) {
try {
synchronized (FORMATS_HTTP[i]) {
return FORMATS_HTTP[i].parse(s);
}
return parse(FORMATS_HTTP[i], s);
} catch (ParseException e) {
// on ParseException try again with next parser
}
@ -282,14 +280,6 @@ public final class serverDate {
return format(FORMAT_SHORT_DAY, new Date());
}
/**
* @see #formatShortDay()
* @param tz a TimeZone the resulting date is aligned to.
*/
public static String formatShortDay(TimeZone tz) {
return format(FORMAT_SHORT_DAY, new Date(), tz);
}
/**
* @see #formatShortDay()
* @param date the Date to transform
@ -299,43 +289,73 @@ public final class serverDate {
}
/**
* This should only be used, if you need a short date String that needs to be aligned to
* a special timezone other than GMT/UTC. Be aware that a receiver won't be able to
* recreate the original Date without additional timezone information.
* @see #formatShortDay()
* @param date the Date to transform
* @param tz a TimeZone the resulting date String should be aligned to.
*/
public static String formatShortDay(Date date, TimeZone tz) {
return format(FORMAT_SHORT_DAY, date);
return format(FORMAT_SHORT_DAY, date, tz);
}
public static Date parseShortDayTime(String timeString) throws ParseException {
synchronized (serverDate.FORMAT_SHORT_DAY) {
return serverDate.FORMAT_SHORT_DAY.parse(timeString);
}
/**
* Parse a String representation of a Date in short day format assuming the date
* is aligned to the GMT/UTC timezone. An example for such a date string is "20071218".
* @see #formatShortDay()
* @throws ParseException The exception is thrown if an error occured during while parsing
* the String.
*/
public static Date parseShortDay(String timeString) throws ParseException {
return parse(FORMAT_SHORT_DAY, timeString);
}
public static String shortSecondTime() {
return shortSecondTime(new Date());
/**
* Returns the current date in short second format which is a fixed width (14 chars)
* String including the date and the time like "20071218233510". The result is in GMT/UTC.
* @see #formatShortDay()
*/
public static String formatShortSecond() {
return formatShortSecond(new Date());
}
public static String shortSecondTime(Date date) {
synchronized (serverDate.FORMAT_SHORT_SECOND) {
return serverDate.FORMAT_SHORT_SECOND.format(date);
}
/**
* Identical to {@link #formatShortDay(Date)}, but for short second format.
*/
public static String formatShortSecond(Date date) {
return format(FORMAT_SHORT_SECOND, date);
}
public static Date parseShortSecondTime(String timeString) throws ParseException {
synchronized (serverDate.FORMAT_SHORT_SECOND) {
return serverDate.FORMAT_SHORT_SECOND.parse(timeString);
}
/**
* Identical to {@link #formatShortDay(Date, TimeZone)}, but for short second format.
*/
public static String formatShortSecond(Date date, TimeZone tz) {
return format(FORMAT_SHORT_SECOND, date, tz);
}
//TODO check the following 2 parse methods for correct use (GMT vs. different timezone)
/**
* Like {@link #parseShortDay(String)}, but for the "short second" format which is short date
* plus a 6 digit day time value, like "20071218233510". The String should be in GMT/UTC to
* get a correct Date.
*/
public static Date parseShortSecond(String timeString) throws ParseException {
return parse(FORMAT_SHORT_SECOND, timeString);
}
public static Date parseShortSecondTime(String remoteTimeString, String remoteUTCOffset) {
/**
* Like {@link #parseShortSecond(String)} using additional timezone information provided in an
* offset String, like "+0100" for CET.
*/
public static Date parseShortSecond(String remoteTimeString, String remoteUTCOffset) {
// FIXME: This method returns an incorrect date, check callers!
// ex: de.anomic.server.serverDate.parseShortSecond("20070101120000", "+0200").toGMTString()
// => 1 Jan 2007 13:00:00 GMT
if (remoteTimeString == null || remoteTimeString.length() == 0) { return new Date(); }
if (remoteUTCOffset == null || remoteUTCOffset.length() == 0) { return new Date(); }
try {
synchronized(serverDate.FORMAT_SHORT_SECOND) {
return new Date(serverDate.FORMAT_SHORT_SECOND.parse(remoteTimeString).getTime() - serverDate.UTCDiff() + serverDate.UTCDiff(remoteUTCOffset));
}
return new Date(parse(FORMAT_SHORT_SECOND, remoteTimeString).getTime() - serverDate.UTCDiff() + serverDate.UTCDiff(remoteUTCOffset));
} catch (java.text.ParseException e) {
serverLog.logFinest("parseUniversalDate", e.getMessage() + ", remoteTimeString=[" + remoteTimeString + "]");
return new Date();
@ -345,9 +365,36 @@ public final class serverDate {
}
}
/**
* called by all public format...(..., TimeZone) methods
* Format a time inteval in milliseconds into a String of the form
* X 'day'['s'] HH':'mm
*/
public static String formatInterval(long millis) {
try {
long mins = millis / 60000;
StringBuffer uptime = new StringBuffer();
int uptimeDays = (int) (Math.floor(mins/1440));
int uptimeHours = (int) (Math.floor(mins/60)%24);
int uptimeMins = (int) mins%60;
uptime.append(uptimeDays)
.append(((uptimeDays == 1)?" day ":" days "))
.append((uptimeHours < 10)?"0":"")
.append(uptimeHours)
.append(":")
.append((uptimeMins < 10)?"0":"")
.append(uptimeMins);
return uptime.toString();
} catch (Exception e) {
return "unknown";
}
}
/** called by all public format...(..., TimeZone) methods */
private static String format(SimpleDateFormat format, Date date, TimeZone tz) {
TimeZone bakTZ = format.getTimeZone();
String result;
@ -361,19 +408,19 @@ public final class serverDate {
return result;
}
/**
* called by all public format...(...) methods
*/
/** called by all public format...(...) methods */
private static String format(SimpleDateFormat format, Date date) {
String result;
synchronized (format) {
result = format.format(date);
return format.format(date);
}
return result;
}
/** calles by all public parse...(...) methods */
private static Date parse(SimpleDateFormat format, String dateString) throws ParseException {
synchronized (format) {
return format.parse(dateString);
}
}
// statics
public final static long secondMillis = 1000;
@ -583,30 +630,6 @@ public final class serverDate {
return new String(result);
}
public static String intervalToString(long millis) {
try {
long mins = millis / 60000;
StringBuffer uptime = new StringBuffer();
int uptimeDays = (int) (Math.floor(mins/1440));
int uptimeHours = (int) (Math.floor(mins/60)%24);
int uptimeMins = (int) mins%60;
uptime.append(uptimeDays)
.append(((uptimeDays == 1)?" day ":" days "))
.append((uptimeHours < 10)?"0":"")
.append(uptimeHours)
.append(":")
.append((uptimeMins < 10)?"0":"")
.append(uptimeMins);
return uptime.toString();
} catch (Exception e) {
return "unknown";
}
}
public static long remainingTime(long start, long due, long minimum) {
if (due < 0) return -1;
long r = due + start - System.currentTimeMillis();
@ -617,7 +640,7 @@ public final class serverDate {
//System.out.println("kelondroDate is (" + new kelondroDate().toString() + ")");
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 : " + shortSecondTime());
System.out.println(" javaDate : " + formatShortSecond());
System.out.println("serverDate : " + new serverDate().toString());
System.out.println(" JavaDate : " + DateFormat.getDateInstance().format(new Date()));
System.out.println("serverDate0: " + new serverDate(0).toShortString(false));

@ -325,14 +325,14 @@ public class yacyCore {
if (newSeed.getLastSeenUTC() >= this.seed.getLastSeenUTC()) {
log.logFine("publish: recently handshaked " + this.seed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_SENIOR) +
" peer '" + this.seed.getName() + "' at " + this.seed.getPublicAddress() + " with old LastSeen: '" +
serverDate.shortSecondTime(new Date(newSeed.getLastSeenUTC())) + "'");
serverDate.formatShortSecond(new Date(newSeed.getLastSeenUTC())) + "'");
newSeed.setLastSeenUTC();
peerActions.peerArrival(newSeed, true);
} else {
log.logFine("publish: recently handshaked " + this.seed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_SENIOR) +
" peer '" + this.seed.getName() + "' at " + this.seed.getPublicAddress() + " with old LastSeen: '" +
serverDate.shortSecondTime(new Date(newSeed.getLastSeenUTC())) + "', this is more recent: '" +
serverDate.shortSecondTime(new Date(this.seed.getLastSeenUTC())) + "'");
serverDate.formatShortSecond(new Date(newSeed.getLastSeenUTC())) + "', this is more recent: '" +
serverDate.formatShortSecond(new Date(this.seed.getLastSeenUTC())) + "'");
this.seed.setLastSeenUTC();
peerActions.peerArrival(this.seed, true);
}

@ -79,7 +79,7 @@ public class yacyNetwork {
if (targetHash != null) post.put("youare", targetHash);
// time information for synchronization
post.put("mytime", serverDate.shortSecondTime(new Date()));
post.put("mytime", serverDate.formatShortSecond(new Date()));
post.put("myUTC", System.currentTimeMillis());
// network identification

@ -142,7 +142,7 @@ public class yacyNewsDB {
return yacyNewsRecord.newRecord(
b.getColString(0, null),
b.getColString(1, "UTF-8"),
(b.empty(2)) ? null : serverDate.parseShortSecondTime(b.getColString(2, null), serverDate.UTCDiffString()),
(b.empty(2)) ? null : serverDate.parseShortSecond(b.getColString(2, null), serverDate.UTCDiffString()),
(int) b.getColLong(3),
serverCodings.string2map(b.getColString(4, "UTF-8"), ",")
);
@ -156,7 +156,7 @@ public class yacyNewsDB {
kelondroRow.Entry entry = this.news.row().newEntry();
entry.setCol(0, r.id().getBytes());
entry.setCol(1, r.category().getBytes("UTF-8"));
entry.setCol(2, (r.received() == null) ? null : serverDate.shortSecondTime(r.received()).getBytes());
entry.setCol(2, (r.received() == null) ? null : serverDate.formatShortSecond(r.received()).getBytes());
entry.setCol(3, kelondroBase64Order.enhancedCoder.encodeLong(r.distributed(), 2).getBytes());
entry.setCol(4, attributes.getBytes("UTF-8"));
return entry;

@ -161,7 +161,7 @@ public class yacyNewsQueue {
}
kelondroRow.Entry b = queueStack.row().newEntry(new byte[][]{
r.id().getBytes(),
serverDate.shortSecondTime(new Date()).getBytes()});
serverDate.formatShortSecond(new Date()).getBytes()});
return b;
}

@ -112,8 +112,8 @@ public class yacyNewsRecord {
if (attributes.toString().length() > attributesMaxLength) throw new IllegalArgumentException("attributes length (" + attributes.toString().length() + ") exceeds maximum (" + attributesMaxLength + ")");
this.category = (attributes.containsKey("cat")) ? (String) attributes.get("cat") : "";
if (category.length() > categoryStringLength) throw new IllegalArgumentException("category length (" + category.length() + ") exceeds maximum (" + categoryStringLength + ")");
this.received = (attributes.containsKey("rec")) ? serverDate.parseShortSecondTime((String) attributes.get("rec"), serverDate.UTCDiffString()) : new Date();
this.created = (attributes.containsKey("cre")) ? serverDate.parseShortSecondTime((String) attributes.get("cre"), serverDate.UTCDiffString()) : new Date();
this.received = (attributes.containsKey("rec")) ? serverDate.parseShortSecond((String) attributes.get("rec"), serverDate.UTCDiffString()) : new Date();
this.created = (attributes.containsKey("cre")) ? serverDate.parseShortSecond((String) attributes.get("cre"), serverDate.UTCDiffString()) : new Date();
this.distributed = (attributes.containsKey("dis")) ? Integer.parseInt((String) attributes.get("dis")) : 0;
this.originator = (attributes.containsKey("ori")) ? (String) attributes.get("ori") : "";
removeStandards();
@ -136,7 +136,7 @@ public class yacyNewsRecord {
if (attributes.toString().length() > attributesMaxLength) throw new IllegalArgumentException("attributes length (" + attributes.toString().length() + ") exceeds maximum (" + attributesMaxLength + ")");
this.attributes = attributes;
this.received = received;
this.created = serverDate.parseShortSecondTime(id.substring(0, serverDate.PATTERN_SHORT_SECOND.length()), serverDate.UTCDiffString());
this.created = serverDate.parseShortSecond(id.substring(0, serverDate.PATTERN_SHORT_SECOND.length()), serverDate.UTCDiffString());
this.category = category;
this.distributed = distributed;
this.originator = id.substring(serverDate.PATTERN_SHORT_SECOND.length());
@ -156,8 +156,8 @@ public class yacyNewsRecord {
// attention: this has no additional encoding
if (this.originator != null) attributes.put("ori", this.originator);
if (this.category != null) attributes.put("cat", this.category);
if (this.created != null) attributes.put("cre", serverDate.shortSecondTime(this.created));
if (this.received != null) attributes.put("rec", serverDate.shortSecondTime(this.received));
if (this.created != null) attributes.put("cre", serverDate.formatShortSecond(this.created));
if (this.received != null) attributes.put("rec", serverDate.formatShortSecond(this.received));
attributes.put("dis", Integer.toString(this.distributed));
String theString = attributes.toString();
removeStandards();
@ -165,7 +165,7 @@ public class yacyNewsRecord {
}
public String id() {
return serverDate.shortSecondTime(created) + originator;
return serverDate.formatShortSecond(created) + originator;
}
public String originator() {

@ -263,7 +263,7 @@ public class yacyPeerActions {
}
if (Math.abs(nowUTC0Time - ctimeUTC0) > 60 * 60 * 24 * 1000) {
// the new connection is out-of-age, we reject the connection
yacyCore.log.logFine("connect: rejecting out-dated peer '" + seed.getName() + "' from " + seed.getPublicAddress() + "; nowUTC0=" + nowUTC0Time + ", seedUTC0=" + ctimeUTC0 + ", TimeDiff=" + serverDate.intervalToString(Math.abs(nowUTC0Time - ctimeUTC0)));
yacyCore.log.logFine("connect: rejecting out-dated peer '" + seed.getName() + "' from " + seed.getPublicAddress() + "; nowUTC0=" + nowUTC0Time + ", seedUTC0=" + ctimeUTC0 + ", TimeDiff=" + serverDate.formatInterval(Math.abs(nowUTC0Time - ctimeUTC0)));
return false;
}

@ -222,7 +222,7 @@ public class yacySeed {
this.dna.put(yacySeed.IPTYPE, "&empty;");
// settings that can only be computed by visiting peer
this.dna.put(yacySeed.LASTSEEN, serverDate.shortSecondTime(new Date(System.currentTimeMillis() - serverDate.UTCDiff()))); // for last-seen date
this.dna.put(yacySeed.LASTSEEN, serverDate.formatShortSecond(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);
@ -527,7 +527,7 @@ public class yacySeed {
// because java thinks it must apply the UTC offset to the current time,
// to create a string that looks like our current time, it adds the local UTC offset to the
// time. To create a corrected UTC Date string, we first subtract the local UTC offset.
dna.put(yacySeed.LASTSEEN, serverDate.shortSecondTime(new Date(System.currentTimeMillis() - serverDate.UTCDiff())) );
dna.put(yacySeed.LASTSEEN, serverDate.formatShortSecond(new Date(System.currentTimeMillis() - serverDate.UTCDiff())) );
}
/**
@ -535,7 +535,7 @@ public class yacySeed {
*/
public final long getLastSeenUTC() {
try {
final long t = serverDate.parseShortSecondTime(get(yacySeed.LASTSEEN, "20040101000000")).getTime();
final long t = serverDate.parseShortSecond(get(yacySeed.LASTSEEN, "20040101000000")).getTime();
// getTime creates a UTC time number. But in this case java thinks, that the given
// time string is a local time, which has a local UTC offset applied.
// Therefore java subtracts the local UTC offset, to get a UTC number.
@ -562,7 +562,7 @@ public class yacySeed {
/** @return the age of the seed in number of days */
public final int getAge() {
try {
final long t = serverDate.parseShortSecondTime(get(yacySeed.BDATE, "20040101000000")).getTime();
final long t = serverDate.parseShortSecond(get(yacySeed.BDATE, "20040101000000")).getTime();
return (int) ((System.currentTimeMillis() - (t - getUTCDiff() + serverDate.UTCDiff())) / 1000 / 60 / 60 / 24);
} catch (java.text.ParseException e) {
return -1;
@ -775,7 +775,7 @@ public class yacySeed {
} else {
newSeed.dna.put(yacySeed.PORT, Integer.toString(serverCore.getPortNr(sb.getConfig("port", "8080"))));
}
newSeed.dna.put(yacySeed.BDATE, serverDate.shortSecondTime(new Date(System.currentTimeMillis() - serverDate.UTCDiff())) );
newSeed.dna.put(yacySeed.BDATE, serverDate.formatShortSecond(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);

Loading…
Cancel
Save