Class AbstractRemoteCacheService<K,V>
java.lang.Object
org.apache.commons.jcs3.auxiliary.remote.http.server.AbstractRemoteCacheService<K,V>
- All Implemented Interfaces:
Remote,ICacheService<K,,V> ICacheServiceNonLocal<K,V>
- Direct Known Subclasses:
RemoteHttpCacheService
public abstract class AbstractRemoteCacheService<K,V>
extends Object
implements ICacheServiceNonLocal<K,V>
This class contains common methods for remote cache services. Eventually I hope to extract out
much of the RMI server to use this as well. I'm starting with the Http service.
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractRemoteCacheService(ICompositeCacheManager cacheManager, ICacheEventLogger cacheEventLogger) Creates the super with the needed items. -
Method Summary
Modifier and TypeMethodDescriptionprotected <T> ICacheEvent<T>createICacheEvent(String cacheName, T key, long requesterId, String eventName) Logs an event if an event logger is configured.protected ICacheEvent<ICacheElement<K,V>> createICacheEvent(ICacheElement<K, V> item, long requesterId, String eventName) Logs an event if an event logger is configured.voidFrees the specified remote cache.voidFrees the specified remote cache.Returns a cache value from the specified remote cache; or null if the cache or key does not exist.Returns a cache bean from the specified cache; or null if the key does not exist.protected ICompositeCacheManagerprotected Stringprotected abstract StringgetExtraInfoForRequesterId(long requesterId) Ip address for the client, if one is stored.Return the keys in this cache.Map<K,ICacheElement<K, V>> getMatching(String cacheName, String pattern) Gets all matching items.Map<K,ICacheElement<K, V>> getMatching(String cacheName, String pattern, long requesterId) Retrieves all matching keys.Map<K,ICacheElement<K, V>> getMultiple(String cacheName, Set<K> keys) Gets multiple items from the cache based on the given set of keys.Map<K,ICacheElement<K, V>> getMultiple(String cacheName, Set<K> keys, long requesterId) Gets multiple items from the cache based on the given set of keys.getStats()Gets the stats attribute of the RemoteCacheServer object.protected voidlogApplicationEvent(String source, String eventName, String optionalDetails) Logs an event if an event logger is configured.protected <T> voidlogICacheEvent(ICacheEvent<T> cacheEvent) Logs an event if an event logger is configured.processGetKeySet(String cacheName) Gets the set of keys of objects currently in the cache.voidRemoves the given key from the specified remote cache.voidRemove the key from the cache region and don't tell the source listener about it.voidRemove all keys from the specified remote cache.voidRemove all keys from the specified remote cache.voidsetCacheEventLogger(ICacheEventLogger cacheEventLogger) Allows it to be injected.protected voidsetCacheManager(ICompositeCacheManager cacheManager) protected voidsetEventLogSourceName(String eventLogSourceName) voidupdate(ICacheElement<K, V> item) Puts a cache item to the cache.voidupdate(ICacheElement<K, V> item, long requesterId) The internal processing is wrapped in event logging calls.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.commons.jcs3.engine.behavior.ICacheService
release
-
Constructor Details
-
AbstractRemoteCacheService
public AbstractRemoteCacheService(ICompositeCacheManager cacheManager, ICacheEventLogger cacheEventLogger) Creates the super with the needed items.- Parameters:
cacheManager-cacheEventLogger-
-
-
Method Details
-
update
Description copied from interface:ICacheServicePuts a cache item to the cache.- Specified by:
updatein interfaceICacheService<K,V> - Parameters:
item-- Throws:
IOException
-
update
The internal processing is wrapped in event logging calls.- Specified by:
updatein interfaceICacheServiceNonLocal<K,V> - Parameters:
item-requesterId-- Throws:
IOException
-
get
Returns a cache value from the specified remote cache; or null if the cache or key does not exist.- Specified by:
getin interfaceICacheService<K,V> - Parameters:
cacheName-key-- Returns:
- ICacheElement
- Throws:
IOException
-
get
Returns a cache bean from the specified cache; or null if the key does not exist.Adding the requestor id, allows the cache to determine the source of the get.
The internal processing is wrapped in event logging calls.
- Specified by:
getin interfaceICacheServiceNonLocal<K,V> - Parameters:
cacheName-key-requesterId-- Returns:
- ICacheElement
- Throws:
IOException
-
getMatching
Gets all matching items.- Specified by:
getMatchingin interfaceICacheService<K,V> - Parameters:
cacheName-pattern-- Returns:
- Map of keys and wrapped objects
- Throws:
IOException
-
getMatching
public Map<K,ICacheElement<K, getMatchingV>> (String cacheName, String pattern, long requesterId) throws IOException Retrieves all matching keys.- Specified by:
getMatchingin interfaceICacheServiceNonLocal<K,V> - Parameters:
cacheName-pattern-requesterId-- Returns:
- Map of keys and wrapped objects
- Throws:
IOException
-
getMultiple
Gets multiple items from the cache based on the given set of keys.- Specified by:
getMultiplein interfaceICacheService<K,V> - Parameters:
cacheName-keys-- Returns:
- a map of K key to ICacheElement<K, V> element, or an empty map if there is no data in cache for any of these keys
- Throws:
IOException
-
getMultiple
public Map<K,ICacheElement<K, getMultipleV>> (String cacheName, Set<K> keys, long requesterId) throws IOException Gets multiple items from the cache based on the given set of keys.The internal processing is wrapped in event logging calls.
- Specified by:
getMultiplein interfaceICacheServiceNonLocal<K,V> - Parameters:
cacheName-keys-requesterId-- Returns:
- a map of K key to ICacheElement<K, V> element, or an empty map if there is no data in cache for any of these keys
- Throws:
IOException
-
getKeySet
Return the keys in this cache.- Specified by:
getKeySetin interfaceICacheServiceNonLocal<K,V> - Parameters:
cacheName- the name of the cache- Returns:
- a set of the key type TODO This should probably be done in chunks with a range passed in. This will be a problem if someone puts a 1,000,000 or so items in a region.
- See Also:
-
processGetKeySet
Gets the set of keys of objects currently in the cache.- Parameters:
cacheName-- Returns:
- Set
-
remove
Removes the given key from the specified remote cache. Defaults the listener id to 0.- Specified by:
removein interfaceICacheService<K,V> - Parameters:
cacheName-key-- Throws:
IOException
-
remove
Remove the key from the cache region and don't tell the source listener about it.The internal processing is wrapped in event logging calls.
- Specified by:
removein interfaceICacheServiceNonLocal<K,V> - Parameters:
cacheName-key-requesterId-- Throws:
IOException
-
removeAll
Remove all keys from the specified remote cache.- Specified by:
removeAllin interfaceICacheService<K,V> - Parameters:
cacheName-- Throws:
IOException
-
removeAll
Remove all keys from the specified remote cache.The internal processing is wrapped in event logging calls.
- Specified by:
removeAllin interfaceICacheServiceNonLocal<K,V> - Parameters:
cacheName-requesterId-- Throws:
IOException
-
dispose
Frees the specified remote cache.- Specified by:
disposein interfaceICacheService<K,V> - Parameters:
cacheName-- Throws:
IOException
-
dispose
Frees the specified remote cache.- Parameters:
cacheName-requesterId-- Throws:
IOException
-
getStats
Gets the stats attribute of the RemoteCacheServer object.- Returns:
- The stats value
- Throws:
IOException
-
createICacheEvent
protected ICacheEvent<ICacheElement<K,V>> createICacheEvent(ICacheElement<K, V> item, long requesterId, String eventName) Logs an event if an event logger is configured.- Parameters:
item-requesterId-eventName-- Returns:
- ICacheEvent
-
createICacheEvent
protected <T> ICacheEvent<T> createICacheEvent(String cacheName, T key, long requesterId, String eventName) Logs an event if an event logger is configured.- Parameters:
cacheName-key-requesterId-eventName-- Returns:
- ICacheEvent
-
logApplicationEvent
Logs an event if an event logger is configured.- Parameters:
source-eventName-optionalDetails-
-
logICacheEvent
Logs an event if an event logger is configured.- Parameters:
cacheEvent-
-
getExtraInfoForRequesterId
Ip address for the client, if one is stored.Protected for testing.
- Parameters:
requesterId-- Returns:
- String
-
setCacheEventLogger
Allows it to be injected.- Parameters:
cacheEventLogger-
-
setCacheManager
- Parameters:
cacheManager- the cacheManager to set
-
getCacheManager
- Returns:
- the cacheManager
-
setEventLogSourceName
- Parameters:
eventLogSourceName- the eventLogSourceName to set
-
getEventLogSourceName
- Returns:
- the eventLogSourceName
-