Package org.atmosphere.cache
Class UUIDBroadcasterCache
java.lang.Object
org.atmosphere.cache.UUIDBroadcasterCache
- All Implemented Interfaces:
BroadcasterCache,AtmosphereConfigAware
An improved
BroadcasterCache implementation that is based on the unique identifier (UUID) that all
AtmosphereResources have.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final List<BroadcasterCacheInspector> protected final List<BroadcasterCacheListener> protected ScheduledExecutorServiceFields inherited from interface org.atmosphere.cpr.BroadcasterCache
DEFAULT, NULL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd aBroadcasterCacheListeneraddToCache(String broadcasterId, String uuid, BroadcastMessage message) Start tracking messages associated withAtmosphereResourcefrom the cache.cacheCandidate(String broadcasterId, String uuid) Add aAtmosphereResource.uuid()to the list of activeAtmosphereResourceMessage will be cached for the resource associated with the uuid.voidcleanup()Clean resources associated with this instance.clearCache(String broadcasterId, String uuid, CacheMessage message) Remove the previously cached message.voidconfigure(AtmosphereConfig config) Configure an AtmosphereFramework object.longexcludeFromCache(String broadcasterId, AtmosphereResource r) Allow an application to exclude, or block, anAtmosphereResourceto received cached message.longhitCount()protected booleanAdd aBroadcasterCacheInspectorthat will be invoked before a message gets added to the cache.protected voidmessages()longRemove aBroadcasterCacheListenerretrieveFromCache(String broadcasterId, String uuid) Retrieve messages associated withAtmosphereResource.voidsetClientIdleTime(long clientIdleTime) voidsetInvalidateCacheInterval(long invalidateCacheInterval) voidsetMaxPerClient(int maxPerClient) voidsetMaxTotal(int maxTotal) voidsetMessageTTL(long messageTTLMillis) voidstart()This method is invoked when the Broadcaster is started.voidstop()This method is invoked when the Broadcaster is stopped.toString()intprotected String
-
Field Details
-
inspectors
-
taskScheduler
-
emptyList
-
listeners
-
-
Constructor Details
-
UUIDBroadcasterCache
public UUIDBroadcasterCache()
-
-
Method Details
-
configure
Description copied from interface:AtmosphereConfigAwareConfigure an AtmosphereFramework object.- Specified by:
configurein interfaceAtmosphereConfigAware- Parameters:
config-AtmosphereConfig
-
start
public void start()Description copied from interface:BroadcasterCacheThis method is invoked when the Broadcaster is started.- Specified by:
startin interfaceBroadcasterCache
-
stop
public void stop()Description copied from interface:BroadcasterCacheThis method is invoked when the Broadcaster is stopped.- Specified by:
stopin interfaceBroadcasterCache
-
cleanup
public void cleanup()Description copied from interface:BroadcasterCacheClean resources associated with this instance. This method is useful when ExecutorServices are shared and some future must be cancelled. This method will always be invoked when aBroadcastergets destroyed.- Specified by:
cleanupin interfaceBroadcasterCache
-
addToCache
Description copied from interface:BroadcasterCacheStart tracking messages associated withAtmosphereResourcefrom the cache.- Specified by:
addToCachein interfaceBroadcasterCache- Parameters:
broadcasterId- The associated}invalid @link
{@link Broadcaster#addAtmosphereResource(AtmosphereResource).getIDuuid-AtmosphereResource.uuid()message-BroadcastMessage.- Returns:
- The
CacheMessage
-
retrieveFromCache
Description copied from interface:BroadcasterCacheRetrieve messages associated withAtmosphereResource.- Specified by:
retrieveFromCachein interfaceBroadcasterCache- Parameters:
broadcasterId- The associated}invalid @link
{@link org.atmosphere.cpr.Broadcaster#addAtmosphereResource(org.atmosphere.cpr.AtmosphereResource).getIDuuid-AtmosphereResource- Returns:
- a
Listof messages (String).
-
clearCache
Description copied from interface:BroadcasterCacheRemove the previously cached message.- Specified by:
clearCachein interfaceBroadcasterCache- Parameters:
broadcasterId- TheBroadcaster.getID()uuid- anAtmosphereResource.uuid()message- theCacheMessage
-
inspector
Description copied from interface:BroadcasterCacheAdd aBroadcasterCacheInspectorthat will be invoked before a message gets added to the cache.- Specified by:
inspectorin interfaceBroadcasterCache- Parameters:
b- an instance ofBroadcasterCacheInspector- Returns:
- this
-
addBroadcasterCacheListener
Description copied from interface:BroadcasterCacheAdd aBroadcasterCacheListener- Specified by:
addBroadcasterCacheListenerin interfaceBroadcasterCache- Parameters:
l- aBroadcasterCacheListener- Returns:
- this
-
removeBroadcasterCacheListener
Description copied from interface:BroadcasterCacheRemove aBroadcasterCacheListener- Specified by:
removeBroadcasterCacheListenerin interfaceBroadcasterCache- Parameters:
l- aBroadcasterCacheListener- Returns:
- this
-
uuid
-
messages
-
activeClients
-
inspect
-
setInvalidateCacheInterval
public void setInvalidateCacheInterval(long invalidateCacheInterval) -
setClientIdleTime
public void setClientIdleTime(long clientIdleTime) -
setMaxPerClient
public void setMaxPerClient(int maxPerClient) -
setMessageTTL
public void setMessageTTL(long messageTTLMillis) -
setMaxTotal
public void setMaxTotal(int maxTotal) -
invalidateExpiredEntries
protected void invalidateExpiredEntries() -
excludeFromCache
Description copied from interface:BroadcasterCacheAllow an application to exclude, or block, anAtmosphereResourceto received cached message. No new message will get sent to this client except the ones already cached.- Specified by:
excludeFromCachein interfaceBroadcasterCache- Parameters:
broadcasterId- TheBroadcaster.getID()r- anAtmosphereResource- Returns:
- this
-
cacheCandidate
Description copied from interface:BroadcasterCacheAdd aAtmosphereResource.uuid()to the list of activeAtmosphereResourceMessage will be cached for the resource associated with the uuid.- Specified by:
cacheCandidatein interfaceBroadcasterCache- Parameters:
broadcasterId- TheBroadcaster.getID()uuid- anAtmosphereResource.uuid()- Returns:
- this
-
toString
-
listeners
-
inspectors
-
totalSize
public int totalSize()- Returns:
- the total number of cached messages across all clients
-
evictionCount
public long evictionCount()- Returns:
- the total number of evictions (max-per-client, TTL, global cap)
-
hitCount
public long hitCount()- Returns:
- the total number of cache hits (retrieveFromCache found messages)
-
missCount
public long missCount()- Returns:
- the total number of cache misses (retrieveFromCache found no messages)
-