Last updated: December 1, 2009
This service requires:
Note that all machines submitting REGISTER/UNREGISTER requests to the Timer V3.x service and all machines specified in a WATCH/UNWATCH must be running STAF V3.0.0 or later.
Install the Timer service by downloading the TimerV303.tar/zip file from Get STAF Services and extracting its contents to a local directory (e.g. C:\STAF\services or /usr/local/staf/services). The STAFTimer.jar file is the service jar file needed when registering the Timer service.
The Timer service is written in Java and since it is an external service, it must be registered with the SERVICE configuration statement in the STAF configuration file. The syntax is:
SERVICE <Name> LIBRARY JSTAF EXECUTE <Service Jar File Name>
[OPTION <Name[=Value]>]... [PARMS <Data Directory>]
where:
SERVICE Timer LIBRARY JSTAF EXECUTE C:/STAF/services/timer/STAFTimer.jar
SERVICE Timer LIBRARY JSTAF EXECUTE /usr/local/staf/services/timer/STAFTimer.jar
SERVICE Timer LIBRARY JSTAF EXECUTE {STAF/Config/STAFRoot}/services/timer/STAFTimer.jar PARMS {STAF/DataDir}/service/timer
Or, you can dynamically add the Timer service using the SERVICE service's ADD SERVICE
request.
REGISTER TYPE <Type> FREQUENCY <Milliseconds> [PRIORITY <Level>] [KEY <Key>]
[BYNAME] [UNREGONNOPATH <1 | 0>] [UNREGONNOHANDLE <1 | 0>]
TYPE specifies a name used to identify the type of timer.
FREQUENCY specifies the frequency of the timer in milliseconds.
PRIORITY specifies the priority level of the notification message to be sent to the registering machine. The default value is 5.
KEY specifies a key to identify the timer. The default value is an empty string. Any timer registered with a key must be unregistered specifying the key.
BYNAME specifies to register the timer by process name rather than by the handle of the process. Any timer registered by name must be unregistered by name.
UNREGONNOPATH may be specified to set timer specific values for the UnregisterOnNoPath variable. If this option is not specified, the timer will use the global values specified via the STAF VAR service.
UNREGONNOHANDLE may be specified to set timer specific values for the UnregisterOnNoHandle variable. If this option is not specified, the timer will use the global values specified via the STAF VAR service.
Note: If a timer already exists with the same TYPE, registering machine and process or handle, and key, you will get an Already Exists error code returned.
The Timer service uses the STAF Queue service for interprocess communication. See "Timer Queue Messages".
Minimum security level of 3 required to register a timer.
All return codes from REGISTER are documented in Appendix A, "API Return Codes", in the STAF User's Guide.
The result buffer will contain an error message if an error occurred and will be empty otherwise.
UNREGISTER TYPE <Type> [KEY] [BYNAME | <MACHINE <Machine> HANDLE <Handle #> | NAME <Handle Name>>]
TYPE specifies the type of the timer to terminate. This must be the same as the TYPE option used when the timer was registered.
KEY specifies a key to identify the timer. This must be the same as the KEY option used when the timer was registered, or do not specify the key if no key was specified when the timer was registered.
MACHINE specifies the machine which issued the register command if different from the current machine.
HANDLE specifies the handle number of the process which issued the REGISTER command if different from the current process handle number.
NAME specifies the handle name of the process which issued the REGISTER command.
BYNAME specifies to unregister this timer using the handle name rather than the handle number of the process. This is required if the timer was registered using the handle name.
Note: If the MACHINE parameter is specified, then BYNAME cannot be specified. The timer will be unregistered using either the handle number or the handle name based upon which parameter (HANDLE or NAME) is specified with MACHINE.
Minimum security level of 3 required for a process to unregister a timer which it previously registered. Minimum security level of 4 required for a process to unregister a timer registered by a process on a different machine.
All return codes from UNREGISTER are documented in Appendix A, "API Return Codes", in the STAF User's Guide.
The result buffer will contain an error message if an error occurred and will be empty otherwise.
Note: The machine to be watched must have Timer Service V3.0.0 or later running.
WATCH MACHINE <Machine> FREQUENCY <Milliseconds> [MARGIN <Milliseconds>]
MACHINE specifies the name of the machine to be watched.
FREQUENCY specifies the frequency at which the machine should send notifications, in milliseconds.
MARGIN specifies the allowable margin of error, in milliseconds, in the response time of the machine being watched, before the machine is considered to be not responding.
Note: If the optional parameter MARGIN is not specified then the allowable margin of error is assumed to be 0.
Minimum security level of 3 required to register a machine to be watched.
All return codes from WATCH are documented in Appendix A, "API Return Codes", in the STAF User's Guide.
The result buffer will contain an error message if an error occurred and will be empty otherwise.
UNWATCH MACHINE <Machine>
MACHINE specifies the name of the machine to stop watching.
Minimum security level of 4 required for a process to unwatch a machine.
All return codes from UNWATCH are documented in Appendix A, "API Return Codes", in the STAF User's Guide.
The result buffer will contain an error message if an error occurred and will be empty otherwise.
LIST <TIMERS [LONG]> | WATCHES | SETTINGS
TIMERS specifies to list the registerd timers.
LONG provides more detailed information when listing the registered timers.
WATCHES specifies to list the watches.
SETTINGS specifies to list the operational settings for the service.
Minimum security level of 2 is required.
All return codes from LIST are documented in Appendix A, "API Return Codes", in the STAF User's Guide.
| Definition of map class STAF/Service/Timer/Timer | |||
|---|---|---|---|
| Description: This map class represents a registered timer. | |||
| Key Name | Display Name | Type | Format / Value |
| type | Type | <String> | |
| machine | Machine | <String> | |
| notifyBy | Notify By (Notify) |
<String> | 'Handle' | 'Name' |
| notifiee | Notifiee | <String> | |
| key | Key | <String> | |
| lastTimestamp | Last Fired Date-Time (Last Date-Time) |
<String> | <None> | <YYYYMMDD-HH:MM:SS> |
| frequency | Frequency (Freq) |
<String> | |
Notes:
| |||
| Definition of map class STAF/Service/Timer/TimerLong | |||
|---|---|---|---|
| Description: This map class represents detailed information about a registered timer. | |||
| Key Name | Display Name | Type | Format / Value |
| type | Type | <String> | |
| machine | Machine | <String> | |
| notifyBy | Notify By | <String> | 'Handle' | 'Name' |
| notifiee | Notifiee | <String> | |
| key | Key | <String> | |
| lastTimestamp | Last Fired Date-Time | <String> | <None> | <YYYYMMDD-HH:MM:SS> |
| frequency | Frequency | <String> | |
| priority | Priority | <String> | |
| unRegOnNoPath | Unregister On No Path | <String> | 'true' | 'false' | 'global' |
| unRegOnNoHandle | Unregister On No Handle | <String> | 'true' | 'false' | 'global' |
Notes:
| |||
| Definition of map class STAF/Service/Timer/Watch | |||
|---|---|---|---|
| Description: This map class represents a watch. | |||
| Key Name | Display Name | Type | Format / Value |
| machine | Machine | <String> | |
| status | Status | <String> | 'OK' | 'Missed' |
| lastTimestamp | Last Fired Date-Time (Last Date-Time) |
<String> | <None> | <YYYYMMDD-HH:MM:SS> |
| frequency | Frequency (Freq) |
<String> | |
| margin | Margin | <String> | |
Notes:
| |||
| Definition of map class STAF/Service/Timer/Settings | |||
|---|---|---|---|
| Description: This map class represents the settings for the Timer service. | |||
| Key Name | Display Name | Type | Format / Value |
| directory | Directory | <String> | |
Notes:
| |||
Syntax: LIST TIMERS
Output: If the request is submitted from the command line and the commands in the file are executed successful, the result, in default format, could look like:
Type Machine Notify Notifiee Key Last Date-Time Freq
------------ --------------- ------ ------------ ---- ----------------- ------
TIMER1 tcp://client1.c Handle 62 <None> 300000
ompany.com@6500
HEARTBEAT tcp://client2.c Handle 49 20050215-15:30:36 60000
ompany.com@6500
FULL_REFRESH tcp://client3.c Name REFRESH 20050215-15:28:44 600000
ompany.com@6500
STAF/SERVICE tcp://client2.c Name STAF/Service CLIE 20050215-15:20:53 60000
/TIMER/WATCH ompany.com@6500 /Timer NT2
STAF/SERVICE tcp://client1.c Name STAF/Service CLIE 20050215-15:20:46 45000
/TIMER/WATCH ompany.com@6500 Timer/Watch NT1
Syntax: LIST TIMERS LONG
Output: If the request is submitted from the command line and the commands in the file are executed successful, the result, in default format, could look like:
[
{
Type : TIMER1
Machine : tcp://client1.company.com@6500
Notify By : Handle
Notifiee : 62
Key :
Last Fired Date-Time : <None>
Frequency : 300000
Priority : 4
Unregister On No Path : global
Unregister On No Handle: global
}
{
Type : HEARTBEAT
Machine : tcp://client2.company.com@6500
Notify By : Handle
Notifiee : 49
Last Fired Date-Time : 20050215-15:20:53
Frequency : 60000
Priority : 5
Unregister On No Path : global
Unregister On No Handle: global
}
{
Type : FULL REFRESH
Machine : tcp://client3.company.com@6500
Notify By : Name
Notifiee : REFRESH
Last Fired Date-Time : 20050215-15:28:44
Frequency : 600000
Priority : 2
Unregister On No Path : true
Unregister On No Handle: false
}
{
Type : STAF/SERVICE/TIMER/WATCH
Machine : tcp://client2.company.com@6500
Notify By : Name
Notifiee : STAF/Service/Timer
Last Fired Date-Time : 20050215-15:20:53
Frequency : 60000
Priority : 5
Unregister On No Path : global
Unregister On No Handle: true
}
{
Type : STAF/SERVICE/TIMER/WATCH
Machine : tcp://client1.company.com@6500
Notify By : Name
Notifiee : STAF/Service/Timer/Watch
Last Fired Date-Time : 20050215-15:20:46
Frequency : 45000
Priority : 5
Unregister On No Path : false
Unregister On No Handle: false
}
]
Syntax: LIST WATCHES
Output: If the request is submitted from the command line and the commands in the file are executed successful, the result, in default format, could look like:
Machine To Watch Machine Status Last Fired Date-Time Frequency Margin ---------------------- -------------- -------------------- --------- ------ CLIENT1 OK 20050215-15:20:46 60000 10000 SERVER1.AUSTIN.IBM.COM Missed 20050215-12:24:55 600000 30000
Syntax: LIST SETTINGS
Output: If the request is submitted from the command line, the result, in default format, could look like:
Directory: C:\STAF\data\STAF\service\timer
REFRESH
Minimum security level of 3 required to refresh variables.
All return codes from REFRESH are documented in Appendix A, "API Return Codes", in the STAF User's Guide.
The result buffer contains no data on return from a REFRESH command.
STAF server1.company.com timer VERSION
Output:
3.0.3
STAF local timer HELP
Output:
Timer Service Help REGISTER TYPEFREQUENCY [PRIORITY ] [KEY ] [BYNAME] [UNREGONNOPATH <1 | 0>] [UNREGONNOHANDLE <1 | 0>] UNREGISTER TYPE [KEY] [BYNAME | HANDLE | NAME >] WATCH MACHINE FREQUENCY [MARGIN ] UNWATCH MACHINE LIST | WATCHES | SETTINGS REFRESH VERSION HELP
The timers use the STAF QUEUE service to send notifications to the process which submitted the REGISTER command.
The behavior of the timer if the process is not available is controlled by the variables UnregisterOnNoHandle and UnregisterOnNoPath.
The message queued to the process will have a queue type of "STAF/Service/Timer" with the content of the message being a <Map> defined as follows:
| Definition for message map for a "STAF/Service/Timer" type queued message | ||
|---|---|---|
| Description: This map represents a timer message. | ||
| Key Name | Type | Format / Value |
| type | <String> | |
| timerServiceName | <String> | |
| timestamp | <String> | <YYYYMMDD-HH:MM:SS> |
| key | <String> | |
Notes:
| ||
Here's an example of a queued message with queue type "STAF/Service/Timer" generated by the Timer service:
STAF local QUEUE GET WAIT
{
Priority : 5
Date-Time : 20050216-14:46:23
Machine : server1.austin.ibm.com
Handle Name: STAF/Service/Timer
Handle : 15
User : none://anonymous
Type : STAF/Service/Timer
Message : {
timerServiceName: Timer
type : HEARTBEAT
timestamp : 20050216-14:46:23
key :
}
}
There are no additional Timer return codes. The Timer service uses the common STAF return codes.