|
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.DiskPersistentStorageFactory
public class DiskPersistentStorageFactory
This will be the disk-persistent element substitute factory
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 | |
---|---|
DiskPersistentStorageFactory(Ehcache cache,
String diskPath)
Constructs an disk persistent 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)
Creates a substitute for the supplied Element |
|
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. |
|
Future<Void> |
flush()
Schedule a flush (index write) for this factory. |
|
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 exclusion,
ElementSubstitute object)
Free any manually managed resources used by this ElementSubstitute . |
|
File |
getDataFile()
Return a reference to the data file backing this factory. |
|
File |
getIndexFile()
Return the index file for this store. |
|
Policy |
getInMemoryEvictionPolicy()
Return the in-memory eviction policy used by this store. |
|
int |
getInMemorySize()
Return the number of in-memory elements |
|
long |
getInMemorySizeInBytes()
Return the approximate serialized size of the in-memory elements |
|
int |
getOnDiskSize()
Return the number of on-disk elements |
|
long |
getOnDiskSizeInBytes()
Return this size in bytes of this factory |
|
boolean |
isInMemory(Object object)
Return true if the given element is in memory |
|
boolean |
isOnDisk(Object object)
Return true if the given element is on disk |
|
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). |
|
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 object)
Decodes the supplied ElementSubstitute . |
|
protected
|
schedule(Callable<U> call)
Schedule to given task on the disk writer executor service. |
|
void |
setInMemoryCapacity(int capacity)
Set the maximum in-memory capacity for this factory. |
|
void |
setInMemoryEvictionPolicy(Policy policy)
Set the in-memory eviction policy to be used by this store. |
|
void |
setOnDiskCapacity(int capacity)
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 store)
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 DiskPersistentStorageFactory(Ehcache cache, String diskPath)
cache
- cache that fronts this factorydiskPath
- path to store data inMethod Detail |
---|
public ElementSubstitute create(Object key, Element element) throws IllegalArgumentException
Element
In the case that this element is no longer mapped to a key - if for example the element is being decoded following a removal - then the supplied key will be null.
key
- key to which this element is mappedelement
- Element to encode
IllegalArgumentException
- if element cannot be substitutedpublic void free(Lock exclusion, ElementSubstitute object)
ElementSubstitute
.
free
in interface ElementSubstituteFactory<ElementSubstitute>
object
- ElementSubstitute being free'd.public Element retrieve(Object key, ElementSubstitute object)
ElementSubstitute
.
key
- key to which this element is mappedobject
- ElementSubstitute to decode
public boolean created(Object object)
true
if this factory created the given object.
object
- object to check
true
if object created by this factorypublic void bind(CompoundStore store)
store
- store to bindpublic void unbind(CompoundStore store)
store
- store to unbindpublic Future<Void> flush()
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
public boolean isInMemory(Object object)
true
if the given element is in memory
public boolean isOnDisk(Object object)
true
if the given element is on disk
public int getInMemorySize()
public long getInMemorySizeInBytes()
public int getOnDiskSize()
public void setInMemoryCapacity(int capacity)
public void setOnDiskCapacity(int capacity)
public void setInMemoryEvictionPolicy(Policy policy)
public Policy getInMemoryEvictionPolicy()
public File getIndexFile()
public long getOnDiskSizeInBytes()
protected 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.
IOException
protected 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 errorprotected net.sf.ehcache.store.compound.factories.DiskStorageFactory.DiskMarker write(Element element) throws IOException
element
- to write
IOException
- on write errorprotected 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 |