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:

  1. Open a terminal in $ISPN_HOME.
  2. 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 of 11222:

    [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]>
Tip

Press the tab key to display available commands and options. Use the -h option to display help text.

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