Docstoc

Monet Execution Manager

Document Sample
Monet Execution Manager Powered By Docstoc
					12




Monet Execution Manager
            Manfred N. Riem
                  March 17, 2004




    / department of mathematics and computer science   1/26
12
What does the Execution Manager (EM) do?
 • Execute written or generated plans.
 • Call (mathematical) web services as specified in a plan.
 • Gives an explanation of an execution.
 • Delivers workflow management for plans.
 • Delivers a simple calculation environment.




               / department of mathematics and computer science   2/26
 12
Where does it plug into the Monet architecture?
In the Monet architecture the Execution manager is at the end of the
pipeline.
A possible scenario is:
 • The user poses a query and gets a result of possible plans that can solve
   the given problem.
 • The user picks one plan and submits it for execution to the Execution
   Manager.
 • The Execution Manager will execute the given plan and return the result
   (with or without explanation) to the user.




                / department of mathematics and computer science          3/26
 12
Looking at EM as a black box
As every component in the Monet architecture is implemented as a webser-
vice you can look at it as a blackbox delivering a specific service.
In the case of the EM this is transforming a plan written in MPL to an ex-
planation written in MEL. Where the explanation can simply be the result of
the execution, or a trace of the execution plus the result, or a more elaborate
result document in MEL.




               Input                Execution             Output
                                     Manager
               MPL                                        MEL




                 / department of mathematics and computer science            4/26
 12
Mathematical Planning Language (MPL)
The EM is written to support MPL. The syntax and semantics of MPL are
similar to the Business Process Execution Language (BPEL). There were
three good reasons for MPL to have a syntax similar to BPEL:
 1. It is a standard used in industry for non-mathematical processes and as
    such borrowing from its syntax makes it easier for users to understand
    MPL.
 2. Writing an EM based on an existing BPEL engine is a possibility.
 3. Integrating the EM into an existing BPEL process / environment is eas-
    ier when the language that is understood is the same language.




                / department of mathematics and computer science         5/26
 12
An example of MPL
<plan>
  ... parameters ...
  ... variables ...
  <sequence>
    ... assignments ...
    <sequence>
       <assign>
         <varref name="g"/>
         <invoke url="http://localhost:8080/gcdws/gcdws?MSDL">
           <mapping>
             <map inputname="a"><paramref name="firstValue"/></map>
             <map inputname="b"><paramref name="secondValue"/></map>
            </mapping>
         </invoke>
       </assign>
       <return><varref name="g"/></return>
    </sequence>
  </sequence>
</plan>


              / department of mathematics and computer science   6/26
 12
Mathematical Explanation Language (MEL)
When executing a plan the result returned is an explanation written in MEL.
The result could be the following things:
 • An answer only
 • An answer plus traces of the calls to webservices
 • An answer plus several explanations given by the invoked webservices
   and/or the plan itself.




                / department of mathematics and computer science         7/26
 12
An example of MEL
<monet:query-response ....>
 <monet:executionResponse>
  <monet:problem>
   ...
  </monet:problem>
  <monet:explanation>
   <monet:executionResponse>
    <monet:errorcode>0</monet:errorcode>
    <monet:explanationFormat isProvided="false"/>
    <monet:result>
     <monet:resultFormat type="xsd:int">123</monet:resultFormat>
    </monet:result>
   </monet:executionResponse>
  </monet:explanation>
  <monet:result>
   <monet:resultFormat type="xsd:int">234</monet:resultFormat>
  </monet:result>
 </monet:executionResponse>
</monet:query-response>


              / department of mathematics and computer science   8/26
 12
How does it work internally?
Our implementation of the Execution Manager uses the following set of
technologies:
 • XSL-T processing.
 • Jelly scripting.
 • Jelly extensions.



                        XSLT              Jelly    Jelly       MEL
                                                    Engine
             MPL




                               Jelly Extensions


                 / department of mathematics and computer science    9/26
 12
What is Jelly?
Jelly is a tool for turning XML into executable code. So Jelly is a Java and
XML based scripting and processing engine.
A Jelly script is an XML document which gets parsed into a Script. The
script can then be ran to produce dynamic XML events which can then be
turned into text, XML, HTML etc.


                                                      Text

                                   Jelly              XHTML
                       Jelly
                                     Engine               XML

                                                      SVG
                                                   ....




                / department of mathematics and computer science         10/26
 12
Example: Hello World
The input document could be:

<j:jelly xmlns:j="jelly:core">
  Hello World!
</j:jelly>

The output document would be:

Hello World!




               / department of mathematics and computer science   11/26
 12
Example: XML processing
<j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml">
  <x:parse var="doc">
    <web-app>
      <servlet>
        <servlet-name>snoop</servlet-name>
        <servlet-class>SnoopServlet</servlet-class>
      </servlet>
      <servlet>
        <servlet-name>file</servlet-name>
        <servlet-class>ViewFile</servlet-class>
        <init-param>
          <param-name>initial</param-name>
          <param-value>1000</param-value>
          <description>
            The initial value for the counter
          </description>
        </init-param>
      </servlet>



              / department of mathematics and computer science   12/26
 12
Example: XML processing (2)
      <servlet-mapping>
        <servlet-name>snoop</servlet-name>
        <url-pattern>/foo/snoop</url-pattern>
      </servlet-mapping>
    </web-app>
  </x:parse>
  <x:set var="count" select="count($doc//servlet)"/>
  <x:forEach var="s" select="$doc//servlet">
    name: <x:expr select="$s/servlet-name"/>
    class: <x:expr select="$s/servlet-class"/>
  </x:forEach>
  There are <x:expr select="$count"/> servlet(s)
</j:jelly>




              / department of mathematics and computer science   13/26
 12
Example: GCD using a GCD webservice
<j:jelly xmlns:j="jelly:core"
 xmlns:i="jelly:nl.tue.win.riaca.jelly.invoke.InvokeTagLibrary">
  <j:set var="a" value="${34}"/>
  <j:set var="b" value="${12}"/>

  <j:expr value="a=${a},"/>
  <j:expr value="b=${b},"/>
  <i:invoke var="r"
      service="Gcdws"
      port="GcdWebServiceIFPort"
      namespace="http://echoservice.org/wsdl"
      endpoint="http://localhost:8080/gcdws/gcdws"
      operation="gcd"
      returnType="xsd:int">
    <int_1 type="xsd:int"><j:expr value="${a}"/></int_1>
    <int_2 type="xsd:int"><j:expr value="${b}"/></int_2>
  </i:invoke>
  <j:expr value="r=${r}"/>
</j:jelly>


              / department of mathematics and computer science   14/26
 12
Example: GCD using an REM webservice
Instead of using a GCD webservice directly one can of course also use a
REM webservice (which does remainder for you) to perform a GCD.

<j:jelly xmlns:j="jelly:core"
 xmlns:i="jelly:nl.tue.win.riaca.jelly.invoke.InvokeTagLibrary">
  <j:set var="a" value="${34}"/>
  <j:set var="b" value="${12}"/>

  <j:if test="a lt b">
    <j:set var="r"><j:expr value="${a}"/></j:set>
    <j:set var="a"><j:expr value="${b}"/></j:set>
    <j:set var="b"><j:expr value="${r}"/></j:set>
  </j:if>

  <j:expr value="a=${a},"/>
  <j:expr value="b=${b},"/>




               / department of mathematics and computer science      15/26
 12
Example: GCD using an REM webservice (2)
  <j:while test="${b ne 0}">
    <i:invoke var="r"
        service="Remws"
        port="RemWebServiceIFPort"
        namespace="http://echoservice.org/wsdl"
        endpoint="http://localhost:8080/remws/remws"
        operation="rem"
        returnType="xsd:int">
      <int_1 type="xsd:int"><j:expr value="${a}"/></int_1>
      <int_2 type="xsd:int"><j:expr value="${b}"/></int_2>
    </i:invoke>
    <j:expr value="r=${r},"/>
    <j:set var="a"><j:expr value="${b}"/></j:set>
    <j:set var="b"><j:expr value="${r}"/></j:set>
    <j:expr value="a=${a},"/>
    <j:expr value="b=${b},"/>
  </j:while>
  <j:expr value="a=${a}"/>
</j:jelly>

              / department of mathematics and computer science   16/26
 12
How is Jelly integrated?
Coming back to the picture of the internals of the Execution Manager. The
input to the EM is MPL and its output is MEL.
How can we go from MPL to MEL? The answer is in the diagram below.
The MPL will need to be transformed to a Jelly script. For a simple plan the
transformation is an easy path, for a plan that contains an invocation to an
external webservice it is a bit more difficult.



                       XSLT              Jelly    Jelly       MEL
                                                   Engine
             MPL




                              Jelly Extensions


                / department of mathematics and computer science          17/26
 12
MPL invocation
MPL defines the invoke element so that a plan can call external webservices.
To make it work inside a Jelly context the invocation below needs to be trans-
lated into a Jelly invocation.
The translation needs the following things to work:
 • The MPL itself.
 • The MSDL of any mathematical webservice that needs to be called.
 • The WSDL of any mathematical webservice that needs to be called.

Note: the current version of the Execution Manager enables you to call Math-
ematical web services described by an MSDL file. If you want to call a non-
mathematical web service you will have to write a Jelly script manually.



                / department of mathematics and computer science           18/26
 12
Jelly invocation
Because Jelly does not contain support to call web services in the basic distri-
bution a Jelly extension was written. In the examples of Jelly given previously
we’ve used the extension written for it. How does it work?
To create a extension one needs to do the following:
 1. Write a Java class implementing the extension.
 2. Declare an XML namespace for the extension used.
 3. Associate the XML namespace with the Java class.
 4. Use the extension.




                 / department of mathematics and computer science            19/26
 12
Programming a Jelly extension class
 1. A library class.
 2. Several tag classes.

The library class is used for registering the tag classes under a specific
namespace. The tag classes are mapped on XML element.
A Java skeleton for a tag class
public class InvokeTag extends TagSupport
{
  public void doTag( XMLOutput output )
        throws MissingAttributeException, JellyTagException {
  }
}




                 / department of mathematics and computer science     20/26
 12
Using the extension class
In the example below 3 separate Jelly extensions are used.
  1. j namespace, the core set of Jelly tags
 2. x namespace, XML processing tags
  3. i namespace, a separate invoke tag library

<j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml"
 xmlns:i="jelly:nl.tue.win.riaca.jelly.invoke.InvokeTagLibrary">
 <x:parse var="input">
  <OMOBJ><OMI>123</OMI></OMOBJ>
  </x:parse>
 </x:parse>
 <i:invoke ....>
  <int_1 type="xsd:int">
   <x:expr select="$input/OMOBJ/OMI"/>
  </int_1>
 </i:invoke>
</j:jelly>


                     / department of mathematics and computer science   21/26
 12
GCD invocation using MEL
The previous examples of GCD didn’t return MEL. The example below does.
As you will notice the main difference is the presence of MEL elements in
the Jelly script.

<j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml"
 xmlns:i="jelly:nl.tue.win.riaca.jelly.invoke.InvokeTagLibrary">
 <x:element name="monet:query-response" ....>
  <x:element name="monet:executionResponse">
   <x:element name="monet:explanation">
    <j:set var="a" value="${34}"/>
    <j:set var="b" value="${12}"/>
    <i:invoke var="r"
       service="Gcdws"
       port="GcdWebServiceIFPort"
       namespace="http://echoservice.org/wsdl"
       endpoint="http://localhost:8080/gcdws/gcdws"
       operation="gcd"
       returnType="xsd:int">

               / department of mathematics and computer science      22/26
 12
GCD invocation using MEL (2)
     <int_1 type="xsd:int"><j:expr value="${a}"/></int_1>
     <int_2 type="xsd:int"><j:expr value="${b}"/></int_2>
    </i:invoke>
    <x:element name="monet:errorcode">0</x:element>
     <x:element name="monet:explanationFormat">
      <x:attribute name="isProvided">false</x:attribute>
     </x:element>
    </x:element>
    <x:element name="monet:result">
     <x:element name="monet:resultFormat">
      <x:attribute name="xsi:type">integer</x:attribute>
      <j:expr value="${r}"/>
     </x:element>
    </x:element>
   </x:element>
  </x:element>
 </x:element>
</j:jelly>



              / department of mathematics and computer science   23/26
12
Future plans
 • Support for additional (scripting) languages
 • Proper transaction support
 • Custom Jelly extensions for more process control
 • Distributed execution
 • Authentication support




               / department of mathematics and computer science   24/26
12


             Questions?




/ department of mathematics and computer science   25/26
12
References
 • JWSDP, http://java.sun.com/webservices/
 • Jelly, http://jakarta.apache.org/common/jelly/
 • BPEL, http://www.ibm.com/developerworks/library/ws-bpel/




               / department of mathematics and computer science   26/26

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:3
posted:2/5/2011
language:English
pages:26