Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

better handling of seed properties

orbiter0eb60cfe6f69
diff --git a/htroot/Network.java b/htroot/Network.java
index 1233cef66..84c1e1629 100644
--- a/htroot/Network.java
+++ b/htroot/Network.java
@@ -453,13 +453,13 @@ public class Network {
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.putNum(STR_TABLE_LIST + conCount + "_LCount", Long.parseLong(seed.get(yacySeed.LCOUNT, "0")));
- prop.putNum(STR_TABLE_LIST + conCount + "_ICount", Long.parseLong(seed.get(yacySeed.ICOUNT, "0")));
- prop.putNum(STR_TABLE_LIST + conCount + "_RCount", Long.parseLong(seed.get(yacySeed.RCOUNT, "0")));
- prop.putNum(STR_TABLE_LIST + conCount + "_sI", Long.parseLong(seed.get(yacySeed.INDEX_OUT, "0")));
- prop.putNum(STR_TABLE_LIST + conCount + "_sU", Long.parseLong(seed.get(yacySeed.URL_OUT, "0")));
- prop.putNum(STR_TABLE_LIST + conCount + "_rI", Long.parseLong(seed.get(yacySeed.INDEX_IN, "0")));
- prop.putNum(STR_TABLE_LIST + conCount + "_rU", Long.parseLong(seed.get(yacySeed.URL_IN, "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));
+ prop.putNum(STR_TABLE_LIST + conCount + "_sI", seed.getLong(yacySeed.INDEX_OUT, 0));
+ prop.putNum(STR_TABLE_LIST + conCount + "_sU", seed.getLong(yacySeed.URL_OUT, 0));
+ prop.putNum(STR_TABLE_LIST + conCount + "_rI", seed.getLong(yacySeed.INDEX_IN, 0));
+ prop.putNum(STR_TABLE_LIST + conCount + "_rU", seed.getLong(yacySeed.URL_IN, 0));
prop.putNum(STR_TABLE_LIST + conCount + "_ppm", PPM);
prop.putNum(STR_TABLE_LIST + conCount + "_qph", Math.round(6000d * QPM) / 100d);
conCount++;
diff --git a/source/de/anomic/yacy/yacyPeerActions.java b/source/de/anomic/yacy/yacyPeerActions.java
index a40c03f96..0a7cba82d 100644
--- a/source/de/anomic/yacy/yacyPeerActions.java
+++ b/source/de/anomic/yacy/yacyPeerActions.java
@@ -273,7 +273,7 @@ public class yacyPeerActions {
if (disconnectedSeed == null) {
dtimeUTC0 = 0; // never disconnected: virtually disconnected maximum time ago
} else {
- dtimeUTC0 = Long.parseLong(disconnectedSeed.get("dct", "0"));
+ dtimeUTC0 = disconnectedSeed.getLong("dct", 0);
}
if (direct) {
diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.java
index 72e02c021..b25164c08 100644
--- a/source/de/anomic/yacy/yacySeed.java
+++ b/source/de/anomic/yacy/yacySeed.java
@@ -329,6 +329,16 @@ public class yacySeed {
if (o == null) { return dflt; }
return (String) o;
}
+
+ public final long getLong(String key, long dflt) {
+ final Object o = this.dna.get(key);
+ if (o == null) { return dflt; }
+ try {
+ return Long.parseLong((String) o);
+ } catch (NumberFormatException e) {
+ return dflt;
+ }
+ }
public final void setIP() { dna.put(yacySeed.IP, ""); }
public final void setIP(final String ip) { dna.put(yacySeed.IP, ip); }
@@ -592,7 +602,7 @@ public class yacySeed {
public final long getLinkCount() {
try {
- return Long.parseLong(get(yacySeed.LCOUNT, yacySeed.ZERO));
+ return getLong(yacySeed.LCOUNT, 0);
} catch (NumberFormatException e) {
return 0;
}