public class RecordManager extends Object
Modifier and Type | Field and Description |
---|---|
static boolean |
INTERNAL_BTREE
A flag used by internal btrees
|
protected static org.slf4j.Logger |
LOG
The LoggerFactory used by this class
|
protected static org.slf4j.Logger |
LOG_CHECK
A dedicated logger for the check
|
AtomicLong |
nbCreatedPages |
AtomicLong |
nbFreedPages
Some counters to track the number of free pages
|
AtomicLong |
nbReusedPages |
AtomicLong |
nbUpdateBTreeHeader |
AtomicLong |
nbUpdatePageIOs |
AtomicLong |
nbUpdateRMHeader |
static boolean |
NORMAL_BTREE
A flag used by internal btrees
|
Constructor and Description |
---|
RecordManager(String fileName)
Create a Record manager which will either create the underlying file
or load an existing one.
|
RecordManager(String fileName,
int pageSize)
Create a Record manager which will either create the underlying file
or load an existing one.
|
Modifier and Type | Method and Description |
---|---|
<K,V> BTree<K,V> |
addBTree(String name,
ElementSerializer<K> keySerializer,
ElementSerializer<V> valueSerializer,
boolean allowDuplicates)
Creates a BTree and automatically adds it to the list of managed btrees
|
void |
close()
Close the RecordManager and flush everything on disk
|
<K,V> org.apache.directory.mavibot.btree.Page<K,V> |
deserialize(BTree<K,V> btree,
long offset) |
void |
dump()
Dump the RecordManager file
|
static String |
dump(byte octet) |
<K,V> BTree<K,V> |
getManagedTree(String name)
Get one managed trees, knowing its name.
|
Set<String> |
getManagedTrees()
Get the managed trees.
|
int |
getNbManagedTrees()
Get the number of managed trees.
|
int |
getPageSize() |
boolean |
isKeepRevisions() |
<K,V> void |
manage(BTree<K,V> btree)
Manage a BTree.
|
<K,V> void |
manage(BTree<K,V> btree,
boolean internalTree)
works the same as @see #manage(BTree) except the given tree will not be linked to top level trees that will be
loaded initially if the internalTree flag is set to true
|
void |
setKeepRevisions(boolean keepRevisions) |
void |
setPageSize(int pageSize) |
String |
toString() |
void |
updateRecordManagerHeader()
Update the header, injecting the following data :
|
protected static final org.slf4j.Logger LOG
protected static final org.slf4j.Logger LOG_CHECK
public AtomicLong nbFreedPages
public AtomicLong nbCreatedPages
public AtomicLong nbReusedPages
public AtomicLong nbUpdateRMHeader
public AtomicLong nbUpdateBTreeHeader
public AtomicLong nbUpdatePageIOs
public static final boolean INTERNAL_BTREE
public static final boolean NORMAL_BTREE
public RecordManager(String fileName)
name
- The file name, or a folder namepublic RecordManager(String fileName, int pageSize)
name
- The file name, or a folder namepageSize
- the size of a page on diskpublic <K,V> org.apache.directory.mavibot.btree.Page<K,V> deserialize(BTree<K,V> btree, long offset) throws EndOfFileExceededException, IOException
public <K,V> void manage(BTree<K,V> btree) throws BTreeAlreadyManagedException, IOException
btree
- The new BTree to manage.BTreeAlreadyManagedException
IOException
public <K,V> void manage(BTree<K,V> btree, boolean internalTree) throws BTreeAlreadyManagedException, IOException
btree
- The new BTree to manage.internalTree
- flag indicating if this is an internal treeBTreeAlreadyManagedException
IOException
public void updateRecordManagerHeader() throws IOException
+---------------+ | PageSize | 4 bytes : The size of a physical page (default to 4096) +---------------+ | NbTree | 4 bytes : The number of managed BTrees (at least 1) +---------------+ | FirstFree | 8 bytes : The offset of the first free page +---------------+ | currentBoB | 1 byte : The current BoB in use +---------------+ | BoB offset[0] | 8 bytes : The offset of the first BoB +---------------+ | BoB offset[1] | 8 bytes : The offset of the second BoB +---------------+
IOException
public int getPageSize()
public void setPageSize(int pageSize)
public void close() throws IOException
IOException
public static String dump(byte octet)
public void dump() throws IOException
IOException
public int getNbManagedTrees()
public Set<String> getManagedTrees()
public <K,V> BTree<K,V> getManagedTree(String name)
public boolean isKeepRevisions()
public void setKeepRevisions(boolean keepRevisions)
keepRevisions
- the keepRevisions to setpublic <K,V> BTree<K,V> addBTree(String name, ElementSerializer<K> keySerializer, ElementSerializer<V> valueSerializer, boolean allowDuplicates) throws IOException, BTreeAlreadyManagedException
name
- the name of the BTreekeySerializer
- key serializervalueSerializer
- value serializerallowDuplicates
- flag for allowing duplicate keysIOException
BTreeAlreadyManagedException
public String toString()
toString
in class Object
Object.toString()
Copyright © 2012-2014 Apache Mavibot Project Parent. All Rights Reserved.