org.apache.jcs.utils.discovery
Class UDPDiscoveryService

java.lang.Object
  extended by org.apache.jcs.utils.discovery.UDPDiscoveryService
All Implemented Interfaces:
IShutdownObserver

public class UDPDiscoveryService
extends Object
implements 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.

Author:
Aaron Smuts

Constructor Summary
UDPDiscoveryService(UDPDiscoveryAttributes attributes, ICacheEventLogger cacheEventLogger)
           
 
Method Summary
 boolean 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.
 void finalize()
          Call shutdown to be safe.
protected  ArrayList getCacheNames()
          Get all the cache names we have facades for.
 Set getCopyOfDiscoveryListeners()
           
 Set getDiscoveredServices()
           
 UDPDiscoveryAttributes getUdpDiscoveryAttributes()
           
 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 serviceRequestBroadcast()
          Send a passive broadcast in response to a request broadcast.
 void setDiscoveredServices(Set discoveredServices)
           
 void setUdpDiscoveryAttributes(UDPDiscoveryAttributes attr)
           
 void shutdown()
          Shuts down the receiver.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UDPDiscoveryService

public UDPDiscoveryService(UDPDiscoveryAttributes attributes,
                           ICacheEventLogger cacheEventLogger)
Parameters:
attributes -
cacheEventLogger -
Method Detail

serviceRequestBroadcast

protected void 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.


addParticipatingCacheName

public void addParticipatingCacheName(String cacheName)
Adds a region to the list that is participating in discovery.

Parameters:
cacheName -

removeDiscoveredService

public void removeDiscoveredService(DiscoveredService service)
Removes the discovered service from the list and calls the discovery listener.

Parameters:
service -

addOrUpdateService

protected void addOrUpdateService(DiscoveredService discoveredService)
Add a service to the list. Update the held copy if we already know about it.

Parameters:
discoveredService - discovered service

getCacheNames

protected ArrayList getCacheNames()
Get all the cache names we have facades for.

Returns:
ArrayList

setUdpDiscoveryAttributes

public void setUdpDiscoveryAttributes(UDPDiscoveryAttributes attr)
Parameters:
attr - The UDPDiscoveryAttributes to set.

getUdpDiscoveryAttributes

public UDPDiscoveryAttributes getUdpDiscoveryAttributes()
Returns:
Returns the lca.

shutdown

public void shutdown()
Shuts down the receiver.

Specified by:
shutdown in interface IShutdownObserver

finalize

public void finalize()
              throws Throwable
Call shutdown to be safe.

Overrides:
finalize in class Object
Throws:
Throwable - on error

setDiscoveredServices

public void setDiscoveredServices(Set discoveredServices)
Parameters:
discoveredServices - The discoveredServices to set.

getDiscoveredServices

public Set getDiscoveredServices()
Returns:
Returns the discoveredServices.

getCopyOfDiscoveryListeners

public Set getCopyOfDiscoveryListeners()
Returns:
the discoveryListeners

addDiscoveryListener

public boolean addDiscoveryListener(IDiscoveryListener listener)
Adds a listener.

Parameters:
listener -
Returns:
true if it wasn't already in the set

removeDiscoveryListener

public boolean removeDiscoveryListener(IDiscoveryListener listener)
Removes a listener.

Parameters:
listener -
Returns:
true if it was in the set


Copyright © 2002-2012 Apache Software Foundation. All Rights Reserved.