Learning through samples
There are three samples shipped with this toolkit that demonstrate how to achieve cross DC failover either in active/active or active/passive modes.
- CrossDataCenterFailoverSample shows how to use the toolkit when the application don't use the Streams consistent region feature.
-
CrossDataCenterFailoverCRSample shows how to use the toolkit when the application uses the Streams consistent region feature.
-
CrossDataCenterFailoverPassiveSample shows how to the toolkit to run in an active/passive mode.
Check the samples SPL code comments for detailed explanations.
Running the samples in active/active mode
The following streamtool commands demonstrate how to run two identical copies of an application in active/active mode.
# In the first data center
streamtool submitjob -d <YOUR_DC1_STREAMS_DOMAIN> -i <YOUR_DC1_STREAMS_INSTANCE> output/com.teracloud.streams.crossdc.failover.sample.CrossDataCenterFailoverSample.sab -P configFileName=<YOUR_DC1_CROSSDC_CONFIG_FILE> -C tracing=info
# in the second data center
streamtool submitjob -d <YOUR_DC2_STREAMS_DOMAIN> -i <YOUR_DC2_STREAMS_INSTANCE> output/com.teracloud.streams.crossdc.failover.sample.CrossDataCenterFailoverSample.sab -P configFileName=<YOUR_DC2_CROSSDC_CONFIG_FILE> -C tracing=info
Running the samples in active/passive mode
Please follow the detailed directions available in the CrossDataCenterFailoverPassiveSample.spl file to run it.
The following streamtool commands demonstrate how to run one sample in active mode and CrossDataCenterFailoverPassiveSample as a standalone application in passive mode.
# In the first data center
streamtool submitjob -d <YOUR_DC1_STREAMS_DOMAIN> -i <YOUR_DC1_STREAMS_INSTANCE> output/com.teracloud.streams.crossdc.failover.sample.CrossDataCenterFailoverSample.sab -P configFileName=<YOUR_DC1_CROSSDC_CONFIG_FILE> -C tracing=info
# In the second data center
cd samples/CrossDataCenterFailoverPassiveSample/output/bin
./standalone configFileName=<YOUR_DC2_CROSSDC_PASSIVE_CONFIG_FILE> shellScriptName=<YOUR_DC2_CROSSDC_FAILOVER_SHELL_SCRIPT>