|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object atg.nucleus.logging.VariableArgumentApplicationLoggingImpl atg.nucleus.GenericService atg.nucleus.TimedOperationService atg.server.tcp.RequestServer atg.rview.InvalidationRelay
public class InvalidationRelay
The InvalidationRelay is used to broadcast cache invalidations from one RelationalViewManager to other RelationalViewManagers, thereby allowing them to keep their caches in sync. This service is a TCP server, so that other InvalidationRelays can connect to this and direct the local RelationalViewManagers to invalidate their caches. This service also acts as a TCP client to connect to remote RelationalViewManagers and direct them to invalidate their caches.
Each InvalidationRelay recognizes that there may be more than one RelationalViewManager running in a Dynamo, each of which needs to communicate with the corresponding RelationalViewManager in other Dynamos. To make this work, an InvalidationRelay requires each local RelationalViewManager to register itself with a name through the method registerCacheInvalidationListener. When a RelationalViewManager sends a message to invalidate a cache, it also sends its own name. The message will then be broadcast to other InvalidationRelays, which will then pass the message to their own local RelationalViewManagers registered with that name. It is therefore important that RelationalViewManagers keep consistent names across Dynamos - this is usually done by making the name be the Nucleus name of the RelationalViewManager service, and making sure that corresponding RelationalViewManagers have the same Nucleus names in other Dynamos. It is also important that the corresponding RelationalViewManagers be running the same relational view definition files, or else the cache invalidations will not make much sense.
The InvalidationRelay is configured with a list of host/port entries to which it will attempt to relay its cache invalidations. Whenever it successfully connects to another InvalidationRelay, it will immediately notify that relay to invalidate all of its caches, since the caches may have gotten out of sync while the relays were disconnected.
If a connection fails, the relay will attempt to reconnect, but only after a period specified by "clientReconnectTime".
The protocol looks like this:
Upon connection, the connector sends a magic# and a protocol version 0xfacade99 (int) version# (int, starting with 0x0001) For each group of invalidations: destination (String, 0-length means all) # of invalidations (int) for each invalidation: invalidation type (byte) INVALIDATE_ALL_CACHES (no further info) INVALIDATE_CACHES_BY_TABLE_NAME table name (String) INVALIDATE_CACHE cache name (String) INVALIDATE_CACHE_ENTRY cache name (String) # key elements (int) each key element (KeyObject) INVALIDATE_CACHE_ENTRIES cache name (String) # cache keys (int) each cache key: # key elements (int) each key element (KeyObject)
And the format for a KeyObject:
TYPE_NULL TYPE_BOOLEAN value (boolean) TYPE_BYTE value (byte) TYPE_SHORT value (short) TYPE_INTEGER value (int) TYPE_LONG value (long) TYPE_FLOAT value (float) TYPE_DOUBLE value (double) TYPE_STRING value (String) TYPE_DATE msec value (long) TYPE_TIME msec value (long) TYPE_TIMESTAMP msec value (long) TYPE_BIGDECIMAL String value (String)
Field Summary | |
---|---|
static java.lang.String |
CLASS_VERSION
|
static int |
INVALIDATE_ALL_CACHES
|
static int |
INVALIDATE_CACHE
|
static int |
INVALIDATE_CACHE_ENTRIES
|
static int |
INVALIDATE_CACHE_ENTRY
|
static int |
INVALIDATE_CACHES_BY_TABLE_NAME
|
static int |
MAGIC_NUMBER
|
java.util.Dictionary |
mCacheInvalidationListeners
|
static int |
PROTOCOL_VERSION
|
static int |
TYPE_BIGDECIMAL
|
static int |
TYPE_BOOLEAN
|
static int |
TYPE_BYTE
|
static int |
TYPE_DATE
|
static int |
TYPE_DOUBLE
|
static int |
TYPE_FLOAT
|
static int |
TYPE_INTEGER
|
static int |
TYPE_LONG
|
static int |
TYPE_NULL
|
static int |
TYPE_SHORT
|
static int |
TYPE_STRING
|
static int |
TYPE_TIME
|
static int |
TYPE_TIMESTAMP
|
Fields inherited from class atg.server.tcp.RequestServer |
---|
DEFAULT_BACKLOG, mAllowedConnection, mAllowedConnectionMatcher, mBacklog, mEnabled, mHandlerCount, mHostAddr, mHostName, mLocalPort, mPort, mPortRegistry, mReadTimeout |
Fields inherited from class atg.nucleus.GenericService |
---|
SERVICE_INFO_KEY |
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging |
---|
DEFAULT_LOG_TRACE_STATUS |
Fields inherited from interface atg.nucleus.logging.ApplicationLogging |
---|
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS |
Constructor Summary | |
---|---|
InvalidationRelay()
|
Method Summary | |
---|---|
void |
broadcastInvalidationCommand(java.lang.String pDestination,
atg.rview.CacheInvalidationCommand pCommand)
Queues the specified cache invalidation command to be broadcast to RelationalViewManagers registered with the given destination. |
void |
broadcastInvalidationCommands(java.lang.String pDestination,
atg.rview.CacheInvalidationCommand[] pCommands)
Queues the specified cache invalidation commands to be broadcast to RelationalViewManagers registered with the given destination. |
protected javax.servlet.Servlet |
createAdminServlet()
Creates and returns a new Servlet that will administer this service. |
protected RequestServerHandler |
createHandler(java.lang.ThreadGroup pGroup,
java.lang.String pThreadName,
java.net.Socket pSocket)
Constructs a new RequestServerHandler. |
void |
deregisterIncomingClient(atg.rview.InvalidationRelayRequestHandler pHandler)
Notifies the relay that an incoming client has detached |
void |
doStartService()
Sets up the clients |
CacheInvalidationListener |
getCacheInvalidationListener(java.lang.String pName)
Returns the CacheInvalidationListener registered with the given name, or null if none is registered with that name. |
long |
getClientReconnectTime()
|
boolean |
getHasClients()
Returns true if there are any clients to send invalidations to. |
java.net.InetAddress[] |
getRemoteRelayHosts()
|
int[] |
getRemoteRelayPorts()
|
boolean |
isInvalidateAllOnConnect()
|
void |
registerCacheInvalidationListener(java.lang.String pName,
CacheInvalidationListener pListener)
Registers a local CacheInvalidationListener (probably a RelationalViewManager) with the given name. |
void |
registerIncomingClient(atg.rview.InvalidationRelayRequestHandler pHandler)
Notifies the relay that an incoming client has attached |
void |
setClientReconnectTime(long pClientReconnectTime)
|
void |
setInvalidateAllOnConnect(boolean pInvalidateAllOnConnect)
|
void |
setRemoteRelayHosts(java.net.InetAddress[] pRemoteRelayHosts)
|
void |
setRemoteRelayPorts(int[] pRemoteRelayPorts)
|
Methods inherited from class atg.nucleus.TimedOperationService |
---|
getAverageRequestHandlingTime, getHandledRequestCount, getRequestStartTime, getTotalRequestHandlingTime, isKeepingStatistics, notifyHandledRequest, resetStatistics, setKeepingStatistics |
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl |
---|
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.lang.String CLASS_VERSION
public static final int MAGIC_NUMBER
public static final int PROTOCOL_VERSION
public static final int INVALIDATE_ALL_CACHES
public static final int INVALIDATE_CACHES_BY_TABLE_NAME
public static final int INVALIDATE_CACHE
public static final int INVALIDATE_CACHE_ENTRY
public static final int INVALIDATE_CACHE_ENTRIES
public static final int TYPE_NULL
public static final int TYPE_BOOLEAN
public static final int TYPE_BYTE
public static final int TYPE_SHORT
public static final int TYPE_INTEGER
public static final int TYPE_LONG
public static final int TYPE_FLOAT
public static final int TYPE_DOUBLE
public static final int TYPE_STRING
public static final int TYPE_DATE
public static final int TYPE_TIME
public static final int TYPE_TIMESTAMP
public static final int TYPE_BIGDECIMAL
public java.util.Dictionary mCacheInvalidationListeners
Constructor Detail |
---|
public InvalidationRelay()
Method Detail |
---|
public long getClientReconnectTime()
public void setClientReconnectTime(long pClientReconnectTime)
public java.net.InetAddress[] getRemoteRelayHosts()
public void setRemoteRelayHosts(java.net.InetAddress[] pRemoteRelayHosts)
public int[] getRemoteRelayPorts()
public void setRemoteRelayPorts(int[] pRemoteRelayPorts)
public boolean isInvalidateAllOnConnect()
public void setInvalidateAllOnConnect(boolean pInvalidateAllOnConnect)
public void registerCacheInvalidationListener(java.lang.String pName, CacheInvalidationListener pListener)
public CacheInvalidationListener getCacheInvalidationListener(java.lang.String pName)
public boolean getHasClients()
public void broadcastInvalidationCommand(java.lang.String pDestination, atg.rview.CacheInvalidationCommand pCommand)
public void broadcastInvalidationCommands(java.lang.String pDestination, atg.rview.CacheInvalidationCommand[] pCommands)
protected RequestServerHandler createHandler(java.lang.ThreadGroup pGroup, java.lang.String pThreadName, java.net.Socket pSocket)
createHandler
in class RequestServer
pGroup
- the ThreadGroup to which the new handler should belongpThreadName
- the name that should be assigned to the
handler's thread.pSocket
- the socket that the handler should use to perform
its one-shot request. If null, then the handler should obtain
sockets by calling "acceptConnection".public void registerIncomingClient(atg.rview.InvalidationRelayRequestHandler pHandler)
public void deregisterIncomingClient(atg.rview.InvalidationRelayRequestHandler pHandler)
public void doStartService() throws ServiceException
doStartService
in class RequestServer
ServiceException
- if there was a problemprotected javax.servlet.Servlet createAdminServlet()
createAdminServlet
in class GenericService
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |