Skip to content

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

fixed a bug in index transfer - the encoding within the new entry format for binary data was wrong - the string parser of RWI receive had to be enhanced

orbiter0a0c3edeb626
diff --git a/htroot/IndexControl_p.html b/htroot/IndexControl_p.html
index 47fc1564d..4b15468f0 100644
--- a/htroot/IndexControl_p.html
+++ b/htroot/IndexControl_p.html
@@ -37,7 +37,8 @@
#{hosts}#
<option value="#[hosthash]#">#[hostname]#</option>
#{/hosts}#
- </select>
+ </select><br />
+ <input type="text" name="host" value="" size="21" maxlength="21" />
</td>
</tr>
</table>
@@ -125,7 +126,7 @@
::
No URL entries related to this word hash <span class="tt">#[keyHash]#</span>.
::
- URL entries related to this word hash <span class="tt">#[keyHash]#</span><br /><br />
+ #[count]# URL entries related to this word hash <span class="tt">#[keyHash]#</span><br /><br />
<form action="IndexControl_p.html" method="post" enctype="multipart/form-data">
#{urlList}# #(urlExists)#
<input type="checkbox" name="urlhx.#[urlhxCount]#" checked value="#[urlhxValue]#" align="top" /><span class="tt">#[urlhxValue]#&nbsp;&lt;unresolved URL Hash&gt;</span><br />
diff --git a/htroot/IndexControl_p.java b/htroot/IndexControl_p.java
index 92d81c537..147863579 100644
--- a/htroot/IndexControl_p.java
+++ b/htroot/IndexControl_p.java
@@ -250,6 +250,24 @@ public class IndexControl_p {
if (keystring.length() == 0 || !plasmaCondenser.word2hash(keystring).equals(keyhash)) {
prop.put("keystring", "<not possible to compute word from hash>");
}
+
+ // find host & peer
+ String host = post.get("host", ""); // get host from input field
+ yacySeed seed = null;
+ if (host.length() != 0) {
+ if (host.length() == 12) {
+ // the host string is a peer hash
+ seed = yacyCore.seedDB.getConnected(host);
+ } else {
+ // the host string can be a host name
+ seed = yacyCore.seedDB.lookupByName(host);
+ }
+ } else {
+ host = post.get("hostHash", ""); // if input field is empty, get from select box
+ seed = yacyCore.seedDB.getConnected(host);
+ }
+
+ // prepare index
prop.put("urlstring", "");
prop.put("urlhash", "");
indexContainer index;
@@ -272,11 +290,12 @@ public class IndexControl_p {
knownURLs.put(iEntry.urlHash(), lurl);
}
}
- // use whats remaining
+
+ // transport to other peer
String gzipBody = switchboard.getConfig("indexControl.gzipBody","false");
int timeout = (int) switchboard.getConfigLong("indexControl.timeout",60000);
HashMap resultObj = yacyClient.transferIndex(
- yacyCore.seedDB.getConnected(post.get("hostHash", "")),
+ seed,
new indexContainer[]{index},
knownURLs,
"true".equalsIgnoreCase(gzipBody),
@@ -443,6 +462,7 @@ public class IndexControl_p {
if ((index == null) || (index.size() == 0)) {
prop.put("genUrlList", 1);
+ prop.put("genUrlList_count", 0);
} else {
final Iterator en = index.entries();
prop.put("genUrlList", 2);
@@ -491,6 +511,7 @@ public class IndexControl_p {
}
prop.put("genUrlList_urlList", i);
prop.put("genUrlList_keyString", keystring);
+ prop.put("genUrlList_count", i);
}
index = null;
return prop;
diff --git a/htroot/yacy/transferRWI.java b/htroot/yacy/transferRWI.java
index b837a69c4..80c8be09a 100644
--- a/htroot/yacy/transferRWI.java
+++ b/htroot/yacy/transferRWI.java
@@ -48,7 +48,7 @@
import java.util.HashSet;
import java.util.Iterator;
-import java.util.LinkedList;
+import java.util.List;
import de.anomic.http.httpHeader;
import de.anomic.index.indexRWIEntry;
@@ -59,6 +59,7 @@ import de.anomic.plasma.urlPattern.plasmaURLPattern;
import de.anomic.server.serverCore;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
+import de.anomic.tools.nxTools;
import de.anomic.yacy.yacyCore;
import de.anomic.yacy.yacyDHTAction;
import de.anomic.yacy.yacySeed;
@@ -128,14 +129,8 @@ public final class transferRWI {
final long startProcess = System.currentTimeMillis();
// decode request
- final LinkedList v = new LinkedList();
- int s = 0;
- int e;
- while (s < indexes.length) {
- e = s; while (e < indexes.length) if (indexes[e++] < 32) {e--; break;}
- if ((e - s) > 0) v.add(new String(indexes, s, e - s));
- s = e; while (s < indexes.length) if (indexes[s++] >= 32) {s--; break;}
- }
+ final List v = nxTools.strings(indexes, null);
+
// free memory
indexes = null;
@@ -148,17 +143,17 @@ public final class transferRWI {
String wordHash;
String urlHash;
indexRWIEntry iEntry;
- int wordhashesSize = v.size();
final HashSet unknownURL = new HashSet();
final HashSet knownURL = new HashSet();
String[] wordhashes = new String[v.size()];
int received = 0;
int blocked = 0;
int receivedURL = 0;
- for (int i = 0; i < wordhashesSize; i++) {
+ Iterator i = v.iterator();
+ while (i.hasNext()) {
serverCore.checkInterruption();
- estring = (String) v.removeFirst();
+ estring = (String) i.next();
p = estring.indexOf("{");
if (p > 0) {
wordHash = estring.substring(0, p);
diff --git a/source/de/anomic/index/indexRWIEntryNew.java b/source/de/anomic/index/indexRWIEntryNew.java
index 04ce559d8..31dd574a0 100644
--- a/source/de/anomic/index/indexRWIEntryNew.java
+++ b/source/de/anomic/index/indexRWIEntryNew.java
@@ -264,6 +264,10 @@ public class indexRWIEntryNew implements Cloneable, indexRWIEntry {
return new kelondroBitfield(this.entry.getColBytes(col_flags));
}
+ public String toString() {
+ return toPropertyForm();
+ }
+
public static indexRWIEntryNew combineDistance(indexRWIEntryNew ie1, indexRWIEntry ie2) {
// returns a modified entry of the first argument
ie1.entry.setCol(col_worddistance, ie1.worddistance() + ie2.worddistance() + Math.abs(ie1.posintext() - ie2.posintext()));
diff --git a/source/de/anomic/kelondro/kelondroRow.java b/source/de/anomic/kelondro/kelondroRow.java
index c17cb0b65..e302c046d 100644
--- a/source/de/anomic/kelondro/kelondroRow.java
+++ b/source/de/anomic/kelondro/kelondroRow.java
@@ -209,6 +209,13 @@ public class kelondroRow {
} catch (NumberFormatException e) {
setCol(nick, 0);
}
+ } else if ((decimalCardinal) && (row[i].celltype() == kelondroColumn.celltype_binary)) {
+ assert row[i].cellwidth() == 1;
+ try {
+ setCol(nick, new byte[]{(byte) Integer.parseInt(elts[i].substring(p + 1).trim())});
+ } catch (NumberFormatException e) {
+ setCol(nick, new byte[]{0});
+ }
} else if ((decimalCardinal) && (row[i].celltype() == kelondroColumn.celltype_bitfield)) {
setCol(nick, (new kelondroBitfield(row[i].cellwidth(), elts[i].substring(p + 1).trim())).bytes());
} else {
@@ -443,6 +450,9 @@ public class kelondroRow {
bb.append(Long.toString(getColLong(i)));
} else if ((decimalCardinal) && (row[i].celltype() == kelondroColumn.celltype_bitfield)) {
bb.append((new kelondroBitfield(getColBytes(i))).exportB64());
+ } else if ((decimalCardinal) && (row[i].celltype() == kelondroColumn.celltype_binary)) {
+ assert row[i].cellwidth() == 1;
+ bb.append(Integer.toString((int) (0xff & getColByte(i))));
} else {
bb.append(rowinstance, colstart[i], row[i].cellwidth());
}
diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.java
index 0c6dd4608..5a211e90e 100644
--- a/source/de/anomic/yacy/yacySeed.java
+++ b/source/de/anomic/yacy/yacySeed.java
@@ -344,9 +344,10 @@ public class yacySeed {
}
public final String getAddress() {
- final String ip = (String) this.dna.get(yacySeed.IP);
+ String ip = (String) this.dna.get(yacySeed.IP);
if (ip == null) { return null; }
if (ip.length() < 8) { return null; } // 10.0.0.0
+ if (ip.equals(yacyCore.seedDB.mySeed.dna.get(yacySeed.IP))) ip = "127.0.0.1";
final String port = (String) this.dna.get(yacySeed.PORT);
if (port == null) { return null; }