Towards Self-Adaptive Software Dipl.-Inf. Andreas Rasche Hasso-Plattner-Institute University of...
-
Upload
eric-douglas -
Category
Documents
-
view
219 -
download
0
Transcript of Towards Self-Adaptive Software Dipl.-Inf. Andreas Rasche Hasso-Plattner-Institute University of...
Towards Self-Adaptive
SoftwareDipl.-Inf. Andreas Rasche
Hasso-Plattner-Institute
University of Potsdam
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
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
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
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)
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]
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
Adaptation: Building Blocks
ObservationMonitoring
React on Changes
• Environment- Network, CPU, Battery
• Component properties• Component behavior
• Reconfiguration• Parameter • Architecture• Data
• Profiles - Map Conditions to According Configurations
Adaptation
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]
Adaptive Control Systems cont. Closed-loop adaptation Self-tuning controller (Kalman `58)
[Sastry and Bodson “Adaptive Control: Stability, Convergence, and Robustness”, 1994]
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
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
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
Configuration Infrastructure
Configuration Manager
XML-
Configuration
Description
IConfigure
IConfigure
IConfigureIConfigure
Monitoring
AdaptationProfile
AdaptationEngine
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 components4. Setting changed component parameters5. Reconnecting components (create connectors)6. Restarting component processing7. Removing old components
Dynamic Reconfiguration
A
B
C
compression=30
Configuration Manager
Configuration 2
XML-Description
1
D
2Create
new Component
3 Calculate Connections to block
Read
Dynamic Reconfiguration
A
B
Configuration Manager
Configuration 2
XML-Description
1
D
Read
C
compression=30
Dynamic Reconfiguration
A
B
Configuration Manager
Configuration 2
XML-Description
1
D
Read
C
compression=30
Block Connection
4
5
Block new connectionsWait for on-going to complete
6
Reconfigurable State
Dynamic Reconfiguration
A
B
Configuration Manager
Configuration 2
XML-Description
1
D
Read
C
compression=30
7
Reconnect A7
Connect D
Dynamic Reconfiguration
A
B
Configuration Manager
Configuration 2
XML-Description
1
D
Read
C
compression=30
8 Restart processing
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 interfaceblocked=false;Release(block_semaphore);
int a = 3;
int b = 5;
Transaction.Begin();
b = calc.Add(1,b);
a = calc.Sub(a,b);
Transaction.End();
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
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
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); }}
Configurable Components Loom.Net Aspect Codeusing 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; }
...}
Configuration Annotations
public class Counter : MarshalByRefObject{
[Property] // Configuration Hookprivate 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);
}}
}
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
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
The Component Configurator -abstracting away CORBA, Java, and .NET
IIOP .NET Remoting Channel Protocol
Mon
itorin
g
CoC
o F
act
ory
Tra
nsa
ctio
nM
ana
ger
Adaption & ConfigurationService
CoFRA
Transaction HandlingAssembly DeploymentReconfiguration Engine
Adaptation EngineMonitoring
CoFRA
Transaction HandlingMonitoring
C1CORBA
C2.NET
Remoting
C4simpleobject
C3simpleobject
IIOP .NET Remoting local
CoCo CoCo CoCoCoCo
.NET RemotingJacorb Janeva .NET Remoting
Java/Corba .NET
Java .NET
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
Pendulum Experiment Control Configurations
USB-Driver
Event Queuing
SafetyController
UserProgram
Event Duplicator
UserProgram
Configuration 1 : safety controller
Configuration 2 : user program (cold standby)
Configuration 3 : user program (warm standby)
USB
SafetyController
SafetyController
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
Component State Transfer - Iclass 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
Component Update State Transfer - IIobject 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
Component Update State Transfer - IIobject 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
Component Update State Transfer - IIobject 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
Component Update State Transfer - IIobject 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())); } }}
Component Update State Transfer - IIobject 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
Component Update State Transfer - IIobject 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
Component Update State Transfer - IIobject 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“
„Blacki“
Color:blackColor:black
Color:black
„Blacki“
Component Update State Transfer - IIobject 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
likes
„Blacki“
Color:black
Component Update State Transfer - IIobject 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
Component Update State Transfer - IIobject 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
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
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;}