Migration to WORK

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1389 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
allo 19 years ago
parent 1e5feedf0e
commit 4d33020f56

@ -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");
@ -579,6 +571,27 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
}
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(){
return sb;
}

@ -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) {

Loading…
Cancel
Save