996411a9de955f9f84649efa37e8caa3.ppt
- Количество слайдов: 44
REJO / ROS Raúl ACOSTA BERMEJO
Outline • Motivation – RAMA: architecture, example • REJO: – REJO structure – Execution Model – Reactive Method Implementation • Mobile Agents • ROS – Migration – Agent structure
RAMA Reactive Autonomous Mobile Agent A set of Java classes built by Navid Nikaein Sep/99, DEA RSD These classes are used to build Mobile Agents on top of the Reactive Approach. Agents are executed on a platform that offers some services, for instance group service.
Architecture Graphical Interface Containers RSInterp Méthodes pour: faire la migration faire réagir la machine gestion du groupe Client Agent. Reac_Client Agent. Player Agents Agent. Message Machine réactive Agent. White. Board Agent. Reactive_Server before next Server Agent. Reactive_Server Group Admin. Project. Impl Ring Table qui gère l’Anneau Virtuel Agent. Reactive_Server
Example package rama; import inria. meije. rc. sugarcubes. *; import java. awt. Label; public class White. Board. Agent. Code extends Agent. Primitive { public void start(String home) { try{ Instruction White. Board. Agent= new Cube(new Java. String. Value("White. Board_Agent_" +(counter++)+home), new Java. Object. Value( new White. Board. Agent("White. Board_Agent_"+(counter-1), home)), new Until("kill", new Seq( new Await("Migrate"), new Loop( new Until(new Or. Config( new Pos. Config("Migrate"), new Pos. Config("Return")), new Merge(new Seq( new Await("Return"), _migration. To. Home() ) , new Seq( new Await("Migrate"), _migration. Code() ) ) )) , new Java. Instruction(){ public void execute(Link self){ ((Agent)self. java. Object()). dispose. Message(); }} … ); Agent. Reactive_client. current. Site. machine. add(White. Board. Agent); }catch(Exception e){ System. out. println("Error when sending the agent: "+e); } } } Nom Linked Obj Program Handlers
Summary Characteristics: • Concurrency Drawbacks: • Monolithic Architecture. • Programming (style) à la Sugar. Cubes. • Naming problems • Local broadcast and thus it is necessary to migrate in order to communicate • Interactivity Broadcast & Reactive Instructions Advantages: • Mobility • Ring Routing • Dynamic (agents, platform) but this is also a drawback because of • Multi-platform big rings & only Algorithm. Thanks to Sugur. Cubes et Java • Reactive Agent Model • Services may be implemented as agents. Agent (Cube) = Link + Shell + Freeze
Motivation - 1 We would like to: • Program reactive Systems à la Reactive Scripts but it is not Java, there isn’t platform, . . . • Have agent services: migration, naming, routing, etc. • May add and remove modules from the platform to: • add a synchronizer, Distributed Reactive Machines (DRM). • have the group service. • pick the routing algorithm. • . . .
Motivation - 2 Java Mobile Agents L 5 L 6 L 1’ L 2 L 7 L 3 Reactive Synchronous Approach L 4 L 1 : Agent Reactive Languages in Java REJO, MARS L 1’ : Reactive Languages in Java Sugar. Cubes, Reactive Scripts, Junior L 2 : Imperative Reactive Languages Esterel L 3 : Declarative Reactive Languages Signal, Lustre L 4 : High order Reactive Languages Library in SML [RP 98] L 5 : Agent Languages in Java Aglets, Concordia, Voyager. L 6 : Agent Languages Messengers L 7 : Agent Reactive Languages ROL [GM 99]
REJO REactive Java Object REJO is an extension of Java that creates Reactive Objects, i. e. objects that have data and a mix of Java instructions and reactive instructions. The execution model is that of reactive Synchronous Model which executes the Java instructions in an atomic way. These objects may be considered as Mobiles Agents because they can migrate using a platform, called ROS, that provides the functionalities they need.
REJO structure import ros. kernel. *; import java. awt. *; public class rejo implements { Agent int cont; public void Methodes_1() { body } public { reactive rmain(String[] args) int ini=5; par{ cont=ini; Methodes_1(); until(“Preemption 1” && “Preemption 2”) loop{ Methodes_1(); stop; } || call Methodes_2(); } } public reactive Methodes_2() { body } } REJO = Data + Java Code + Reactive Code
REJO instruction set • ; • stop • atom, expr • par{ b 1 || b 2 } • loop • repeat • if-else • gen, generate, ! • wait, ? • when-else • until-handler current. Values • local previous. Values • control • freezable • call • inline • try-catch • print, println • link • scanner
Translation Examples - 1 react method( param ) { var loc; = > body } Program _method_id _() { obj = new _Local_Vars_Method_(); return Translation(body) ; } class _Local_Vars_Method_() { var loc; param; }
Translation Examples - 2 i 1; i 2; … ; = > Jr. Seq( i 1, Jr. Seq( i 2, Jr. Seq( i. N-1, i. N ) ) ) par = > Jr. Par( { i 1; i 1, Jr. Par( || i 2; i 2, Jr. Par( || … i. N-1, i. N ) ) ) }
Translation Examples - 3 loop { body } = > Jr. Loop ( body ) Assign: i=5; = > Jr. Atom(new Action(){ i= Var Loc ou Glo public void execute(Environment env) Arithm. Exp. , etc. { Invoke: meth(); Instructions; obj. meth(); }} ) atom{ Expressions; Flow Control Structures if, for, while. }
Translation Examples - 4 repeat( Cte ){ body } = > Jr. Repeat( Cte , body ) repeat( Var ){ = > Jr. Repeat (new Var. Integer. Wrapper (loc. Var, n. Atom), body body } ) The same thing for If and When instructions
Translation Examples - 5 wait "eve" + var + met() = > Jr. Await( Jr. Presence(new Var. Identifier. Wrapper(loc. Var, n. Atom)) ) case n. Atom: return "eve" + var + met(); wait "eve" && var = > Jr. Await ( wait var || met() Jr. And( Jr. Presence( … ), Jr. And( … ) ) wait ! "eve " Jr. Or( Jr. Presence( … ), Jr. Or( … ) ) Jr. Not( … ) )
Production rules of reactive instructions Java Grammar Ver 1. 1 Java. CC REJO life cycle REJO parser *. javac file. rejo REJOC parser. class + shell script phase 1: java parser file. java phase 2: javac file. class ROS
Reactive Object Model What is the relation between data and code? Rhum Sugar. Cubes ROM Cube
Execution Model - High level REJO 1 REJO 2 Data Reac. Met. call Data events Java Code atom Java Code add par Reactive Machine react
Execution Model - Low level Par Reactive Machine Par Agent REJO rmain Reac. Met 1 local API_kernel ros; Par Program method() { ~ } until call Par Reac. Met 2 loc. Name() { ~ } call Atom Gen method() { ~ } Par Wait
Reactive Method in REJOC v 0. X Class REJO Vars Glo int y; RM(){ _RM Obj; return Program; Jr. Atom{ f(env) = Obj. x + y } } class _RM { Vars Loc int x; } Jr. Link Obj Hash table: To know the local variables and use a prefix, example Prefix=Obj. var
Reactive Method in REJOC v 1. 1 r 1 Class REJO Vars Glo int y; RM(){ Loc. Vars_RM Obj; return Program; } class _RM { Vars Loc int x; actions(Env e, int i) { switch(i) { case 1: y + Obj. x } } Jr. Link D Obj Jr. Atom(Obj){ Obj. actions(Env=Obj); }
Reactive Method in REJOC v 2. 0 r 1 Class REJO Vars Glo RM(){ Loc. Vars_RM Obj; return Program; } class Loc. Vars_RM implements Wrappers. And. Actions { Vars Loc int x; actions(Env e, int i) { switch(i) { case 1: x + y } } Jr. Par Jr. Atom(Obj, i){ Obj. actions(Env, i); }
REJO summary REJO not only makes easier the reactive programming (avoiding the utilization of parentheses) it allows programmers to: • Mix the reactive model with Java variables to use them in conditions (when, wait, …) or values (if, repeat). REJO hides the utilization of wrappers. • Mix the reactive model with Java instructions Arithmetic expressions & Java method invocations. Atomic execution of Java instructions. • Use Reactive Methods to: Modular programming. Re-use code making invocations to reactive methods. • Use local variables inside of reactive methods. In conclusion, all these elements define a Reactive Object Model that doesn’t exist in Junior. The other models defined in Java are Rhum and Sugar. Cubes.
Agents An agent is a program that is autonomous enough to act independently even when the user or application that launched it is not available to provide guidance and handle errors. A mobile agent is an agent that can move through a heterogeneous network under its own control, migrating from host to host and interacting with other agents and resources on each, typically returning to its home site when its task is done. Advantages • Bandwidth reduction • Latency reduction • Support for disconnected operation (network fails). • Load balancing • Development of applications (personalize server be
Client-Server Paradigm Agent Paradigm X Get info Get X, Y Z Info Y Info X Y Z Z 6 msgs 4 msgs
Client-Server Paradigm get BIG file Compression algo_A Size_X = algo_A(BIG file) Agent Paradigm Compression algo_B get BIG file Size_Y = algo_B(BIG file) Size_X > Size_Y
RMI - 1 Client Program Server Program Interface Implementation Stubs & Skeletons Remote Reference Layer Transport Layer
RMI - 2 5’, 6’ RMI registry Lookup(ads, name) bind(ads, obj) 2 RMI client 3 Reference= stub 7 4 1 RMI server 5 Search in: CLASSPATH or remote codebase RO=Remote Object RO / String bind(ads, obj) 8 6 Code server URL = http file 1. Srv registers RO and registry reads srv codebase 2. Clt demands Refer name 3. Srv returns Refer 4. Clt searches stub code 5. Clt request stub from the srv codebase 6. URL srv returns stub class and any other class needed 7. Clt executes a methode on the RO and RO doesn’t know a parameter(class) 8. RO downloads the class using clt codebase. If it fails then it uses srv codebase Plus firewall
Mobile Agent System Design • Mobility Strong or weak • Routing Address transfer or List of sites with their offered services • Communication Message Passing, RMI (RPC), Publish Subscribe, Broadcast Com. Inter-group or Intra-group, Local Inter-group or Global • Naming Local Name + Machine Name, Domain Name Server, Global Name • Language: compiler or interpreter Portability, robustness, security, performance
Characteristics Mobile Agent Systm Language Tcl/Tk: Java: C/C++: Orient Object: others: TACOMA, Ara, Agent Tcl. Ara, Aglets, Voyager, MARS, Concordia. TACOMA, Ara, Messangers(melange C) Telescript( C++), Obliq. Messangers( postcript). Communication Message-passing: Broadcast: Agent Tcl, Aglets, MARS, Odyssey. RAMA, REJO/ROS. Protocol TCP/IP: RMI: others: TACOMA, Odyssey, MARS. Odyssey, RAMA, REJO/ROS. Aglets(ATP=Agent. Transfer. Protocol) Persistency Concordia Ara Concordia (Tamper) Security Authentification: Mobility Strong: Weak: Ara, Agent. Tcl, Telescript, RAMA, Ajanta, Concordia, REJO/ROS. Tacoma, Aglets, Obliq, Messengers, Voy. Routing Itinerary: Ring: Concordia RAMA
ROS Reactive Operating System ROS is a system built on top of Reactive Model which executes reactive objects, REJOs. ROS architecture is similar to Distributed Operating System (DOS) architecture, micro-kernel. ROS was implemented with Junior and thus it has almost all RAMA advantages.
Architecture Applications Agents Reactive Shell Graphical Interface API Kernel API REJO Table Reactive Operating = ROS System Kernel Engine Daemon Reactive Machine Migration Daemon M i g a t i o n
Agent structure - 1 class REJO implements Agent { public reactive rmain(…) { } Agent. Impl 1. txt API_kernel ros; void set. Ros(API_kernel ros) {…} API_kernel get. Ros() {…} Agent. Impl 2. rejo Data Java Method public reactive shell(…) { } Agent. Data data. Ag; Agent. Data get. Data. Ag() {…} void set. Data. Ag(Agent. Data da) {…} } String loc. Name() {…} String to. String() {…} } public boolean migrate. To(…) { public reactive re. Load() { }
public reactive shell(hand. Susp, hand. Resume) { Object[] obj; local("step") until( loc. Name() + "!kill" ) par { loop until( loc. Name() + "!susp” ) loop{ gen "step"; stop; } handler{ call hand. Susp; stop; wait loc. Name() + "!resume” ; call hand. Resume; } || control("step"){ par { freezable( loc. Name() + "!migra" ) call body(); || loop{ wait loc. Name() + "!migra” , obj; if( migrate. To(obj) ) gen loc. Name() + "!kill” ; else gen loc. Name() + "!reload” ; stop; } || wait loc. Name() + "!reload” ; run re. Load(); } } } handler call hand. Termin(); } public reactive re. Load() { par { set. Migra(false); freezable( loc. Name() + "!migra" ){ call hand. Warm. Up(); || get. Group()+”!kill” call body(); } || stop; wait loc. Name() + "!reload” ; run re. Load(); } } } Agent structure - 2
public boolean migrate. To(Object[] obj) { String dest="", ROSname=""; if( obj. length < 2 ) Traitement des paramètres … Agent structure - 3 Program res = ros. un. Load( loc. Name() + "!migra" ); if( res == null) … set. Body( res ); set. Migra(true); try{ Sending. The = (Migration. Serv) lookup("//"+dest+"/Migration. Serv. At "+ ROSname ); if( Sending. The. Agent(rejo) == 0 ) return false; }catch(Exception e) {…} }
Migration - 1 1. Adding instructions: 3. Freeze and removing instructions atom{send copy} gen event; 4. Send a copy If (pbm) add else … instant i i+1 2. Executing the instructions: Starting the freeze i+2 5. Loading instructions i+3 5. Re-execution 4 instants … instant j
Migration - 2 1. Adding instructions: atom{send copy} 2. gen event; 5. Loading instructions 5. Re-exécution. instant i i+1 i+2 i+3 3. Freeze and removing instructions 4. Sending a copy If (pbm) add else … 3 instants … instant j
Migration - 3 1. gen “migra”, “ads”; gen “migra”, “ROSname”; instant i 5. Loading instructions 4. Re-execution i+1 i+2 2. Freeze and removing instructions 3. Sending a copy If (pbm) run else … 2 instants … instant j
Conclusions REJO is a language that: • Makes easier the reactive programming: syntax without parentheses modularity because of reactive methods • Keeps Junior properties: semantics, cooperative programming, … • Has an object oriented programming style: inheritance, polymorphism • Offers the means to build mobile agents.
Conclusions ROS is a platform that: • Executes Reactive Objects (REJOs). • Allows REJOs to migrate. • Shows that the Reactive Synchronous Model may be used instead of cooperative threads. • Has an modular architecture analogue to that of an DOS: microkernel.
Future activities 1 • Static Balancing? REJO generates a comb tree that is … in REWRITE … STORM • To analyze the code to: Simplify the tree (if or if reactive), … • To introduce Link instruction 3 types of variables … meth. var • Modifications local( eve 1, eve 2 ) = local(eve 1) local(eve 2) • Addings: this ( ou self), generate ads, msg, obj. Class X { int v 1; reactive m() { int v 2; link(obj) { obj. v 3; } } }
Future activities - 2 Events as numbers gen 3; wait 5; wait "str"+*; wait *+var; wait loc. Name()+*; wait *+"!migra"
Questions? Raul. Acosta_Bermejo@sophia. inria. fr http: //www. inria. fr/mimosa/rp/ROS/
996411a9de955f9f84649efa37e8caa3.ppt