|
Mobios v0.91 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object mobios.mckoi.store.AbstractStore
public abstract class AbstractStore
Provides an abstract implementation of Store. This implements a bin based best-fit recycling algorithm. The store manages a structure that points to bins of freed space of specific sizes. When an allocation is requested the structure is searched for the first bin that contains an area that best fits the size requested.
Provided the derived class supports safe atomic IO operations, this store is designed for robustness to the level that at no point is the store left in a unworkable (corrupt) state.
Method Summary | |
---|---|
long |
alloc(long size)
Allocates a block of memory out of the store of the specified size, and returns a pointer to the block. |
void |
close()
Closes the store. |
ArrayList |
findAllocatedAreasNotIn(ArrayList list)
Scans the area list, and any areas that aren't deleted and aren't found in the given ArrayList are returned as leaked areas. |
void |
free(long pointer)
Frees a block of memory from the store that was previously allocated via 'alloc'. |
List |
getAllAreas()
Returns a List of Long objects that contain a complete list of all areas in the store. |
Area |
getArea(long pointer)
Returns an Area object that can be used to manipulate an area allocated from the store. |
Area |
getFixedArea()
Returns an Area object that represents the 64 byte fixed area as can be changed by the 'getFixedArea' and 'setFixedArea' methods. |
void |
getFixedArea(byte[] buf,
int off,
int len)
|
InputStream |
getInputStream(long pointer)
Returns an InputStream for reading from the area of the store allocated via the 'alloc' method. |
OutputStream |
getOutputStream(long pointer)
Returns an OutputStream for writing to the area of the store allocated via the 'alloc' method. |
Iterator |
iterator()
|
boolean |
lastCloseClean()
Returns true if the store was closed cleanly. |
boolean |
open()
Opens the data store. |
void |
openScanAndFix(UserTerminal terminal)
Opens/scans the store looking for any errors with the layout. |
void |
setFixedArea(byte[] buf,
int off,
int len)
|
void |
statsScan(HashMap properties)
Performs an extensive lookup on all the tables in this store and sets a number of properties in the given HashMap (property name(String) -> property description(Object)). |
long |
totalAllocatedSinceStart()
Returns the total allocated space since the file was openned. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface mobios.mckoi.store.Store |
---|
flush, synch |
Method Detail |
---|
public boolean open() throws IOException
IOException
public void close() throws IOException
IOException
public void openScanAndFix(UserTerminal terminal) throws IOException
IOException
public void statsScan(HashMap properties) throws IOException
Assume the store is open.
IOException
public List getAllAreas() throws IOException
getAllAreas
in interface Store
IOException
public ArrayList findAllocatedAreasNotIn(ArrayList list) throws IOException
IOException
public long totalAllocatedSinceStart()
public long alloc(long size) throws IOException
Store
alloc
in interface Store
size
- the amount of memory to allocate.
IOException
- is the allocation can not happen.public void free(long pointer) throws IOException
Store
free
in interface Store
pointer
- a 64-bit pointer to the memory to free.
IOException
public void setFixedArea(byte[] buf, int off, int len) throws IOException
IOException
public void getFixedArea(byte[] buf, int off, int len) throws IOException
IOException
public Area getFixedArea() throws IOException
Store
getFixedArea
in interface Store
IOException
public InputStream getInputStream(long pointer) throws IOException
Store
The returned stream does not perform buffering. For efficiency, it is a good idea to wrap the returned steam with a BufferedInputStream.
getInputStream
in interface Store
pointer
- a 64-bit pointer to the memory to read.
IOException
public OutputStream getOutputStream(long pointer) throws IOException
Store
The returned stream does not perform buffering. For efficiency, it is a good idea to wrap the returned steam with a BufferedOutputStream.
getOutputStream
in interface Store
pointer
- a 64-bit pointer to the memory to write.
IOException
public Area getArea(long pointer) throws IOException
Store
getArea
in interface Store
pointer
- a 64-bit pointer to the area (allocated via 'alloc').
IOException
public boolean lastCloseClean()
Store
lastCloseClean
in interface Store
public Iterator iterator()
|
Mobios v0.91 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |