haOverflow.README.html Maven / Gradle / Ivy
vFabric™ GemFire®
HA Overflow
Java Caching API Programming Example
The haOverflow example has a CacheServer
that allows HA queue overflow. The server starts with eviction-policy
as entry
, implying
that eviction of the client HA queues is based on the number of entries. Other options for
this parameter include mem
, or memory, which means the queue eviction is based on the
memory/size of the client HA queue.
Available specifications for this parameter are as follows :
none
implying no overflow
mem
implying memory-based overflow, threshold in MB
entry
implying entry-based overflow, threshold as number of entries
The capacity parameter dictates the queue capacity, before the queue is faulted to
the disk. It should be set to "Number of Entries" for policy as entry
, and "Memory size in MB"
for mem
eviction. The disk directory for overflow is specified with the overflow-directory
parameter, and is set to $CWD/backupDirectory
. You can check the contents of this overflow directory as the example executes.
The haOverflow
example is located in the GemFire installation under examples/dist/haOverflow
.
Start two terminal sessions, or shells. In each shell, configure your
environment according to the instructions provided in
examples/EnvSetup.html.
Once your environment is set, change to the examples/dist/haOverflow
directory in both shells to run the application. You may wish to configure the example
to run with non-default connection properties (to use a unique mcast-port,
for example). To do this, change the mcast-port
value
in the server_gemfire.properties
file.
The application takes a cache server configuration file in input. You can use the example
configuration files provided in the example directory, or you can create and test your own.
This sample uses examples/haOverflow/server.xml
file for
cache initialization.
Start the server in one shell using this command, entered on a single line:
java -DgemfirePropertyFile=server_gemfire.properties haOverflow.HACacheServer server.xml
Once started, the server waits for clients to connect. It is set up to create an overflow for
HA event queues that can include get
and put
events, for example.
The following examples guide you through a simple exercise using entry overflow,
but you are encouraged to try your own.
Running the Durable Client Manager to simulate an event downflow
Start the HADurableClientMgr
in the other shell using this command, entered on a single line:
java -DgemfirePropertyFile=client_gemfire.properties haOverflow.HADurableClientMgr client.xml
The HADurableClientMgr
example runs three cache clients sequentially in the same distributed system.
The cache clients define the same cache region, named cs_region
.
The first cache client is a durable client, which registers with the server and disconnects
with a keepalive
option. This in effect lets the server keep the event queues for the durable
client open. The default timeout for the queues is 300 seconds.
Subsequently, the second cache client connects and feeds data into the cs_region
region. This
data population gets events populated in the queues for the durable clients. The queue overflows
to the disk once the threshold set earlier in the server is breached.
Finally, the third cache client connects and starts the durable client again. This causes the server to fetch all applicable events from the disk and flush them to the client.
To end this example, press CTRL-C
in the server and client shells, then enter exit
in both shells to close them.
Optionally, you can start HADurableClient
and HAFeederClient
, each in a separate shell, and have more control over when the overflow happens.
Running the HADurableClient and HAFeederClient separately
Running the Durable Client
To try out HADurableClient
with these configuration files, run:
java -DgemfirePropertyFile=durable_client_gemfire.properties haOverflow.HADurableClient client.xml
- Running the Feeder Client
To try out HAFeederClient
with these configuration files, run:
java -DgemfirePropertyFile=client_gemfire.properties haOverflow.HAFeederClient client.xml
This starts the cache client and initializes their caches.