Accounting Policy
An accounting policy is used to add local policy to the process of creating an usage record. While a usage record is being constructed each of the defined accounting policies are invoked in turn. Each one can see the accounting properties that have been defined by the parser and the previous accounting policies and can use these to add new Properties to the UsageRecord. A common use of an accounting policy might be to calculate a charge for the UsageRecord. They can also be used to implement other local policies. For example generating the charging budget for a job based on the username and/or the groupname the job was run under.
Predefined Accounting Policies
The following policies are available by default:
- Classification Policy
- Listener Policy
- Derived Property
- Expression Property Policy
- AliasProperty Policy
Custom Accounting Policies
Accounting policies may be defined to implement specific tasks unique to the environment in which Grid-SAFE is deployed. A policy is essentially a Java class that implements uk.ac.ed.epcc.safe.accounting.UsageRecordPolicy. This interface has several methods that must be defined appropriately. See the relevant Javadoc for descriptions of what these methods do.
To make life a little easier, one may instead choose to extend the class uk.ac.ed.epcc.safe.accounting.policy.BasePolicy. This class defines all method required by the interface. Each method does nothing. Subclasses may override these default definitions to provide functionality. This class is useful as UsageRecordPolicy provides many hooks which can be used when applying policy to usage record data. Most of these hooks will not be needed most of the time so it is helpful to have them automatically implemented.
Once the policy class has been written, it's class files must be placed on the classpath being used by the Grid-SAFE application of interest. Once there, it can be referenced in configuration properties using it's binary name (that is it's full class name which includes it's parent packages. e.g. java.lang.String is the full binary name of Java's standard String class). As these names are often quite long you can define aliases in the java properties e.g.
classdef.MyPolicy=com.example.policies.MyPolicy