org.apache.jcs.auxiliary.lateral.socket.tcp.discovery
Class UDPDiscoveryService

java.lang.Object
  extended by org.apache.jcs.auxiliary.lateral.socket.tcp.discovery.UDPDiscoveryService
All Implemented Interfaces:
IShutdownObserver

public class UDPDiscoveryService
extends java.lang.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

Field Summary
protected  ICacheEventLogger cacheEventLogger
          The event logger.
protected  IElementSerializer elementSerializer
          The serializer.
 
Constructor Summary
UDPDiscoveryService(java.lang.String discoveryAddress, int discoveryPort, int servicePort, ICompositeCacheManager cacheMgr, ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer)
           
 
Method Summary
protected  void addNoWait(LateralCacheNoWait noWait)
          This adds nowaits to a facde for the region name.
 boolean addNoWaitFacade(LateralCacheNoWaitFacade facade, java.lang.String cacheName)
          Adds a nowait facade under this cachename.
protected  java.util.ArrayList getCacheNames()
          Get all the cache names we have facades for.
protected  java.lang.String getDiscoveryAddress()
           
protected  int getDiscoveryPort()
           
protected  int getServicePort()
           
 ITCPLateralCacheAttributes getTcpLateralCacheAttributes()
           
protected  void serviceRequestBroadcast()
          Send a passive broadcast in response to a request broadcast.
protected  void setDiscoveryAddress(java.lang.String discoveryAddress)
           
protected  void setDiscoveryPort(int discoveryPort)
           
protected  void setServicePort(int servicePort)
           
 void setTcpLateralCacheAttributes(ITCPLateralCacheAttributes tCPLateralCacheAttributes)
           
 void shutdown()
          Shuts down the receiver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cacheEventLogger

protected ICacheEventLogger cacheEventLogger
The event logger.


elementSerializer

protected IElementSerializer elementSerializer
The serializer.

Constructor Detail

UDPDiscoveryService

public UDPDiscoveryService(java.lang.String discoveryAddress,
                           int discoveryPort,
                           int servicePort,
                           ICompositeCacheManager cacheMgr,
                           ICacheEventLogger cacheEventLogger,
                           IElementSerializer elementSerializer)
Parameters:
discoveryAddress - address to multicast to
discoveryPort - port to multicast to
servicePort - the port this service runs on, the service we are telling other about
cacheMgr -
cacheEventLogger -
elementSerializer -
Method Detail

addNoWaitFacade

public boolean addNoWaitFacade(LateralCacheNoWaitFacade facade,
                               java.lang.String cacheName)
Adds a nowait facade under this cachename. If one already existed, it will be overridden.

When a broadcast is received from the UDP Discovery receiver, for each cacheName in the message, the add no wait will be called here. To add a no wait, the facade is looked up for this cache name.

Parameters:
facade -
cacheName -
Returns:
true if the facade was not already registered.

addNoWait

protected void addNoWait(LateralCacheNoWait noWait)
This adds nowaits to a facde for the region name. If the region has no facade, then it is not configured to use the lateral cache, and no facde will be created.

Parameters:
noWait -

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 reques, 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.


getCacheNames

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

Returns:
ArrayList

shutdown

public void shutdown()
Shuts down the receiver.

Specified by:
shutdown in interface IShutdownObserver

setDiscoveryAddress

protected void setDiscoveryAddress(java.lang.String discoveryAddress)
Parameters:
discoveryAddress - The discoveryAddress to set.

getDiscoveryAddress

protected java.lang.String getDiscoveryAddress()
Returns:
Returns the discoveryAddress.

setDiscoveryPort

protected void setDiscoveryPort(int discoveryPort)
Parameters:
discoveryPort - The discoveryPort to set.

getDiscoveryPort

protected int getDiscoveryPort()
Returns:
Returns the discoveryPort.

setServicePort

protected void setServicePort(int servicePort)
Parameters:
servicePort - The servicePort to set.

getServicePort

protected int getServicePort()
Returns:
Returns the servicePort.

setTcpLateralCacheAttributes

public void setTcpLateralCacheAttributes(ITCPLateralCacheAttributes tCPLateralCacheAttributes)
Parameters:
tCPLateralCacheAttributes - The tCPLateralCacheAttributes to set.

getTcpLateralCacheAttributes

public ITCPLateralCacheAttributes getTcpLateralCacheAttributes()
Returns:
Returns the tCPLateralCacheAttributes.


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