1 / 23

Technical Stream Session 6: Mobile Agents and Aglets

CSC 253 Paul Grace. [http://research.lumeta.com/ches/map/]. Technical Stream Session 6: Mobile Agents and Aglets. Distributed Systems. Overview of the Session. Introducing Mobile Agents What are agents and mobile agents? Mobile agents versus client-server When to use mobile agents

Download Presentation

Technical Stream Session 6: Mobile Agents and Aglets

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSC 253 Paul Grace [http://research.lumeta.com/ches/map/] Technical Stream Session 6:Mobile Agents and Aglets Distributed Systems

  2. Overview of the Session • Introducing Mobile Agents • What are agents and mobile agents? • Mobile agents versus client-server • When to use mobile agents • Mobile agent toolkits • A example mobile agent toolkit: Aglets • The Aglet architecture • Mobile agent programming • Sample Aglets

  3. What is an Agent? • An agent is a software program that acts on behalf of a user, or another software program • Typically used to retrieve and process information • Execute persistently (rather than on demand) • The agent decides when to take action • Types of Agent • Autonomous agents • Use AI techniques to modify how they reach their objective • Distributed agents • Executed upon multiple distinct machines • Multi-agent systems • Distributed agents that co-operate to reach a goal • Mobile agents • Agents that relocate

  4. Examples of Stationary Agent Applications • E-mail filtering • Continuously monitor incoming e-mail, decide how to process: is it spam? Important? etc. • Data Mining • Crawl the Web to collect data on a topic • E-Commerce • Book the cheapest holiday • Flights, hotel, hire car etc.

  5. What is a Mobile Agent? • Mobile agents are a distributed computing paradigm • A mobile agent migrates from one machine to another under its own control • Decides which locations to visit and what commands to execute • Interaction with the original source isn't required • Suspend execution at any time and migrate to a new host

  6. Levels of Mobility • Evolution of Mobile Agents • Mobile code = transfer of code • Mobile objects = transfer of code + data • Mobile agent = transfer of code + data + thread + directive • Or … • Weak Mobility • Mobile agent carries code and data. Execution has to start from beginning after transfer • Data state = global state • Strong Mobility • Mobile agent carries code, data and execution state • Data state = global state • Execution state = local variables and threads state See Lectures on Mobile Code in Java

  7. Server Client Network Service Mobile Agent Client Server Mobile Agents versus Client-Server • Remote Procedure Call • One computer invokes operations on another • Continuous exchange of request and response messages • Mobile Agents • Client sends and receives 1 message --> mobile agent • Client is still continuously interacting with the server • However, there is NO continuous network communication Network

  8. The Advantages of Mobile Agents • Reduce bandwidth consumption and network load • Local communication between agent and host • Act autonomously • Well suited to distributed mobile applications • Limited resource devices • Processing can be moved to resource rich devices • Frequent network disconnections • Rather than deal with network exceptions, the agent migrates when a connection is available

  9. When to use mobile agents • Mobile agents are not a substitute for client-server • Or any other paradigm you’ve learned about • Group communication (JGroups), Messaging (JMS), etc. • They are an alternative approach that for certain application types can provide benefits • As a distributed systems engineer you must decide the correct paradigm, based upon … • legacy systems • Security • Mobile environment • etc… • I.e. use the knowledge learned in this course to choose when agents are best Which approach should I use?

  10. An Example Mobile Agent Application • Information foraging • Agents starts on the user’s home machine  Task = find all text written by G.S. Blair • Agent travels to each site hosting a distributed library and interacts with a retrieval agent to get the documents • As the agent travels it merges the results into a single report  task result • To optimise the task, the original agent spawns mobile child agents that retrieve the data in parallel.

  11. Mobile Agent Toolkits • Provide the infrastructure for mobile agents ... • to interact with a local computer system; this is known as a“context” for mobile agents to reside and execute • to move from host to host • to communicate with other agents and hosts through message passing • These toolkits are normally Java-based e.g. • Aglets • Concordia • JADE • OAA • TACOMA (C++) • … and others

  12. Mobile Agent Toolkits: Conceptual Architecture Application Application Agent Execution Environment Agent Execution Environment Agent’s place of execution Messaging Subsystem Messaging Subsystem Handle transport of messages and agents Communication Infrastructure

  13. Java & Mobile Agents • Java is well suited to mobile agents because of the following properties • 1. Platform independence • Allow agents to move in a heterogeneous network • 2. Security • Secure servers against incoming agents • Remember sandboxing and the security manager • 3. Dynamic class loading • Execute an incoming agent • 4. Object serialisation • Remember the Lecture on RMI & Mobile Code • Stub distribution: an example of mobile code • Agents are another example of how to use mobile code

  14. Aglets • Java based mobile agent toolkit developed by IBM • Now available as open source under the IBM public license • The name originates from agent+applet = Aglet • Aglet properties: • Mobile Java object that can visit Aglet enabled hosts • Executes in a Context; there may be many contexts on a node • An Aglet server hosts N contexts • Aglet = Aglet state (variable values) + Aglet code (Java class) • Autonomous • Runs in a separate thread when it arrives at a host • Reactive • Responds to messages that are sent to it. A message is an object exchanged by by aglets • Message passing is synchronous and asynchronous • Is unique • A globally unique identifier is bound to each aglet • Mobility level = weak mobility

  15. Aglet Operations • Creation • Create a new aglet in a context and start its execution • Cloning • Create a copy of an aglet, with a unique ID • Dispatching • Send an aglet to another context, either locally or on a new host • Retraction • Pull an aglet from its current context back to the requesting context • Deactivation/ Activation • Halt and restart the aglet’s execution • Disposal • Halt aglet execution and remove it from context

  16. The Aglet Lifecycle Dispose Context Two Context One Clone Dispatch Aglet Aglet Retract Activate Deactivate Class File Disk Storage

  17. The Aglet Programming Model • Event based programming model • Aglets have listeners which catch events in the lifecycle of the aglet • Clone Listener • About to be cloned, after cloning • Persistence Listener • After activation, or about to be deactivated • Etc.. • MobilityListener – Interface for receiving mobility events • onDispatching(mobilityEvent) • Invoked when aglet is being dispatched • OnReverting(mobilityEvent) • Invoked when the aglet is being retracted • onArrival(mobilityEvent) • Invoked when aglet has arrived at its destination You override these methods with the aglet logic Okay, I’ll say hello! You’ve Arrived!

  18. Aglet Creation and Management • Aglets are created and managed per context • The Context API interface AgletContext • CreateAglet(CodeBase, ClassName, Args); returns a proxy to the created aglet • Others: getAgletProxy, getAgletProxies, etc.. • You manage an aglet by calling methods on the proxy using the Aglet API interface  AgletProxy • This can be done remotely (so a proxy is similar to an RMI stub) • Clone() – Create a copy of this aglet • Dispatch(destination) – Send the aglet to a destination • Dispose() – destroy the aglet • and others, etc…

  19. Writing an Aglet import com.ibm.aglet.*; /** * DisplayAglet * Displays text in the message area on its aglet viewer. */ public class DisplayAglet extends Aglet { public void run() { setText("Hello, world! I am " + getClass().getName() + "."); } } All Aglets inherit the Aglet super class – we’re saying this is an aglet! What happens when the aglet is executed

  20. Simple migration public class HelloAglet extends Aglet { public void atHome(Message msg) { setText("I'm back."); dispose(); } public void onCreation(Object init) { setMessage("Hello World!"); itinerary = new SimpleItinerary(this); home = getAgletContext().getHostingURL().toString(); } public void sayHello(Message msg) { setText(message); try { itinerary.go(home, "atHome"); } catch (Exception ex) {ex.printStackTrace();} } When I arrive home – delete myself When created, setup an Itinerary (where to go) When dispatched, this method is called (see next slide). Makes itself go home

  21. /* Starts the trip of this aglet to the destination */ public synchronized void startTrip(Message msg) { // get the address for trip String destination = (String)msg.getArg(); // Go to the destination and Send "sayHello" message to owner(this) try { itinerary.go(destination, "sayHello"); } catch (Exception ex) { ex.printStackTrace(); } } } Called by the initiator – or could be called from run() Dispatch the agent – note it calls a specific method on arrival

  22. Delving Deeper • Use the toolkit, its available at: • http://aglets.sourceforge.net/ • There is much more to Aglets • Message passing between Aglets • 3 Styles • One way • Request-Response • Asynchronous Messaging • You can create sophisticated migration and meeting patterns for aglets • How and when aglets choose to move • You can synchronise meetings between aglets at particular hosts • … build your own applications to see what is possible

  23. Expected Learning Outcomes At the end of this sixth unit: • You should know what a mobile agent is and be able to describe its characteristics • You should know the benefits of mobile agent programming and be able to compare it against client-server • You should know what types of applications are suited to mobile agents • You should be able to classify the mobility levels of example mobile agent toolkits • You should know what an Aglet is, and how the Aglet toolkit works

More Related