Skip to content

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

Migration to WORK

allo4d33020f5679
diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java
index a4857daa6..7cd5a921c 100644
--- a/source/de/anomic/plasma/plasmaSwitchboard.java
+++ b/source/de/anomic/plasma/plasmaSwitchboard.java
@@ -170,6 +170,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
public File listsPath;
public File htDocsPath;
public File rankingPath;
+ public File workPath;
public HashMap rankingPermissions;
public plasmaURLPool urlPool;
public plasmaWordIndex wordIndex;
@@ -241,6 +242,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
this.rankingPath = new File(rootPath, getConfig("rankingPath", "DATA/RANKING"));
this.log.logConfig("Ranking Path: " + this.rankingPath.toString());
this.rankingPermissions = new HashMap(); // mapping of permission - to filename.
+ this.workPath = new File(rootPath, getConfig("workPath", "DATA/WORK"));
+ this.log.logConfig("Work Path: " + this.workPath.toString());
/* ============================================================================
* Remote Proxy configuration
@@ -409,22 +412,11 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
plasmaCrawlLoader.switchboard = this;
this.cacheLoader = new plasmaCrawlLoader(this.cacheManager, this.log);
- // starting message board
- this.log.logConfig("Starting Message Board");
- File messageDbFile = new File(getRootPath(), "DATA/SETTINGS/message.db");
- this.messageDB = new messageBoard(messageDbFile, ramMessage);
- this.log.logConfig("Loaded Message Board DB from file " + messageDbFile.getName() +
- ", " + this.messageDB.size() + " entries" +
- ", " + ppRamString(messageDbFile.length()/1024));
+ // starting board
+ initMessages(ramMessage);
// starting wiki
- this.log.logConfig("Starting Wiki Board");
- File wikiDbFile = new File(getRootPath(), "DATA/SETTINGS/wiki.db");
- this.wikiDB = new wikiBoard(wikiDbFile,
- new File(getRootPath(), "DATA/SETTINGS/wiki-bkp.db"), ramWiki);
- this.log.logConfig("Loaded Wiki Board DB from file " + wikiDbFile.getName() +
- ", " + this.wikiDB.size() + " entries" +
- ", " + ppRamString(wikiDbFile.length()/1024));
+ initWiki(ramWiki);
// Init User DB
this.log.logConfig("Loading User DB");
@@ -436,9 +428,9 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
//Init bookmarks DB
this.log.logConfig("Loading Bookmarks DB");
- File bookmarksFile = new File(getRootPath(), "DATA/WORK/bookmarks.db");
- File tagsFile = new File(getRootPath(), "DATA/WORK/bookmarkTags.db");
- File datesFile = new File(getRootPath(), "DATA/WORK/bookmarkDates.db");
+ File bookmarksFile = new File(workPath, "bookmarks.db");
+ File tagsFile = new File(workPath, "bookmarkTags.db");
+ File datesFile = new File(workPath, "bookmarkDates.db");
this.bookmarksDB = new bookmarksDB(bookmarksFile, tagsFile, datesFile, 512);
this.log.logConfig("Loaded Bookmarks DB from files "+ bookmarksFile.getName()+ ", "+tagsFile.getName());
this.log.logConfig(this.bookmarksDB.tagsSize()+" Tag, "+this.bookmarksDB.bookmarksSize()+" Bookmarks");
@@ -577,6 +569,27 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
sb=this;
log.logConfig("Finished Switchboard Initialization");
}
+
+
+ public void initMessages(int ramMessage) {
+ this.log.logConfig("Starting Message Board");
+ File messageDbFile = new File(workPath, "message.db");
+ this.messageDB = new messageBoard(messageDbFile, ramMessage);
+ this.log.logConfig("Loaded Message Board DB from file " + messageDbFile.getName() +
+ ", " + this.messageDB.size() + " entries" +
+ ", " + ppRamString(messageDbFile.length()/1024));
+ }
+
+
+ public void initWiki(int ramWiki) {
+ this.log.logConfig("Starting Wiki Board");
+ File wikiDbFile = new File(workPath, "wiki.db");
+ this.wikiDB = new wikiBoard(wikiDbFile,
+ new File(workPath, "wiki-bkp.db"), ramWiki);
+ this.log.logConfig("Loaded Wiki Board DB from file " + wikiDbFile.getName() +
+ ", " + this.wikiDB.size() + " entries" +
+ ", " + ppRamString(wikiDbFile.length()/1024));
+ }
public static plasmaSwitchboard getSwitchboard(){
diff --git a/source/migration.java b/source/migration.java
index 210a6feb4..93a739092 100644
--- a/source/migration.java
+++ b/source/migration.java
@@ -39,16 +39,63 @@
// the intact and unchanged copyright notice.
// Contributions and changes to the program code must be marked as such.
+import java.io.File;
+import java.io.IOException;
+
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.plasma.plasmaSwitchboard;
+import de.anomic.server.serverFileUtils;
+import de.anomic.server.logging.serverLog;
public class migration {
+ //SVN constants
+ public static final int USE_WORK_DIR=1389; //wiki & messages in DATA/WORK
public static void main(String[] args) {
}
public static void migrate(plasmaSwitchboard sb){
presetPasswords(sb);
migrateSwitchConfigSettings(sb);
+ migrateWorkFiles(sb);
+ }
+
+ public static void migrateWorkFiles(plasmaSwitchboard sb){
+ File file=new File(sb.getRootPath(), "DATA/SETTINGS/wiki.db");
+ File file2;
+ if (file.exists()) {
+ serverLog.logInfo("MIGRATION", "Migrating wiki.db to "+ sb.workPath);
+ sb.wikiDB.close();
+ file2 = new File(sb.workPath, "wiki.db");
+ try {
+ serverFileUtils.copy(file, file2);
+ file.delete();
+ } catch (IOException e) {
+ }
+
+ file = new File(sb.getRootPath(), "DATA/SETTINGS/wiki-bkp.db");
+ if (file.exists()) {
+ serverLog.logInfo("MIGRATION", "Migrating wiki-bkp.db to "+ sb.workPath);
+ file2 = new File(sb.workPath, "wiki-bkp.db");
+ try {
+ serverFileUtils.copy(file, file2);
+ file.delete();
+ } catch (IOException e) {}
+ }
+ sb.initWiki((int) sb.getConfigLong("ramCacheWiki", 1024) / 1024);
+ }
+
+
+ file=new File(sb.getRootPath(), "DATA/SETTINGS/message.db");
+ if(file.exists()){
+ serverLog.logInfo("MIGRATION", "Migrating message.db to "+ sb.workPath);
+ sb.messageDB.close();
+ file2=new File(sb.workPath, "message.db");
+ try {
+ serverFileUtils.copy(file, file2);
+ file.delete();
+ } catch (IOException e) {}
+ sb.initMessages((int) sb.getConfigLong("ramCacheMessage", 1024) / 1024);
+ }
}
public static void presetPasswords(plasmaSwitchboard sb) {