210 likes | 314 Views
Distributed Dynamic Weaving is a Crosscutting Concern. Michihiro Horie , Satoshi Morita, Shigeru Chiba Tokyo Institute of Technology, Japan. Aspect Oriented Programming (AOP). AOP languages enable to modularize crosscutting concerns into aspects Distributed dynamic AOP languages
E N D
Distributed Dynamic Weaving is a Crosscutting Concern MichihiroHorie, Satoshi Morita, Shigeru Chiba Tokyo Institute of Technology, Japan
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
An example of woven aspects Advice Pointcut Aspect publicaspectEncrypter { 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
Weaving fails without a consistency mechanism • An experiment in InTrigger grid computing platform • Encryption/decryption with a message serviceapplication • 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]
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 decrypt encrypt Client Server restart Client Server Encrypted message
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 decrypt encrypt Client Server message deploy Client Server message activate Client Server Encrypted message activate
DandyJ • New distributed Dynamic AOP language • 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
First-class and two-phase weaving • First-class • Dynamic aspect • Can be woven during runtime • dynamicmodifier • A subtype of DAspect • It has to be explicitly instantiated • Can be assigned to a variable andpassed 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();
Methods available on dynamic aspects • The asynchronousdeploy and synchronous activate • Allows us to minimize the duration of the “stop the world” time for dynamic weaving
Remote pointcut [Nishizawaet.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 node00: ... send (); node00 Aspect
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 undeployexplicitly • onetime modifier Control weaving encrypt decrypt Server Client Encrypted message undeploy Client Server Encrypted message
Encryption aspects in DandyJ publicdynamicaspectEncrypter { localvoid around (String msg): client() && args(msg) { // encrypt the message proceed (msg); }} public abstractdynamic onetime aspectServerClient { … before (): server() && if (openPort.isDeployed() && server.isDeployed()) { openPort.activate(); server.activate(); } before (): client() && if(server.isActivated() && changePort.isDeployed() && client.isWoven()) { changePort.activate(); client.activate(); }} publicdynamicaspectDecrypter { local voidaround (String msg, Server s): server() && args(msg) && this(s){ if ( /* */ ) { // decrypt the message proceed (msg); } else { proceed(msg); }}}
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 Join point Calculation Data sending node00 node01 node02 t = 101 sync t = 102 sync activation t = 103 Do not activate
A reusable aspect for barrier synchronization public abstractaspectBarrierSync { … 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); }}}
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 • InTriggerchiba & mirai • OS: Debian • Chiba CPU: Core2Duo 2.13GHz, memory: 4GB • Mirai CPU: Xeon 2.33GHz, memory: 16GB
Results Delay for barrier sync. Weave an aspect • Onetime aspect contributes to response time and consistency 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
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 InTriggergrid computing platform
Related work • DyReS [Truyen et.al. 08] • 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
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
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