Скачать презентацию Multiple Generic Agents for XMLaw Luiz Fernando Rodrigues Скачать презентацию Multiple Generic Agents for XMLaw Luiz Fernando Rodrigues

e4001a1b02839ea8b1f41fb1b1e62a07.ppt

  • Количество слайдов: 24

Multiple Generic Agents for XMLaw Luiz Fernando Rodrigues Multiple Generic Agents for XMLaw Luiz Fernando Rodrigues

Agenda • XMLaw – Using a XMLaw agent – Developing a XMLaw agent • Agenda • XMLaw – Using a XMLaw agent – Developing a XMLaw agent • Scenario Simulation – Number of Stub agents analysis • Generic Agents – Commands and Requests – Environment Variables – Stream approach • Multiple Generic Agents – Example • Conclusion Laboratório de Engenharia de Software – PUC-Rio

Using a XMLaw Agent Laboratório de Engenharia de Software – PUC-Rio Using a XMLaw Agent Laboratório de Engenharia de Software – PUC-Rio

Developing a XMLaw Agent Laboratório de Engenharia de Software – PUC-Rio Developing a XMLaw Agent Laboratório de Engenharia de Software – PUC-Rio

Simulating Scenarios • Agents – Foo – Bar • Organization – Fubar Organization • Simulating Scenarios • Agents – Foo – Bar • Organization – Fubar Organization • Foo and Bar exchange messages • Stub Agents – Foo. Stub – Bar. Stub • Test Agents – Scenario 1 • Executes Foo with Bar. Stub and verifies the expected behavior – Scenario 2 • Executes Bar with Foo. Stub and verifies the expected behavior Laboratório de Engenharia de Software – PUC-Rio

Scenario 1 - Bar. Stub System Interaction. . . Message add. Law. Reply = Scenario 1 - Bar. Stub System Interaction. . . Message add. Law. Reply = get. Mediator. Facade(). inform. Organization. To. Mediator(law. URL. to. String ()); String org. Exec = add. Law. Reply. get. Content. Value(Message. Content. Constants. KEY_ORGANIZATION_EXECUTION_ID); Message enter. Org. Reply = get. Mediator. Facade(). enter. Organization(org. Exec); Message perform. Role. Reply = get. Mediator. Facade(). perform. Role(org. Exec, "bar"); Message start. Scene. Reply = get. Mediator. Facade(). start. Scene("game", org. Exec); String scene. Exec = start. Scene. Reply. get. Content. Value(Message. Content. Constants. KEY_SCENE_EXECUTION_ID); Message enter. Scene. Reply = get. Mediator. Facade(). enter. In. Scene(scene. Exec, org. Exec, "bar"); Message bar. Stub. Msg = new Message(Message. INFORM); bar. Stub. Msg. set. Content. Value(Message. Content. Constants. KEY_ORGANIZATION_EXECUTION_ID, org. Exec); bar. Stub. Msg. set. Content. Value(Message. Content. Constants. KEY_SCENE_EXECUTION_ID, scene. Exec); bar. Stub. Msg. set. Content. Value("hello", "Hello foo, how bar you? "); bar. Stub. Msg. set. Receiver(foo. Id, "bar"); send(bar. Stub. Msg, "bar"); Message answer = wait. For. Message(); . . . Create, set and send the message Laboratório de Engenharia de Software – PUC-Rio

Number of Stub Agents Analysis • Each agent may need s scenarios to be Number of Stub Agents Analysis • Each agent may need s scenarios to be tested • Each scenario implies in n-1 Stub Agents • In a system with n agents, the number of Stub agents is, in the worst case: Where Sk is the number of scenarios for the agent k • If each agent has only 1 scenario: Laboratório de Engenharia de Software – PUC-Rio

Generic Agents • Is a XMLaw agent • Make stub creation easier • Important Generic Agents • Is a XMLaw agent • Make stub creation easier • Important Features – Commands and Requests – Environment Variables – Stream approach Laboratório de Engenharia de Software – PUC-Rio

Generic Agents - Structural View Laboratório de Engenharia de Software – PUC-Rio Generic Agents - Structural View Laboratório de Engenharia de Software – PUC-Rio

Commands and Requests • Command – Execute an operation on the agent • Request Commands and Requests • Command – Execute an operation on the agent • Request – Inform the command to execute – Inform arguments to the command – Example: • perform. Role 171 bar • Ask the system to perform the role bar in the organization 171 • Extensions – Developer may create domain specific commands Laboratório de Engenharia de Software – PUC-Rio

Environment Variables • Shared variables • Storage of any string value • Storage of Environment Variables • Shared variables • Storage of any string value • Storage of messages – A message is a set of variables • Example: – – – – – the message bar. Msg is represented by the set: bar. Msg. sender. Role bar. Msg. receiver. Role bar. Msg. performative bar. Msg. id bar. Msg. protocol • The content of a variable is identified when the character $ is used before a String • The variable “last” Laboratório de Engenharia de Software – PUC-Rio

The Stream Approach Laboratório de Engenharia de Software – PUC-Rio The Stream Approach Laboratório de Engenharia de Software – PUC-Rio

The Stream Approach • Input Stream – Receives requests • Output Stream – Write The Stream Approach • Input Stream – Receives requests • Output Stream – Write command responses • Control Stream – Assert Command – Automated tests • Several Streams Implementations available – – – Console File Socket Stub Composite Piped • The GA implementation don’t know the Stream type it is using – Flexibility Laboratório de Engenharia de Software – PUC-Rio

GA example 1 - Command Line • • • User inputs commands in the GA example 1 - Command Line • • • User inputs commands in the command line User reads responses in the command line Control Stream is not used Useful for a first contact with open system Hard to repeat . . . Generic. Agent agent = new Generic. Agent("command line agent"); Command. Manager manager = new Command. Manager( System. in, System. out, new Stub. Output. Stream() agent); . . . Laboratório de Engenharia de Software – PUC-Rio

GA example 2– Script File • • • User inputs commands in the script GA example 2– Script File • • • User inputs commands in the script file User reads responses in the output file Control Stream is not used Easy to repeat User must know the commands . . . File. Input. Stream script. Stream = new File. Input. Stream("script. txt"); File. Output. Stream output. Stream = new File. Output. Stream("output. txt"); Generic. Agent agent = new Generic. Agent("script agent"); Command. Manager manager = new Command. Manager( script. Stream, output. Stream, new Stub. Output. Stream() agent); . . . Laboratório de Engenharia de Software – PUC-Rio

GA example 3 – Test Application • Test application uses a piped stream • GA example 3 – Test Application • Test application uses a piped stream • Uses the control stream to assert expected behavior in Script Test. App Command. Manager control Laboratório de Engenharia de Software – PUC-Rio output

GA example 3 - Test Application. . . File. Input. Stream script. Stream = GA example 3 - Test Application. . . File. Input. Stream script. Stream = new File. Input. Stream("script. txt"); Piped. Input. Stream pipe. In. Script = new Piped. Input. Stream(); Piped. Output. Stream pipe. Out. Script = new Piped. Output. Stream(pipe. In. Script); Piped. Input. Stream pipe. In. Ctrl = new Piped. Input. Stream(); Piped. Output. Stream pipe. Out. Ctrl = new Piped. Output. Stream(pipe. In. Ctrl); Test. App app = new Test. App(script. Stream, pipe. Out. Script, pipe. In. Ctrl); File. Output. Stream output. Stream = new File. Output. Stream("output. txt"); Generic. Agent agent = new Generic. Agent("tested agent"); Command. Manager manager = new Command. Manager( pipe. In. Script, output. Stream, pipe. Out. Ctrl, agent); . . . Laboratório de Engenharia de Software – PUC-Rio

Multiple Generic Agents - Mu. GA • Single agent approach – Hard to create Multiple Generic Agents - Mu. GA • Single agent approach – Hard to create scenarios – Hard to execute • Asynchronous execution • Multiple agent approach – Several agents in a single script – Easy to execute • Synchronous execution – Easy to assert behaviors Laboratório de Engenharia de Software – PUC-Rio

Multiple Generic Agents Laboratório de Engenharia de Software – PUC-Rio Multiple Generic Agents Laboratório de Engenharia de Software – PUC-Rio

Script Format agent 1 agent 2 #comments agent 1: #requests for agent 1 agent Script Format agent 1 agent 2 #comments agent 1: #requests for agent 1 agent 2: #requests for agent 2 agent 1: #requests for agent 1 … Laboratório de Engenharia de Software – PUC-Rio

Example – Airport Law • Four agents – – Announcer Customer Seller Bank • Example – Airport Law • Four agents – – Announcer Customer Seller Bank • Four scenes – – Announcement Scene Selection Scene Negotiation Scene Payment Scene Laboratório de Engenharia de Software – PUC-Rio

Example announcer customer seller bank announcer: add. Law http: //www. les. inf. puc-rio. br/xmlaw/leis/airport-law. Example announcer customer seller bank announcer: add. Law http: //www. les. inf. puc-rio. br/xmlaw/leis/airport-law. xml set airport. Org. Id $last. org. Execution. Id enter. Org $airport. Org. Id perform. Role $airport. Org. Id announcer customer: enter. Org $airport. Org. Id perform. Role $airport. Org. Id customer seller: enter. Org $airport. Org. Id perform. Role $airport. Org. Id seller bank: enter. Org $airport. Org. Id perform. Role $airport. Org. Id bank Laboratório de Engenharia de Software – PUC-Rio

Example (cont) ##############ANNOUNCEMENT SCENE############## customer: start. Scene $airport. Org. Id announcement set announcement. Scene. Example (cont) ##############ANNOUNCEMENT SCENE############## customer: start. Scene $airport. Org. Id announcement set announcement. Scene. Id $last. scene. Execution. Id enter. Scene $airport. Org. Id $announcement. Scene. Id customer msg m 1 request set m 1. hello set m 1. org. Execution. Id $airport. Org. Id set m 1. scene. Execution. Id $announcement. Scene. Id set m 1. receiver announcer send $m 1 announcer: receive 5 rm 1 enter. Scene $airport. Org. Id $announcement. Scene. Id announcer msg m 2 inform set m 2. services movies; date; food set m 2. org. Execution. Id $airport. Org. Id set m 2. scene. Execution. Id $announcement. Scene. Id set m 2. receiver customer send $m 2 customer: receive 5 rm 2 assert $rm 2. services movies; date; food Laboratório de Engenharia de Software – PUC-Rio

Conclusions • Instead of: • We have: • If each agent has only 1 Conclusions • Instead of: • We have: • If each agent has only 1 scenario Laboratório de Engenharia de Software – PUC-Rio