Verteilte Systeme (Distributed Systems)
Karl M. Göschka Karl.Goeschka@tuwien.ac.at
http://www.infosys.tuwien.ac.at/teaching/courses/ VerteilteSysteme/
Verteilte Systeme (Distributed Systems) Karl M. Gschka - - PowerPoint PPT Presentation
Verteilte Systeme (Distributed Systems) Karl M. Gschka Karl.Goeschka@tuwien.ac.at http://www.infosys.tuwien.ac.at/teaching/courses/ VerteilteSysteme/ Lecture 3: Communication (Part 2) Remote Procedure Call (contd) Remote Method
http://www.infosys.tuwien.ac.at/teaching/courses/ VerteilteSysteme/
3
client Request Reply Communication Communication module module dispatcher service client stub server stub procedure procedure client process server process procedure program
Stub procedures marshal and unmarshal parameters. Client stub marshals input parameters (and unmarshals return paramter). Server stub unmarshals input parameters and marshals return parameter.
4
5
7
8
9
10
11
(c)
12
14
16
17
18
19
20
a) Example with implicit binding using only global references b) Example with explicit binding using global and local references
Distr_object* obj_ref; //Declare a systemwide object reference
; // Initialize the reference to a distributed object
// Implicitly bind and invoke a method (a) Distr_object* obj_ref; //Declare a systemwide object reference Local_object* obj_ptr; //Declare a pointer to local objects
; //Initialize the reference to a distributed object
//Explicitly bind and obtain a pointer to the local proxy
//Invoke a method on the local proxy (b)
21
22
The organization of an IOR with specific information for IIOP.
23
24
The situation when passing an object by reference or by value.
26
27
// MyService Interface import java.rmi.*; public interface MyService extends java.rmi.Remote { public int mymethod (int param) throws RemoteException; }
28
// MyServiceServer import java.rmi.*; import java.rmi.server.*; public class MyServiceServer extends UnicastRemoteObject implements MyService { public MyServiceServer () throws RemoteException { super(); } public Integer mymethod (int param) throws RemoteException { return (param); } public static void main (String args[]) throws Exception { if (System.getSecurityManager() == null) System.setSecurityManager ( new RMISecurityManager() ); MyServiceServer svr = new MyServiceServer(); //create server instance Naming.bind ("MyService", svr); //register with naming service (bind with registry) System.out.println ("Service bound...."); } }
29
// MyServiceClient import java.rmi.*; import java.rmi.Naming; import java.io.*; public class MyServiceClient { public static void main(String args[]) throws Exception { if (System.getSecurityManager() == null) { System.setSecurityManager (new RMISecurityManager()); } MyService service = (MyService) Naming.lookup ("rmi://my.host.edu/MyService"); //obtain reference System.out.println (service.mymethod(17)); } }
Implicit binding
31
Client Security Manager Stub Server Security Manager Naming 1 2 3 4 5 6 7 8 9
32
34
35
36
37
38
39
40
41
45
46
47
48
Install a handler to be called when a message is put into the specified queue. Notify Check a specified queue for messages, and remove the first. Never block. Poll Block until the specified queue is nonempty, and remove the first message Get Append a message to a specified queue Put
Meaning Primitive
49
50
52
53
54
60
61
62
A general architecture for streaming stored multimedia data over a network.
66
68
69
71
74