Format of a Detyped Operation Request

The basic method a user of the AS 7 programmatic managment API would use it very simple:

 

     ModelNode execute(ModelNode operation) throws CancellationException, IOException;

 

where the return value is the detyped representation of the response, and operation is the detyped representation of the operating being invoked.

 

The purpose of this article is to document the structure of operation.

 

See this page for a discussion of the format of the response.

 

See this page for a more in depth example of using the native management API.

 

Simple Operations

 

A text representation of simple operation would look like this:

 

 

 

{
    "operation" => "write-core-threads",
    "address" => [
        ("profile" => "production"),
        ("subsystem" => "threads"),
        ("bounded-queue-thread-pool" => "pool1")
    ],
    "count" => 0,
    "per-cpu" => 20
}

 

 

 

Java code to produce that output would be:

 

ModelNode op = new ModelNode();
op.get("operation").set("write-core-threads");
ModelNode addr = op.get("address");
addr.add("profile", "production");
addr.add("subsystem", "threads");
addr.add("bounded-queue-thread-pool", "pool1");
op.get("count").set(0);
op.get("per-cpu").set(20);

System.out.println(op);

 

The order in which the outermost elements appear in the request is not relevant. The required elements are:

 

  • operation -- String -- The name of the operation being invoked.
  • address -- the address of the managed resource against which the request should be executed. If not set, the address is the root resource. The address is an ordered list of key-value pairs describing where the resource resides in the overall management resource tree. Management resources are organized in a tree, so the order in which elements in the address occur is important.

 

The other key/value pairs are parameter names and their values. The names and values should match what is specified in the operation's description.

 

Parameters may have any name, except for operation, address and operation-headers.

 

Operation Headers

 

Besides the special operation and address values discussed above, operation requests can also include special "header" values that help control how the operation executes. These headers are created under the special reserved word operation-headers:

 

ModelNode op = new ModelNode();
op.get("operation").set("write-core-threads");
ModelNode addr = op.get("address");
addr.add("base", "domain");
addr.add("profile", "production");
addr.add("subsystem", "threads");
addr.add("bounded-queue-thread-pool", "pool1");
op.get("count").set(0);
op.get("per-cpu").set(20);
op.get("operation-headers", "rollback-on-runtime-failure").set(false);

System.out.println(op);

 

This produces:

 

{
    "operation" => "write-core-threads",
    "address" => [
        ("profile" => "production"),
        ("subsystem" => "threads"),
        ("bounded-queue-thread-pool" => "pool1")
    ],
    "count" => 0,
    "per-cpu" => 20,
    "operation-headers" => {
        "rollback-on-runtime-failure => false

    }

}

 

The following operation headers are supported:

 

  • rollback-on-runtime-failure -- boolean, optional, defaults to true. Whether an operation that successfully updates the persistent configuration model should be reverted if it fails to apply to the runtime. Operations that affect the persistent configuration are applied in two stages -- first to the configuration model and then to the actual running services. If there is an error applying to the configuration model the operation will be aborted with no configuration change and no change to running services will be attempted. However, operations are allowed to changed the configuration model even if there is a failure to apply the change to the running services -- if and only if this rollback-on-runtime-failure header is set to false.  So, this header only deals with what happens if there is a problem applying an operation to the running state of a server (e.g. actually increasing the size of a runtime thread pool.)
  • rollout-plan -- only relevant to requests made to a Domain Controller or Host Controller. See "Operations with a Rollout Plan" for details.
  • allow-resource-service-restart -- boolean, optional, defaults to false. Whether an operation that requires restarting some runtime services in order to take effect should do so. See discussion of resource-services in the "Applying Updates to Runtime Services" section of the Detyped Description of the AS 7 Management Model wiki for further details.

 

Composite Operations

 

The root resource managed by a (Domain|Host|Server)Controller will expose an operation named "composite".   This operation executes a list of other operations as an atomic unit*.  The structure of the request for the "composite" operations has the same fundamental structure as a simple operation (operation name, address, params as key value pairs.

 

* See the discussion below of the  rollback-on-runtime-failure operation header for how the atomicity requirement can be relaxed.

 

{
    "operation" => "composite",
    "address" => [],
    "steps" => [
         {
              "operation" => "write-core-threads",
              "address" => [
                   ("profile" => "production"),
                   ("subsystem" => "threads"),
                   ("bounded-queue-thread-pool" => "pool1")
              ],
              "count" => 0,
              "per-cpu" => 20
         }, 
         {
              "operation" => "write-core-threads",
              "address" => [
                   ("profile" => "production"),
                   ("subsystem" => "threads"),
                   ("bounded-queue-thread-pool" => "pool2")
              ],
              "count" => 5,
              "per-cpu" => 10
         }
    ],
    "operation-headers" => {
        "rollback-on-runtime-failure => false

    }
}

 

 

The "composite" operation takes a single parameter:

 

  • steps -- a list, where each item in the list has the same structure as a simple operation request. In the example above each of the two steps is modifying the thread pool configuration for a different pool. There need not be any particular relationship between the steps. Note that the rollback-on-runtime-failure and rollout-plan operation headers are not supported for the individual steps in a composite operation.

 

The rollback-on-runtime-failure operation header discussed above has a particular meaning when applied to a composite operation, controlling whether steps that successfully execute should be reverted if other steps fail at runtime. Note that if any steps modify the persistent configuration, and any of those steps fail, all steps will be reverted. Partial/incomplete changes to the persistent configuration are not allowed.

 

Operations with a Rollout Plan

 

Operations targetted at domain or host level resources can potentially impact multiple servers. Such operations can include a "rollout plan" detailing the sequence in which the operation should be applied to servers as well as policies for detailing whether the operation should be reverted if it fails to execute successfully on some servers.

 

If the operation includes a rollout plan, the structure is as follows:

 

{

    "operation" => "write-core-threads",

    "address" => [

        ("profile" => "production"),

        ("subsystem" => "threads"),

        ("bounded-queue-thread-pool" => "pool1")

    ],

    "count" => 0,

    "per-cpu" => 20,

    "operation-headers" => {

        "rollout-plan" => {

            "in-series" => [

                {

                    "concurrent-groups" => {

                        "groupA" => {

                            "rolling-to-servers" => true,

                            "max-failure-percentage" => 20

                        },

                        "groupB" => undefined

                    }

                },

                {

                   "server-group" => {

                        "groupC" => {

                            "rolling-to-servers" => false,

                            "max-failed-servers" => 1

                        }

                    }

                },

                {

                    "concurrent-groups" => {

                        "groupD" => {

                            "rolling-to-servers" => true,

                            "max-failure-percentage" => 20

                        },

                        "groupE" => undefined

                    }

                }

            ],

            "rollback-across-groups" => true

        }

    }

}

 

 

As you can see, the rollout plan is another structure in the operation-headers section. The root node of the structure allows two children:

 

  • in-series -- a list -- A list of steps that are to be performed in series, with each step reaching completion before the next step is executed. Each step involves the application of the operation to the servers in one or more server groups. See below for details on each element in the list.
  • rollback-across-groups -- boolean -- indicates whether the need to rollback the operation on all the servers in one server group should trigger a rollback across all the server groups. This is an optional setting, and defaults to false.

 

Each element in the list under the in-series node must have one or the other of the following structures:

 

  • concurrent-groups -- a map of server group names to policies controlling how the operation should be applied to that server group. For each server group in the map, the operation may be applied concurrently. See below for details on the per-server-group policy configuration.
  • server-group -- a single key/value mapping of a server group name to a policy controlling how the operation should be applied to that server group. See below for details on the policy configuration. (Note: there is no difference in plan execution between this and a "concurrent-groups" map with a single entry.)

 

The policy controlling how the operation is applied to the servers within a server group has the following elements, each of which is optional:

 

  • rolling-to-servers -- boolean -- If true, the operation will be applied to each server in the group in series. If false or not specified, the operation will be applied to the servers in the group concurrently.
  • max-failed-servers -- int -- Maximum number of servers in the group that can fail to apply the operation before it should be reverted on all servers in the group. The default value if not specified is zero; i.e. failure on any server triggers rollback across the group.
  • max-failure-percentage -- int between 0 and 100 -- Maximum percentage of the total number of servers in the group that can fail to apply the operation before it should be reverted on all servers in the group. The default value if not specified is zero; i.e. failure on any server triggers rollback across the group.

 

If both max-failed-servers and max-failure-percentage are set to non-zero values, max-failure-percentage takes precedence.

 

Looking at the (contrived) example above, application of the operation to the servers in the domain would be done in 3 phases. If the policy for any server group triggers a rollback of the operation across the server group, all other server groups will be rolled back as well. The 3 phases are:

 

  1. Server groups groupA and groupB will have the operation applied concurrently. The operation will be applied to the servers in groupA in series, while all servers in groupB will handle the operation concurrently. If more than 20% of the servers in groupA fail to apply the operation, it will be rolled back across that group. If any servers in groupB fail to apply the operation it will be rolled back across that group.
  2. Once all servers in groupA and groupB are complete, the operation will be applied to the servers in groupC. Those servers will handle the operation concurrently. If more than one server in groupC fails to apply the operation it will be rolled back across that group.
  3. Once all servers in groupC are complete, server groups groupD and groupE will have the operation applied concurrently. The operation will be applied to the servers in groupD in series, while all servers in groupE will handle the operation concurrently. If more than 20% of the servers in groupD fail to apply the operation, it will be rolled back across that group. If any servers in groupE fail to apply the operation it will be rolled back across that group.

 

Default Rollout Plan

 

All operations that impact multiple servers will be executed with a rollout plan. However, actually specifying the rollout plan in the operation request is not required. If no rollout-plan is specified, a default plan will be generated. The plan will have the following characteristics:

 

  • There will only be a single high level phase. All server groups affected by the operation will have the operation applied concurrently.
  • Within each server group, the operation will be applied to all servers concurrently.
  • Failure on any server in a server group will cause rollback across the group.
  • Failure of any server group will result in rollback of all other server groups.