Distributed
Embedded Systems
1. Motivation
2. An Overview of Distributed Software Architecture Approaches
2.1 Pro & Contra Middleware
2.2 Message-Based Architectures
2.3 Service-Based Architectures
2.4 Subscribe-Based Architectures
2.5 Component-Based Architectures
3. Inter-Process-Communication (IPC) in Unix
4. Example: MPI
5. Example: Web Services
6. Example: OPC UA
7. Critical Sections and Deadlocks
8. Example: DDS
9. Example: OSGi
10. Redundancy and Consistency
11. MultiCore Programming and Synchronous Languages
Introduction
Web Services
Web services:
• service-based middleware optimized for the internet • flexible calling of remote services via the internet
• creation of complex applications by the composition of services
Internet Web Application Server UDDI Service Registry/Broker Client PC
Introduction
Web Services
Using web services
Internet Web Application Server UDDI Service Registry/Broker Client PC 1: Send service description WSDL File 2: return service handle UDDI protocol 3: Send SOAP request SOAP XML 4: Send SOAP answer SOAP XML e.g. HTTP protocol
UDDI
Web Services
Founded by IBM, Ariba, and Microsoft Service publishing and discovery
Based on other web service technologies:
HTTP, ftp, IIOP, etc. SOAP WSDL UDDI WSFL network protocol XM-based messaging service description service publishing & discovery service interactions
UDDI
Web Services
Categorization of services using predefined taxonomies
UDDI defines the protocol used to communicate with a service registry/broker
UDDI messages are defined in XML, wrapped in a SOAP frame and send via HTTP
UDDI Service Registry/ Broker SW Companies, Standardization bodies, etc. 1: publish tModels Businesses 2: publish services 3: UDDI assigns a unique UUID to each
tModel and each service 4: Applications request the services
UDDI
Web Services
The UDDI Service Registry/Broker uses a standardized data model to specify a registered service: 1. businessEntity:
• description of publishing party 2. businessService:
• service description 3. bindingTemplate:
• description of a service’s API
• used to access the service on a technical level 4. tModels:
• categories and taxonomies
• used by the other parts of the data model
UDDI
Web Services
The UDDI Service Registry/Broker uses a standardized data model to specify a registered service: 1. businessEntity:
• description of publishing party 2. businessService:
• service description 3. bindingTemplate:
• description of a service’s API
• used to access the service on a technical level 4. tModels:
• categories and taxonomies
• used by the other parts of the data model
UDDI Example 1
Web Services
The UDDI Service Registry/Broker uses a standardized data model to specify a registered service: 1. businessEntity:
• description of publishing party 2. businessService:
• service description 3. bindingTemplate:
• description of a service’s API
• used to access the service on a technical level 4. tModels:
• categories and taxonomies
• used by the other parts of the data model
<tModel xmlns="urn:uddi-org:api" tModelKey="UUID:AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA">
<name>hs-owl:add_42</name>
<description xml:lang="en">Add the (sic) number</description> <overviewDoc> <overviewURL>http://schema.com/add42.wsdl</overviewURL> </overviewDoc> <categoryBag> <keyedReference tModelKey="UUID:CD253352-186B-4532-C53F-6BDAD766635" keyName="Number adding services"
keyValue="84.14.16.01.00"/> <keyedReference tModelKey="UUID:C1ACF26D-9672-4404-9D70-39B756E62AB4" keyName="types" keyValue="Nonsense sevices"/> </categoryBag> </tModel>
UDDI Example 1
Web Services
The UDDI Service Registry/Broker uses a standardized data model to specify a registered service: 1. businessEntity:
• description of publishing party 2. businessService:
• service description 3. bindingTemplate:
• description of a service’s API
• used to access the service on a technical level 4. tModels:
• categories and taxonomies
• used by the other parts of the data model
<tModel xmlns="urn:uddi-org:api" tModelKey="UUID:AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA">
<name>hs-owl:add_42</name>
<description xml:lang="en">Add the (sic) number</description> <overviewDoc> <overviewURL>http://schema.com/add42.wsdl</overviewURL> </overviewDoc> <categoryBag> <keyedReference tModelKey="UUID:CD253352-186B-4532-C53F-6BDAD766635" keyName="Number adding services"
keyValue="84.14.16.01.00"/> <keyedReference tModelKey="UUID:C1ACF26D-9672-4404-9D70-39B756E62AB4" keyName="types" keyValue="Nonsense sevices"/> </categoryBag> </tModel> The WSDL reference
The pointer to an element in a user-defined taxonomy
The pointer to an element in the "wsdlSpec" type in the uddi-org:types (UUID:C1ACF26D...)
tModels
Web Services
Predefined taxonomies (tModels):
1. ISO 3166 Geographic Taxonomy: Geographical locations
2. Universal Standard Products and Services Classification (UNSPSC) <businessEntity businessKey=...
...
<categoryBag>
<!-- Categorize this businessEntity as serving California using the ISO 3166
taxonomy -->
<keyedReference keyName="California, USA" keyValue="US-CA" tModelKey="uuid:4E49A8D6-D5A2-4FC2-93A0-0411D8D19E88"/> </categoryBag> ... </businessEntity> <businessEntity businessKey=... ... <categoryBag>
<keyedReference keyName="Domestic Air Cargo Transport" keyValue="78.10.15.01.00"
tModelKey = "uuid:CD153257-086A-4237-B336-6BDCBDCC6634"/> </categoryBag>
...
UDDI Example 1
Web Services
The UDDI Service Registry/Broker uses a standardized data model to specify a registered service: 1. businessEntity:
• description of publishing party 2. businessService:
• service description 3. bindingTemplate:
• description of a service’s API
• used to access the service on a technical level 4. tModels:
• categories and taxonomies
• used by the other parts of the data model
<businessService
businessKey="BBBBBBBB-BBBB-BBBB-BBBB-BBBBBBBBBBBB" serviceKey="CCCCCCCC-CCCC-CCCC-CCCC-CCCCCCCCCCCC"> <name>OWL Add 42 Instance</name>
<bindingTemplates> <bindingTemplate serviceKey="CCCCCCCC-CCCC-CCCC-CCCC-CCCCCCCCCCCC" bindingKey="DDDDDDDD-DDDD-DDDD-DDDD-DDDDDDDDDDDD"> <accessPoint URLType="https">https://hs-owl.de/add42</ accessPoint> <tModelInstanceDetails> <tModelInstanceInfo tModelKey="UUID:AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA"/> <tModelInstanceDetails> </bindingTemplate> </bindingTemplates </businessService>
Stub/Proxy/Skeleton Pattern
Web Services
Processor Communication System Middleware Communication Driver Processor Communication Driver Client Proxy Middleware Server Skeleton DispatcherProcessor Communication System Middleware Communication Driver Processor Communication Driver Client Proxy Middleware Server Skeleton Dispatcher
Stub/Proxy/Skeleton Pattern
Web Services
The client is just your everyday program; nothing related to distributed systems is used.
Processor Communication System Middleware Communication Driver Processor Communication Driver Client Proxy Middleware Server Skeleton Dispatcher
Stub/Proxy/Skeleton Pattern
Web Services
The proxy replaces the server component the
client side. From the client point of view, the proxy is the the server component.
It(de-)serializes the method calls and object
accesses. It also translates between middleware API and proxy.
Processor Communication System Middleware Communication Driver Processor Communication Driver Client Proxy Middleware Server Skeleton Dispatcher
Stub/Proxy/Skeleton Pattern
Web Services
The dispatcher chooses the right server components, i.e. its skeleton.
Processor Communication System Middleware Communication Driver Processor Communication Driver Client Proxy Middleware Server Skeleton Dispatcher
Stub/Proxy/Skeleton Pattern
Web Services
The skeleton translates between server API and middleware. It also handles parallel accesses.
The skeleton (de-)serializes the method calls and object accesses.
Processor Communication System Middleware Communication Driver Processor Communication Driver Client Proxy Middleware Server Skeleton Dispatcher
Stub/Proxy/Skeleton Pattern
Web Services
The server is just your everyday program; nothing related to distributed systems is used.
Stub/Proxy/Skeleton Pattern
Web Services
Proxy and/or skeletons are often also called stubs.
The binding between client and server can either be static or dynamic:
Static binding means that the references between client and servers are statically defined at compile-time. Dynamic binding means that references are established at run-time via a broker/repository.
Distributed system may either use compile-time or run-time objects. Compile-time objects are instances of classes/ interfaces which have been defined at compile-time. Run-time objects are constructed at run-time via reflection mechanisms.
If distributed systems are cross-language (e.g. CORBA), object adapters are used to translate between the languages.
Introduction
SOAP
Protocol for the exchange of structured data. Data is expressed in form of an XML document.
SOAP normally used TCP and HTTP/HTTPS as underlying protocols.
SOAP defines how data can be expressed and how remote calls are modeled History:
• Dave Winer and Microsoft developed 1998 XML-RPC • SOAP V1.0 1999
Message Structure
SOAP
<?xml version="1.0"?> <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"> <s:Header> </s:Header> <s:Body> </s:Body> </s:Envelope>Messages are transmitted in an “envelope”
The header comprises application-specific meta information about a message (transaction IDs, authentication, etc.).
Message Structure
SOAP
Example: Ask a database if a specific wine is on storage
Request: Answer: <?xml version="1.0"?> <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"> <s:Body> <m:BottleInStorage xmlns:m="http://www.wine-store.de/soap"> Brunello di Montalcino </m: BottleInStorage> </s:Body> </s:Envelope> <?xml version="1.0"?> <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"> <s:Header>
<m:RequestID xmlns:m="http://www.wine-store.de/soap">c4f7d603e</m:RequestID> </s:Header>
<s:Body>
<m:DbResponse xmlns:m="http://www.wine-store.de/soap"> <m:title value="Brunello di Montalcino">
<m:Choice value="1">Il Poggione, 1998</m:Choice> <m:Choice value="2">Castello Banfi, 1999</m:Choice> </m:title>
</m:DbResponse> </s:Body>
Introduction
WSDL
WSDL (Web Service Description Language) is an XML Schema to describe web services. WSDL V2.0 is a W3C recommendation
Structure of a WSDL 2.0 document:
1. Abstract Section: Meta-Level
1.1 Types (aka messages): Data Types described as an XML Schema 1.2 Interfaces (aka portType): Interfaces implemented by the services
1.2.1 Operation: Operations/methods including input and output parameters, parameters types are defined in 1.1
2. Concrete Section: Instance-Level
2.1 Binding: Interfaces from 1.2 used by the service, transport protocol 2.2 Service
Example
WSDL
Example
WSDL
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://
www.example.org/FindWine/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http:// www.w3.org/2001/XMLSchema" name="FindWine" targetNamespace="http://www.example.org/FindWine/"> <wsdl:types>
<xsd:schema targetNamespace="http://www.example.org/FindWine/"> <xsd:element name="findWine">
<xsd:complexType> <xsd:sequence>
<xsd:element name="in" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="findWineResponse"> <xsd:complexType> <xsd:sequence>
<xsd:element name="out" type="xsd:string"/> </xsd:sequence>
</xsd:complexType> </xsd:element>
<xsd:element name="findWine" type="xsd:string"></xsd:element> </xsd:schema>
</wsdl:types>
<wsdl:message name="findWineRequest">
<wsdl:part element="tns:findWine" name="parameters"/> </wsdl:message>
<wsdl:message name="findWineResponse">
<wsdl:part element="tns:findWineResponse" name="parameters"/> </wsdl:message>
Example
WSDL
<wsdl:portType name="FindWine"> <wsdl:operation name="findWine"> <wsdl:input message="tns:findWineRequest"/> <wsdl:output message="tns:findWineResponse"/> </wsdl:operation> </wsdl:portType><wsdl:binding name="FindWineSOAP" type="tns:FindWine">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="findWine"> <soap:operation soapAction="http://www.example.org/FindWine/findWine"/> <wsdl:input> <soap:body use="literal"/> </wsdl:input> <wsdl:output> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="FindWine">
<wsdl:port binding="tns:FindWineSOAP" name="FindWineSOAP"> <soap:address location="http://www.example.org/"/>
</wsdl:port> </wsdl:service> </wsdl:definitions>
SOAP & Eclipse
SOAP
Install Eclipse JEE Edition
SOAP & Eclipse
SOAP
SOAP & Eclipse
SOAP
Create WebServices for this class. Eclipse can do this by invoking the “WebService” context menu on the Java class.
SOAP & Eclipse
SOAP
SOAP & Eclipse
SOAP
The generated server application knows about the mapping between our Java program and the service.
SOAP & Eclipse
SOAP
For the generated client application, several java classes have been generated.
SOAP & Eclipse
SOAP
General structure on the client side (simplified!):
SOAP & Eclipse
SOAP
Client Application AddClass Interface AddClassProxy implements uses AddClassServiceLocatorask for SOAP dispatcher
AddClassSoapBindingStub
return handle to
AddClassSoapBindingStub uses
SOAP Middleware (Axis)
Client application implemented in JavaServer Pages (JSP): Result.jsp
SOAP & Eclipse
SOAP
<jsp:useBean id="sampleAddClassProxyid" scope="session" class="DefaultNamespace.AddClassProxy" /> <%
if (request.getParameter("endpoint") != null && request.getParameter("endpoint").length() > 0) sampleAddClassProxyid.setEndpoint(request.getParameter("endpoint"));
%> ....
case 13:
gotMethod = true;
String x_1id= request.getParameter("x16"); int x_1idTemp = Integer.parseInt(x_1id);
int add_4213mtemp = sampleAddClassProxyid.add_42(x_1idTemp);
String tempResultreturnp14 = org.eclipse.jst.ws.util.JspUtils.markup(String.valueOf(add_4213mtemp)); %>
<%= tempResultreturnp14 %> <%
break;
Connect to Java class
AddClass.java:
SOAP & Eclipse
SOAP
/**
* AddClass.java *
* This file was auto-generated from WSDL
* by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. */
package DefaultNamespace;
public interface AddClass extends java.rmi.Remote {
public int add_42(int x) throws java.rmi.RemoteException; }
Our server class is now an interface on the client side.
AddClassProxy.java: Proxy Class
SOAP & Eclipse
SOAP
package DefaultNamespace;
public class AddClassProxy implements DefaultNamespace.AddClass { private DefaultNamespace.AddClass addClass = null;
...
private void _initAddClassProxy() { try {
addClass = (new DefaultNamespace.AddClassServiceLocator()).getAddClass(); if (addClass != null) { if (_endpoint != null) ((javax.xml.rpc.Stub)addClass)._setProperty("javax.xml.rpc.service.endpoint.address", _endpoint); else _endpoint = (String)((javax.xml.rpc.Stub)addClass)._getProperty("javax.xml.rpc.service.endpoint.address"); } }
catch (javax.xml.rpc.ServiceException serviceException) {} }
...
public int add_42(int x) throws java.rmi.RemoteException{ if (addClass == null)
_initAddClassProxy();
return addClass.add_42(x); }}
This class implements the interface, it is the proxy for the server class on the client side.
Get SOAP stub class.
package DefaultNamespace;
public class AddClassServiceLocator extends org.apache.axis.client.Service implements DefaultNamespace.AddClassService {
...
// Use to get a proxy class for AddClass
private java.lang.String AddClass_address =
"http://localhost:8080/WebServiceProject/services/AddClass";
public java.lang.String getAddClassAddress() { return AddClass_address;
}
// The WSDD service name defaults to the port name.
private java.lang.String AddClassWSDDServiceName = "AddClass";
SOAP & Eclipse
SOAP
AddClassServiceLocator.java: SOAP-specific dispatcher class
The URI
Service Name
SOAP & Eclipse
SOAP
AddClassServiceLocator.java
public DefaultNamespace.AddClass getAddClass() throws javax.xml.rpc.ServiceException { java.net.URL endpoint;
try {
endpoint = new java.net.URL(AddClass_address); }
catch (java.net.MalformedURLException e) {
throw new javax.xml.rpc.ServiceException(e); }
return getAddClass(endpoint); }
public DefaultNamespace.AddClass getAddClass(java.net.URL portAddress) throws javax.xml.rpc.ServiceException {
try {
DefaultNamespace.AddClassSoapBindingStub _stub = new
DefaultNamespace.AddClassSoapBindingStub(portAddress, this); _stub.setPortName(getAddClassWSDDServiceName()); return _stub; } catch (org.apache.axis.AxisFault e) { return null; } }
SOAP & Eclipse
SOAP
AddClassSoapBindingStub.java
public int add_42(int x) throws java.rmi.RemoteException { ...
org.apache.axis.client.Call _call = createCall(); _call.setOperation(_operations[0]);
_call.setUseSOAPAction(true); _call.setSOAPActionURI(""); _call.setEncodingStyle(null);
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
_call.setOperationName(new javax.xml.namespace.QName("http://DefaultNamespace", "add_42"));
setRequestHeaders(_call); setAttachments(_call);
try { java.lang.Object _resp =
_call.invoke(new java.lang.Object[]{new java.lang.Integer(x)}); if (_resp instanceof java.rmi.RemoteException) {
throw (java.rmi.RemoteException)_resp; } else {
extractAttachments(_call); try {
return ((java.lang.Integer) _resp).intValue(); } catch (java.lang.Exception _exception) {
return ((java.lang.Integer) org.apache.axis.utils.JavaUtils.convert(_resp, int.class)).intValue(); Dispatcher for method