Presentation: Special Repetition Recap on Distributed Principles.
-
Upload
archibald-glenn -
Category
Documents
-
view
217 -
download
0
description
Transcript of Presentation: Special Repetition Recap on Distributed Principles.
Presentation:Special Repetition
Recap on Distributed Principles
Ingeniørhøjskolen i ÅrhusSlide 2 af 17
Outline
• Some troubles with the understanding detected at last weeks exercises– Mapping principles with technology– We will recap on some principles (apx. 10 min.)– You will form groups of 3-4 too discuss the problems at
hand – and make the mappings yourselves (apx. 15 min.)
– We will discuss your conclusions (10-15 min.)• After today – I expect you to understand all
principles – if not -> read and discuss in your study groups!
Ingeniørhøjskolen i ÅrhusSlide 3 af 17
Method Call vs. Object Request
CalledCalled
StubStubStubStub
CallerCaller
CalledCalled
CallerCallerCallerCaller
Transport Layer (e.g. TCP or UDP)Transport Layer (e.g. TCP or UDP)
Ingeniørhøjskolen i ÅrhusSlide 4 af 17
Server Class – The Skeleton (Stub)…public class HelloWorldServerThread extends Thread { protected DatagramSocket socket = null; public HelloWorldServerThread() throws IOException { super(); socket = new DatagramSocket(4450); }
public void run() { while (true) { …
if (request.startsWith("sayHelloWorld")) { new String(packet.getData()); // figure out response String response = null; //Call the HelloWorldOO method & place it in response HelloWorldOO helloWorldOO = new HelloWorldOO(); response = helloWorldOO.sayHelloWorld(); buf = response.getBytes(); … socket.send(packet);…
CalledCalled
StubStub
Ingeniørhøjskolen i ÅrhusSlide 5 af 17
The Client Stub - HelloWorldProxypublic class HelloWorldProxy { public HelloWorldProxy() { } public String sayHelloWorld() {… // get a datagram socket socket = new DatagramSocket(); // send the request byte[] buf = new byte[256]; buf = methodCalled.getBytes(); InetAddress address = InetAddress.getByName("localhost"); DatagramPacket packet = new DatagramPacket(buf, buf.length, address, 4450); socket.send(packet); // get a response packet = new DatagramPacket(buf, buf.length); socket.receive(packet); response = new String(packet.getData()); } catch (Exception e) { e.printStackTrace(); } socket.close(); return response;…
StubStub
CallerCaller
Ingeniørhøjskolen i ÅrhusSlide 6 af 17
Achieving Access Transparency
package chapter1;public class HelloWorldClient { public static void main(String[] args) { System.out.println("Recieved from Server: " + new HelloWorldProxy().sayHelloWorld()); }}
… and thus we have achieved access transparencyusing rather simple constucts (the Proxy pattern).
We could have achieved an even higher degree of transparency by using an interface definition – and thus a contract between Client & Server.
StubStub
CallerCaller
Ingeniørhøjskolen i ÅrhusSlide 7 af 17
Direct Use of Network Protocols implies
• Manual mapping of complex request parameters to byte streams or datagrams – is complex & error prone
• Manual resolution of data heterogeneity– encoding differs on NT & UNIX (what is the format of an Integer?)
• Manual identification of components– References must be established manually (host add., port nr. etc.)
• Manual implementation of component activation• No guarantees for type safety• Manual synchronization of interaction between distributed
components– Developers need to handle TCP/UDP output stream/responses
• No quality of service guarantees– Transactions, Security, Concurrency, Scalability, Reliability
Ingeniørhøjskolen i ÅrhusSlide 8 af 17
= Reason for Using Middleware
• Layered between Application and OS/Network• Makes distribution transparent• Resolves heterogeneity of
– Hardware– Operating Systems– Networks– Programming Languages
• Provides development and run-time environment for distributed systems
• “Gets you of the hook” – concerning the nasty stuff in network programming
Ingeniørhøjskolen i ÅrhusSlide 9 af 17
Flashback to HelloWorld Example
• How to map complex types?– e.g. returning a struct (in C, C++) or an object (in C++,
Java, C#, etc.)?– How would you do it?
Ingeniørhøjskolen i ÅrhusSlide 10 af 17
InterfaceDefinition
Facilitating Type Safety
ServerClient
Request
Reply
Client & Server has a contract
Ingeniørhøjskolen i ÅrhusSlide 11 af 17
Interface Definition Language
• Every object-oriented middleware has an interface definition language (IDL)– In Web services = WSDL, CORBA = IDL, DCOM =
MIDL, Java RMI = Java Interfaces
• Object-oriented middleware provide IDL compilers that create client and server stubs to implement session and presentation layer
Ingeniørhøjskolen i ÅrhusSlide 12 af 17
IDL Example
interface Player : Object { typedef struct _Date { short day; short month; short year; } Date; attribute string name; readonly attribute Date DoB;};interface PlayerStore : Object { exception IDNotFound{}; short save (in Player p); Player load(in short id) raises(IDNotFound); void print(in Player p);};
Ingeniørhøjskolen i ÅrhusSlide 13 af 17
HelloWorld.jws?wsdl
Ingeniørhøjskolen i ÅrhusSlide 14 af 17
InterfaceDefinition
Design
Server StubGeneration
Client StubGeneration
ServerCoding
ClientCoding
ServerRegistration
Development Steps
SOAP: WSDLJava2WSDL
WSDL2JAVA
AXISSOAP
Ingeniørhøjskolen i ÅrhusSlide 15 af 17
Team.idl
included ingeneratesreads
IDL-Compiler
Teamcl.hhTeamcl.cc Teamsv.cc
Teamsv.hh
Stub Generation
Team.wsdlTeam.java
Team.midl
Ingeniørhøjskolen i ÅrhusSlide 16 af 17
C++ Compiler, Linker
Server
Client.cc Server.cc
C++ Compiler, Linker
Client
Team.idl
included ingeneratesreads
IDL-Compiler
Teamcl.hhTeamcl.cc Teamsv.cc
Teamsv.hh
Client and Server Implementation
Ingeniørhøjskolen i ÅrhusSlide 17 af 17
Assignment
• Find the excerises you have made so far– Ultra simple UDP solotion– AXIS Web service
• Discuss the following in student groups of 3-4:1. What technologies are used for building Web serivces?2. When are the individual technologies used in Web services (every
time a request is made or …)?3. How do the specific technologies from above (from 2.) map to the
general principles discuessed earlier on? (IDL, stub, proxy, skeleton, design, client, server,etc)
4. Make a figure (in your own words and style) describing the development steps needed – and map these to the Web service technologies