Chapter 3. Performing Cross-Site Replication Operations
Bring sites online and offline. Transfer cache state to remote sites.
3.1. Performing Cross-Site Operations with the CLI Copy linkLink copied to clipboard!
The Data Grid command line interface lets you remotely connect to Data Grid servers, manage sites, and push state transfer to backup locations.
Prerequisites
- Start the Data Grid CLI.
- Connect to a running Data Grid cluster.
3.1.1. Bringing Backup Locations Offline and Online Copy linkLink copied to clipboard!
Take backup locations offline manually and bring them back online.
Procedure
- Create a CLI connection to Data Grid.
Check if backup locations are online or offline with the
site statuscommand:[//containers/default]> site status --cache=cacheName --site=NYCNote--siteis an optional argument. If not set, the CLI returns all backup locations.Manage backup locations as follows:
Bring backup locations online with the
bring-onlinecommand:[//containers/default]> site bring-online --cache=customers --site=NYCTake backup locations offline with the
take-offlinecommand:[//containers/default]> site take-offline --cache=customers --site=NYC
For more information and examples, run the help site command.
3.1.2. Configuring Cross-Site State Transfer Modes Copy linkLink copied to clipboard!
You can configure cross-site state transfer operations to happen automatically when Data Grid detects that backup locations come online. Alternatively you can use the default mode, which is to manually perform state transfer through the CLI or via JMX or REST.
Procedure
- Create a CLI connection to Data Grid.
Use the
sitecommand to configure state transfer modes, as in the following examples:Retrieve the current state transfer mode.
[//containers/default]> site state-transfer-mode get --cache=cacheName --site=NYC "MANUAL"- Configure automatic state transfer operations for a cache and backup location.
[//containers/default]> site state-transfer-mode set --cache=cacheName --site=NYC --mode=AUTO
Run the help site command for more information and examples.
3.1.3. Pushing State to Backup Locations Copy linkLink copied to clipboard!
Transfer cache state to remote backup locations.
Procedure
- Create a CLI connection to Data Grid.
Use the
sitecommand to push state transfer, as in the following example:[//containers/default]> site push-site-state --cache=cacheName --site=NYC
For more information and examples, run the help site command.
Reference
3.2. Performing Cross-Site Operations with the REST API Copy linkLink copied to clipboard!
Data Grid servers provide a REST API that allows you to perform cross-site operations.
3.2.1. Getting Status of All Backup Locations Copy linkLink copied to clipboard!
Retrieve the status of all backup locations with GET requests.
GET /v2/caches/{cacheName}/x-site/backups/
Data Grid responds with the status of each backup location in JSON format, as in the following example:
{
"NYC": "online",
"LON": "offline"
}
| Value | Description |
|---|---|
|
| All nodes in the local cluster have a cross-site view with the backup location. |
|
| No nodes in the local cluster have a cross-site view with the backup location. |
|
| Some nodes in the local cluster have a cross-site view with the backup location, other nodes in the local cluster do not have a cross-site view. The response indicates status for each node. |
3.2.2. Getting Status of Specific Backup Locations Copy linkLink copied to clipboard!
Retrieve the status of a backup location with GET requests.
GET /v2/caches/{cacheName}/x-site/backups/{siteName}
Data Grid responds with the status of each node in the site in JSON format, as in the following example:
{
"NodeA":"offline",
"NodeB":"online"
}
| Value | Description |
|---|---|
|
| The node is online. |
|
| The node is offline. |
|
| Not possible to retrieve status. The remote cache could be shutting down or a network error occurred during the request. |
3.2.3. Taking Backup Locations Offline Copy linkLink copied to clipboard!
Take backup locations offline with POST requests and the ?action=take-offline parameter.
POST /v2/caches/{cacheName}/x-site/backups/{siteName}?action=take-offline
3.2.4. Bringing Backup Locations Online Copy linkLink copied to clipboard!
Bring backup locations online with the ?action=bring-online parameter.
POST /v2/caches/{cacheName}/x-site/backups/{siteName}?action=bring-online
3.2.5. Pushing State to Backup Locations Copy linkLink copied to clipboard!
Push cache state to a backup location with the ?action=start-push-state parameter.
POST /v2/caches/{cacheName}/x-site/backups/{siteName}?action=start-push-state
3.2.6. Canceling State Transfer Copy linkLink copied to clipboard!
Cancel state transfer operations with the ?action=cancel-push-state parameter.
POST /v2/caches/{cacheName}/x-site/backups/{siteName}?action=cancel-push-state
3.2.7. Getting State Transfer Status Copy linkLink copied to clipboard!
Retrieve status of state transfer operations with the ?action=push-state-status parameter.
GET /v2/caches/{cacheName}/x-site/backups?action=push-state-status
Data Grid responds with the status of state transfer for each backup location in JSON format, as in the following example:
{
"NYC":"CANCELED",
"LON":"OK"
}
| Value | Description |
|---|---|
|
| State transfer to the backup location is in progress. |
|
| State transfer completed successfully. |
|
| An error occurred with state transfer. Check log files. |
|
| State transfer cancellation is in progress. |
3.2.8. Clearing State Transfer Status Copy linkLink copied to clipboard!
Clear state transfer status for sending sites with the ?action=clear-push-state-status parameter.
POST /v2/caches/{cacheName}/x-site/local?action=clear-push-state-status
3.2.9. Modifying Take Offline Conditions Copy linkLink copied to clipboard!
Sites go offline if certain conditions are met. Modify the take offline parameters to control when backup locations automatically go offline.
Procedure
Check configured take offline parameters with
GETrequests and thetake-offline-configparameter.GET /v2/caches/{cacheName}/x-site/backups/{siteName}/take-offline-configThe Data Grid response includes
after_failuresandmin_waitfields as follows:{ "after_failures": 2, "min_wait": 1000 }Modify take offline parameters in the body of
PUTrequests.PUT /v2/caches/{cacheName}/x-site/backups/{siteName}/take-offline-configIf the operation successfully completes, the service returns
204 (No Content).
3.2.10. Canceling State Transfer from Receiving Sites Copy linkLink copied to clipboard!
If the connection between two backup locations breaks, you can cancel state transfer on the site that is receiving the push.
Cancel state transfer from a remote site and keep the current state of the local cache with the ?action=cancel-receive-state parameter.
POST /v2/caches/{cacheName}/x-site/backups/{siteName}?action=cancel-receive-state
3.2.11. Getting Status of Backup Locations Copy linkLink copied to clipboard!
Retrieve the status of all backup locations from Cache Managers with GET requests.
GET /rest/v2/cache-managers/{cacheManagerName}/x-site/backups/
Data Grid responds with status in JSON format, as in the following example:
{
"SFO-3":{
"status":"online"
},
"NYC-2":{
"status":"mixed",
"online":[
"CACHE_1"
],
"offline":[
"CACHE_2"
]
}
}
| Value | Description |
|---|---|
|
| All nodes in the local cluster have a cross-site view with the backup location. |
|
| No nodes in the local cluster have a cross-site view with the backup location. |
|
| Some nodes in the local cluster have a cross-site view with the backup location, other nodes in the local cluster do not have a cross-site view. The response indicates status for each node. |
3.2.12. Taking Backup Locations Offline Copy linkLink copied to clipboard!
Take backup locations offline with the ?action=take-offline parameter.
POST /rest/v2/cache-managers/{cacheManagerName}/x-site/backups/{siteName}?action=take-offline
3.2.13. Bringing Backup Locations Online Copy linkLink copied to clipboard!
Bring backup locations online with the ?action=bring-online parameter.
POST /rest/v2/cache-managers/{cacheManagerName}/x-site/backups/{siteName}?action=bring-online
3.2.14. Retrieving the State Transfer Mode Copy linkLink copied to clipboard!
Check the state transfer mode with GET requests.
GET /rest/v2/caches/{cacheName}/x-site/backups/{site}/state-transfer-mode
3.2.15. Setting the State Transfer Mode Copy linkLink copied to clipboard!
Configure the state transfer mode with the ?action=set parameter.
POST /rest/v2/caches/{cacheName}/x-site/backups/{site}/state-transfer-mode?action=set&mode={mode}
3.2.16. Starting State Transfer Copy linkLink copied to clipboard!
Push state of all caches to remote sites with the ?action=start-push-state parameter.
POST /rest/v2/cache-managers/{cacheManagerName}/x-site/backups/{siteName}?action=start-push-state
3.2.17. Canceling State Transfer Copy linkLink copied to clipboard!
Cancel ongoing state transfer operations with the ?action=cancel-push-state parameter.
POST /rest/v2/cache-managers/{cacheManagerName}/x-site/backups/{siteName}?action=cancel-push-state
3.3. Performing Cross-Site Operations with JMX Copy linkLink copied to clipboard!
Data Grid provides JMX tooling to perform cross-site operations such as pushing state transfer and bringing sites online.
3.3.1. Configuring Data Grid to Register JMX MBeans Copy linkLink copied to clipboard!
Data Grid can register JMX MBeans that you can use to collect statistics and perform administrative operations. You must enable statistics separately to JMX otherwise Data Grid provides 0 values for all statistic attributes.
Procedure
Modify your cache container configuration to enable JMX in one of the following ways:
-
Declarative: Add the
<jmx enabled="true" />element to the cache container. -
Programmatic: Call the
.jmx().enable()method.
Declarative
<cache-container>
<jmx enabled="true" />
</cache-container>
Programmatic
GlobalConfiguration globalConfig = new GlobalConfigurationBuilder()
.jmx().enable()
.build();
3.3.2. Performing Cross-Site Operations Copy linkLink copied to clipboard!
Perform cross-site operations via JMX clients.
Prerequisites
- Configure Data Grid to register JMX MBeans
Procedure
- Connect to Data Grid with any JMX client.
Invoke operations from the following MBeans:
-
XSiteAdminprovides cross-site operations for caches. GlobalXSiteAdminOperationsprovides cross-site operations for Cache Managers.For example, to bring sites back online, invoke
bringSiteOnline(siteName).
-
See the Data Grid JMX Components documentation for details about available cross-site operations.