Presentation is loading. Please wait.

Presentation is loading. Please wait.

Distributed Dynamic Weaving is a Crosscutting Concern

Similar presentations


Presentation on theme: "Distributed Dynamic Weaving is a Crosscutting Concern"— Presentation transcript:

1 Distributed Dynamic Weaving is a Crosscutting Concern
Michihiro Horie, Satoshi Morita, Shigeru Chiba Tokyo Institute of Technology, Japan

2 Aspect Oriented Programming (AOP)
AOP languages enable to modularize crosscutting concerns into aspects Distributed dynamic AOP languages Extended for a distributed and running program Weaving encryption/decryption aspects to a running program Crosscutting concerns Must be woven simultaneously Client Server messages Encrypt Decrypt Client Server encrypted messages

3 An example of woven aspects
Advice Pointcut Aspect public aspect Encrypter { void around (String msg): call(void Client.send(String))&& args(msg) { String cipher = encrypt(msg); // encryption proceed(cipher); // original method invocation } description class Client { void send (String msg) { }} Joinpoint Server Encryption

4 Weaving fails without a consistency mechanism
An experiment in InTrigger grid computing platform Encryption/decryption with a message service application Sending 1 message/ms Chiba to Hakodate The network latency was 27 msec. Results 10 times failure in Java-based language 1 failure in CaesarJ [Mezini et.al. 03]

5 Existing approaches: Barrier synchronization
Client Server Which tick do we suspend the program at? Needs another aspect to control weaving Difficult to define This aspect should be also woven dynamically… message Client Server suspend encrypt decrypt Client Server restart Client Server Encrypted message

6 Existing approaches: Atomic weaving [Truyen et.al. 06]
deploy Client Server An aspect weaving is split into two phases Deploy An aspect is delivered to a remote host Activate Only when it is explicitly activated No language support No single atomic weaving mechanism for all applications Decreases reusability of control aspects STOP message encrypt decrypt Client Server message deploy Client Server message activate Client Server Encrypted message activate

7 DandyJ New distributed Dynamic AOP language Three language constructs
Distributed dynamic weaving can be written by aspects Control weaving depends on each application An aspect to control weaving can be independent Reusable Three language constructs First-class aspects with two-phase weaving Remote pointcuts One-time aspects

8 First-class and two-phase weaving
Dynamic aspect Can be woven during runtime dynamic modifier A subtype of DAspect It has to be explicitly instantiated Can be assigned to a variable and passed as a method parameter Reusable library code Two-phase weaving Deploy and activate dynamic aspect Encrypter { …. } Encrypter enc = new Encrypter (); enc.deploy(); enc.activate(); ... enc.undeploy();

9 Methods available on dynamic aspects
The asynchronous deploy and synchronous activate Allows us to minimize the duration of the “stop the world” time for dynamic weaving Methods Description void deploy() Deploy a dynamic aspect with being inactive void undeploy() Undeploy an aspect void activate() Activate an aspect void unactivate() Inactivate an aspect boolean isDeployed() Returns true if an aspect has been deployed boolean isActivated() Returns true if an aspect is active Deployment is performed asynchronously

10 Remote pointcut [Nishizawa et.al. 04]
Selects execution events on a remote machine Method calls etc. local modifier for locally deploying aspects Useful to implement an action that has to be performed on the same machine Aspect node00: node00 ... send (); Pointcut designator Joinpoint hosts(hostName1, hostName2 ..) Selects joinpoints on hostName1, hostName2, … hostName(hostName) Binds a variable hostName to the name of the host machine where the selected joinpoint exists.

11 Onetime aspect Client Server message Automatically undeployed after all its advices are executed Useful to implement a program for controlling distributed weaving Need not write undeploy explicitly onetime modifier Control weaving encrypt decrypt Client Server Encrypted message undeploy Client Server Encrypted message

12 Encryption aspects in DandyJ
public dynamic aspect Encrypter { local void around (String msg): client() && args(msg) { // encrypt the message proceed (msg); }} public abstract dynamic onetime aspect ServerClient { before (): server() && if (openPort.isDeployed() && server.isDeployed()) { openPort.activate(); server.activate(); } before (): client() && if(server.isActivated() && changePort.isDeployed() && client.isWoven()) { changePort.activate(); client.activate(); }} public dynamic aspect Decrypter { local void around (String msg, Server s): server() && args(msg) && this(s){ if ( /* */ ) { // decrypt the message proceed (msg); } else { proceed(msg); }}}

13 Another example: a logging aspect with a n-body problem solver
Weaving along the barrier synchronization Deploys two aspects One for the preparation Another for logging deploy node00 node01 node02 sync activation t = 101 t = 102 t = 103 Do not activate Join point Calculation Data sending

14 A reusable aspect for barrier synchronization
public abstract aspect BarrierSync { abstract pointcut sync(); before(String host): sync() && hostName(host) { map.put(host, true); } after(String host): sync() && hostName(host) && if(dAspect.isDeployed()) { synchronized(this) { if (!map.containsValue(false)) { dAspect.activate(); this.undeploy(); map.put(host, false); }}}

15 Experiment Encryption/decryption aspects for a message service application Uses two remote clusters Chiba Sending messages Control weaving Mirai: Receiving messages Four scenarios (A) Deploy and activate aspects without any consideration of atomicity (B) Suspend the application, weave aspects, and then restart it (C) Deploy and activate aspects by our DandyJ aspect (D) The same as (C) but the aspect is not one-time Environment InTrigger chiba & mirai OS: Debian Chiba CPU: Core2Duo 2.13GHz, memory: 4GB Mirai CPU: Xeon 2.33GHz, memory: 16GB

16 Results Onetime aspect contributes to response time and consistency
Weave an aspect Delay for barrier sync. Response time ◎ Consistency × Response time × Consistency ○ Response (ms) Max: 69 Ave: 45.4 Max: 133 Ave: 47.5 Message sent (times) Response time ○ Consistency ○ Response time △(7%) Consistency ○ Max: 71 Ave: 46.6 Max: 75 Ave: 49.6

17 Concluding remarks Illustrates that distributed dynamic weaving is a crosscutting concern DandyJ New distributed dynamic AOP language Three language constructs First-class aspect with two-phase weaving Remote pointcut Onetime-aspect Experiment with the InTrigger grid computing platform

18

19 Related work DyReS [Truyen et.al. 08] CaesarJ [Mezini et.al. 03]
Uses XML script to describe activation of aspects Difficult to understand procedures in remote hosts Scripts tend to be complicated CaesarJ [Mezini et.al. 03] Activates an aspect through deploy instruction Cannot control procedures in remote hosts DJAsCo [Navarro et.al. 06] Available for remote pointcut Cannot describe an activation code by an advice Lasagne [truyen et.al. 06] Atomic weaving

20 Implementation of DandyJ
ddjc: Compiler based on JastAdd-version of Aspect- Bench Compiler Extended by aspects Added 5,000 Lines of codes ddj: Runtime system Executes dynamic weaving Uses Javassist 3,000 Lines of codes

21 The port changes Deploy encryption/decryption aspects by the deploy method in the control aspect Confirm deployment by the isDeployed method Activate deployed aspects Uses the different port


Download ppt "Distributed Dynamic Weaving is a Crosscutting Concern"

Similar presentations


Ads by Google