Docstoc

Globus C Web Services Core for Developers

Document Sample
Globus C Web Services Core for Developers Powered By Docstoc
					Globus C Web Services Core
      for Developers
       Bill Allcock, ANL
        Joe Bester, ANL
  GlobusWORLD / GridWORLD
           Sep 2006
                        Features
       Hosting web services written in C and C++
       Implementation of WSRF concepts and port
        types
       Type, client, and service bindings generator
        from WSDL and XML schemas to C
       Client APIs and programs




Sep 2006             GlobusWORLD / GridWORLD           2
                 Service Engine/Container
       API (globus_service_engine) for processing
        WS requests within an application
              Uses HTTP processor in XIO
              SOAP serializer/deserializer
              Service loading and invocation
       Program for hosting services
              globus-wsc-container




Sep 2006                   GlobusWORLD / GridWORLD   3
                    Service Engine Usage
       globus_service_engine_init()
       To manage connection usage:
              globus_service_engine_register_session(),
               globus_service_engine_register_process()
       For simplicity
              globus_service_engine_register_start(),
               globus_service_engine_register_stop()




Sep 2006                  GlobusWORLD / GridWORLD          4
                         WS-Resources
       Resource management API
              create/find/destroy resource
              property management
              lifetime management
       globus_wsrf_core_tools.h includes function
        to find resource from EPR used in the
        current message




Sep 2006                  GlobusWORLD / GridWORLD    5
                  WS-Resource Properties
       Property values associated with a type_info
        for serialization information
       Property values may be dynamic
              callbacks for attempts to get or set the value
       Apps can be notified when properties
        change
              Call globus_resource_property_changed() for
               dynamic values



Sep 2006                   GlobusWORLD / GridWORLD              6
                        Operation Providers
       Reuse a port type implementation
              Resource Properties
              Operations
       Examples:
              wsrp:GetResourceProperty
                   GetResourceProperty operation

              wsrl:ScheduledResourceTermination
                   SetTerminationTime operation
                   CurrentTime, TerminationTime properties



Sep 2006                       GlobusWORLD / GridWORLD        7
                      Notification Consumer
       Callback-driven notification
       User has to deal with XML wildcard
        messages
       Usage:
              Create Engine (don't forget to start it!)
              Create Consumer
                   Returns EPR of Notification Consumer Service

              Subscribe via client stubs
                   May be different for some services



Sep 2006                        GlobusWORLD / GridWORLD            8
                        Notification Producer
       wsnt:NotificationProducer provider
              Creates notification-related properties
              Handles Subscribe/GetCurrentMessage
               operations
              Creates Topics for Resource Properties
       Notification Producer API
              Create/destroy topics
              Change topics
              Also: manage producer, subscriptions, etc
                   but provider handles these for you
Sep 2006                        GlobusWORLD / GridWORLD    9
                             Service Groups
       wssg:ServiceGroup,
        wssg:ServiceGroupRegistration providers
              creates wssg-related properties (Entry,
               MembershipContentRule)
              implements Add operation
       service_group API to manage entries
              add/remove entries
              enumerate entries
              also: create/destroy service group
                   provider handles these for you
Sep 2006                        GlobusWORLD / GridWORLD   10
                             Handler Chains
       Handle specific message elements
       Called when matching header element is
        found
       Examples:
              WS-Addressing
                   Set attributes when addressing values encountered
                   Verify all required addressing elements are present

              WS-SecureMessage
                   Add attributes for elements to be signed
                   Add message signatures

Sep 2006                        GlobusWORLD / GridWORLD                   11
                       SOAP Messaging
          XML Serialization Handles
              to/from file, memory, libxml DOM, HTTP
          Options to control (de)serialization
              default NS
              xsi:type attribute
              c14n
              …



Sep 2006                    GlobusWORLD / GridWORLD
                     Message Attributes
       Key-Value pairs
              When value is set, optional copy and destroy
               functions for memory management
       Default attributes set at engine initialization
        (service) or on a client stub
       Additional attributes used to pass info from
        message handlers
              Example: wsa:To value set by WS-
               Addressing handler


Sep 2006                  GlobusWORLD / GridWORLD             13
                   Message Attributes (2)
       Authentication Options
              TLS / WS-SecureMessage
              Credentials to use
              Message protection
              Peer subject name
       Also: Message timeouts, persistent
        connections




Sep 2006                  GlobusWORLD / GridWORLD   14
                    Bindings Generator
          globus-wsrf-cgen program
              Uses JavaScript-based template language
          Generates type bindings
              Data structures, allocators, deallocators,
               serializers, etc
              Type information for wildcard handling
          Generates service module to call service
           implementation
          Generates client stub functions to invoke
           (remote) operations
          Generates Packaging/Makefiles
Sep 2006                 GlobusWORLD / GridWORLD            15
              Resource Property Element
           <element name="CounterRP">
            <complexType>
              <sequence>
                <element ref="tns:Value"/>
                <element maxOccurs="unbounded"     ref="rpns0:Topic"/>
                <element maxOccurs="unbounded"
                                 ref="rpns0:TopicExpressionDialects"/>
                <element ref="rpns1:TerminationTime"/>
                <element ref="rpns1:CurrentTime"/>
                <element ref="rpns0:FixedTopicSet"/>
              </sequence>
            </complexType>
           </element>



Sep 2006                     GlobusWORLD / GridWORLD                     16
                Example Counter Service
           <element name="createCounter">
               <complexType/>
           </element>
           <element name="createCounterResponse">
             <complexType>
               <sequence>
                 <element ref="wsa:EndpointReference"/>
               </sequence>
             </complexType>
           </element>




Sep 2006                     GlobusWORLD / GridWORLD      17
                   Message Definition

           <message name="CreateCounterRequest">
            <part name="request"
              element="tns:createCounter"/>
           </message>
           <message name="CreateCounterResponse">
            <part name="response"
              element="tns:createCounterResponse"/>
           </message>




Sep 2006                GlobusWORLD / GridWORLD       18
                   Port Type Definition
    <portType name="CounterPortType"
           wsrp:ResourceProperties="tns:CounterRP">
           <operation name="createCounter">
                 <input
                  message="tns:CreateCounterRequest"/>
                 <output
                  message="tns:CreateCounterResponse"/>
           </operation>
           ...
    </portType>


Sep 2006                   GlobusWORLD / GridWORLD        19
                     C Type Binding
    typedef struct createCounterResponseType_s
    {
           wsa_EndpointReferenceType EndpointReference;
    } createCounterResponseType;


    typedef struct createCounterResponseType_array_s
    {
           struct createCounterResponseType_s *
                                         elements;
           int                           length;
           globus_xsd_type_info_t        type_info;
    } createCounterType_array;


Sep 2006               GlobusWORLD / GridWORLD            20
             C Type Bindings Functions
    globus_result_t
    createCounterResponseType_init(
           createCounterResponseType ** inst);


    void
    createCounterResponseType_destroy(
           createCounterResponseType * inst);


    struct createCounterType_s *
    createCounterResponseType_array_push(
           createCounterResponseType_array * array);



Sep 2006               GlobusWORLD / GridWORLD         21
                    C Type Serializer
    globus_result_t
    createCounterResponseType_serialize(
           const xsd_QName * element_name,
           const createCounterResponseType * val,
           globus_soap_message_handle_t message_handle,
           globus_xsd_element_options_t options);



    also deserialize, copy, array, contents-only
    versions.



Sep 2006               GlobusWORLD / GridWORLD            22
                  XML Wildcards (1)
    struct globus_xsd_type_info_s
    {
           xsd_QName * type;
           globus_xsd_serialize_func_t serialize;
           globus_xsd_deserialize_func_t deserialize;
           globus_xsd_init_func_t initialize;
           globus_xsd_destroy_func_t destroy;
           globus_xsd_copy_func_t copy;
    ...};




Sep 2006              GlobusWORLD / GridWORLD           23
                    XML Wildcards (2)

    typedef struct xsd_any_s
    {
           globus_xsd_type_registry_t              registry;
           globus_xsd_type_info_t                  any_info;
           xsd_QName *                             element;
           void *                                  value;
           xsd_string_array                        namespaces;
    } xsd_any;




Sep 2006                 GlobusWORLD / GridWORLD                 24
                  Client Stub Binding
       globus_result_t
       CounterPortType_createCounter(
           CounterService_client_handle_t       handle,
           const char * service_endpoint,
           const createCounterType * createCounter,
           createCounterResponseType **
                 createCounterResponse,
           CounterPortType_createCounter_fault_t *
                 fault_type,
           xsd_any ** fault);
       Also   with EPR in place of service_endpoint
       Also   non-blocking functions
       Request   and response versions
Sep 2006              GlobusWORLD / GridWORLD             25
                    Client Example (1)
    createCounterType createCounter;
    createCounterResponseType *createCounterResponse=NULL;
    createCounterType_init_contents(&createCounter);
    globus_soap_message_attr_init(&attrs);
    globus_soap_message_attr_set(
           attrs,
           GLOBUS_SOAP_MESSAGE_AUTHENTICATION_METHOD_KEY,
           NULL, NULL,
           GLOBUS_SOAP_MESSAGE_AUTH_SECURE_MESSAGE);


    CounterService_client_init(
           &client_handle, attrs, NULL);


Sep 2006                 GlobusWORLD / GridWORLD             26
                 Client Example (2)
    result = CounterPortType_createCounter(
            client_handle,
            counter_service_contact,
            &createCounter,
            &createCounterResponse,
            &fault_type,
            &fault);
    if (result != GLOBUS_SUCCESS) ...
    globus_wsrf_core_export_endpoint_reference(
            &createCounterResponse->EndpointReference,
            "counter.epr",
            &wsa_EndpointReference_qname)l


Sep 2006               GlobusWORLD / GridWORLD           27
                 Service Initialization

    globus_result_t
    CounterService_init(
        globus_service_descriptor_t * service_desc)
    {
           globus_module_activate(
              GLOBUS_WSRF_RESOURCE_MODULE);
    ...
    }




Sep 2006               GlobusWORLD / GridWORLD        28
             Operation Implementation
    globus_result_t
    CounterPortType_createCounter_impl(
           globus_service_engine_t engine,
           globus_soap_message_handle_t message,
           globus_service_descriptor_t * service,
           createCounterType * createCounter,
           createCounterResponseType *
               createCounterResponse,
           const char **    fault_name,
           void ** fault)


Sep 2006              GlobusWORLD / GridWORLD       29
           Service EPR Construction
    globus_service_engine_get_contact(
                engine, &endpoint);
    epr->Address.base_value =
           globus_common_create_string("%s/%s",
           endpoint,COUNTERSERVICE_BASE_PATH);
    counter_key = xsd_any_array_push(
            epr->ReferenceProperties->any);
    counter_key->any_info = &xsd_string_info;
    counter_key->element = &CounterKey_qname;
    counter_key->value = &resource_id;



Sep 2006           GlobusWORLD / GridWORLD        30
                       add operation
    globus_result_t
    CounterPortType_add_impl(
           globus_service_engine_t               engine,
           globus_soap_message_handle_t          message,
           globus_service_descriptor_t *         service,
           xsd_int *                             add,
           xsd_int *                             addResponse,
           const char **                         fault_name,
           void **                               fault)




Sep 2006               GlobusWORLD / GridWORLD                  31
              add implementation
    globus_wsrf_core_get_resource(
            message, service, &resource);
    globus_resource_get_property(resource,
            &CounterPortType_Value_rp_qname,
           (void **)&counter_value, NULL);
    *counter_value += *add
    *addResponse = *counter_value;
    globus_resource_property_changed(resource,
    &CounterPortType_Value_rp_qname);
    globus_resource_finish(resource);


Sep 2006           GlobusWORLD / GridWORLD       32
               Generating WSRF Faults


    time_t timestamp = time(NULL);


    wsrp_ResourceUnknownFaultType_init(fault);
    globus_libc_gmtime_r(&timestamp,
           &(*fault)->Timestamp);
    *fault_name="ResourceUnknownFault";




Sep 2006               GlobusWORLD / GridWORLD   33
      Performance Snapshot (GT 4.0.1)
                                               Get Resource Property (LAN)
                 200
                                                             181.96
                 175

                                                                                                     149.67
                 150                                                     140.5

                                                                                                                         GT4-Java
                 125
     Time (ms)




                                                                                                                         GT4 - C
                                                                                                                         pyGridWare
                 100                                                                                                     WSRF::Lite
                                                                                     81.39                               WSRF.NET
                 75
                                                                                                          55.6
                 50

                                      25.57
                 25                           17.1                14.8                       11.46               12.91
                       10.05                         8.23
                               2.34                                              0                2.85
                   0
                           No Security                         X.509 Signature                      HTTPS




Sep 2006                                                    GlobusWORLD / GridWORLD                                                   34
                Use Case: globusrun-ws
     Command-line client to submit and monitor WS-GRAM
      jobs
     Interacts with WS-Delegation, WS-GRAM, and
      (indirectly) RFT
     Includes a service engine to handle notification
      messages from WS-GRAM
     On the order of 20x faster than the Java client program
          Largely due to the JVM startup costs




Sep 2006                  GlobusWORLD / GridWORLD           35
                  Use Case: RFT Client
     Command-line client to RFT service
          RFT performs reliable 3rd-party transfers using
           GridFTP
     Create a transfer, start & monitor it
     Monitoring via WS-Notification
     Adds features, improves performance over previous
      java client




  Meet Ravi:
  9/14 11:30 AM "Globus RFT for Developers"
Sep 2006                 GlobusWORLD / GridWORLD             36
            Use Case: GridFTP Resource Properties
          Experimental GridFTP feature
          Server exposes state via resource
           properties
            Server   load
            Connection      limits
          Acts as WS-MDS provider




Sep 2006                 GlobusWORLD / GridWORLD   37
               Use Case: Container on an ARM
                         processor
       Prototype for ocean floor sensor platform
        for the LOOKING project
       Port of C WS Core to proprietary
        embedded operating system
              Development board with 4MB Flash, 16MB
               RAM
              NET+OS
       C Container statically linked with OS and
        services
Sep 2006                 GlobusWORLD / GridWORLD        38
         Use Case: Core Command-Line tools
          Substitute for Java CLI tools in 4.1, 4.2
          Clients work with any service implementing
           the related port types
          WS-ResourceProperties
              globus-wsrf-query
              globus-wsrf-get-property
              globus-wsrf-get-properties
              globus-wsrf-insert-property
              globus-wsrf-update-property
              globus-wsrf-delete-property
Sep 2006                  GlobusWORLD / GridWORLD       39
        Use Case: Core Command-Line tools

       WS-ResourceLifetime
            globus-wsrf-destroy

            globus-wsrf-set-termination-time

       WS-BaseNotification
            globus-wsn-get-current-message

            globus-wsn-pause-subscription

            globus-wsn-resume-subscription

            globus-wsn-subscribe




Sep 2006               GlobusWORLD / GridWORLD   40
         Project Web Page / Contributions
          http://dev.globus.org/wiki/C_WS_Core
          Globus is largely following the Apache project
           model at this point.
          We would welcome contributors.
              Long term, high quality contributors can be voted in
               as committers.
          An alternative would be to start a new,
           independent project that utilized C WS Core, on
           which you could be a committer at the start.




Sep 2006                    GlobusWORLD / GridWORLD                   41
             Getting help / more information
    Email lists
          cwscore-[dev|user|announce]@globus.org
    Documentation
          http://www.globus.org/toolkit/docs
    Bugzilla
          http://bugzilla.globus.org/bugzilla
          Product is C WS Core
    HPDC Paper
          http://www.globus.org/alliance/publications/papers/WSRF
           Comparison2005-3.pdf
          Comparison of five different WSRF implementations

Sep 2006                    GlobusWORLD / GridWORLD              42
                               Futures
       More clients (delegation, ...)
       Improved container
              More core services (registry, secure
               conversation, …)
              More flexible container configuration
       Authorization Improvements
       Persistent services
       Update to newer web standards
       Your C based Web service or client?

Sep 2006                   GlobusWORLD / GridWORLD     43
       Meet the Developers Session at Globus
              Alliance Booth (152A-P7)
     September 12

           8:00am - 9:00am "Java WS Core and Security (C, Java)" -- Olle Mulmo,
           Jarek Gawor, Rachana Anantakrishnan
           11:30am -12:30pm "RLS" -- Rob Schuler, Ann Chervenak
           12:30pm -1:30pm "MDS" -- Mike D'arcy, Laura Pearlman
           3:00pm - 4:00pm ”Resource Management (GRAM, Virtual Workspaces
           and Dynamic Accounts)" – Stu Martin, Peter Lane, Tim Freeman, Kate
           Keahey
           6:00pm - 7:00pm "C WS Core" -- Joe Bester
           7:00pm - 8:00pm "Python WS Core" -- Joshua Boverhof


     September 13

           8:00am - 9:00am "GridShib" -- Von Welch, Ton Scavo, Tim Freeman
           11:30am - 12:30pm "GT Installation and Administration" -- Charles
           Bacon
           12:30pm - 1:30pm "MyProxy" -- Jim Basney
           3:00pm - 4:00pm "GridFTP, XIO, RFT" -- John Bresnahan, Ravi Madduri

Sep 2006                       GlobusWORLD / GridWORLD
                                        Question: Do you see a Fun & Exciting
                                        Career in my future?

                                        Magic 8 Ball: All Signs Point to YES




                     Say YES to Great Career Opportunities
 SOFTWARE ENGINEER/ARCHITECT
 Mathematics and Computer Science Division, Argonne National Laboratory
 The Grid is one of today's hottest technologies, and our team in the Distributed Systems
 Laboratory (www.mcs.anl.gov/dsl) is at the heart of it. Send us a resume through the
 Argonne site (www.anl.gov/Careers/), requisition number MCS-310886.

 SOFTWARE DEVELOPERS
 Computation Institute, University of Chicago
 Join a world-class team developing pioneering eScience technologies and applications.
 Apply using the University's online employment application
 (http://jobs.uchicago.edu/, click "Job Opportunities" and search for requisition
 numbers 072817 and 072442).
 See our Posting on the GlobusWorld Job Board or Talk to Any of our Globus Folks.




Sep 2006                      GlobusWORLD / GridWORLD