Presentation is loading. Please wait.

Presentation is loading. Please wait.

Mastère RSD - TC4 2005/20061 Distributed JAVA Aims and Principles The ProActive library Models of behaviours Generation of finite (parameterized) models.

Similar presentations


Presentation on theme: "Mastère RSD - TC4 2005/20061 Distributed JAVA Aims and Principles The ProActive library Models of behaviours Generation of finite (parameterized) models."— Presentation transcript:

1 Mastère RSD - TC4 2005/20061 Distributed JAVA Aims and Principles The ProActive library Models of behaviours Generation of finite (parameterized) models Eric Madelaine INRIA Sophia-Antipolis, Oasis team

2 Mastère RSD - TC4 2005/20062 Distributed JAVA : ProActive http://www-sop.inria.fr/oasis/ProActive Aims: Ease the development of distributed applications, with mobility and security features. Distributed = Network + many machines (Grids, WANs, LANs, P2P, PDAs,...) Library for distributed JAVA active objects –Communication : Asynchronous remote methods calls Non blocking futures (return values) –Control : Explicit programming of object activities Transparent distribution / migration

3 Mastère RSD - TC4 2005/20063 ProActive PDC Most of the time, activities and distribution are not known at the beginning, and change over time Seamless implies reuse, smooth and incremental transitions SequentialMultithreadedDistributed Seamless

4 Mastère RSD - TC4 2005/20064 ProActive : model Active objects : coarse-grained structuring entities (subsystems) Each active object: - possibly owns many passive objects - has exactly one thread. No shared passive objects -- Parameters are passed by deep-copy Asynchronous Communication between active objects Future objects and wait-by-necessity. Full control to serve incoming requests

5 Mastère RSD - TC4 2005/20065 Call between Objects b->foo(x) ba x Copy

6 Mastère RSD - TC4 2005/20066 ProActive : Active object 3 Proxy Body Object Active object Objet Standard object An active object is composed of several objects : The object itself (1) The body: handles synchronization and the service of requests (2) The queue of pending requests (3) 2 1 1

7 Mastère RSD - TC4 2005/20067 An object created with A a = new A (obj, 7); can be turned into an active and remote object: –Instantiation-based: A a = (A)newActive(«A», params, node); The most general case. –Class-based: a static method as a factory To get a non-FIFO behavior : class pA extends A implements RunActive { … } –Object-based: A a = new A (obj, 7);... a = (A)turnActive (a, node); ProActive : Creating active objects

8 Mastère RSD - TC4 2005/20068 ProActive : Reuse and seamless Polymorphism between standard and active objects –Type compatibility for classes (and not only interfaces) –Needed and done for the future objects also –Dynamic mechanism (dynamically achieved if needed) Wait-by-necessity: inter-object synchronization –Systematic, implicit and transparent futures Ease the programming of synchronizations, and the reuse of routines "A" "pA" a p_a foo (A a) { a.g (...); v = a.f (...);... v.bar (...); }

9 Mastère RSD - TC4 2005/20069 ProActive : Reuse and seamless Polymorphism between standard and active objects –Type compatibility for classes (and not only interfaces) –Needed and done for the future objects also –Dynamic mechanism (dynamically achieved if needed) Wait-by-necessity: inter-object synchronization –Systematic, implicit and transparent futures Ease the programming of synchronizations, and the reuse of routines "A" "pA" a p_a foo (A a) { a.g (...); v = a.f (...);... v.bar (...); } O.foo(a) : a.g() and a.f() are « local » O.foo(p_a): a.g() and a.f()are «remote + Async.»

10 Mastère RSD - TC4 2005/200610 ProActive : Intra-object synchronization Explicit control: Library of service routines: –Non-blocking services,... serveOldest (); serveOldest (f); –Blocking services, timed, etc. serveOldestBl (); serveOldestTm (ms); –Waiting primitives waitARequest(); etc. class BoundedBuffer extends FixedBuffer implements Active { void runActivity (Body myBody) { while (...) { if (this.isFull()) myBody.serveOldest("get"); else if (this.isEmpty()) myBody.serveOldest ("put"); else myBody.serveOldest (); // Non-active wait myBody.waitARequest (); }}} Implicit (declarative) control: library classes e.g. : myBody.forbid ("put", "isFull");

11 Mastère RSD - TC4 2005/200611 Example: Dining Philosophers Very classical toy example for distributed system analysis: Both Philosophers and Forks are here implemented as distributed active objects, synchronised by ProActive messages (remote method calls).

12 Mastère RSD - TC4 2005/200612 public class Philosopher implements Active { protected int id; protected int rightForkIndex; protected int State; protected Forks Fork[]; public Philosopher (int id, Forks forks[]) { this.id = id; this.Fork=forks; this.State=0; if (id + 1 ==5) rightForkIndex = 0; else rightForkIndex = id + 1; }../.. Philosopher.java

13 Mastère RSD - TC4 2005/200613 public void runActivity (Body myBody) { while (true) { switch (State) { case 0: think(); break; case 1: getForks(); break; case 2: eat(); break; case 3: putForks(); break; } } public void getForks() { ProActive.waitFor(Fork[rightForkIndex].take()); ProActive.waitFor(Fork[leftForkIndex].take()); State=2; }../.. Philosopher.java (cont.)

14 Mastère RSD - TC4 2005/200614 public class Forks implements Active { protected int id; protected boolean FreeFork; protected int State; public void ProActive. runActivity(Body myBody){ while(true){ switch (State){ case 0: myBody.getService().serveOldestWithoutBlocking("take"); break; case 1:myBody.getService().serveOldestWithoutBlocking("leave"); break; }}}../.. Fork.java

15 Mastère RSD - TC4 2005/200615 // Creates the fork active objects Fks= new Forks[5]; Params = new Object[1];// holds the fork ID for (int n = 0; n < 5; n++) { Params[0] = new Integer(n);// parameters are Objects try { if (url == null) Fks[n] = (Forks) newActive (“Fork”, Params, null); else Fks[n] = (Forks) newActive (“Fork”, Params, NodeFactory.getNode(url)); } catch (Exception e) { e.printStackTrace(); }}../.. Philosophers.java : initialization

16 Mastère RSD - TC4 2005/200616 Distributed JAVA Aims and Principles The ProActive library Models of behaviours Generation of finite (parameterized) models Eric Madelaine INRIA Sophia-Antipolis, Oasis team

17 Mastère RSD - TC4 2005/200617 Principles (1) Objectives: Behavioural model (Labelled Transition Systems), built in a compositional (structural) manner : One LTS per active object. Synchronisation based on ProActive semantics Usable for Model-checking => finite / small Java / ProActive code Abstract ProActive code Network of Parameterized LTSs Network of finite LTSs Data abstraction Behavioural semantics Finite instanciation

18 Mastère RSD - TC4 2005/200618 Principles (2) Define a behavioural model : networks of parameterized LTSs Implement using : abstraction of source code (slicing, data abstraction), analysis of method call graphs. Build parameterized models, then instantiate to obtain a finite structure. Build compositional models, use minimisation by bisimulation. Use equivalence-checker to prove equivalence of a component with its specification, model-checker to prove satisfiability of temporal logic formulas.

19 Mastère RSD - TC4 2005/200619 Communication model Active objects communicate through by Remote Method Invocation (requests, responses). Each active object: has a Request queue (always accepting incoming requests) has a body specifying its behaviour (local state and computation, service of requests, submission of requests) manages the « wait by necessity » of responses (futures)

20 Mastère RSD - TC4 2005/200620 A Remote requests Proxy Java Object A ag = newActive (“A”, […], VirtualNode) V v1 = ag.foo (param); V v2 = ag.bar (param);... v1.bar(); //Wait-By-Necessity V Wait-By-Necessity is a Dataflow Synchronization A Active Object Future Object Request Req. Queue Thread v1 v2 ag WBN!

21 Mastère RSD - TC4 2005/200621 Serv_Q(A) request served (executed and removed) response received Serv_Q(A) Method Calls : informal modelisation method call Local objectRemote object request arriving in the queue !ro.Q_m(f,args) ?Q_m(f,args) !lo.R_m(f,val) ?R_m(f,val) !ro.Q_m(f,args) ?Q_m(f,args) !lo.R_m(f,val) response received ?R_m(f,val)

22 Mastère RSD - TC4 2005/200622 Example (cont.) Philo Fork !ReqTake D !ReqTake G ?RepTake D ?RepTake G !ReqDrop D !ReqDrop G ?ReqTake !RepTake?ReqDrop (1) Build the network topology: Static code analysis for identification of: ProActive API primitives References to remote objects Variables carrying future values public void runActivity (Body myBody) { while (true) { switch (State) { case 0: think(); break; case 1: getForks(); break; case 2: eat(); break; case 3: putForks(); break; } } public void getForks() { ProActive.waitFor(Fork[rightForkIndex].take()); ProActive.waitFor(Fork[leftForkIndex].take()); State=2; }

23 Mastère RSD - TC4 2005/200623 Example (cont.) Philo(n) Fork(m) !F(n+1).Q_Take(f_i) ?R_Take(f_i) !F(n+1).Q_Drop() ?Q_Take(f_i) !P(m).R_Take(f_i) ?Q_Drop() Or better : using parameterized networks and actions: !F(n).Q_Take(f_j) ?R_Take(f_j) !F(n).Q_Drop() Eat(n)

24 Mastère RSD - TC4 2005/200624 public class Philosopher implements Active { protected int id; … public void runActivity (Body myBody) { while (true) { switch (State) { case 0: think(); break; case 1: getForks(); break; case 2: eat(); break; case 3: putForks(); break; } } public void getForks() { ProActive.waitFor(Fork[rightForkIndex].take()); ProActive.waitFor(Fork[leftForkIndex].take()); State=2; }../.. Exercice: Draw the (body) Behaviour of a philosopher, using a parameterized LTS

25 Mastère RSD - TC4 2005/200625 Exercice: Same exercice for the Fork !

26 Mastère RSD - TC4 2005/200626 Server Side : models for the queues General case : – Infinite structure (unbounded queue) – In practice the implementation uses bounded data structures – Approximation : (small) bounded queues – Operations : Add, Remove, Choose (filter on method name and args) Generic Queue model Optimisation : – Most programs filter on method names : partition the queue. – Use specific properties to find a bound to the queue length

27 Mastère RSD - TC4 2005/200627 Example (cont.) Fork: A queue for Take requests Fork: body LTSs public void ProActive. runActivity(Body myBody){ while(true){ switch (State){ case 0: myBody.getService().serveOldestWithoutBlocking("take"); break; case 1: myBody.getService().serveOldestWithoutBlocking(“drop"); break; }}}

28 Mastère RSD - TC4 2005/200628 Active object model: Full structure Body Proxy Queue !A2.Q_m(args) !A2.Q_m(f,args) A1 A2 Serve_m (f,args) !f.R_m(val) Use_m(val)

29 Mastère RSD - TC4 2005/200629 Verification : Properties 1) Deadlock – it is well-known that this system can deadlock. How do the tools express the deadlock property ? – Trace of actions : sequence of (visible) transitions of the global system, from the initial state to the deadlock state. Decomposition of the actions (and states) on the components. – Correction of the philosopher problem: Left as an exercise.

30 Mastère RSD - TC4 2005/200630 Next courses 3) Distributed Components –Fractive : main concepts –Black-box reasoning –Deployment, management, transformations www-sop.inria.fr/oasis/Eric.Madelaine/Teaching


Download ppt "Mastère RSD - TC4 2005/20061 Distributed JAVA Aims and Principles The ProActive library Models of behaviours Generation of finite (parameterized) models."

Similar presentations


Ads by Google