Friday, March 18, 2005

Representing Policies as Aspects

The theories about aspects and aspect-oriented modeling are still developing. An aspect can be described by joint points and corresponding advice in terms of Aspect-Oriented Programming (AOP), which is an approach addresses the code tangling and code scattering issues. A joint point is the place where the concern will crosscut the application. An advice is the action that will be executed at the joint points. Similarly, a joint point of an autonomic policy is the target component or process whose behavior is modified to achieve the goal. The advice is the configuration parameters for managed resources. E.g. for the policy that
for the customers whose orders sum up to more than $3,000 in a day, apply 5% discount for the amount over $3,000.


the joint point is the pricing process of an item ordered by a customer, and the advice is to apply 5% discount to the amount over $3,000 if the sum of the customer's orders in that day exceed $3,000.

We could model policies as aspects. However, there are still many differences between policies and the aspects that we can implement using current AOP languages and tools. Policies are hierarchically organized. The subject of a high-level policy may have no idea about the details how its goal will be realized by low-level policies. The representations of policies may vary for the heterogeneous managed resources. The autonomic managers transform the policies to the versions that their managed resources can understand, and distribute them to the targets. Policy transformation and distribution will occur on each hierarchy of the system. The autonomic managers at higher hierarchies do not need to know all the details about how to deploy the policies. The complexity of these autonomic managers is reduced in this way.

The joint points and advice of a policy are modified in the process of transformation and distribution. E.g. for a policy to increase the service capability for all the web servers, the joint points are all the web servers in the resource pool, and the advice is to increase the service capability. When the policy is distributed to an Apache HTTP server, the joint point turns to the Multi-Processing Module, and the advice will be to increase the value of MaxClients, MinSpareThreads, and MaxSpareThreads with the constraint that MaxClients > ThreadsPerChild * ServerLimit.

The parameters in a policy are initialized in transformation and distribution. Suppose an enterprise has branches in charge of the business of different areas. Now a new policy as follows needs to be executed by all the branches.

For all customers whose orders sum up to more than certain amount in a day, apply certain discount for the amount over the amount.


The policy will be transformed to different versions at branches. For example, the amount and the discount are $3,000 USD and 5% for American customers, and $4,000 CAD and 4% for Canadian customers.

Policies transformation and distribution need a policy specification language. There are a number of running projects related to policy specification languages. XML-based specifications are widely endorsed. However, an industrial standard is in demand.

It will be easy to distribute policies represented in XML among autonomic elements using Web services. The policy will take effect once it is distributed and deployed at load time or runtime. AspectJ is a seamless aspect-oriented extension to the Java programming language. AspectJ defines the syntax for aspects and supplies a weaver to compose the system from classes and aspects. The future AspectJ will support XML representation of aspects and deployment at load time. The policy example in Section 3 may be implemented by the following code snippet in AspectJ.

public aspect TestDiscount {
pointcut checkOut() : call(public double getPrice(..));
after() : discount() {
applyDiscount(AMOUNT, PERCENT);
}
}

The joint point is a call to getPrice(..) method that retrieve the price of an item that the customer orders. The advice is to call applyDiscount(int amount, int percent) to apply the discount specified by certain AMOUNT and PERCENT.

No comments:

Post a Comment