Presentation is loading. Please wait.

Presentation is loading. Please wait.

Distributed and Parallel Processing George Wells.

Similar presentations


Presentation on theme: "Distributed and Parallel Processing George Wells."— Presentation transcript:

1 Distributed and Parallel Processing George Wells

2 Java: Remote Method Invocation (RMI) Write Java interface to specify actions to be performed by remote objects – Must extend java.rmi.Remote – Methods must throw java.rmi.RemoteException – Parameters/return values must be Serializable Write class that implements interface Create object – “Export” to obtain stub – Register to make available on network

3 Example: Remote Mandelbrot Service Interface import java.rmi.Remote; import java.rmi.RemoteException; /** This interface specifies the remote object * methods. */ public interface MandelbrotCalculator extends Remote { public byte[][] calculateMandelbrot (int xsize, int ysize, double x1, double x2, double y1, double y2) throws RemoteException; } // interface MandelbrotCalculator

4 Server import java.rmi.registry.Registry; import java.rmi.registry.LocateRegistry; import java.rmi.RemoteException; import java.rmi.server.UnicastRemoteObject; public class MandelbrotServer implements MandelbrotCalculator { public byte[][] calculateMandelbrot (...) {... // As normal } // calculateMandelbrot public static void main (String args[]) {... } // main } // class MandelbrotServer

5 The main Method try { MandelbrotServer ms = new MandelbrotServer(); MandelbrotCalculator stub = (MandelbrotCalculator) UnicastRemoteObject.exportObject(ms, 0); // Bind remote object stub in registry Registry reg = LocateRegistry.getRegistry(); reg.bind("MandelbrotService", stub); System.out.println("Mandelbrot Server ready"); } catch (Exception e)...

6 RMI — Client Side Lookup remote object using registry – Returns stub (implements the interface) Call methods of stub

7 Client... import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.RemoteException; public class MandelbrotClient extends Applet implements Runnable, MouseListener, MouseMotionListener {... // Remote server object MandelbrotCalculator calc;... } // class MandelbrotClient

8 Client: Initialisation public void init() {... try { Registry registry = LocateRegistry.getRegistry(); calc = (MandelbrotCalculator) registry.lookup("MandelbrotService"); } catch (Exception e) {... } } // init

9 Client: Using the Remote Object private void generateImage () { byte[][] image = null; try { image = calc.calculateMandelbrot (xsize, ysize, x1, x2, y1, y2); } catch (RemoteException exc) {... } display(image); done = true; repaint(); } // generateImage

10 Running the Registry The JDK includes the registry program: rmiregistry

11 Practical 3 Use RMI to implement a simple message service Server holds messages for users – Hash table indexed by user name list of messages Client(s) – Deposit message for a user – Retrieve all messages for a user

12 Other Distributed Object Models CORBA – Standard for remote object calls – Supports many programming languages DCOM – Distributed Component Object Model SOAP – Web-oriented – XML over HTTP

13 Object Space Models High level of abstraction Logically shared memory – Sometimes called virtual shared memory

14 Level of Abstraction LowHigh Ease of Use Performance Performance & Ease of Use of Middleware Layers

15 Shared, Associative, Virtual Memory Process A Process B Process C Process D Tuple Space

16 Linda “Coordination Language” for concurrent programming – Host Language (Java, C++, anything) Shared Memory Communication Model – “Tuple Space” – Decoupling of Communicating Processes Temporal decoupling Spatial decoupling Small set of operations: out, rd, in, rdp, inp

17 Linda Primitive Operations out(t) – output tuple t to tuple space in(t) – input a tuple from tuple space which matches the template/antituple t – Removes the matching tuple rd(t) – read a tuple from tuple space which matches the template/antituple t inp(t) and rdp(t) – Like in(t) and rd(t) but do not block

18 Matching A template/antituple is matched using associative matching – Number of fields must match – Types of fields must match – Values of any defined fields must match E.g. in(”element”, i+1, j, ?result) might match (”element”, 3, 4, 5)

19 Linda (continued) Example: out(”point”, 23, 5) in(”point”, ?x, ?y) Tuple Space Associative matching (”point”, 23, 5)

20 Tuple Groups Implementation strategy to improve performance Place similar tuples into groups Tuples within a group must match – Number and type of fields – Value of constant fields

21 Simple Example Boss() { int i; for (i=1; i < 1000; i++} { out(“ping”); in(“pong”); } Worker() { int i; for (i=1; i < 1000; i++} { in(“ping”); out(“pong”); }

22 Adaptive Parallelism: Piranha Based on Linda Parallel computation using a pool of processors Processors can come and go during computation

23

24 Adaptive Parallelism Linda provides anonymous communication between processes Processes can be stopped, moved to another processor and restarted – Other processes are unaffected Linda provides an abstraction that hides the details of the pool of processors

25 Unreliable Nodes May join or withdraw from a computation Are only allowed to run client processes

26 Reliable Nodes May not withdraw from computation Hold the Linda tuple space One reliable node is configured as the master node – Controls the computation

27 Load Monitoring Used to control participation of nodes Based on – Number of runnable processes – Number of users logged on – Number of active users – Console activity

28 Speedup Measurement (Placing 14 Queens)

29 Bioinformatics Application Searching human genome for specific “protein patterns” Implemented using Java on Linux Time on one processor: – 4 hours 48 minutes Time on 50 processors: – 12 minutes 27 seconds

30 Speedup: Bioinformatics Application (1GB Data)

31 eLinda Three new features: – Programmable Matching Engine (PME) – Broadcast output operation ( wr ) – Multimedia support Three implementations: – fully distributed tuple space – centralised tuple space – centralised with local caching of broadcast tuples

32


Download ppt "Distributed and Parallel Processing George Wells."

Similar presentations


Ads by Google