44
1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corp oration) Tetsuo Tamai University o f Tokyo rnational Conference on Metalevel Architecture and Separation of Crosscuttin 8, 2001

1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

Embed Size (px)

Citation preview

Page 1: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

1

Separation of Concernsin Mobile Agent Applications

Naoyasu Ubayashi ( Toshiba Corporation)

Tetsuo Tamai ( University of Tokyo )

Reflection2001The Third International Conference on Metalevel Architecture and Separation of Crosscutting Concerns Kyoto, JapanSeptember 25-28, 2001

Page 2: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

2

Plan of Presentation

1. Introduction

2. Problems of constructing cooperative mobile agent applications

3. RoleEP model

and Java RoleEP Framework

4. Related works

5. Conclusions

Page 3: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

3

1. Introduction

Page 4: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

4

Background

Recently, cooperative distributed applications based on mobile agent systems are increasing. Using mobile agents, we can developcooperative distributed applications that run over the Internet moreeasily and more flexibly than before.

But, there are problems ...

Page 5: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

5

Problems

• It is difficult to understand collaborations among agents and travels of individual agents as a whole because mobility/collaboration functions tend to be intertwined in the code.

• It is difficult to define behaviors of agents explicitly because they are influenced by the external context. Agents may change their functions dynamically.

host

agent

mobility function

collaboration function

intertwined!

Page 6: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

6

Aspects of mobilty/collaboration

Many aspects of mobility/collaboration strategies including

traveling,coordination constraints,synchronization constraints

andsecurity-checking strategies

should be considered when mobile agent applications are constructed.

Page 7: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

7

Goal of this research

This research proposes the concept of RoleEP (Role Based Evolutionary Programming) in order to alleviate the problems mentioned here.

1) RoleEP provides a mechanism for separating concerns about mobility/collaboration in mobile agent applications.

2) RoleEP gives a systematic and dynamic evolutionary programming style.

GoalGoal

Page 8: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

8

2. Problems of constructingcooperative mobile agent applications

~  Traditional approaches  ~

Page 9: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

9

Traditional approaches

1. Orthodox approach2. Design-pattern approach3. AOP approach

Page 10: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

10

ExampleA distributed information retrieval system (a typical example of cooperative distributed applications based on mobile agent systems)

contract-net protocol( collaboration)

Host

Host

user proxy

roaming around hosts(mobility)

searcher

(manager)

contract-net protocol( collaboration)

(contractor)

User

A user requests an agentto search information on specified topics.

Page 11: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

11

Viewpoints for estimation

Viewpoints

Separation of concerns 1) roaming around hosts (mobility)2) contract-net protocol (collaboration)

Evolution 1) User proxy agent ー (evolve) → Manager agent2) Searcher agent ー (evolve) → Contractor agent

User proxy

+User proxy + Manager

Page 12: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

12

Case1: Orthodox approach

A program description maps domain structures to program structures.

ApproachApproach

Page 13: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

13

Description of case1 -- Written in quasi-code similar to Java

public class UserProxy {

public void roam(){ : // move to the next host // and execute the method // "contractNet_start" }

public void contractNet_start(){ : // multicasts a task-announcement message // to all agents existing in the host. } public void contractNet_bid(){ : // select the “best_contractor” // if all bids are finished. best-contractor.contractNet_award(); } public void contractNet_end(){ // save the information // from the “best_contractor” // move to the next host roam();}}

Code for roaming around hosts

is mixed with

code for executing the contract-net protocol.

Mobiltyfunction

Mobilityfunction

Contract-netfunction

In most cases, mobile agent applications

are described in this programming style !!

Page 14: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

14

Estimation of case1

Viewpoints Estimation

Separation of concerns    ×Evolution    ×

It is difficult to understand a program behavior as a whole since mobility/collaboration functions that compose a program are not described separately.

MeritMerit

ProblemProblem

none

EstimationEstimation

Page 15: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

15

Case2: Design-pattern approach

Design patterns for Aglets (Aridor, Y. and Lange, D.B.)

1) Traveling Patterns:Itinerary, Forwarding, Ticket, etc.

2) Task Patterns:Master-Slave, Plan, etc.

3) Collaboration Patterns:Meeting, Locker, Messenger, Facilitator,Organized Group, etc.

Collaborations among agents are structured using design patternsfocused on mobile agents.

ApproachApproach

The Aglets is a mobile agent system based on Java.

Page 16: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

16

Description of case2 -- Written in Aglets

public class UserProxy extends Aglets{

public void roam(){ // sets sequential planning itinerary itinerary = new SeqPlanItinerary(this); itinerary.addPlan(HostAddress1, "contractNet_start"); : itinerary.addPlan(HostAddressN, "contractNet_start"); // starts the trip itinerary.startTrip(); }

public void contractNet_start(){ // multicasts a task-announcement message // to all agents existing in the host. : // waits until contract-net process is finished } public void contractNet_bid(){ // select the “best_contractor” // if all bids are finished. : best-contractor.award(); } public void contractNet_end(){ // saves results of the task execution. : // notifies this agent. }}

Itinerary Pattern

Separated!(within an agent)

Contract-netfunction

Mobilityfunction

This program is written in Aglets using the Itinerary pattern,a design pattern for roaming around hosts.

Page 17: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

17

Estimation of case2

ProblemProblem

MeritMerit

Code for roaming around hosts is separated from code for executing the contract-net protocol.

Separations of mobility/collaboration descriptions are limited only within an agent.

As shown in the program, if a roaming agent wants to behave as a manager at the host machine the agent moves into, functions requested for a manager should be described as methods of the agent !

EstimationEstimation

Viewpoints Estimation

Separation of concerns    △Evolution   ×

Page 18: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

18

Case3: AOP approach (Aspect Oriented Programming)

AOP is a programming paradigm such that a system is divided into aspects and objects.Crosscutting concerns are defined as aspects.A compiler, called weaver, weaves aspects and objects together into a system.

Kendall, E.A. proposed role model designs and implementations with AspectJ that is an aspect-oriented extension to Java.

ApproachApproach

Page 19: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

19

Description of case3 -- Written in AspectJ

public class UserProxy{ public void roam(){ … }}

aspect Manager extends Role{

// introduces public void UserProxy.start(){} public void UserProxy.bid (InforSearcher i){} public void UserProxy.end(Result r){}

// advise weaves before (Userproxy u) : target (u) && call (public void start) {…}

before (Userproxy u) : target (u) && call (public void bid) {…}

before (Userproxy u) : target (u) && call (public void end) {…}}

public class InfoSearcher{ public void executeTask(){ … }}

aspect Contractor extends Role{

// introduces public void InfoSearcher.taskAnnounce (Userproxy u) {} public void InfoSearcher.award (Userproxy u) {}

// advise weave before(InfoSearcher i): target (i) && call (public void taskAnnounce) {…}

before (InfoSearcher i): target (i) && call (public void award) { u.end( executeTask() ); }}

weaver

program

staticweaving

Mobilityfunction

Contract-netfunction

Contract-netfunction

Page 20: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

20

Estimation of case3

Each aspect must be defined per a role. A description that crosscuts roles may be dispersed in several aspects. Dynamic evolution is not emphasized.

ProblemProblem

MeritMerit

Code for roaming around hosts is separated from code for executing the contract-net protocol completely.

EstimationEstimation

Viewpoints Estimation

Separation of concerns    △Evolution   △

Page 21: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

21

Estimation of traditional approaches (summary)

Approaches Viewpoints(Separation of concerns) (Evolution)

Orthodox approach × ×Design-pattern approach △ ×AOP approach △ △

In traditional approaches,

language constructs for separation of concerns and evolution

are insufficient.

In traditional approaches,

language constructs for separation of concerns and evolution

are insufficient.

Page 22: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

22

3. RoleEP modeland Java RoleEP Framework

Page 23: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

23

Goal of RoleEP

1) RoleEP provides a mechanism for separating concerns about mobility/collaboration in mobile agent applications.

2) RoleEP gives a systematic and dynamic evolutionary programming style.

Page 24: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

24

RoleEP ModelRoleEP is composed of four model constructs -- environments, roles, objects and agents

[Evolution (object → agent)]

Object

bind

Binding-interface(abstract method)

RoleAgent

migrate

Environment

Page 25: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

25

Model constructs (1)

A function that an agent assumes in a field.

EnvironmentEnvironment

A field where a group of mobile agents collaborate with each other.

RoleRole

Mobility/collaboration functions including tours around hosts and message communications among agents are described by role attributes and role methods.

RoleAgent

migrate

Environment

Role

Role

Page 26: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

26

Model constructs (2)

ObjectObject

An object becomes an agent by binding itself to a role that is defined in an environment, and acquires functions needed for collaborating with other agents that exist in the same environment.

[Evolution (object → agent)]

Object

bind

Binding-interface(abstract method)

RoleAgent

migrate

Environment

Objects have original functions that are common to all kinds of environment and do not contain mobility/collaboration functions.

AgentAgent

Page 27: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

27

Model constructs (3)

Binding-operationBinding-operation Agent ( Role + Object )

role method

binding-interface

Role

Object

bind

renamesignature

&delegate

concrete methods

(before action)send a message corresponding to

(after action)

binding-interface

•Binding-operation binds binding-interfaces of roles to concrete methods of objects.

•The binding-interface defines the interface in order to receive messages from other roles existing in the same environment.

• Using the binding-interface, collaborations among a set of roles can be described separately from each object.

Binding-operations are implemented by renaming signatures and creating delegational relations between roles and objects dynamically.

Binding-operations are implemented by renaming signatures and creating delegational relations between roles and objects dynamically.

Page 28: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

28

Separation of Concerns in RoleEP Model

Mobility/Collaborationfunctions

Mobility/Collaborationfunctions

Original functionsOriginal functions

separated

[Evolution (object → agent)]

Object

bind

Binding-interface(abstract method)

RoleAgent

migrate

Environment

Page 29: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

29

Model constructs (Summary)

environment ::= [environment attributes, environment methods, roles]role ::= [role attributes, role methods, binding-interfaces]

agent ::= [roles, object]

object ::= [attributes, methods]

Page 30: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

30

Construction of Cooperative Mobile Agent Applications in RoleEP

Cooperative mobile agent applications, which may change their functions dynamically, can be constructed by synthesizing multiple environments dynamically.

Evolutionaryconstruction

Page 31: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

31

Epsilon/J --Java RoleEP Framework

Epsilon/J is a framework that supports RoleEP concepts.]

This framework, which is presented as class libraries, is implemented on Aglets that is a mobile agent system based on Java.

Page 32: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

32

Description in Epsilon/J

public class Roaming extends Environment{ public class Visitor extends Role{ …}}

public class ContractNet extends Environment{ public class Manager extends Role{ public void start(){} public void bid(){} public void end(){} } public class Contractor extends Role{ public void award(){

m.end (executeTask()); }}

public class UserProxy extends EpsilonObj{ public void life(){ bind ... bind ... }}

public class InfoSearcher extends EpsilonObj{ public void life() {

bind( “executeTask”, “searchInfo”); }

public void searchInfo(){ …}}

object object

Environment & role Environment & role

Dynamic evolution!

addBindingInterface(“executeTask”)

addBindingInterface(“executeTask”)

Mobilityfunction

Contract-netfunction

Page 33: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

33

Binding-operationAgent ( Role + Object )

ExecuteTask

(binding-interface)

bind

Rename signature&

delegate

concrete methods

ContractorRole

SearcherObject

If the binding-interface “executeTask” is bound to the method “searchInfo”, the message "executeTask" received by the role is renamed "searchInfo" and delegated to the object.

UserProxyObject

ManagerRole

searchInfoSeparated!!

Page 34: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

34

Estimation of RoleEP

Approaches Viewpoints(Separation of concerns) (Evolution)

RoleEP ○ ○

Orthodox approach × ×Design-pattern approach △ ×AOP approach △ △

Page 35: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

35

Merits of RoleEP

1) Construction mechanisms for mobility/collaboration componentsEnvironment classes can be regarded as mobility/collaboration components.

2) Evolution mechanisms for agentsAn object can dynamically evolve to an agent that can behave multiple roles. Using RoleEP, programs that adapt to external context can be described easily.

3) Agentification mechanismsIn RoleEP, a role corresponds to a transducer that accepts messages from other agents and translates them into messages that an object can understand. RoleEP can be regarded as one of dynamic agentification mechanisms.

Page 36: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

36

4. Related works

Page 37: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

37

Related works

Aspect Oriented Programming (Kiczales, G., et al.)Subject Oriented Programming (Harrison, W. and Ossher, H.)HyperspacesPluggable composite adapter (Mezini, M., et al.)Role model (VanHilst, M. and Notkin, D.)

SOC ( Separation of Crosscutting Concerns )SOC ( Separation of Crosscutting Concerns )

RoleEP emphasizes not only SOC but also dynamic evolution !

Page 38: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

38

5. Conclusions

Page 39: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

39

Conclusions

We proposed RoleEP, a new approach that constructs cooperative mobile agent applications.

1) RoleEP provides a mechanism for separating concerns about mobility/collaboration in mobile agent applications.

2) RoleEP gives a systematic and dynamic evolutionary programming style.

1) RoleEP provides a mechanism for separating concerns about mobility/collaboration in mobile agent applications.

2) RoleEP gives a systematic and dynamic evolutionary programming style.

Page 40: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

40

Appendix

Page 41: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

41

AOP vs RoleEP

viewpoint AOP RoleEP

aspects aspects environments and rolescomponents components objectsjoint points join points roles (between aspects and components)weaving method weaver binding-operation

aspect reuse emphasized emphasizeddynamic evolution not emphasized emphasized

Page 42: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

42

Pluggable composite adapteradapter ContractNet {

adapter Manager adapts UserProxy {

public void start(){...}

public void bid() {...}

public void end() {...} }

adapter Contractor adapts InfoSearcher {

public void taskAnnounce(){...}

public void award(){ InfoSearcher.this.searchInfo(); }

}}

Notions of the pluggable composite adapter are quite similar to RoleEP.

However, there are some differences between them as follows:

1) A relation between an adapter and an adaptee is described statically in the the pluggable composite adapter;

2) Descriptions of adapter's behavior depend on interface names of adaptee's class in the pluggable composite adapter.

Page 43: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

43

Mobile Ambients

Mobile Ambients (Cardelli, L. and Gordon, A.D.)

This model gives a layered agent structure. In this model, agents run on fieldsconstructed by synthesizing contexts (environments) dynamically.

Page 44: 1 Separation of Concerns in Mobile Agent Applications Naoyasu Ubayashi Toshiba Corporation) Tetsuo Tamai University of Tokyo Reflection2001 The Third International

44

*If a role receives a message corresponding to its binding-interface from other roles or itself, the role delegates the message to an object bound to the role.