Call us: +1-415-738-4000
This sample application demonstrates the Big Memory WAN Replication service for Big Memory Max clusters. WAN replication enables two or more BigMemory Max clusters to share data in an eventually consistent manner.
The scenario simulated by this application involves two BigMemory Max clusters, named Region-1 and Region-2. Any data stored in Region-1 will be shown to be replicated to Region-2, and vice versa.
You can run the sample application on a single machine, or on machines that are actually connected via WAN. To run the demo on different machines, you need to specify the correct IP:PORT addresses in the xml configuration files.
The sample application is located under
In order to run the sample application, you must have Java 1.6 or higher and you must set
JAVA_HOME as follows:
For Windows, use the following command:
set JAVA_HOME="<path to java home>"
For UNIX/Linux, use the following command:
export JAVA_HOME="<path to java home>"
If you intend to modify the source code of the application and build it, you will also need Maven.
Run the application to demonstrate the WAN replication.
Note: The list of all commands is available by typing
In the wan-config-region-1.xml and wan-config-region-2.xml files, replace the "wan-samples-root-dir" placeholder with the actual location of the folder (for example, $WAN_SAMPLES/).
Launch the Region-1 TSA using the command
start-sample-server-1.sh (for UNIX/Linux) or
start-sample-server-1.bat (for Windows).
Launch the Region-2 TSA using the command
start-sample-server-2.sh (for UNIX/Linux) or
start-sample-server-2.bat (for Windows).
Launch the Region-1 WAN Orchestrator using the command
start-orch-1.sh (for UNIX/Linux) or
start-orch-1.bat (for Windows).
Launch the Region-2 WAN Orchestrator using the command
start-orch-2.sh (for UNIX/Linux) or
start-orch-2.bat (for Windows).
Now that the TSA and WAN services for regions 1 and 2 have started, we are ready to run the application and demonstrate the replication process.
Start the Region-1 application using the command
run.sh (for UNIX/Linux) or
run.bat (for Windows). You should see a command prompt which indicates that the application has started and is ready to accept various instructions.
At the command prompt type:
> connect localhost:9510 bar
bar is a sample cache name. You can use any name you want. This will start the application's cache manager and will make the Region-1 cluster operational.
Start the Region-2 application, but at the command prompt, type:
> connect localhost:9610 bar
bar is a sample cache name. You can use any name you want. This will start the application's cache manager and will make the Region-2 cluster operational.
Store some elements in the Region-1 TSA by typing the following command on the Region-1 application:
> fill 100
This command will put 100 keys named k0, k1, ... k99 with values v0, v1, ... , v99 into Region-1.
See if the elements have been replicated to the Region-2 TSA by typing the following command on the Region-2 application:
> get k0
You should see
[k0, v0] as the result, which indicates that the key k0, which was inserted on Region-1, was successfully replicated to Region-2.
Change the k0 value from Region-2 by typing the following command:
> put k0 baz
This "put", which happened on Region-2, should now be visible in Region-1. Type the following command on the command prompt of Region-1:
> get k0
You should see
[k0, baz] as the result, which indicates successful replication.
To terminate and clean up the application, use the scripts
stop-*.sh (for UNIX/Linux) or
stop-*.bat (for Windows). Alternatively, kill all the Java processes by sending a CTRL-C signal.