Skip to content

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

fixed problem with lost peers in database migrated seedDB from BLOBTree to BLOBHeap

orbiterffed5fc415bf
diff --git a/htroot/Network.java b/htroot/Network.java
index 9b7514b51..966ade1bd 100644
--- a/htroot/Network.java
+++ b/htroot/Network.java
@@ -308,7 +308,7 @@ public class Network {
prop.put(STR_TABLE_LIST + conCount + "_updatedBlog", 0);
prop.put(STR_TABLE_LIST + conCount + "_isCrawling", 0);
if (conCount >= maxCount) { break; }
- if (seed.hash.equals(sb.webIndex.seedDB.mySeed().hash)) {
+ if (sb.webIndex.seedDB.mySeed() != null && seed.hash.equals(sb.webIndex.seedDB.mySeed().hash)) {
prop.put(STR_TABLE_LIST + conCount + "_dark", 2);
} else {
prop.put(STR_TABLE_LIST + conCount + "_dark", ((dark) ? 1 : 0) ); dark=!dark;
diff --git a/source/de/anomic/kelondro/kelondroMapDataMining.java b/source/de/anomic/kelondro/kelondroMapDataMining.java
index 32590b357..410212baf 100644
--- a/source/de/anomic/kelondro/kelondroMapDataMining.java
+++ b/source/de/anomic/kelondro/kelondroMapDataMining.java
@@ -39,7 +39,6 @@ public class kelondroMapDataMining extends kelondroMap {
private final String[] sortfields, longaccfields, doubleaccfields;
private HashMap<String, kelondroMScoreCluster<String>> sortClusterMap; // a String-kelondroMScoreCluster - relation
private HashMap<String, Object> accMap; // to store accumulations of specific fields
- private int elementCount;
@SuppressWarnings("unchecked")
public kelondroMapDataMining(final kelondroBLOB dyn, final int cachesize, final String[] sortfields, final String[] longaccfields, final String[] doubleaccfields, final Method externalInitializer, final Object externalHandler) {
@@ -87,7 +86,6 @@ public class kelondroMapDataMining extends kelondroMap {
long valuel;
double valued;
Map<String, String> map;
- this.elementCount = 0;
while (it.hasNext()) {
mapname = new String(it.next());
map = super.get(mapname);
@@ -129,7 +127,6 @@ public class kelondroMapDataMining extends kelondroMap {
e.printStackTrace();
}
}
- elementCount++;
}
} catch (final IOException e) {}
@@ -165,7 +162,6 @@ public class kelondroMapDataMining extends kelondroMap {
}
}
}
- this.elementCount = 0;
}
public synchronized void put(final String key, final HashMap<String, String> newMap) throws IOException {
@@ -176,10 +172,7 @@ public class kelondroMapDataMining extends kelondroMap {
// update elementCount
if ((longaccfields != null) || (doubleaccfields != null)) {
final Map<String, String> oldMap = super.get(key, false);
- if (oldMap == null) {
- // new element
- elementCount++;
- } else {
+ if (oldMap != null) {
// element exists, update acc
if ((longaccfields != null) || (doubleaccfields != null)) updateAcc(oldMap, false);
}
@@ -250,8 +243,6 @@ public class kelondroMapDataMining extends kelondroMap {
if ((sortfields != null) || (longaccfields != null) || (doubleaccfields != null)) {
final Map<String, String> map = super.get(key);
if (map != null) {
- // update count
- elementCount--;
// update accumulators (subtract)
if ((longaccfields != null) || (doubleaccfields != null)) updateAcc(map, false);
@@ -331,7 +322,6 @@ public class kelondroMapDataMining extends kelondroMap {
}
public synchronized int size() {
- if ((sortfields != null) || (longaccfields != null) || (doubleaccfields != null)) return elementCount;
return super.size();
}
diff --git a/source/de/anomic/plasma/plasmaWordIndex.java b/source/de/anomic/plasma/plasmaWordIndex.java
index cd4bcb0e5..7425fb88b 100644
--- a/source/de/anomic/plasma/plasmaWordIndex.java
+++ b/source/de/anomic/plasma/plasmaWordIndex.java
@@ -215,9 +215,9 @@ public final class plasmaWordIndex implements indexRI {
final File oldSeedFile = new File(new File(indexPrimaryRoot.getParentFile(), "YACYDB"), "mySeed.txt");
if (oldSeedFile.exists()) oldSeedFile.renameTo(mySeedFile);
seedDB = new yacySeedDB(
- new File(networkRoot, "seed.new.db"),
- new File(networkRoot, "seed.old.db"),
- new File(networkRoot, "seed.pot.db"),
+ new File(networkRoot, "seed.new.heap"),
+ new File(networkRoot, "seed.old.heap"),
+ new File(networkRoot, "seed.pot.heap"),
mySeedFile
);
diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.java
index d5947fd8b..e8b923d3a 100644
--- a/source/de/anomic/yacy/yacySeedDB.java
+++ b/source/de/anomic/yacy/yacySeedDB.java
@@ -47,7 +47,7 @@ import de.anomic.http.JakartaCommonsHttpResponse;
import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpd;
import de.anomic.http.httpdAlternativeDomainNames;
-import de.anomic.kelondro.kelondroBLOBTree;
+import de.anomic.kelondro.kelondroBLOBHeap;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroException;
import de.anomic.kelondro.kelondroMScoreCluster;
@@ -220,7 +220,6 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {
@SuppressWarnings("unchecked")
private synchronized kelondroMapDataMining openSeedTable(final File seedDBFile) {
- final boolean usetree = false;
final File parentDir = new File(seedDBFile.getParent());
if (!parentDir.exists()) {
if(!parentDir.mkdirs())
@@ -244,11 +243,17 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {
initializeHandlerMethod = null;
}
try {
- return new kelondroMapDataMining(new kelondroBLOBTree(seedDBFile, true, true, commonHashLength, 480, '#', kelondroBase64Order.enhancedCoder, usetree, false, true), 500, sortFields, longaccFields, doubleaccFields, initializeHandlerMethod, this);
+ return new kelondroMapDataMining(new kelondroBLOBHeap(seedDBFile, commonHashLength, kelondroBase64Order.enhancedCoder), 500, sortFields, longaccFields, doubleaccFields, initializeHandlerMethod, this);
} catch (final Exception e) {
// try again
- kelondroBLOBTree.delete(seedDBFile);
- return new kelondroMapDataMining(new kelondroBLOBTree(seedDBFile, true, true, commonHashLength, 480, '#', kelondroBase64Order.enhancedCoder, usetree, false, true), 500, sortFields, longaccFields, doubleaccFields, initializeHandlerMethod, this);
+ seedDBFile.delete();
+ try {
+ return new kelondroMapDataMining(new kelondroBLOBHeap(seedDBFile, commonHashLength, kelondroBase64Order.enhancedCoder), 500, sortFields, longaccFields, doubleaccFields, initializeHandlerMethod, this);
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ System.exit(-1);
+ return null;
+ }
}
}
@@ -403,30 +408,15 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {
}
public int sizeConnected() {
- return seedActiveDB.size();
- /*
- Enumeration e = seedsConnected(true, false, null);
- int c = 0; while (e.hasMoreElements()) {c++; e.nextElement();}
- return c;
- */
+ return seedActiveDB.size();
}
public int sizeDisconnected() {
- return seedPassiveDB.size();
- /*
- Enumeration e = seedsDisconnected(true, false, null);
- int c = 0; while (e.hasMoreElements()) {c++; e.nextElement();}
- return c;
- */
+ return seedPassiveDB.size();
}
public int sizePotential() {
- return seedPotentialDB.size();
- /*
- Enumeration e = seedsPotential(true, false, null);
- int c = 0; while (e.hasMoreElements()) {c++; e.nextElement();}
- return c;
- */
+ return seedPotentialDB.size();
}
public long countActiveURL() { return seedActiveDB.getLongAcc(yacySeed.LCOUNT); }