|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mycore.datamodel.ifs2.MCRStore
public abstract class MCRStore
Stores metadata files or file collections containing files and directories in a persistent store implemented using a local filesystem. For better filesystem performance, the store can build slot subdirectories (containing other subdirectories and so on) so that not all objects are stored in the same filesystem directory. Directories containing a very large number of files typically show bad performance. The slot layout of the store defines the usage of subdirectories within the base directory. A layout of "8" would mean no subdirectories will be used, the maximum ID size is 8 digits, and therefore up to 99999999 objects can be stored all in the same base directory. A layout of "2-2-4" would mean data is stored using two levels of subdirectories, where the first subdirectory contains up to 100 (00-99) subdirectories, the second subdirectory level below contains up to 100 subdirectories, too, and below the data is stored, with up to 10000 data objects in the subdirectory. Using this slot layout, the data of ID 10485 would be stored in the file object "/00/01/00010485", for example. Using layout "4-2-2", data would be stored in "/0001/04/00010485", and so on. The slot file name itself may optionally have a prefix and suffix. With prefix "derivate-", the slot name would be "derivate-00010485". With prefix "DocPortal_document_" and suffix ".xml", the slot name would be "DocPortal_document_00010485.xml" for example. MCR.IFS2.Store.ID.Class=org.mycore.datamodel.ifs2.MCRFileStore MCR.IFS2.Store.ID.BaseDir=/foo/bar MCR.IFS2.Store.ID.SlotLayout=4-2-2
| Field Summary | |
|---|---|
static boolean |
ASCENDING
Indicates ascending order when listing IDs |
static boolean |
DESCENDING
Indicates descending order when listing IDs |
protected File |
dir
The base directory containing the stored data |
protected String |
id
The ID of the store |
protected int |
idLength
The maximum length of IDs |
protected int |
lastID
The last ID assigned by this store. |
protected int |
offset
Offset to add to the maximum ID found in the store to build the new ID. |
protected String |
prefix
The prefix of slot names |
protected int[] |
slotLength
The slot subdirectory layout, which is the number of digits used at each subdirectory level to build the filename. |
protected static HashMap<String,MCRStore> |
stores
Map of defined stores, where store ID is the map key. |
protected String |
suffix
The suffix of slot names |
| Constructor Summary | |
|---|---|
MCRStore()
|
|
| Method Summary | |
|---|---|
(package private) void |
delete(org.apache.commons.vfs.FileObject fo)
Deletes the data stored in the given file object from the store |
void |
delete(int id)
Deletes the data stored under the given ID from the store |
boolean |
exists(int id)
Returns true if data for the given ID is existing in the store. |
(package private) String |
getBaseDir()
Returns the absolute path of the local base directory |
int |
getHighestStoredID()
|
String |
getID()
Returns the ID of this store |
int |
getNextFreeID()
Returns the next free ID that can be used to store data. |
(package private) org.apache.commons.vfs.FileObject |
getSlot(int ID)
Returns the slot file object used to store data for the given ID. |
(package private) String |
getSlotPath(int ID)
Returns the relative path used to store data for the given ID within the store base directory |
(package private) String[] |
getSlotPaths(int ID)
Returns the paths of all subdirectories and the slot itself used to store data for the given ID relative to the store base directory |
protected static MCRStore |
getStore(String ID)
Returns the store with the given ID |
protected void |
init(String id)
Initializes a new store instance |
Iterator<Integer> |
listIDs(boolean order)
Lists all IDs currently used in the store, in ascending or descending order |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static HashMap<String,MCRStore> stores
protected String id
protected File dir
protected int idLength
protected int[] slotLength
protected String prefix
protected String suffix
protected int offset
protected int lastID
public static final boolean ASCENDING
public static final boolean DESCENDING
| Constructor Detail |
|---|
public MCRStore()
| Method Detail |
|---|
protected static MCRStore getStore(String ID)
ID - the ID of the storeprotected void init(String id)
public String getID()
String getBaseDir()
org.apache.commons.vfs.FileObject getSlot(int ID)
throws Exception
ID - the ID of the data
ExceptionString getSlotPath(int ID)
ID - the ID of the data
String[] getSlotPaths(int ID)
ID - the ID of the data
public boolean exists(int id)
throws Exception
id - the ID of the data
Exceptionpublic int getNextFreeID()
public int getHighestStoredID()
public Iterator<Integer> listIDs(boolean order)
order - the order in which IDs should be returned.
ASCENDING,
DESCENDING
public void delete(int id)
throws Exception
id - the ID of the document to be deleted
Exception
void delete(org.apache.commons.vfs.FileObject fo)
throws Exception
fo - the file object to be deleted
Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||