Chapter 23. Red Hat JBoss Data Grid CLIs
Red Hat JBoss Data Grid includes two Command Line Interfaces: a Library Mode CLI (see Section 23.1, “Red Hat JBoss Data Grid Library Mode CLI” for details) and a Server Mode CLI (see Section 23.2, “Red Hat Data Grid Server CLI” for details).
23.1. Red Hat JBoss Data Grid Library Mode CLI
Red Hat JBoss Data Grid includes the Red Hat JBoss Data Grid Library Mode Command Line Interface (CLI) that is used to inspect and modify data within caches and internal components (such as transactions, cross-datacenter replication sites, and rolling upgrades). The JBoss Data Grid Library Mode CLI can also be used for more advanced operations such as transactions.
The Library Mode CLI consists of a server-side module and a client command tool. The server-side module (
infinispan-cli-server-$VERSION.jar
) includes an interpreter for commands and must be included in the application.
23.1.1. Start the Library Mode CLI (Server)
Start the Red Hat JBoss Data Grid CLI's server-side module with the
standalone
and cluster
files. For Linux, use the standlaone.sh
or clustered.sh
script and for Windows, use the standalone.bat
or clustered.bat
file.
23.1.2. Start the Library Mode CLI (Client)
Start the Red Hat JBoss Data Grid CLI client using the
cli
files in the bin
directory. For Linux, run bin/cli.sh
and for Windows, run bin\cli.bat
.
When starting up the CLI client, specific command line switches can be used to customize the start up.
23.1.3. CLI Client Switches for the Command Line
The listed command line switches are appended to the command line when starting the Red Hat JBoss Data Grid CLI command:
Table 23.1. CLI Client Command Line Switches
Short Option | Long Option | Description |
---|---|---|
-c | --connect=${URL} | Connects to a running Red Hat JBoss Data Grid instance. For example, for JMX over RMI use jmx://[username[:password]]@host:port[/container[/cache]] and for JMX over JBoss Remoting use remoting://[username[:password]]@host:port[/container[/cache]] |
-f | --file=${FILE} | Read the input from the specified file rather than using interactive mode. If the value is set to - then the stdin is used as the input. |
-h | --help | Displays the help information. |
-v | --version | Displays the CLI version information. |
23.1.4. Connect to the Application
Use the following command to connect to the application using the CLI:
[disconnected//]> connect jmx://localhost:12000 [jmx://localhost:12000/MyCacheManager/>
Note
The port value
12000
depends on the value the JVM is started with. For example, starting the JVM with the -Dcom.sun.management.jmxremote.port=12000
command line parameter uses this port, but otherwise a random port is chosen. When the remoting protocol (remoting://localhost:9999
) is used, the Red Hat JBoss Data Grid server administration port is used (the default is port 9999
).
The command line prompt displays the active connection information, including the currently selected
CacheManager
.
Use the
cache
command to select a cache before performing cache operations. The CLI supports tab completion, therefore using the cache
and pressing the tab button displays a list of active caches:
[[jmx://localhost:12000/MyCacheManager/> cache ___defaultcache namedCache [jmx://localhost:12000/MyCacheManager/]> cache ___defaultcache [jmx://localhost:12000/MyCacheManager/___defaultcache]>
Additionally, pressing tab displays a list of valid commands for the CLI.
23.1.5. Stopping a Red Hat JBoss Data Grid Instance with the CLI
Library Mode
When running a Red Hat JBoss Data Grid instance in a container as a library mode deployment, the life cycle of JBoss Data Grid is bound to the life cycle of the user deployment.
Stop or undeploy the user deployment using you container's management interfaces. For example, in Red Hat JBoss Enterprise Application Platform, use the Management CLI. See the Management Interfaces chapter in the JBoss Enterprise Application Platform Administration and Configuration Guide for more information.
Remote Client-Server Mode
A remote client-server JBoss Data Grid instance can be stopped using the following script:
jboss-datagrid-{VERSION}-server/bin/init.d/jboss-datagrid.sh stop
Alternatively, you can use the
kill
commands directly:
kill -15 $pid # send the TERM signal
If after a period of time the
PID
is still there, use the following:
kill -9 $pid