incubator-imperius-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Neeraj Joshi <jnee...@us.ibm.com>
Subject RE: SPI , APIs etc
Date Thu, 24 Jan 2008 19:15:33 GMT
Hi Erik,
You are correct that the DC and AC are both bound to the Rule provider. 
What I was thinking was the rule provider could also use this same 
descriptor to pick which DC and AC implementation to instantiate.
It could be that there may be more than 1 implementations of each and the 
rule provider chooses which ones to use based on the descriptor. 
Alternatively, we could have the Rule provider read a seperate descriptor 
to keep things simple
What do you think?
Neeraj
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Those are my principles. If you don't like them I have others. -- Groucho 
Marx" 

http://incubator.apache.org/imperius
 
Neeraj Joshi
Autonomic Computing Policy Development
Tivoli, IBM

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



"Erik Bengtson" <erik@jpox.org> 
01/24/2008 01:49 PM
Please respond to
imperius-dev@incubator.apache.org


To
<imperius-dev@incubator.apache.org>
cc

Subject
RE: SPI , APIs etc






Neeraj,

I understand the datacollector and actuator instances are bound to the
policy rule provider, why configure them?

Erik
-----Message d'origine-----
De : Neeraj Joshi [mailto:jneeraj@us.ibm.com] 
Envoyé : mardi 22 janvier 2008 17:42
À : imperius-dev@incubator.apache.org
Objet : RE: SPI , APIs etc

Hi All,
Here is the proposed SPL descriptor 

<?xml version="1.0" encoding="UTF-8"?>
<SPL xmlns="http://org.apache.imperius"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://org.apache.imperius SPLDescriptor.xsd">
        <SPLConfiguration>
                <SPLHome>.</SPLHome>
                <SPLPolicyRuleProvider>
org.apache.imperius.javaspl.Java_SPLPolicyRuleProvider</
SPLPolicyRuleProvider>
                <SPLDataCollector>
org.apache.imperius.javaspl.JavaDataCollectorImpl</SPLDataCollector>
                <SPLActuator>org.apache.imperius.javaspl.JavaActuatorImpl
</SPLActuator>
                <logging>
                        <log-file>SPLLog.log</log-file>
                        <log-level>FINE</log-level>
                        <audit-file>SPLAudit.log</audit-file>
                </logging>
        </SPLConfiguration>
        <SPLExpressions>
                <SPLOperatorExpressionList>
                        <SPLOperatorExpression returnType="boolean" 
expressionType="Boolean">LogicalOr</SPLOperatorExpression>
                        <SPLOperatorExpression returnType="number" 
expressionType="Numeric">Addition</SPLOperatorExpression>
                </SPLOperatorExpressionList>
                <SPLActionExpressionList>
                        <SPLActionExpression>ReturnValues</
SPLActionExpression>
                </SPLActionExpressionList>
        </SPLExpressions>
 
</SPL>


And here is the schema 

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://org.apache.imperius"
xmlns="http://org.apache.imperius"
elementFormDefault="qualified">
<!--  Expression Classification  -->
  <xsd:simpleType name="expressionType">
   <xsd:restriction base="xsd:string">
     <xsd:enumeration value="Boolean"/>
     <xsd:enumeration value="Numeric"/>
     <xsd:enumeration value="String"/>
     <xsd:enumeration value="Collection"/>
     <xsd:enumeration value="DateTime"/>
   </xsd:restriction>
  </xsd:simpleType>
<!--  Data Type --> 
  <xsd:simpleType name="dataType">
   <xsd:restriction base="xsd:string">
     <xsd:enumeration value="boolean"/>
     <xsd:enumeration value="number"/>
     <xsd:enumeration value="byte"/>
     <xsd:enumeration value="short"/>
     <xsd:enumeration value="integer"/>
     <xsd:enumeration value="long"/>
     <xsd:enumeration value="float"/>
     <xsd:enumeration value="double"/>
     <xsd:enumeration value="string"/>
     <xsd:enumeration value="datetime"/>
     <xsd:enumeration value="long"/>
     <xsd:enumeration value="reference"/>
     <xsd:enumeration value="boolean[]"/>
     <xsd:enumeration value="number[]"/>
     <xsd:enumeration value="byte[]"/>
     <xsd:enumeration value="short[]"/>
     <xsd:enumeration value="integer[]"/>
     <xsd:enumeration value="long[]"/>
     <xsd:enumeration value="float[]"/>
     <xsd:enumeration value="double[]"/>
     <xsd:enumeration value="string[]"/>
     <xsd:enumeration value="datetime[]"/>
     <xsd:enumeration value="long[]"/>
     <xsd:enumeration value="reference[]"/>
   </xsd:restriction>
  </xsd:simpleType>
 
  <!--  Logging configuration -->
  <xsd:element name="log-file" type="xsd:anyURI"/>
  <xsd:element name="audit-file" type="xsd:anyURI"/>
 
  <xsd:element name="log-level">
    <xsd:simpleType>
      <xsd:restriction base="xsd:string">
        <xsd:enumeration value="OFF"/>
        <xsd:enumeration value="SEVERE"/>
        <xsd:enumeration value="WARNING"/>
        <xsd:enumeration value="INFO"/>
        <xsd:enumeration value="FINE"/>
        <xsd:enumeration value="FINER"/>
        <xsd:enumeration value="FINEST"/>
        <xsd:enumeration value="ALL"/>
      </xsd:restriction>
    </xsd:simpleType>
  </xsd:element>

  <xsd:element name="logging">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="log-file"/>
        <xsd:element ref="log-level"/>
        <xsd:element ref="audit-file"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
 
  <xsd:element name="SPL">
        <xsd:complexType>
           <xsd:sequence>
                <xsd:element maxOccurs="1" minOccurs="1"  ref=
"SPLConfiguration"/>
                <xsd:element maxOccurs="1" minOccurs="1"  ref=
"SPLExpressions"/>
           </xsd:sequence>
        </xsd:complexType>
  </xsd:element>
  <xsd:element name="SPLConfiguration">
        <xsd:complexType>
           <xsd:sequence>
                <xsd:element maxOccurs="1" minOccurs="1"  ref="SPLHome"/>
            <xsd:element maxOccurs="1" minOccurs="1"  ref=
"SPLPolicyRuleProvider"/>
                <xsd:element maxOccurs="1" minOccurs="1"  ref=
"SPLDataCollector"/>
                <xsd:element maxOccurs="1" minOccurs="1"  ref=
"SPLActuator"/>
                <xsd:element maxOccurs="1" minOccurs="1"  ref="logging"/>
           </xsd:sequence>
        </xsd:complexType>
  </xsd:element>
  <xsd:element name="SPLExpressions">
        <xsd:complexType>
           <xsd:sequence>
                <xsd:element maxOccurs="1" ref="SPLOperatorExpressionList"
/>
                <xsd:element maxOccurs="1" ref="SPLActionExpressionList"/>
           </xsd:sequence>
        </xsd:complexType>
  </xsd:element>
  <xsd:element name="SPLOperatorExpressionList">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element maxOccurs="unbounded" ref="SPLOperatorExpression"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="SPLActionExpressionList">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element maxOccurs="unbounded" ref="SPLActionExpression"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="SPLOperatorExpression">
    <xsd:complexType mixed="true">
      <xsd:attribute name="returnType" type="dataType" use="required"/>
      <xsd:attribute name="expressionType" type="expressionType" use=
"required"/>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="SPLActionExpression" type="xsd:string"/>
  <xsd:element name="SPLPolicyRuleProvider" type="xsd:string"/>
  <xsd:element name="SPLDataCollector" type="xsd:string"/>
  <xsd:element name="SPLActuator" type="xsd:string"/>
  <xsd:element name="SPLHome" type="xsd:string" default="."/>

 
 
</xsd:schema>


Comments / Suggestions?

Neeraj

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Those are my principles. If you don't like them I have others. -- Groucho 

Marx" 

http://incubator.apache.org/imperius
 
Neeraj Joshi
Autonomic Computing Policy Development
Tivoli, IBM

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



"Erik Bengtson" <erik@jpox.org> 
01/19/2008 06:10 AM
Please respond to
imperius-dev@incubator.apache.org


To
<imperius-dev@incubator.apache.org>
cc

Subject
RE: SPI , APIs etc






>SPI / API : The interfaces within the external package etc can be 
>classified into SPI or API. Are you referring to documenting which is 
>which and how to use them?

+ Some consistent naming across the methods

>or you are thinking there are more places where we could add APIs/ SPIs ? 


>(or we need to add more methods to the existing interfaces?)

Add and drop methods/interfaces

>XML schema for Expressions: I will give that a shot and will post it and 
>we can iterate over it (or if you have something already please share it)

Go ahead.

>You had also talked about a Factory that would instantiate the SPL 
engine. 
>I was thinking of a class with a static method which returns a singleton 
>instance of
>PolicyManager did you have anything more in mind?

IMO a singleton is not a good pattern inside a framework and should be 
handled by users if they need this pattern.

Here is a rough proposal for API (MBeans should also be in the API, but 
not specified here):

Interface Policy{
String getName();
Boolean deploy(); //update=true
Boolean deploy(boolean update);
Boolean undeploy();
}

Interface PolicyManager{...}
Interface SPI.DataColletor{...}
Interface SPI.Actuator{...}
Interface SPI.PolicyRuleProvider
{
getDataCollector();
getActuator();
}
Interface SPI.PolicyEvaluator
{
Object evaluate(Map params);
}
Class JavaSPL.PolicyRuleProviderImpl implements PolicyRuleProvider

Class SPLCore.PolicyManagerImpl implements PolicyManager

Class SPLCore.ImperiusFactory
{
static PolicyManager newPolicyManager(Map properties);
}

Example 1 (Factory and Evaluator):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", 
"JavaSPL.PolicyRuleProviderImpl");
m.put(...);
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
PolicyEvaluator eval = pm.newPolicyEvaluator(name);
Map result = eval.evaluate(parameters);

Example 2 (Custom Datastore):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", 
"JavaSPL.PolicyRuleProviderImpl");
m.put("org.apache.imperius.spl.DatastoreClass", 
"Custom.RDBMSDatastoreImpl");
m.put(...); //other properties e.g. datastore connection properties
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
PolicyEvaluator eval = pm.newPolicyEvaluator(name);
Map result = eval.evaluate(parameters);

Example 3 (Custom Evaluator - Evaluate via RMI):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", 
"JavaSPL.PolicyRuleProviderImpl");
m.put("org.apache.imperius.spl.DatastoreClass", 
"Custom.RDBMSDatastoreImpl");
m.put("org.apache.imperius.spl.PolicyEvaluatorClass", 
"Custom.RMIPolicyEvaluatorImpl");
m.put(...); //other properties e.g. datastore connection properties and 
rmi server
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
PolicyEvaluator eval = pm.newPolicyEvaluator(name);
Map result = eval.evaluate(parameters);

Example 3 (Deploy Policy):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", 
"JavaSPL.PolicyRuleProviderImpl");
m.put("org.apache.imperius.spl.DatastoreClass", 
"Custom.RDBMSDatastoreImpl");
m.put(...);
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
Policy policy = pm.newPolicy(name);
policy.deploy();

Example 4 (UnDeploy Policy):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", 
"JavaSPL.PolicyRuleProviderImpl");
m.put("org.apache.imperius.spl.DatastoreClass", 
"Custom.RDBMSDatastoreImpl");
m.put(...);
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
Policy policy = pm.getPolicy(name);
policy.undeploy();








Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message