building distributed applications with jolie and qt · based on a formal theoretical framework. it...

25
Introduction JOLIE QtJolie Example Building distributed applications with JOLIE and Qt How to help your applications enter the service-oriented world Fabrizio Montesi, Kévin Ottens Akademy 2009 – July 6th Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 1/25

Upload: others

Post on 13-Jun-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

Building distributed applications withJOLIE and Qt

How to help your applications enter theservice-oriented world

Fabrizio Montesi, Kévin Ottens

Akademy 2009 – July 6th

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 1/25

Page 2: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

Outline

1 Introduction

2 JOLIE

3 QtJolie

4 Example

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 2/25

Page 3: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

Outline

1 Introduction

2 JOLIE

3 QtJolie

4 Example

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 3/25

Page 4: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

A distributed world

Networking technologies have introduced new waysfor users to share, store and access data.

User data is now stored in multiple points, each onepossibly implemented in a different way.

We want to enable users to coordinate theirdistributed data.

How do we make UIs interacting with this distributedworld?

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 4/25

Page 5: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

The objectives

Reuse existing tools and languages in their ownspecific area.

Provide developers with the means for coordinatingdistributed applications easily.

Connect UIs to these technologies.

Pay attention to performance and scalability.

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 5/25

Page 6: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

How we do it

We make use of a service-oriented language (JOLIE)to handle distributed programming.

We build a layer between C++/Qt and JOLIE so theycan interoperate.

Distributed programming and UI programmingremain separated.

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 6/25

Page 7: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

Service-Oriented Computing (SOC)

An emerging paradigm for programming distributedapplications.

Generalizes the concepts of service.

Offers a model for handling the complexity ofservice systems.

Web Services and D-Bus are examples ofservice-oriented technologies.

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 7/25

Page 8: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

What’s a service?

An application exposing functionalities to otherapplications.

It communicates through language-independentprotocols.

Offers a description of itself to the other partners.

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 8/25

Page 9: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

Service composition and orchestration

A service can exploit the functionalities of existingones, by composing them.

Such composite services are called "orchestrators".

An orchestrator coordinates other services from itssingle point of view.

Writing orchestrators can be a difficult task: weneed new appropriate languages and primitives.

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 9/25

Page 10: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

Outline

1 Introduction

2 JOLIE

3 QtJolie

4 Example

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 10/25

Page 11: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

JOLIE

JOLIE is a new service-oriented language.

Lightweight and cross-platform.

Based on a formal theoretical framework.

It offers new constructs and primitives, focusing onthe problems of distributed programming.

It supports pluggable communication protocols andmediums, without requiring you to change yourprograms.

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 11/25

Page 12: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

Some native features in JOLIE

Native primitives for performing communications.

Parallel execution of activities, through the |operator.

External choice: the orchestrator offers multiplepossibilities (like in a switch) and thecommunicating partner chooses one by sending amessage notifying the choice.

Dynamic fault handling, adaptive w.r.t. theexecution flow.

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 12/25

Page 13: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

MetaService

A registry of services, it acts as a service router.

It allows you to access services without knowingtheir location, or even the protocol they speak.

Routes your messages to the registered service,converting the data to the appropriate protocol.

Can load embedded services on demand.

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 13/25

Page 14: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

Outline

1 Introduction

2 JOLIE

3 QtJolie

4 Example

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 14/25

Page 15: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

Qt + JOLIE→ QtJolieExposing C++ applications to the service world since 2009

Goals

Allow Qt applications to drive a JOLIE instance

Make it easy to talk to a (Web) Service

Mid-term, benefit from JOLIE abilities to mix servicesand protocols

Provide a Qt-ish API, similar to QtDBus when itmakes sense

Architecture

Application QtJolie JOLIE

MetaService

Uses SODEP

Uses Instanciates

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 15/25

Page 16: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

API overview

[WARNING]Work in progress.

Convenience missing.

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 16/25

Page 17: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

API overviewMost important facts

We’re using the Jolie namespace

You can create a Client or a ServerThe API allows to manage Messages

Messages have data which is a Value instance

Values form a tree of key/list pairs and can be int,double or byte array

In case of problems Fault instances shall be issued

By inheriting AbstractAdaptor you can processincoming calls

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 17/25

Page 18: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

Making callsLet’s use Jolie::Client

using namespace Jolie;

Client *client = new Client("localhost", 9000);

Message message("/Printer", "printInput");message.setData(Value("Patapatapon!"));

Message reply = client->call(message);

Q_ASSERT(reply.toByteArray()=="success");

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 18/25

Page 19: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

Receiving calls (1/3)Let’s use Jolie::Server and Jolie::AbstractAdaptor

using namespace Jolie;

class CalculatorAdaptor : public AbstractAdaptor{

Q_OBJECTpublic:

CalculatorAdaptor(QObject *parent = 0): AbstractAdaptor(parent) { }

private://==>

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 19/25

Page 20: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

Receiving calls (2/3)Let’s use Jolie::Server and Jolie::AbstractAdaptor

//<==Message relay(Server *server,

const Message &message){

Value data = message.data();qint32 x = data.children("x").first().toInt();qint32 y = data.children("y").first().toInt();

Message reply(message.resourcePath(),message.operationName(),message.id());

reply.setData(Value(x+y));return reply;

}};

[...]Server *server = new Server(8000);CalculatorAdaptor *adaptor = new CalculatorAdaptor(this);server->registerAdaptor("/", adaptor);

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 20/25

Page 21: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

Receiving calls (3/3)Let’s use Jolie::Server and Jolie::AbstractAdaptor

using namespace Jolie;

Server *server = new Server(8000);CalculatorAdaptor *adaptor

= new CalculatorAdaptor(this);

server->registerAdaptor("/", adaptor);

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 21/25

Page 22: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

Managing servicesLet’s use Jolie::MetaService

MetaService management

start()/stop()loadService("Math", "math.ol")unloadService("MathService")listServices()

Redirections

addRedirection("Calculator","socket://localhost:8000",Value("sodep"),Value("soap"));

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 22/25

Page 23: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

Outline

1 Introduction

2 JOLIE

3 QtJolie

4 Example

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 23/25

Page 24: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

Yahoo! Search clientQuick and dirty... but with nice tricks

Quick demo...

Show me the code!

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 24/25

Page 25: Building distributed applications with JOLIE and Qt · Based on a formal theoretical framework. It offers new constructs and primitives, focusing on the problems of distributed programming

Introduction JOLIE QtJolie Example

Questions ?

Fabrizio [email protected]

Kévin [email protected]

Fabrizio Montesi, Kévin Ottens – Building distributed applications with JOLIE and Qt – 25/25