Introduction : Applications r - PowerPoint PPT Presentation

About This Presentation
Title:

Introduction : Applications r

Description:

Introduction : Applications r parties par objets Mireille Blay-Fornarino blay_at_essi.fr http://www.polytech.unice.fr/~blay/ENSEIGNEMENT/AppRep/ http://www.polytech ... – PowerPoint PPT presentation

Number of Views:195
Avg rating:3.0/5.0
Slides: 70
Provided by: UNS66
Category:

less

Transcript and Presenter's Notes

Title: Introduction : Applications r


1
Introduction Applications réparties par objets
  • Mireille Blay-Fornarino
  • blay_at_essi.fr
  • http//www.polytech.unice.fr/blay/ENSEIGNEMENT/Ap
    pRep/
  • http//www.polytech.unice.fr/pinna/Sar/AppRep/

Voir les cours qui ont servi de référence dans la
bibliographie
2
Objectifs
  • Sensibilisation au besoin dintégration des
    applications logicielles réparties en contexte
    industriel
  • Conception dArchitectures logicielles
  • Acquisition de connaissances sur les modèles
    existants pour les applications réparties
  • RMI, CORBA, JNDI, JMS,
  • Puis dans le domaine de linternet
  • SOAP Services web, Ajax,
  • Bases de lapproche Intergiciel
  • Principes directeurs, organisation, usage
  • Fonctionnement interne ( au coeur de )

3
Entreprise virtuelle illustration
Assemblage de ressources de Stockage, Calculs,
réseaux
gt B2B
Mireille Blay-Fornarino
4
Pourquoi utiliser des applications réparties ?
5
Les 8 erreurs conceptuelles
  1. Le réseau est fiable.
  2. La latence est nulle.
  3. La bande passante du réseau est infinie.
  4. Le réseau est sécurisé.
  5. La topologie de lapplication est  éternelle 
  6. Il y a un seul administrateur du réseau
  7. Le coût du transport est nul.
  8. Le réseau est homogène.

Annick Fron
6
Propriétés à prendre en compte
  • Hétérogénéité
  • Hardware
  • Langages
  • Ressources
  • Contexte dusage
  • Désignation/localisation
  • Migration
  • Mobilité
  • Ubiquité
  • Evolution
  • Distribution
  • Equilibrage de charge
  • Parallélisation
  • Décentralisation
  • Couplage
  • Prise de décision
  • Contrôle de laccès concurrent
  • Serveurs parallèles
  • Données réparties synchronisation de l'accès aux
    ressources, Gestion des transactions

Mireille Blay-Fornarino
7
Propriétés à prendre en compte
  • Sécurité
  • authentification (certificats)
  • sécurisation des communications (cryptage)
  • contrôle daccès (autorisation)
  • Dimensionnement
  • croissance du nombre de clients
  •  duplication des serveurs ,  gestion de
    caches 
  • gigantesque quantité de données
  • Grain des informations plans de vol journalier
    ou pistes radar à la seconde ?
  • Tolérance aux fautes
  • site en panne ou inaccessible
  • redondance des serveurs 
  •  fonctionnement en mode dégradé 

Mireille Blay-Fornarino
8
Bus logiciel ?
  • Principes de base de larchitecture des
    intergiciels
  • Via RMI et CORBA

9
1. Au début était la socket
  • Service 1 Hello world
  • Une méthode hello avec un paramètre de type
    chaîne et retourne une chaîne hello,
    paramètre

Daprès Raphael.Marvie_at_lifl.fr et Sacha
Krakowiak Et (cf. références en bas des pages)
10
Principe
  • Deux programmes écrits en deux classes Java
  • Une pour le serveur Server.java
  • Une pour le client Client.java
  • Dans chaque classe est implémenté
  • Le code fonctionnel manipulation des chaînes
  • Le code technique construction / analyse des
    messages réseau

11
Architecture version  socket 
Client
Serveur
Réseau
12
Modélisation des Interactions
13
Côté serveur
  • Initialisation du réseau
  • Instanciation dune socket serveur
  • Gestion des requêtes
  • Attente de connexion (accept)
  • Initialisation des flux dentrée et de sortie
  • Evaluation des requêtes
  • Lecture de la requête sur le flux dentrée
  • Création de la chaîne à retourner
  • Ecriture de la réponse sur le flux de sortie

14
Code serveur (i)
  • package step1
  • import java.io.
  • import java.net.
  • public class Server
  • private ServerSocket asock
  • public Server () throws Exception
  • this.asock new ServerSocket (12345)
  • public static void main (String args)
  • Server s new Server ()
  • s.run ()

15
Code serveur (ii)
  • public void run () throws Exception
  • while (true)
  • Socket sock this.asock.accept ()
  • BufferedReader in new BufferedReader
  • (new InputStreamReader(sock.getInputStream
    ()))
  • DataOutputStream out
  • new DataOutputStream (sock.getOutputStream
    ())
  • String msg in.readLine ()
  • String res "Hello, " msg "\n" //
    fonctionnel
  • out.writeBytes (res)

16
Côté client
  • Initialisation du réseau
  • Instanciation dune socket de communication
    (connexion implicite)
  • Gestion de léchange réseau
  • Initialisation des flux dentrée et de sortie
  • Demande de service
  • Ecriture de la requête sur le flux de sortie
  • Lecture de la réponse sur le flux entrée
  • Affichage de la chaîne retournée
  • Fermeture de la connexion

17
Code client (i)
  • package step1
  • import java.io.
  • import java.net.
  • public class Client
  • private Socket sock
  • public Client () throws Exception
  • this.sock new Socket ("localhost", 12345)
  • public static void main (String args) throws
    Exception
  • Client c new Client ()
  • c.run (args0)

18
Code client (ii)
  • public void run (String msg) throws Exception
  • BufferedReader in new BufferedReader
  • (new InputStreamReader(this.sock.getInputStream
    ()))
  • DataOutputStream out
  • new DataOutputStream (this.sock.getOutputStream
    ())
  • out.writeBytes (msg "\n")
  • String res in.readLine ()
  • System.out.println ("Server replied " res)
  • this.sock.close()

19
Bénéfices et limitations
  • Bénéfices
  • Invocation dun service distant (hello world)
  • Permet de réaliser des applications client /
    serveur
  • Parmi les limitations
  • Une seule connexion cliente à la fois
  • Un seul service ciblé
  • Beaucoup de code très technique / peu de code
    métier (40 lignes de code technique pour une
    ligne de code métier)
  • Un beau plat de spaghettis, difficilement
    évolutif

20
et il y eut lesApplications à base dobjets
répartis
  • Comparaison RMI et CORBA
  • Applications Réparties
  • AM Dery M. Blay-Fornarino
  • Merci à Rémi Vankeisbelck, Michel Riveill, Annick
    Fron, etc

21
Objectifs des objets répartis RAPPELS
  • 1)  utiliser  un objet distant (OD), sans
    savoir où il se trouve
  • ObjetDistant ServiceDeNoms.recherche("monObjet")
  • 2) invoquer des méthodes comme en local
  • objetDistant.nomMethode(Parametres)
  • 3)  passer  un OD en paramètre dappel à une
    méthode
  • resultat objetLocal.nomMethode(objetDistant)
  • resultat objetDistant.nomMethode(autreObjetDista
    nt)
  • 4) récupérer le  résultat  dun appel distant
    sous forme dun nouvel objet qui aurait été créé
    sur la machine distante
  • ObjetDistant1 ObjetDistant2.methode()

22
Des technologies
  • RMI (Remote Method Invocation)
  • Système dobjets distribués performant destiné au
    développement dapplications distribuées
    entièrement en Java
  • CORBA (Common Object Request Broker Architecture)
  • Plate-forme client/serveur orientée objets qui
    permet de faire communiquer des applications
    écrites dans des langages différents (C, Lisp,
    Smalltalk, Python) et sur des plateformes
    (Interopérabilité Langage et Plateformes)

23
2. Bus mono-langage RMIRemote Method Invocation
  • Oui oui vous savez déjà.
  • Mais un petit rappel !
  • Remote/serialisable

24
Principe
  • Deux programmes écrits en deux classes Java
  • Une pour le serveur Server.java
  • Une pour le client Client.java
  • Mais cette fois-ci
  • Des objets  Hello 
  • Un contrat

25
Architecture version  RMI 
StubProxy/Talon Squelette Proxy/Talon
Contrat/ Interface
Serveur
Service Servant
Service Servant
Client
Squelette
Stub
Squelette
RMI System
Réseau
http//java.sun.com/j2se/1.5.0/docs/guide/rmi/reln
otes.html
26
Architecture RMI
Java Remote Method Protocol (JRMP)
Client Stub Remote reference layer
Serveur Skeleton Remote reference layer
TCP/IP, Unicast
Pinna -2007
27
Contrat Interface Java
  • import java.rmi.Remote
  • public interface HelloService extends Remote
  • public String hello (String msg) throws
    Exception
  • public HelloService getClone(String
    InitialMessage) throws Exception

MBF -2007
28
Côté Serveur Implémentations Objets Remote
  • public class HelloServiceRemote extends
    UnicastRemoteObject implements HelloService
  • int counter 0
  • String initialMessage ""
  • private HelloServiceRemote(int count, String
    message) throws RemoteException initialMessage
    message
  • counter count
  • public String hello(String msg) throws
    Exception
  • counter
  • return initialMessage "Hello " msg " tu
    es le " counter
  • public HelloService getClone(String
    initialMessage) throws Exception
  • return new HelloServiceRemote(this.counter,initi
    alMessage)

MBF -2007
29
Côté Serveur Implémentations Objets
Sérialisable
  • import java.io.Serializable
  • public class HelloServiceSerializable
  • implements HelloService, Serializable
  • int counter 0
  • private String initialMessage ""
  • private HelloServiceSerializable(int count,
    String message) throws RemoteException
  • protected HelloServiceSerializable() throws
    RemoteException
  • public String hello(String msg) throws Exception
  • public HelloService getClone(String
    initialMessage) throws Exception

MBF -2007
30
Code du serveur
  • public class HelloServer
  • public static void main(String args) throws
    RemoteException, MalformedURLException
  • HelloService serializedObject new
    HelloServiceSerializable()
  • HelloService remoteObject new
    HelloServiceRemote()
  • Naming.rebind("aSerializedHello",
    serializedObject)
  • Naming.rebind("aremoteHello", remoteObject)
  • System.out.println("Hellos bound in registry")

Démarrage du serveur On lance le rmiregistry On
lance le serveur
31
Côté client
  • public class HelloClient
  • public static void main(String args)
  • HelloService objLocal null
  • HelloService objRemote null
  • try
  • objLocal (HelloService)
    Naming.lookup("aSerializedHello")
  • System.out.println(objLocal.hello("Premier
    "))
  • System.out.println(objLocal.hello("deuxieme
    "))
  • objLocal (HelloService)
    Naming.lookup("aSerializedHello")
  • System.out.println(objLocal.hello("troisieme
    "))

MBF -2007
32
Côté client
  • public class HelloClient
  • public static void main(String args)
  • HelloService objLocal null
  • HelloService objRemote null
  • try
  • objRemote (HelloService)
    Naming.lookup("aremoteHello")
  • System.out.println(objRemote.hello("Premier
    "))
  • System.out.println(objRemote.hello("deuxieme
    "))
  • objRemote (HelloService)
    Naming.lookup("aremoteHello")
  • System.out.println(objRemote.hello("troisieme
    "))

33
Côté client
  • Suite du précédent
  • HelloService copieObjRemote
    objRemote.getClone("Remote copy ")
  • System.out.println(
  • copieObjRemote.hello("Premiere copie"))
  • System.out.println(objRemote.hello("l'origina
    l"))

MBF -2007
34
Bénéfices et limitations
  • Bénéfices
  • Invocation de plusieurs services distants
  • Quasiment pas de code technique
  • Création à distance des objets accessibles
  • Limitations
  • Un seul langage
  • Pas de persistance des références
  • Gestion des Pool dobjets
  • Pas dAssemblage dynamique

35
3. "Bus" multi-langages CORBACommon Object
Request Broker Architecture
  • Juste un premier exemple
  • Introduction à CORBA par comparaison

36
Spécificité Corba gt ORB
I.5. OMA ORB
  • la localisation dobjet
  • la désignation des objets
  • lempaquetage des paramètres (marshalling)
  • le dépaquetage des paramètres (unmarshalling)
  • linvocation des méthodes
  • De plus, il fournit des caractéristiques telles
    que
  • la gestion des exceptions
  • l activation automatique et transparente des
    objets
  • la liaison avec  tous  les langages de
    programmation
  • un système auto-descriptif
  • l interopérabilité entre les bus

37
Architecture version  CORBA
Contrat/ Interface IDL
StubProxy/Talon Squelette Proxy/Talon
Serveur
Service Servant
Nommage Servant
Service Servant
Client
Squelette
Stub
Squelette
Squelette
CORBA System
POA
orb
Réseau
http//java.sun.com/j2se/1.5.0/docs/guide/rmi/reln
otes.html
38
CORBA par comparaison
GIOP/IIOP
Client Stub Object request broker
Serveur Skeleton Object request broker
Interface IDL
TCP/IP, Unicast
39
Points communs et interopérabilité
  • Utilisent les sockets
  • Des Protocoles
  • Un propriétaire JRMP (Remote Method Protocol)
  • Un protocole normalisé par lOMG GIOP/IIOP
  • Il existe des implémentations RMI basées sur le
    protocole RMI-IIOP

40
Modèle de référence OMA
CORBA
Bus dobjets répartis (O.R.B.)
41
Rappel processus RMI
Interface HelloWorld
Interface HelloWorld
Code du client
Classe dimplémentation HelloWorldImpl
Code du serveur
Utilisation du registry
42
Étapes de mise en œuvre Corba
Spécification interface IDL
Compilation interface IDL
Implantation des objets Corba
Implantation du serveur
Implantation du client
Enregistrement du serveur
Côté client
Utilisation du service Nommage
Côté serveur
43
Contrat IDL CORBA
interface HelloService string hello (in
string msg) HelloService getClone(in string
InitialMessage)
44
Corba Interface décrite avec IDLDes
projections multi-langages
Client dobjets
Fournisseur d objets
Stub IDL
Bus CORBA
Squelette IDL
Objets Corba
45
Compilation interface IDL vers Java
Hello.idl
Généré
À implémenter
jidl
HelloServiceOperations.java
HelloService.java
HelloService_Impl.java
HelloServiceHelper.java
HelloServiceHolder.java
46
Côté Serveur Implémentation
  • public class HelloServiceImpl extends
    HelloServicePOA
  • private org.omg.CORBA.ORB orb_
  • int counter 0
  • String initialMessage ""
  • public HelloServiceImpl(org.omg.CORBA.ORB orb)
  • orb_orb
  • public HelloServiceImpl(org.omg.CORBA.ORB orb,
    int count, String message)
  • this(orb) initialMessage message counter
    count
  • public String hello(String msg)
  • counter return initialMessage "Hello "
    msg " tu es le " counter
  • public HelloService getClone(String
    InitialMessage)
  • return (new HelloServiceImpl(orb_,thi
    s.counter,initialMessage))._this(orb_)

47
Code serveur
  • public class Server
  • static int run(org.omg.CORBA.ORB orb,
    String args) throws org.omg.CORBA.UserException
  • org.omg.PortableServer.POA rootPOA
  • org.omg.PortableServer.POAHelper.narro
    w(
  • orb.resolve_initial_references("RootPOA"))
  • org.omg.PortableServer.POAManager manager
    rootPOA.the_POAManager()
  • HelloServiceImpl helloRemoteImp new
    HelloServiceImpl(orb)
  • HelloService helloRemote
    helloRemoteImp._this(orb)
  • try
  • String ref orb.object_to_string(helloRemote
    )
  • String refFile "helloRemote.ref"
  • FileOutputStream file new
    FileOutputStream(refFile)
  • PrintWriter out new PrintWriter(file)
  • out.println(ref)
  • out.flush()
  • file.close()

48
Côté client
  • public class Client
  • static int run(org.omg.CORBA.ORB orb,
    String args) throws org.omg.CORBA.UserExc
    eption
  • String ref null
  • try
  • String refFile "helloRemote.ref"
  • FileInputStream file new
    FileInputStream(refFile)
  • BufferedReader in new BufferedReader(new
    InputStreamReader(file))
  • ref in.readLine()
  • file.close()
  • org.omg.CORBA.Object obj
    orb.string_to_object(ref)
  • HelloService hello HelloServiceHelper.narr
    ow(obj)
  • System.out.println(hello.hello("premier"))
  • System.out.println(hello.hello("deuxieme"))
  • HelloService helloBis hello.getClone("copie
    ")
  • System.out.println(helloBis.hello("copie
    1"))
  • return 0

49
Compilation interface IDL vers C
Hello.idl
Compilateur idl
Client
Hello_Impl
Server
Fichiers Souche
Fichiers Squelette
Compilateur C
Compilateur C
Serveur (.exe)
Client (.exe)
50
Côté Serveur Implémentation(1)

char Hello_implhello(const char msg)
throw(CORBASystemException)
CORBAString_var message CORBAstring_dup("H
ello") message msg count
message count return message._retn ()
51
Côté Serveur Implémentation(2)

Hello_ptr Hello_implgetClone(const char
InitialMessage) throw(CORBASystemException
) Hello_impl helloImpl new
Hello_impl(orb_, poa_) helloImpl-gtcount
this-gtcount Hello_var hello
helloImpl -gt _this() return
hello._retn()
52
Le programme Server

include ltOB/CORBA.hgt include ltHello_impl.hgt inc
lude ltfstreamgt using namespace std int
run(CORBAORB_ptr) int main(int argc, char
argv) int status EXIT_SUCCESS CORBAORB_v
ar orb try orb CORBAORB_init(argc,
argv) status run(orb, argc, argv)

53
Le programme Server

PortableServerPOA_var rootPOA
PortableServerPOA_narrow( CORBAObject_var(o
rb -gt resolve_initial_references("RootPO
A"))) Hello_impl helloImpl new
Hello_impl(orb, rootPOA) Hello_var hello
helloImpl -gt _this() CORBAString_var s orb
-gt object_to_string(hello) const char refFile
"Hello.ref" FILE f fopen(refFile,
"w") fputs(s.in(), f) fclose(f) .
54
Le programme Client
  • include ltOB/CORBA.hgt
  • include ltHello.hgt
  • include ltfstreamgt
  • using namespace std
  • int run(CORBAORB_ptr)
  • int main(int argc, char argv)
  • int status EXIT_SUCCESS
  • CORBAORB_var orb
  • try
  • orb CORBAORB_init(argc, argv)
  • status run(orb)

55
Le programme Client (suite)
  • run(CORBAORB_ptr orb, int / argc /, char
    argv)
  • CORBAObject_var obj orb -gt
    string_to_object("relfile/Hello.ref")
  • Hello_var hello Hello_narrow(obj)
  • CORBAString_var reply CORBAstring_dup("")
  • reply hello -gt say_hello("Premier")
  • stdcout ltlt reply ltlt stdendl
  • Hello_var helloCopyhello -gt
    getClone("copie")
  • reply helloCopy -gt say_hello("copie")
  • stdcout ltlt reply ltlt stdendl

56
Bus logiciel . Communications
  • MOM (Message Oriented Middleware)
  • ou
  • RPC (Remote Procedure Call)

57
Echanges de messages
  • JMS
  • Principe
  • Production de messages
  • Consommation des messages
  • Tous clients du  bus !

58
Appel de procédure à distance
  • RMI,CORBA,.NET remoting, SOAP,
  • Principe
  • Invocation dun service (contexte dappel)
  • Attente bloquante des résultats

59
Bus logiciel en résumé
  • Un bus logiciel repose essentiellement sur deux
    concepts
  • La désignation dun service (les références)
  • La liaison avec un service distant (établir
    une connexion)
  • Un intergiciel (middleware) est un  programme 
    qui permet de faire communiquer des machines
    entre-elles, indépendamment de la nature du
    processeur, du SE, voire du langage.

60
Classes dintergiciels
  • Objets répartis
  • Java RMI, CORBA, DCOM, .NET
  • Composants répartis
  • Java Beans, Enterprise Java Beans, CCM
  • Message-Oriented Middleware (MOM)
  • Message Queues, Publish-Subscribe
  • Intégration dapplications
  • Web Services
  • Coordination
  • Accès aux données, persistance
  • Support dapplications mobiles

61
Architecture générale dun bus logiciel
62
Définitions dinterfaces
  • Partie opérationnelle
  • Interface Definition Language (IDL)
  • Pas de standard indépendant
  • IDL CORBA
  • Java et C définissent leur propre IDL
  • WSDL
  • Partie contractuelle
  • Plusieurs niveaux de contrats
  • Sur la forme spécification de types -gt
    conformité syntaxique
  • Sur le comportement (1 méthode) assertions -gt
    conformité sémantique
  • Sur les interactions entre méthodes
    synchronisation
  • Sur les aspects non fonctionnels (performances,
    etc.) contrats de QoS

C 2003 - Sacha Krakowiak
63
L amorce client (stub)
  • Représentant local de l OD qui implémente ses
    méthodes  exportées 
  • Transmet l invocation distante à la couche
    inférieure Remote Reference Layer / ORB
  • Il réalise le pliage ( marshalling ) des
    arguments des méthodes distantes
  • Dans l autre sens, il réalise le dépliage
    ( demarshalling ) des valeurs de retour

64
L amorce serveur (Skeleton)
  • Réalise le dépliage des arguments reçus par le
    flux de pliage
  • Fait un appel à la méthode de l objet distant
  • Réalise le pliage de la valeur de retour

65
La couche des références distantes
  • Permet l obtention d une référence d objet
    distant à partir de la référence locale au Stub
    un service dannuaire
  • Rmiregistry en RMI
  • Service de nommage Naming en Corba
  • JNDI Interface dannuaire

66
La couche de transport
  • Connecte les 2 espaces d adressage (JVM pour
    Java)
  • Suit les connexions en cours
  • Ecoute et répond aux invocations
  • Construit une table des OD disponibles
  • Réalise l aiguillage des invocations
  • Sécurité ?

67
Diagramme d interaction
Stub
Skeleton
Implementation
invoke
Marshal param Send req.
Unmarshal param Invoke impl.
Return result
Return return or exc. Marshal return or exc. Send
reply
Unmarshal reply Return value or exc
68
Bibliographie
  • École dété sur les Intergiciels et sur la
    Construction dApplications Réparties Patrons
    et Canevas pour lIntergiciel
  • Sacha Krakowiak, ICAR 2003
  • Dis papa, cest quoi un bus logiciel réparti ?
  • Raphael.Marvie_at_lifl.fr
  • LIFL IRCICA
  • Equipe GOAL
  • Décembre 2003

69
Quelques livres...
  • Core Java Volume 2
  • Par Cay S. Horstmann Gary Cornell
  • Editions CampusPress
  • Une référence pour les développeurs Java
  • Bonne section sur RMI, servi de base pour ce
    cours
  • Java Distributed Computing
  • Par Jim Farley
  • Editions O'Reilly
  • Tout sur les applications reparties avec Java
  • Plus technique...
  • Architectures réparties en Java
  • Par Annick Fron (2007)
  • Edition Dunod
  • RMI, CORBA, JMS, Sockets, SOAP, services web
Write a Comment
User Comments (0)
About PowerShow.com