|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.pg2k.svrCore.datasource.ExhibitDataSimpleCache.MetaData
private static final class ExhibitDataSimpleCache.MetaData
Cache meta-data class. Holds information about what exhibit data is cached on disc.
Is serialisable to be able to persist to disc and allow for a fast start-up.
Can be marked read-only to hold the cache in its current state.
This object is completely thread-safe and holds its instance lock to synchronise activity.
The names of all members affecting the state of cached exhibit data and meta-data start with `exhibit'.
All activity that actually affects disc operations must be passed the rwl and it will be held while disc I/O takes place, and most of these operations will throw and IOException. (Note that if the ExhibitDataSimpleCache instance lock must be held as well then it and the rwl must be grabbed in the appropriate order before one of these routines is called.)
| Field Summary | |
|---|---|
private java.util.Map<java.lang.Object,java.lang.Long> |
_beingExtended
Thread-safe Map of which exhibits we are currently extending and when we started extending. |
private Tuple.Triple<java.io.File,java.lang.Long,java.lang.Long> |
_cFSBHWM_cache
Cache of estimated usable free space in the underlying cache filesystem; initially null. |
private int |
_fullyCachedCount
Cache of estimate of full-cached exhibits; non-negative. |
private java.util.Map<Name.ExhibitFull,ExhibitDataSimpleCache.CachedFile> |
cachedExhibits
Set of cached exhibits, from full exhibit name to CachedFile entry; never null after construction/deserialisation. |
private java.util.SortedSet<ExhibitDataSimpleCache.CachedFile> |
exhibitsLRU
LRU ordered set of the CachedFile values in cachedExhibits; never null after construction/deserialisation. |
private static int |
MAX_CONC_EXT_WAIT_TIME_MS
Approximate maximum time to wait for another thread to extend an exhibit cache entry (ms); strictly positive. |
private static int |
MAX_FS_USABLE_SPACE_CACHE_MS
Maximum time in ms that we may retain a cached 'usable filespace' estimate; strictly positive. |
private static int |
MIN_FS_PERCENT_FREE
Minimum percentage free in cache filesystem for us to expand the cache; non-negative in range ]100,0]. |
private boolean |
needsSave
If true, we need a save to disc (ie our state has changed). |
private static boolean |
NEVER_REQUEST_UPSTREAM_CACHEING
If true, we NEVER ask upstream to cache for us. |
private boolean |
readWrite
If true, this cache meta-data is read/write. |
private static long |
serialVersionUID
My serial ID. |
private long |
totalBytes
Estimated total bytes of disc used by cached entries. |
private long |
totalBytesHighWaterMark
The highest value of totalBytes, ie the cache actual high-water mark; never negative. |
private static boolean |
TRY_TO_RETAIN_TN_IN_PURGE
If true then try to retain metadata and thumbnails of exhibits we purge. |
private static boolean |
USE_EXTANT_DISC_ENTRY_ON_CREATE
If true, when creating cache entry if data found on disc use it rather than refuse to build meta-data entry. |
| Constructor Summary | |
|---|---|
ExhibitDataSimpleCache.MetaData()
Build an empty, read-only set of meta-data. |
|
ExhibitDataSimpleCache.MetaData(AllExhibitProperties aepCurrent,
java.io.File cacheDir,
SimpleLoggerIF logger)
Build a new meta-data set by examining the given cache directory. |
|
| Method Summary | |
|---|---|
private boolean |
_exhibitRemoveLRUCacheEntry(java.util.concurrent.locks.ReentrantReadWriteLock rwl,
java.io.File cacheDir,
Name.ExhibitFull dontRemoveName,
boolean justData,
SimpleLoggerIF logger,
StatsLogger.StatsConfig statsIDSCGEN)
Remove the least-recently-used exhibit cache item, if any. |
private int |
_readRawDataStartFromCache(java.util.concurrent.locks.ReentrantReadWriteLock rwl,
Name.ExhibitFull name,
int dataStart,
java.io.File cacheDir,
java.nio.ByteBuffer buf,
SimpleLoggerIF logger,
StatsLogger.StatsConfig statsIDSCGEN)
Fill as much as possible of the read request from disc cache, returning the number of bytes read; non-negative. |
private void |
_recomputeDerivedValues()
This private routine updates all (transient) data derived from the primary cachedExhibits map. |
private void |
_remove(java.util.concurrent.locks.ReentrantReadWriteLock rwl,
Name.ExhibitFull name)
Remove cached-file details, adjusting cache data in situ; does nothing if not present. |
private void |
_setTotalBytes(long newTB)
Set estimated total bytes of disc used by cached entries; never negative. |
private void |
_update(java.util.concurrent.locks.ReentrantReadWriteLock rwl,
ExhibitDataSimpleCache.CachedFile newCf,
SimpleLoggerIF logger)
Update or add new cached-file details, adjusting cache data in situ. |
(package private) boolean |
canPrecache(java.io.File cacheDir)
If true, some precaching may be possible, going by our generally-least-strict limit. |
(package private) boolean |
canPrecacheExhibitData(java.io.File cacheDir)
If true, we can pre-cache data blocks for (new or existing) exhibits. |
(package private) boolean |
canPrecacheThumbnails(java.io.File cacheDir)
If true, we can pre-cache thumbnails for (existing) exhibits. |
(package private) long |
computeFreeSpaceBelowHighWaterMark(java.io.File cacheDir)
Compute available free space in cache (bytes); zero or negative if none. |
(package private) long |
computeFreeSpaceBelowLowWaterMark(java.io.File cacheDir)
Compute current definite free-space in cache. |
(package private) long |
computeTargetHighWaterMark()
Computes the target high-water mark (target maximum cache size); strictly positive. |
(package private) boolean |
exhibitCreateNewCacheEntry(java.util.concurrent.locks.ReentrantReadWriteLock rwl,
java.io.File cacheDir,
ExhibitStaticAttr esa,
SimpleLoggerIF logger,
StatsLogger.StatsConfig statsIDSCGEN)
Create a new exhibit entry. |
(package private) ExhibitDataSimpleCache.CachedFile |
exhibitGetInfo(Name.ExhibitFull name)
Get cached-file details for a given exhibit; null if exhibit not cached. |
(package private) ExhibitThumbnails |
exhibitGetThumbnails(java.util.concurrent.locks.ReentrantReadWriteLock rwl,
java.io.File cacheDir,
Name.ExhibitFull name,
SimpleLoggerIF logger)
Get the cached thumbnails for an exhibit, or null if none cached. |
(package private) boolean |
exhibitIsFullyLoaded(ExhibitStaticAttr esa)
Check if the exhibit is fully loaded. |
(package private) ExhibitDataSimpleCache.CachedFile |
exhibitMarkAsAccessed(java.util.concurrent.locks.ReentrantReadWriteLock rwl,
Name.ExhibitFull name,
SimpleLoggerIF logger,
java.io.File cacheDir)
Mark exhibit as accessed (`touch' it) and returns the possibly-modified CachedFile record. |
(package private) void |
exhibitRead(java.util.concurrent.locks.ReentrantReadWriteLock rwl,
java.lang.String fetchFromPeer,
java.io.File cacheDir,
Name.ExhibitFull name,
SimpleExhibitPipelineIF upstream,
AllExhibitImmutableData aeid,
GenProps gp,
int dataStart,
java.nio.ByteBuffer buf,
java.lang.Boolean dontCache,
SimpleLoggerIF logger,
StatsLogger.StatsConfig statsIDSCGEN)
Reads data for an exhibit into the given buffer. |
(package private) boolean |
exhibitRemoveCacheEntry(java.util.concurrent.locks.ReentrantReadWriteLock rwl,
java.io.File cacheDir,
Name.ExhibitFull name,
boolean justData,
SimpleLoggerIF logger,
StatsLogger.StatsConfig statsIDSCGEN)
Remove an exhibit entry from cache, possibly including all its data and metadata. |
(package private) boolean |
exhibitSaveThumbnails(java.util.concurrent.locks.ReentrantReadWriteLock rwl,
GenProps gp,
java.io.File cacheDir,
ExhibitStaticAttr esa,
ExhibitThumbnails tns,
SimpleLoggerIF logger,
StatsLogger.StatsConfig statsIDSCGEN)
Saves the thumbnails for an exhibit. |
(package private) int |
getFullyCachedCount(AllExhibitProperties aep,
boolean force)
Return estimated count of known-fully-cached exhibits; non-negative. |
(package private) java.util.Set<Name.ExhibitFull> |
getKnownExhibits()
Get Set of exhibits on which metadata is currently held in this cache. |
(package private) boolean |
getNeedsSave()
Get the 'needs to be saved to disc' value. |
(package private) long |
getTotalBytesCurrentlyUsedByCache()
Get estimated total bytes of disc used by cached entries; never negative. |
(package private) long |
getTotalBytesHighWaterMark()
Get the highest value of totalBytes, ie the cache actual high-water mark; never negative. |
(package private) boolean |
isEmpty()
Is our meta-data store empty, ie no exhibits cached at all? |
(package private) boolean |
isEquivalent(ExhibitDataSimpleCache.MetaData other)
Returns true if this metadata is essentially equivalent to another one. |
(package private) boolean |
isReadWrite()
Get the `cache-is-read/write' value. |
(package private) boolean |
lotsFree(java.io.File cacheDir)
Returns true if we have lots of disc space free. |
(package private) void |
mergeWithNewMetaData(ExhibitDataSimpleCache.MetaData newData,
SimpleLoggerIF logger)
Install info from new cache object in this one. |
(package private) void |
purge(java.util.concurrent.locks.ReentrantReadWriteLock rwl,
GenProps gp,
java.io.File cacheDir,
long howMuch,
Name.ExhibitFull dontPurgeName,
SimpleLoggerIF logger,
StatsLogger.StatsConfig statsIDSCGEN)
Purges the cache of old entries to make space for new, if needed. |
private void |
readObject(java.io.ObjectInputStream in)
Deserialise. |
(package private) void |
saveToDisc(java.io.File cacheDir,
SimpleLoggerIF logger,
StatsLogger.StatsConfig statsIDSCGEN)
Save (serialise) to disc; throws IOException in case of difficulty. |
(package private) void |
setNeedsSave()
Set the `needs to be saved to disc' value to be true. |
(package private) void |
setReadWrite(boolean rw)
Set the `cache-is-read/write' value. |
(package private) int |
size()
Get count of cached exhibits, including partially-cached ones; never negative. |
(package private) boolean |
someFree(java.io.File cacheDir)
Returns true if we have some (not lots of) disc space free. |
void |
validateObject()
Validate fields/state. |
private void |
writeObject(java.io.ObjectOutputStream oos)
Write out a less-redundant form of our internal information. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private transient java.util.Map<Name.ExhibitFull,ExhibitDataSimpleCache.CachedFile> cachedExhibits
This is the primary store of data; other (transient) values are derived from it; this is saved to and restored from the serialised form in an efficient and defensive way.
This is a Hashtable for thread-safety.
Compound operations may be made atomic by a lock on this object, but no other lock may be taken while this happens.
Any access that updates this table should be under the instance lock.
private transient java.util.SortedSet<ExhibitDataSimpleCache.CachedFile> exhibitsLRU
The least-recently-accessed items are first in this list, and are the first to be discarded if the cache becomes over-full.
This is not of itself thread-safe and all access must be under the instance lock.
private transient volatile long totalBytes
Write access restricted to _setTotalBytes(); marked volatile to allow unlocked read access.
private transient volatile long totalBytesHighWaterMark
Write access restricted to _setTotalBytes() and by _setTotalBytesHighWaterMark() and must be under the instance lock.
Marked volatile to allow lock-free read access.
private transient volatile boolean needsSave
Is volatile (so accessed with no lock) only by setNeedsSave() (to set it true) and saveToDisc() (to clear it after a successful save to disc).
private transient volatile boolean readWrite
Is transient so that it is deserialised as false, and is also false on construction of a new empty MetaData instance; should only be set true after comparing with or recreating from, real disc state.
Is volatile so that it can be read without taking a lock.
private static final boolean USE_EXTANT_DISC_ENTRY_ON_CREATE
private static final int MIN_FS_PERCENT_FREE
A value in the range 1-10 is probably good.
private transient volatile Tuple.Triple<java.io.File,java.lang.Long,java.lang.Long> _cFSBHWM_cache
It is in fact assumed that in general:
Marked volatile for thread-safe unlocked access.
private static final int MAX_FS_USABLE_SPACE_CACHE_MS
Pick a prime-ish value to minimise clashes with other activity...
private static final boolean TRY_TO_RETAIN_TN_IN_PURGE
private static final boolean NEVER_REQUEST_UPSTREAM_CACHEING
If false, we just ask it not to cache our precache requests which do not reflect explicit user requests, and assume that there will still be shared locality between different slaves or that it might be expensive for the master to fetch data.
Note that in either case, if data can be satisfied from the local cache then it will be, and if we have lots of space we might cache locally regardless.
private static final int MAX_CONC_EXT_WAIT_TIME_MS
private transient java.util.Map<java.lang.Object,java.lang.Long> _beingExtended
The key is a unique (new) String of the full exhibit name.
We notify on this key object instance when removing an entry.
private static final long serialVersionUID
private transient volatile int _fullyCachedCount
Marked volatile to allow thread-safe lock-free access.
Initially zero to force recomputation.
Not serialised.
| Constructor Detail |
|---|
ExhibitDataSimpleCache.MetaData()
ExhibitDataSimpleCache.MetaData(AllExhibitProperties aepCurrent,
java.io.File cacheDir,
SimpleLoggerIF logger)
throws java.io.IOException
No locks (ie especially the rwl or cache's instance lock) should be held while this is running.
This does not modify the disc.
The constructed object is marked as needing to be saved.
This relies in part on being able to find the data files for the cached (prefixes of) exhibits by their valid full exhibit names.
We do also explicitly attempt to recover any plausible entries corresponding to current AEP entries.
Thus we may miss entries which have no current data file, eg because we had zero bytes cached for that file, and may have to recover such data later as we run across it.
We do also explicitly attempt to recover any plausible entries corresponding to current AEP entries.
aepCurrent - reasonably current AEP as a hint for entries to look for;
never nullcacheDir - the cache top-level directory; never nulllogger - to log to; never null
java.io.IOException - in case of major problems in reconstructing
the cache state (minor problems will be ignored)| Method Detail |
|---|
java.util.Set<Name.ExhibitFull> getKnownExhibits()
long getTotalBytesCurrentlyUsedByCache()
private void _setTotalBytes(long newTB)
long getTotalBytesHighWaterMark()
private void _recomputeDerivedValues()
boolean getNeedsSave()
void setNeedsSave()
void saveToDisc(java.io.File cacheDir,
SimpleLoggerIF logger,
StatsLogger.StatsConfig statsIDSCGEN)
throws java.io.IOException
FIXME: see if this and writeObject() should simply make the object read-only for the duration
cacheDir - specified the top-level cache directory; never null
java.io.IOExceptionboolean isReadWrite()
void setReadWrite(boolean rw)
Insists on grabbing the instance lock to block changes to this without the instance lock held.
int size()
boolean isEmpty()
ExhibitDataSimpleCache.CachedFile exhibitGetInfo(Name.ExhibitFull name)
This is thread-safe and does not need nor grab any cache locks, but to ensure this data remains valid during any compound operation, at least a read lock should usually be obtained.
name - the exhibit whose meta-data is required; never nullboolean exhibitIsFullyLoaded(ExhibitStaticAttr esa)
This does not grab any cache locks, but to ensure this data remains valid during any compound operation, at least a read lock should generally be obtained.
esa - the exhibit whose meta-data is required; never null
private void _remove(java.util.concurrent.locks.ReentrantReadWriteLock rwl,
Name.ExhibitFull name)
Does not check the read/write status; should be checked before this is called.
Cache write lock must be held by current thread.
private void _update(java.util.concurrent.locks.ReentrantReadWriteLock rwl,
ExhibitDataSimpleCache.CachedFile newCf,
SimpleLoggerIF logger)
Does not check the read/write status; should be checked before this is called.
Marks the meta-data as needing to be saved.
Cache write lock must be held by current thread.
boolean isEquivalent(ExhibitDataSimpleCache.MetaData other)
The result is false if the argument is null.
void mergeWithNewMetaData(ExhibitDataSimpleCache.MetaData newData,
SimpleLoggerIF logger)
throws java.lang.IllegalStateException
This essentially throws away the old state and replaces it with that passed in, though this may do things such as retain the best notion of last-accessed timestamp from both.
Both this and the newData objects are locked for the duration of this operation.
The readWrite status is not altered or updated by this operation but needsSave may be; therefore both objects must be read-only before this is called.
Only the cache-checking routines should call this at all.
java.lang.IllegalStateException
ExhibitDataSimpleCache.CachedFile exhibitMarkAsAccessed(java.util.concurrent.locks.ReentrantReadWriteLock rwl,
Name.ExhibitFull name,
SimpleLoggerIF logger,
java.io.File cacheDir)
throws java.io.IOException
This call does not access disc (ie affects in-memory status only), and silently does nothing if there is no entry for the named exhibit.
If this metadata not read-write, this action is silently vetoed as it is assumed not to be of vital importance.
This marks the last-accessed time in the MetaData as now, to be preserved on disc at some point in the future.
This MetaData object is marked as needing to be saved if an exhibit was `touched' successfully.
This is preferably used to:
This holds a write lock on the cache while updating state.
cacheDir - if not null
then we force an update of a timestamp on disc
as a backup in case the serialised metadata is lost;
this causes extra disc traffic though not necessarily synchronous
java.io.IOException
private boolean _exhibitRemoveLRUCacheEntry(java.util.concurrent.locks.ReentrantReadWriteLock rwl,
java.io.File cacheDir,
Name.ExhibitFull dontRemoveName,
boolean justData,
SimpleLoggerIF logger,
StatsLogger.StatsConfig statsIDSCGEN)
throws java.io.IOException
If the named item is the oldest then we'll remove the next oldest, if there is one.
justData - if true then we try to retain metadata/thumbnails
java.io.IOException
boolean exhibitRemoveCacheEntry(java.util.concurrent.locks.ReentrantReadWriteLock rwl,
java.io.File cacheDir,
Name.ExhibitFull name,
boolean justData,
SimpleLoggerIF logger,
StatsLogger.StatsConfig statsIDSCGEN)
throws java.io.IOException
This will fail if the metaData is read only, or if an entry for the exhibit does not exist in the metadata and on disc.
Since these failures will be by returning false rather than by causing an exception then this can be used as a gentle unconditional way to make sure that an entry does not exist whether or not one did before.
This needs to access disc and so will need to hold the main write lock while it does so, grabbing the metaData instance lock inside the main lock where both need to be held simultaneously.
Can optionally attempt to just remove the exhibit data, leaving metadata and any thumbnails intact.
rwl - the main cache lock object; must not be nulljustData - if true then we try to retain metadata/thumbnails
java.io.IOException
boolean exhibitCreateNewCacheEntry(java.util.concurrent.locks.ReentrantReadWriteLock rwl,
java.io.File cacheDir,
ExhibitStaticAttr esa,
SimpleLoggerIF logger,
StatsLogger.StatsConfig statsIDSCGEN)
throws java.io.IOException
This will fail if the metaData is read only, or if an entry for the exhibit already exists in the metaData or on disc.
Since these failures will be by returning false rather than by causing an exception then this can be used as a gentle unconditional way to make sure that an entry does exist whether or not one did before.
This needs to access disc and so will need to grab a write lock on the main cache lock while it does so, grabbing the metaData instance lock inside the main lock where both need to be held simultaneously.
Marks the meta-data as needing to be saved if a new meta-data entry had to be created...
rwl - the main lock object; must not be nullesa - the basic info on the exhibit to have an entry created
java.io.IOException - in case of serious problems
accessing the on-disc cache statelong computeTargetHighWaterMark()
We may further restict cache size to leave a given percentage free in the underlying filesystem.
long computeFreeSpaceBelowLowWaterMark(java.io.File cacheDir)
If we don't trust the GenProps value then the low-water mark is the current actual high-water mark for the cache, ie we try to maintain its size approximately.
Is synchronized to maintain consistency while working.
boolean lotsFree(java.io.File cacheDir)
If we don't trust GenProps this always returns false.
boolean someFree(java.io.File cacheDir)
If we don't trust GenProps this always returns false.
long computeFreeSpaceBelowHighWaterMark(java.io.File cacheDir)
This is thread-safe though may be expensive.
boolean canPrecacheExhibitData(java.io.File cacheDir)
boolean canPrecacheThumbnails(java.io.File cacheDir)
Basically we're prepared to go right up to the wire to generate thumbnails because they are so useful to the user.
We leave a little bit of wiggle room on space.
boolean canPrecache(java.io.File cacheDir)
void purge(java.util.concurrent.locks.ReentrantReadWriteLock rwl,
GenProps gp,
java.io.File cacheDir,
long howMuch,
Name.ExhibitFull dontPurgeName,
SimpleLoggerIF logger,
StatsLogger.StatsConfig statsIDSCGEN)
throws java.io.IOException
This will avoid purging the cache of the item passed to it by name in case it was a candidate for removal.
If the argument is zero this tries to ensure that space for at least one new (empty) exhibit cache entry to be created.
If greater than zero this tries to ensure that an existing cache entry can be extended by at least the given number of bytes (either for the exhibit data or for thumbnail data).
This grabs the cache write lock and instance lock.
This will fail if the cache is marked read-only.
howMuch - howMuch space we need to ensure is free; positive
java.io.IOException
void exhibitRead(java.util.concurrent.locks.ReentrantReadWriteLock rwl,
java.lang.String fetchFromPeer,
java.io.File cacheDir,
Name.ExhibitFull name,
SimpleExhibitPipelineIF upstream,
AllExhibitImmutableData aeid,
GenProps gp,
int dataStart,
java.nio.ByteBuffer buf,
java.lang.Boolean dontCache,
SimpleLoggerIF logger,
StatsLogger.StatsConfig statsIDSCGEN)
throws java.io.IOException
This will extend the underlying cache entry if necessary (and possible) to satisfy the read, and may also apply read-ahead to maximise user-perceived performance.
If the metaData is read-only, then any (portion of the) read that cannot be satisfied from the cache is passed back up the pipeline.
This needs to access disc and so will need to hold the rwl while it does so, grabbing the metaData instance lock inside the rwl where both need to be held simultaneously.
Note that we control caching to suit our precaching and any downstream precache/random activity, so at this level we have a 3-way choice.
This may only mark a cache entry as accessed if dontCache is FALSE and we actually read from or add data to the cache, though we may mark it as updated at other times too.
Whenever we (easily) know that we can satisfy the request from cache, we only take a read lock to improve concurrency.
We return as soon as we have satisfied some part of the request so as minimise internal copying of data, etc.
rwl - the main cache lock object; must not be nullfetchFromPeer - if non-null and we need to extend the cache
then we will try to do so from the mirror with the given tagdontCache - if FALSE, then cache here if possible and
ask upstream to cache;
if null then cache locally but not upstream
(this is our precaching activity);
if TRUE then don't cache here or upstream
(this is downstream precaching or random activity);
note therefore that we ask upstream to cache
unless dontCache is FALSE
java.io.IOException - in case of serious problems
accessing the on-disc cache state
or if request is out of bounds of underlying exhibit
or too big to handle
private int _readRawDataStartFromCache(java.util.concurrent.locks.ReentrantReadWriteLock rwl,
Name.ExhibitFull name,
int dataStart,
java.io.File cacheDir,
java.nio.ByteBuffer buf,
SimpleLoggerIF logger,
StatsLogger.StatsConfig statsIDSCGEN)
throws java.io.IOException
Likely to be heavily used, so efficiency is important here.
java.io.IOException
ExhibitThumbnails exhibitGetThumbnails(java.util.concurrent.locks.ReentrantReadWriteLock rwl,
java.io.File cacheDir,
Name.ExhibitFull name,
SimpleLoggerIF logger)
throws java.io.IOException
If a problem is encountered deserialising thumbnails, the cache is not-read-only, and AUTO_REPAIR_DURING_IO is true, we may zap the offending serialised file to try to recreate it later.
We will need to hold a write lock if updating timestamps when accessing the thumbnails; this may greatly reduce concurrency.
rwl - the main cache lock object; must not be null
java.io.IOException - in case of serious problems
accessing the on-disc cache state
boolean exhibitSaveThumbnails(java.util.concurrent.locks.ReentrantReadWriteLock rwl,
GenProps gp,
java.io.File cacheDir,
ExhibitStaticAttr esa,
ExhibitThumbnails tns,
SimpleLoggerIF logger,
StatsLogger.StatsConfig statsIDSCGEN)
throws java.io.IOException
This will fail if the metaData is read only.
If the thumbnails argument is null, this will purge any extant thumbnails for this exhibit.
This will create a new zero-length exhibit entry if necessary.
Since these failures will be by returning false rather than by causing an exception then this can be used as a gentle unconditional way to make sure that an entry does exist whether or not one did before.
This needs to access disc and so will need to hold the main lock while it does so, grabbing the metaData instance lock inside the main lock where both need to be held simultaneously.
Note that this will have to grab a write lock.
rwl - the main lock object; must not be nullesa - the basic info on the exhibit to have an entry created
java.io.IOException - in case of serious problems
accessing the on-disc cache state
private void writeObject(java.io.ObjectOutputStream oos)
throws java.io.IOException
The more-efficient on-the-wire format also makes defensive reading easier.
java.io.IOException
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException,
java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
public void validateObject()
throws java.io.InvalidObjectException
Barf if something bad is found. (Maybe allow some extra info in debug version.)
Assumes _recomputeDerivedValues() has been called before this is called since deserialisation or construction.
validateObject in interface java.io.ObjectInputValidationjava.io.InvalidObjectException
int getFullyCachedCount(AllExhibitProperties aep,
boolean force)
Note that since the cached count is not serialised with the metadata then it will need to be recomputed when metadata is loaded/deserialised.
Even without a recomputation being forced, we may decide to do one if it seems that the value might be stale.
This will take time O(n) for an n-exhibit AEP to (re)compute its result, but does minimal or no locking, and none for the duration of the method, so is safe to launch in a background thread for example.
May be expensive (continually recomputing) if/while no exhibit is fully locally cached, but this is assumed to be unlikely in practice.
aep - if non-null, allow recomputation against this AEPforce - if true, force immediate recomputation against this AEP if non-null
|
DHD Multimedia Gallery V1.57.21 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||