|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.planx.xmlstore.koala.storage.StorageManager
org.planx.xmlstore.koala.storage.SegmentManager
public class SegmentManager
A SegmentManager manages multiple segments with unique
SourceIds. In memory, each segment is represented by a
MemoryFileSystem and on disk all segments are persisted in a
single LocalFileSystem.
Note, that during sharing/garbage collection the SourceId
of a segment may change which can be interpreted as the old segment
disappearing and a new segment being created. Updating references to the
old segment is not the responsibility of the SegmentManager.
TODO: Implement caching of in-memory segments.
TODO: Consider stopping recursive save only if a node's cached locator is native
to this SegmentManager.
The main class for this package that manages saving, loading, sharing, and
garbage collection. The StorageManager operates on
LocalLocator which has two properties: First, they contain a
Locator which can be used with the SegmentManager
to save and load data. Second, they support behind-the-scenes updating
when the sharer has determined some references to be equivalent. To track
live LocalLocators a RootManager is used.
Thus, the StorageManager combines the capabilities of the
SegmentManager and the RootManager to provided
the information needed for the Sharer.
| Constructor Summary | |
|---|---|
SegmentManager(String name)
|
|
SegmentManager(String name,
StorageConfiguration config)
Creates a SegmentManager loading previously saved data from
disk using the specified name or creating a new manager
that will save data using the name. |
|
| Method Summary | |
|---|---|
void |
addRootListener(LocatorListener l)
|
LocalLocator |
asMemoryRoot(LocalLocator loc)
Returns a weak, in-memory root for a strong root. |
Segment |
cacheRetrieve(SourceId id)
|
void |
close()
Flushes and closes. |
boolean |
contains(SourceId id)
Returns true if and only if a live segment exists with the
specified SourceId. |
void |
delete(SourceId id)
Frees the on-disk space occupied by the data in the segment with the specified SourceId and invalidates any in-memory
copy of the segment. |
void |
flush()
|
void |
flushWrite()
Commits all data written to the single in-memory write segment to permanent storage and creates a new, empty in-memory write segment. |
RootManager |
getRootManager()
|
Sharer |
getSharer()
|
Segment |
getWriteSegment()
|
Set<SourceId> |
ids()
Returns a set view of all the segments' SourceIds. |
int |
inMemorySegments()
Returns the number of Segments currently in memory. |
SystemNode |
load(LocalLocator l)
Loads a node. |
SystemNode |
load(RelativeDualReference<Locator,LocalLocator> ref)
Attempts to load directly using the Locator of the
RelativeDualReference and if the segment's state has changed
instead loads using the relative reference. |
void |
persist(Segment segment)
Saves the segment to persistent storage adding the segment to the segments managed by this SegmentManager. |
int |
persistedSegments()
Returns the number of Segments currently on disk. |
void |
register(Segment s)
|
MultiMap<SourceId,SourceId> |
relations()
|
void |
release(LocalLocator loc)
Releases a root that was previously retained. |
void |
removeRootListener(LocatorListener l)
|
void |
retain(LocalLocator loc)
Requests that a root be kept permanently alive. |
Segment |
retrieve(SourceId id)
Returns an in-memory representation of the data contained in the segment with the specified SourceId. |
LocalLocator |
save(SystemNode node)
Saves the node to the single in-memory write segment unless the node already has a Locator associated with it. |
long |
size()
Returns the on-disk size of the associated LocalFileSystem. |
BijectiveMap<SourceId,SourceId> |
states()
Returns a mapping from segment ids to state ids. |
String |
toString()
|
| Methods inherited from class org.planx.xmlstore.koala.storage.StorageManager |
|---|
instance, instance |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public SegmentManager(String name)
throws IOException
IOException
public SegmentManager(String name,
StorageConfiguration config)
throws IOException
SegmentManager loading previously saved data from
disk using the specified name or creating a new manager
that will save data using the name.
IOException| Method Detail |
|---|
public SystemNode load(LocalLocator l)
throws IOException
load in class StorageManagerIOException
public SystemNode load(RelativeDualReference<Locator,LocalLocator> ref)
throws IOException
Locator of the
RelativeDualReference and if the segment's state has changed
instead loads using the relative reference.
load in interface Loader<RelativeDualReference<Locator,LocalLocator>,SystemNode>load in class StorageManagerIOException
public LocalLocator save(SystemNode node)
throws IOException
Locator associated with it.
TODO: Should perhaps only stop recursive save if the locator is native
to this SegmentManager and not another one.
save in class StorageManagerIOExceptionpublic void retain(LocalLocator loc)
StorageManager
retain in class StorageManager
public void release(LocalLocator loc)
throws UnknownReferenceException
release in class StorageManagerUnknownReferenceExceptionpublic LocalLocator asMemoryRoot(LocalLocator loc)
StorageManager
asMemoryRoot in class StorageManagerpublic void addRootListener(LocatorListener l)
addRootListener in class StorageManagerpublic void removeRootListener(LocatorListener l)
removeRootListener in class StorageManagerpublic RootManager getRootManager()
public Sharer getSharer()
public void flushWrite()
throws IOException
IOException
public Segment getWriteSegment()
throws IOException
IOException
public void register(Segment s)
throws IOException
IOException
public void delete(SourceId id)
throws IOException
SourceId and invalidates any in-memory
copy of the segment.
IOException
public void persist(Segment segment)
throws IOException
SegmentManager.
IOException
public Segment retrieve(SourceId id)
throws IOException
SourceId.
IOException
public Segment cacheRetrieve(SourceId id)
throws IOException
IOExceptionpublic boolean contains(SourceId id)
true if and only if a live segment exists with the
specified SourceId.
public Set<SourceId> ids()
SourceIds.
public MultiMap<SourceId,SourceId> relations()
public BijectiveMap<SourceId,SourceId> states()
public void flush()
throws IOException
flush in class StorageManagerIOException
public void close()
throws IOException
close in class StorageManagerIOException
public long size()
throws IOException
LocalFileSystem.
size in class StorageManagerIOExceptionpublic int inMemorySegments()
Segments currently in memory.
public int persistedSegments()
Segments currently on disk.
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||