此内容没有您所选择的语言版本。
Chapter 2. Interacting with the Data Grid REST API
The Data Grid REST API lets you monitor, maintain, and manage Data Grid deployments and provides access to your data.
2.1. Creating and Managing Caches 复制链接链接已复制到粘贴板!
Create and manage Data Grid caches and perform operations on data.
2.1.1. Creating Caches 复制链接链接已复制到粘贴板!
Create named caches across Data Grid clusters with POST requests that include XML or JSON configuration in the payload.
POST /rest/v2/caches/{cacheName}
POST /rest/v2/caches/{cacheName}
| Header | Required or Optional | Parameter |
|---|---|---|
|
| REQUIRED |
Sets the MediaType for the Data Grid configuration payload; either |
|
| OPTIONAL | Used to set AdminFlags |
2.1.1.1. XML Configuration 复制链接链接已复制到粘贴板!
Data Grid configuration in XML format must conform to the schema and include:
-
<infinispan>root element. -
<cache-container>definition.
Example XML Configuration
2.1.1.2. JSON Configuration 复制链接链接已复制到粘贴板!
Data Grid configuration in JSON format:
- Requires the cache definition only.
Must follow the structure of an XML configuration.
- XML elements become JSON objects.
- XML attributes become JSON fields.
Example JSON Configuration
2.1.2. Verifying Caches 复制链接链接已复制到粘贴板!
Check if caches are available in Data Grid clusters with HEAD requests.
HEAD /rest/v2/caches/{cacheName}
HEAD /rest/v2/caches/{cacheName}
2.1.3. Creating Caches with Templates 复制链接链接已复制到粘贴板!
Create caches from Data Grid templates with POST requests and the ?template= parameter.
POST /rest/v2/caches/{cacheName}?template={templateName}
POST /rest/v2/caches/{cacheName}?template={templateName}
2.1.4. Retrieving Cache Configuration 复制链接链接已复制到粘贴板!
Retrieve Data Grid cache configurations with GET requests.
GET /rest/v2/caches/{name}?action=config
GET /rest/v2/caches/{name}?action=config
| Header | Required or Optional | Parameter |
|---|---|---|
|
| OPTIONAL |
Sets the required format to return content. Supported formats are |
2.1.5. Converting Cache Configurations to JSON 复制链接链接已复制到粘贴板!
Invoke a POST request with valid XML configuration and the ?action=toJSON parameter. Data Grid responds with the equivalent JSON representation of the configuration.
POST /rest/v2/caches?action=toJSON
POST /rest/v2/caches?action=toJSON
2.1.6. Retrieving All Cache Details 复制链接链接已复制到粘贴板!
Invoke a GET request to retreive all details for Data Grid caches.
GET /rest/v2/caches/{name}
GET /rest/v2/caches/{name}
Data Grid provides a JSON response such as the following:
-
statscurrent stats of the cache. -
sizethe estimated size for the cache. -
configurationthe cache configuration. -
rehash_in_progresstrue when a rehashing is in progress. -
indexing_in_progresstrue when indexing is in progress. -
boundedwhen expiration is enabled. -
indexedtrue if the cache is indexed. -
persistenttrue if the cache is persisted. -
transactionaltrue if the cache is transactional. -
securedtrue if the cache is secured. -
has_remote_backuptrue if the cache has remote backups.
2.1.7. Adding Entries 复制链接链接已复制到粘贴板!
Add entries to caches with POST requests.
POST /rest/v2/caches/{cacheName}/{cacheKey}
POST /rest/v2/caches/{cacheName}/{cacheKey}
The preceding request places the payload, or request body, in the cacheName cache with the cacheKey key. The request replaces any data that already exists and updates the Time-To-Live and Last-Modified values, if they apply.
If a value already exists for the specified key, the POST request returns an HTTP CONFLICT status and does not modify the value. To update values, you should use PUT requests. See Replacing Entries.
| Header | Required or Optional | Parameter |
|---|---|---|
|
| OPTIONAL | Sets the content type for the key in the request. See Key-Content-Type for more information. |
|
| OPTIONAL | Sets the MediaType of the value for the key. |
|
| OPTIONAL | Sets the number of seconds before the entry is automatically deleted. If you do not set this parameter, Data Grid uses the default value from the configuration. If you set a negative value, the entry is never deleted. |
|
| OPTIONAL | Sets the number of seconds that entries can be idle. If a read or write operation does not occur for an entry after the maximum idle time elapses, the entry is automatically deleted. If you do not set this parameter, Data Grid uses the default value from the configuration. If you set a negative value, the entry is never deleted. |
|
| OPTIONAL | The flags used to add the entry. See Flag for more information. |
The flags header also applies to all other operations involving data manipulation on the cache,
If both timeToLiveSeconds and maxIdleTimeSeconds have a value of 0, Data Grid uses the default lifespan and maxIdle values from the configuration.
If only maxIdleTimeSeconds has a value of 0, Data Grid uses:
-
the default
maxIdlevalue from the configuration. -
the value for
timeToLiveSecondsthat you pass as a request parameter or a value of-1if you do not pass a value.
If only timeToLiveSeconds has a value of 0, Data Grid uses:
-
the default
lifespanvalue from the configuration. -
the value for
maxIdlethat you pass as a request parameter or a value of-1if you do not pass a value.
2.1.8. Replacing Entries 复制链接链接已复制到粘贴板!
Replace entries in caches with PUT requests.
PUT /rest/v2/caches/{cacheName}/{cacheKey}
PUT /rest/v2/caches/{cacheName}/{cacheKey}
If a value already exists for the specified key, the PUT request updates the value. If you do not want to modify existing values, use POST requests that return HTTP CONFLICT status instead of modifying values. See Adding Values.
2.1.9. Retrieving Data By Keys 复制链接链接已复制到粘贴板!
Retrieve data for specific keys with GET requests.
GET /rest/v2/caches/{cacheName}/{cacheKey}
GET /rest/v2/caches/{cacheName}/{cacheKey}
The server returns data from the given cache, cacheName, under the given key, cacheKey, in the response body. Responses contain Content-Type headers that correspond to the MediaType negotiation.
Browsers can also access caches directly, for example as a content delivery network (CDN). Data Grid returns a unique ETag for each entry along with the Last-Modified and Expires header fields.
These fields provide information about the state of the data that is returned in your request. ETags allow browsers and other clients to request only data that has changed, which conserves bandwidth.
| Header | Required or Optional | Parameter |
|---|---|---|
|
| OPTIONAL |
Sets the content type for the key in the request. The default is |
|
| OPTIONAL | Sets the required format to return content. See Accept for more information. |
Append the extended parameter to the query string to get additional information:
GET /rest/v2/caches/{cacheName}/{cacheKey}?extended
GET /rest/v2/caches/{cacheName}/{cacheKey}?extended
The preceding request returns custom headers:
-
Cluster-Primary-Ownerreturns the node name that is the primary owner of the key. -
Cluster-Node-Namereturns the JGroups node name of the server that handled the request. -
Cluster-Physical-Addressreturns the physical JGroups address of the server that handled the request.
2.1.10. Checking if Entries Exist 复制链接链接已复制到粘贴板!
Verify that specific entries exists with HEAD requests.
HEAD /rest/v2/caches/{cacheName}/{cacheKey}
HEAD /rest/v2/caches/{cacheName}/{cacheKey}
The preceding request returns only the header fields and the same content that you stored with the entry. For example, if you stored a String, the request returns a String. If you stored binary, base64-encoded, blobs or serialized Java objects, Data Grid does not de-serialize the content in the request.
HEAD requests also support the extended parameter.
| Header | Required or Optional | Parameter |
|---|---|---|
|
| OPTIONAL |
Sets the content type for the key in the request. The default is |
2.1.11. Deleting Entries 复制链接链接已复制到粘贴板!
Remove entries from caches with DELETE requests.
DELETE /rest/v2/caches/{cacheName}/{cacheKey}
DELETE /rest/v2/caches/{cacheName}/{cacheKey}
| Header | Required or Optional | Parameter |
|---|---|---|
|
| OPTIONAL |
Sets the content type for the key in the request. The default is |
2.1.12. Deleting Caches 复制链接链接已复制到粘贴板!
Remove caches from Data Grid clusters with DELETE requests.
DELETE /rest/v2/caches/{cacheName}
DELETE /rest/v2/caches/{cacheName}
2.1.13. Retrieving All Keys from Caches 复制链接链接已复制到粘贴板!
Invoke GET requests to retrieve all the keys in a cache in JSON format.
GET /rest/v2/caches/{cacheName}?action=keys
GET /rest/v2/caches/{cacheName}?action=keys
| Parameter | Required or Optional | Value |
|---|---|---|
|
| OPTIONAL |
Specifies the internal batch size when retrieving the keys. The default value is |
2.1.14. Clearing Caches 复制链接链接已复制到粘贴板!
To delete all data from a cache, invoke a GET request with the ?action=clear parameter.
GET /rest/v2/caches/{cacheName}?action=clear
GET /rest/v2/caches/{cacheName}?action=clear
2.1.15. Getting Cache Size 复制链接链接已复制到粘贴板!
Retrieve the size of caches across the entire cluster with GET requests and the ?action=size parameter.
GET /rest/v2/caches/{cacheName}?action=size
GET /rest/v2/caches/{cacheName}?action=size
2.1.16. Getting Cache Statistics 复制链接链接已复制到粘贴板!
Obtain runtime statistics for caches with GET requests.
GET /rest/v2/caches/{cacheName}?action=stats
GET /rest/v2/caches/{cacheName}?action=stats
2.1.17. Querying Caches 复制链接链接已复制到粘贴板!
Perform Ickle queries on caches with GET requests and the ?action=search&query parameter.
GET /rest/v2/caches/{cacheName}?action=search&query={ickle query}
GET /rest/v2/caches/{cacheName}?action=search&query={ickle query}
Data Grid responds with query hits such as the following:
-
total_resultsdisplays the total number of results from the query. -
hitsis an array of matches from the query. hitis an object that matches the query.TipHits can contain all fields or a subset of fields if you use a
Selectclause.
| Parameter | Required or Optional | Value |
|---|---|---|
|
| REQUIRED | Specifies the query string. |
|
| OPTIONAL |
Sets the number of results to return. The default is |
|
| OPTIONAL |
Specifies the index of the first result to return. The default is |
|
| OPTIONAL |
Specifies how the Data Grid server executes the query. Values are |
To use the body of the request instead of specifying query parameters, invoke POST requests as follows:
POST /rest/v2/caches/{cacheName}?action=search
POST /rest/v2/caches/{cacheName}?action=search
The following example shows a query in the request body:
{
"query":"from Entity where name:\"user1\"",
"max_results":20,
"offset":10
}
{
"query":"from Entity where name:\"user1\"",
"max_results":20,
"offset":10
}
2.1.18. Re-indexing Data 复制链接链接已复制到粘贴板!
Re-index all data in caches with GET requests and the ?action=mass-index&mode={mode} parameter.
GET /v2/caches/{cacheName}/search/indexes?action=mass-index&mode={mode}
GET /v2/caches/{cacheName}/search/indexes?action=mass-index&mode={mode}
Values for the mode parameter are as follows:
-
syncreturns a response of200only after the re-indexing operation is complete. -
asyncreturns a response of200immediately and the re-indexing operation continues running in the cluster. You can check the status with the Index Statistics REST call.
2.1.19. Purging Indexes 复制链接链接已复制到粘贴板!
Delete all indexes from caches with GET requests and the ?action=clear parameter.
GET /v2/caches/{cacheName}/search/indexes?action=clear
GET /v2/caches/{cacheName}/search/indexes?action=clear
2.1.20. Retrieving Index Statistics 复制链接链接已复制到粘贴板!
Obtain information about indexes in caches with GET requests.
GET /v2/caches/{cacheName}/search/indexes/stats
GET /v2/caches/{cacheName}/search/indexes/stats
Data Grid provides a JSON response such as the following:
-
indexed_class_namesProvides the class names of the indexes present in the cache. For Protobuf the value is alwaysorg.infinispan.query.remote.impl.indexing.ProtobufValueWrapper. -
indexed_entities_countProvides the number of entities indexed per class. -
index_sizesProvides the size, in bytes, for each index in the cache. -
reindexingIndicates if a re-indexing operation was performed for the cache. If the value istrue, theMassIndexerwas started in the cache.
2.1.21. Retrieving Query Statistics 复制链接链接已复制到粘贴板!
Get information about the queries that have been run in caches with GET requests.
GET /v2/caches/{cacheName}/search/query/stats
GET /v2/caches/{cacheName}/search/query/stats
Data Grid provides a JSON response such as the following:
-
search_query_execution_countProvides the number of queries that have been run. -
search_query_total_timeProvides the total time spent on queries. -
search_query_execution_max_timeProvides the maximum time taken for a query. -
search_query_execution_avg_timeProvides the average query time. -
object_loading_total_timeProvides the total time spent loading objects from the cache after query execution. -
object_loading_execution_max_timeProvides the maximum time spent loading objects execution. -
object_loading_execution_avg_timeProvides the average time spent loading objects execution. -
objects_loaded_countProvides the count of objects loaded. -
search_query_execution_max_time_query_stringProvides the slowest query executed.
2.1.22. Clearing Query Statistics 复制链接链接已复制到粘贴板!
Reset runtime statistics with GET requests and the ?action=clear parameter.
GET /v2/caches/{cacheName}/search/query/stats?action=clear
GET /v2/caches/{cacheName}/search/query/stats?action=clear
2.1.23. Listing Caches 复制链接链接已复制到粘贴板!
List all available caches in Data Grid clusters with GET requests.
GET /rest/v2/caches/
GET /rest/v2/caches/
2.1.24. Cross-Site Operations with Caches 复制链接链接已复制到粘贴板!
Perform cross-site replication operations with the Data Grid REST API.
2.1.24.1. Getting Status of All Backup Locations 复制链接链接已复制到粘贴板!
Retrieve the status of all backup locations with GET requests.
GET /v2/caches/{cacheName}/x-site/backups/
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"
}
{
"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. |
2.1.24.2. Getting Status of Specific Backup Locations 复制链接链接已复制到粘贴板!
Retrieve the status of a backup location with GET requests.
GET /v2/caches/{cacheName}/x-site/backups/{siteName}
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"
}
{
"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. |
2.1.24.3. Taking Backup Locations Offline 复制链接链接已复制到粘贴板!
Take backup locations offline with GET requests and the ?action=take-offline parameter.
GET /v2/caches/{cacheName}/x-site/backups/{siteName}?action=take-offline
GET /v2/caches/{cacheName}/x-site/backups/{siteName}?action=take-offline
2.1.24.4. Bringing Backup Locations Online 复制链接链接已复制到粘贴板!
Bring backup locations online with the ?action=bring-online parameter.
GET /v2/caches/{cacheName}/x-site/backups/{siteName}?action=bring-online
GET /v2/caches/{cacheName}/x-site/backups/{siteName}?action=bring-online
2.1.24.5. Pushing State to Backup Locations 复制链接链接已复制到粘贴板!
Push cache state to a backup location with the ?action=start-push-state parameter.
GET /v2/caches/{cacheName}/x-site/backups/{siteName}?action=start-push-state
GET /v2/caches/{cacheName}/x-site/backups/{siteName}?action=start-push-state
2.1.24.6. Canceling State Transfer 复制链接链接已复制到粘贴板!
Cancel state transfer operations with the ?action=cancel-push-state parameter.
GET /v2/caches/{cacheName}/x-site/backups/{siteName}?action=cancel-push-state
GET /v2/caches/{cacheName}/x-site/backups/{siteName}?action=cancel-push-state
2.1.24.7. Getting State Transfer Status 复制链接链接已复制到粘贴板!
Retrieve status of state transfer operations with the ?action=push-state-status parameter.
GET /v2/caches/{cacheName}/x-site/backups?action=push-state-status
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"
}
{
"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. |
2.1.24.8. Clearing State Transfer Status 复制链接链接已复制到粘贴板!
Clear state transfer status for sending sites with the ?action=clear-push-state-status parameter.
GET /v2/caches/{cacheName}/x-site/local?action=clear-push-state-status
GET /v2/caches/{cacheName}/x-site/local?action=clear-push-state-status
2.1.24.9. Modifying Take Offline Conditions 复制链接链接已复制到粘贴板!
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-configGET /v2/caches/{cacheName}/x-site/backups/{siteName}/take-offline-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow The Data Grid response includes
after_failuresandmin_waitfields as follows:{ "after_failures": 2, "min_wait": 1000 }{ "after_failures": 2, "min_wait": 1000 }Copy to Clipboard Copied! Toggle word wrap Toggle overflow Modify take offline parameters in the body of
PUTrequests.PUT /v2/caches/{cacheName}/x-site/backups/{siteName}/take-offline-configPUT /v2/caches/{cacheName}/x-site/backups/{siteName}/take-offline-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow
2.1.24.10. Canceling State Transfer from Receiving Sites 复制链接链接已复制到粘贴板!
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.
GET /v2/caches/{cacheName}/x-site/backups/{siteName}?action=cancel-receive-state
GET /v2/caches/{cacheName}/x-site/backups/{siteName}?action=cancel-receive-state
2.1.25. Rolling Upgrades 复制链接链接已复制到粘贴板!
Perform rolling upgrades of cache data between Data Grid clusters
2.1.25.1. Synchronizing Data 复制链接链接已复制到粘贴板!
Synchronize data from a source cluster to a target cluster with GET requests and the ?action=sync-data parameter:
GET /v2/caches/{cacheName}?action=sync-data
GET /v2/caches/{cacheName}?action=sync-data
When the operation completes, Data Grid responds with the total number of entries copied to the target cluster.
2.1.25.2. Disconnecting Source Clusters 复制链接链接已复制到粘贴板!
After you synchronize data to target clusters, disconnect from the source cluster with GET requests and the ?action=disconnect-source parameter:
GET /v2/caches/{cacheName}?action=disconnect-source
GET /v2/caches/{cacheName}?action=disconnect-source
2.2. Creating and Managing Counters 复制链接链接已复制到粘贴板!
Create, delete, and modify counters via the REST API.
2.2.1. Creating Counters 复制链接链接已复制到粘贴板!
Create counters with POST requests that include configuration in the payload.
POST /rest/v2/counters/{counterName}
POST /rest/v2/counters/{counterName}
Example Weak Counter
Example Strong Counter
2.2.2. Deleting Counters 复制链接链接已复制到粘贴板!
Remove specific counters with DELETE requests.
DELETE /rest/v2/counters/{counterName}
DELETE /rest/v2/counters/{counterName}
2.2.3. Retrieving Counter Configuration 复制链接链接已复制到粘贴板!
Retrieve configuration for specific counters with GET requests.
GET /rest/v2/counters/{counterName}/config
GET /rest/v2/counters/{counterName}/config
Data Grid responds with the counter configuration in JSON format.
2.2.4. Adding Values to Counters 复制链接链接已复制到粘贴板!
Add values to specific counters with POST requests.
This method processes plain/text content only.
POST /rest/v2/counters/{counterName}
POST /rest/v2/counters/{counterName}
If the request payload is empty, the counter is incremented by one, otherwise the payload is interpreted as a signed long and added to the counter.
WEAK counters never respond after operations.
STRONG counters return the current value after each operation.
2.2.5. Getting Counter Values 复制链接链接已复制到粘贴板!
Retrieve counter values with GET requests.
GET /rest/v2/counters/{counterName}
GET /rest/v2/counters/{counterName}
| Header | Required or Optional | Parameter |
|---|---|---|
| OPTIONAL | The required format to return the content. Supported formats are application/json and text/plain. JSON is assumed if no header is provided. |
2.2.6. Resetting Counters 复制链接链接已复制到粘贴板!
Restore the intial value of counters without GET requests and the ?action=reset parameter.
GET /rest/v2/counters/{counterName}?action=reset
GET /rest/v2/counters/{counterName}?action=reset
2.2.7. Incrementing Counters 复制链接链接已复制到粘贴板!
Increment counter values with GET request` and the ?action=increment parameter.
GET /rest/v2/counters/{counterName}?action=increment
GET /rest/v2/counters/{counterName}?action=increment
WEAK counters never respond after operations.
STRONG counters return the current value after each operation.
2.2.8. Adding Deltas to Counters 复制链接链接已复制到粘贴板!
Add arbitrary values to counters with GET requests that include the ?action=add and delta parameters.
GET /rest/v2/counters/{counterName}?action=add&delta={delta}
GET /rest/v2/counters/{counterName}?action=add&delta={delta}
WEAK counters never respond after operations.
STRONG counters return the current value after each operation.
2.2.9. Decrementing Counter Values 复制链接链接已复制到粘贴板!
Decrement counter values with GET requests and the ?action=decrement parameter.
GET /rest/v2/counters/{counterName}?action=decrement
GET /rest/v2/counters/{counterName}?action=decrement
WEAK counters never respond after operations.
STRONG counters return the current value after each operation.
Atomically set values for strong counters with GET requests and the compareAndSet parameter.
GET /rest/v2/counters/{counterName}?action=compareAndSet&expect={expect}&update={update}
GET /rest/v2/counters/{counterName}?action=compareAndSet&expect={expect}&update={update}
Data Grid atomically sets the value to {update} if the current value is {expect}. If the operation is successful, Data Grid returns true.
Atomically set values for strong counters with GET requests and the compareAndSwap parameter.
GET /rest/v2/counters/{counterName}?action=compareAndSwap&expect={expect}&update={update}
GET /rest/v2/counters/{counterName}?action=compareAndSwap&expect={expect}&update={update}
Data Grid atomically sets the value to {update} if the current value is {expect}. If the operation is successful, Data Grid returns the previous value in the payload.
2.2.12. Listing Counters 复制链接链接已复制到粘贴板!
Retrieve a list of counters in Data Grid clusters with GET requests.
GET /rest/v2/counters/
GET /rest/v2/counters/
2.3. Working with Cache Managers 复制链接链接已复制到粘贴板!
Interact with Data Grid Cache Managers to get cluster and usage statistics.
2.3.1. Getting Basic Cache Manager Information 复制链接链接已复制到粘贴板!
Retrieving information about Cache Managers with GET requests.
GET /rest/v2/cache-managers/{cacheManagerName}
GET /rest/v2/cache-managers/{cacheManagerName}
Data Grid responds with information in JSON format, as in the following example:
-
versioncontains the Data Grid version -
namecontains the name of the cache manager as defined in the configuration -
coordinatoris true if the cache manager is the coordinator of the cluster -
cache_configuration_namescontains an array of all caches configurations defined in the cache manager -
cluster_namecontains the name of the cluster as defined in the configuration -
physical_addressescontains the physical network addresses associated with the cache manager -
coordinator_addresscontains the physical network addresses of the coordinator of the cluster -
cache_manager_statusthe lifecycle status of the cache manager. For possible values, check theorg.infinispan.lifecycle.ComponentStatusdocumentation -
created_cache_countnumber of created caches, excludes all internal and private caches -
running_cache_countnumber of created caches that are running -
node_addresscontains the logical address of the cache manager -
cluster_membersandcluster_members_physical_addressesan array of logical and physical addresses of the members of the cluster -
cluster_sizenumber of members in the cluster -
defined_cachesA list of all caches defined in the cache manager, excluding private caches but including internal caches that are accessible
2.3.2. Getting Cluster Health 复制链接链接已复制到粘贴板!
Retrieve health information for Data Grid clusters with GET requests.
GET /rest/v2/cache-managers/{cacheManagerName}/health
GET /rest/v2/cache-managers/{cacheManagerName}/health
Data Grid responds with cluster health information in JSON format, as in the following example:
cluster_healthcontains the health of the cluster-
cluster_namespecifies the name of the cluster as defined in the configuration. health_statusprovides one of the following:-
DEGRADEDindicates at least one of the caches is in degraded mode. -
HEALTHY_REBALANCINGindicates at least one cache is in the rebalancing state. -
HEALTHYindicates all cache instances in the cluster are operating as expected.
-
-
number_of_nodesdisplays the total number of cluster members. Returns a value of0for non-clustered (standalone) servers. -
node_namesis an array of all cluster members. Empty for standalone servers.
-
cache_healthcontains health information per-cache-
statusHEALTHY, DEGRADED or HEALTHY_REBALANCING -
cache_namethe name of the cache as defined in the configuration.
-
2.3.3. Getting Cache Manager Health Status 复制链接链接已复制到粘贴板!
Retrieve the health status of Cache Managers with GET requests that do not require authentication.
GET /rest/v2/cache-managers/{cacheManagerName}/health/status
GET /rest/v2/cache-managers/{cacheManagerName}/health/status
Data Grid responds with one of the following in text/plain format:
-
HEALTHY -
HEALTHY_REBALANCING -
DEGRADED
2.3.4. Checking REST Endpoint Availability 复制链接链接已复制到粘贴板!
Verify Data Grid server REST endpoint availability with HEAD requests.
HEAD /rest/v2/cache-managers/{cacheManagerName}/health
HEAD /rest/v2/cache-managers/{cacheManagerName}/health
If you receive a successful response code then the Data Grid REST server is running and serving requests.
2.3.5. Obtaining Global Configuration for Cache Managers 复制链接链接已复制到粘贴板!
Retrieve global configuration for Cache Managers with GET requests.
GET /rest/v2/cache-managers/{cacheManagerName}/config
GET /rest/v2/cache-managers/{cacheManagerName}/config
| Header | Required or Optional | Parameter |
|---|---|---|
| OPTIONAL | The required format to return the content. Supported formats are application/json and application/xml. JSON is assumed if no header is provided. |
Reference
2.3.6. Obtaining Configuration for All Caches 复制链接链接已复制到粘贴板!
Retrieve the configuration for all caches with GET requests.
GET /rest/v2/cache-managers/{cacheManagerName}/cache-configs
GET /rest/v2/cache-managers/{cacheManagerName}/cache-configs
Data Grid responds with JSON arrays that contain each cache and cache configuration, as in the following example:
2.3.7. Listing Available Cache Templates 复制链接链接已复制到粘贴板!
Retrieve all available Data Grid cache templates with GET requests.
GET /rest/v2/cache-managers/{cacheManagerName}/cache-configs/templates
GET /rest/v2/cache-managers/{cacheManagerName}/cache-configs/templates
Retrieve a list of all available caches for a Cache Manager, along with cache statuses and details, with GET requests.
GET /rest/v2/cache-managers/{cacheManagerName}/caches
GET /rest/v2/cache-managers/{cacheManagerName}/caches
Data Grid responds with JSON arrays that lists and describes each available cache, as in the following example:
2.3.9. Getting Cache Manager Statistics 复制链接链接已复制到粘贴板!
Retrieve the statistics for Cache Managers with GET requests.
GET /rest/v2/cache-managers/{cacheManagerName}/stats
GET /rest/v2/cache-managers/{cacheManagerName}/stats
Data Grid responds with Cache Manager statistics in JSON format, as in the following example:
-
statistics_enabledistrueif statistics collection is enabled for the Cache Manager. -
read_write_ratiodisplays the read/write ratio across all caches. -
time_since_startshows the time, in seconds, since the Cache Manager started. -
time_since_resetshows the number of seconds since the Cache Manager statistics were last reset. -
number_of_entriesshows the total number of entries currently in all caches from the Cache Manager. This statistic returns entries in the local cache instances only. -
total_number_of_entriesshows the number of store operations performed across all caches for the Cache Manager. -
off_heap_memory_usedshows the amount, inbytes[], of off-heap memory used by this cache container. -
data_memory_usedshows the amount, inbytes[], that the current eviction algorithm estimates is in use for data across all caches. Returns0if eviction is not enabled. -
missesshows the number ofget()misses across all caches. -
remove_hitsshows the number of removal hits across all caches. -
remove_missesshows the number of removal misses across all caches. -
evictionsshows the number of evictions across all caches. -
average_read_timeshows the average number of milliseconds taken forget()operations across all caches. -
average_read_time_nanossame asaverage_read_timebut in nanoseconds. -
average_remove_timeshows the average number of milliseconds forremove()operations across all caches. -
average_remove_time_nanossame asaverage_remove_timebut in nanoseconds. -
required_minimum_number_of_nodesshows the required minimum number of nodes to guarantee data consistency. -
hitsprovides the number ofget()hits across all caches. -
storesprovides the number ofput()operations across all caches. -
current_number_of_entries_in_memoryshows the total number of entries currently in all caches, excluding passivated entries. -
hit_ratioprovides the total percentage hit/(hit+miss) ratio for all caches. -
retrievalsshows the total number ofget()operations.
2.3.10. Cross-Site Operations with Cache Managers 复制链接链接已复制到粘贴板!
Perform cross-site operations with Cache Managers to apply the operations to all caches.
2.3.10.1. Getting Status of Backup Locations 复制链接链接已复制到粘贴板!
Retrieve the status of all backup locations from Cache Managers with GET requests.
GET /rest/v2/cache-managers/{cacheManagerName}/x-site/backups/
GET /rest/v2/cache-managers/{cacheManagerName}/x-site/backups/
Data Grid responds with status in JSON format, as in the following example:
| 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. |
2.3.10.2. Taking Backup Locations Offline 复制链接链接已复制到粘贴板!
Take backup locations offline with the ?action=take-offline parameter.
GET /rest/v2/cache-managers/{cacheManagerName}/x-site/backups/{siteName}?action=take-offline
GET /rest/v2/cache-managers/{cacheManagerName}/x-site/backups/{siteName}?action=take-offline
2.3.10.3. Bringing Backup Locations Online 复制链接链接已复制到粘贴板!
Bring backup locations online with the ?action=bring-online parameter.
GET /rest/v2/cache-managers/{cacheManagerName}/x-site/backups/{siteName}?action=bring-online
GET /rest/v2/cache-managers/{cacheManagerName}/x-site/backups/{siteName}?action=bring-online
2.3.10.4. Starting State Transfer 复制链接链接已复制到粘贴板!
Push state of all caches to remote sites with the ?action=start-push-state parameter.
GET /rest/v2/cache-managers/{cacheManagerName}/x-site/backups/{siteName}?action=start-push-state
GET /rest/v2/cache-managers/{cacheManagerName}/x-site/backups/{siteName}?action=start-push-state
2.3.10.5. Canceling State Transfer 复制链接链接已复制到粘贴板!
Cancel ongoing state transfer operations with the ?action=cancel-push-state parameter.
GET /rest/v2/cache-managers/{cacheManagerName}/x-site/backups/{siteName}?action=cancel-push-state
GET /rest/v2/cache-managers/{cacheManagerName}/x-site/backups/{siteName}?action=cancel-push-state
2.4. Working with Data Grid Servers 复制链接链接已复制到粘贴板!
Monitor and manage Data Grid server instances.
2.4.1. Retrieving Basic Server Information 复制链接链接已复制到粘贴板!
View basic information about Data Grid servers with GET requests.
GET /rest/v2/server
GET /rest/v2/server
Data Grid responds with the server name, codename, and version in JSON format as in the following example:
{
"version":"Infinispan 'Codename' xx.x.x.Final"
}
{
"version":"Infinispan 'Codename' xx.x.x.Final"
}
2.4.2. Getting Cache Managers 复制链接链接已复制到粘贴板!
Retrieve lists of cache managers for Data Grid servers with GET requests.
GET /rest/v2/server/cache-managers
GET /rest/v2/server/cache-managers
Data Grid responds with an array of the cache manager names configured for the server.
2.4.3. Adding Caches to Ignore Lists 复制链接链接已复制到粘贴板!
Configure Data Grid to temporarily exclude specific caches from client requests. Send empty POST requests that include the names of the cache manager name and the cache.
POST /v2/server/ignored-caches/{cache-manager}/{cache}
POST /v2/server/ignored-caches/{cache-manager}/{cache}
Data Grid returns a service unavailable status (503) for REST client requests and a Server Error (code 0x85) for Hot Rod client requests.
Data Grid currently supports one cache manager per server only. For future compatibility you must provide the cache manager name in the requests.
2.4.4. Removing Caches from Ignore Lists 复制链接链接已复制到粘贴板!
Remove caches from the ignore list with DELETE requests.
DELETE /v2/server/ignored-caches/{cache-manager}/{cache}
DELETE /v2/server/ignored-caches/{cache-manager}/{cache}
2.4.5. Confirming Ignored Caches 复制链接链接已复制到粘贴板!
Confirm that caches are ignored with GET requests.
GET /v2/server/ignored-caches/{cache-manager}
GET /v2/server/ignored-caches/{cache-manager}
2.4.6. Obtaining Server Configuration 复制链接链接已复制到粘贴板!
Retrieve Data Grid server configurations with GET requests.
GET /rest/v2/server/config
GET /rest/v2/server/config
Data Grid responds with the configuration in JSON format, as follows:
2.4.7. Getting Environment Variables 复制链接链接已复制到粘贴板!
Retrieve all environment variables for Data Grid servers with GET requests.
GET /rest/v2/server/env
GET /rest/v2/server/env
2.4.8. Getting JVM Memory Details 复制链接链接已复制到粘贴板!
Retrieve JVM memory usage information for Data Grid servers with GET requests.
GET /rest/v2/server/memory
GET /rest/v2/server/memory
Data Grid responds with heap and non-heap memory statistics, direct memory usage, and information about memory pools and garbage collection in JSON format.
2.4.9. Getting JVM Thread Dumps 复制链接链接已复制到粘贴板!
Retrieve the current thread dump for the JVM with GET requests.
GET /rest/v2/server/threads
GET /rest/v2/server/threads
Data Grid responds with the current thread dump in text/plain format.
2.4.10. Stopping Data Grid Servers 复制链接链接已复制到粘贴板!
Stop Data Grid servers with GET requests.
GET /rest/v2/server?action=stop
GET /rest/v2/server?action=stop
Data Grid responds with 200(OK) and then stops running.
2.5. Working with Data Grid Clusters 复制链接链接已复制到粘贴板!
Monitor and perform administrative tasks on Data Grid clusters.
2.5.1. Stopping Data Grid Clusters 复制链接链接已复制到粘贴板!
Shut down entire Data Grid clusters with GET requests.
GET /rest/v2/cluster?action=stop
GET /rest/v2/cluster?action=stop
Data Grid responds with 200(OK) and then performs an orderly shutdown of the entire cluster.
2.5.2. Stopping Specific Data Grid Servers in Clusters 复制链接链接已复制到粘贴板!
Shut down one or more specific servers in Data Grid clusters with GET requests and the ?action=stop&server parameter.
GET /rest/v2/cluster?action=stop&server={server1_host}&server={server2_host}
GET /rest/v2/cluster?action=stop&server={server1_host}&server={server2_host}
Data Grid responds with 200(OK).
2.6. Using Server Tasks 复制链接链接已复制到粘贴板!
Retrieve, execute, and upload Data Grid server tasks.
2.6.1. Retrieving Server Tasks Information 复制链接链接已复制到粘贴板!
View information about available server tasks with GET requests.
GET /rest/v2/tasks
GET /rest/v2/tasks
| Parameter | Required or Optional | Value |
|---|---|---|
|
| OPTIONAL |
|
Data Grid responds with a list of available tasks. The list includes the names of tasks, the engines that handle tasks, the named parameters for tasks, the execution modes of tasks, either ONE_NODE or ALL_NODES, and the allowed security role in JSON format, as in the following example:
2.6.2. Executing Tasks 复制链接链接已复制到粘贴板!
Execute tasks with GET requests that include the task name and required parameters prefixed with param.
GET /rest/v2/tasks/myTask?action=exec¶m.p1=v1¶m.p2=v2
GET /rest/v2/tasks/myTask?action=exec¶m.p1=v1¶m.p2=v2
Data Grid responds with the task result.
2.6.3. Uploading Script Tasks 复制链接链接已复制到粘贴板!
Upload script tasks with PUT or POST requests.
Supply the script as the content payload of the request. After Data Grid uploads the script, you can execute it with GET requests.
POST /rest/v2/tasks/taskName
POST /rest/v2/tasks/taskName