移动 A GENT 系统 ——Aglets. 提纲 Aglets 简介 Aglets 模型 Aglets API Aglets 样例 2.

Slides:



Advertisements
Similar presentations
DISTRIBUTED COMPUTING PARADIGMS
Advertisements

MicroKernel Pattern Presented by Sahibzada Sami ud din Kashif Khurshid.
Software Agents and Aglets
Agents & Mobile Agents.
Comparison Study of Three Mobile Agent Systems Aglets, Grasshopper and Voyager Qunhua Zhao, Hua Wang and Yi Zhang Department of Computer Science and Engineering.
Mobile Agents Mouse House Creative Technologies Mike OBrien.
MPI Message Passing Interface
Remote Procedure Call (RPC)
Java Mobile Agents with Aglets Wolfgang Schreiner
Component Patterns – Architecture and Applications with EJB copyright © 2001, MATHEMA AG Component Patterns Architecture and Applications with EJB JavaForum.
Network Operating Systems Users are aware of multiplicity of machines. Access to resources of various machines is done explicitly by: –Logging into the.
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
GRASSHOPPER-a mobile agent platform mailto:
© Lethbridge/Laganière 2001 Chap. 3: Basing Development on Reusable Technology 1 Let’s get started. Let’s start by selecting an architecture from among.
Communication in Distributed Systems –Part 2
Tcl Agent : A flexible and secure mobile-agent system Paper by Robert S. Gray Dartmouth College Presented by Vipul Sawhney University of Pennsylvania.
16: Distributed Systems1 DISTRIBUTED SYSTEM STRUCTURES NETWORK OPERATING SYSTEMS The users are aware of the physical structure of the network. Each site.
1 Threads Chapter 4 Reading: 4.1,4.4, Process Characteristics l Unit of resource ownership - process is allocated: n a virtual address space to.
Client Server Model and Software Design TCP/IP allows a programmer to establish communication between two application and to pass data back and forth.
C++ fundamentals.
Chapter 51 Threads Chapter 5. 2 Process Characteristics  Concept of Process has two facets.  A Process is: A Unit of resource ownership:  a virtual.
Chapter 2 Architectural Models. Keywords Middleware Interface vs. implementation Client-server models OOP.
MADE Mobile Agents based system for Distance Evaluation Vikram Jamwal KReSIT, IIT Bombay Guide : Prof. Sridhar Iyer.
Intranet, Extranet, Firewall. Intranet and Extranet.
Understanding the CORBA Model. What is CORBA?  The Common Object Request Broker Architecture (CORBA) allows distributed applications to interoperate.
1 Lecture 4: Threads Operating System Fall Contents Overview: Processes & Threads Benefits of Threads Thread State and Operations User Thread.
Chapter 6 Operating System Support. This chapter describes how middleware is supported by the operating system facilities at the nodes of a distributed.
SALSA: Language and Architecture for Widely Distributed Actor Systems. Carlos Varela, Abe Stephens, Department of.
OS provide a user-friendly environment and manage resources of the computer system. Operating systems manage: –Processes –Memory –Storage –I/O subsystem.
Using Mobile Agents for Network Resource Discovery in P2P Network Zhengzheng Wan.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
SAMANVITHA RAMAYANAM 18 TH FEBRUARY 2010 CPE 691 LAYERED APPLICATION.
DCE (distributed computing environment) DCE (distributed computing environment)
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Operating-System Structures System Components Operating System Services.
In the name of Allah The Proxy Pattern Elham moazzen.
Locating Mobile Agents in Distributed Computing Environment.
MOBILE AGENTS What is a software agent ? Definition of an Agent (End-User point of view): An agent is a program that assists people and acts on their behalf.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
Secure Active Network Prototypes Sandra Murphy TIS Labs at Network Associates March 16,1999.
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
RMI remote method invocation. Traditional network programming The client program sends data to the server in some intermediary format and the server has.
Transparent Mobility of Distributed Objects using.NET Cristóbal Costa, Nour Ali, Carlos Millan, Jose A. Carsí 4th International Conference in Central Europe.
Chapter 10 Defining Classes. The Internal Structure of Classes and Objects Object – collection of data and operations, in which the data can be accessed.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Legion - A Grid OS. Object Model Everything is object Core objects - processing resource– host object - stable storage - vault object - definition of.
1 Java Servlets l Servlets : programs that run within the context of a server, analogous to applets that run within the context of a browser. l Used to.
Agent Based Transaction System CS790: Dr. Bruce Land Sanish Mondkar Sandeep Chakravarty.
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
JS (Java Servlets). Internet evolution [1] The internet Internet started of as a static content dispersal and delivery mechanism, where files residing.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Aglets Based on Mobile Agents with Java: The Aglet API by Danny B. Lange and Mitsuru Oshima.
Component Patterns – Architecture and Applications with EJB copyright © 2001, MATHEMA AG Component Patterns Architecture and Applications with EJB Markus.
Institute for Visualization and Perception Research 1 © Copyright 1999 Haim Levkowitz Java-based mobile agents.
Java Mobile Agents with Aglets End of studies report Responsible : M. Logothetis ERASMUS Exchange.
Operating Systems Unit 2: – Process Context switch Interrupt Interprocess communication – Thread Thread models Operating Systems.
EEL 5937 Mobile agents (2) EEL 5937 Multi Agent Systems Lotzi Bölöni.
Securing Web Applications Lesson 4B / Slide 1 of 34 J2EE Web Components Pre-assessment Questions 1. Identify the correct return type returned by the doStartTag()
Topic 4: Distributed Objects Dr. Ayman Srour Faculty of Applied Engineering and Urban Planning University of Palestine.
C HAPTER 5.4 DISTRIBUTED PROCESS IMPLEMENTAION By: Nabina Pradhan 10/09/2013.
Mobile Agents Technology - Programming with Aglet
Lecture 4: RPC Remote Procedure Call Coulouris et al: Chapter 5
Mobile Agents.
Mobile Agents M. L. Liu.
Lecture 4: RPC Remote Procedure Call CDK: Chapter 5
Threads Chapter 4.
Dynamic Exchange of Capabilities Between Mobile Agents
Chapter 4: Threads.
Presentation transcript:

移动 A GENT 系统 ——Aglets

提纲 Aglets 简介 Aglets 模型 Aglets API Aglets 样例 2

A GLETS Aglets IBM Latest version 2.5-alpha Stable version:

A GLETS What are mobile agents? Mobile network agents are programs that can be dispatched from one computer and transported to a remote computer for execution. Arriving at the remote computer, they present their credentials and obtain access to local services and data. The remote computer may also serve as a broker by bringing together agents with similar interests and compatible goals, thus providing a meeting place at which agents can interact. 4

A GLETS What is the Aglets Software Development Kit? The Aglets Software Development Kit is an environment for programming mobile Internet agents in Java. (It is what we used to be called Aglets Workbench.) 5

A GLETS What is an aglet? The aglet represents the next leap forward in the evolution of executable content on the Internet, introducing program code that can be transported along with state information. Aglets are Java objects that can move from one host on the Internet to another. That is, an aglet that executes on one host can suddenly halt execution, dispatch itself to a remote host, and resume execution there. When the aglet moves, it takes along its program code as well as its data. 6

A GLETS Aglet Mobile Agent Platform (Aglets MAP): is the core platform, able to manage mobile agents. Tahiti: is the main server in charge of managing the mobility of agents. It comes with a GUI that helps administrators taking care of running agents. Aglets Software Development Kit (Aglets SDK – ASDK): is a library that provides developers all the facilities required to write mobile agents compliant to the Aglets MAP. 7

AGLETS 迁移机制 通信机制 安全保障 8

M OBILITY Strong Mobility vs. Weak Mobility Example for (int i = 0; i<10; i++){ migrate ( remoteHosts[i] ); } 9

M OBILITY Aglets only support weak mobility! In fact, almost all the Java MAP support only the weak mobility. No support in Java to get enough information about the execution flow. The Thread class itself is not serializable, and so cannot be transmitted over the network. 10

M OBILITY Aglets ensures that an agent will keep its Java state (i.e. the value of its inner variable) among migrations (at least if the Java state is serializable). When the agent is going to be executed on the remote machine, the execution will start from a well defined entry point (a method), and no re- initialization will happen (in order to not override the current agent state). 11

C OMMUNICATION Based on message passing! Agents cannot directly reference other agents, so it is not possible for an agent to handle a “pointer” to another agent. For security reason 12

C OMMUNICATION Proxy Pattern A proxy is an object that masquerades another object (its owner) and that forwarders method calls to its owner. 13

C OMMUNICATION Aglets are hidden by proxies, and other aglets can send messages or perform method calls against the proxy, having the proxy to forward such method calls on the owner agent. Advantages: Aglets are always protected, being invisible and that the system can create and manage a lot of proxies for the same aglet without breaking the agent protection. The dispose of a proxy does not causes the disposing of the agent it is masquerading. In Aglets, agents are created and managed by the MAP, while proxies represents “handles” to other agents, thanks to which agents can communicate each other. 14

SECURITY protection of the host against aglets, protection of other aglets, protection of the aglet from the host, and protection of the underlying network. 15

S ECURITY 16

SECURITY The Aglet security model supports the flexible definition of various security policies and describes how and where a secure system enforces these policies. Security policies are defined in terms of a set of rules by one administrative authority. 17

S ECURITY P OLICIES the conditions under which aglets may access objects; the authentication required of users and other principals, which actions an authenticated entity is allowed to perform, and whether entities can delegate their rights; the communications security required between aglets and between contexts, including trust; and the degree of accountability required for each security relevant activity. 18

A GLET 体系结构 Interagent Communication Manager Agent Application Gateway Agent Manager Reliability Manager Directory Manager Security Manager External Application Generic Mobile Agent Server Network Generic Mobile Agent Server 19

A GLET 模型 What is java aglet? Lightweight agent Java object that can move from one host to another A mobile java agent that supports concepts of autonomous execution and dynamic routing on its itinerary. Has its own thread of control Is event-driven Communicates by message passing “Write once, go anywhere” 20

A GLET M ODEL (1) Basic Elements: Aglet – a mobile Java object Proxy – a representative of an aglet Context – an aglet ’ s workplace Identifier – bound to each aglet 21

R ELATIONSHIP BETWEEN A GLET AND P ROXY Proxy Represents the Aglet A handle for local, remote or deactivated aglet Shields Public Methods for Potential Misuse Can Hide the “ actual ” Location of Aglet Proxy and Aglet on Different Computing Nodes Proxy : Aglet n : 1 22

Interaction Clients Proxy Aglet Interaction Clients Proxy Aglet H1 H2 23

C ONTEXT A context is an uniform execution environment for aglet. a stationary object provides a means for maintaining and managing running aglets One node in a computer network may run multiple servers and each server may host multiple contexts. Contexts are named and can thus be located by the combination of their server's address and their name. 24

C ONTEXT Aglets must be instantiated within a context, and at any time belong to exactly one context. Context can be used for: createAglet retractAglet getAgletProxies / getAgletProxy setProperty/getProperty 25

R ELATIONSHIP BETWEEN H OST, S ERVER P ROCESS (E NGINE ), AND C ONTEXTS Context Host Server Process (Engine) Network 26

C ONTEXT, PROXY, AGLET Context Proxy aglet 27

A GLET M ODEL (2) Basic Elements Aglet : a mobile java object Proxy : a representative of an aglet Context : an aglet ’ s workplace Identifier : bound to each aglet Message : an object exchanged between aglets Future reply : an asynchronous message-sending 28

A GLET M ODEL (2) Message an object exchanged between aglets. It allows for synchronous as well as asynchronous message passing between aglets. Future reply A future reply is used in asynchronous message- sending as a handler to receive a result later asynchronously 29

A GLET : C OMMUNICATION M ODEL Message passing: Allows aglets to create and exchange messages in flexible ways. Key Components: Aglet, AgletProxy, Message, Future reply, Reply set Aglet/ Application Message Reply Message Reply ProxyAglet 30

A GLET M ODEL (2) Context Proxy aglet Proxy aglet Message 31

A GLET : O PERATIONS Six Basic Operations 1. Creation 2. Cloning 3. Dispatching 4. Retraction 5. Activation and Deactivation 6. Disposal 32

A GLET : O PERATIONS Creation Initializes a New Aglet Assigns Aglet an Identifier Cloning Produce an Identical Copy of an Aglet Differences Between Clone and Original Aglet Identifier Place of Execution 33

A GLET : O PERATIONS Dispatching Aglet is Transported (Pushed) From One Context to Another Retraction Concept that Returns an Aglet Back to its Original Context Original Context Pulls Back the Aglet From the Current Context 34

A GLET : O PERATIONS Deactivation and Activation Deactivation Must Occur Before Activation Deactivation Halts the Execution of an Aglet Activation Starts Execution of an Aglet Activation Must Occur to Restore the Aglet Disposal Stops Execution of an Aglet Removes an Aglet From its Current Context 35

B ASIC O PERATIONS Classification of Six Basic Aglet Operations Classified as the Life Cycle of an Aglet Observation of Six Basic Aglet Operations Context Functions Just Like a Place 36

A GENT L IFE -C YCLE M ODEL Aglet Class File Disk Storage Create Deactivate Activate Dispose Clone Context AContext B Retract Dispatch 37

A GENT L IFE -C YCLE M ODEL 38

A GLET E VENT M ODEL Aglet Programming Model Similar to the Java Event Model Event Based Listeners Used to Perform Event Actions Three Event Model Listeners Clone Listener Mobility Listener Persistence Listener Actions Listen for the Event They are Named After Listeners Can Be Customized to Perform Specific Actions When the Listener Event Occurs 39

R ELATIONSHIP BETWEEN A GLET AND ITS L ISTENERS Aglet Clone Events Mobility Events Persistence Events CloneListener MobilityListener PersistenceListener 40

E VENT M ODEL L ISTENERS Clone Listener Listens for Cloning Events Actions Can Be Customized to Occur Before, During, or After the Cloning Mobility Listener Listens for Mobility Events Actions Can Be Customized to Occur When an Aglet is About to Be Dispatched, Retracted, or Arrives in a New Context Persistence Listener Listens for Persistence Events Actions Can Be Customized to Occur When an Aglet is About to Be Deactivated or Has Been Activated 41

E XAMPLE Agent dispatch 42

T HE A GLET M ODEL Message Handling Aglets exploit a communication system based on message passing. An agent that wants to explicitly manage messages has to override the handleMessage(..) method, returning true in the case that the message is managed by the agent, and false otherwise. 43

M ESSAGE H ANDLING An aglet is not necessarily aware of message source, it just receives and handles messages. Message source should be included in some way in the message itself, since there is no other way to identify it. Message handling is as complex as the handleMessage(…) implementation. The method handleMessage(Message msg) has one parameter, the message received by the aglet, which can be used to define the aglet message handling behavior. The message type is its classification. 44

M ESSAGE H ANDLING 45

T HE A GLET M ODEL Agent Design Patterns Traveling Task Interaction 46

A GENT D ESIGN P ATTERN ( CONT.) Traveling Itinerary: routes among destinations. Forwarding: a host forwards an arrived agent to another host. Ticket: objectifies a destination address and encapsulates the quality of service and permissions needed to dispatch an agent to a host address and to execute it there. 47

A GENT D ESIGN P ATTERN ( CONT.) Task Master-Slave: an agent delegate a task to another Plan: organize multiple tasks to be performed in sequence or in parallel by multiple agents. 48

A GENT D ESIGN P ATTERN ( CONT.) Interaction Meeting: two or more agents initiate local interaction at a given host. Locker: defines a storage and come back for data later. Messenger: an agent carries a remote message from one agent to another. Facilitator: an agent provides services for naming and locating agents. Organized Group: travel together. 49

Aglet Class & API 50

A GLETS Mobile Agents with Java Aglet Package (Classes) Aglet Class Message Class AgletID Class AgletInfo Class AgletStub Class FutureReply Class QoC Class ReplySet Class 51

A GLETS Mobile Agents with Java Aglet Package (Interfaces) AgletProxy Interface AgletContext Interface MessageManager Interface 52

A GLET API: C LASSES Aglet Class Contains All Methods Needed to Perform the Basic Aglet Operations Basis for Building All Aglets Contains All the Elements of the Aglet 53

A GLET C LASS Aglet Creation Create a Customized Aglet import com.ibm.aglet.*; public class MyFirstAglet extends Aglet{ //Put aglet’s methods here } The Dispatch Method Dispatches an Aglet to a Remote Context The Method Call Contains the URL of the Remote Context dispatch(new URL(atp://remote.host.com/context”)); 54

A GLET C LASS Overridden methods: public void onCreation(Object init){ //do some initialization here … } public void run() { //do something here; }//main entry point e.g. call dispatch(new URL( “ atp://some.host.com//context ” )); 55

A GLET API : A GLET C LASS What happens when “ dispatch ” ? State Byte Code Host Sending Receiving State Byte Code Host Object Serialization Transfer Deserialization and re-create state 56

M ESSAGE C LASS Message Objects are Sent Using the AgletProxy Class Methods Object sendMessage(Message msg) void sendOnewayMessage(Message msg) Code Example proxy.sendMessage(myName); String name = (String)proxy.sendMessage(yourName); 57

M ESSAGE C LASS Public boolean handleMessage(Message msg){ if(msg.samekind( “ my name ” )){ String name=(String)msg.getArg(); return true; //Yes, I handled this message } else if(msg.samekind( “ your name? ” )) { msg.sendReply( “ Yina ” ); //Return its name return true; //Yes, I handled this message } else return false; //No, I did not handle this message } handleMessage method: 58

A GLET API : A GLET P ROXY How to get a proxy? Get proxy from a newly created aglet: AgletContext.createAglet() AgletProxy.clone() Get proxy from existing aglets Aglet.getProxy() – get its own proxy AgletContext.getAgletProxies() – retrieve an enum. of proxies in a context AgletContext.getAgletProxy() – get an aglet proxy for a given aglet ID AgletContext.setProperty – put proxy into context property and share it. 59

A GLET API : A GLET C ONTEXT An aglet context is the equivalent of a place. An aglet uses AgletContext interface to: Get information about its environment Send message to the environment, including other aglets currently active in that environment How it works: context=getAgletContext(); context.createAglet(); context.retractAglet(remoteContextURL,agletID); 60

E XAMPLE Aglet Example: Remote File Update Premise: Large Multiple Remote Files that Must be Updated by Word Replacement One Solution: Move Files to Central Server, Perform Update, and Move Files Back Another Solution: An Aglet that Updates Files by Replacing All Occurrences of One Specified Word in the Files With Another Specified Word Distributes the Load of Updates to Multiple Servers We ’ re Moving “ Code ” Rather Than Files 61

M ULTIPLE A GLETS U PDATING F ILES IN P ARALLEL Aglet Host (Updating) Host FFFFFF 62

U PDATE F ILE A GLET import com.ibm.aglet.*; import com.ibm.aglet.event.*; import java.net.*; import java.io.*; public class UpdateFile extends Aglet{ URL destination = null; File dir = null; String from = null; String to = null; public void onCreation(Object args){ destination = (URL)((Object[])args)[0]; dir = (File)((Object[])args)[1]; from = (String)((Object[])args)[2]; to = (String)((Object[])args)[3]; addMobilityListener(){ new MobilityAdapter(){ 63

U PDATE F ILE A GLET Public void onArrival(MobilityEvent e){ replace(args.file,args.from,args.to); dispose(); } } try{ dispatch(args.destination); }catch (Exception e){ System.out.println(“Failed to dispatch.”); } void replace(File, file, String, from, Sting to){ //Open ‘file’ and replace ‘from’ with ‘to’ } 64

A PPLICATION OF A GLETS Marketplace Architecture Shop agents go to a market from a shop owner ’ s terminal Customer agents travel around various markets to get more information Market advertisers go to other markets to invite customer agents 65

A NATOMY OF AN A GLET Creation & Disposal Clone Mobility – Dispatch and Retract Persistence – Activate and Deactive 66

C REATION public final AgletContext Aglet.getAgletContext() //Example: getAgletContext().createAglet(getCodeBase(), ” SomeAglet ”,null); Methods that can be overridden protected Aglet.Aglet() Public void Aglet.onCreation(Object init) Public void Aglet.run() createAglet() Aglet() onCreation run() 67

C LONING public final Object Aglet.clone() public final void Aglet.addCloneListener(CloneListener listener) public final void Aglet.removeCloneListener(CloneListener listener) public CloneAdapter.CloneAdapter() public void CloneAdapter.onCloning(CloneEvent event) public void CloneAdapter.onClone(CloneEvent event) public void CloneAdapter.onCloned(CloneEvent event) 68

public class CloningExample extends Aglet{ boolean _theClone=false; public void onCreation(Object o) { addCloneListener(new CloneAdapter(){ public void onCloning(CloneEvent e){ // print to the console } public void onClone(CloneEvent e){ // print to the console } public void onCloned(CloneEvent e){ // print to the console } } ); } public void run() { if (! _theClone) { //the original runs here… try{ clone(); } catch (Exception e) { System.out.println(e.getMessage( )); } else {//the clone runs here…} } run() onCloning() onCloned() onClone() run() original clone C LONING 69

M OBILITY -- Dispatching run( ) dispatch( ) onDispatching( ) onArrival( ) run( ) Origin Destination retractAglet( ) onArrival( ) run( ) onReverting( ) Local Remote -- Retracting 70

P ERSISTENCE Persistence run( ) deactivate( ) onDeactivating( ) onActivation( ) run( ) Before After Aglet Context Deactivate Activate 71