public class SaltedHashFreenetStore<T extends StorableBlock> extends java.lang.Object implements FreenetStore<T>
Modifier and Type | Class and Description |
---|---|
class |
SaltedHashFreenetStore.ShutdownDB |
FreenetStore.StoreType
Modifier and Type | Field and Description |
---|---|
static boolean |
NO_CLEANER_SLEEP |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
close(boolean abort) |
static <T extends StorableBlock> |
construct(java.io.File baseDir,
java.lang.String name,
StoreCallback<T> callback,
java.util.Random random,
long maxKeys,
boolean useSlotFilter,
SemiOrderedShutdownHook shutdownHook,
boolean preallocate,
boolean resizeOnStart,
Ticker exec,
byte[] masterKey) |
void |
destruct() |
T |
fetch(byte[] routingKey,
byte[] fullKey,
boolean dontPromote,
boolean canReadClientCache,
boolean canReadSlashdotCache,
boolean ignoreOldBlocks,
BlockMetadata meta)
Retrieve a block.
|
void |
forceValidEmpty()
Testing only! Force all entries that say empty/unknown on the slot
filter to empty/certain.
|
long |
getBloomFalsePositive() |
long |
getMaxKeys() |
StoreAccessStats |
getSessionAccessStats() |
StoreAccessStats |
getTotalAccessStats() |
FreenetStore<T> |
getUnderlyingStore() |
long |
hits() |
long |
keyCount() |
long |
misses() |
boolean |
probablyInStore(byte[] routingKey)
Check if a routing key probably
|
void |
put(T block,
byte[] data,
byte[] header,
boolean overwrite,
boolean isOldBlock)
Store a block.
|
boolean |
put(T block,
byte[] data,
byte[] header,
boolean overwrite,
boolean isOldBlock,
boolean wrongStore) |
void |
setAltStore(SaltedHashFreenetStore<T> store) |
void |
setMaxKeys(long newStoreSize,
boolean shrinkNow)
Change the store size.
|
void |
setPreallocate(boolean preallocate)
Set preallocate storage space
|
void |
setUserAlertManager(UserAlertManager userAlertManager) |
boolean |
slotCacheLikelyMatch(int value,
byte[] digestedRoutingKey) |
boolean |
start(Ticker ticker,
boolean longStart)
If start can be completed quickly, or longStart is true, then do it.
|
java.lang.String |
toString() |
long |
writes() |
public void setAltStore(SaltedHashFreenetStore<T> store)
public static <T extends StorableBlock> SaltedHashFreenetStore<T> construct(java.io.File baseDir, java.lang.String name, StoreCallback<T> callback, java.util.Random random, long maxKeys, boolean useSlotFilter, SemiOrderedShutdownHook shutdownHook, boolean preallocate, boolean resizeOnStart, Ticker exec, byte[] masterKey) throws java.io.IOException
java.io.IOException
public boolean start(Ticker ticker, boolean longStart) throws java.io.IOException
start
in interface FreenetStore<T extends StorableBlock>
java.io.IOException
public T fetch(byte[] routingKey, byte[] fullKey, boolean dontPromote, boolean canReadClientCache, boolean canReadSlashdotCache, boolean ignoreOldBlocks, BlockMetadata meta) throws java.io.IOException
FreenetStore
fetch
in interface FreenetStore<T extends StorableBlock>
routingKey
- The routing key i.e. the database key under which the block is stored.dontPromote
- If true, don't promote the block to the top of the LRU.canReadClientCache
- Whether we can read the client-cache, for purposes of finding
the pubkey for an SSK.java.io.IOException
- If a disk I/O error occurs.public void put(T block, byte[] data, byte[] header, boolean overwrite, boolean isOldBlock) throws java.io.IOException, KeyCollisionException
FreenetStore
put
in interface FreenetStore<T extends StorableBlock>
overwrite
- If true, overwrite old content rather than throwing a
KeyCollisionException
.isOldBlock
- If true, the block really shouldn't be in the datastore, but we are storing
it anyway; it should not have the new block flag, so it should be excluded
from Bloom filter sharing.KeyCollisionException
- If the key already exists and callback.collisionPossible()
is
true
.java.io.IOException
public boolean put(T block, byte[] data, byte[] header, boolean overwrite, boolean isOldBlock, boolean wrongStore) throws java.io.IOException, KeyCollisionException
java.io.IOException
KeyCollisionException
public boolean slotCacheLikelyMatch(int value, byte[] digestedRoutingKey)
public void setPreallocate(boolean preallocate)
preallocate
- public void setUserAlertManager(UserAlertManager userAlertManager)
setUserAlertManager
in interface FreenetStore<T extends StorableBlock>
public void setMaxKeys(long newStoreSize, boolean shrinkNow) throws java.io.IOException
FreenetStore
setMaxKeys
in interface FreenetStore<T extends StorableBlock>
newStoreSize
- The maximum number of keys to be cached.shrinkNow
- If false, don't shrink the store immediately.java.io.IOException
public void close()
close
in interface FreenetStore<T extends StorableBlock>
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
public void close(boolean abort)
public long hits()
hits
in interface FreenetStore<T extends StorableBlock>
public long misses()
misses
in interface FreenetStore<T extends StorableBlock>
public long writes()
writes
in interface FreenetStore<T extends StorableBlock>
public long keyCount()
keyCount
in interface FreenetStore<T extends StorableBlock>
public long getMaxKeys()
getMaxKeys
in interface FreenetStore<T extends StorableBlock>
public long getBloomFalsePositive()
getBloomFalsePositive
in interface FreenetStore<T extends StorableBlock>
public boolean probablyInStore(byte[] routingKey)
FreenetStore
probablyInStore
in interface FreenetStore<T extends StorableBlock>
false
only if the key does not exist in store.public void destruct()
public java.lang.String toString()
toString
in class java.lang.Object
public StoreAccessStats getSessionAccessStats()
getSessionAccessStats
in interface FreenetStore<T extends StorableBlock>
public StoreAccessStats getTotalAccessStats()
getTotalAccessStats
in interface FreenetStore<T extends StorableBlock>
public void forceValidEmpty()
public FreenetStore<T> getUnderlyingStore()
getUnderlyingStore
in interface FreenetStore<T extends StorableBlock>