You are on page 1of 287

Architectures

of Internet Services
Pawe Czarnul
pczarnul@eti.pg.gda.pl
http://pczarnul.eti.pg.gda.pl
Computer Architecture Department
Gdansk University of Technology, Poland

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 1


Architectures of Internet Services
Progress

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 2


Architectures of Distributed Systems
1. High Performance Computing/cluster computing
Simulations on clusters/supercomputers:
Kind of a niche products, for specialized uses: simulations of physical
phenomena, battle fields, climate modelling, medical simulations etc.
E.g. PVM, MPI
1. Client-server
Good model for business applications: serving requests from clients
Problem: integration with external systems (firewalls blocking ports)
E.g. CORBA, DCOM, Java RMI, RPC
1. Distributed object systems
In fact client server based on distributed objects +
Services defined and supported by the environment including distributed
objects, e.g. CORBA

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 3


Architectures of Distributed Systems
1. Multi-tier applications
separated:
User/presentation/business logic/database layers e.g. Web
browser/Tomcat/MySQL
Component application development in e.g. J2EE, Microsoft .NET
Easy-to-use technologies like PHP, JSP, servlets etc.

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 4


Client-server

client

server
client

client

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 5


Distributed objects

Object A
Object B

Object E

Object C

Object D

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 6


Multi-tier systems

Tier 0 Tier 1 Tier 2

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 7


Service oriented systems

Service 2

Client Service 1 Service 3

Service 4

Service 5 Service 6

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 8


Agent based systems

Agent A
Agent B

Agent E

Agent C

Agent D
Autonomic
Learning
ontologies
2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 9
Volunteer computing

volunteer
volunteer

Project
server

volunteer
volunteer
volunteer

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 10


Grid systems

Virtual
Virtual
Organization A
Organization B

Grid middleware

Virtual
Virtual Organization C
Organization D

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 11


Cloud/Sky systems

Provider 1

client
Provider 2

Provider 3

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 12


Architectures of Distributed Systems
1. Peer-to-peer
Cooperation of units in a distributed network, no servers are
distinguished (although hybrid approaches are possible), replication

1. Agent-based systems
Autonomic agents
Useful if one can send agents to perform certain work remotely where
they can communicate locally if remote communication is lost
Kind of a niche products, for specialized uses: gathering data inside
corporations etc.
Are there really any advamtages over client-server computing?
Agents vs client-server - discussion

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 13


Architectures of Distributed Systems
1. SOA Service Oriented Computing
Remote calling services (loosely-coupled) using well defined standards

A variety of standards for the implementation of SOA Web Services:


WSDL, SOAP, XML,
Web Services not blocked by firewalls, usually SOAP messages
transferred using HTTP (also SMTP etc. possible)
UDDI as information registry
Various standards for service integration
A service can invoke other services, services can be combined into
workflows (business, scientific)
Portability and heterogeneity: works on various equipment, possible to
implement service and caller sides in various programming languages,
various platforms that support Web Services e.g. Apache+AXIS,
Microsoft .NET, etc.
QoS in scientific and business workflows
Ontologies for service integration

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 14


Architectures of Distributed Systems
1. SOA Service Oriented Computing
Remote calling services (loosely-coupled) using well defined standards

A variety of standards for the implementation of SOA Web Services:


WSDL, SOAP, XML,
Web Services not blocked by firewalls, usually SOAP messages
transferred using HTTP (also SMTP etc. possible)
UDDI as information registry
Various standards for service integration
A service can invoke other services, services can be combined into
workflows (business, scientific)
Portability and heterogeneity: works on various equipment, possible to
implement service and caller sides in various programming languages,
various platforms that support Web Services e.g. Apache+AXIS,
Microsoft .NET, etc.
QoS in scientific and business workflows
Ontologies for service integration

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 15


Architectures of Distributed Systems

1. Grid systems, role of middleware

What is it all about?

Controlled resource sharing integration of geographically distributed


resources for large scale projects
Integrate many different geographically distributed resources together to
create a platform for collaborative computing

Issues: authentication, authorization,


remote task submission (hiding queueing systems such as LSF/PBS),
management of user accounts
licensing/payments etc.

OGSA

Off-the-shelf systems

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 16


Architectures of Distributed Systems

Mobile devices in the Internet


Low hardware requirements
CLDC, CDC
MIDP
Functions:
User interface
Network connections (HTTP/S, Web Services)
multithreading
Multimedia
Locality
1. Pervasive Computing
2. Volunteer Computing
High computational power, dependability and privacy issues

1. Cloud Computing

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 17


Architectures of Distributed Systems

Cloud Computing

IaaS Infrastructure as a Service


SaaS Software as a Service
PaaS Platform as a Service

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 18


Web Services
Overview

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 19


Web Services

Web services is a technology implementing Service Oriented


Architecture (SOA):

Providers can publish loosely coupled services from various locations,


using various platforms and languages

Business functions of a service can be described in a UDDI registry


along with information about the provider e.g. - the service for ordering
holidays
Technical aspects of a service (methods, arguments, data types,
location, protocols) are described in a WSDL document (Web Service
Description Language)

Services are dynamic may appear and disappear at any time


Services can be part of complex processing can be integrated into
workflows represented e.g. by directed acyclic graphs (DAGs) where one
service is executed for a graph vertex and edges denote time
dependencies between the services

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 20


Web Services: Typical sequence for service invocation

UDDI
registry
s
i ce nd t i on

d ith ce a
v

e
er tain
a

sc lin s
w rvi turn
e r ma
s

r
or cer
r c

i k
i

se re
f ide serv info

ti s t
k of
o
v

3.
o ns o W
o
pr bout lish
. l o bl e s
2 pa i on A P ub
ca nct 1.
S

fu
l
D

is
L

t of

DL
4. get WS Service
5. retur
WSDL n
&
client s ing e .g . SO AP/HTTP(S) provider
u
6. call service 7. return result
s

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 21


SOAP
Overview

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 22


SOAP

SOAP is a protocol for transferring data between the source and the
destination through potential intermediate nodes:

several protocols can be used to transfer messages coded in SOAP, in


particular HTTP(S) and SMTP

structure of the message envelope, body etc

XML-based impacts performance Web services offer worse


performance than CORBA and technologies for parallel computing
such as MPI implementations, PVM
Portable if the client and the server where the service is installed
understand it the system works this means the technology does not
depend on operating systems, programming languages etc.
There are many implementations handling it for various languages and
platforms
for more details refer to SOAP Primer:
URL: http://www.w3.org/TR/soap12-part0/
2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 23
Web Services in AXIS

AXIS allows one to publish a Web Service:


as a JWS (Java Web Service) file
if source code is available (public class and public methods can be
published inside a Web service at once)
copy a *.java file into jakarta-tomcat*/webapps/axis directory and it
will be available immediately as a Web Service

using a WSDD (Web Service Deployment descriptor) file for:


specifying methods which are allowed (accessible to the client)
attaching a handler to the web service to write down every invocation
of the service (logging)

see the AXIS users guide for more details more slides to follow
on this course

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 24


Web Services in AXIS

More information can be found in:

manuals for labs 2-4 read the following documents:

2. basic Web service invocation and deployment, WSDL


http://fox.eti.pg.gda.pl/~pczarnul/AUI-lab2-1.pdf
http://fox.eti.pg.gda.pl/~pczarnul/AUI-lab2-1.zip

3. securing Web Service calls with HTTPS and HTTP basic auth see also next
slides
http://fox.eti.pg.gda.pl/~pczarnul/AUI-lab3-1.pdf
http://fox.eti.pg.gda.pl/~pczarnul/AUI-lab3-1.zip

4. handlers for Web Services


http://fox.eti.pg.gda.pl/~pczarnul/AUI-lab4-1.pdf
http://fox.eti.pg.gda.pl/~pczarnul/AUI-lab4-1.zip

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 25


EJB to Web Services

EJBs can be deployed as Web Services easily:


an example with JBoss and AXIS
make BeesyClusters EJBs available as Web Services

uses WSDD configuration files (allowed methods etc.)

more information can be found in the manual for the BeesyCluster


system to be embedded here

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 26


Web Service Deployment
Tomcat/AXIS2

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 27


Installation using Standalone AXIS2

Steps to compile and deploy Web Services:

Install Java e.g. into


/usr/local/jdk1.7.0_07

Deploy AXIS2 as a standalone server i.e. Unzip the archive


into
/usr/local/axis2-1.6.2

and start:
/usr/local/axis2-1.6.2/bin# ./axis2server.sh
Using AXIS2_HOME: /usr/local/axis2-1.6.2
Using JAVA_HOME: /usr/local/jdk1.7.0_07
[INFO] [SimpleAxisServer] Starting

By default, it will start listening on port 8080

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 28


Installation using Standalone AXIS2

Steps to compile and deploy Web Services:

Follow the steps from the lab manual to:



compile the service,
prepare an appropriate descriptor
Include optional jars in the lib subdirectory
Package everything into an aar archive

Then the service in the aar archive needs to be deployed in the server
i.e. Put into a dedicate directory:

[INFO] Deploying Web service: version.aar - file:/usr/local/axis2-
1.6.2/repository/services/version.aar
[INFO] Deploying Web service: HelloService.aar - file:/usr/local/axis2-
1.6.2/repository/services/HelloService.aar
[INFO] Deploying Web service: StockQuoteService.aar -
file:/usr/local/axis2-1.6.2/repository/services/StockQuoteService.aar
2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 29
Installation using Tomcat

In this case AXIS2 is deployed into a servlet container - Tomcat:

Install Apache Tomcat i.e. Download an archive and unpack it into e.g.:

/usr/local/apache-tomcat-5.5.28

Then copy the packaged AXIS2 into the webapps subdirectory of
Apache Tomcat i.e. Copy file:

axis2.war into that directory (can be downloaded separately)

Access AXIS2 at:

http://localhost:8080/axis2

Then you can perform AXIS administration using login/pass:
admin/axis2 by default

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 30


Installation using Tomcat

In this case AXIS2 is deployed into a servlet container - Tomcat:

Then services prepared in archives can be uploaded as aar files and


deployed through a Web browser check if these are available in the
administration control panel

Invoke a service through the browser using:

Invocation of method sayHello of service HelloService:
http://localhost:8080/axis2/services/HelloService/sayHello

Or if you want to pass parameters:
http://localhost:8080/axis2/services/StockQuoteService/getPrice?
symbol=PG

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 31


Web Service Security
HTTP, HTTPS, HTTP Basic-AUTH, Web
Services in BeesyCluster
Tomcat/AXIS 1.4

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 32


Security in Web Services

Simple WS examples do not provide any means of security:


server does not authenticate the client
no channel encryption/decryption is used

Solutions:
use HTTP BASIC authorization (requires login and password but sent
as plain text)
use HTTPS encryption (data is encrypted and cannot be decrypted by
third parties but no login/password is specified)
use mixed HTTPS/ HTTP BASIC technologies supports data
encryption and login/password
does not indicate that the user who has just logged in is the
particular person digital signature is required
any of the solutions above do not address more complex
communications scenarios (several calls issued discuss the
BeesyCluster solution)

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 33


Web Service Simple Client No Security

No security:
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.utils.Options;

import javax.xml.rpc.ParameterMode;

public class RunTaskClient


{
public static void main(String [] args) throws Exception {

Options options = new Options(args);

String endpoint = "http://localhost:" + options.getPort() +


"/axis/RunTaskServer.jws";

args = options.getRemainingArgs();

String method = "RunTask";

2012
String s1 =Pawel
new Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl
String(args[0]); 34
Web Service Simple Client No Security

No security:
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.utils.Options;

import javax.xml.rpc.ParameterMode;

public class RunTaskClient


{
public static void main(String [] args) throws Exception {

Options options = new Options(args);

String endpoint = "http://localhost:" + options.getPort() +


"/axis/RunTaskServer.jws";

args = options.getRemainingArgs();

String method = "RunTask";

2012
String s1 =Pawel
new Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl
String(args[0]); 35
Web Service Simple Client BASIC AUTH Security

BASIC AUTH security:

call.setTargetEndpointAddress( new java.net.URL(endpoint) );


call.setOperationName( method );
call.addParameter( "op1", XMLType.XSD_STRING,
ParameterMode.IN );
call.setReturnType( XMLType.XSD_INT );

call.setUsername("runtaskuser");
call.setPassword(<password>");

Integer ret=(Integer) call.invoke( new Object [] { s1 });

System.out.println("Got result : " + ret);

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 36


Web Service Simple Client BASIC AUTH Security

Server configuration:

define the user(s) in file jakarta-tomcat-4.1.18/conf/tomcat-


users.xml

<tomcat-users>
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="runtaskuser"/>
<role rolename="onjavauser"/>
<user username="tomcat" password=<password>" roles="tomcat"/>
<user username="role1" password=<password>" roles="role1"/>
<user username="both" password=<password>" roles="tomcat,role1"/>
<user username="runtaskuser" password=<password>" roles="runtaskuser"/>
<user username="bob" password=<password>" roles="onjavauser"/>
</tomcat-users>

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 37


Web Service Simple Client Server configuration

Server configuration:
insert the following at the end of file jakarta-tomcat-
4.1.18/webapps/axis/WEB-INF/web.xml before </web-app>
ends:
<security-constraint>
<web-resource-collection>
<web-resource-name>RunTaskApplication</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>runtaskuser</role-name>
</auth-constraint>
</security-constraint>

<login-config>
<auth-method>BASIC</auth-method>
<realm-name>RunTask Application</realm-name>
</login-config>
2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 38
Web Service Simple Client HTTPS encryption/decryption

The client code:

Options options = new Options(args);

String endpoint =
"https://localhost:8443/axis/accessedbyHTTPS/RunTaskServer.jw
s";

System.setProperty("javax.net.ssl.trustStore",
"/home/pczarnul/.keystore");

args = options.getRemainingArgs();

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 39


Web Service Simple Client HTTPS encryption/decryption

The server side the standard non-encrypted 8080 port still available:

<!--
Define a SSL Coyote HTTP/1.1 Connector on port 8443
-->
-
<Connector
className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8443" minProcessors="5" maxProcessors="75"
enableLookups="true" acceptCount="100" debug="0"
scheme="https" secure="true" useURIValidationHack="false"
disableUploadTimeout="true">
<Factory
className="org.apache.coyote.tomcat4.CoyoteServerSocketFact
ory" clientAuth="false" protocol="TLS"/>
</Connector>
2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 40
Web Service Simple Client HTTPS encryption/decryption

The client code:

keystore how to generate? why is it needed?

keytool

System.setProperty("javax.net.ssl.trustStore",
"/home/pczarnul/.keystore");

for more information about securing Web Services see:


http://www-
106.ibm.com/developerworks/webservices/library/ws-sec1.html

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 41


Web Service Security
HTTPS, HTTP Basic-AUTH
Tomcat/AXIS2

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 42


Configuration

Idea the same as for Tomcat/AXIS 1.4

Configure HTTPS by following these steps:



Enable listening on 8443 in conf/server.xml of Tomcat:

<Connector port="8080" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25"
maxSpareThreads="75"
enableLookups="false" redirectPort="8443"
acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />

Generate:
$JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA (Unix)
with a password value of "changeit" for both the certificate and
the keystore itself.

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 43


Configuration

Idea the same as for Tomcat/AXIS 1.4

Now it is necessary to enable a https receiver in AXIS. To do this,


follow:
Unpack axis2.war jar xvf axis2.war
Add the following to WEB-INF/conf/axis2.xml:
<transportReceiver name="http"
class="org.apache.axis2.transport.http.AxisServletListener">
<parameter name="port">8080</parameter>
</transportReceiver>

<transportReceiver name="https"
class="org.apache.axis2.transport.http.AxisServletListener">
<parameter name="port">8443</parameter>
</transportReceiver>
Pack using jar cvf axis2.war .
And deploy into the server (remove the axis2 directory if there is one in
webapps of Tomcat)
2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 44
Advanced Web Service Deployment
AXIS Technology

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 45


Usage of SOAP

What to use SOAP for?

another RPC implementation e.g. SOAP/HTTP instead of e.g. CORBA


calls
treat input data as an XML document and have it processed by the
server (XSLT) and return to the client

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 46


Message Handling in AXIS

Process messages in a chain:

see the architecture guide of AXIS

for chains, handlers etc.

see the users guide of AXIS

for message styles (standard, document/wrapped and message for XML


processing

serializers/deserializers

WSDD deployment)

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 47


Message Handling in AXIS

Process messages in a chain:

see the reference guide of AXIS for terminology and the format of the
following files:
deploy.wsdd
undeploy.wsdd
others

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 48


Message Handling in AXIS

Process messages in a chain:

process data before or after the web service is invoked


SOAP header handling
logging Web Service calls

AXIS defines chains: codes launched successively on the incoming data


chains are implemented by handlers have access to all requests and
responses and can modify them!
IDEA: process message before/after the server responds to the call
allows to build some add-on features without the need for code
modification
encryption/decryption the real method gets a decrypted
message
the output data is encrypted again without the need for code
modification

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 49


Message Handling in AXIS

Process messages in a chain:

chains can be specific for the transport layer (HTTP, SMTP)


can implement e.g. encryption/decryption for a certain protocol
what else?

chains can be global (for all web service calls)

chains can be specific for a given web service

priorities: - this model can also be applied on the client side


1. transport chain
2. global
3. web service specific (includes request handler, the very web
service, reponse handler)
4. global
5. transport chain

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 50


Message Handling in AXIS

Transport layer handling:

AXIS assumes there is/are (a) transport module that listens for
messages on a certain port and passes data to the main AXIS module
the listener can be a 80 port listener
can be a specific listener waiting for a defined action e.g. when a
certain user logs in to the system

can get a reference to


AxisEngine e=AxisServer.getSingleton();
MessageContext mc=new MessageContext(e); // stores data
associates with the call

Message . // put message into Message Context

engine.invoke(mc);

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 51


AXIS Configuration

Configuration Steps:

copy directory axis_ver/webapps/axis to the webapps directory of the


server e.g. Tomcat
deployment:
JWS (Java Web Service) files should be located in webapps/axis
Java classes deployed as Web Services should be put into
webapps/axis/WEB-INF/classes

webapps/axis/WEB-INF/lib should contain jar files used by AXIS

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 52


Advanced Application Deployment in AXIS

1. Use a deploy.xml/undeploy.xml file to deploy or undeploy a Web


Service, deploy.xml can contain:
handler:

<handler name=name class=classname> [<option name=name


value=value/>]*

</handler>

options are available for the handler suring execution

it is necessary to provide the name and the class code for the handler

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 53


Advanced Application Deployment in AXIS

1. Use a deploy.xml/undeploy.xml file to deploy or undeploy a Web


Service, deploy.xml can contain:
chain:

defines a chain of handlers for the web service:

either:
flow (a sequence of defined handlers is executed)
request, pivot, response (before, the actual web service handler
and after the web service is invoked)

<chain name=name flow= handler1 handler2 handlern>


[<option name=name value=value/>]*
</chain>
<chain name=name request= handler1 handler2 handlern
pivot=handlern+1 response=handlern+2 .>
[<option name=name value=value/>]*
</chain>

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 54


Advanced Application Deployment in AXIS

1. Use a deploy.xml/undeploy.xml file to deploy or undeploy a Web


Service, deploy.xml can contain:
service:

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 55


Features of AXIS 2.0

Features:

http://ws.apache.org/axis2/

modular technology: more than 1.x


asynchronous calls see examples

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 56


Web Services - WSDL
Web Services Description Language

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 57


WSDL Overview

What is WSDL?

A standard which describes a Web Service:


Its interface (method names, parameters, types)
Protocols used to access the service
The address of the Web Service (e.g. URL)
Submitted by IBM, Microsoft and others to W3C Consortium for
approval in 2000
Access the current specification at:

http://www.w3.org/TR/wsdl

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 58


WSDL: Considered Example
1. Generate WSDL from Java - how?
Given
public class Point {
public int x;
public int y;
}

public class Rectangle {


public void SetLeftUpperPoint(Point pt) { }

public void SetLeftUpperPoint(int x,int y) { }

public String GetDescription() { return "aaa"; }


public void SetDescription(String desc) { }
}

We want to translate the interface to WSDL.

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 59


WSDL: Message
1. WSDL Elements
Message describes A SET OF parameters used by operations
(methods) invoked by the client code
Composed of parts (parameters i.e. parameter names and
corresponding types)
Can be (specified in a PortType) of type:
Input
Output
Fault (information describing an error)
Arguments for method
public void SetDescription(String desc)
correspond to:
<wsdl:message name="SetDescriptionRequest">
<wsdl:part name="in0" type="xsd:string"/>
</wsdl:message>

<wsdl:message name="SetDescriptionResponse">
</wsdl:message>

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 60


WSDL: Message
1. WSDL Elements
Message
Arguments for method
public void SetLeftUpperPoint(int x,int y)
correspond to
<wsdl:message name="SetLeftUpperPointRequest1">

<wsdl:part name="in0" type="xsd:int"/>

<wsdl:part name="in1" type="xsd:int"/>

</wsdl:message>

<wsdl:message name="SetLeftUpperPointResponse1">

</wsdl:message>

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 61


WSDL: Message
1. WSDL Elements
Message
Arguments for method
public void SetLeftUpperPoint(Point pt)
correspond to
<wsdl:message name="SetLeftUpperPointRequest">

<wsdl:part name="in0" type="tns2:Point"/>

</wsdl:message>

<wsdl:message name="SetDescriptionResponse">

</wsdl:message>

NOTE: class Point defined in Types

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 62


WSDL: Type
1. WSDL Elements
Type defines all data types used in the description of the Web Service
(WSDL), used by part entries of messages which in turn correspond to
sets of arguments of various operations
Uses XML (XSD)
Examples
Simple types
<wsdl:message name="SetLeftUpperPointRequest1">

<wsdl:part name="in0" type="xsd:int"/>

<wsdl:part name="in1" type="xsd:int"/>

</wsdl:message>
complex type corresponding to
public class Point {
public int x;
public int y;
}

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 63


WSDL: Type
1. WSDL Elements
Type (cont.)
complex types
<wsdl:message name="SetLeftUpperPointRequest">

<wsdl:part name="in0" type="tns2:Point"/>

</wsdl:message>

<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://DefaultNamespace">
<import
namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="Point">
<sequence>
<element name="x" type="xsd:int"/>
<element name="y" type="xsd:int"/>
</sequence>
</complexType>
</schema>
</wsdl:types>
2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 64
WSDL: portType
1. WSDL Elements
portType definition of a Web Service interface
Contains declarations of MANY operations to be called within the
discussed Web Service
Corresponds to a Java interface which defined various methods
(operations here)
Operations use messages and define whether they are input,
output or fault messages

Operation can be of type:


Request-response contain input, output and optional fault
messages
One-way only input messages in the operation
Notification one-way from server to client (possibly a
registration of the client is required first to record the address
where the notification is to be sent)
Notification-response in this mode the client responds to the
notification message (the order of messages is output/input
rather than input/output in request/response)
2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 65
WSDL: portType
1. WSDL Elements
portType

Example
<wsdl:portType name="Rectangle">

<wsdl:operation name="SetLeftUpperPoint"
parameterOrder="in0">

<wsdl:input name="SetLeftUpperPointRequest"
message="impl:SetLeftUpperPointRequest"/>

<wsdl:output name="SetLeftUpperPointResponse"
message="impl:SetLeftUpperPointResponse"/>

</wsdl:operation>

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 66


WSDL: portType
1. WSDL Elements
portType
Example (cont.)
<wsdl:operation name="SetLeftUpperPoint" parameterOrder="in0
in1">
<wsdl:input name="SetLeftUpperPointRequest1"
message="impl:SetLeftUpperPointRequest1"/>
<wsdl:output name="SetLeftUpperPointResponse1"
message="impl:SetLeftUpperPointResponse1"/>
</wsdl:operation>
<wsdl:operation name="GetDescription">
<wsdl:input name="GetDescriptionRequest"
message="impl:GetDescriptionRequest"/>
<wsdl:output name="GetDescriptionResponse"
message="impl:GetDescriptionResponse"/>
</wsdl:operation>
<wsdl:operation name="SetDescription" parameterOrder="in0">
<wsdl:input name="SetDescriptionRequest"
message="impl:SetDescriptionRequest"/>
<wsdl:output name="SetDescriptionResponse"
message="impl:SetDescriptionResponse"/>
</wsdl:operation>
2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 67
WSDL: Port
1. WSDL Elements
Port contains the address of the Web Service and the corresponding
binding which defines what should be invoked
Example

<wsdl:port name="Rectangle"
binding="impl:RectangleSoapBinding">

<wsdlsoap:address
location="http://localhost:8080/axis/Rectangle"/>

</wsdl:port>

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 68


WSDL: Binding
1. WSDL Elements
binding associates the operations inside a portType with the particular
protocol which defines how the parameters should be encoded e.g.
SOAP or POST in HTTP, etc.
Example
<wsdl:binding name="RectangleSoapBinding"
type="impl:Rectangle">

<wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>

<wsdl:operation name="SetLeftUpperPoint">

<wsdlsoap:operation soapAction=""/>

<wsdl:input name="SetLeftUpperPointRequest">

<wsdlsoap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:Rectangle"/>

</wsdl:input>
2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 69
WSDL: Service
1. WSDL Elements
Service groups ports together why? Possibly for grouping ports
connected with different bindings (protocols) of one portType (interface)
OR for grouping connected but different portTypes
Example
<wsdl:service name="RectangleService">

<wsdl:port name="Rectangle"
binding="impl:RectangleSoapBinding">

<wsdlsoap:address
location="http://localhost:8080/axis/Rectangle"/>

</wsdl:port>

</wsdl:service>

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 70


Java2WSDL in AXIS
1. Generate WSDL from Java in AXIS - how?
Given
public class Point {
public int x;
public int y;
}

public class Rectangle {


public void SetLeftUpperPoint(Point pt) { }

public void SetLeftUpperPoint(int x,int y) { }

public String GetDescription() { return "aaa"; }


public void SetDescription(String desc) { }
}

Use the Java2WSDL tool to create a WSDL file from the interface
above.

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 71


Java2WSDL in AXIS
1. Generate WSDL from Java in AXIS - how?
Here is an example invocation that produces the wsdl file (wp.wsdl)
from the interface described in the previous section:

% java org.apache.axis.wsdl.Java2WSDL -o wp.wsdl


-l"http://localhost:8080/axis/services/WidgetPrice" -n "urn:Example6"
-p"samples.userguide.example6" "urn:Example6"
samples.userguide.example6.WidgetPrice

Where:
* -o indicates the name of the output WSDL file
* -l indicates the location of the service
* -n is the target namespace of the WSDL file
* -p indicates a mapping from the package to a namespace. There
may be multiple mappings.
* the class specified contains the interface of the webservice.

java org.apache.axis.wsdl.Java2WSDL -o rectangle.wsdl


-l"http://localhost:8080/axis/Rectangle" -n "urn:Rectangle"
-p"math.rectangle" "urn:Rectangle" Rectangle

generates rectangle.wsdl 72
2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl
Web Services - UDDI
Universal Description, Discovery and Integration

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 73


UDDI Literature

1. Literature
S. Graham, S. Simeonov, T. Boubez, D. Davis, G. Daniels
Building Web Services with Java: Making Sense of XML, SOAP, WSDL
and UDDI
http://www.uddi.org/find.html
http://uddi4j.sourceforge.net/
http://www-
106.ibm.com/developerworks/webservices/library/ws-
uddi4j2.html
http://ws.apache.org/juddi/

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 74


Structures in UDDI
1. businessEntity information about companies various pages just
as the phone book
white pages information about companies: name, address, contact
information
yellow pages by type(s) of services performed by the company
can be more than one
green pages how to invoke services offered by the company

1. tModel can represent a concept, an abstract model of a service,


specification that the service adheres to etc.
service types that can be reused by many companies
1. elements in UDDI form a tree structures contain structures
identification by Universal Unique Identifiers (UUIDs) for the main
structures:
tModel
businessEntity
businessService
bindingTemplate

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 75


UDDI API
1. API
defines operations that any UDDI compliant server must
understand/respond to them (SOAP/HTTP,HTTPS)

API for publication of services


allows to publish information about the company and the services
offered
requires an authentication token
UDDI providers must provide their own authorization method

API for querying about services


no authorization required
can return sketchy information/overview
can return detailed information about services

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 76


UDDI API
1. Find operations for the main structures in UDDI return lists of
entries that satisfy the given criteria
find_business for businessEntity (company)
find_service for businessService (service)
find_binding for businessBinding (binding)
find_tModel for tModel

one can issue these and other functions programmatically in the client
programs (full API is available) or through UDDI servers WWW (if
available)

1. Find details operations for the main structures in UDDI take lists
of ids and return data referring to these entities
get_businessDetail for businessEntity (company)
can include get_businessDetailExt (optional)
get_serviceDetail for businessService (service)
get_bindingDetail for businessBinding (binding)
get_tModelDetail for tModel

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 77


UDDI API
1. Save operations for the main structures in UDDI return ids for
newly created entries, take ids for entries to update
save_business for businessEntity (company)
save_service for businessService (service)
save_binding for businessBinding (binding)
save_tModel for tModel

one can issue these and other functions programmatically in the client
programs (full API is available) or through UDDI servers WWW (if
available)

1. Delete operations for the main structures in UDDI use ids to


delete a particular entry
delete_business for businessEntity (company)
delete_service for businessService (service)
delete_binding for businessBinding (binding)
delete_tModel for tModel

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 78


UDDI API
1. Auth API
get_authToken get a token (used for publishing)
discard_authToken dump the token

getRegisteredInfo returns all tModels and businessEntities registered


by the user

1. UDDI through WWW


uddi.microsoft.com

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 79


tModel
1. One service type declaration can define e.g. technical
specifications
tModel contains:
attributes:
tModelKey UUID attached by the UDDI operator used in
queries later, cannot be modified
operator the UDDI operator (where created) name, cannot be
modified
authorizedName the name given to the user who has registered
the model, cannot be modified
elements:
name mandatory
description optional
overviewDoc contains more information, namely:
string description
string overviewURL an URL that contains more (technical)
info about tModel to be fetched by HTTP/GET

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 80


tModel
1. One service type declaration
tModel contains:
elements:

overviewDoc contains more information (optional element),
namely:
string description
string overviewURL an URL that contains more (technical)
info about tModel to be fetched by HTTP/GET
identifierBag contains elements keyedReference each is a
name-value pair refers to a name space defined within UDDI or
by some external entities can be useful while searching
categoryBag as above contains elements keyedReference
refers to taxonomies within UDDI or defined by external entities

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 81


UDDI
1. Categories and classification
categories
classifications how objects are mapped to categories

UDDI contains the following classifications:


NAICS (North American Industry Classification System) classifies
companies by their profiles
UNSPSC (Universal Standard Products and Services Classification)
classifies products and services

to refer to those use categoryBag which contains:


tModelKey refers to the classification schema
keyValue identifies the particular category e.g. photo camera
manufacturers

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 82


UDDI
1. Categories and classification

same for identifierBag assigns the company/tModels to an


identification system i.e. Tax Identification Number or PKD/EKD
identification data instead of categories here

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 83


Authorization in UDDI
1. Authorization
for publication API calls UDDI servers use SSL and require an auth
token from the client (authInfo)

UDDI operators may define their own ways to obtain the auth token or
must implement get_authToken which returns the token. The token is
then used in the publication API queries

discard_authToken client can invoke after has completed the


publication calls

get_authToken takes the user name and the password (may be


obtained by prior registration on the UDDI web page)

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 84


Publishing tModels
1. Publishing
get authInfo from the UDDI server (registration, user/password may be
required)

invoke save_tModel takes:


authInfo
tModel one or more

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 85


businessEntity in UDDI
1. businessEntity information about the company
attributes:
operator the name of the UDDI operator (assigned by the operator,
cannot be changed)
businessKey assigned by the UDDI operator, cannot be changed
can be used for updates later
authorizedName as for tModel
elements:
name
description
contacts can include contact elements:
string personName
string description
string phone
string email
address contains string addressLines

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 86


businessEntity in UDDI
businessEntity information about the company
elements:
name
description
contacts
discoveryURLs contains elements discoveryURL which can point at
services offered by the company etc., optional
businessServices can contain businessService
identifierBag as for tModel
categoryBag as for tModel

save_business can take:


authInfo
businessEntity

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 87


services in UDDI
1. services and bindings
services can have a universal description (element businessService)
and particular bindings e.g. SOAP/HTTP, HTTP

businessService:
attributes:
businessKey identifies businessEntity that contains this
businessService, a service can be registered with the
businessEntity (save_business) this attribute is set by the server
or by calling save_service (then it must be set to an existing
businessEntity)
serviceKey identifies the service, set by the UDDI operator,
cannot be modified, can be used for updates later

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 88


services in UDDI
1. services and bindings

businessService:
elements:
name - mandatory
description optional
categoryBag
bindingTemplates includes elements bindingTemplate
(mandatory) define the implementation details of the services

bindingTemplates attributes:
bindingKey set by the UDDI operator
serviceKey defines the service the binding is associated with, the
bindingTemplate can be saved with save_service and save_binding

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 89


services in UDDI
1. services and bindings
bindingTemplates elements:
description
accessPoint the address, attribute (attribute in an XML node)
URLType can include http, ftp, https, phone etc.
hostingRedirector used instead of accessPoint defines where to look
for the the binding (can be another company)
tModelInstanceDetails can contain elements tModelInstanceDetail
which by (tModelKey) refer to the protocols tModel e.g. SOAP etc.
save_service takes authInfo and businessService
save_binding takes authInfo and bindingTemplate

operations delete_* take authInfo and the key of the element to delete

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 90


Finding in UDDI
1. Find for general information and get_detail* for more details
method find can define:
maxRows the maximum number of rows to be returned (attribute)
findQualifiers can contain elements findQualifier which denote how
input values are matched e.g.:
sortByNameAsc, sortByNameDesc, sortByDateAsc,
sortByDateDesc, exactNameMatch etc.

find_business finds businesses registered on the UDDI server,


arguments, apart from the attributes above:
name
discoveryURLs whether contains one or more
tModelBag whether contains all tModelKeys
categoryBag whether contains all
identifierBag whether contains one or more

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 91


Finding in UDDI
1. Find for general information and get_detail* for more details
find_business returns businessList includes elements businessInfo, if
it was truncated then attribute truncated=true
businessInfo contains businessKey, name, description and
serviceInfos

serviceInfos is included in serviceList which is returned by find_service


and can contain elements serviceInfo (attr. truncated used as before):
businessKey
serviceKey
name
find_service takes:
name
categoryBag
tModelBag
businessKey is an attribute here

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 92


Finding in UDDI
1. Find for general information and get_detail* for more details
find_binding is analogous to find_service, takes attributes serviceKey
and (optional) maxRows, can have findQualifiers (XML nodes, not
attributes)
takes tModelBag

find_binding returns bindingDetail with attr. generic (version), operator


and truncated and the following elements:
bindingKey
serviceKey
description
accessPoint or hostRedirector
tModelInstanceDetails

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 93


Finding in UDDI
1. Find for general information and get_detail* for more details
find_tModel (attr. findQualifiers, maxRows) and input args:
name
identifierBag
categoryBag

returns tModelList with tModelInfos tModelInfo contains tModelKey


and name

get*Detail take tModelKey, businessKey, serviceKey, bindingKey as


arguments and return tModelDetail (includes tModel) ,
businessDetail (includes businessEntity), serviceDetail (includes
businessService)

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 94


UDDI API with UDDI4J
1. Using UDDI4J
download ant, AXIS, JSDK 1.2+
install all the above, add all jars to CLASSPATH

compile uddi4j unpack and go to the root directory, type ant all
should compile without problems
samples will be compiled to build/samples

to run samples:
go to the samples directory, add uddi4j.jar to the CLASSPATH (note
whether do not use another uddi4j.jar like the modified version in
BeesyCluster)
configure the samples.prop file see the following slide
run java FindBusinessExample should contact the inquiry server
(e.g. IBMs or Microsofts) and return information about available
services

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 95


UDDI API with UDDI4J
1. Using UDDI4J
go through the source code of the samples and become familiar with
them
configuration of the samples.prop file (used by Configurator, this in turn
used by the other classes e.g. FindBusinessExample): - define the
following, set Transport to AXIS, URLs to any available UDDI operator
and userid and password if you wish to publish, publish URL uses
HTTPS
inquiryURL =
publishURL =

userid =
password =

# -----------------------------------------------------------------------
# Transport classname. Typically defined on commandline as
# -Dorg.uddi4j.TransportClassName=xxx.
# -----------------------------------------------------------------------
TransportClassName=org.uddi4j.transport.ApacheSOAPTransport
# TransportClassName=org.uddi4j.transport.ApacheAxisTransport
# TransportClassName=org.uddi4j.transport.HPSOAPTransport

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 96


UDDI 2.0
1. New features in 2.0

http://www.oasis-open.org/committees/uddi-
spec/doc/tcspecs.htm#uddiv2

modelling inter-company relations in UDDI

creation of new taxonomies

etc.

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 97


UDDI API with UDDI4J

1. UDDI if now often used as internal company registries and/or for


integration with other companies
2. On the other hand there are web sites with web access to
databases storing information about services, monitoring their
statuses at runtime etc. e.g.:

http://www.service-repository.com/
http://www.xmethods.net/ve2/index.po
http://seekda.com/

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 98


Mapping WSDL to UDDI
1. UDDI can reflect some information contained in WSDL not all
UDDI.org publishes Best Practices which define how this mapping
should be performed
tModel can represent a specification that can be reused

Mapping (WSDL->UDDI ver 2.0, what changes with respect to ver 1.0
see the Best Practice below):

portType -> tModel with name = portType name


overviewURL=wsdl location
categoryBag type=portType namespace=namespace
binding -> tModel with name = binding name
overviewURL=wsdl location
categoryBag type=binding namespace=namespace portType =
portType tModel protocol= e.g. SOAP transport= e.g. HTTP

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 99


Mapping WSDL to UDDI
1. UDDI can reflect some information contained in WSDL not all
Mapping (WSDL->UDDI ver 2.0, what changes with respect to ver 1.0
see the Best Practice below):

http://www.oasis-open.org/committees/uddi-
spec/doc/tn/uddi-spec-tc-tn-wsdl-v202-20040631.htm

port -> bindingTemplate accesspoint=service address e.g. URL


portType=portType tModel binding=binding tModel local name = port
name

service -> businessService with name = given name


bindingTemplate as above
categoryBag
type=service
namespace=namespace
local name = name of the service

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 100


Mapping WSDL to UDDI
1. UDDI can reflect some information contained in WSDL not all
Mapping (WSDL->UDDI ver 2.0, what changes with respect to ver 1.0
see the Best Practice below):

http://www.oasis-open.org/committees/uddi-
spec/doc/tn/uddi-spec-tc-tn-wsdl-v202-20040631.htm

see the mapping details of various (6) WSDL elements and their
attributes to UDDI elements in:

STUDY the example mapping in the Best Practice above

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 101


Workflows
Models, Standards, Optimization

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 102


Workflows

Workflow: a graph representation of tasks (represented by nodes) with


dependencies (represented by edges)

Types of workflows:
business traditionally control flow oriented e.g. exchange of
communication, orders, quotes etc. Between businesses

scientific usually compute and/or data intensive applications on the


grid.
usually requires much computational power thus integration of
various clusters to accomplish even one task (high level grid
systems which hide particulars of queueing systems)
may require flow of large amounts of data (user virtual directory,
problem of replication, efficiency when accessing data, handling
failures etc.)

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 103


Workflow examples

Example of a business workflow:

Order apples of the given sort, plums of the given sort, additional
ingredients such as sugar etc, transport them to the factory, produce
jam, transport to a storage location and then distribute based on orders
from large shops

Example of a scientific workflow:

Generate geometry for the given simulation i.e. files which describe
parameters of the simulation, points in space on which the code must
compute certain values, launch two different simulation codes (which
produce different output) on same input data (possibly in parallel),
merge results, in the meantime get additional data from measurements
and launch another simulation using the whole set, requires more than
one cluster because of the size of data as well as care when handling
data sets (large)

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 104


Exceptions in Workflows

Exception handling for workflows:

In business workflows:
partner may stop operation (goes out of business)
factory may close down (electricity failure)
partner may be late with payments
SLA not followed

In scientific workflows:
cluster may go down (restart simulation, maybe was checkpointed
before)
node where the data was stored goes down (should be able to restore
the data transparently to the user)
cluster gets overloaded (additional users how to cope with that?
Process/data Migration?) need for constant monitoring of the
simulation

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 105


Service selection problem

The workflow is modelled as an acyclic directed graph G(V,E) where


each vertex denotes a task and directed edges denote the flow.
There is input data located in designated directories on
clusters/servers available to the user and the data is transferred to
following tasks before they are executed. The user sets which input
data flows to which successor nodes.
each task ti has a corresponding set of services Si out of which one
service sij is chosen to execute task ti

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 106


Service selection problem

The graph defines tasks and dependencies between them

Each service sij has several parameters corresponding to the quality


attributes such as:
execution time tij
Cost cij
Reliability rij
etc.
The goal is to select best services (one for each task) to minimize the
given goal of QoS attributes for the whole workflow while meeting
constraints on some of them
Algorithms:
integer linear programming (ILP)
genetic algorithms
market-based solutions

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 107


Optimization Goals and Reselection

Minimization of several alternative goals:


a product of workflow execution time and the sum of costs of
selected services
A weighted linear combination of workflow cost and
execution time
Workflow execution time with a constraint on the workflow
cost
Others possible

Reselection is launched if some services have become unavailable or


QoS conditions have changed

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 108


Example of a An Assembly/Distribution Workflow

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 109


Possible Applications of the Model

The model is suitable for both:


Scientific workflows hiding queueing systems, selection of
services installed on various clusters means selection of
resources, failures of nodes, other users
Business workflows services published by users with defined
costs, services controlled by users, time-cost scheduling
(possibly more quality attributes), changing markets

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 110


Quality attributes in service composition/integration

Execution Time - time needed to accomplish the given composition of


services from the moment the client invokes the workflow until the last
service is finished and output results reported. May be delayed by:
queueing time of tasks on clusters -- may depend on the current
number, priorities and queues on the given cluster and this possibly on
the time of the day, week etc, maintenance breaks etc., other tasks
scheduled to run on the same node
spawning tasks by other users on the computing nodes not using
queueing systems and already being used by the given client which
slows down the execution of services due to processor time sharing.

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 111


Quality attributes in service composition/integration

Cost - sum of the costs of all services selected for the execution of the
workflow
Availability defined as e.g. MTBF (Mean Time Between Failrues) with a
proper weight to be incorporated into a final QoS metric composed of
this and other quality attributes
Accessibility - meant as the probability of being able to access the
service irrespective of whether the service itself is available or not -- this
in fact leads to the quality of the network/software infrastructure
between the client and the service nodes or high load caused by
requests from other users
Fidelity or conformance to predict the degree to which the task has been
performed by the service or whether and to what degree the
workflow/service are compliant with the published requirements or
standards

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 112


Quality attributes in service composition/integration

Security - several aspects could be considered here as:


whether the existence or execution of the workflow by a user is
confidential
whether transmission of input data or results is secure

Reputation related to reliability and qualities of the provider

To compute the final aggregate quality for the whole workflow


reduction algorithms are used which reduce constructs found in a
workflow graph i.e. shrink the network to one node. Each reduction
computes an output value of a quality attribute from the values of the
quality attributes of the elements of the construct.

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 113


Scheduling for workflows Task scheduling

A graph represents tasks with dependencies, the goal is to map tasks


(with defined execution times) to the available resources so that the
dependencies are satisfied and the execution time is minimized
No costs are considered
NP.-complete
Heuristics:
min-min - maps a task with a minimum completion time to a first
machine. Min-min is used in Pegasus with a round-robin and random
allocation methods.
HEFT algorithm first weighs nodes and edges of the task graph, then
ranks tasks in the order to be executed and maps tasks to available
resources. This is compared to a genetic algorithm and appears to
shown to produce better or comparable mappings
while being faster than GA. Used in ASKALON.
simulated annealing, random and best of n random choosing and one
following the game theory in which players optimize their gains,
simulated annealing produces best results (ICENI).

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 114


Scheduling for workflows Scheduling on utility grids

cost, reliability, security, availability etc. can be considered instead of


just the execution time as for task scheduling.
There are services distinguished which can execute particular tasks
The goal is to map tasks to services so that dependencies are satisfied
(no more than one task to service at the same time) compared to
service selection here for each task a service is scheduled at a
particular point in time

and the goal composed of QoS attributes is minimized (e.g. the


execution time when there is a given budget for the workflow)

Proposed solutions:
genetic algorithm how to encode a genom?
divide-and-conquer distribute a deadline (or budget) among sections
of the graph and optimize locally

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 115


Workflows
Workflow Management Environment in
BeesyCluster

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 116


Workflows
Semantic searching for services

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 117


Need for semantics

Various data formats (e.g. XML) are good in terms of syntax, however
the existence of many various formats used in both business and
scientific worlds does not allow automation of the integration of services,
in particular automatic reasoning and integration of services

There is a need for an ontology a formalized description of the part of


the universe in which the given entity operates

There are good technological standards for services: WSDL, UDDI,


SOAP which do not allow reasoning about data (e.g. the standard UDDI
allows only keyword-based search)

Example:
Client wants to buy a certain type of plums
Provider publishes they sell plums
UDDI will not find this provider when searching for the particular type of
plums does not know it is plums we need an ontology which says
this sort is plums

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 118


Standards for semantics and relations

RDF, DAML etc.

Various data formats (e.g. XML) are good in terms of syntax, however
the existence of many various formats used in both business and
scientific worlds does not

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 119


RDF

Resource Description Framework


An RDF document contains statements

Each statement consists of a subject, property and an object (object


defines the subject by the property)

Subject, property are resources

Object can be either a resource or a literal (string with a corresponding


language id or a string and a corresponding XML schema)

Resources can be any concepts from the considered domain (not


necessarily connected to the Web)

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 120


RDF

Each resource can have a unique id which allows to refer to this


resource (rdf:ID)

An example of a property is type (rdf:type) which defines that the


subject is of type of the object

rdf:about refers to a resource which is defined somewhere else (using


an URI)

RDF also defines groups of resources:


rdf:Seq a sequence (order important)
rdf:Bag unordered group
rdf:Alt the property would refer to one from the group

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 121


RDF

An RDF document can be represented by a graph where:

vertices subject and objects this is a directed graph (literals, URIs


or not labeled)

edges property corresponds to an edge and defines the label of the


graph the label can be a vertex (property is a resource)

An RDF document can be stored in XML or a database easily


When in XML where vertices correspond to an XML element there is a
need to refer from within a vertex to another vertex

RDFS (Schema) defines basic (standard) properties which allow to


represent semantic relationships
Class, Resource (instance of Class), Property, Container
subClassOf, subPropertyOf used in statements

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 122


OWL

Web Ontology Language

Allows to define contraints (a car has at least 4 wheels), boolean


operators (NOT, AND, OR)

Represented by an XML file, with a version and a comment

OWL uses classes and relations (subclass etc.) multiple inheritance


allowed

It can be defined that a class which is in a relation with specific class is


also a specific class (driver of a car is a human)

Multiple contrains can be defined e.g. the car has one gearbox etc.

OWL defines instances of classes - objects

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 123


OWL

OWL versions:

OWL Full content limited by the RDF syntax there is no guarantee


as to completeness or being able to reason based on the content

OWL DL allows reasoning (deriving conclusions from the content


can be completed in finite time) and that conclusions can be derived

OWL Lite with limited set of constraints (no negation etc.)

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 124


OWL-S

OWL for services (OWL-S)

Relates to service, in particular allows reasoning about services (what


services do), making automatic integration of services more automatic

The goal is for the service provider to describe their services using
OWL-S (and possibly store in UDDI) and then the client can use a
matching algorithm to match against the published information on
available services

OWL-S description of a service (provided by a resource) consists of:


ServiceProfile defines what the service performs
ServiceModel defines processes and constructs of them how
exactly the service does what it is supposed to
ServiceGrounding defines how to invoke ths service processes
can be described in terms of WSDLs operation, messages

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 125


OWL-S

ServiceProfile defines what the service performs


defines effects, preconditions, inputs and outputs of the service what
the service does
can contain quality parameters, service category, service name,
contact information regarding the provider

service profile can be mapped to UDDI to store this information to


allow retrieval from clients and execution of ontology-assisted search
in particular mapped to UDDIs:

business service
business entity

mapping is done along the idea: map to a corresponding UDDI


element if there is one, otherwise create a UDDI tModel for the
element (e.g. input, output, precondition, effects)

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 126


OWL-S

ServiceModel defines how the service does defined by processes

There can be composite processes using constructs on simple


processes such as:
iteration
if-then
selection
sequence
split
join

atomic processes implement simple processes

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 127


Automatic service discovery

Steps (can be applied both to business and scientific worlds):

Publish information on a service in terms of ontological concepts (like in


Meteor-S):

Functional specification: like in OWL-S input, output, effects and


preconditions
QoS characteristics values of the quality attributes shown next

Translate data to UDDI


Client specifies an abstract workflow (a graph with nodes representing a
scenario with functional/quality requirements and dependencies
edges)

Match making algorithm matches services to the abstract workflow


specified by the client

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 128


Automatic service discovery publishing data

Require a format to write the information in, e.g. can be one of the
following:
OWL-S
WSDL-S
annotated WSDL

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 129


Automatic service discovery abstract definition from client

Principally can be a graph in which vertices represent tasks (for which


there may be several services which accomplish those tasks) and
edged represent dependencies between them

In a more general form this can also be done using one of the
languages used to model workflows e.g. BPEL4WS as in Meteor-S

Meteor-S talks about binding services to processes, while other works


(workflow scheduling) about finding services to tasks

The client needs to specify requirements for the task or service to be


bound (in terms of ontological concepts and QoS requirements)

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 130


Automatic service discovery matching algorithm

The matching algorithm would work in the following stages:

1. Dynamic selection of services matching the particular task in the


graph/process based on the functional and additional QoS requirements
for the given task/process

1. Optimization of the whole workflow by selection of services so that


global constraints on the workflow and the desired metric is optimized.

This raises the issue of computing global QoS values from those of
individual tasks

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 131


Automatic service discovery execution engines

Having the details of the selected services (through UDDI to the


technical description WSDL)

and the description of the workflow (graph or BPEL4WS)

we need an engine to execute the services

BPWS4J is such a platform

e.g. Meteor-S extracts WSDL details of matched services and creates a


BPEL file which is executed by BPWS4J

http://www.alphaworks.ibm.com/tech/bpws4j

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 132


Workflow Management and Execution in BeesyCluster

Support for a full workflow development, execution


and management cycle:
Workflow editing through a Java applet
Optimization of service selection:
Statically
At runtime
Execution engines:
Centralized
Distributed
Workflow management and visualization

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 133


Workflow Model with Static and Just-in-time Service Selection

The workflow is modelled as an acyclic directed


graph G(V,E) where each vertex denotes a task and
directed edges denote the flow.
There is input data located in designated
directories on clusters/servers available to the user
and the data is transferred to following tasks before
they are executed. The user sets which input data
flows to which successor nodes.
each task ti has a corresponding set of services Si
out of which one service sij is chosen to execute
task ti
each service sij has an execution time tij for
performing the given task on the given input data
as well as a corresponding price cij .
2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 134
Optimization Goals and Algorithms for Workflow Scheduling

Minimization of several alternative goals:


a product of workflow execution time and the
sum of costs of selected services
A weighted linear combination of workflow cost
and execution time
Workflow execution time with a constraint on
the workflow cost
Others possible
Several algorithms implemented with both local and
global knowledge about the workflow
Rescheduling is launched if some services have become
unavailable or QoS conditions have changed

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 135


Example of Assembly/Distribution Workflow Run in BeesyCluster

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 136


Workflow in an Editor

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 137


Workflow Instances

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 138


Two Execution Engines for Workflow Applications

centralized managed by BeesyCluster


server(s) which acts as a proxy between
service locations, manages efficient data
copying etc., multithreaded implementation
uses JMS on JEE server

distributed managed by JADE agents which


can learn about services and environment and
be closer to the services; a workflow is
exported in BPEL for execution

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 139


Workflow Execution using Agents

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 140


Workflow Execution using Agents

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 141


Workflows
Languages for modelling

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 142


Flow and Interaction langugaes for business BPEL4WS

Executable business process represents the flow/actions of the given


party
Business protocol describes interactions between parties

Business Process Execution Language for Web Services


can model both of the above

In BPEL4WS the flow is a graph where the node is representd by an


activity
Data is transferred between containers (a sheet of paper can be a
container and the data can be copied to a database as an example)
Iteraction occurs between partners

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 143


Flow and Interaction langugaes for business BPEL4WS

The role each partner takes is represented by service link e.g.


subscriber or publisher
An BPEL4WS document would define an outer element process with a
name
used containers e.g. requests and responses
partners and service links
activities e.g. in a construct like a sequence:
copying from one container to another (copy in assign element)
invoking an operation (invoke element)
replying (reply element)

http://www-128.ibm.com/developerworks/webservices/library/w
http://www-
128.ibm.com/developerworks/webservices/library/ws-
bpelcol2/
2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 144
Flow and Interaction langugaes for business BPEL4WS

BPEL4WS allows to integrate activities into workflow by the following


constructs:
while
switch
pick
sequence
flow (parallel execution)
And lower level functions:
assign a value to a variable
wait
reply - to a request
receive waiting for a call
invoke a service
throw (an exception)
terminate

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 145


Flow and Interaction langugaes for business WSFL

Web Service Flow Language being replaced by BPEL4WS

Specifies a flow model which defines the sequence of activities


(invoking services) and flow of control and data between activities
(controlLink, dataLink)

The global model specifies interactions between services

WSFL allows directed graphs but acyclic, no support for transactions,


support for exception handling

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 146


Flow and Interaction langugaes for business BPML

Business Process Modeling Language


Allows to define invoking services, receive, send operations, sequential,
parallel execution, loops, joins
Block oriented i.e. execute activities in the block sequentially

Can schedule tasks at the given time

Includes transaction support and exception handling

WSCI (Web Service Choreography Interface) is thought to be a part of


BPML so that WSCI defines interactions between services while BPML
business processes

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 147


WSCI

In WSCI an action would correspond to an operation in WSDL


Call would be used for calling services

Supports parallel, sequential execution, loops, conditional constructs


such as switch or choice

WSCI defines only interactions between services (business protocol),


not executable business process and does so from the perspective of
one party

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 148


CORBA (Common Object Request
Broker Architecture)
Architecture and Applications

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 149


CORBA Architecture (1)
1. CORBA
Supported by Object Management Group founded in 1989 as a non-
profit organization to develop software standards and reduce the
complexity of applications; http://www.omg.org
CORBA distinguishes communication between a client and an object.
The client obtains a reference to a (possibly remote i.e. running in a
different address space) object
The client invokes a method on the object passing input parameters
and collecting results
CORBA supports interoperability between heterogeneous systems and
objects
Allows to hook up heterogeneous systems together e.g. various
UNIX flavors, MS Windows etc.
Objects can be implemented in different languages e.g. the server
in C++ and a client in Java and can still communicate smoothly

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 150


CORBA Architecture (2)
1. CORBA
The client invokes (possibly remotely) methods on the server through
the underlying standardized communication layer Object Request
Broker (ORB)
ORB delivers clients requests to object implementations
Hides all the low level location discovery, communication,
parameter wrapping/unwrapping
Provides a way (for clients) to create objects remotely and obtain
references to them
Objects are identified by Interoperable Object References (IORs)
ORB implements Internet Inter Object Protocol (IIOP)
ORB provides the following operations on object references:
Stringification (the conversion of an object reference to a
string); such a string can be then sent to another object which
can communicate the corresponding object remotely
Destringification (the conversion of a string to the
corresponding object reference)

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 151


CORBA Architecture (3)
1. CORBA
Interoperability between various ORBs is possible thanks to Global Inter
ORB Protocol (GIOP) that uses Common Data Representation (CDR)
for internal data representation
Remote invocations in CORBA
Look like local calls through object references
Object Adapter is an intermediate layer between an ORB and the server
object implementation; supports the following functions:
Object activation/deactivation
Translation and generation of object references
Registers object implementations
Interface Definition Language (IDL) a language that allows to define
server classes and methods
Similar in syntax to Java and C++
The idl compiler compiles the idl interface defintions and generates:
Server object skeleton intermediates between ORB and the
server object implementation
Client stub intermediates between the client and the ORB

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 152


CORBA Architecture (4)
1. CORBA
client-server communication through the various layers

In arguments
Server
Client
Out args + ret val Object
Remote
Method Skeleton
Stub Invocation
Object Adapter

GIOP IIOP ORB

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 153


CORBA Application Development Steps
1. Interface Definition in IDL
Define the methods the client will invoke
1. Generate server skeletons and client stubs using IDL compiler(s)
Use the compiler dedicated for the implementation language you wish to
use e.g.:
IDL to C++ for the skeleton of the server implementation in C++
IDL to Java (e.g. idlj) for the client stub for the client implementation
in Java
1. Implement the code
The server code is assisted by the automatically generated skeleton
code
The client code invokes generated methods available in the stub code
1. Run the application
Start the name service if the aplication uses it
Otherwise start the server which passes references to the client (e.g.
using stringified references saved to a file and the read by the client and
destringified)

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 154


CORBA (Common Object Request
Broker Architecture)
Architecture and Applications

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 155


Object Request Broker Services

Interface Repository (IR)


provides other objects with information about
other IDL interfaces
Implementation Repository
Supports the location and management of
object implementations
Replication (copying objects and consistent state
management)
Installation and activation
Distribute, install, activate, migrate objects

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 156


Distributed Object Services (1)

Naming (white pages: finding objects/services


based on their names)
Trading (yellow pages: advertise services and
bid for contracts)
Event (distribute events among components)
Data producers/consumers
Push model (supplier sends notifications),
pull model (consumer sends requests)

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 157


Distributed Object Services (2)

Externalization (writing/reading an objects


state to/from external files)
Life Cycle
Create
Delete
Copy
Move
Collection (creation and operations on groups
of objects: sequences, queues, stacks, sets,
etc.)

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 158


Distributed Object Services (3)

Query (queries individual objects or groups)


Security
Identification
Authentication
Access control
Secure communication
Licensing (a way to control the users of some
intellectual property)
Reservation/expiration/charging for use

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 159


Distributed Object Services (4)

Time (obtain time)


Global synchronization/logical clocks
Generating time-based events
Concurrency control
Simultaneous access to resources
Locking mechanisms
Atomic actions
Property
Assigns name-value pairs to objects at
runtime

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 160


Distributed Object Services (5)

Transactions; ACID properties:


Atomicity: finishes successfully or does
nothing
Does not fail when the server fails
Consistency: makes the system state jump
from one consistent state to another
Isolation: transactions do not see
intermediate results of others
Durability: output data stored in non-
volatile memory

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 161


Distributed Object Services (6)

Relationship
An object fulfills a role when it participates
in a relationship
Multidirectional
Relationships can have attributes and
operations
Persistent Object Service
accessing the persistent state of other
objects
storing their own state persistently
objects are often stored in an object
oriented database management system

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 162


Distributed Object Services (7)

Data interchange
Supports the exchange of visible state
information between objects
Change management
Version identification
configuration management of object
interfaces, implementations and instances

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 163


Distributed Object Services (8)

Relationship
An object fulfills a role when it participates
in a relationship
Multidirectional
Relationships can have attributes and
operations
Persistent Object Service
accessing the persistent state of other
objects
storing their own state persistently
objects are often stored in an object
oriented database management system

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 164


CORBA (Common Object Request
Broker Architecture)
Architecture and Applications
Additional section (not covered in such detail
during the lecture)

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 165


IDL Mapping
IDL mapping is defined by OMG for a variety of languages, in particular
(http://www.omg.org/technology/documents/idl2x_spec_catalog.htm):
C++
http://www.omg.org/technology/documents/formal/c+
+.htm
C (no objects there!)
http://www.omg.org/technology/documents/formal/c_language
Java
http://www.omg.org/technology/documents/formal/omg_id
l_to_java_language_mapping.htm
Lisp
Python
Smalltalk
ADA
COBOL

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 166


IDL Java Mapping

Basic data types (IDL Java SDK):


float float
double double
short short
long int
long long long
unsigned short short
unsigned long int
unsigned long long long
char char
wchar char
boolean boolean
octet byte
any org.omg.CORBA.Any

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 167


IDL Java Mapping

Basic data types (IDL C++ (MICO)):


float CORBA::float
double CORBA::Double
short CORBA::Short
long CORBA::Long
long long CORBA::LongLong
unsigned short CORBA::UShort
unsigned long CORBA::ULong
unsigned long long CORBA::ULongLong
char CORBA::Char
wchar CORBA::WChar
boolean CORBA::Boolean
octet CORBA::Octet
any CORBA::Any
fixed FixedTmpl<a,b>

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 168


IDL Java Mapping

Basic data types (IDL C (ORBit)):


float CORBA_float
double CORBA_double
short CORBA_short
long CORBA_long
long long CORBA_long_long
unsigned short CORBA_unsigned_short
unsigned long CORBA_unsigned_long
unsigned long long CORBA_unsigned_long_long
char CORBA_char
wchar
boolean CORBA_boolean
octet CORBA_octet
any CORBA_any

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 169


IDL Mapping

Sequences (not defined or predefined length then like an array):


the latter one can be faster
the programmer can fetch/update data in the buffer to reach still better
efficiency
e.g. in IDL:
typedef sequence<double> DoubleSequence;
typedef sequence<double,16> DoubleDefLengthSequence;
in MICO C++, the mapping will be:
typedef
SequenceTmpl<CORBA::Double,MICO_TID_
DEF> DoubleSequence;
typedef
BoundedSequence<CORBA::Double,MICO_T
ID_DEF,16> DoubleDefLengthSequence;

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 170


IDL Mapping

Sequences (not defined or predefined length then like an array):


to operate on the buffer, use:
get_buffer to read data
replace to replace data in the buffer
example:
LongSeq *ls=new LongSeq;
ls->length(25);
(*ls)[13]=445;

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 171


IDL Mapping
Example an interface in IDL as follows:
typedef sequence<octet> ByteBuffer;
typedef long LongTable[33];
struct Cred {
long login;
char password;
};
interface Cluster {
ByteBuffer StoreDataOnCluster(in ByteBuffer buffer, inout ByteBuffer
buffer1);
Cred Login(in Cred cred, inout Cred cred1);
string IsRunning(in string process,inout string process1);
any PassArg(in any a,inout any a1);
LongTable PassTable(in LongTable table,inout LongTable table1);
long Add(inout long a,in long a1);
long Subtract(inout long a,in long a1);

};
2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 172
IDL Mapping

Mapping in C++ (invoke idl --c++-impl cluster.idl in MICO):


typedef SequenceTmpl< CORBA::Octet,MICO_TID_OCTET>
ByteBuffer;
typedef CORBA::Long LongTable[ 33 ];

struct Cred {
Cred();
~Cred();
Cred( const Cred& s );
Cred& operator=( const Cred& s );
CORBA::Long login;
CORBA::Char password;
};

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 173


IDL Mapping

Mapping in C++ (invoke idl --c++-impl cluster.idl in MICO):


class Cluster_stub: virtual public Cluster
{
public:
::ByteBuffer* StoreDataOnCluster( const ::ByteBuffer& buffer,
::ByteBuffer& buffer1 );
::Cred Login( const ::Cred& cred, ::Cred& cred1 );
char* IsRunning( const char* process, char*& process1 );
CORBA::Any* PassArg( const CORBA::Any& a, CORBA::Any& a1 );
::LongTable_slice* PassTable( const ::LongTable table, ::LongTable
table1 ); CORBA::Long Add( CORBA::Long& a, CORBA::Long a1 );
CORBA::Long Subtract( CORBA::Long& a, CORBA::Long a1 );

};

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 174


IDL Mapping

Mapping in Java (invoke idlj -f all cluster.idl in JSDK):


Helper class includes:
reading and writing the object from/to a stream
returning object repository id
cast to/from the Any type

Holder class needed to modify the inout or out parameters a Holder


class encapsulates the real data passed from the client
the client instantiates a Holder class and passes the object to the
server which may modify the contents
available for all basic data types and generated for the user-defined
ones

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 175


IDL Mapping

Mapping in Java (invoke idlj -f all cluster.idl in JSDK):


public final class ByteBufferHolder implements
org.omg.CORBA.portable.Streamable{
public byte value[] = null;
public ByteBufferHolder ()
{}
public ByteBufferHolder (byte[] initialValue)
{ value = initialValue; }
public void _read (org.omg.CORBA.portable.InputStream i)
{ value = ByteBufferHelper.read (i); }
public void _write (org.omg.CORBA.portable.OutputStream o)
{ ByteBufferHelper.write (o, value); }
public org.omg.CORBA.TypeCode _type ()
{
return ByteBufferHelper.type ();
}
}

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 176


IDL Mapping

Mapping in Java (invoke idlj -f all cluster.idl in JSDK):


abstract public class ByteBufferHelper
{
private static String _id = "IDL:ByteBuffer:1.0";
public static void insert (org.omg.CORBA.Any a, byte[] that)
{
org.omg.CORBA.portable.OutputStream out =
a.create_output_stream ();
a.type (type ());
write (out, that);
a.read_value (out.create_input_stream (), type ());
}
public static byte[] extract (org.omg.CORBA.Any a)
{
return read (a.create_input_stream ());
}


2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 177
IDL Mapping

Mapping in Java (invoke idlj -f all cluster.idl in JSDK):


abstract public class ByteBufferHelper
{
private static org.omg.CORBA.TypeCode __typeCode = null;
synchronized public static org.omg.CORBA.TypeCode type ()
{ ..... return __typeCode; }
public static String id ()
{ return _id; }
public static byte[] read (org.omg.CORBA.portable.InputStream
istream)
{ byte value[] = null;
int _len0 = istream.read_long ();
value = new byte[_len0];
istream.read_octet_array (value, 0, _len0);
return value;
}


2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 178
IDL Mapping

Mapping in Java (invoke idlj -f all cluster.idl in JSDK):


abstract public class ByteBufferHelper
{


public static void write (org.omg.CORBA.portable.OutputStream
ostream, byte[]
value)
{
ostream.write_long (value.length);
ostream.write_octet_array (value, 0, value.length);
}

}

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 179


IDL Mapping

Mapping in Java (invoke idlj -f all cluster.idl in JSDK):


in our example the following Holder and Helper classes will be
generated:

ByteBufferHelper.java CredHelper.java
ClusterHelper.java LongTableHelper.java

ByteBufferHolder.java CredHolder.java
ClusterHolder.java LongTableHolder.java

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 180


IDL Mapping
Mapping in Java (invoke idlj -f all cluster.idl in JSDK):
additionally the following Cred class (mapped from struct) will be
generated:
public final class Cred implements org.omg.CORBA.portable.IDLEntity
{
public int login = (int)0;
public char password = (char)0;
public Cred ()
{ } // ctor

public Cred (int _login, char _password)
{
login = _login;
password = _password;
} // ctor

} // class Cred

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 181


IDL Mapping

Mapping in C (invoke orbit-idl skeleton-impl cluster.idl in ORBit):


additionally the following Cred class (mapped from struct) will be
generated:
typedef struct
{
CORBA_unsigned_long _maximum,
_length;
CORBA_octet *_buffer;
CORBA_boolean _release;
} CORBA_sequence_CORBA_octet;
CORBA_octet
*CORBA_sequence_CORBA_octet_allocbuf(CORBA_unsigned_long
len);

the struct contains the maximum and the current length

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 182


IDL Mapping

Mapping in C (invoke orbit-idl skeleton-impl cluster.idl in ORBit):


regarding the buffer, usually it is freed using CORBA_free()

if we allocate memory using a different method than


CORBA_sequence_CORBA_octet_allocbuf()
then it is necessary to change release to FALSE (CORBA_FALSE)
so that CORBA_free is not automatically called and the programmer is
responsible for deallocation

CORBA_sequence_set_release
CORBA_sequence_get_release

do not use 0,1 for FALSE,TRUE!

the struct contains the maximum and the current length

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 183


IDL Mapping

Mapping in C (invoke orbit-idl skeleton-impl cluster.idl in ORBit):


all in file cluster.h generated by ORBit (like the structures before)

typedef CORBA_long LongTable[33];

typedef struct
{
CORBA_long login;
CORBA_char password;
} Cred;

typedef CORBA_Object Cluster;

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 184


IDL Mapping

Mapping in C (invoke orbit-idl skeleton-impl cluster.idl in ORBit):


all in file cluster.h generated by ORBit (like the structures before)

ByteBuffer *Cluster_StoreDataOnCluster(Cluster _obj,


const ByteBuffer * buffer,
ByteBuffer * buffer1,
CORBA_Environment * ev);
Cred Cluster_Login(Cluster _obj, const Cred * cred0, Cred * cred1,
CORBA_Environment * ev);
CORBA_char *Cluster_IsRunning(Cluster _obj, const CORBA_char *
process,
CORBA_char ** process1,
CORBA_Environment * ev);
CORBA_any *Cluster_PassArg(Cluster _obj, const CORBA_any * a,
CORBA_any * a1, CORBA_Environment * ev);

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 185


IDL Mapping

Mapping in C (invoke orbit-idl skeleton-impl cluster.idl in ORBit):


all in file cluster.h generated by ORBit (like the structures before)

LongTable_slice *Cluster_PassTable(Cluster _obj, const LongTable


table,
LongTable table1,
CORBA_Environment * ev);
CORBA_long Cluster_Add(Cluster _obj, CORBA_long * a, const
CORBA_long a1,
CORBA_Environment * ev);
CORBA_long Cluster_Subtract(Cluster _obj, CORBA_long * a,
const CORBA_long a1, CORBA_Environment * ev);

NOTE the pointers for inout/out parameters (given as arguments)


the C implementation requires memory handling
(allocation/deallocation) by the programmer more error-prone

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 186


IDL Mapping

Mapping in C (invoke orbit-idl skeleton-impl cluster.idl in ORBit):


all in file cluster.h generated by ORBit (like the structures before)

now in file cluster-skelimpl.c the methods are preceded by


impl_

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 187


IDL Mapping

String:
in C/C++ mapped to char *
delimited by NULL compatible with the standard Clibrary (strcmp,
strlen etc.)
do not use new/delete, instead use:

char *CORBA::string_alloc(ULong len); -- allocate memory


char *CORBA::string_dup(const char *); -- duplicate a string
void CORBA::string_free(char *); - free memory

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 188


IDL Mapping

String:
the user can see/use CORBA::String (same as char *)
and CORBA::String_var

the latter one is like CORBA::String but its memory is automatically


freed by CORBA::string_free when it gets out of scope

CORBA::String_var allows to access/modify the characters in the string


and can be cast to/from char * and const char *

NOTE: when instantiated from char * - String_var captures the string,


when instantiated from const char * - a copy of the string is allocated

String_out for out arguments

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 189


IDL Mapping
struct:
natural mapping in C/C++
in C++ no need to manage the memory of internal members of the
struct handled by the default destructor
a string in a struct will be mapped to Struct_var no need to worry
about the memory management
struct Str {
string a;
string b;
}; is mapped from IDL to C++ as:
struct Str {
Str();
~Str();
Str( const Str& s );
Str& operator=( const Str& s );
CORBA::String_var a;
CORBA::String_var b;
};
2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 190
IDL Mapping

struct:
Str s;
s.a=CORBA::string_alloc(...);
s.a=CORBA::string_alloc(...);

is allowed, memory will be handled properly (no memory leaks)

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 191


IDL Mapping
array:
mapped naturally in C++ (see the previous example)
typedef long LongTable[33];
is mapped to
typedef CORBA::Long LongTable[ 33 ];
NOTE the mapping:
::LongTable_slice*
Cluster_impl::PassTable( const ::LongTable table, ::LongTable table1 )
throw(
::CORBA::SystemException)

{
::LongTable_slice* retval;
// add your implementation here
....
return retval;
}

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 192


IDL Mapping

array:
::LongTable_slice corresponds to an element so a pointer to it should
be returned

_slice is one-dimension lower than the array itself

Operations on such an array correspond to those on regular pointers


the following operations are available:

::LongTable_alloc(); - array allocation e.g.:

LongTable_slice *lt=LongTable_alloc();
lt[3]=4;

LongTable_free(table );

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 193


IDL Mapping

any:
http://members.tripod.com/gsraj/corba/chapter/
get_buffer to read data
replace to replace data in the buffer
example:
LongSeq *ls=new LongSeq;
ls->length(25);
(*ls)[13]=445;

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 194


IDL Mapping

any:
this type can encapsulate any other type
can be combined with DII and DSI

some basic data types require special cast functions why?

will work with float, double, enums, object references,


strings etc.

operators <<= and >>= are available for insertion and extraction of data
e.g. (in C++) :
CORBA::Any any;
any <<= (CORBA::Double) 2.7172;

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 195


IDL Mapping
any:
special cast wrappers are available for selected types in C++:
octet, boolean, char and string

data can be extracted and cast to a certain type (trying the type) may
result in a fault then no data of this type is held in the CORBA::Any
type.

CORBA::Any an;
CORBA::Long lo;
if (TRUE==(a>>=lo)) printf(success)
else printf(fault);

alternatively

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 196


IDL Mapping
any:
CORBA::Any an;
CORBA::Long lo;

alternatively check the type code

if (an.type()->equal(CORBA::_tc_long)) printf(success)
else printf(fault)

2.7172 what type is it? a double or a float?


use casting

special functions for selected types:


CORBA::Any::from_boolean(FALSE/TRUE);
CORBA::Any::to_boolean(bool_var);

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 197


IDL Mapping
any:
CORBA::Any an;
CORBA::String_var str((const char *)fff);

an <<= CORBA::Any::from_string(str,str_length);

if str_length==0 then the string is unbounded

----

const char *str1;


an >>= CORBA::Any::to_string(str1,0);

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 198


IDL Mapping

any:
to/from CORBA::Any operators can be defined by the programmer

also they are needed for structs and arrays already generated for the
previous example find them!

how TypeCode is used find it

the programmer writes operators <<= and >>= for their own e.g.
sequences (CORBA::Any &, Type &) e.g. write the length first and then
the elements

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 199


Dynamic Invocation Interface (DII)

the client chooses method names and prepares arguments at runtime


(not before coding as before):
fetch the IOR (as before)
prepare the request
add proper arguments (remember about casting)
set the return type (remember about casting)
invoke the method
fetch the results method value returns the any type use the
knowledge you have gained before
for complex types e.g. sequences overload the operators with the any
type

invoke() - blocking the client


send_oneway nonblocking
send_deferred nonblocking but can check the results afterwards i.e.:
see an example in mico/test/dii-request

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 200


Dynamic Skeleton Interface (DSI)

Dynamic implementation of a particular method:


the server object decodes the name of the method that has been called
the server implements method invoke()
checks what method has been called (op_name() in the request returns
this information)
creates a list of the arguments for the method invoked
decodes the parameters
performs the actual operation
encodes the return value

uses the any type

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 201


Intercepting requests

Possibility to intercept requests:


both at the client (before it is sent and before it returns)
and the server (before the actual method is invoked and after it has
been invoked)

at the server side it is possible to reject certain requests e.g. based on


the IP of the requester implement methods client_connect,
client_disconnect in the interceptor (inherits from ConnInterceptor)
returns INVOKE_CONTINUE or INVOKE_ABORT

can implement encryption/decryption (at both sides)

see an example at mico/test/pi/dii-request

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 202


MICO Examples

Test the following examples provided by MICO CORBA (C++):


mico/test/pi/dii-request (portable interceptor)
mico/test/pi/oneway-request notice the oneway in *idl
mico/test/dii/*
mico/test/ir/*
mico/demo/generic
mico/demo/interceptor

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 203


CORBA Sources

Literature:
OMG specification
M. Sawerwain CORBA, Programowanie w praktyce

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 204


Java Enterprise Edition (JEE/J2EE)
Overview

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 205


JEE/J2EE Specification Components

Main specification components of J2EE:


J2EE Platform platform specification
J2EE Reference Implementation the implementation
provided by the standard developer Sun Microsystems
J2EE Compatibility Test Suite a set of tests that allow to
verify the given J2EE implementation against the
specification
J2EE Blueprints a set of suggested solutions, tips, design
patterns and distributed application model proposition

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 206


JEE/J2EE Main Idea

JEE/J2EE Tiers:
Client tier Web tier Business tier EIS tier

Client
Application

EJB Database

Client JSP
Applet EJB

Servlet Database
EJB
Client
Browser J2EE
Server

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 207


JEE/J2EE Elements (1) - Components

JEE/J2EE elements:
Components
Executed on the client side:
Web client
Thin client heavy operations like database access,
computations, complex application logic is handled at the
server side
Thin client (a browser) receives pages generated by the
Web-tier components (servlets or JSP pages)
Security, reliability, load balancing handled at the server
side
Applet (a heavier client)
Application client an application that typically requires a fancy
interface (developed using Abstract Window Toolkit AWT or
Swing)
Usually access the logic in the business tier (EJBs)
Can also send requests to JSP pages or servlets
Java Beans can be used to manage data being exchanged
between a client and a server or a server and a database
2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 208
JEE/J2EE Elements (2) - Components

JEE/J2EE elements:
Components
Executed on the server side:
Web-tier (WWW) components (two complementary technologies,
one can substitute the other one but different target uses):
Servlets (should be used for application logic, should not
contain too many HTML lines)
JSP pages (should be used for presentation, should not
contain too much Java code)
Business-tier EJB (Enterprise Java Beans) components
used for application logic
Receives data from the web tier/ the client, processes,
sends to a database
Reads data from a database, processes and sends to the
client
can represent system resources (like a database)
through objects

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 209


JEE/J2EE Elements (3) Communication & Services
JEE/J2EE elements:
Commmunication
Client to application presentation layer
Client is a web browser typically that accesses the application
through HTTP or secure HTTPS protocols
Data is fetched by servlets or JSP pages
Application logic to data resources
Servlets or EJB components refer to data through:
JDBC or JNDI interfaces
Entity EJBs that allow to access data (EJBs are contacted
through RMI)
Services
Application server acts as a service provider for executed
applications
Enables applications to access to external data storage systems EIS
(Enterprise Information System) through drivers

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 210


JEE/J2EE Containers (1)
Containers in JEE/J2EE:
A container is the interface between a component and a low-level
functionality/environment where the component works
Defines the underlying services supported by J2EE:
Security
Transaction management
JNDI services
Depending on the final environment, different settings can be
defined for a component thanks to:
Security model allow to configure an EJB or a Web
component so that only authorized users can access them
Transaction model specify relations among methods so some
sequences are treated as one
Remote connectivity low-level communication between a
client and an EJB (methods on it can be invoked as on one
machine)

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 211


JEE/J2EE Containers (2)
Containers in JEE/J2EE:
Manage:
Database connection pooling
Allows to invoke the J2EE programming interfaces
Data-persistent operations in entity EJBs (can be overridden look
at EJBs)
Lifecycles of:
EJBs
Servlets
Containers in J2EE:
J2EE application server
EJB container
Web component container
Client application container
Applet container

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 212


JEE/J2EE Containers

JEE/J2EE Tiers:
Client tier Web tier Business tier EIS tier

Client
Application Web
Container
Application Container EJB Database

Applet Container JSP


Client EJB
Applet Database
Servlet
EJB
Client
Browser J2EE EJB
Server Container

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 213


JEE/J2EE Security
Security:
Generally the server allows to configure the following:
Users
User groups

Roles associated with particular access levels

Mapping:
Roles to particular resources such as web components (URLs) or
EJBs (particular methods)
Users to the roles

Can be defined in:


descriptors by declarations does not affect the code
configuration is separated from the code
Programatically at the code level

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 214


JEE/J2EE Transactions
Transactions:
Can be managed in several ways:
By the bean in this case the transaction is defined in the code
Methods generally include commit() and rollback()

It is possible to use the JTA API or JDBC API


For JDBC the transaction methods are invoked on a connection

By the container in this case by setting some attributes the


container knows where to start/stop a transaction can be
configured on the method level especially when an EJB invokes
some other methods or the bean level, can be used for message
driven beans:
Available attributes include: Required, Mandatory, Supports,
Never, NotSupported, RequiresNew

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 215


JEE/J2EE Programming Interfaces (1)
Programming JEE/J2EE:
Various implementations:
Includes an application server and allows component deplyment
Must fulfill strict requirements and pass several defined tests
Programming JEE/J2EE = providing components

Programming Interfaces:
Java Data Base Connectivity (JDBC)
Allows access to relational databases
Includes:
JDBC Core API (package java.sql.*)
JDBC Optional Package API (package javax.sql.*)
Allows to access data through DataSource objects that can
represent a database, a file etc.
Application server can open several database connections in
advance to avoid the high costs of opening connections at runtime
Clients can check out open connections really fast then

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 216


JEE/J2EE Programming Interfaces (2)
Programming Interfaces:
Java Naming and Directory Interface
Allows to assign attributes to objects and search for objects using
their attributes
Enables a J2EE application to store and access data regarding any
Java object
Information is stored in contexts that are organized in a tree
Contexts can contain subcontexts
Uniform access to information including existing systems like DNS,
LDAP or NIS
Contexts contain information about:
Data sources
Message queues of Java Messaging Service
Interfaces of EJB components (through java:comp/env/ejb)
Environment variables
Databases through JDBC (through java:comp/env/jdbc)
Internally works like JDBC a proper driver must be loaded prior to
data access
2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 217
JEE/J2EE Programming Interfaces (3)
Programming Interfaces:
Servlet API
Implements the request-response model
Can respond to any type of requests typically used to reply to
HTTP requests
Life cycle (instance, init(), threads, destroy())
Targeted for data processing rather than data presentation
Recommended use:
Intercept a request
Process data
Use JDBC, Use EJBs
Process output data to be presented by JSP pages
Java Server Pages (JSP)
Contain static text (HTML, XML, WML) and JSP dynamic constructs
Allow to create HTML pages dynamically
Targeted for data presentation rather than data processing
JSP pages are translated to Java code at runtime
and then compiled
Data can be shared on different levels (request, session, application)
2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 218
JEE/J2EE Programming Interfaces (4)
Programming Interfaces:
Java Message Service
A communication standard that allows to create, send, receive and
read messages
Reliable
Asynchronous
Loosely-coupled messages are not sent directly to receivers
Point-to-point model sender sends a message to a queue
where it is fetched from by a receiver
A message has only one receiver
A queue can be used by many senders and receivers
Publish-subscribe model sender sends a message to a list
A message can be read by many receivers
Client needs to obtain a connection through QueueConnection or
TopicConnection for the above two models respectively

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 219


JEE/J2EE Programming Interfaces (5)
Programming Interfaces:
Java Transaction API
Provides an interface to demarcate transactions
Auto commit other applications will see updated data only
after read or write operations
If a transaction consists of two or more separate database
accesses that depend on each other:
Use JTA to define where the transaction begins, rolls back
and commits
Java Mail
Allows Java applications to send emails
Consists of two interfaces:
Application level interface used by clients to send emails
Service provider interface

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 220


JEE/J2EE Programming Interfaces (6)
Programming Interfaces:
JavaBeans Activation Framework
Used by Java Mail
Allows to:
Determine the type of a piece of data
Encapsulate data
Determine the operations allowed on the data
Create a JavaBeans component for the operations
Provides conversion of MIME types to Java objects
Maps file extensions to MIME types
Java API for XML processing
Used to generate/read XML data that will be/has been
read/generated by various applications
Generated data can be later presented in a desired way as it
separates content from presentation

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 221


JEE/J2EE Programming Interfaces (7)
Programming Interfaces:
Java API for XML processing
Implements:
DOM model
A tree representation of an XML file is created
Methods allow to retrieve and modify nodes
SAX
A parser uses the callback paradigm when an XML file is
being parsed then appropriate methods (implemented by
the programmer) are called
Connector Architecture
Used by tool vendors to support access to various enterprise
information systems (EISes)
This is done by providing resource adapters:
Allow an application to access the underlying resource
managers and to exchange data
Need for specific resource adapters for different information
systems or databases

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 222


JEE/J2EE Programming Interfaces (8)
Programming Interfaces:
Connector Architecture
The JEE/J2EE application server manages access to EISes
through resource adapters; so-called system-level contracts are
defined:

Java Authentication and Authorization Service


Provides authentication and authorization of a specific user to run
JEE/J2EE components: applications, applets, WWW or EJB
components
JAAS derives from the Pluggable Authentication Module (PAM)
concept and supports user-based authorization to Java

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 223


JEE/J2EE Programming Interfaces (9)
Programming Interfaces:
Enterprise Java Beans (EJBs)
Code with methods and fields that is used for application logic
Three types of beans:
Session beans
Handles a single data exchange with the client the data
is deleted when the communication with the client is done
Needs to use JDBC if wants to access databases
Entities (Java Persistence API) an instance represents a row
in the relational database, the class represents the table
Annotations used to represent relationships between
entities
Persistent fields or properties and relationships are
mapped to the underlying database
Relationships can be one-to-one, one-to-many, many-to-
one, many-to-many
Can be used in web and EJB tiers as well as in JSE
Are registered in the entity manager
Each entity object has a unique key
One
2012 Pawel Czarnul entity can be mapped
http://pczarnul.eti.pg.gda.pl to more than one table
email: pczarnul@eti.pg.gda.pl 224
JEE/J2EE Programming Interfaces (10)

Programming Interfaces:
Enterprise Java Beans (EJBs)
Code with methods and fields that is used for application logic
Three types of beans:
(...)
Entities (Java Persistence API) an instance represents a row
in the relational database, the class represents the table
()

One can search for an entity using the find(<entity


class>,<key>) of the entity manager
The entity manager offers method remove(<entity>)
The entity allows creation of queries:
em.createQuery and em.createNamedQuery to query the
data store for particular entities

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 225


JEE/J2EE Programming Interfaces (11)

Programming Interfaces:
Enterprise Java Beans (EJBs)
Code with methods and fields that is used for application logic
Three types of beans:
(...)

Entity beans in former versions of J2EE represent data through


objects
Represents persistent data from a database (one row of a
table) data is kept is the client terminates
No need for SQL code in the bean if not necessary handled
by the container
If the container-based persistence is overwritten then
database access through JDBC is required
Message-driven beans a session bean that can receive
messages through JMS
Can be used alone or with other beans

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 226


JEE/J2EE Packaging (1)
Packaging:
Components are packed separately
Related files: graphics, HTML, server-side Java classes etc. Are
packed into one module and added to a J2EE application
Descriptors
A descriptor is a separate XML file that contains settings for the
component (e.g. an EJB) to be deployed e.g. security and
transaction settings for an EJB
Can be changed without changing the source code of the
component

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 227


JEE/J2EE Packaging (2)
File formats/extensions:
An J2EE application is delivered in an EAR (Enterprise Archive) File
EAR = a standard JAR file with the .ear extension
An EAR file contains a complete J2EE application and can be run
on any J2EE server
An EAR file is described by an application descriptor
An EAR file consists of
Modules
consist of components
described by a module descriptor
Can be run separately, independent from the application
descriptor
A typical J2EE application consists of:
One or more EJB modules (JAR files): session, entity or
communication EJBs and a descriptor
Resource adapters modules (RAR files Resource Archive)
WWW modules (WAR files): servlets, JSP pages, HTML pages and
a descriptor

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 228


JEE/J2EE Development
Code Development Phase:
Implement the necessary components:
Servlets, JSP pages, EJBs
Pack the components into modules adding appropriate descriptors
Pack the modules into an J2EE application
Create a descriptor consistent with the application modules
Pack the modules and the descriptor into an EAR (J2EE
application) file

Deployment Phase:
Use the deployment tool provided by the vendor to run an J2EE
application
Retrieve the application descriptor
In a loop:
Retrieve a module descriptor (e.g. required security or
transaction measures)
Install a component in a container

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 229


BeesyCluster as Middleware
for Service Integration

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 230


BeesyCluster: Middleware for Distributed Services

a company LAN producing house designs based


on the user requirements

CLIENTS PROVIDERS (AutoCAD etc.)

ssh LANs (MPI,


serwer PVM apps)
serwer
BeesyCluster
HTTPS serwer
BeesyCluster
single PC offering
/Web BeesyCluster
BeesyCluster
a user app as
a service e.g.
Services servers generate
ss
thumbnails
ssh h from
HTTPS
ssh images
ssh galera Clusters
holk
(128 (SCI,Myrinet)
procs)
(256 procs) , MPI, PVM
weather, medical simulations, apps
PDEs etc.
2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 231
BeesyCluster: Middleware for HPC and Business Services

BeesyCluster is a single access point to many


PCs/clusters (WWW or Web Services)
single sign-on,
any PC/cluster with SSH access can be attached to
BeesyCluster in a second for all these features (e.g. ACC
Gdansk clusters galera 128 procs, holk 256 procs) only
SSH access required for PC/cluster, no other configuration
necessary
users can run tasks, any command, manage files on their
accounts through WWW/Web Services
Users can publish (also in UDDI) and rent (single click
operations) services for others to use via WWW or Web
Services (single click application launch) without giving
access to shell
accounting for the use of services of other users

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 232


BeesyCluster Architecture

CLIENTS

Presentation servlets
Layer JSP KC TS Teamwork
Cluster Support
Commander
Web
EJB
AS -Authorization PS - PaymentServices Chat
Business Service AXIS UDDI
RA - Run Service Board
Layer Anywhere Server
J2EE servers
Servers
EIS Database
MySQL DM - Database
Layer xn Manager
Host n

Database

ssh ssh Host1

PROVIDERS
2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 233
File Manager via WWW

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 234


Submit a Task to a Queue via WWW

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 235


Team Work Environment via WWW

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 236


Wiki Subsystem

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 237


Visualization of Cluster and Server Statuses and Metrics

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 238


Run Command or Service on Resource via Web Services

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 239


Run Command via Web Service - Code

ASService service = new ASServiceLocator();


AS port = service.getAS();

// try to login now


String[] auth = port.logIn(new String[]
{"<login>","<password>"}, 1,1); // the latter
arguments should be signer and login agent ids
if (auth==null) System.out.println(Login failed...");

// run ls on the given cluster now


KCWSService service1 = new
KCWSServiceLocator();
KCWS port1 = service1.getKCWS();
System.out.println(port1.runCommand(auth,2,"ls
2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 240
Web Services in a Complex System
BeesyCluster login, authenticator

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 241


Web Service Philosophy in BeesyCluster

User
Layer

Presentation servlets
Layer CC
JSP Cluster
TS Teamwork
Support
Commander

EJB AS -Authorization PS - Payment


Service Chat
Business
RA - Run Service Board
Layer servers
Anywhere
J2EE
Serversss
EIS Database
DM - Database
Layer MySQL Manager Host n

xn Database
Host1

ssh ssh
holk (256 processors)
HPC galera (128 processors)
Layer small Linux clusters

Cluster 1 Cluster n

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 242


Web Service Philosophy in BeesyCluster

Philosophy:
multi-step
authenticator
ticket
why is it needed?
overhead?
multiple servers parts of the request can be routed to various servers

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 243


Web Service Philosophy in BeesyCluster

Client code:
multi-step
import java.io.*;

import as.interfaces.auth.*;
import as.interfaces.sign.*;
public class RunBeesyClusterTaskClient
{
public static void main(String [] args) throws Exception {

int i;
ASService service = new ASServiceLocator();
AS port = service.getAS();

try {
System.out.println("Trying to list login agent descriptions...");
LoginAgentDescription[] lad=port.listLoginAgents();

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 244


Web Service Philosophy in BeesyCluster

Client code:
multi-step
import java.io.*;

for(i=0;i<lad.length;i++)
System.out.println("Login agent "+i+": ID="+lad[i].getID()+"
description="+lad[i].getDescription());

System.out.println("Trying to list signer descriptions...");


SignerDescription[] sd=port.listSigners();

for(i=0;i<sd.length;i++)
System.out.println("Signer "+i+": ID="+sd[i].getID()+"
description="+sd[i].getDescription());
// try to login now
String[] auth = port.logIn(new String[] {"<login>","<password>"},
id0,id1); // the latter arguments should be signer and login agent ids

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 245


Web Service Philosophy in BeesyCluster

Client code:
multi-step

if (auth==null) System.out.println("Nieudane logowanie...");


System.out.println("Pokazuje elementy ("+auth.length+")
autentykatora.");
for(i=0;i<auth.length;i++)
System.out.println("Auth element "+i+": "+auth[i]);

// now try to call a method from the KCWS interface


KCWSService service1 = new KCWSServiceLocator();
KCWS port1 = service1.getKCWS();

System.out.println("Trying to call runCommand for ls");


System.out.println(port1.hello());
System.out.println(port1.runCommand(auth,clusterid,"ls")); // clusterid
denotes a cluster id in the system database

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 246


Web Service Philosophy in BeesyCluster

Client code:
Assuming BeesyCluster's services are available at
beesycluster2.eti.pg.gda.pl
Refer to http://beesycluster2.eti.pg.gda.pl/axis/services/bc/KCWS?wsdl
and http://beesycluster2.eti.pg.gda.pl/axis/services/bc/AS?wsdl
Download descriptions of services available by these URLs save to
KCWS.wsdl and AS.wsdl respectively
AS interface is responsible for logging and authorization to BeesyCluster
KCWS interface allows calling commands on clusters via BeesyCluster

Now generate client stubs using AXIS's WSDL2Java tool:


pczarnul@wolf:~/BC-ws-comm-log/AUI-BC-WS-call$ java
org.apache.axis.wsdl.WSDL2Java AS.wsdl
- Unable to find required classes (javax.activation.DataHandler and
javax.mail.internet.MimeMultipart). Attachment support is disabled.
pczarnul@wolf:~/BC-ws-comm-log/AUI-BC-WS-call$ java
org.apache.axis.wsdl.WSDL2Java KCWS.wsdl
- Unable to find required classes (javax.activation.DataHandler and
javax.mail.internet.MimeMultipart).
2012 Attachment support is247
Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl disabled.
Web Service Philosophy in BeesyCluster

Client code:
Now see generated stubs and compile the client code:

pczarnul@wolf:~/BC-ws-comm-log/AUI-BC-WS-call$ ls
as AS.wsdl KCWS.wsdl pl RunBeesyClusterTaskClient.java
pczarnul@wolf:~/BC-ws-comm-log/AUI-BC-WS-call$ javac
RunBeesyClusterTaskClient.java
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
pczarnul@wolf:~/BC-ws-comm-log/AUI-BC-WS-call$ ls
as AS.wsdl KCWS.wsdl pl RunBeesyClusterTaskClient.class
RunBeesyClusterTaskClient.java

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 248


Web Service Philosophy in BeesyCluster

Client code:
Finally run the client code (if you see invalid credentials or account
expired it is possible that the account in BeesyCluster has simply
expired contact BeesyCluster admin then):

pczarnul@wolf:~/BC-ws-comm-log/AUI-BC-WS-call$ java
RunBeesyClusterTaskClient ls
- Unable to find required classes (javax.activation.DataHandler and
javax.mail.internet.MimeMultipart). Attachment support is disabled.
Trying to list login agent descriptions...
Login agent 0: ID=1 description=identyfikacja za pomoca loginu i hasla
Trying to list signer descriptions...
Signer 0: ID=1 description=podpisywanie kluczem symetrycznym
Login agent + Signer:0.0 s
Pokazuje elementy (2) autentykatora.
Auth element 0: 03%23%21class%3Das.tokens.Authenticator%0A.UID
%3D251%0A.validity_period%3D28800000%0A.timestamp
%3D1258303970834%0A.AS_ID%3D-

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 249


Web Service Philosophy in BeesyCluster

Id%253D1%250A.keyGeneration%253D0%250A.keyIndex
%253D1%250A.MAC%253D07E7FE88EAA5F00EA7CCD0313504F67D
%250A%0A
Auth element 1: Konto bedzie wazne jeszcze przez 364 dni
Login:0.58 s
Trying to call runCommand for ls
0
02.c
102023

()

calling:13.855 s
Total:15.905 s
pczarnul@wolf:~/BC-ws-comm-log/AUI-BC-WS-call$

Code available in directory AUI-BC-WS-call

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 250


BeesyCluster: Access Portal for HPC Facilities

SETTING UP AN ACCOUNT
A new user-provider sets up a BeesyCluster
account by submitting logins/passwords of
accounts available through SSH on the selected
cluster/PC and is able to log in via BeesyCluster
just after the administrator has granted access.
It is only required that the account(s) are
accessible via SSH. No other configuration is
necessary. This gives BeesyCluster an advantage
over the often complex process of deployment of
new sites in grid systems.
The user can set up a BeesyCluster account
without any cluster/PC accounts for use of free
services published by others.

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 251


BeesyCluster: Access Portal for HPC Facilities

PUBLISHING SERVICES:
The user can publish any of the applications

(both run from the shell and to be submitted to


the queue like LSF/PBS) or files from any of the
registered accounts of any of the PCs/clusters
registered to other users/groups (e.g. student
groups) in BeesyCluster.
The user-provider who grants access to a

resource can allow right delegation to other


users. Publishing a service does not give shell
access and thus does not sacrifice security.
Access can be restricted to a specific group of

users like a student group or attendees of a


course.

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 252


BeesyCluster: Access Portal for HPC Facilities

RUNNING SERVICES:
The user has full access to any of the
files/applications on their registered accounts on
the registered PCs/clusters, can:
access/edit files,

run commands via an easy-to-use WWW

interface or Web Services.


For every published service, users see a link in
the WWW interface. By clicking the user-client
invokes the service which runs on the provider's
account as may require a proper environment
(libraries etc.).

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 253


Agent-based architectures
Architecture and implementation

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 254


Agent-based systems
1. Architecture
An environment supporting execution of agents and their life cycle
Agents can communicate between each other
Agents can be spawned and can terminate dynamically

1. Agent
Autonomic, independent from other agents
Live somewhere in the system
Can migrate from node to node
Can learn about the environment and use the knowledge to make
intelligent decisions
Can interact, especially negotiate with other agents

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 255


Agent-based systems
1. Issues

How do agents find other agent locations?


How do agents find out about other agents?

How do agents understand each other? Language, format, meaning of


requests, responses, proposals, refusals

Sending, receiving messages, how to interact with various agents at the


same time?

Reliability, what is some agents fail?

Security, is it possible to hack an agent? Or insert a malicious agent into


the environment?

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 256


Standards for Agent-based Computing
1. FIPA

An IEEE organization that sets agent standards


Approved by IEEE in 2005

Contains 25 specifications
http://www.fipa.org/repository/standardspecs.html

Covers:
agent communication,
agent transport,
agent management,
abstract architecture
applications.

http://www.fipa.org/specifications/index.html

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 257


JADE as implementation of an agent system
1. Architecture
Agents run on nodes of the agent system
Each agent runs within a container

Each platform (an environment for agents) must have at least one main
container (started as the first one in the row) and zero or more regular
containers

Regular containers register with the main container

The main container holds two special kinds of agents:

Directory Facilitator (DF) a name service agent: other agents can


register services with it so that others can find out and locate a
desired agent and communicate with it
Agent Management System (AMS) in charge of the platform
allows to spawn or terminate agents

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 258


JADE as implementation of an agent system
1. Agent
An object that has a life cycle:
is created
Either sleeps or performs so-called behaviours
Terminates
Actually as defined by FIPA can be in one of the following states:
INITIATED, ACTIVE, SUSPENDED, WAITING, DELETED, TRANSIT
Has a unique id - name that also incorporates the name of the platform:
agentname@platformname

Since JADE is Java-based, each agent extends jade.core.Agent and


should implement several methods related to the life cycle:
setup() - kind of init() for servlets invoked once when the agent is
being created generally for initialization,
can read arguments from the command line here using
Agent.getArguments()
takeDown() - like destroy() for servlets invoked when the agent is
being destroyed, one can cause this by calling doDelete() from the
agent code
2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 259
JADE as implementation of an agent system
1. Agent - behaviours
Implements the actual agent functions/code

Each agent can implement one or more behaviours note that these
are being executed one by one, not in parallel by several threads! - may
need some more programming effort

Each behaviour is generally implemented in a class that inherits from


class Behaviour

There are generally two methods to implement:


void action() that implements what the agent does
boolean done() - after each pass of action(), method done() returns
whether action() should be invoked again or if the agent should go to
sleep

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 260


JADE as implementation of an agent system
1. Agent particular behaviours
JADE contains predefined classes for certain often used types of
behaviours:
TickerBehaviour(Agent, int tickInMiliSecods)
Just implement method void onTick() that will be invoked every
tickInMiliSeconds
WakerBehaviour(Agent, int delayInMiliSecods)
Just implement method void handleElapsedTimeout() that will be
invoked after the specified delay
CyclicBehaviour just implement method action() - will be invoked
one by one
OneShotBehaviour - just implement method action() - will be invoked
just once
Implement your own behaviour by inheriting from Behaviour
knowing the communication protocol one can implement particular
steps of interaction in action() and these will be activated one by one
after successive passes implemented in method done() - using e.g.
a counter

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 261


JADE as implementation of an agent system
1. Communication between Agents
Agents communicate in a peer-to-peer manner by sending messages to
each other
Each message can be sent to one or more agents

a message implemented as an ACLMessage


Each message has the following set:
receiver(s)
content e.g. a string
Language regarding syntax
Ontology related to the meaning of concepts used in the message
Message type related to the purpose of the message e.g.
REQUEST, INFORM, PROPOSE; then receiving agents can filter by
this type
The above set using proper setter methods such as setOntology,
setLanguage, setContent etc.

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 262


JADE as implementation of an agent system
1. Communication between Agents

After a meesage has been prepared, it can be sent using


send(ACLMessage) on an agent

To receive a message, method ACLMessage receive() is generally


invoked
It is not blocking and either receives the first message from the
communication queue assigned to the agent or null if there is no
message
If there is no message then the agent should invoke block() so that it
will go to sleep; blocked behaviours will be notified and resumed
when a new message is inserted into the queue
The receiving party can fetch details of the message by calling
appropriate getter methods such as message.getContent(), etc.
It is possible to create a template for receiving messages so that
various behaviours receive different templates:
receive(MessageTemplate) set the template before receive

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 263


JADE as implementation of an agent system
1. Other functions JADE offers:

DF Directory Facilitator
Agents can register services with the DF
An agent creates a DFAgentDescription, sets its own name in the
description and then adds a ServiceDescription to the agent
description
Then the agent description is registered with the DF

Other agents create a template of an agent description along with a


service description with some field set and perform a search on a DF

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 264


JADE as implementation of an agent system
1. Compile and run JADE examples

unpack JADE-all*zip and then JADE-bin*zip as well as


JADE*example*zip

configuration:
in ~/.bashrc set:
export
JADECLASSPATH=/home/pczarnul/JADE/jade/lib/http.jar:/home/pczarnul/J
ADE/jade/lib/iiop.jar:/home/pczarnul/JADE/jade/lib/jade.jar:/home/pczarnul/J
ADE/jade/lib/jadeTools.jar

export CLASSPATH=$CLASSPATH:$AXISCLASSPATH:
$JADECLASSPATH

compile the examples - go to a directory and invoke:

pczarnul@wolf:~/JADE/jade/src$ javac examples/bookTrading/Book*java

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 265


JADE as implementation of an agent system
1. Compile and run JADE examples

add the directory to the classpath


export
JADEEXAMPLECLASSPATH=/home/pczarnul/JADE/jade/src/exampl
es/bookTrading

export CLASSPATH=$CLASSPATH:$AXISCLASSPATH:
$JADECLASSPATH:$JADEEXAMPLECLASSPATH

now run the application starting two agents:

java -cp $CLASSPATH:/home/pczarnul/JADE/jade/src jade.Boot -gui


"buyer:examples.bookTrading.BookBuyerAgent(Ania-z-zielonego-
wzgorza)" seller:examples.bookTrading.BookSellerAgent

use the GUI to add new books, finally a book will be sold to the buyer
agent

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 266


Agent-based systems
1. Other agent-based systems

Aglets, SPRINGS, Voyager

1. Typical applications

Negotiations

Brokerage and simulations in economy


Stock market etc.

Management of services in distributed environments

Gathering data and statistical information from the network

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 267


Volunteer Computing
Architecture and implementation

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 268


Volunteer Computing

volunteer
volunteer

Project
server

volunteer
volunteer
volunteer

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 269


Volunteer Computing
1. Features
Social undertaking users contribute their own effort and actually pay
for the computations they perform
Users identify themselves with projects and want to see they have
obtained some particular results (like finding a big prime)

Client-server architecture
Project server(s) that host projects, status data, particular results,
divide and schedule data to be distributed to the users
Project servers host executables that are distributed to the users, new
versions may be downloaded by clients automatically
Clients download client code that allows to join the project servers,
create a unique login/password, select project(s), set preferences and
policies, download and run executables downloaded from the
server(s)

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 270


Volunteer Computing
1. Issues

Reliability of computations (client nodes may fail, the network may fail)

Security concerns on the client side (can use account-based sandboxing


in Linux, Windows, Mac)

Can the client be trusted? Validation of results from two or more clients
(occasionally there might also be computation errors)

Giving credits to the clients based on CPU time + CPU type etc. from
the clients computing a particular piece of data

Can computations affect day-to-day work? Set proper preferences

Privacy concerns what data is revealed to the server side? (can have
some advantages like tracking stolen computers if they are connected to
the network by the thieves and clients report Ips to the server(s)

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 271


Volunteer Computing
1. Issues

Client performance some executables can use GPUs for some work

Preferences processor, disk, memory usage (maximum values,


maximum %, when can be used)

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 272


Volunteer Computing - BOINC
1. Popular implementation - BOINC

http://boinc.berkeley.edu/

Used for several projects like SETI@home, primegrid etc.


http://boinc.berkeley.edu/projects.php

Clients for various operating systems, various versions

Can use GPUs

The client side uses a client connecting to the server(s) via HTTP, a GUI
(using TCP to connect to the client), a screensaver and executables
managed by the client

User needs to download and run the client, choose (a) project(s),
download executables and data to process, process data, send output
files, report results and repeat the process

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 273


Grid Computing
Controlled resource sharing

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 274


Grid Computing

Grid computing is about controlled resource sharing in distributed


environments:

Various Virtual Organizations want to share equipment, software


allowing both its users to access other resources and software but also
other clients to use the infrastructure and allow to run software
Environment can be trusted in a way (more than volunteer computing or
cloud computing resources and software)
Problem with:
Various authentication systems/mechanisms
Ways to store data
Start and manage computations
Queuing systems such as PBS, LSF, LoadLeveler
Difficult to install new nodes
How to write applications that would use the whole grid? MPICH-G,
PACX-MPI, BC-MPI etc.

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 275


Grid Computing

Grid computing is about controlled resource sharing in distributed


environments:

The hardware and software is:


Distributed geographically
Dynamic (in the sense of availability)
Heterogeneous
Managed by various policies
Security
Resource management

Grid computing is supposed to give:


Transparent access to computing resources
No need to know where computations are performed or where
the data is stored
This should be supported by a grid middleware
2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 276
Grid Computing

Grid computing focuses on:

The end user using the grid must be easy


Making potentially various resources available:
Computers/servers,
Clusters
Large databases
Specialized monitoring and measurement equipment
Development and making available of large world-scale applications
Examples of large-scale problems ...

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 277


Grid Computing

Virtual
Virtual
Organization A
Organization B

Grid middleware

Virtual
Virtual Organization C
Organization D

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 278


Grid Computing Globus Toolkit

High level grid functions of Globus Toolkit (the architecture of the grid is
defined by OGSA Open Grid Services Architecture):

Job submission and management

File management

Replicas

Programming API Globus Toolkit:

Notion of a grid service (web service + resource (WSRF))


Notifications
Security based on certificates
Resource life cycle
2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 279
Cloud Computing

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 280


Cloud Computing

client
client

Cloud
(infrastructure,
CLOUD service,
platform)

client
client
client

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 281


Cloud Computing
1. Assumptions

Processing in a cloud (=infrastructure maintaned by third parties)


instead on a powerful local computer
Eliminates the need for software licences, powerful hardware,
updates etc.
Data is stored on third party servers
Allows to access this data from any place at any time
Privacy considerations
Marketed as more costly efficient than the standard model
The client is not interested in what is needed to perform/deliver the
service he or she needs (like running a particular application), where it
needs to be installed, what software packages it needs etc.
There can be several services in the cloud available to the user
Requires a terminal and a fast connection

Not entirely a new model

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 282


Cloud Computing
1. Features

Resources can be scheduled and used more efficiently (in case of


several remote clients) rather than tailoring them to needs of one entity

De facto outsourcing of services in the Internet

Several popular applications already work in this way:


Mail (servers)
Sharing files, photos
Online photo editing or calc applications etc

Can work in several ways:


Client can buy a certain infrastructure (required configuration
including memory, processors, disks etc.) - infrastructure as a service
(IaaS)

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 283


Cloud Computing
1. Features

Can work in several ways:


SaaS software as a service provider grants access to the software
the client needs conditions like payment for running applications is
agreed between the parties

Providing a whole package of services and applications to the user


according to the agreed conditions - PaaS

Can provide better reliability than the standard processing (unless one
installs RAID, several computers etc. which is costly however)

Some claim that users can be forced to work with the cloud if they start
and that can allow driving costs too high

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 284


Cloud Computing
1. Marketed implementations

Google apps, Gmail, Google App Engine allows to create web


applications and run them on the provider's servers

Social portals, file sharing portals

Amazon Elastic Computing Cloud EC2 renting hardware tailored to


the user's needs

Microsoft Windows Azure Platform


Windows Azure Windows environment fo running applications in a
cloud
SQL Azure - database
.NET Services

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 285


Cloud Computing
1. Main issues and concerns in regard to using clouds

So-called vendor lock-in


Using SaaS/IaaS/PaaS from just one provider can lead to locking you
into one solution/API/platform with the need for your adjustments
and following changing SLAs in the future

Data security and privacy


No control over the data that is stored on the cloud
One solution would be to encrypt the data with a key only known to
the client

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 286


Sky Computing

2012 Pawel Czarnul http://pczarnul.eti.pg.gda.pl email: pczarnul@eti.pg.gda.pl 287