Class RemoteCacheServer<K,V> 
- All Implemented Interfaces:
- Serializable,- Remote,- Unreferenced,- IRemoteCacheServer<K,,- V> - ICacheObserver,- ICacheService<K,,- V> - ICacheServiceAdmin,- ICacheServiceNonLocal<K,- V> 
Remote cache servers can be clustered. If the cache used by this remote cache is configured to use a remote cache of type cluster, the two remote caches will communicate with each other. Remote and put requests can be sent from one remote to another. If they are configured to broadcast such event to their client, then remove an puts can be sent to all locals in the cluster.
Get requests are made between clustered servers if AllowClusterGet is true. You can setup several clients to use one remote server and several to use another. The get local will be distributed between the two servers. Since caches are usually high get and low put, this should allow you to scale.
- See Also:
- 
Field SummaryFieldsFields inherited from class java.rmi.server.RemoteObjectref
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedRemoteCacheServer(IRemoteCacheServerAttributes rcsa, Properties config) Constructor for the RemoteCacheServer object.protectedRemoteCacheServer(IRemoteCacheServerAttributes rcsa, Properties config, RMISocketFactory customRMISocketFactory) Constructor for the RemoteCacheServer object.
- 
Method SummaryModifier and TypeMethodDescription<KK,VV> void addCacheListener(String cacheName, ICacheListener<KK, VV> listener) Subscribes to the specified remote cache.<KK,VV> void addCacheListener(ICacheListener<KK, VV> listener) Subscribes to all remote caches.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 CacheListeners<K,V> getCacheListeners(String cacheName) Returns the cache listener for the specified cache.protected CacheListeners<K,V> getClusterListeners(String cacheName) Gets the clusterListeners attribute of the RemoteCacheServer object.protected StringgetExtraInfoForRequesterId(long requesterId) Ip address for the client, if one is stored.Return the keys in the 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.protected Map<K,ICacheElement<K, V>> processGetMatching(String cacheName, String pattern, long requesterId) Retrieves all matching keys.voidput(ICacheElement<K, V> item) Puts a cache bean to the remote cache and notifies all listeners which
 have a different listener id than the originating host; are currently subscribed to the related cache.voidrelease()Frees all remote caches.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.voidremoveCacheListener(String cacheName, long listenerId) Unsubscribe this listener from this region.<KK,VV> void removeCacheListener(String cacheName, ICacheListener<KK, VV> listener) Unsubscribe this listener from this region.<KK,VV> void removeCacheListener(ICacheListener<KK, VV> listener) Unsubscribes from all remote caches.voidsetCacheEventLogger(ICacheEventLogger cacheEventLogger) Allows it to be injected.voidshutdown()Shuts down the remote server.voidShuts down a server at a particular host and port.voidCalled by the RMI runtime sometime after the runtime determines that the reference list, the list of clients referencing the remote object, becomes empty.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.rmi.server.UnicastRemoteObjectclone, exportObject, exportObject, exportObject, unexportObjectMethods inherited from class java.rmi.server.RemoteServergetClientHost, getLog, setLog
- 
Field Details- 
DFEAULT_REMOTE_CONFIGURATION_FILE- See Also:
 
 
- 
- 
Constructor Details- 
RemoteCacheServerprotected RemoteCacheServer(IRemoteCacheServerAttributes rcsa, Properties config) throws RemoteException Constructor for the RemoteCacheServer object. This initializes the server with the values from the properties object.- Parameters:
- rcsa-
- config- cache hub configuration
- Throws:
- RemoteException
 
- 
RemoteCacheServerprotected RemoteCacheServer(IRemoteCacheServerAttributes rcsa, Properties config, RMISocketFactory customRMISocketFactory) throws RemoteException Constructor for the RemoteCacheServer object. This initializes the server with the values from the properties object.- Parameters:
- rcsa-
- config- cache hub configuration
- customRMISocketFactory-
- Throws:
- RemoteException
 
 
- 
- 
Method Details- 
putPuts a cache bean to the remote cache and notifies all listeners which
 - have a different listener id than the originating host;
- are currently subscribed to the related cache.
 - Parameters:
- item-
- Throws:
- IOException
 
- 
updateDescription copied from interface:ICacheServicePuts a cache item to the cache.- Specified by:
- updatein interface- ICacheService<K,- V> 
- Parameters:
- item-
- Throws:
- IOException
 
- 
updateThe internal processing is wrapped in event logging calls.- Specified by:
- updatein interface- ICacheServiceNonLocal<K,- V> 
- Parameters:
- item-
- requesterId-
- Throws:
- IOException
 
- 
getReturns a cache value from the specified remote cache; or null if the cache or key does not exist.- Specified by:
- getin interface- ICacheService<K,- V> 
- Parameters:
- cacheName-
- key-
- Returns:
- ICacheElement
- Throws:
- IOException
 
- 
getReturns 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 interface- ICacheServiceNonLocal<K,- V> 
- Parameters:
- cacheName-
- key-
- requesterId-
- Returns:
- ICacheElement
- Throws:
- IOException
 
- 
getMatchingGets all matching items.- Specified by:
- getMatchingin interface- ICacheService<K,- V> 
- Parameters:
- cacheName-
- pattern-
- Returns:
- Map of keys and wrapped objects
- Throws:
- IOException
 
- 
getMatchingpublic Map<K,ICacheElement<K, getMatchingV>> (String cacheName, String pattern, long requesterId) throws IOException Retrieves all matching keys.- Specified by:
- getMatchingin interface- ICacheServiceNonLocal<K,- V> 
- Parameters:
- cacheName-
- pattern-
- requesterId-
- Returns:
- Map of keys and wrapped objects
- Throws:
- IOException
 
- 
processGetMatchingprotected Map<K,ICacheElement<K, processGetMatchingV>> (String cacheName, String pattern, long requesterId) Retrieves all matching keys.- Parameters:
- cacheName-
- pattern-
- requesterId-
- Returns:
- Map of keys and wrapped objects
 
- 
getMultipleGets multiple items from the cache based on the given set of keys.- Specified by:
- getMultiplein interface- ICacheService<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
 
- 
getMultiplepublic 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 interface- ICacheServiceNonLocal<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
 
- 
getKeySetReturn the keys in the cache.- Specified by:
- getKeySetin interface- ICacheServiceNonLocal<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:
 
- 
processGetKeySetGets the set of keys of objects currently in the cache.- Parameters:
- cacheName-
- Returns:
- Set
 
- 
removeRemoves the given key from the specified remote cache. Defaults the listener id to 0.- Specified by:
- removein interface- ICacheService<K,- V> 
- Parameters:
- cacheName-
- key-
- Throws:
- IOException
 
- 
removeRemove 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 interface- ICacheServiceNonLocal<K,- V> 
- Parameters:
- cacheName-
- key-
- requesterId-
- Throws:
- IOException
 
- 
removeAllRemove all keys from the specified remote cache.- Specified by:
- removeAllin interface- ICacheService<K,- V> 
- Parameters:
- cacheName-
- Throws:
- IOException
 
- 
removeAllRemove all keys from the specified remote cache.The internal processing is wrapped in event logging calls. - Specified by:
- removeAllin interface- ICacheServiceNonLocal<K,- V> 
- Parameters:
- cacheName-
- requesterId-
- Throws:
- IOException
 
- 
disposeFrees the specified remote cache.- Specified by:
- disposein interface- ICacheService<K,- V> 
- Parameters:
- cacheName-
- Throws:
- IOException
 
- 
disposeFrees the specified remote cache.- Parameters:
- cacheName-
- requesterId-
- Throws:
- IOException
 
- 
releaseFrees all remote caches.- Specified by:
- releasein interface- ICacheService<K,- V> 
- Throws:
- IOException
 
- 
getCacheListenersReturns the cache listener for the specified cache. Creates the cache and the cache descriptor if they do not already exist.- Parameters:
- cacheName-
- Returns:
- The cacheListeners value
 
- 
getClusterListenersGets the clusterListeners attribute of the RemoteCacheServer object.TODO may be able to remove this - Parameters:
- cacheName-
- Returns:
- The clusterListeners value
 
- 
addCacheListenerpublic <KK,VV> void addCacheListener(String cacheName, ICacheListener<KK, VV> listener) throws IOExceptionSubscribes to the specified remote cache.If the client id is 0, then the remote cache server will increment it's local count and assign an id to the client. - Specified by:
- addCacheListenerin interface- ICacheObserver
- Parameters:
- cacheName- the specified remote cache.
- listener- object to notify for cache changes. must be synchronized since there are remote calls involved.
- Throws:
- IOException
 
- 
addCacheListenerSubscribes to all remote caches.- Specified by:
- addCacheListenerin interface- ICacheObserver
- Parameters:
- listener- The feature to be added to the CacheListener attribute
- Throws:
- IOException
 
- 
removeCacheListenerpublic <KK,VV> void removeCacheListener(String cacheName, ICacheListener<KK, VV> listener) throws IOExceptionUnsubscribe this listener from this region. If the listener is registered, it will be removed from the event queue map list.- Specified by:
- removeCacheListenerin interface- ICacheObserver
- Parameters:
- cacheName-
- listener-
- Throws:
- IOException
 
- 
removeCacheListenerUnsubscribe this listener from this region. If the listener is registered, it will be removed from the event queue map list.- Parameters:
- cacheName-
- listenerId-
 
- 
removeCacheListenerUnsubscribes from all remote caches.- Specified by:
- removeCacheListenerin interface- ICacheObserver
- Parameters:
- listener-
- Throws:
- IOException
 
- 
shutdownShuts down the remote server.- Specified by:
- shutdownin interface- ICacheServiceAdmin
- Throws:
- IOException
 
- 
shutdownShuts down a server at a particular host and port. Then it calls shutdown on the cache itself.- Specified by:
- shutdownin interface- ICacheServiceAdmin
- Parameters:
- host-
- port-
- Throws:
- IOException
 
- 
unreferencedCalled by the RMI runtime sometime after the runtime determines that the reference list, the list of clients referencing the remote object, becomes empty.- Specified by:
- unreferencedin interface- Unreferenced
 
- 
getStatsGets the stats attribute of the RemoteCacheServer object.- Specified by:
- getStatsin interface- ICacheServiceAdmin
- Returns:
- The stats value
- Throws:
- IOException
 
- 
logApplicationEventLogs an event if an event logger is configured.- Parameters:
- source-
- eventName-
- optionalDetails-
 
- 
logICacheEventLogs an event if an event logger is configured.- Parameters:
- cacheEvent-
 
- 
getExtraInfoForRequesterIdIp address for the client, if one is stored.Protected for testing. - Parameters:
- requesterId-
- Returns:
- String
 
- 
setCacheEventLoggerAllows it to be injected.- Parameters:
- cacheEventLogger-
 
 
-