Class LateralTCPService<K,V>
java.lang.Object
org.apache.commons.jcs3.auxiliary.lateral.socket.tcp.LateralTCPService<K,V>
- All Implemented Interfaces:
Remote
,ICacheService<K,
,V> ICacheServiceNonLocal<K,
V>
A lateral cache service implementation. Does not implement getGroupKey
TODO: Remove generics
-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Specify serializerLateralTCPService
(ITCPLateralCacheAttributes lca, IElementSerializer serializer) Constructor for the LateralTCPService object -
Method Summary
Modifier and TypeMethodDescriptionvoid
Will close the connection.Returns a cache bean from the specified cache; or null if the key does not exist.If get is allowed, we will issues a get request.Return the keys in this cache.protected long
Map<K,
ICacheElement<K, V>> getMatching
(String cacheName, String pattern) If allow get is true, we will issue a getmatching query.Map<K,
ICacheElement<K, V>> getMatching
(String cacheName, String pattern, long requesterId) If allow get is true, we will issue a getmatching query.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) This issues a separate get for each item.static void
Deprecated.Use unit testsvoid
release()
Does nothing.void
Uses the default listener id and calls the next remove method.void
Wraps the key in a LateralElementDescriptor.void
Remove all keys from the specified cache.void
Remove all keys from the specified cache.protected void
setListenerId
(long listernId) void
update
(ICacheElement<K, V> item) Puts a cache item to the cache.void
update
(ICacheElement<K, V> item, long requesterId) If put is allowed, we will issue a put.
-
Constructor Details
-
LateralTCPService
Deprecated.Specify serializerConstructor for the LateralTCPService object- Parameters:
lca
- ITCPLateralCacheAttributes the configuration object- Throws:
IOException
-
LateralTCPService
public LateralTCPService(ITCPLateralCacheAttributes lca, IElementSerializer serializer) throws IOException Constructor for the LateralTCPService object- Parameters:
lca
- ITCPLateralCacheAttributes the configuration objectserializer
- the serializer to use when sending- Throws:
IOException
- Since:
- 3.1
-
-
Method Details
-
update
Description copied from interface:ICacheService
Puts a cache item to the cache.- Specified by:
update
in interfaceICacheService<K,
V> - Parameters:
item
-- Throws:
IOException
-
update
If put is allowed, we will issue a put. If issue put on remove is configured, we will issue a remove. Either way, we create a lateral element descriptor, which is essentially a JCS TCP packet. It describes what operation the receiver should take when it gets the packet.- Specified by:
update
in interfaceICacheServiceNonLocal<K,
V> - Throws:
IOException
- See Also:
-
remove
Uses the default listener id and calls the next remove method.- Specified by:
remove
in interfaceICacheService<K,
V> - Throws:
IOException
- See Also:
-
remove
Wraps the key in a LateralElementDescriptor.- Specified by:
remove
in interfaceICacheServiceNonLocal<K,
V> - Throws:
IOException
- See Also:
-
release
Does nothing.- Specified by:
release
in interfaceICacheService<K,
V> - Throws:
IOException
-
dispose
Will close the connection.- Specified by:
dispose
in interfaceICacheService<K,
V> - Parameters:
cacheName
-- Throws:
IOException
-
get
Description copied from interface:ICacheService
Returns a cache bean from the specified cache; or null if the key does not exist.- Specified by:
get
in interfaceICacheService<K,
V> - Parameters:
cacheName
-key
-- Returns:
- ICacheElement<K, V> if found.
- Throws:
IOException
-
get
If get is allowed, we will issues a get request.- Specified by:
get
in interfaceICacheServiceNonLocal<K,
V> - Parameters:
cacheName
-key
-requesterId
-- Returns:
- ICacheElement<K, V> if found.
- Throws:
IOException
-
getMatching
If allow get is true, we will issue a getmatching query.- Specified by:
getMatching
in interfaceICacheService<K,
V> - Parameters:
cacheName
-pattern
-- Returns:
- a map of K key to ICacheElement<K, V> element, or an empty map if there is no data in cache matching the pattern.
- Throws:
IOException
-
getMatching
public Map<K,ICacheElement<K, getMatchingV>> (String cacheName, String pattern, long requesterId) throws IOException If allow get is true, we will issue a getmatching query.- Specified by:
getMatching
in interfaceICacheServiceNonLocal<K,
V> - Parameters:
cacheName
-pattern
-requesterId
- - our identity- Returns:
- a map of K key to ICacheElement<K, V> element, or an empty map if there is no data in cache matching the pattern.
- Throws:
IOException
-
getMultiple
Gets multiple items from the cache based on the given set of keys.- Specified by:
getMultiple
in 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 This issues a separate get for each item.TODO We should change this. It should issue one request.
- Specified by:
getMultiple
in 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:
getKeySet
in interfaceICacheServiceNonLocal<K,
V> - Parameters:
cacheName
- the name of the cache region- 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.
- Throws:
IOException
- See Also:
-
removeAll
Description copied from interface:ICacheService
Remove all keys from the specified cache.- Specified by:
removeAll
in interfaceICacheService<K,
V> - Parameters:
cacheName
-- Throws:
IOException
-
removeAll
Description copied from interface:ICacheServiceNonLocal
Remove all keys from the specified cache.- Specified by:
removeAll
in interfaceICacheServiceNonLocal<K,
V> - Parameters:
cacheName
-requesterId
-- Throws:
IOException
-
main
Deprecated.Use unit testsTest- Parameters:
args
-
-
setListenerId
- Parameters:
listernId
- The listernId to set.
-
getListenerId
- Returns:
- Returns the listernId.
-