[freenet-cvs] r16883 - trunk/freenet/src/freenet/store
toad at freenetproject.org
toad at freenetproject.org
Fri Jan 4 15:32:40 UTC 2008
Author: toad
Date: 2008-01-04 15:32:40 +0000 (Fri, 04 Jan 2008)
New Revision: 16883
Modified:
trunk/freenet/src/freenet/store/BerkeleyDBFreenetStore.java
Log:
keyLength
Modified: trunk/freenet/src/freenet/store/BerkeleyDBFreenetStore.java
===================================================================
--- trunk/freenet/src/freenet/store/BerkeleyDBFreenetStore.java 2008-01-04 15:26:37 UTC (rev 16882)
+++ trunk/freenet/src/freenet/store/BerkeleyDBFreenetStore.java 2008-01-04 15:32:40 UTC (rev 16883)
@@ -79,6 +79,7 @@
private long hits = 0;
private long misses = 0;
private long writes = 0;
+ private final int keyLength;
private final Database keysDB;
private final SecondaryDatabase accessTimeDB;
private final SecondaryDatabase blockNumDB;
@@ -131,10 +132,17 @@
String newStoreFileName = typeName(type) + suffix + '.' + (isStore ? "store" : "cache");
File newStoreFile = new File(baseStoreDir, newStoreFileName);
File lruFile = new File(baseStoreDir, newStoreFileName+".lru");
- File keysFile = null;
- if(type == TYPE_SSK)
+
+ int keyLength;
+ File keysFile;
+ if(type == TYPE_SSK) {
+ keyLength = 32;
keysFile = new File(baseStoreDir, newStoreFileName+".keys");
-
+ } else {
+ keyLength = 0;
+ keysFile = null;
+ }
+
String newDBPrefix = typeName(type)+ '-' +(isStore ? "store" : "cache")+ '-';
File newFixSecondaryFile = new File(baseStoreDir, "recreate_secondary_db-"+newStoreFileName);
@@ -149,7 +157,7 @@
// Don't need to create a new Environment, since we can use the old one.
tmp = openStore(storeEnvironment, baseStoreDir, newDBPrefix, newStoreFile, lruFile, keysFile, newFixSecondaryFile, maxStoreKeys,
- blockSize, headerSize, throwOnTooFewKeys, false, lastVersion, type, false, storeShutdownHook, tryDbLoad, reconstructFile);
+ blockSize, headerSize, throwOnTooFewKeys, false, lastVersion, type, false, storeShutdownHook, tryDbLoad, reconstructFile, keyLength);
} else {
@@ -158,7 +166,7 @@
tmp = openStore(storeEnvironment, baseStoreDir, newDBPrefix, newStoreFile, lruFile, keysFile, newFixSecondaryFile,
maxStoreKeys, blockSize, headerSize, throwOnTooFewKeys, false, lastVersion, type,
- false, storeShutdownHook, tryDbLoad, reconstructFile);
+ false, storeShutdownHook, tryDbLoad, reconstructFile, keyLength);
}
@@ -168,7 +176,7 @@
private static BerkeleyDBFreenetStore openStore(Environment storeEnvironment, File baseDir, String newDBPrefix, File newStoreFile,
File lruFile, File keysFile, File newFixSecondaryFile, long maxStoreKeys, int blockSize, int headerSize, boolean throwOnTooFewKeys,
boolean noCheck, int lastVersion, short type, boolean wipe, SemiOrderedShutdownHook storeShutdownHook,
- boolean tryDbLoad, File reconstructFile) throws DatabaseException, IOException {
+ boolean tryDbLoad, File reconstructFile, int keyLength) throws DatabaseException, IOException {
if(tryDbLoad) {
String dbName = newDBPrefix+"CHK";
@@ -199,7 +207,7 @@
// First try just opening it.
return new BerkeleyDBFreenetStore(type, storeEnvironment, newDBPrefix, newStoreFile, lruFile, keysFile, newFixSecondaryFile,
maxStoreKeys, blockSize, headerSize, throwOnTooFewKeys, noCheck, wipe, storeShutdownHook,
- reconstructFile);
+ reconstructFile, keyLength);
} catch (DatabaseException e) {
// Try a reconstruct
@@ -213,7 +221,7 @@
newStoreFile.delete();
return new BerkeleyDBFreenetStore(type, storeEnvironment, newDBPrefix, newStoreFile, lruFile, keysFile, newFixSecondaryFile,
maxStoreKeys, blockSize, headerSize, throwOnTooFewKeys, noCheck, wipe, storeShutdownHook,
- reconstructFile);
+ reconstructFile, keyLength);
}
System.err.println("Attempting to reconstruct index...");
@@ -222,7 +230,7 @@
// Reconstruct
return new BerkeleyDBFreenetStore(storeEnvironment, newDBPrefix, newStoreFile, lruFile, keysFile, newFixSecondaryFile,
- maxStoreKeys, blockSize, headerSize, type, noCheck, storeShutdownHook, reconstructFile);
+ maxStoreKeys, blockSize, headerSize, type, noCheck, storeShutdownHook, reconstructFile, keyLength);
}
}
@@ -246,9 +254,10 @@
* @throws DatabaseException
* @throws FileNotFoundException if the dir does not exist and could not be created
*/
- private BerkeleyDBFreenetStore(short type, Environment env, String prefix, File storeFile, File lruFile, File keysFile, File fixSecondaryFile, long maxChkBlocks, int blockSize, int headerSize, boolean throwOnTooFewKeys, boolean noCheck, boolean wipe, SemiOrderedShutdownHook storeShutdownHook, File reconstructFile) throws IOException, DatabaseException {
+ private BerkeleyDBFreenetStore(short type, Environment env, String prefix, File storeFile, File lruFile, File keysFile, File fixSecondaryFile, long maxChkBlocks, int blockSize, int headerSize, boolean throwOnTooFewKeys, boolean noCheck, boolean wipe, SemiOrderedShutdownHook storeShutdownHook, File reconstructFile, int keyLength) throws IOException, DatabaseException {
logMINOR = Logger.shouldLog(Logger.MINOR, this);
this.storeType = type;
+ this.keyLength = keyLength;
this.dataBlockSize = blockSize;
this.headerBlockSize = headerSize;
this.freeBlocks = new SortedLongSet();
@@ -977,9 +986,10 @@
* @throws IOException If the store cannot be opened because of a filesystem problem.
* @throws FileNotFoundException if the dir does not exist and could not be created
*/
- private BerkeleyDBFreenetStore(Environment env, String prefix, File storeFile, File lruFile, File keysFile, File fixSecondaryFile, long maxChkBlocks, int blockSize, int headerSize, short type, boolean noCheck, SemiOrderedShutdownHook storeShutdownHook, File reconstructFile) throws DatabaseException, IOException {
+ private BerkeleyDBFreenetStore(Environment env, String prefix, File storeFile, File lruFile, File keysFile, File fixSecondaryFile, long maxChkBlocks, int blockSize, int headerSize, short type, boolean noCheck, SemiOrderedShutdownHook storeShutdownHook, File reconstructFile, int keyLength) throws DatabaseException, IOException {
logMINOR = Logger.shouldLog(Logger.MINOR, this);
this.storeType = type;
+ this.keyLength = keyLength;
this.dataBlockSize = blockSize;
this.headerBlockSize = headerSize;
this.freeBlocks = new SortedLongSet();
More information about the cvs
mailing list