fixed bugs (dns, seedDB)

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@13 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 20 years ago
parent 89eb9a2292
commit 072052f150

@ -92,7 +92,13 @@ public class httpc {
private static HashMap nameCacheHit = new HashMap();
//private static HashSet nameCacheMiss = new HashSet();
public static String dnsResolve(String host) {
static {
// set time-out of InetAddress.getByName cache ttl
java.security.Security.setProperty("networkaddress.cache.ttl" , "60");
java.security.Security.setProperty("networkaddress.cache.negative.ttl" , "0");
}
private static String dnsResolveX(String host) {
// looks for the ip of host <host> and returns ip number as string
String ip = (String) nameCacheHit.get(host);
if (ip != null) return ip;
@ -111,6 +117,18 @@ public class httpc {
return null;
}
public static String dnsResolve(String host) {
String ip = null;
for (int i = 0; i < 50; i++) {
ip = dnsResolveX(host);
if (ip != null) {
//if (i > 0) System.out.println(i + " attempts for " + host);
return ip;
}
}
return ip;
}
public static boolean dnsFetch(String host) {
// looks for the ip of host <host> and returns false if the host was in the cache
// if it is not in the cache the ip is fetched and this resturns true

@ -158,8 +158,11 @@ public class kelondroDyn extends kelondroTree {
String k;
String v;
int c;
byte[][] nt;
while (ri.hasNext()) {
g = ((byte[][]) ri.next())[0];
nt = (byte[][]) ri.next();
if (nt == null) return null;
g = nt[0];
if (g == null) return null;
k = new String(g, 0, keylen);
v = new String(g, keylen, counterlen);

@ -96,6 +96,7 @@ public class kelondroMap {
Map map;
while (it.hasNext()) {
key = (String) it.next();
//System.out.println("kelondroMap: enumerating key " + key);
map = get(key);
if (sortfields != null) for (int i = 0; i < sortfields.length; i++) {
@ -422,6 +423,7 @@ public class kelondroMap {
}
try {
Map map = get(nextKey);
if (map == null) return null;
map.put("key", nextKey);
return map;
} catch (IOException e) {

@ -251,12 +251,14 @@ public class kelondroTree extends kelondroRecords implements Comparator {
Node nextNode = null;
boolean up, rot;
LinkedList nodeStack;
int count;
public nodeIterator(boolean up, boolean rotating) throws IOException {
this(up, rotating, (up) ? firstNode() : lastNode());
}
public nodeIterator(boolean up, boolean rotating, Node start) throws IOException {
this.count = 0;
this.up = up;
this.rot = rotating;
this.nextNode = start;
@ -289,7 +291,9 @@ public class kelondroTree extends kelondroRecords implements Comparator {
}
public Object next() {
count++;
if (nextNode == null) return null;
if (count > size()) return null;
Object ret = nextNode;
// middle-case
@ -890,7 +894,9 @@ public class kelondroTree extends kelondroRecords implements Comparator {
public Object next() {
try {
return ((Node) nodeIterator.next()).getValues();
Node nextNode = (Node) nodeIterator.next();
if (nextNode == null) return null; // this is an error case of the nodeIterator
return nextNode.getValues();
} catch (IOException e) {
return null;
}

Loading…
Cancel
Save