Title: Separation of Concerns in Mobile Agent Applications
1Separation of Concerns in Mobile Agent
Applications
Reflection2001 The Third International Conference
on Metalevel Architecture and Separation of
Crosscutting Concerns Kyoto, Japan September
25-28, 2001
- Naoyasu Ubayashi (Toshiba Corporation)
- Tetsuo Tamai (University of Tokyo)
2Plan of Presentation
- 1. Introduction
- 2. Problems of constructing cooperative mobile
agent applications - 3. RoleEP model
- and Java RoleEP Framework
- 4. Related works
- 5. Conclusions
31. Introduction
4Background
Recently, cooperative distributed applications
based on mobile agent systems are increasing.
Using mobile agents, we can develop cooperative
distributed applications that run over the
Internet more easily and more flexibly than
before.
But, there are problems ...
5Problems
- 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
mobility function
intertwined!
agent
collaboration function
6Aspects of mobilty/collaboration
Many aspects of mobility/collaboration strategies
including traveling, coordination
constraints, synchronization constraints
and security-checking strategies should be
considered when mobile agent applications are
constructed.
7Goal of this research
This research proposes the concept of RoleEP
(Role Based Evolutionary Programming) in order to
alleviate the problems mentioned here.
Goal
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.
82. Problems of constructingcooperative mobile
agent applications
9Traditional approaches
1. Orthodox approach 2. Design-pattern
approach 3. AOP approach
10Example
A distributed information retrieval system (a
typical example of cooperative distributed
applications based on mobile agent systems)
Host
contract-net protocol ( collaboration)
roaming around hosts (mobility)
searcher
User
contract-net protocol ( collaboration)
(manager)
A user requests an agent to search information on
specified topics.
(contractor)
11Viewpoints for estimation
Viewpoints Separation of concerns 1) roaming
around hosts (mobility) 2) contract-net
protocol (collaboration) Evolution 1) User
proxy agent ? (evolve) ? Manager
agent 2) Searcher agent ? (evolve) ?
Contractor agent
User proxy
User proxy Manager
12Case1 Orthodox approach
Approach
A program description maps domain structures to
program structures.
13Description 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()
Mobilty function
Contract-net function
Code for roaming around hosts is mixed with
code for executing the contract-net protocol.
Mobility function
In most cases, mobile agent applications are
described in this programming style !!
14Estimation of case1
Merit
none
Problem
It is difficult to understand a program behavior
as a whole since mobility/collaboration functions
that compose a program are not described
separately.
Estimation
15Case2 Design-pattern approach
Approach
Collaborations among agents are structured using
design patterns focused on mobile agents.
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.
The Aglets is a mobile agent system based on Java.
16Description 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.
Contract-net function
Mobility function
Itinerary Pattern
Separated! (within an agent)
This program is written in Aglets using the
Itinerary pattern, a design pattern for roaming
around hosts.
17Estimation of case2
Merit
Code for roaming around hosts is separated from
code for executing the contract-net protocol.
Problem
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 !
Estimation
18Case3 AOP approach (Aspect Oriented
Programming)
Approach
- 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.
19Description of case3 -- Written in AspectJ
public class UserProxy public void roam()
public class InfoSearcher public void
executeTask()
Mobility function
static weaving
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)
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
Contract-net function
Contract-net function
20Estimation of case3
Merit
Code for roaming around hosts is separated from
code for executing the contract-net protocol
completely.
Problem
Each aspect must be defined per a role. A
description that crosscuts roles may be dispersed
in several aspects. Dynamic evolution is not
emphasized.
Estimation
21Estimation of traditional approaches (summary)
In traditional approaches, language
constructs for separation of concerns and
evolution are insufficient.
223. RoleEP model and Java RoleEP Framework
23Goal 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.
24RoleEP Model
RoleEP is composed of four model constructs --
environments, roles, objects and agents
25Model constructs (1)
Environment
Environment
A field where a group of mobile agents
collaborate with each other.
Role
Agent
A function that an agent assumes in a
field.
migrate
Mobility/collaboration functions including tours
around hosts and message communications among
agents are described by role attributes and role
methods.
26Model constructs (2)
Object
Objects have original functions that are common
to all kinds of environment and do not contain
mobility/collaboration functions.
Agent
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.
27Model constructs (3)
Binding-operation
Agent ( Role Object )
- 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.
role method
Role
binding-interface
rename signature delegate
Binding-operations are implemented by renaming
signatures and creating delegational relations
between roles and objects dynamically.
bind
concrete methods
Object
28Separation of Concerns in RoleEP Model
29Model constructs (Summary)
environment environment attributes,
environment methods,
roles role role attributes, role methods,
binding-interfaces agent roles, object
object attributes, methods
30Construction 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.
Evolutionary construction
31Epsilon/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.
32Description in Epsilon/J
object
object
public class UserProxy extends EpsilonObj
public void life() bind
... bind ...
public class InfoSearcher extends EpsilonObj
public void life() bind(
executeTask,
searchInfo) public void searchInfo()
Dynamic evolution!
Environment role
Environment role
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())
addBindingInterface (executeTask)
Mobility function
Contract-net function
33Binding-operation
Agent ( Role Object )
Contractor Role
Manager Role
ExecuteTask (binding-interface)
Rename signature delegate
UserProxy Object
searchInfo
Separated!!
Searcher Object
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.
bind
concrete methods
34Estimation of RoleEP
35Merits of RoleEP
1) Construction mechanisms for mobility/collaborat
ion components Environment classes can be
regarded as mobility/collaboration
components. 2) Evolution mechanisms for
agents An 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
mechanisms In 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.
364. Related works
37Related works
SOC ( Separation of Crosscutting Concerns )
Aspect Oriented Programming (Kiczales, G., et
al.) Subject Oriented Programming (Harrison, W.
and Ossher, H.) Hyperspaces Pluggable composite
adapter (Mezini, M., et al.) Role model
(VanHilst, M. and Notkin,
D.)
RoleEP emphasizes not only SOC but also dynamic
evolution !
385. Conclusions
39Conclusions
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.
40Appendix
41AOP vs RoleEP
viewpoint AOP RoleEP aspects aspects en
vironments and roles components components obje
cts joint points join points roles
(between aspects and components) weaving
method weaver binding-operation aspect
reuse emphasized emphasized dynamic
evolution not emphasized emphasized
42Pluggable composite adapter
adapter 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 - A relation between an adapter and an adaptee is
described statically in the the pluggable
composite adapter - Descriptions of adapter's behavior depend on
interface names of adaptee's class in the
pluggable composite adapter.
43Mobile Ambients
Mobile Ambients (Cardelli, L. and Gordon, A.D.)
This model gives a layered agent structure. In
this model, agents run on fields constructed by
synthesizing contexts (environments) dynamically.
44If 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.