Distributed cache mode uses EventServer
components (of class atg.adapter.gsa.event.GSAEventServer
) to communicate distributed cache mode events with each other. All SQL repository instances in a given JVM use the same EventServer
instance. The Nucleus address of the EventServer
component is specified by the eventServer
property of the GSARepository
component. The default EventServer
component is /atg/dynamo/server/SQLRepositoryEventServer
. When an ATG application starts, the first repository that uses distributed cache mode causes the EventServer
instance to be created. At this time, the EventServer
opens up a server socket on either a specific port or a randomly assigned port (a randomly assigned port is used if the EventServer
uses port=0
, which is the default setting).
When an item is modified by one ATG server, a cache invalidation event is sent to all other servers that might cache that item type. At this time, a persistent connection is created to all other EventServer
components in the cluster as listed in the das_gsa_subscriber
table. Events are written into this connection.
When the EventServer
receives a GSAEvent
, which contains an item descriptor name, it looks up the EventListener
for that item descriptor name and sends the event to the matching repository. GSARepository
implements the GSAEventListener
interface. When a GSARepository
component receives a GSAEvent
, it removes the item identified by the GSAEvent
from its cache.
When an EventServer
attempts to connect to an ATG server, it may not be able to establish a connection immediately. For example, if the server’s JVM is performing garbage collection, the connection will not be established until garbage collection is completed. Therefore, the EventServer
waits a certain amount of time before timing out the connection. By default, it waits 60 seconds, but you can specify a different value with the connectTimeout
property of the EventServer
component. You specify this property value in milliseconds. For example, to set the timeout to 2 minutes:
connectTimeout=120000
If an ATG server fails to connect to another server, it prints a warning message and removes the das_gsa_subscriber
row for that item type for that server. When the ATG server sends an event, it also checks to make sure the current EventServer
instance is still in the table. If not, it prints a warning and adds itself back in.
When an ATG application starts up, the EventServer
broadcasts a dummy invalidation event. This dummy event is used to form all of the connections that may be required and to ensure that the das_gsa_subscriber
table is valid and properly updated for all item types. Also note that distributed cache mode is used by the internally defined item descriptor used to access the das_gsa_subscriber
table. This is necessary so that other servers can be made aware dynamically of changes made to this table while the server is running.
checkSubscriptions() Method
The GSARepository
class has a checkSubscriptions()
method that can be called periodically (e.g., by a scheduled service) to ensure that the repository is still subscribed to events for items with cache-mode="distributed"
. When another server fails to connect to the EventServer
, the EventServer
removes the server from the das_gsa_subscriber
table. The checkSubscriptions()
method issues one query on this table for each item descriptor in the repository with cache-mode="distributed"
; if the method determines that a server has been removed from the table, it issues a warning and flushes the caches of the affected item types to ensure that no invalid data is maintained in the caches.