Bookmark this page

Guided Exercise: Exploring the Management CLI Tool

Explore the management CLI in offline mode.

Resources
Files: /opt/jboss-eap-7.4/standalone/configuration/exploring-cli.xml
Application URL: N/A

Outcomes

You should be able to configure a stand-alone server of Red Hat JBoss Enterprise Application Platform (JBoss EAP) using the management CLI.

Before beginning the guided exercise, run the following command to prepare the exercise environment:

[student@workstation ~]$ lab start deploying-cli

Instructions

  1. Start the management CLI

    1. During the setup of this laboratory, a file named exploring-cli.xml was copied to the /opt/jboss-eap-7.4/standalone/configuration directory. Open this file and compare it to the original standalone.xml file to verify that they have the same content.

    2. Open a terminal window, and run the following command to start the CLI:

      [student@workstation ~]$ sudo -u jboss \
      /opt/jboss-eap-7.4/bin/jboss-cli.sh
    3. This exercise uses the offline mode to explore the management CLI tool. Start the embedded server by using the exploring-cli.xml configuration file:

      [disconnected /] embed-server --server-config=exploring-cli.xml
  2. Getting information about configuration elements

    1. Verify the settings at the top level using the following command:

      [standalone@embedded /] /:read-resource

      Remember that the management CLI input is a hierarchical structure that starts at /. The previous commands execute the read-resource operation at the top level. The / level refers to the XML structure from the exploring-cli.xml file. When you run :read-resource, you request information about the first level of the exploring-cli.xml file.

      Press q to exit from the listing of a long result.

    2. The ejb3 subsystem is responsible for configuring the Enterprise Java Beans (EJB) specification in the JBoss EAP server. This subsystem has a thread pool resource. A thread pool contains a number of EJBs already created available for the applications. Using this thread pool, you can decreases the execution time of EJB clients requests.

      Using the absolute path, verify the configuration of the default thread pool in the ejb3 subsystem:

      [standalone@embedded /] /subsystem=ejb3/thread-pool=default:read-resource
      {
          "outcome" => "success",
          "result" => {
              "core-threads" => undefined,
              "keepalive-time" => {
                  "time" => 60L,
                  "unit" => "SECONDS"
              },
              "max-threads" => 10,
              "name" => "default",
              "thread-factory" => undefined
          }
      }

      The previous command displays that the default thread pool can create up to ten threads.

    3. Navigate to the logging subsystem and verify the configuration recursively:

      [standalone@embedded /] cd /subsystem=logging
      [standalone@embedded subsystem=logging] :read-resource(recursive=true)
      {
          "outcome" => "success",
          "result" => {
              "add-logging-api-dependencies" => true,
              "use-deployment-logging-config" => true,
              "async-handler" => undefined,
              "console-handler" => {"CONSOLE" => {
                  "autoflush" => true,
                  "enabled" => true,
                  "encoding" => undefined,
                  "filter" => undefined,
                  "filter-spec" => undefined,
                  "formatter" => "%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n",
                  "level" => "INFO",
                  "name" => "CONSOLE",
                  "named-formatter" => "COLOR-PATTERN",
                  "target" => "System.out"
              }},
              "custom-formatter" => undefined,
              "custom-handler" => undefined,
              "file-handler" => undefined,
              "filter" => undefined,
      ...output omitted...

      This step uses the cd command to navigate to the logging subsystem tree. Navigating through the elements tree helps to minimize the commands required to fetch and change information.

      Observe that the CONSOLE handler sets the INFO level. Logging handlers and logging levels are discussed in this course.

      Note

      Remember to use Tab to auto complete the command to avoid typos.

    4. A data source is a resource in the server that creates connections for accessing a relational database from a Java application. The data source specifies the number of connections that JBoss EAP must create to minimize the time that an application spends waiting for the connection to be available.

      Navigate to the ExampleDS data source in the datasources subsystem, and inspect the description of the test-connection-in-pool operation:

      [standalone@embedded subsystem=logging] cd \
      /subsystem=datasources/data-source=ExampleDS
      [standalone@embedded data-source=ExampleDS] :read-operation-description\
      (name=test-connection-in-pool)

      You can verify if a data source works by using the test-connection-in-pool operation. According to the description, you can pass a username and a password to test the connection.

    5. View the description of all attributes from the ExampleDS data source:

      [standalone@embedded data-source=ExampleDS] :read-resource-description
      {
          "outcome" => "success",
          "result" => {
              "description" => "A JDBC data-source configuration",
              "capabilities" => [{
                  "name" => "org.wildfly.data-source",
                  "dynamic" => true,
                  "dynamic-elements" => ["data-source"]
              }],
              "access-constraints" => {"application" => {"data-source" => {"type" => "datasources"}}},
              "attributes" => {
                  "allocation-retry" => {
                      "type" => INT,
                      "description" => "The allocation retry element indicates the number of times that allocating a connection should be tried before throwing an exception",
                      "expressions-allowed" => true,
                      "required" => false,
                      "nillable" => true,
                      "access-type" => "read-write",
                      "storage" => "configuration",
                      "restart-required" => "all-services"
                  },
                  "allocation-retry-wait-millis" => {
      ...output omitted...

      Observe that the command displays if an attribute is required, or if it is read only, or if the server needs restart to apply a change in the attribute.

      The read-resource-description is an alternative to the product documentation.

  3. Modifying resources

    1. Modify the data source to be at least 5 connections and up to ten connections within the pool:

      [standalone@embedded data-source=ExampleDS] :write-attribute\
      (name=min-pool-size,value=5)
      {"outcome" => "success"}
      
      [standalone@embedded data-source=ExampleDS] :write-attribute\
      (name=max-pool-size,value=10)
      {"outcome" => "success"}
    2. Verify that the values changed:

      [standalone@embedded data-source=ExampleDS] :read-attribute(name=min-pool-size)
      {
          "outcome" => "success",
          "result" => 5
      }
      
      [standalone@embedded data-source=ExampleDS] :read-attribute(name=max-pool-size)
      {
          "outcome" => "success",
          "result" => 10
      }
    3. Open the /opt/jboss-eap-7.4/standalone/configuration/exploring-cli.xml and verify that the ExampleDS defines a pool with the specified values in the previous step. You should see the following content:

      <pool>
        <min-pool-size>5</min-pool-size>
        <max-pool-size>10</max-pool-size>
      </pool>
    4. Create a new system property named my-property whose value is production:

      [standalone@embedded data-source=ExampleDS] /system-property=\
      my-property:add(value=production)

      Remember that when you want to create a new resource, you need to specify a name after the = character, and call the :add operation, passing the required attributes. You can discover the available attributes using the Tab key for auto completion.

    5. Try to remove the user.home path available in the /path structure:

      [standalone@embedded data-source=ExampleDS] /path=user.home:remove
      {
          "outcome" => "failed",
          "failure-description" => "WFLYCTL0262: Path 'user.home' is read-only; it cannot be removed",
          "rolled-back" => true
      }

      It is not possible to remove the user.home path because it is read-only.

    6. It is possible to remove a subsystem if necessary. For example, if your company does not have projects that use JSF, then you can remove this subsystem. Remove the jsf subsystem:

      [standalone@embedded data-source=ExampleDS] /subsystem=jsf:remove
  4. Exit the CLI tool.

    [standalone@embedded data-source=ExampleDS] exit

Finish

On the workstation machine, use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish deploying-cli

Revision: ad248-7.4-18a9db2