Class UDPDiscoveryService
java.lang.Object
org.apache.commons.jcs3.utils.discovery.UDPDiscoveryService
- All Implemented Interfaces:
IRequireScheduler
,IShutdownObserver
This service creates a listener that can create lateral caches and add them to the no wait list.
It also creates a sender that periodically broadcasts its availability.
The sender also broadcasts a request for other caches to broadcast their addresses.
-
Constructor Summary
ConstructorsConstructorDescriptionUDPDiscoveryService
(UDPDiscoveryAttributes attributes) Deprecated.Specify serializer implementation explicitlyUDPDiscoveryService
(UDPDiscoveryAttributes attributes, IElementSerializer serializer) Constructor -
Method Summary
Modifier and TypeMethodDescriptionboolean
addDiscoveryListener
(IDiscoveryListener listener) Adds a listener.protected void
addOrUpdateService
(DiscoveredService discoveredService) Add a service to the list.void
addParticipatingCacheName
(String cacheName) Adds a region to the list that is participating in discovery.protected void
cleanup()
This goes through the list of services and removes those that we haven't heard from in longer than the max idle time.Get all the cache names we have facades for.Return the serializer implementationvoid
Initial request that the other caches let it know their addresses.void
removeDiscoveredService
(DiscoveredService service) Removes the discovered service from the list and calls the discovery listener.boolean
removeDiscoveryListener
(IDiscoveryListener listener) Removes a listener.protected void
Send a passive broadcast in response to a request broadcast.void
setScheduledExecutorService
(ScheduledExecutorService scheduledExecutor) Inject an instance of a central ScheduledExecutorServicevoid
void
shutdown()
Shuts down the receiver.protected void
Issues a remove broadcast to the others.void
startup()
Start necessary receiver thread
-
Constructor Details
-
UDPDiscoveryService
Deprecated.Specify serializer implementation explicitlyConstructor- Parameters:
attributes
- settings of the service
-
UDPDiscoveryService
Constructor- Parameters:
attributes
- settings of serviceserializer
- the serializer to use to send and receive messages- Since:
- 3.1
-
-
Method Details
-
setScheduledExecutorService
Description copied from interface:IRequireScheduler
Inject an instance of a central ScheduledExecutorService- Specified by:
setScheduledExecutorService
in interfaceIRequireScheduler
- See Also:
-
cleanup
This goes through the list of services and removes those that we haven't heard from in longer than the max idle time.- Since:
- 3.1
-
initiateBroadcast
Initial request that the other caches let it know their addresses.- Since:
- 3.1
-
serviceRequestBroadcast
Send a passive broadcast in response to a request broadcast. Never send a request for a request. We can respond to our own requests, since a request broadcast is not intended as a connection request. We might want to only send messages, so we would send a request, but never a passive broadcast. -
shutdownBroadcast
Issues a remove broadcast to the others.- Since:
- 3.1
-
addParticipatingCacheName
Adds a region to the list that is participating in discovery.- Parameters:
cacheName
-
-
removeDiscoveredService
Removes the discovered service from the list and calls the discovery listener.- Parameters:
service
-
-
addOrUpdateService
Add a service to the list. Update the held copy if we already know about it.- Parameters:
discoveredService
- discovered service
-
getCacheNames
Get all the cache names we have facades for.- Returns:
- ArrayList
-
setUdpDiscoveryAttributes
- Parameters:
attr
- The UDPDiscoveryAttributes to set.
-
getUdpDiscoveryAttributes
- Returns:
- Returns the lca.
-
getSerializer
Return the serializer implementation- Returns:
- the serializer
- Since:
- 3.1
-
startup
Start necessary receiver thread -
shutdown
Shuts down the receiver.- Specified by:
shutdown
in interfaceIShutdownObserver
-
getDiscoveredServices
- Returns:
- Returns the discoveredServices.
-
getCopyOfDiscoveryListeners
- Returns:
- the discoveryListeners
-
addDiscoveryListener
Adds a listener.- Parameters:
listener
-- Returns:
- true if it wasn't already in the set
-
removeDiscoveryListener
Removes a listener.- Parameters:
listener
-- Returns:
- true if it was in the set
-