Dukes Bank and Operations

From ControlTier

Jump to: navigation, search

Java duke mascot.jpg This is part of the DukesBank portion of the ControlTier Demo

(Accessing the Dukes Bank Website)

Contents

Overview

This page describes a demonstration on how to manage Dukes Bank in operations.

This demo focusses on managing the runtime state of the service. This is done via startup and shutdown procedures. Startup and shutdown procedures are managed via a standard set of ControlTier commands:

This allows you to manage the runtime state of application services both locally on a single machine, or managing sets of services across the distributed environment.

You can manage the Dukes Bank instances in one of three ways:

  1. Local Service: Manage a single service locally on a chosen node. Using this approach you first log in to a target machine where one of the Dukes Bank services is running (e.g., JBossServer) and run one of its control commands (e.g., Restart). This action only affects this single instance.
  2. Distributed Service: In this mode, instead of controlling just one Service on one node, you can invoke a command across all the nodes where a particular instance of service is deployed. This uses CTL's node dispatch capability to invoke commands to Services deployed across the network. Using this approach you can for example tell all "developmentDukesBank" JBossServer instances to "Stop".
  3. Site: You can control the entire Dukes Bank application as a logical whole, which provides a single management interface to control Services that only belong to the Site. This uses the standard Site type to perform mediated actions across all the Services that comprise the integrated application (e.g., JBossServer and HsqlRdb instances).

Preparation

Before getting started confirm the JBossServer, HsqldbRdb and Site objects are deployed to CTL.

Run the ctl-project command:

$ ctl-project -p demo -a install
"Install" command running for resource: (Site) developmentDukesBank
.
.
.
"Install" command running for resource: (JBossServer) developmentDukesBank
.
.
.

Your output should include messages for the Site, HsqldbRdb and JBossServer (among other objects).


These commands are defined in the Service and Site types. JBossServer and HsqldRdb both extend Service and include their own startup and shutdown procedures.

The following sections include examples for these commands.


By Service

This section describes how to manage the instances of Dukes Bank from the Service level. This lets you control a particular application tier in Dukes Bank.

Status

Local Service

The "Status" command checks if the JBoss instance is running:

ctl -p demo -t JBossServer -r developmentDukesBank -c Status
begin workflow command (1/1) -> "assertServiceIsUp " ...
alexh    20179  1.4 20.8 324584 107548 pts/2 Sl   18:43   0:22 /home/alexh/ctier/pkgs/jdk1.5.0_17/bin/java -server 
-Dprogram.name=run.sh -Djava.endorsed.dirs=/home/alexh/ctier/demo/elements/development/dukesbank/jboss-4.0.3SP1/lib/endorsed 
-classpath /home/alexh/ctier/demo/elements/development/dukesbank/jboss-4.0.3SP1/bin/run.jar:/home/alexh/ctier/pkgs/jdk1.5.0_17/lib/tools.jar org.jboss.Main -c default
end workflow command (1/1) -> "assertServiceIsUp "

Distributed Service

Use the node set filtering option "-I", to all hosts where the JBossServer instance is deployed:

$ ctl -I '.*' -p demo -t JBossServer -r developmentDukesBank -c Status
begin workflow command (1/1) -> "assertServiceIsUp " ...
alexh    20179  1.4 20.8 324584 107548 pts/2 Sl   18:43   0:22 /home/alexh/ctier/pkgs/jdk1.5.0_17/bin/java -server 
-Dprogram.name=run.sh -Djava.endorsed.dirs=/home/alexh/ctier/demo/elements/development/dukesbank/jboss-4.0.3SP1/lib/endorsed 
-classpath /home/alexh/ctier/demo/elements/development/dukesbank/jboss-4.0.3SP1/bin/run.jar:/home/alexh/ctier/pkgs/jdk1.5.0_17/lib/tools.jar org.jboss.Main -c default
end workflow command (1/1) -> "assertServiceIsUp "


Stop

Local Service

The "Stop" command shuts down the JBoss instance:

$ ctl -p demo -t JBossServer -r developmentDukesBank -c Stop
begin workflow command (1/1) -> "assertServiceIsDown " ...
alexh    22080  0.3 23.4 333896 120768 pts/2 Sl   Jan14   4:48 /home/alexh/ctier/pkgs/jdk1.5.0_17/bin/java -server 
-Dprogram.name=run.sh -Djava.endorsed.dirs=/home/alexh/ctier/demo/elements/development/dukesbank/jboss-4.0.3SP1/lib/endorsed 
-classpath /home/alexh/ctier/demo/elements/development/dukesbank/jboss-4.0.3SP1/bin/run.jar:/home/alexh/ctier/pkgs/jdk1.5.0_17/lib/tools.jar org.jboss.Main -c default
Error handler caught failed command execution: developmentDukesBank[JBossServer]->assertServiceIsDown. reason: The following error occurred while executing this line:
/home/alexh/ctier/ctl/projects/default/modules/JBossServer/commands/assertServiceIsDown.xml:33: shellscript returned: 1
Running handler command: stopServiceWrapper
Workflow beginning. commands: stopService,waitforStopEvent
begin workflow command (1/2) -> "stopService " ...
Shutdown message has been posted to the server.
Server shutdown may take a while - check logfiles for completion
end workflow command (1/2) -> "stopService "
begin workflow command (2/2) -> "waitforStopEvent " ...
end workflow command (2/2) -> "waitforStopEvent "
[command.timer: 4.637 sec]
Workflow completed. execution time: 4.637 sec
end workflow command (1/1) -> "assertServiceIsDown "

Distributed Service

$ ctl -I '.*' -p demo -t JBossServer -r developmentDukesBank -c Stop
begin workflow command (1/1) -> "assertServiceIsDown " ...
.
.
.

Start

Local Service

The "Start" command starts the JBoss instance:

$ ctl -p demo -t JBossServer -r developmentDukesBank -c Start
begin workflow command (1/1) -> "assertServiceIsUp " ...
Running handler command: startServiceWrapper
Workflow beginning. commands: startService,waitforStartEvent
begin workflow command (1/2) -> "startService " ...
Moving 1 file to /home/alexh/ctier/demo/elements/development/dukesbank/jboss-4.0.3SP1/server/default/log
end workflow command (1/2) -> "startService "
begin workflow command (2/2) -> "waitforStartEvent " ...
end workflow command (2/2) -> "waitforStartEvent "
[command.timer: 24.735 sec]
Workflow completed. execution time: 24.735 sec
end workflow command (1/1) -> "assertServiceIsUp "


Restart

Local Service

The "Restart" command is a workflow that calls "Stop" and then "Start":

$ ctl -p demo -t JBossServer -r developmentDukesBank -c Restart
begin workflow command (1/2) -> "Stop " ...
begin workflow command (1/1) -> "assertServiceIsDown " ...
alexh    20179  1.3 20.8 324584 107548 pts/2 Sl   18:43   0:22 /home/alexh/ctier/pkgs/jdk1.5.0_17/bin/java -server
-Dprogram.name=run.sh -Djava.endorsed.dirs=/home/alexh/ctier/demo/elements/development/dukesbank/jboss-4.0.3SP1/lib/endorsed 
-classpath /home/alexh/ctier/demo/elements/development/dukesbank/jboss-4.0.3SP1/bin/run.jar:/home/alexh/ctier/pkgs/jdk1.5.0_17/lib/tools.jar org.jboss.Main 
-c default
Error handler caught failed command execution: developmentDukesBank[JBossServer]->assertServiceIsDown. reason: 
The following error occurred while executing this line:
/home/alexh/ctier/ctl/projects/default/modules/JBossServer/commands/assertServiceIsDown.xml:33: shellscript returned: 1
Running handler command: stopServiceWrapper
Workflow beginning. commands: stopService,waitforStopEvent
begin workflow command (1/2) -> "stopService " ...
Shutdown message has been posted to the server.
Server shutdown may take a while - check logfiles for completion
end workflow command (1/2) -> "stopService "
begin workflow command (2/2) -> "waitforStopEvent " ...
end workflow command (2/2) -> "waitforStopEvent "
[command.timer: 3.665 sec]
Workflow completed. execution time: 3.665 sec
end workflow command (1/1) -> "assertServiceIsDown "
end workflow command (1/2) -> "Stop "
begin workflow command (2/2) -> "Start " ...
begin workflow command (1/1) -> "assertServiceIsUp " ...
Running handler command: startServiceWrapper
Workflow beginning. commands: startService,waitforStartEvent
begin workflow command (1/2) -> "startService " ...
Moving 1 file to /home/alexh/ctier/demo/elements/development/dukesbank/jboss-4.0.3SP1/server/default/log
end workflow command (1/2) -> "startService "
begin workflow command (2/2) -> "waitforStartEvent " ...
end workflow command (2/2) -> "waitforStartEvent "
[command.timer: 3.665 sec]
Workflow completed. execution time: 3.665 sec
end workflow command (1/1) -> "assertServiceIsUp "
end workflow command (2/2) -> "Start "

Distributed Service

This example uses Node filtering options to look up JBossServer instances and then run the "Restart" command. You can of course specify any of JBossServer's commands.

$ ctl -I '.*' -p demo -t JBossServer -r developmentDukesBank -c Restart
begin workflow command (1/2) -> "Stop " ...
begin workflow command (1/1) -> "assertServiceIsDown " ...
.
.
.

By Site

This section describes how to manage the instances of Dukes Bank from the Site level. This lets you control all tiers in Dukes Bank from a single control point.

Status

You can invoke the Status command across all JBossServers via the "developmentDukesBank" Site. The Site will dispatch the "Status" command to all services by default.

$ ctl -p demo -t Site  -r developmentDukesBank -c Status
Dispatching command 'Status' to objects: developmentDukesBank[HsqldbRdb], developmentDukesBank[JBossServer] ...
starting: developmentDukesBank[HsqldbRdb]->Status ...
starting: developmentDukesBank[JBossServer]->Status ...
begin workflow command (1/1) -> "assertServiceIsUp " ...
.
.
.

To limit the dispatch to just the JBossServers use the "-resourcetype" option.

$ ctl -p demo -t Site  -r developmentDukesBank -c Status -- -resourcetype JBossServer
Dispatching command 'Status' to objects: developmentDukesBank[JBossServer] ...
.
.
.

This limits "Status" to just JBossServer instances and excludes everything else (e.g., HsqRdb instances)

Stop

The Site "Stop" command shuts down all of the instances:

$ ctl -p demo -t Site  -r developmentDukesBank -c Stop
Dispatching command 'Stop' to objects: developmentDukesBank[JBossServer], developmentDukesBank[HsqldbRdb] ...
starting: developmentDukesBank[JBossServer]->Stop ...
starting: developmentDukesBank[HsqldbRdb]->Stop ...
begin workflow command (1/1) -> "assertServiceIsDown " ...
alexh    20894  1.4 21.3 326948 109988 pts/2 Sl   19:16   0:22 /home/alexh/ctier/pkgs/jdk1.5.0_17/bin/java -server 
-Dprogram.name=run.sh -Djava.endorsed.dirs=/home/alexh/ctier/demo/elements/development/dukesbank/jboss-4.0.3SP1/lib/endorsed 
-classpath /home/alexh/ctier/demo/elements/development/dukesbank/jboss-4.0.3SP1/bin/run.jar:/home/alexh/ctier/pkgs/jdk1.5.0_17/lib/tools.jar org.jboss.Main -c default
Error handler caught failed command execution: developmentDukesBank[JBossServer]->assertServiceIsDown. reason: The following error occurred while executing this line:
/home/alexh/ctier/ctl/projects/default/modules/JBossServer/commands/assertServiceIsDown.xml:33: shellscript returned: 1
Running handler command: stopServiceWrapper
Workflow beginning. commands: stopService,waitforStopEvent
begin workflow command (1/2) -> "stopService " ...
Shutdown message has been posted to the server.
Server shutdown may take a while - check logfiles for completion
end workflow command (1/2) -> "stopService "
begin workflow command (2/2) -> "waitforStopEvent " ...
end workflow command (2/2) -> "waitforStopEvent "
[command.timer: 3.361 sec]
Workflow completed. execution time: 3.361 sec
end workflow command (1/1) -> "assertServiceIsDown "
begin workflow command (1/1) -> "assertServiceIsDown " ...
Running handler command: stopService
end workflow command (1/1) -> "assertServiceIsDown "

Run the command again but this time use "-resourcetype" to match just the JBossServer instances:

$ ctl -p demo -t Site  -r developmentDukesBank -c Stop -- -resourcetype JBossServer
Dispatching command 'Stop' to objects: developmentDukesBank[JBossServer] ...
starting: developmentDukesBank[JBossServer]->Stop ...
begin workflow command (1/1) -> "assertServiceIsDown " ...
end workflow command (1/1) -> "assertServiceIsDown "


Start

The Site "Start" command brings up all of the instances:

$ ctl -p demo -t Site  -r developmentDukesBank -c Start
Dispatching command 'Start' to objects: developmentDukesBank[HsqldbRdb], developmentDukesBank[JBossServer] ...
starting: developmentDukesBank[HsqldbRdb]->Start ...
starting: developmentDukesBank[JBossServer]->Start ...
begin workflow command (1/1) -> "assertServiceIsUp " ...
.
.
.
end workflow command (1/2) -> "startService "
begin workflow command (2/2) -> "waitforStartEvent " ...
end workflow command (2/2) -> "waitforStartEvent "

Run the command again but this time just limit the command to HsqldbRdb instances:

$ ctl -p demo -t Site  -r developmentDukesBank -c Start -- -resourcetype HsqldbRdb
Dispatching command 'Start' to objects: developmentDukesBank[HsqldbRdb] ...
starting: developmentDukesBank[HsqldbRdb]->Start ...
begin workflow command (1/1) -> "assertServiceIsUp " ...
assertion succeeded since the HSQLDB instance is up.
end workflow command (1/1) -> "assertServiceIsUp "

Notice, the Start command did not call startService since the service was already running.

Restart

The Site "Restart" command shuts down and then starts up all the associated Services:

$ ctl -p demo -t Site  -r developmentDukesBank -c Restart
Dispatching command 'Restart' to objects: developmentDukesBank[JBossServer], developmentDukesBank[HsqldbRdb] ...
starting: developmentDukesBank[JBossServer]->Restart ...
starting: developmentDukesBank[HsqldbRdb]->Restart ...
begin workflow command (1/2) -> "Stop " ...
begin workflow command (1/1) -> "assertServiceIsDown " ...
.
.
.
end workflow command (1/2) -> "Stop "
begin workflow command (2/2) -> "Start " ...
.
.
.
end workflow command (2/2) -> "Start "

Restart just the JBoss instances:

$ ctl -p demo -t Site  -r developmentDukesBank -c Restart -- -resourcetype JBossServer
Dispatching command 'Restart' to objects: developmentDukesBank[JBossServer] ...
starting: developmentDukesBank[JBossServer]->Restart ...
.
.
.
end workflow command (2/2) -> "waitforStartEvent "
Workflow completed. execution time: 3.867 sec
end workflow command (1/1) -> "assertServiceIsUp "
end workflow command (2/2) -> "Start "
Personal tools
Namespaces
Variants
Actions
Navigation
Communication
Development
Toolbox
Print/export