Package it.tidalwave.image
Class ImageModelCache
- java.lang.Object
-
- it.tidalwave.image.ImageModelCache
-
- Direct Known Subclasses:
DefaultImageModelCache
public abstract class ImageModelCache extends java.lang.Object
A cache of ImageModels used for distributed computing. The purpose of the cache is - quite obviously - to reduce the need for moving image through the network among different computing nodes.- Author:
- Fabrizio Giudici
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ImageModelCache()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract boolean
contains(java.io.Serializable id)
Returns true if there's a local copy with the given id.static ImageModelCache
getInstance()
Returns the default instance of the cache on the local VM.abstract void
remove(java.io.Serializable id, boolean remote)
Removes an ImageModel from the cache.abstract ImageModel
retrieve(java.io.Serializable id, boolean remote)
Finds an ImageModel in the cache.static void
setDefault(java.lang.Class<? extends ImageModelCache> defaultClass)
Sets the default implementation of the cache for the local VM.abstract void
store(ImageModel imageModel)
Adds an ImageModel to the cache.abstract void
update(ImageModel imageModel)
Updates an ImageModel in the cache.
-
-
-
Method Detail
-
setDefault
public static void setDefault(java.lang.Class<? extends ImageModelCache> defaultClass)
Sets the default implementation of the cache for the local VM.- Parameters:
defaultClass
- the implementation class- Throws:
java.lang.IllegalStateException
- if a cache has been already instantiated
-
getInstance
public static ImageModelCache getInstance()
Returns the default instance of the cache on the local VM.- Returns:
- the local cache
-
store
public abstract void store(ImageModel imageModel)
Adds an ImageModel to the cache. The image is always added only in the local cache. Remote caches will pull the images they lack on demand.- Parameters:
imageModel
- the ImageModel to add
-
update
public abstract void update(ImageModel imageModel)
Updates an ImageModel in the cache. This means that all remote copies of this image will be invalidated. TODO: should investigate more complex cases. Maybe the remote workers still want to work with a remote snapshot. Include versioning instead of invalidating?- Parameters:
imageModel
- the ImageModel to update
-
remove
public abstract void remove(java.io.Serializable id, boolean remote)
Removes an ImageModel from the cache. According to the value of theremote
parameter, the operation is performed only locally or also to remote caches.- Parameters:
id
- the id of the ImageModel to removeremove
- true if the operation must be performed also remotely
-
retrieve
public abstract ImageModel retrieve(java.io.Serializable id, boolean remote)
Finds an ImageModel in the cache. According to the value of theremote
parameter, the search is performed only locally or also to remote caches.- Parameters:
id
- the id of the ImageModel to removeremove
- true if the operation must be performed also remotely
-
contains
public abstract boolean contains(java.io.Serializable id)
Returns true if there's a local copy with the given id.- Parameters:
id
- the id of the ImageModel to remove- Returns:
- true if there's a local copy
-
-