|
ehcache | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.ehcache.store.compound.factories.DiskOverflowStorageFactory
public class DiskOverflowStorageFactory
A factory that stores elements on disk in their serialized form.
| Field Summary | |
|---|---|
protected static String |
AUTO_DISK_PATH_DIRECTORY_PREFIX
Path stub used to create unique ehcache directories. |
protected CompoundStore |
store
The store bound to this factory. |
| Constructor Summary | |
|---|---|
DiskOverflowStorageFactory(Ehcache cache,
String diskPath)
Constructs an overflow factory for the given cache and disk path. |
|
| Method Summary | ||
|---|---|---|
void |
bind(CompoundStore store)
Bind a store instance to this factory. |
|
boolean |
bufferFull()
Return true if the disk write queue is full. |
|
ElementSubstitute |
create(Object key,
Element element)
Encodes an Element as a marker to on-disk location. |
|
boolean |
created(Object object)
Returns true if this factory created the given object. |
|
protected net.sf.ehcache.store.compound.factories.DiskStorageFactory.DiskMarker |
createMarker(long position,
int size,
Element element)
Create a disk marker representing the given element, and area on disk. |
|
protected void |
delete()
Deletes the data file for this factory. |
|
void |
expireElements()
Remove elements created by this factory if they have expired. |
|
protected void |
free(net.sf.ehcache.store.compound.factories.DiskStorageFactory.DiskMarker marker)
Free the given marker to be used by a subsequent write. |
|
void |
free(Lock lock,
ElementSubstitute substitute)
Free any manually managed resources used by this ElementSubstitute. |
|
File |
getDataFile()
Return a reference to the data file backing this factory. |
|
long |
getOnDiskSizeInBytes()
Return this size in bytes of this factory |
|
int |
getSize()
Return the count of elements created by this factory. |
|
protected void |
markUsed(net.sf.ehcache.store.compound.factories.DiskStorageFactory.DiskMarker marker)
Mark this on-disk marker as used (hooks into the file space allocation structure). |
|
void |
primary(CapacityLimitedInMemoryFactory memory)
Sets the primary factory that this factory should fault to, when elements are retrieved. |
|
protected Element |
read(net.sf.ehcache.store.compound.factories.DiskStorageFactory.DiskMarker marker)
Read the data at the given marker, and return the associated deserialized Element. |
|
Element |
retrieve(Object key,
ElementSubstitute proxy)
Decode an ElementProxy from an on disk marker (or a pending placeholder). |
|
protected
|
schedule(Callable<U> call)
Schedule to given task on the disk writer executor service. |
|
void |
setCapacity(int newCapacity)
Set the maximum on-disk capacity for this factory. |
|
protected void |
shrinkDataFile()
Shrink this store's data file down to a minimal size for its contents. |
|
protected void |
shutdown()
Shuts down this disk factory. |
|
void |
unbind(CompoundStore localStore)
Unbinds a store instance from this factory |
|
protected net.sf.ehcache.store.compound.factories.DiskStorageFactory.DiskMarker |
write(Element element)
Write the given element to disk, and return the associated marker. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final String AUTO_DISK_PATH_DIRECTORY_PREFIX
protected volatile CompoundStore store
| Constructor Detail |
|---|
public DiskOverflowStorageFactory(Ehcache cache,
String diskPath)
cache - cache that fronts this factorydiskPath - path to store data in| Method Detail |
|---|
public void primary(CapacityLimitedInMemoryFactory memory)
public ElementSubstitute create(Object key,
Element element)
throws IllegalArgumentException
Immediately substitutes a placeholder for the original element while the Element itself is asynchronously written to disk using the executor service.
key - key to which this element is mappedelement - Element to encode
IllegalArgumentException
public Element retrieve(Object key,
ElementSubstitute proxy)
This implementation makes no attempt to fault in the decoded Element in place of the proxy.
key - key to which this element is mappedproxy - ElementSubstitute to decode
public void free(Lock lock,
ElementSubstitute substitute)
ElementSubstitute.
free in interface ElementSubstituteFactory<ElementSubstitute>substitute - ElementSubstitute being free'd.public void unbind(CompoundStore localStore)
localStore - store to unbindpublic int getSize()
public void setCapacity(int newCapacity)
public boolean created(Object object)
true if this factory created the given object.
object - object to check
true if object created by this factorypublic long getOnDiskSizeInBytes()
public void bind(CompoundStore store)
store - store to bindprotected void markUsed(net.sf.ehcache.store.compound.factories.DiskStorageFactory.DiskMarker marker)
protected void shrinkDataFile()
protected void shutdown()
throws IOException
This shuts down the executor and then waits for its termination, before closing the data file.
IOExceptionprotected void delete()
protected <U> Future<U> schedule(Callable<U> call)
U - return type of the callablecall - callable to call
protected Element read(net.sf.ehcache.store.compound.factories.DiskStorageFactory.DiskMarker marker)
throws IOException,
ClassNotFoundException
marker - marker to read
IOException - on read error
ClassNotFoundException - on deserialization error
protected net.sf.ehcache.store.compound.factories.DiskStorageFactory.DiskMarker write(Element element)
throws IOException
element - to write
IOException - on write error
protected net.sf.ehcache.store.compound.factories.DiskStorageFactory.DiskMarker createMarker(long position,
int size,
Element element)
This method can be overridden by subclasses to use different marker types.
position - starting disk offsetsize - size of in disk areaelement - element to be written to area
protected void free(net.sf.ehcache.store.compound.factories.DiskStorageFactory.DiskMarker marker)
marker - marker to be free'dpublic boolean bufferFull()
true if the disk write queue is full.
public File getDataFile()
public void expireElements()
|
ehcache | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||