Chapter 2. Getting Started with the Data Grid CLI
The command line interface (CLI) lets you remotely connect to Data Grid servers to access data and perform administrative functions.
Prerequisites
- At least one running Data Grid server.
2.1. Starting the Data Grid CLI
Start the Data Grid CLI as follows:
-
Open a terminal in
$ISPN_HOME
. Run the CLI.
$ bin/cli.sh [disconnected]>
2.2. Connecting to Data Grid Servers
Do one of the following:
Run the
connect
command to connect to a Data Grid server on the default port of11222
:[disconnected]> connect [hostname1@cluster//containers/default]>
Specify the location of a Data Grid server. For example, connect to a local server that has a port offset of 100:
[disconnected]> connect 127.0.0.1:11322 [hostname2@cluster//containers/default]>
Press the tab key to display available commands and options. Use the -h
option to display help text.
2.3. Navigating CLI Resources
The Data Grid CLI exposes a navigable tree that allows you to list, describe, and manipulate Data Grid cluster resources.
When you connect to a Data Grid cluster, it opens in the context of the default cache container.
[//containers/default]>
-
Use
ls
to list resources.
[//containers/default]> ls caches counters configurations schemas tasks
-
Use
cd
to navigate the resource tree.
[//containers/default]> cd caches
-
Use
describe
to view information about resources.
[//containers/default]> describe { "name" : "default", "version" : "xx.x.x-FINAL", "cluster_name" : "cluster", "coordinator" : true, "cache_configuration_names" : [ "org.infinispan.REPL_ASYNC", "___protobuf_metadata", "org.infinispan.DIST_SYNC", "org.infinispan.LOCAL", "org.infinispan.INVALIDATION_SYNC", "org.infinispan.REPL_SYNC", "org.infinispan.SCATTERED_SYNC", "org.infinispan.INVALIDATION_ASYNC", "org.infinispan.DIST_ASYNC" ], "physical_addresses" : "[192.0.2.0:7800]", "coordinator_address" : "<hostname>", "cache_manager_status" : "RUNNING", "created_cache_count" : "1", "running_cache_count" : "1", "node_address" : "<hostname>", "cluster_members" : [ "<hostname1>", "<hostname2>" ], "cluster_members_physical_addresses" : [ "192.0.2.0:7800", "192.0.2.0:7801" ], "cluster_size" : 2, "defined_caches" : [ { "name" : "mycache", "started" : true }, { "name" : "___protobuf_metadata", "started" : true } ] }
2.3.1. CLI Resources
The Data Grid CLI exposes different resources to:
- create, modify, and manage local or clustered caches.
- perform administrative operations for Data Grid clusters.
Cache Resources
[//containers/default]> ls caches counters configurations schemas
caches
-
Data Grid cache instances. The default cache container is empty. Use the CLI to create caches from templates or
infinispan.xml
files. counters
-
Strong
orWeak
counters that record the count of objects. configurations
- Data Grid configurations.
schemas
- Protocol Buffers (Protobuf) schemas that structure data in the cache.
tasks
- Remote tasks creating and managing Data Grid cache definitions.
Cluster Resources
[hostname@cluster/]> ls containers cluster server
containers
- Cache containers on the Data Grid cluster.
cluster
- Lists Data Grid servers joined to the cluster.
server
- Resources for managing and monitoring Data Grid servers.
2.4. Resource statistics
You can inspect server-collected statistics for some of the resources within a Data Grid server using the stats
command. Use the stats
command either from the context of a resource which collects statistics (containers, caches) or with a path to such a resource:
[//containers/default]> stats { "statistics_enabled" : true, "number_of_entries" : 0, "hit_ratio" : 0.0, "read_write_ratio" : 0.0, "time_since_start" : 0, "time_since_reset" : 49, "current_number_of_entries" : 0, "current_number_of_entries_in_memory" : 0, "total_number_of_entries" : 0, "off_heap_memory_used" : 0, "data_memory_used" : 0, "stores" : 0, "retrievals" : 0, "hits" : 0, "misses" : 0, "remove_hits" : 0, "remove_misses" : 0, "evictions" : 0, "average_read_time" : 0, "average_read_time_nanos" : 0, "average_write_time" : 0, "average_write_time_nanos" : 0, "average_remove_time" : 0, "average_remove_time_nanos" : 0, "required_minimum_number_of_nodes" : -1 }
[//containers/default]> stats /containers/default/caches/mycache { "time_since_start" : -1, "time_since_reset" : -1, "current_number_of_entries" : -1, "current_number_of_entries_in_memory" : -1, "total_number_of_entries" : -1, "off_heap_memory_used" : -1, "data_memory_used" : -1, "stores" : -1, "retrievals" : -1, "hits" : -1, "misses" : -1, "remove_hits" : -1, "remove_misses" : -1, "evictions" : -1, "average_read_time" : -1, "average_read_time_nanos" : -1, "average_write_time" : -1, "average_write_time_nanos" : -1, "average_remove_time" : -1, "average_remove_time_nanos" : -1, "required_minimum_number_of_nodes" : -1 }
2.5. Shutting Down Data Grid Servers
Use the CLI to gracefully shutdown running servers. This ensures that Data Grid passivates all entries to disk and persists state.
Use the
shutdown server
command to stop individual servers.[//containers/default]> shutdown server $hostname
Use the
shutdown cluster
command to stop all servers joined to the cluster.[//containers/default]> shutdown cluster
Verification
Check the server logs for the following messages:
ISPN080002: Data Grid Server stopping ISPN000080: Disconnecting JGroups channel cluster ISPN000390: Persisted state, version=<$version> timestamp=YYYY-MM-DDTHH:MM:SS ISPN080003: Data Grid Server stopped