JBoss Community

Format of a Detyped Operation Request

modified by Brian Stansberry in JBoss AS7 Development - View the full document

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.

 

Simple Operations

 

A text representation of simple operation would look like this:

 

 

 

{
    "op" => "write-core-threads",
    "op-addr" => [
        ("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("op").set("setCoreThreads");
ModelNode addr = opB.get("op-addr");
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);
 
System.out.println(op);

 

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

 

  • op -- String -- The name of the operation being invoked.
  • op-addr -- the address of the managed resource against which the request should be executed.

 

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 op, op-addr and rollout-plan.

 

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 a (semi-)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.

 

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





 

 

The "composite" operation takes two parameters:

 

  • 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.
  • rollback-on-runtime-failure -- boolean, optional, defaults to true. 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. So, this flag 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.)

 

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:

 

{

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

    "op-addr" => [

        ("profile" => "production"),

        ("subsystem" => "threads"),

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

    ],

    "count" => 0,

    "per-cpu" => 20,

    "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

                    }}

            },

            {"server-group" => {"groupC" => undefined}},

            {"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 simply another structure at the same level as op, op-addr and the operation parameters. 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, 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.

 

See also JBAS-8795 for a suggestion on additional rollout plan capabilities.

Comment by going to Community

Create a new document in JBoss AS7 Development at Community