AdminAction Class Reference

Inherits com::webobjects::appserver::WODirectAction.

Collaboration diagram for AdminAction:

Collaboration graph
[legend]

List of all members.

Classes

class  DirectActionException

Public Member Functions

 AdminAction (WORequest worequest)
WOActionResults bounceAction ()
void clearDeathsAction ()
void forceQuitAction ()
WOActionResults infoAction ()
WOComponent MainAction ()
Session mySession ()
WOActionResults performActionNamed (String s)
WOActionResults performMonitorActionNamed (String s)
WOActionResults runningAction ()
void startAction ()
void stopAction ()
WOActionResults stoppedAction ()
void turnAutoRecoverOffAction ()
void turnAutoRecoverOnAction ()
void turnRefuseNewSessionsOffAction ()
void turnRefuseNewSessionsOnAction ()
void turnScheduledOffAction ()
void turnScheduledOnAction ()

Protected Member Functions

void addInstancesForApplication (MApplication mapplication)
AdminApplicationsPage applicationsPage ()
void prepareApplications (NSArray nsarray)
void prepareInstances (NSArray nsarray)
void refreshInformation ()

Protected Attributes

NSMutableArray applications
AdminApplicationsPage applicationsPage
NSMutableArray instances

Static Protected Attributes

static NSArray supportedActionNames

Private Member Functions

MSiteConfig siteConfig ()

Private Attributes

WOTaskdHandler _handler


Detailed Description

The following direct actions were added to Monitor. They might be useful for creating scripts to automate deployments of new WO application versions. (First time deployments and config changes would still require interactive sessions in Monitor.) Each direct action returns a short string (instead of a full HTML page) and an HTTP status code indicating whether the respective action was executed successfully. If Monitor is password-protected, the password must be passed on the URL with the name "pw", (e.g. &pw=foo). If the password is missing or incorrect, these direct actions are not permitted to be executed.
Direct Action Return Values Description
running 'YES', 'NO', or
error message
checks whether instances are running (alive)
stopped checks whether instances have stopped (are dead)
start 'OK' or
error message
attempts to start instances which have been stopped or are stopping
stop attempts to stops instances which are running or starting
forceQuit stops instances forcefully
turnAutoRecoverOn 'OK' or
error message
turns Auto Recover on
turnAutoRecoverOff turns Auto Recover off
turnRefuseNewSessionsOn 'OK' or
error message
turns Refuse New Sessions on
turnRefuseNewSessionsOff turns Refuse New Sessions off
turnScheduledOn 'OK' or
error message
turns Scheduled on
turnScheduledOff turns Scheduled off
clearDeaths 'OK' or
error message
sets the number of deaths to 0
bounce 'OK' or
error message
bounces the application (starts a few instances per hosts, set the rest to refusing sessions and auto-recover)
info JSON or
error message
returns a JSON encoded list of instances with all the data from the app detail page. Add form value info=full to also return the Additional Arguments.

All direct actions must be invoked with a type:
Type Description Requires Names
all all instances of all applications no
app all instances of the specified applications yes
ins all the specified instances

The direct action 'running' can be invoked with a num argument:
Num Description
all / -1 all instances of the application must be running. this is the default if no num argument is set
number a minimum of number instances of the specified application must be running. if there are less instances configured acts like 'all'

The direct action 'bounce' can be invoked with additional arguments:
Argument Value Description
bouncetype graceful | shutdown graceful bounces the application by starting a few instances per host and setting the rest to refusing sessions
shutdown bounces the application by stopping all instances and then restarting them (use this if your
application will migrate the database so the old application will crash)
The default bouncetype is graceful.
maxwait secs number of seconds to wait for applications to shut down themselves before force quitting the instances.
The default is 30 seconds.

Possible status codes:
Code Circumstance
200 (OK) return value is 'OK' or 'YES'
403 (Unauthorized) Monitor is password protected
404 (Not Found) one or more of the supplied application or instance names can't be found
406 (Not Acceptable) an unknown type is supplied, or names are required but missing
417 (Not Expected) return value is 'NO'
500 (Error) software defect (please send stacktrace from Monitor's log)

Examples:
URL Description
.../JavaMonitor.woa/admin/start?type=app&name=AppleStore&name=MemberSite Starts all instances of the AppleStore and the MemberSite applications. Returns error if any of these applications are unknown to Monitor, OK otherwise.
.../JavaMonitor.woa/admin/turnScheduledOff?type=all Turns scheduling off for all instances of all applications, then returns OK.
.../JavaMonitor.woa/admin/stopped?type=ins&name=AppleStore-4&name= MemberSite-8&name=AppleStore-2 Returns YES if the instances 2 and 4 of the AppleStore and instance 8 of the MemberSite are all dead. Returns NO if at least one of them has not stopped. Returns error if any of these instances are unknown to Monitor.

A simple deployment script could look as follows:
#!/bin/sh

# clean build
ant clean install

# run unit tests
ant test

# stop application
result=`curl -s http://bigserver:1086/cgi-bin/WebObjects/JavaMonitor.woa/admin/stop\?type=app&name=MemberSite`
[ "$result" = OK ] || { echo $result; exit 1; }

# deploy new application
scp -rq /Library/WebObjects/Applications/MemberSite.woa bigserver:/Library/WebObjects/Applications/

# start application
result=`curl -s http://bigserver:1086/cgi-bin/WebObjects/JavaMonitor.woa/admin/start\?type=app&name=MemberSite`
[ "$result" = OK ] || { echo $result; exit 1; }

echo "deployment completed"

Invoking direct actions manually:
curl -w " (status: %{http_code})\n" http://bigserver:1086/cgi-bin/WebObjects/JavaMonitor.woa/admin/forceQuit\?type=ins&name=AppleStore-3

Author:
christian@pekeler.org

ak


Constructor & Destructor Documentation

AdminAction ( WORequest  worequest  ) 


Member Function Documentation

void addInstancesForApplication ( MApplication  mapplication  )  [protected]

WOActionResults bounceAction (  ) 

void clearDeathsAction (  ) 

void forceQuitAction (  ) 

WOActionResults infoAction (  ) 

WOComponent MainAction (  ) 

Session mySession (  ) 

WOActionResults performActionNamed ( String  s  ) 

WOActionResults performMonitorActionNamed ( String  s  ) 

void prepareApplications ( NSArray  nsarray  )  [protected]

void prepareInstances ( NSArray  nsarray  )  [protected]

void refreshInformation (  )  [protected]

WOActionResults runningAction (  ) 

MSiteConfig siteConfig (  )  [private]

void startAction (  ) 

void stopAction (  ) 

WOActionResults stoppedAction (  ) 

void turnAutoRecoverOffAction (  ) 

void turnAutoRecoverOnAction (  ) 

void turnRefuseNewSessionsOffAction (  ) 

void turnRefuseNewSessionsOnAction (  ) 

void turnScheduledOffAction (  ) 

void turnScheduledOnAction (  ) 


Member Data Documentation

NSArray supportedActionNames [static, protected]

Initial value:

 new NSArray(new String[] { "running", "bounce", "stopped", "start", "stop", "forceQuit", "turnAutoRecoverOn", "turnAutoRecoverOff",
            "turnRefuseNewSessionsOn", "turnRefuseNewSessionsOff", "turnScheduledOn", "turnScheduledOff", "turnAutoRecoverOn", "turnAutoRecoverOff", "clearDeaths", "info" })


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:42:33 2012 for Project Wonder by  doxygen 1.5.8