fixed bugs (dns, seedDB)

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@13 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
orbiter 2005-04-11 22:44:40 +00:00
parent 89eb9a2292
commit 072052f150
4 changed files with 32 additions and 3 deletions

View File

@ -92,7 +92,13 @@ public class httpc {
private static HashMap nameCacheHit = new HashMap(); private static HashMap nameCacheHit = new HashMap();
//private static HashSet nameCacheMiss = new HashSet(); //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 // looks for the ip of host <host> and returns ip number as string
String ip = (String) nameCacheHit.get(host); String ip = (String) nameCacheHit.get(host);
if (ip != null) return ip; if (ip != null) return ip;
@ -111,6 +117,18 @@ public class httpc {
return null; 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) { public static boolean dnsFetch(String host) {
// looks for the ip of host <host> and returns false if the host was in the cache // 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 // if it is not in the cache the ip is fetched and this resturns true

View File

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

View File

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

View File

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