In addition to known VBScript syntax, Business Logic formulas can contain special procedures as follows:
Called once at the start of calculations. Can be used for initializing global variables.
Called every time a period ends. IsCompleteRecord is True when the tracking period has ended and False when making an intermediate calculation.
Called every time a new period starts.
A mandatory procedure for associating events with user-defined procedures. OnRegistration is called once by the calculation engine at the beginning of the metric 's calculation.
Events are associated with procedures by using the methods of the Dispatcher object, as shown below:
This property enables the user to know if the Onregistration method is running as part of the actual calculation or during infrastructure processing. This is useful because sometimes, a customer has a significant amount code in the OnRegistration method. This code has no effect on registration, but must run whenever the resource structure changes (i.e. it needs to run inside the OnRegistration method).
Users often keep a map of the resource structure for calculation use. Since the resource structure is dynamic, the structure in the map should be updated when the resource structure changes. The registration function is called whenever the resource structure changes.
However, filling the map is not relevant to the registration purposes. This means that filling the map degrades performance of the OnRegistration function. This is not important during runtime, as it does not happen very often. But during Infrastructure Processing, this can happen a large number of times resulting in significant performance degradation with no benefit.
Actually, the code needs to run only when the system is actually calculating. The IsRuntimeMode property enables the customer to discover whether the code needs to run or not.
The tasks of filling maps and all other initializations that must run when a resource structure changes (but which are not relevant to the actual registration) can be done in a separate function.
In the two part Example 1 below, the first routine (OnRegistration(dispatcher)) contains the code which is relevant to the registration and must remain in the OnRegistration function. The second routine (New) contains the code which is not relevant to the registration and can be placed in the new function:
Example 1
Sub OnRegistration(dispatcher) Dim MyResource MyResource = Context.ClusterItem Dispatcher.RegisterByResource "OnEvent", "My Event Type", MyResource End Sub
Sub New
Dim ThisResourceMap
Set GlobalResourceVector= CreateObject("SlalomVector.Vector")
Dim resource
Set ThisResourceMap = Context.ResourcesOfResourceGroup(Context.ClusterItem)
For Each resource In ThisResourceMap
GlobalResourceVector.Add resource
Next
End Sub
Example 2
Sub OnRegistration(dispatcher)
Dispatcher.RegisterByResource “OnEvent”, ”my event type”, “my resource”
Dim a
For a = 1 to 1000000: next
End Sub
This code would have an adverse effect on the infrastructure processing stage of the calculations for no reason.
Instead, you can now use:
Sub OnRegistration(dispatcher)
Dispatcher.RegisterByResource “OnEvent”, ”my event type”, “my resource”
If (dispatcher.IsRuntimeMode) then
Dim a
For a = 1 to 1000000: next
End If
End Sub
Note: This method is no longer used.
This method enables registering for events which were sent by a specific metric. The method receives the following parameters:
Name of the method to call when an event arrives.
Type of events that are received by this registration.
Name of the Resource or Resource Group on which events are sent or 'Context.ClusterItem'. This parameter can contain the empty string (""). In this case (an empty string), the registration is performed on events which were sent to all resources (in SendEvent).
This parameter defines whether the current metric registers to receive metric events from tracking agent only (in which case the value to be provided is "tracking") or to receive events from all agents (each working agent of the current metric receives events from the corresponding agent of the sending metric. For example, hourly agent receives events from the hourly agent, the daily agent from the daily agent, etc. The value that should be provided in this case is "equivalent"). The 2 possible values are "tracking" and "equivalent".
Name of the metric to receive events from.
Name of the contract, which above metric belongs to. This parameter is optional - if it is not provided, do not provide the ContractPartyName (see below) either. If these parameters are not given, the system assumes that the MetricName belongs to the current contract.
Name of the contract party which the above contract belongs to. This parameter is optional. In case the parameter is not provided, the system assumes that the ContractName belongs to same contract party as the current contract.
Note: "ProcedureName" = "MethodName" and "EventType=EventTypeName"
Called when entering a TimeSlot.
Called when exiting a TimeSlot.
|
Copyright © 2012 CA.
All rights reserved.
|
|