The following example shows in detail how a guarantee is evaluated by the WSAG4J framework as described in the section Guarantee Definition. The example is based on a simple template for a computational job execution. This sample template contains a single service description term (SDT) that describes the computational job using the Job Submission Description Language (JSDL). Additionally, the template contains a Service Properties definition, which specifies a set of variables. Finally, the template contains one guarantee that specifies a reward and a penalty for meeting respectively violating the service level objective of the guarantee.
The following snippet shows the SDT defined in the sample template. The service description specifies an application "ACME_WebService" (version 1.0). The application requires a set of resources at runtime, which are described in the JSDL Resources section.
<wsag:ServiceDescriptionTerm wsag:Name="COMPUTE_SDT" wsag:ServiceName="ComputationalService"> <jsdl:JobDefinition xmlns:jsdl="http://schemas.ggf.org/jsdl/2005/11/jsdl"> <jsdl:JobDescription> <jsdl:Application> <jsdl:ApplicationName>ACME_WebService</jsdl:ApplicationName> <jsdl:ApplicationVersion>1.0</jsdl:ApplicationVersion> <jsdl:Description>The ACME Web Service.</jsdl:Description> </jsdl:Application> <jsdl:Resources> <jsdl:IndividualCPUSpeed> <jsdl:LowerBoundedRange>2.0E9</jsdl:LowerBoundedRange> </jsdl:IndividualCPUSpeed> <jsdl:IndividualCPUCount> <jsdl:Exact>2.0</jsdl:Exact> </jsdl:IndividualCPUCount> <jsdl:TotalResourceCount> <jsdl:Exact>16.0</jsdl:Exact> </jsdl:TotalResourceCount> </jsdl:Resources> </jsdl:JobDescription> </jsdl:JobDefinition> </wsag:ServiceDescriptionTerm>
Next, the template defines the service properties. The service properties contain a set of variable definitions that are later used to define the Service Level Objective of a service guarantee.
<wsag:ServiceProperties wsag:Name="COMPUTE_PROPERTIES" wsag:ServiceName="ComputationalService"> <wsag:VariableSet> <wsag:Variable wsag:Name="SERVICE_STATE" wsag:Metric="xs:string"> <wsag:Location> declare namespace wsag='http://schemas.ggf.org/graap/2007/03/ws-agreement'; $this/wsag:Terms/wsag:All/wsag:ServiceDescriptionTerm [@wsag:Name='COMPUTE_SDT']/wsag:State </wsag:Location> </wsag:Variable> <wsag:Variable wsag:Name="REQ_CPU_SPEED" wsag:Metric="xs:double"> <wsag:Location> declare namespace jsdl='http://schemas.ggf.org/jsdl/2005/11/jsdl'; declare namespace wsag='http://schemas.ggf.org/graap/2007/03/ws-agreement'; $this/wsag:Terms/wsag:All/wsag:ServiceDescriptionTerm [@wsag:Name = 'COMPUTE_SDT']/jsdl:JobDefinition/jsdl:JobDescription /jsdl:Resources/jsdl:IndividualCPUSpeed/jsdl:LowerBoundedRange </wsag:Location> </wsag:Variable> <wsag:Variable wsag:Name="ACT_CPU_SPEED" wsag:Metric="xs:double"> <wsag:Location> declare namespace jsdl='http://schemas.ggf.org/jsdl/2005/11/jsdl'; declare namespace wsag='http://schemas.ggf.org/graap/2007/03/ws-agreement'; $this/wsag:ServiceTermState[@wsag:termName='COMPUTE_SDT'] /jsdl:JobDefinition/jsdl:JobDescription/jsdl:Resources /jsdl:IndividualCPUSpeed/jsdl:Exact </wsag:Location> </wsag:Variable> </wsag:VariableSet> </wsag:ServiceProperties>
The Service Properties element defines three variables. The first variable SERVICE_STATE resolves the current service provisioning state, the second variable REQ_CPU_SPEED resolves the requested CPU speed of the resources at runtime, and the last variable ACT_CPU_SPEED resolves the CPU speed of the actually provided resources. The variable definitions include a location element that defines how the variable values are resolved from the agreement resource properties document. The WSAG4J framework uses XQuery to resolve the variable values of Service Properties since it allows to define namespace prefixes as part of the XQuery expression.
Notice that the locations of the SERVICE_STATE variable and of the ACT_CPU_SPEED variables refer to a service term state element. This specific element only exists at runtime in the Agreement Resource Properties document. It contains state information for the compute service at service provisioning time. This state information is produced by the agreement monitoring system once an agreement is in the Observed state (see agreement monitoring).
As mentioned before, the variables defined in the service properties are used to specify the Qualifying Condition or the Service Level Objective of a guarantee. A guarantee term definition may specify qualifying conditions that must be met before the guarantee is evaluated. In case the Qualifying Condition is not met, the guarantee is not evaluated and the corresponding guarantee term state will change to NotDetermined. The following shows a guarantee term with a Qualifying Condition and a Service Level Objective using the variables defined in the Service Properties shown above.
<wsag:GuaranteeTerm wsag:Name="CPU_SPEED_GUARANTEE"> <wsag:ServiceScope wsag:ServiceName="ComputationalService"/> <wsag:QualifyingCondition>SERVICE_STATE eq 'Ready'</wsag:QualifyingCondition> <wsag:ServiceLevelObjective> <wsag:KPITarget> <wsag:KPIName>CPU SPEED</wsag:KPIName> <wsag:CustomServiceLevel>ACT_CPU_SPEED ge REQ_CPU_SPEED</wsag:CustomServiceLevel> </wsag:KPITarget> </wsag:ServiceLevelObjective> <wsag:BusinessValueList> <wsag:Penalty> <wsag:AssessmentInterval> <wsag:TimeInterval>P5M</wsag:TimeInterval> </wsag:AssessmentInterval> <wsag:ValueUnit>Euro</wsag:ValueUnit> <wsag:ValueExpression>5</wsag:ValueExpression> </wsag:Penalty> <wsag:Reward> <wsag:AssessmentInterval> <wsag:TimeInterval>P5M</wsag:TimeInterval> </wsag:AssessmentInterval> <wsag:ValueUnit>Euro</wsag:ValueUnit> <wsag:ValueExpression>10</wsag:ValueExpression> </wsag:Reward> </wsag:BusinessValueList> </wsag:GuaranteeTerm>
This particular qualifying condition is coupled to the execution state of the provided service. This state is resolved by the SERVICE_STATE variable. Only if the service is in the Ready state (the service is up and running) the guarantee is evaluated. If the service is not set up yet (NotReady) or already shut down (Completed) the guarantee is not evaluated. In case the qualifying condition is met and the service is active, the CPU_SPEED_GUARANTEE is evaluated. The guarantee defines a reward in case the service level objective is met, and a penalty if the service level objective is violated.
When the computation of the guarantee term states is finished, penalties and rewards are issued to the accounting component. By default, the WSAG4J framework writes an info message for each accounting event to the log file (see SimpleAccountingSystemLogger). Specific implementations can also use these events to trigger self-management or self optimizing actions based on the guarantee evaluation. Custom accounting system implementation must implement the IAccountingSystem interface.
public class SimpleAccountingSystem implements IAccountingSystem { ... public void issueCompensation(CompensationType compensation, IAccountingContext context) { super.issueCompensation(compensation, context); ... this.compensation = (context.getEvaluationResult()) ? "reward" : "penalty"; this.amount = Double.parseDouble(XmlString.Factory.parse(compensation.getValueExpression().getDomNode()).getStringValue()); ... } ... }
The code snippet below shows how the sample accounting system is configured for a monitored agreement.
SimpleAccountingSystem accountingSystem = new SimpleAccountingSystem(); monitorAgreement.setAccountingSystem(accountingSystem);