Presentation is loading. Please wait.

Presentation is loading. Please wait.

Towards Self-Adaptive Software Dipl.-Inf. Andreas Rasche Hasso-Plattner-Institute University of Potsdam.

Similar presentations


Presentation on theme: "Towards Self-Adaptive Software Dipl.-Inf. Andreas Rasche Hasso-Plattner-Institute University of Potsdam."— Presentation transcript:

1 Towards Self-Adaptive Software Dipl.-Inf. Andreas Rasche Hasso-Plattner-Institute University of Potsdam

2 Outline Why Self-Adaptive Software ? Approaches for Adaptive Software – A History Development of adaptive applications using Adapt.Net  Basic Building Blocks  Dynamic Reconfiguration Algorithms  Runtime State Transfer: Migration & Updates  On-demand deployment  Tool Support for application creation

3 The term adaptation Adaptation - “the process of adapting to something (such as environmental conditions)”  Origin: L. Adaptare = to fit Adaptive – “possessing an ability to change to suit different conditions” Self-Adaptive – Automatic Adaptation without manual intervention

4 Dynamic World needs Adaptation Mobility  Location Awareness  Power Awareness, Battery Life CPU frequency scaling  Changing Communication Network Properties  Offline-/Online Computation  Display Complexity  Reaction to failures

5 Variety of Communication Networks & Dynamically Changing Properties GSM, UMTS, WLAN, Bluetooth, Satellite Communication, IrDA Quality of Service Parameter depend on  Geographic Position, Environmental conditions (reflection, distance to base station, countryside)  Moving users (Doppler Effect)  Utilisation (number of users / cell)

6 Adaptation: How to integrate ? Hard-wired integration into the application  Problem: Application concurrency Application Transparent Adaptation: CODA  Legacy applications run unmodified Application Aware: Collaboration of application and operating system/middleware [Noble et. al. 97]

7 Adaptivity: Quality Measurements Agility: Speed and accuracy of detection and reaction to changes in resource availability  Resource demand different agility: Network Bandwidth vs. Battery Power Fidelity: Application Data Quality delivered to users compared to maximum available  Video data: frame rate, image quality of frames  Spatial data (topografical maps) : resolution, feature size  Adaptivity: Trade-offs among fidelity dimensions

8 Adaptation: Building Blocks Observation Monitoring React on Changes Environment - Network, CPU, Battery Component properties Component behavior Reconfiguration Parameter Architecture Data Profiles - Map Conditions to According Configurations Adaptation

9 Adaptive Control Systems 50s – 60s : Gain scheduling controller Self-adjustment of controller parameters Open-loop adaptation scheme [Sastry and Bodson “Adaptive Control: Stability, Convergence, and Robustness”, 1994]

10 Adaptive Control Systems cont. Closed-loop adaptation Self-tuning controller (Kalman `58) [Sastry and Bodson “Adaptive Control: Stability, Convergence, and Robustness”, 1994]

11 The Adapt.Net Framework Dynamic reconfiguration of component-based applications Runtime Deployment Tool-support for building self-adaptive applications Building alternative configurations: architectural patterns Runtime Updates and Migration Monitoring infrastructure: environmental properties, component parameter, component state Choosing configrations: Adaptation Profiles

12 Application Model Based on a work of J. Magee, J. Kramer, M. Wermelinger Components: Interconnected computational entities  Provide interfaces : in-ports  Require other components: out-ports Components connected by connectors No cycles in application topology graph A transaction virtually combines a number of bidirectional interactions between components  completes in bounded time  Initiator is informed about completion A transaction T1 is dependent on a subsequent transaction T2 (T1/T2) if its completion depends on the completion of this transaction

13 XML-Based Configuration Description “A Configuration of a component-based application denotes the set of its parameterized components and the connections among them.” Configuration Description:  List of components  Component attributes  Component ports  Connectors

14 Configuration Infrastructure Configuration Manager XML- Configuration Description IConfigure Monitoring Adaptation Profile Adaptation Engine

15 Reconfiguration Algorithm 1. Loading of new components 2. Bringing application into reconfigurable state Application consistency must be preserved during reconfiguration Blocking all connections: Wait for all on-going transactions to complete; don’t allow initialization of new ones Blocking must be ordered due to dependent transactions 3. Transferring state of migrated/updated components 4. Setting changed component parameters 5. Reconnecting components (create connectors) 6. Restarting component processing 7. Removing old components

16 Dynamic Reconfiguration A B C compression=30 A D C B Configuration 1 Configuration 2

17 Dynamic Reconfiguration A B C compression=30 Configuration Manager Configuration 2 XML- Description 1 D 2 Create new Component 3 Calculate Connections to block Read

18 Dynamic Reconfiguration A B Configuration Manager Configuration 2 XML- Description 1 D Read C compression=30

19 Dynamic Reconfiguration A B Configuration Manager Configuration 2 XML- Description 1 D Read C compression=30 Block Connection 4 5 Block new connections Wait for on-going to complete 6 Reconfigurable State

20 Dynamic Reconfiguration A B Configuration Manager Configuration 2 XML- Description 1 D Read C compression=30 7 Reconnect A 7 Connect D

21 Dynamic Reconfiguration A B Configuration Manager Configuration 2 XML- Description 1 D Read C compression=30 8 Restart processing

22 Blocking a Connection Component Code calls  TransactionBegin: If(blocked) Wait(block_semaphore); processing=true; Wait(proc_semaphore);  TransactionEnd: processing=false; Release(proc_semaphore) Configuration interface  BlockConnection blocked=true; Wait(block_semaphore) if(processing) Wait(proc_semaphore) Release(proc_semaphore)  Start of Configuration interface blocked=false; Release(block_semaphore); int a = 3; int b = 5; Transaction.Begin(); b = calc.Add(1,b); a = calc.Sub(a,b); Transaction.End();

23 Configurable Components Each component has to implement a configuration hook IConfigure:  Start component processing  Block connections  Set properties  Connect/disconnect out-going ports  Initialization / Finalization Implementation for IConfigure can be generated  Integrated into graphical development tool of Adapt.Net

24 Configurable Components + AOP Aspect-Oriented Programming (AOP) Separation of Concerns Component configuration is a separate concern Usage of Loom.Net static aspect weaver Based on Communation between functional component and configurtion code via.NET Reflection

25 public class ConfiguredFilter:Filter,IConfigure { void SetProperty(string name, string val){ cval = Convert(val); this.GetField(name).SetValue(cval) } void Connect(string port, obj target){ this.GetField(port).SetValue(obj); } void BlockConnection(string conn){ mutex.Aquire(); } void StartProcessing(){ mutex.Release(); } Configurable Components public class Filter{ [AdaptNet.Property] int compression; [AdaptNet.Connection] IViewer viewer; public void Send(byte[] data) { Transaction.Begin(viewer); viewer.Send(data); Transaction.End(viewer); }

26 Configurable Components Loom.Net Aspect Code using AdaptNet; [Serializable] class Configurable/*[CLASSNAME]*/:/*[CLASSNAME]*/, IConfigure {... public bool SetProperty(string name, string attvalue) { FieldInfo _field = this.GetType().GetField(name); _field.SetValue(this,Convert.ChangeType(attvalue, GetFieldofThis(name).FieldType,null)); return true; }... }

27 Configuration Annotations public class Counter : MarshalByRefObject { [Property] // Configuration Hook private long step; private long count = 0; // State public void Reset() { count = 0; } public void Increase() { count += step; } public long GetCount() { return count; } public class CounterClient { [Connection] private Counter counter = null; public void Main() { while(true) { Transaction.Begin("counter"); counter.Increase(); Console.WriteLine("Counter Value :" + counter.GetCount()); Transaction.End("counter"); Thread.Sleep(1000); }

28 CoFRA Infrastructure

29 Component Type Loaders Component configurators hide implementation details of component instances during runtime Available Component Type Loaders manage components life cycle : loading, initialization, deletion, finalization Existing Component Type Loaders and component start  Simple Object Created using new language construct .NET Remoting Object Registration of Remote Service  Process Component Type CreateProcess and Registration of Management Service Interface  Java-based CORBA Object Initialization of CORBA runtime, object creation and registration

30 Connector Architecture Connector between components exchangeable during runtime Connector establishment implemented in IConfigure.Connect method.NET Remoting Connector .NET-.NET Local Call Connector  Between simple Objects IIOP Connector  CORBA -.NET and CORBA-CORBA Planned connector patterns:  Tupelspace connector for online/offline configurations  Webservice connector to integrate available functionality  Gridservice connector to exploit available computing grids

31 The Component Configurator - abstracting away CORBA, Java, and.NET

32 Adaptation Profiles

33 Architectural Patterns for Adaptive Applications Voter Pattern  Compare output of 3 objects supporting the same interface Safe update pattern  Update a running object to a new version Load balancer pattern Migration pattern  Migrate an object from one host to another Filter, Compression, Encryption Pattern Simplex Pattern  Used in Foucault’s Pendulum

34 Grafical Support for Pattern Integration

35 Pendulum Experiment Control Configurations USB-Driver Event Queuing Safety Controller User Program Event Duplicator User Program Configuration 1 : safety controller Configuration 2 : user program (cold standby) Configuration 3 : user program (warm standby) USB Safety Controller Safety Controller

36 Reconfiguration and State

37 Reconfiguration and State - Overview

38 Component Updates: An Algorithm Bring components into reconfigurable state Traversal of whole object graph Member-wise investigation of nodes using Reflection Investigation of each node for update Update specified via assembly mapping:  Specification of updated assemblies State transfer via member-wise close

39 Component State Transfer - I class People { public string Name; public People[] friends; public IAnimal animal; } enum Color{gray, black, white}; class Animal { string name; Color color; People[] likes; } People[ ] People1 People2 people3 People „Andre“ friends animal People „Christiane“ friends animal People „Torsten“ friends animal Animal „Wuffi“ Color:black likes Animal „Blacki“ Color:black likes root

40 Component Update State Transfer - II object UpdateObjectGraph(object node, Type type, Hashtable updateMapping) { Type newType = GetUpdate(type,updateMapping); if(newType!=null) object updatedNode = FormatterServices.GetUninitializedObject(newType); foreach(FieldInfo _field in type.GetFields()) { if(LeafNode(_field.GetValue(node),_field.GetValue(node).GetType()) { if(updatedNode!=null) _updatedField.SetValue(updatedNode,_field.GetValue(node)); } else if(updatedNode!=null) { _updatedField.SetValue(updatedNode,UpdateObjectGraph(_field.GetValue(node),_field.GetValue(node).GetType())); } else { _field.SetValue(node,UpdateObjectGraph(_field.GetValue(node),_field.GetValue(node).GetType())); } People „Torsten“ friends animal Animal „Blacki“ Color:black likes root Animal > Animal1.dll V 2.0 People root

41 Component Update State Transfer - II object UpdateObjectGraph(object node, Type type, Hashtable updateMapping) { Type newType = GetUpdate(type,updateMapping); if(newType!=null) object updatedNode = FormatterServices.GetUninitializedObject(newType); foreach(FieldInfo _field in type.GetFields()) { if(LeafNode(_field.GetValue(node),_field.GetValue(node).GetType()) { if(updatedNode!=null) _updatedField.SetValue(updatedNode,_field.GetValue(node)); } else if(updatedNode!=null) { _updatedField.SetValue(updatedNode,UpdateObjectGraph(_field.GetValue(node),_field.GetValue(node).GetType())); } else { _field.SetValue(node,UpdateObjectGraph(_field.GetValue(node),_field.GetValue(node).GetType())); } People „Torsten“ friends animal Animal „Blacki“ Color:black likes root Animal > Animal1.dll V 2.0

42 Component Update State Transfer - II object UpdateObjectGraph(object node, Type type, Hashtable updateMapping) { Type newType = GetUpdate(type,updateMapping); if(newType!=null) object updatedNode = FormatterServices.GetUninitializedObject(newType); foreach(FieldInfo _field in type.GetFields()) { if(LeafNode(_field.GetValue(node),_field.GetValue(node).GetType()) { if(updatedNode!=null) _updatedField.SetValue(updatedNode,_field.GetValue(node)); } else if(updatedNode!=null) { _updatedField.SetValue(updatedNode,UpdateObjectGraph(_field.GetValue(node),_field.GetValue(node).GetType())); } else { _field.SetValue(node,UpdateObjectGraph(_field.GetValue(node),_field.GetValue(node).GetType())); } People „Torsten“ friends animal Animal „Blacki“ Color:black likes root Animal.dll V 1.0: Animal.dll V 2.0 No Update here

43 Component Update State Transfer - II object UpdateObjectGraph(object node, Type type, Hashtable updateMapping) { Type newType = GetUpdate(type,updateMapping); if(newType!=null) object updatedNode = FormatterServices.GetUninitializedObject(newType); foreach(FieldInfo _field in type.GetFields()) { if(LeafNode(_field.GetValue(node),_field.GetValue(node).GetType()) { if(updatedNode!=null) _updatedField.SetValue(updatedNode,_field.GetValue(node)); } else if(updatedNode!=null) { _updatedField.SetValue(updatedNode,UpdateObjectGraph(_field.GetValue(node),_field.GetValue(node).GetType())); } else { _field.SetValue(node,UpdateObjectGraph(_field.GetValue(node),_field.GetValue(node).GetType())); } People „Torsten“ friends animal Animal „Blacki“ Color:black likes root Animal > Animal1.dll V 2.0 friends „Torsten“ animal object UpdateObjectGraph(object node, Type type, Hashtable updateMapping) { Type newType = GetUpdate(type,updateMapping); if(newType!=null) object updatedNode = FormatterServices.GetUninitializedObject(newType); foreach(FieldInfo _field in type.GetFields()) { if(LeafNode(_field.GetValue(node),_field.GetValue(node).GetType()) { if(updatedNode!=null) _updatedField.SetValue(updatedNode,_field.GetValue(node)); } else if(updatedNode!=null) { _updatedField.SetValue(updatedNode,UpdateObjectGraph(_field.GetValue(node),_field.GetValue(node).GetType())); } else { _field.SetValue(node,UpdateObjectGraph(_field.GetValue(node),_field.GetValue(node).GetType())); }

44 Component Update State Transfer - II object UpdateObjectGraph(object node, Type type, Hashtable updateMapping) { Type newType = GetUpdate(type,updateMapping); if(newType!=null) object updatedNode = FormatterServices.GetUninitializedObject(newType); foreach(FieldInfo _field in type.GetFields()) { if(LeafNode(_field.GetValue(node),_field.GetValue(node).GetType()) { if(updatedNode!=null) _updatedField.SetValue(updatedNode,_field.GetValue(node)); } else if(updatedNode!=null) { _updatedField.SetValue(updatedNode,UpdateObjectGraph(_field.GetValue(node),_field.GetValue(node).GetType())); } else { _field.SetValue(node,UpdateObjectGraph(_field.GetValue(node),_field.GetValue(node).GetType())); } People „Torsten“ friends animal Animal „Blacki“ Color:black likes root Animal > Animal1.dll V 2.0 animal Animal animal

45 Component Update State Transfer - II object UpdateObjectGraph(object node, Type type, Hashtable updateMapping) { Type newType = GetUpdate(type,updateMapping); if(newType!=null) object updatedNode = FormatterServices.GetUninitializedObject(newType); foreach(FieldInfo _field in type.GetFields()) { if(LeafNode(_field.GetValue(node),_field.GetValue(node).GetType()) { if(updatedNode!=null) _updatedField.SetValue(updatedNode,_field.GetValue(node)); } else if(updatedNode!=null) { _updatedField.SetValue(updatedNode,UpdateObjectGraph(_field.GetValue(node),_field.GetValue(node).GetType())); } else { _field.SetValue(node,UpdateObjectGraph(_field.GetValue(node),_field.GetValue(node).GetType())); } People „Torsten“ friends animal Animal „Blacki“ Color:black likes root Animal > Animal1.dll V 2.0 Animal V2

46 Component Update State Transfer - II object UpdateObjectGraph(object node, Type type, Hashtable updateMapping) { Type newType = GetUpdate(type,updateMapping); if(newType!=null) object updatedNode = FormatterServices.GetUninitializedObject(newType); foreach(FieldInfo _field in type.GetFields()) { if(LeafNode(_field.GetValue(node),_field.GetValue(node).GetType()) { if(updatedNode!=null) _updatedField.SetValue(updatedNode,_field.GetValue(node)); } else if(updatedNode!=null) { _updatedField.SetValue(updatedNode,UpdateObjectGraph(_field.GetValue(node),_field.GetValue(node).GetType())); } else { _field.SetValue(node,UpdateObjectGraph(_field.GetValue(node),_field.GetValue(node).GetType())); } People „Torsten“ friends animal Animal „Blacki“ Color:black likes root Animal > Animal1.dll V 2.0 Animal V2 „Blacki“ Color:black „Blacki“

47 Component Update State Transfer - II object UpdateObjectGraph(object node, Type type, Hashtable updateMapping) { Type newType = GetUpdate(type,updateMapping); if(newType!=null) object updatedNode = FormatterServices.GetUninitializedObject(newType); foreach(FieldInfo _field in type.GetFields()) { if(LeafNode(_field.GetValue(node),_field.GetValue(node).GetType()) { if(updatedNode!=null) _updatedField.SetValue(updatedNode,_field.GetValue(node)); } else if(updatedNode!=null) { _updatedField.SetValue(updatedNode,UpdateObjectGraph(_field.GetValue(node),_field.GetValue(node).GetType())); } else { _field.SetValue(node,UpdateObjectGraph(_field.GetValue(node),_field.GetValue(node).GetType())); } People „Torsten“ friends animal Animal „Blacki“ Color:black likes root Animal > Animal1.dll V 2.0 Animal V2 Color:black likes „Blacki“ Color:black

48 Component Update State Transfer - II object UpdateObjectGraph(object node, Type type, Hashtable updateMapping) { Type newType = GetUpdate(type,updateMapping); if(newType!=null) object updatedNode = FormatterServices.GetUninitializedObject(newType); foreach(FieldInfo _field in type.GetFields()) { if(LeafNode(_field.GetValue(node),_field.GetValue(node).GetType()) { if(updatedNode!=null) _updatedField.SetValue(updatedNode,_field.GetValue(node)); } else if(updatedNode!=null) { _updatedField.SetValue(updatedNode,UpdateObjectGraph(_field.GetValue(node),_field.GetValue(node).GetType())); } else { _field.SetValue(node,UpdateObjectGraph(_field.GetValue(node),_field.GetValue(node).GetType())); } People „Torsten“ friends animal root Animal > Animal1.dll V 2.0 Animal V2 Animal „Blacki“ Color:black likes Color:black „Blacki“ Color:black likes GC People root

49 Component Update State Transfer - II object UpdateObjectGraph(object node, Type type, Hashtable updateMapping) { Type newType = GetUpdate(type,updateMapping); if(newType!=null) object updatedNode = FormatterServices.GetUninitializedObject(newType); foreach(FieldInfo _field in type.GetFields()) { if(LeafNode(_field.GetValue(node),_field.GetValue(node).GetType()) { if(updatedNode!=null) _updatedField.SetValue(updatedNode,_field.GetValue(node)); } else if(updatedNode!=null) { _updatedField.SetValue(updatedNode,UpdateObjectGraph(_field.GetValue(node),_field.GetValue(node).GetType())); } else { _field.SetValue(node,UpdateObjectGraph(_field.GetValue(node),_field.GetValue(node).GetType())); } People „Torsten“ friends animal root Animal > Animal1.dll V 2.0 Animal V2 Animal „Blacki“ Color:black likes Color:black „Blacki“ Color:black likes GC Running in new version now

50 Component Update State Transfer III Cycle recognition – visited nodes: bool firstTime; long id = idGenerator.GetId(node,out firstTime); if(!firstTime) return visitedNodes[id]; Save updated nodes in visited nodes list Investigation of all arrays  Traverse all reference type members  Create new version in case of base-type update  Copy content of updated arrays

51 Component Update: Delegates Funtion pointers in.NET Traverse all targets of delegates Multicast delegates contain multiple delegates Updating multicast delegates:  Extract all delegates from multicast delegate  Create new versions: Delegate.CreateDelegate  Combine to new multicast delegate public abstract class Delegate { private System.Type target_type; private object m_target; private string method_name; private int method_ptr; }


Download ppt "Towards Self-Adaptive Software Dipl.-Inf. Andreas Rasche Hasso-Plattner-Institute University of Potsdam."

Similar presentations


Ads by Google