svn commit: r705689 - in /jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral: ./ socket/tcp/ socket/tcp/discovery/ socket/tcp/utils/
[email protected] Fri, 17 Oct 2008 18:11:12 -0000
| Newsgroups | gmane.comp.jakarta.turbine.jcs.devel |
|---|---|
| Message-ID | <[email protected]> |
Author: asmuts
Date: Fri Oct 17 11:11:11 2008
New Revision: 705689
URL: http://svn.apache.org/viewvc?rev=705689&view=rev
Log:
doing some minor cleanup on some messy classes. more is needed
Modified:
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheAttributes.java
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheMonitor.java
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheManager.java
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPListener.java
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/TCPLateralCacheAttributes.java
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryManager.java
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryMessage.java
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryReceiver.java
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoverySender.java
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoverySenderThread.java
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryService.java
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/utils/SocketOpener.java
Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheAttributes.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheAttributes.java?rev=705689&r1=705688&r2=705689&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheAttributes.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheAttributes.java Fri Oct 17 11:11:11 2008
@@ -26,9 +26,7 @@
import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheAttributes;
/**
- * This class stores attributes for all of the available lateral cache
- * auxiliaries.
- *
+ * This class stores attributes for all of the available lateral cache auxiliaries.
*/
public class LateralCacheAttributes
extends AbstractAuxiliaryCacheAttributes
@@ -37,16 +35,17 @@
/** Don't change */
private static final long serialVersionUID = -3408449508837393660L;
+ /** Default receive setting */
private static final boolean DEFAULT_RECEIVE = true;
+ /** THe type of lateral */
String transmissionTypeName = "UDP";
-
+
int transmissionType = UDP;
String httpServers;
- // used to identify the service that this manager will be
- // operating on
+ /** used to identify the service that this manager will be operating on */
String httpServer = "";
String httpReceiveServlet = "";
@@ -59,23 +58,22 @@
int httpListenerPort = 8080;
-
- // JAVAGROUPS -------------------------
+ /** REMOVE THIS: JAVAGROUPS ------------------------- */
private String jgChannelProperties = null;
- // GENERAL ------------------------------
- // disables gets from laterals
+ /** disables gets from laterals */
boolean putOnlyMode = true;
- // do we receive and broadcast or only broadcast
- // this is useful when you don't want to get any notifications
+ /**
+ * do we receive and broadcast or only broadcast this is useful when you don't want to get any
+ * notifications
+ */
private boolean receive = DEFAULT_RECEIVE;
/**
* Sets the httpServer attribute of the LateralCacheAttributes object
- *
- * @param val
- * The new httpServer value
+ * <P>
+ * @param val The new httpServer value
*/
public void setHttpServer( String val )
{
@@ -84,7 +82,6 @@
/**
* Gets the httpServer attribute of the LateralCacheAttributes object
- *
* @return The httpServer value
*/
public String getHttpServer()
@@ -92,13 +89,9 @@
return httpServer;
}
-
-
/**
* Sets the httpServers attribute of the LateralCacheAttributes object
- *
- * @param val
- * The new httpServers value
+ * @param val The new httpServers value
*/
public void setHttpServers( String val )
{
@@ -107,7 +100,6 @@
/**
* Gets the httpSrvers attribute of the LateralCacheAttributes object
- *
* @return The httpServers value
*/
public String getHttpServers()
@@ -115,13 +107,9 @@
return httpServers;
}
-
-
/**
* Sets the httpListenerPort attribute of the ILateralCacheAttributes object
- *
- * @param val
- * The new tcpListenerPort value
+ * @param val The new tcpListenerPort value
*/
public void setHttpListenerPort( int val )
{
@@ -130,7 +118,6 @@
/**
* Gets the httpListenerPort attribute of the ILateralCacheAttributes object
- *
* @return The httpListenerPort value
*/
public int getHttpListenerPort()
@@ -140,9 +127,7 @@
/**
* Sets the udpMulticastAddr attribute of the LateralCacheAttributes object
- *
- * @param val
- * The new udpMulticastAddr value
+ * @param val The new udpMulticastAddr value
*/
public void setUdpMulticastAddr( String val )
{
@@ -151,7 +136,6 @@
/**
* Gets the udpMulticastAddr attribute of the LateralCacheAttributes object
- *
* @return The udpMulticastAddr value
*/
public String getUdpMulticastAddr()
@@ -161,9 +145,7 @@
/**
* Sets the udpMulticastPort attribute of the LateralCacheAttributes object
- *
- * @param val
- * The new udpMulticastPort value
+ * @param val The new udpMulticastPort value
*/
public void setUdpMulticastPort( int val )
{
@@ -172,7 +154,6 @@
/**
* Gets the udpMulticastPort attribute of the LateralCacheAttributes object
- *
* @return The udpMulticastPort value
*/
public int getUdpMulticastPort()
@@ -182,9 +163,7 @@
/**
* Sets the transmissionType attribute of the LateralCacheAttributes object
- *
- * @param val
- * The new transmissionType value
+ * @param val The new transmissionType value
*/
public void setTransmissionType( int val )
{
@@ -213,7 +192,6 @@
/**
* Gets the transmissionType attribute of the LateralCacheAttributes object
- *
* @return The transmissionType value
*/
public int getTransmissionType()
@@ -222,11 +200,8 @@
}
/**
- * Sets the transmissionTypeName attribute of the LateralCacheAttributes
- * object
- *
- * @param val
- * The new transmissionTypeName value
+ * Sets the transmissionTypeName attribute of the LateralCacheAttributes object
+ * @param val The new transmissionTypeName value
*/
public void setTransmissionTypeName( String val )
{
@@ -255,9 +230,7 @@
}
/**
- * Gets the transmissionTypeName attribute of the LateralCacheAttributes
- * object
- *
+ * Gets the transmissionTypeName attribute of the LateralCacheAttributes object
* @return The transmissionTypeName value
*/
public String getTransmissionTypeName()
@@ -266,12 +239,10 @@
}
/**
- * Sets the outgoingOnlyMode attribute of the ILateralCacheAttributes. When
- * this is true the lateral cache will only issue put and remove order and
- * will not try to retrieve elements from other lateral caches.
- *
- * @param val
- * The new transmissionTypeName value
+ * Sets the outgoingOnlyMode attribute of the ILateralCacheAttributes. When this is true the
+ * lateral cache will only issue put and remove order and will not try to retrieve elements from
+ * other lateral caches.
+ * @param val The new transmissionTypeName value
*/
public void setPutOnlyMode( boolean val )
{
@@ -298,7 +269,6 @@
/**
* Returns a clone of the attributes.
- *
* @return Self
*/
public AuxiliaryCacheAttributes copy()
@@ -314,11 +284,8 @@
return this;
}
-
-
/**
- * @param receive
- * The receive to set.
+ * @param receive The receive to set.
*/
public void setReceive( boolean receive )
{
@@ -333,8 +300,6 @@
return receive;
}
-
-
/*
* (non-Javadoc)
*
Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheMonitor.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheMonitor.java?rev=705689&r1=705688&r2=705689&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheMonitor.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheMonitor.java Fri Oct 17 11:11:11 2008
@@ -27,39 +27,39 @@
import org.apache.jcs.engine.CacheConstants;
/**
- * Used to monitor and repair any failed connection for the lateral cache
- * service. By default the monitor operates in a failure driven mode. That is,
- * it goes into a wait state until there is an error. Upon the notification of a
- * connection error, the monitor changes to operate in a time driven mode. That
- * is, it attempts to recover the connections on a periodic basis. When all
- * failed connections are restored, it changes back to the failure driven mode.
- *
+ * Used to monitor and repair any failed connection for the lateral cache service. By default the
+ * monitor operates in a failure driven mode. That is, it goes into a wait state until there is an
+ * error. Upon the notification of a connection error, the monitor changes to operate in a time
+ * driven mode. That is, it attempts to recover the connections on a periodic basis. When all failed
+ * connections are restored, it changes back to the failure driven mode.
*/
public class LateralCacheMonitor
implements Runnable
{
+ /** The logger */
private final static Log log = LogFactory.getLog( LateralCacheMonitor.class );
+ /** How long to wait between runs */
private static long idlePeriod = 20 * 1000;
- // minimum 20 seconds.
- //private static long idlePeriod = 3*1000; // for debugging.
-
- // Must make sure LateralCacheMonitor is started before any lateral error
- // can be detected!
+ /**
+ * Must make sure LateralCacheMonitor is started before any lateral error can be detected!
+ */
private boolean alright = true;
+ /** code for eror */
private final static int ERROR = 1;
+ /** The mode we are running in. Error driven */
private static int mode = ERROR;
+ /** The manager */
private ILateralCacheManager manager;
/**
* Configures the idle period between repairs.
- *
- * @param idlePeriod
- * The new idlePeriod value
+ * <p>
+ * @param idlePeriod The new idlePeriod value
*/
public static void setIdlePeriod( long idlePeriod )
{
@@ -70,9 +70,8 @@
}
/**
- * Allows close classes, ie testers to set the idle period to something
- * testable.
- *
+ * Allows close classes, ie testers to set the idle period to something testable.
+ * <p>
* @param idlePeriod
*/
protected static void forceShortIdlePeriod( long idlePeriod )
@@ -80,11 +79,11 @@
LateralCacheMonitor.idlePeriod = idlePeriod;
}
- /** Constructor for the LateralCacheMonitor object
+ /**
+ * Constructor for the LateralCacheMonitor object
+ * <p>
+ * It's the clients responsibility to decide how many of these there will be.
* <p>
- * It's the clients responsibility to decide how many
- * of these there will be.
- *
* @param manager
*/
public LateralCacheMonitor( ILateralCacheManager manager )
@@ -93,8 +92,7 @@
}
/**
- * Notifies the cache monitor that an error occurred, and kicks off the
- * error recovery process.
+ * Notifies the cache monitor that an error occurred, and kicks off the error recovery process.
*/
public void notifyError()
{
Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java?rev=705689&r1=705688&r2=705689&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java Fri Oct 17 11:11:11 2008
@@ -154,6 +154,8 @@
* @param lac ITCPLateralCacheAttributes
* @param lcnwf
* @param cacheMgr
+ * @param cacheEventLogger
+ * @param elementSerializer
* @return null if none is created.
*/
private UDPDiscoveryService createDiscoveryService( ITCPLateralCacheAttributes lac, LateralCacheNoWaitFacade lcnwf,
Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheManager.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheManager.java?rev=705689&r1=705688&r2=705689&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheManager.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheManager.java Fri Oct 17 11:11:11 2008
@@ -56,10 +56,13 @@
public class LateralTCPCacheManager
extends LateralCacheAbstractManager
{
+ /** Don't change. */
private static final long serialVersionUID = -9213011856644392480L;
+ /** The logger. */
private final static Log log = LogFactory.getLog( LateralTCPCacheManager.class );
+ /** The monitor */
private static LateralCacheMonitor monitor;
/** Address to instance map. */
@@ -68,6 +71,7 @@
/** ITCPLateralCacheAttributes */
protected ITCPLateralCacheAttributes lca;
+ /** number of clients, we can remove this. */
private int clients;
/**
Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPListener.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPListener.java?rev=705689&r1=705688&r2=705689&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPListener.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPListener.java Fri Oct 17 11:11:11 2008
@@ -43,19 +43,20 @@
import EDU.oswego.cs.dl.util.concurrent.ThreadFactory;
/**
- * Listens for connections from other TCP lateral caches and handles them. The
- * initialization method starts a listening thread, which creates a socket
- * server. When messages are received they are passed to a pooled executor which
- * then calls the appropriate handle method.
+ * Listens for connections from other TCP lateral caches and handles them. The initialization method
+ * starts a listening thread, which creates a socket server. When messages are received they are
+ * passed to a pooled executor which then calls the appropriate handle method.
*/
public class LateralTCPListener
implements ILateralCacheListener, Serializable
{
+ /** Don't change. */
private static final long serialVersionUID = -9107062664967131738L;
+ /** The logger */
private final static Log log = LogFactory.getLog( LateralTCPListener.class );
- /** How long the server will block on an accept(). 0 is infinte. */
+ /** How long the server will block on an accept(). 0 is infinite. */
private final static int acceptTimeOut = 0;
/** The CacheHub this listener is associated with */
@@ -67,34 +68,39 @@
/** The socket listener */
private ListenerThread receiver;
+ /** Configuration attributes */
private ITCPLateralCacheAttributes tcpLateralCacheAttributes;
+ /** Listening port */
private int port;
+ /** The processor. We should probably use an event queue here. */
private PooledExecutor pooledExecutor;
+ /** put count */
private int putCnt = 0;
+ /** remove count */
private int removeCnt = 0;
+ /** get count */
private int getCnt = 0;
/**
- * Use the vmid by default. This can be set for testing. If we ever need to
- * run more than one per vm, then we need a new technique.
+ * Use the vmid by default. This can be set for testing. If we ever need to run more than one
+ * per vm, then we need a new technique.
*/
private long listenerId = LateralCacheInfo.listenerId;
/**
* Gets the instance attribute of the LateralCacheTCPListener class.
* <p>
- * @param ilca
- * ITCPLateralCacheAttributes
+ * @param ilca ITCPLateralCacheAttributes
* @param cacheMgr
* @return The instance value
*/
public synchronized static ILateralCacheListener getInstance( ITCPLateralCacheAttributes ilca,
- ICompositeCacheManager cacheMgr )
+ ICompositeCacheManager cacheMgr )
{
ILateralCacheListener ins = (ILateralCacheListener) instances.get( String.valueOf( ilca.getTcpListenerPort() ) );
@@ -118,8 +124,7 @@
}
/**
- * Only need one since it does work for all regions, just reference by
- * multiple region names.
+ * Only need one since it does work for all regions, just reference by multiple region names.
* <p>
* @param ilca
*/
@@ -153,21 +158,18 @@
}
/**
- * Let the lateral cache set a listener_id. Since there is only one
- * listerenr for all the regions and every region gets registered? the id
- * shouldn't be set if it isn't zero. If it is we assume that it is a
- * reconnect.
+ * Let the lateral cache set a listener_id. Since there is only one listerenr for all the
+ * regions and every region gets registered? the id shouldn't be set if it isn't zero. If it is
+ * we assume that it is a reconnect.
* <p>
* By default, the listener id is the vmid.
* <p>
- * The service should set this value. This value will never be changed by a
- * server we connect to. It needs to be non static, for unit tests.
+ * The service should set this value. This value will never be changed by a server we connect
+ * to. It needs to be non static, for unit tests.
* <p>
- * The service will use the value it sets in all send requests to the
- * sender.
+ * The service will use the value it sets in all send requests to the sender.
* <p>
- * @param id
- * The new listenerId value
+ * @param id The new listenerId value
* @throws IOException
*/
public void setListenerId( long id )
@@ -193,8 +195,8 @@
}
/**
- * Increments the put count. Gets the cache that was injected by the lateral
- * factory. Calls put on the cache.
+ * Increments the put count. Gets the cache that was injected by the lateral factory. Calls put
+ * on the cache.
* <p>
* @see org.apache.jcs.engine.behavior.ICacheListener#handlePut(org.apache.jcs.engine.behavior.ICacheElement)
*/
@@ -220,8 +222,8 @@
}
/**
- * Increments the remove count. Gets the cache that was injected by the
- * lateral factory. Calls remove on the cache.
+ * Increments the remove count. Gets the cache that was injected by the lateral factory. Calls
+ * remove on the cache.
* <p>
* @see org.apache.jcs.engine.behavior.ICacheListener#handleRemove(java.lang.String,
* java.io.Serializable)
@@ -247,8 +249,7 @@
}
/**
- * Gets the cache that was injected by the lateral factory. Calls removeAll
- * on the cache.
+ * Gets the cache that was injected by the lateral factory. Calls removeAll on the cache.
* <p>
* @see org.apache.jcs.engine.behavior.ICacheListener#handleRemoveAll(java.lang.String)
*/
@@ -264,8 +265,7 @@
}
/**
- * Gets the cache that was injected by the lateral factory. Calls get on the
- * cache.
+ * Gets the cache that was injected by the lateral factory. Calls get on the cache.
* <p>
* @param cacheName
* @param key
@@ -314,8 +314,8 @@
/**
* Gets the cacheManager attribute of the LateralCacheTCPListener object.
* <p>
- * Normally this is set by the factory. If it wasn't set the listener
- * defaults to the expected singleton behavior of the cache amanger.
+ * Normally this is set by the factory. If it wasn't set the listener defaults to the expected
+ * singleton behavior of the cache amanger.
* <p>
* @param name
* @return CompositeCache
@@ -363,8 +363,7 @@
}
/**
- * @param cacheMgr
- * The cacheMgr to set.
+ * @param cacheMgr The cacheMgr to set.
*/
public void setCacheManager( ICompositeCacheManager cacheMgr )
{
@@ -380,8 +379,7 @@
}
/**
- * @param tcpLateralCacheAttributes
- * The tcpLateralCacheAttributes to set.
+ * @param tcpLateralCacheAttributes The tcpLateralCacheAttributes to set.
*/
public void setTcpLateralCacheAttributes( ITCPLateralCacheAttributes tcpLateralCacheAttributes )
{
@@ -397,8 +395,8 @@
}
/**
- * Processes commands from the server socket. There should be one listener
- * for each configured TCP lateral.
+ * Processes commands from the server socket. There should be one listener for each configured
+ * TCP lateral.
*/
public class ListenerThread
extends Thread
@@ -444,12 +442,12 @@
}
/**
- * A Separate thread taht runs when a command comes into the
- * LateralTCPReceiver.
+ * A Separate thread taht runs when a command comes into the LateralTCPReceiver.
*/
public class ConnectionHandler
implements Runnable
{
+ /** The socket connection, passed in via constructor */
private Socket socket;
/**
@@ -532,8 +530,8 @@
}
/**
- * This calls the appropriate method, based on the command sent in the
- * Lateral element descriptor.
+ * This calls the appropriate method, based on the command sent in the Lateral element
+ * descriptor.
* <p>
* @param led
* @throws IOException
@@ -604,14 +602,14 @@
/**
* Allows us to set the daemon status on the executor threads
* <p>
- * @author aaronsm
+ * @author Aaron Smuts
*/
class MyThreadFactory
implements ThreadFactory
{
- /*
- * (non-Javadoc)
- * @see EDU.oswego.cs.dl.util.concurrent.ThreadFactory#newThread(java.lang.Runnable)
+ /**
+ * @param runner
+ * @return daemon thread
*/
public Thread newThread( Runnable runner )
{
Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/TCPLateralCacheAttributes.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/TCPLateralCacheAttributes.java?rev=705689&r1=705688&r2=705689&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/TCPLateralCacheAttributes.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/TCPLateralCacheAttributes.java Fri Oct 17 11:11:11 2008
@@ -35,18 +35,25 @@
/** Don't change. */
private static final long serialVersionUID = 1077889204513905220L;
+ /** default */
private static final String DEFAULT_UDP_DISCOVERY_ADDRESS = "228.5.6.7";
+ /** default */
private static final int DEFAULT_UDP_DISCOVERY_PORT = 6789;
+ /** default */
private static final boolean DEFAULT_UDP_DISCOVERY_ENABLED = true;
+ /** default */
private static final boolean DEFAULT_ALLOW_GET = true;
+ /** default */
private static final boolean DEFAULT_ALLOW_PUT = true;
+ /** default */
private static final boolean DEFAULT_ISSUE_REMOVE_FOR_PUT = false;
+ /** default */
private static final boolean DEFAULT_FILTER_REMOVE_BY_HASH_CODE = true;
// TCP --------------------------------------------
Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryManager.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryManager.java?rev=705689&r1=705688&r2=705689&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryManager.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryManager.java Fri Oct 17 11:11:11 2008
@@ -30,22 +30,23 @@
import org.apache.jcs.engine.logging.behavior.ICacheEventLogger;
/**
- * This manages UDPDiscovery Services. We should end up with one service per
- * Lateral Cache Manager Instance. One service works for multiple regions. We
- * don't want a connection for each region.
+ * This manages UDPDiscovery Services. We should end up with one service per Lateral Cache Manager
+ * Instance. One service works for multiple regions. We don't want a connection for each region.
* <p>
* @author Aaron Smuts
- *
*/
public class UDPDiscoveryManager
{
+ /** The logger */
private final static Log log = LogFactory.getLog( UDPDiscoveryManager.class );
+ /** Singleton instance */
private static UDPDiscoveryManager INSTANCE = new UDPDiscoveryManager();
+ /** Known services */
private Map services = new HashMap();
-
+ /** private for singleton */
private UDPDiscoveryManager()
{
// noopt
@@ -53,7 +54,7 @@
/**
* Singelton
- *
+ * <p>
* @return UDPDiscoveryManager
*/
public static UDPDiscoveryManager getInstance()
@@ -63,18 +64,20 @@
/**
* Returns the UDP Discovery service associated with this instance.
- *
- * @param lca
- * ITCPLateralCacheAttributes
+ * <p>
+ * @param lca ITCPLateralCacheAttributes
* @param cacheMgr
- * @param cacheEventLogger
- * @param elementSerializer
+ * @param cacheEventLogger
+ * @param elementSerializer
* @return instance for this address
*/
- public synchronized UDPDiscoveryService getService( ITCPLateralCacheAttributes lca, ICompositeCacheManager cacheMgr, ICacheEventLogger cacheEventLogger,
+ public synchronized UDPDiscoveryService getService( ITCPLateralCacheAttributes lca,
+ ICompositeCacheManager cacheMgr,
+ ICacheEventLogger cacheEventLogger,
IElementSerializer elementSerializer )
{
- UDPDiscoveryService service = getService( lca.getUdpDiscoveryAddr(), lca.getUdpDiscoveryPort(), lca.getTcpListenerPort(), cacheMgr, cacheEventLogger, elementSerializer );
+ UDPDiscoveryService service = getService( lca.getUdpDiscoveryAddr(), lca.getUdpDiscoveryPort(), lca
+ .getTcpListenerPort(), cacheMgr, cacheEventLogger, elementSerializer );
// TODO find a way to remote these attributes from the service, the manager needs it on disocvery.
service.setTcpLateralCacheAttributes( lca );
@@ -85,18 +88,19 @@
* Creates a service for the address and port if one doesn't exist already.
* <p>
* TODO we may need to key this using the listener port too
- *
+ * <p>
* @param discoveryAddress
* @param discoveryPort
* @param servicePort
* @param cacheMgr
- * @param cacheEventLogger
- * @param elementSerializer *
+ * @param cacheEventLogger
+ * @param elementSerializer
* @return UDPDiscoveryService
*/
private synchronized UDPDiscoveryService getService( String discoveryAddress, int discoveryPort, int servicePort,
- ICompositeCacheManager cacheMgr, ICacheEventLogger cacheEventLogger,
- IElementSerializer elementSerializer )
+ ICompositeCacheManager cacheMgr,
+ ICacheEventLogger cacheEventLogger,
+ IElementSerializer elementSerializer )
{
String key = discoveryAddress + ":" + discoveryPort;
@@ -108,7 +112,8 @@
log.info( "Creating service for address:port [" + key + "]" );
}
- service = new UDPDiscoveryService( discoveryAddress, discoveryPort, servicePort, cacheMgr, cacheEventLogger, elementSerializer );
+ service = new UDPDiscoveryService( discoveryAddress, discoveryPort, servicePort, cacheMgr,
+ cacheEventLogger, elementSerializer );
services.put( key, service );
}
@@ -118,7 +123,5 @@
}
return service;
-
}
-
}
Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryMessage.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryMessage.java?rev=705689&r1=705688&r2=705689&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryMessage.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryMessage.java Fri Oct 17 11:11:11 2008
@@ -43,15 +43,19 @@
*/
public static final int REQUEST_BROADCAST = 1;
+ /** The message type */
private int messageType = PASSIVE_BROADCAST;
+ /** udp port */
private int port = 6789;
+ /** UDP host */
private String host = "228.5.6.7";
- /** Description of the Field */
+ /** Id of the requestor, allows self-filtration */
private long requesterId;
+ /** Names of regions */
private ArrayList cacheNames = new ArrayList();
/**
Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryReceiver.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryReceiver.java?rev=705689&r1=705688&r2=705689&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryReceiver.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryReceiver.java Fri Oct 17 11:11:11 2008
@@ -59,27 +59,31 @@
/** The socket used for communication. */
private MulticastSocket m_socket;
- // todo consider using the threadpool manager to
- // get this thread pool
- // for now place a tight restrcition on the pool size
+ /**
+ * TODO: Consider using the threadpool manager to get this thread pool. For now place a tight
+ * restriction on the pool size
+ */
private static final int maxPoolSize = 10;
+ /** The processor */
private PooledExecutor pooledExecutor = null;
- // number of messages received.
+ /** number of messages received. For debugging and testing. */
private int cnt = 0;
- /**
- * Service to get cache names and hande request broadcasts
- */
+ /** Service to get cache names and hande request broadcasts */
protected UDPDiscoveryService service = null;
+ /** Address */
private String multicastAddressString = "";
+ /** The port */
private int multicastPort = 0;
+ /** The cache manager. */
private ICompositeCacheManager cacheMgr;
+ /** Is it shutdown. */
private boolean shutdown = false;
/** The event logger. */
@@ -271,6 +275,7 @@
public class MessageHandler
implements Runnable
{
+ /** The message to handle. Passed in during construction. */
private UDPDiscoveryMessage message = null;
/**
@@ -397,7 +402,7 @@
{
Thread t = new Thread( runner );
String oldName = t.getName();
- t.setName( "JCS-UDPDiscoveryReceiver-" + oldName );
+ t.setName( "JCS-UDPDiscoveryReceiver-" + oldName );
t.setDaemon( true );
t.setPriority( Thread.MIN_PRIORITY );
return t;
Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoverySender.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoverySender.java?rev=705689&r1=705688&r2=705689&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoverySender.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoverySender.java Fri Oct 17 11:11:11 2008
@@ -33,18 +33,21 @@
/**
* This is a generic sender for the UDPDiscovery process.
- *
+ * <p>
* @author Aaron Smuts
- *
*/
public class UDPDiscoverySender
{
+ /** The logger. */
private final static Log log = LogFactory.getLog( UDPDiscoverySender.class );
+ /** The socket */
private MulticastSocket m_localSocket;
+ /** The address */
private InetAddress m_multicastAddress;
+ /** The port */
private int m_multicastPort;
/**
@@ -53,10 +56,8 @@
* This sender can be used to send multiple messages.
* <p>
* When you are done sending, you should destroy the socket sender.
- *
* @param host
* @param port
- *
* @exception IOException
*/
public UDPDiscoverySender( String host, int port )
@@ -81,7 +82,6 @@
/**
* Closes the socket connection.
- *
*/
public void destroy()
{
@@ -102,7 +102,6 @@
/**
* Just being careful about closing the socket.
- *
* @throws Throwable
*/
public void finalize()
@@ -114,7 +113,6 @@
/**
* Send messages.
- *
* @param message
* @throws IOException
*/
@@ -159,10 +157,8 @@
}
/**
- * Ask other to broadcast their info the the multicast address. If a lateral
- * is non receiving it can use this. This is also called on startup so we
- * can get info.
- *
+ * Ask other to broadcast their info the the multicast address. If a lateral is non receiving it
+ * can use this. This is also called on startup so we can get info.
* @throws IOException
*/
public void requestBroadcast()
@@ -180,11 +176,9 @@
}
/**
- * This sends a message braodcasting our that the host and port is available
- * for connections.
+ * This sends a message braodcasting our that the host and port is available for connections.
* <p>
* It uses the vmid as the requesterDI
- *
* @param host
* @param port
* @param cacheNames
@@ -198,7 +192,6 @@
/**
* This allows you to set the sender id. This is mainly for testing.
- *
* @param host
* @param port
* @param cacheNames
@@ -225,7 +218,6 @@
/**
* This allows us to get the byte array from an output stream.
- *
* @author asmuts
* @created January 15, 2002
*/
@@ -235,7 +227,6 @@
{
/**
* Gets the bytes attribute of the MyByteArrayOutputStream object
- *
* @return The bytes value
*/
public byte[] getBytes()
Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoverySenderThread.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoverySenderThread.java?rev=705689&r1=705688&r2=705689&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoverySenderThread.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoverySenderThread.java Fri Oct 17 11:11:11 2008
@@ -42,8 +42,10 @@
/** the host and port we listen on for TCP socket connections */
private String myHostName = null;
+ /** The udp port */
private int myPort = 0;
+ /** List of known regions. */
private ArrayList cacheNames = new ArrayList();
/**
Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryService.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryService.java?rev=705689&r1=705688&r2=705689&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryService.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryService.java Fri Oct 17 11:11:11 2008
@@ -61,24 +61,31 @@
/** thread that listens for messages */
private Thread udpReceiverThread;
- // the runanble that the receiver thread runs
+ /** the runanble that the receiver thread runs */
private UDPDiscoveryReceiver receiver;
+ /** Map of facades */
private Map facades = new HashMap();
- // the runanble that sends messages via the clock daemon
+ /** the runnanble that sends messages via the clock daemon */
private UDPDiscoverySenderThread sender = null;
+ /** The host address */
private String hostAddress = "unknown";
+ /** THe udp address */
private String discoveryAddress;
+ /** The port to braodcast to. */
private int discoveryPort;
- // the port this service runs on, the service we are telling other about
- // we should have a service info object instead
+ /**
+ * the port this service runs on, the service we are telling other about. we should have a
+ * service info object instead
+ */
private int servicePort;
+ /** Attributes for creating new instances. */
private ITCPLateralCacheAttributes tcpLateralCacheAttributes;
/** The event logger. */
@@ -257,7 +264,8 @@
/**
* Get all the cache names we have facades for.
- * @return
+ * <p>
+ * @return ArrayList
*/
protected ArrayList getCacheNames()
{
@@ -290,7 +298,7 @@
{
Thread t = new Thread( runner );
String oldName = t.getName();
- t.setName( "JCS-UDPDiscoveryService-" + oldName );
+ t.setName( "JCS-UDPDiscoveryService-" + oldName );
t.setDaemon( true );
t.setPriority( Thread.MIN_PRIORITY );
return t;
Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/utils/SocketOpener.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/utils/SocketOpener.java?rev=705689&r1=705688&r2=705689&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/utils/SocketOpener.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/utils/SocketOpener.java Fri Oct 17 11:11:11 2008
@@ -23,24 +23,26 @@
import java.net.Socket;
/**
- * Socket openere that will timeout on the initial connect rather than block
+ * This should no longer be needed.
+ * <p>
+ * Socket opener that will timeout on the initial connect rather than block
* forever. Technique from core java II.
- *
- * @version $Id$
*/
public class SocketOpener
implements Runnable
{
-
+ /** The host */
private String host;
+ /** The port. */
private int port;
+ /** The socket */
private Socket socket;
/**
- * Opens a socket with a connection timeout value. Joins against a backgroud
- * thread that does the openeing.
+ * Opens a socket with a connection timeout value. Joins against a background
+ * thread that does the opening.
*
* @param host
* @param port