Before you start
About this tutorial
This tutorial is written for IT Administrators who want to create new policies that define business rules and scenarios. After explaining some of the rudimentary concepts associated with a policy document, the tutorial describes a few fictional business scenarios. The tutorial then breaks the pieces of these scenarios into their policy-related components. Meanwhile, the policy Extensible Markup Language (XML) will be written and put together into functional policy documents.
You must have a basic knowledge of XML to complete this tutorial. Additionally, you should understand the ins and outs of the PMAC application. Resources contains some useful XML and PMAC-related links.
Introducing autonomic policy documents
Most, if not all, businesses have policies by which they operate. Some rules may dictate the business' resource behavior, while others may dictate the rules for business operation. This tutorial gives you an in-depth look into creating autonomic policy documents that can be used to automate and carry out business scenarios. Two example scenarios are used to illustrate the way in which generic business policies can be translated into PMAC XML policy documents.
Using policy documents with PMAC
The policy documents you create in this tutorial can be used in conjunction with PMAC to create a functional autonomic manager for your resources. See Resources for more information on setting up and using PMAC.
Introduction to the business scenarios
This section gives a high-level explanation of each of the business scenarios used in this tutorial.
A customer rewards policy
The first example scenario involves a fictional retail store's customer rewards policy. This is a business policy that dictates the type of discounts available to customers with different purchasing histories.
A server provisioning policy
The second example scenario deals with an IT shop's allocation of server resources. This is an IT policy that dictates when to add and remove servers depending on the number of users connected to the system, as well as other pertinent conditions.
Breaking down the scenarios
This section creates examples of the scenarios and breaks each down into their respective
if-then statements, which eventually become the Condition and Decision components of the policy documents. For a full explanation of these elements, see "How to write a complete XML policy using PMAC" in Resources.
Creating the if-then statements
For both scenarios, you need to create an
if-then statement that best sums up what the business or IT rule is trying to accomplish. This can be a somewhat subjective process, depending upon the complexity of a given scenario; therefore, heuristic testing of the
if-then statement is generally a good idea.
Customer rewards if-then statement
Expanding upon the scenario introduced in the Introduction to the business scenarios section for the customer rewards business rule, you could create the following example:
Listing 1. Customer rewards example
if the customer spent more than $4000 in the last six months, and more than $10,000 last year, then give him a 20% discount on all purchases for the next month. OR if the customer spent over $4000 in the last six months, but less than $10,000 last year, then give him a 10% discount on all purchases for the next month.
It is very important to note that PMAC policies do not have an explicit
else mechanism built in. This is handled by writing a separate policy document for each
if-then statement. This is explained in detail as you continue to build the policy document for the scenarios in this tutorial.
Server provisioning if-then statement
Expanding upon the scenario introduced in the Introduction to the business scenarios section for the server provisioning business rule, you could create the following example:
Listing 2. Server provisioning example
if there are currently ten or less servers online, and there are currently more than 3000 active connections then activate eight additional servers to take the extra workload.
Constructing the policy Condition if statements
This section breaks down each of the
if-then statements from the previous section into the Condition (also known as
if) component of the policy document. To really understand what is going on in this section, you must be familiar with the content of the "How to write a complete XML policy using PMAC" tutorial (see Resources).
The customer reward if statement
As you did in the "How to write a complete XML policy using PMAC" tutorial (see Resources), you first need to reword the if statement in the previous section to resemble an equation. In the case of the "if the customer spent more than $4000 in the last six months, and more than $10000 last year" statement, you could rewrite it as such:
Listing 3. Rewriting customer reward statement
if (the customer's orders over last 6 months > $400) and (the customer's orders for last year > $10,000)
That's pretty simple, right? Try to write the same sort of statement for the "if the customer spent over $4000 in the last six months, but less than $10,000 last year" condition. Check your answer by looking at the customer_if_answer.txt file from the sample code zip file that you can download from this tutorial.
The server provisioning if statement
Let's create a statement that resembles an equation for the server provisioning if statement in the previous section. The "if there are currently ten or less servers online, and there are currently more than 3000 active connections" statement could be rewritten as:
Listing 4. Rewriting server provisioning statement
if (the number of servers <= 10) and (the number of active connections > 3000)
Constructing the policy Condition XML
In this section, you'll take the
if statement "equations" from the previous section and convert them into PMAC Condition XML elements. To really understand what is going on in this section, you need to be familiar with the content of the "How to write a complete XML policy using PMAC" tutorial (see Resources).
The customer reward Condition XML
Let's create a few variables to represent the amount a customer spent. These are used during run time to set actual values for the policy to use when evaluating the statements. For more information on this, see Resources.
Orders_Over_Last_6_Months to represent a customer's orders over the last six months, and
Orders_Over_Last_Year to represent a customer's orders over the last year. You'll use these variables as Property Sensors in the example policy. Listing 5 shows the Condition XML for the customer reward scenario:
Listing 5. Condition XML for customer reward scenario
<acpl:Condition> <exp:And> <exp:Greater> <exp:PropertySensor propertyName="Orders_Over_Last_6_Months"/> <exp:IntConstant> <Value>4000</Value> </exp:IntConstant> </exp:Greater> <exp:Greater> <exp:PropertySensor propertyName="Orders_Over_Last_Year"/> <exp:IntConstant> <Value>10000</Value> </exp:IntConstant> </exp:Greater> </exp:And> </acpl:Condition>
If you have not yet completed the "How to write a complete XML policy using PMAC" tutorial (see Resources), this may look a bit like graffiti. But if you are familiar with the Condition structure, you can see how the
PropertySensor elements are being compared to a preset constant.
The server provisioning Condition XML
Now, it is your turn to try writing a Condition. Using the server provisioning
statement from the previous section, construct your own Condition XML. Use the variables
NumberOfActiveConnections to represent the current number of servers and current number of connections, respectively. Check your answer against the server_xml_answer.txt file in the sample code zip file that you can download from this tutorial.
Constructing the policy Decision then statements
then portion of the
if-then statement is the policy Decision. It determines the action to be taken given a Condition that evaluates to true. This tutorial deals with result-based policies, which tend to be fairly straightforward. For information about the different types of decisions, see the developerWorks article "An Introduction to Policy for Autonomic Computing" (see Resources).
The customer reward then statement
In the customer rewards scenario, there are two different outcomes depending on which Condition you used. Let's rewrite the first statement, "then give him a 20% discount on all purchases for the next month" as:
then discount = .20
The other statement, "then give him a 10% discount on all purchases for the next month," would translate to this:
then discount = .10
It doesn't get much simpler than that!
The server provisioning "then" statement
The server provisioning Decision is just as simple to break down as the customer reward. The statement "activate eight additional servers to take the extra workload" can be rewritten as:
then AddServersNumber = 8
AddServersNumber is a variable that represents the number of servers to add to the configuration.
Constructing the policy Decision XML
In this section, you will take the
then statements from the previous section and convert them into PMAC Decision XML elements. To really understand what is going on in this section, you must be familiar with the content of the "How to write a complete XML policy using PMAC" tutorial (see Resources).
The customer reward XML
Much like the Condition XML you created earlier, the Decision XML will use a variable, known as a
Property, to represent the discount rate. You'll call this variable
Listing 6 shows what the Decision XML snippet would look like:
Listing 6. Decision XML code snippet
<acpl:Decision> <acpl:Result> <acpl:Property propertyName="Discount"> <exp:FloatConstant> <Value>.20</Value> </exp:FloatConstant> </acpl:Property> </acpl:Result> <acpl:Decision>
then statement would look exactly the same, except the
FloatConstant would be set to .10 rather than .20.
The server provisioning XML
AddServersNumber as a variable (in other words,
Property) that represents the number of servers to add to the configuration, you would get the XML snippet shown in Listing 7 for the Decision:
Listing 7. Decision XML code snippet
<acpl:Decision> <acpl:Result> <acpl:Property propertyName="AddServersNumber"> <exp:IntConstant> <Value>8</Value> </exp:InConstant> </acpl:Property> </acpl:Result> <acpl:Decision>
Constructing the Policy Business Value
The Business Value is not as complicated a topic as the Condition and Decision, but it does deserve mention for each of the scenarios. This section presents a business value case for each of the scenarios.
The customer reward business value
There are cases where two or more policies could evaluate to true, and the autonomic manager would need to decide which one takes precedence. For example, the customer rewards policy could use the business value to give a discount to a loyal customer before (or instead of) a new customer. I'll use a more generic business value case for this tutorial; specifically, one that rewards a customer who spends more, and ignores one who spends less. Not the smartest practice for a retail store to adopt, but it suits this tutorial just fine.
To implement this, simply create a business value that is higher for the policy that gives a 20% discount for the customer who spends more than $4000 in six months, and more than $10,000 in a year. To see this business value XML in the context of a policy document, see the customer_rewards1.xml and customer_rewards2.xml files in the sample code zip file that you can download from this tutorial.
The server provisioning business value
In the server provisioning scenario, a higher business value could grant precedence to a policy that checked for server connections and CPU utilization rate over policies that checked only one of those conditions. To see this business value XML in the context of a policy document, see the server_provisioning1.xml and server_provisioning2.xml files in the downloadable zip file.
Constructing the Policy Scope
I won't dwell on the policy scope component of the policy document, but will simply define separate scopes for each of the scenarios. This is not to take away from the importance of the scope element in PMAC, but it is beyond the scope of this tutorial to delve deeply into the scope.
The customer rewards scenario will use a scope named
Customer_Rewards, and the server provisioning scenario will use
Server_Provisioning. Makes sense! To see this scope XML in the context of a policy document, see the customer_rewards1.xml and customer_rewards2.xml files in the downloadable zip file.
In this tutorial, you have created complete policy document XML files that model
real-world, fictional business and IT scenarios. You have learned to break down each of the
components of an
if-then statement and translate them into policy XML and to further distinguish these policies using the business value and scope elements.
|Collection of samples for this tutorial||ac-buspmacsource.zip||56 KB|
- "How to write a complete XML policy using PMAC" (developerWorks, September 2005) describes how to use policy documents in concert with the PMAC component to manage resources quickly and efficiently.
- A related article titled " An Introduction to Policy for Autonomic Computing" (developerWorks, March 2005) introduces the concept of policy-based management, talks briefly about key standards, and discusses how policies can be structured.
- To learn how to programmatically create policies, see the tutorial "Using the ACPolicy API" (developerWorks, June 2005).
- To get more information on XML, check out the XML Zone on developerWorks. You'll find articles for beginner, intermediate, and advanced XML programming.
- For information on how to use the PMAC application, see the "Use Policy Management for Autonomic Computing (developerWorks, April 2005) tutorial.
- For information on the WS-Policy standard definition, see Web Services Policy Framework on developerWorks.
Get products and technologies
- Policy Management for Autonomic Computing (PMAC) Version 1.2.0 can be downloaded from the alphaWorks Web site.
- For information and trial downloads for IBM Rational Software Architect, check out the Rational Software Architect site.
- For information and trial downloads for the entire IBM Rational portfolio, visit the Rational Software page at www.ibm.com.
Dig deeper into Tivoli (service management) on developerWorks
Get samples, articles, product docs, and community resources to help build, deploy, and manage your cloud apps.
Keep up with the best and latest technical info to help you tackle your development challenges.
Software development in the cloud. Register today to create a project.
Evaluate IBM software and solutions, and transform challenges into opportunities.