|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.ehcache.store.disk.DiskStorageFactory
public class DiskStorageFactory
A mock-up of a on-disk element proxy factory.
Nested Class Summary | |
---|---|
static class |
DiskStorageFactory.DiskMarker
DiskMarker instances point to the location of their associated serialized Element instance. |
static class |
DiskStorageFactory.DiskSubstitute
Abstract superclass for all disk substitutes. |
Field Summary | |
---|---|
protected DiskStore |
store
The store bound to this factory. |
Constructor Summary | |
---|---|
DiskStorageFactory(Ehcache cache,
RegisteredEventListeners cacheEventNotificationService)
Constructs an disk persistent factory for the given cache and disk path. |
Method Summary | ||
---|---|---|
void |
bind(DiskStore store)
Bind a store instance to this factory. |
|
boolean |
bufferFull()
Return true if the disk write queue is full. |
|
DiskStorageFactory.DiskSubstitute |
create(Element element)
Create a disk substitute for an element |
|
boolean |
created(Object object)
Returns true if this factory created the given object. |
|
protected void |
delete()
Deletes the data file for this factory. |
|
protected static void |
deleteFile(File f)
Attempt to delete the corresponding file and log an error on failure. |
|
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(DiskStorageFactory.DiskMarker marker)
Free the given marker to be used by a subsequent write. |
|
void |
free(Lock lock,
DiskStorageFactory.DiskSubstitute substitute)
Free any manually managed resources used by this DiskStorageFactory.DiskSubstitute . |
|
void |
free(Lock lock,
DiskStorageFactory.DiskSubstitute substitute,
boolean faultFailure)
Free any manually managed resources used by this DiskStorageFactory.DiskSubstitute . |
|
File |
getDataFile()
Return a reference to the data file backing this factory. |
|
File |
getIndexFile()
Return the index file for this store. |
|
int |
getOnDiskSize()
Return the number of on-disk elements |
|
long |
getOnDiskSizeInBytes()
Return this size in bytes of this factory |
|
protected void |
markUsed(DiskStorageFactory.DiskMarker marker)
Mark this on-disk marker as used (hooks into the file space allocation structure). |
|
protected Element |
read(DiskStorageFactory.DiskMarker marker)
Read the data at the given marker, and return the associated deserialized Element. |
|
Element |
retrieve(DiskStorageFactory.DiskSubstitute object)
Decodes the supplied DiskStorageFactory.DiskSubstitute . |
|
Element |
retrieve(DiskStorageFactory.DiskSubstitute object,
Segment segment)
Decodes the supplied DiskStorageFactory.DiskSubstitute , updating statistics. |
|
protected
|
schedule(Callable<U> call)
Schedule to given task on the disk writer executor service. |
|
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()
Unbinds a store instance from this factory |
|
protected 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 volatile DiskStore store
Constructor Detail |
---|
public DiskStorageFactory(Ehcache cache, RegisteredEventListeners cacheEventNotificationService)
cache
- cache that fronts this factoryMethod Detail |
---|
public long getOnDiskSizeInBytes()
public void bind(DiskStore store)
store
- store to bindpublic void free(Lock lock, DiskStorageFactory.DiskSubstitute substitute)
DiskStorageFactory.DiskSubstitute
.
lock
- the lock protecting the DiskSubstitutesubstitute
- DiskSubstitute being freed.public void free(Lock lock, DiskStorageFactory.DiskSubstitute substitute, boolean faultFailure)
DiskStorageFactory.DiskSubstitute
.
lock
- the lock protecting the DiskSubstitutesubstitute
- DiskSubstitute being freed.faultFailure
- true if this DiskSubstitute should be freed because of a disk failureprotected void markUsed(DiskStorageFactory.DiskMarker marker)
marker
- on-disk marker to mark as usedprotected void shrinkDataFile()
protected void shutdown() throws IOException
This shuts down the executor and then waits for its termination, before closing the data file.
IOException
- if an IO error occurredprotected void delete()
protected <U> Future<U> schedule(Callable<U> call)
U
- return type of the callablecall
- callable to call
protected Element read(DiskStorageFactory.DiskMarker marker) throws IOException, ClassNotFoundException
marker
- marker to read
IOException
- on read error
ClassNotFoundException
- on deserialization errorprotected DiskStorageFactory.DiskMarker write(Element element) throws IOException
element
- to write
IOException
- on write errorprotected void free(DiskStorageFactory.DiskMarker marker)
marker
- marker to be free'dpublic boolean bufferFull()
true
if the disk write queue is full.
true
if the disk write queue is full.public File getDataFile()
public void expireElements()
protected static void deleteFile(File f)
f
- the file to deletepublic DiskStorageFactory.DiskSubstitute create(Element element) throws IllegalArgumentException
element
- the element to create a disk substitute for
IllegalArgumentException
- if element cannot be substitutedpublic Element retrieve(DiskStorageFactory.DiskSubstitute object)
DiskStorageFactory.DiskSubstitute
.
object
- ElementSubstitute to decode
public Element retrieve(DiskStorageFactory.DiskSubstitute object, Segment segment)
DiskStorageFactory.DiskSubstitute
, updating statistics.
object
- 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 unbind()
public Future<Void> flush()
public int getOnDiskSize()
public void setOnDiskCapacity(int capacity)
capacity
- the maximum on-disk capacity for this factory.public File getIndexFile()
|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |