The Actor Architecture
March 5, 2004 Myeong-Wuk Jang Open Systems Laboratory
Outline
Actor Model Actor Architecture (AA) Main Functions of AA GUI of an AA Platform Structure of AA Examples
Hello World!
Extended Operators Actor Migration Middle Actor Services
UIUIC - OSL 2
03-05-04
The Actor Model
Definition of an Actor:
A self-contained, interactive, autonomous object that can communicate with other actors by asynchronous message passing.
Three Primitives:
create(b) send(a, m) become(b)
03-05-04
UIUIC - OSL
3
The Actor Architecture (AA)
Java Actor System AA Platforms
Actor execution environments
Actor Library
A development tool to implement actors on AA platforms.
03-05-04
UIUIC - OSL
4
Main Functions of AA
Actor Operators
create, send, become createRemote, call, migrate, destroy actor state: active, suspended, in-transit, transit actor location
Actor Management
Actor Migration Middle Actor Service
matchmaking brokering
UIUIC - OSL 5
03-05-04
Graphical User Interface
03-05-04
UIUIC - OSL
6
The Structure of AA
Actor
AA Platform
Directory Manager
Advanced Service
Actor Manager
Actor Migration Manager
Actor Management Service
Delayed Message Manager
Message Delivery Service
Message Manager
Transport Receiver
Transport Manager
Transport Sender
Message Transport Service
Transport Sender
Transport Manager
Transport Receiver
Message Transport Service
AA Platform
03-05-04
UIUIC - OSL
7
Actor Life Cycle
Transit
Suspended
Resume Move Start Destroy Suspend Execute In-Transit Move Start Active Unknown
Move End
Create or Execute
03-05-04
UIUIC - OSL
8
Actor Naming and Message
UAN: Universal Actor Name
uan://128.174.245.49:37
Actor Communication Message
Sender UAN Receiver UAN Message (Method) Name Arguments Reply With Reply To Return Request Flag Error Message Flag
UIUIC - OSL 9
03-05-04
Actor Communication
Message Manager vs. Transport Manager
Actor platform of a sender actor and a receiver actor
sende r actor
Message Manager
receive r actor
a. Procedure of Internal Actor Communication
Actor platform of a sender actor
sende r actor Message Manager Transport Sender
Actor platform of a receiver actor
Transport Receiver Message Manager receive r actor
b. Procedure of External Actor Communication
03-05-04 UIUIC - OSL 10
Example 1: Hello World!
package app.quickstart.hello; import aa.core.Actor; import aa.core.CreateActorException; public class Hello extends Actor { public Hello() { System.out.print(" Hello"); try { create("app.quickstart.hello.World"); } catch (CreateActorException e) { System.out.println("> Hello.Hello: " + e); } } }
package app.quickstart.hello;
import aa.core.Actor; public class World extends Actor { public World() { System.out.println(" World!"); } }
03-05-04
UIUIC - OSL
11
Example 2: Hello World!
package app.quickstart.hello; import aa.core.Actor; import aa.core.ActorName; import aa.core.CreateActorException; public class Hello extends Actor { public Hello() { System.out.print(" Hello"); try { ActorName anWorld = create("app.quickstart.hello.World"); send(anWorld, “world”); } catch (CreateActorException e) { System.out.println("> Hello.Hello: " + e); } } }
package app.quickstart.hello;
import aa.core.Actor; public class World extends Actor { public World() { } public void world() { System.out.println(" World!"); } }
03-05-04
UIUIC - OSL
12
Example 3: Hello World!
package app.quickstart.hello; import aa.core.Actor; import aa.core.BecomeActorException; public class Hello extends Actor { public Hello() { System.out.print(" Hello"); try { become("app.quickstart.hello.World"); } catch (BecomeActorException e) { System.out.println("> Hello.Hello: " + e); } } }
package app.quickstart.hello;
import aa.core.Actor; public class World extends Actor { public World() { System.out.println(" World!"); } }
03-05-04
UIUIC - OSL
13
Extended Operators
createRemote(h, b):
creates an actor on the remote host computer. sends a message and waits for the reply. synchronous communication moves the actor from its current host to another.
call(a, m):
migrate(h):
destroy():
destroys the actor.
UIUIC - OSL 14
03-05-04
Example 4: Hello World!
package app.quickstart.hello; import aa.core.Actor; import aa.core.CreateActorException; public class Hello extends Actor { public Hello() { System.out.print(" Hello"); try { createRemote(“seine.cs.uiuc.edu”, "app.quickstart.hello.World"); } catch (CreateActorException e) { System.out.println("> Hello.Hello: " + e); } } }
package app.quickstart.hello;
import aa.core.Actor; public class World extends Actor { public World() { System.out.println(" World!"); } }
03-05-04
UIUIC - OSL
15
Example 5: Hello World!
package app.quickstart.hello; import aa.core.Actor; import aa.core.ActorName; import aa.core.CreateActorException; public class Hello extends Actor { public Hello() { try { ActorName anWorld = create("app.quickstart.hello.World"); send(anWorld, “start”, getActorName()); } catch (CreateActorException e) { System.out.println("> Hello.Hello: " + e); } } public void hello() { System.out.print(" Hello"); } } } package app.quickstart.hello; import aa.core.Actor; import aa.core.ActorName; public class World extends Actor { public World() { }
public start(ActorName pan) { send(pan, “hello”); send(getActorName(). “world”); }
public void world() { System.out.println(" World!"); }
03-05-04
UIUIC - OSL
16
Example 6: Hello World!
package app.quickstart.hello; import aa.core.Actor; import aa.core.ActorName; import aa.core.CreateActorException; public class Hello extends Actor { public Hello() { try { ActorName anWorld = create("app.quickstart.hello.World"); send(anWorld, “start”, getActorName()); } catch (CreateActorException e) { System.out.println("> Hello.Hello: " + e); } } public void hello() { System.out.print(" Hello"); } } } package app.quickstart.hello; import aa.core.Actor; import aa.core.ActorName; public class World extends Actor { public World() { }
public start(ActorName pan) { call(pan, “hello”); send(getActorName(). “world”); }
public void world() { System.out.println(" World!"); }
03-05-04
UIUIC - OSL
17
Actor Migration
Advantage
move the code for the better working environment run an actor on any computer host even if the binary code does not exist
Operator
migrate(h)
03-05-04
UIUIC - OSL
18
Message Passing for Mobile Actors
Two Approaches
UAN-based Message Passing Location-based Message Passing
LAN: Location-based Actor Name
lan://128.174.244.147//128.174.245.49:37
03-05-04
UIUIC - OSL
19
UAN-based Message Passing
Actor Platform A: Actor Platform C:
UAN1://B:15
UAN2://B:16
send a from UAN1 UAN1 UAN2 send a message to UAN2 message to UAN2 from UAN1 UAN1 UAN2
Actor Platform B: UAN1://B:15 UAN2://B:16
03-05-04
UIUIC - OSL
20
LAN-based Message Passing
Actor Platform A: Actor Platform C:
UAN1://B:15
UAN2://B:16
send a message to LAN2://C/B:16 from LAN1://A/B:15 LAN1://A/B:15 LAN1://C/B:16
Actor Platform B:
03-05-04
UIUIC - OSL
21
Directory Manager
Open Distributed Actor Systems Middle Actor Service
Matchmaking Brokering
03-05-04
UIUIC - OSL
22
Matchmaking Service
Yellow Page Service Operators
register, deregister search, searchAll
Directory Manager UAN1, UAN2 Sende r Actor send Actor UAN2 Actor UAN1
searchAll
03-05-04
UIUIC - OSL
23
Matchmaking Service
Directory Manager
UAN2, seller, computer, 950
UAN3, seller, computer, 650 UAN2, seller, printer, 120 UAN4, seller, computer, 1290
searchAll
UAN2, seller, computer, 950 UAN3, register register seller, computer, 650 UAN4, seller, computer, 1290 UAN2, UAN3, UAN4 ?, seller, computer, ? UAN2, seller, printer, 120 Model-XXX send getModelName
register
UAN1:buyer UAN2:seller send
getModelName Model-YYY
UAN3:seller UAN4:seller
03-05-04
UIUIC - OSL
24
Brokering Service
Operators
register, deregister deliver, deliverAll
deliverAll
Directory Manager
send Actor UAN1
Sende r Actor
Actor UAN2
03-05-04
UIUIC - OSL
25
Brokering Service
Directory Manager
UAN2, seller, computer, 950
UAN3, seller, computer, 650 UAN2, seller, printer, 120 UAN4, seller, computer, 1290
deliverAll
sendModelName ?, seller, computer, ? Model-XXX send getModelName
send
sendModelName
UAN1:buyer UAN2:seller send
getModelName Model-YYY
UAN3:seller UAN4:seller
03-05-04
UIUIC - OSL
26
Actor Communication
Asynchronous Communication
send
Synchronous Communication
call
Attribute-based Communication
Directory Manager
03-05-04
UIUIC - OSL
27
Summary
The Actor Model The Actor Architecture
actor library
three actor primitives extended operators actor state management actor communication actor migration
actor execution environments
03-05-04
UIUIC - OSL
28
References
Web site:
osl.cs.uiuc.edu/aa
The Actor Architecture Manual The Actor Architecture Quickstart Manual E-Mail:
mjang@uiuc.edu
03-05-04
UIUIC - OSL
29