layers first (Line 1). Until the queue becomes empty,
we keep on executing a loop to spread the changes.
In each iteration, we take one layer i out from the
queue, synchronize the current state m
0
i
at layer to
its two neighbors. If the transformation result m is
not the same as the input m
0
j
, then it means that the
layer j is not stable yet, and we put it into the queue.
Thanks to the Harmlessness property of bidirectional
transformation, if a layer model already embeds the
modifications from another layer, the transformation
will keep the model state unchanged. In this way, the
spread process will not fall into an endless loop, and
we will finally reach a stable set of model states. After
that, we evaluate the constraints on each model, and
find the violated ones to fill the mismatch set.
Adaptation is implemented as a semi-automated
loop, which ends until the mismatch sets from all the
layers are empty, or all the left mismatches are marked
as ignored by administrators (Line 8).
Inside the main loop, we first try to resolve the
mismatches that have fixing logic (Lines 9-12). For
such a mismatch, we execute its fixing logic and get
a new model state m
◦
i
(Line 11), and spread this new
modification to the neighboring layers (Line 16-22).
Inside the spread procedure, we first re-evaluate the
constraint, in order to delete the resolved mismatches
and see if new ones are introduced (Line 17). After
that, we use bidirectional transformation to synchro-
nize the modification result m
◦
i
with the newest state
of the neighboring model m
◦
j
(Line 19). If the result is
different, then it means that the modification on layer
i has influence on layer j. Thus we re-evaluate the
constraints on j, and update Msm
j
. In this way, we
will remove the mismatches that are resolved by the
modification on another layer, and also record the new
mismatches on the remote modification.
When a set of mismatches are resolved automati-
cally, we provide the remaining mismatches to the ad-
ministrators. The invocation to ManualAdaptation
on Line 13 will be blocked until any administrator on
any layer perform a modification. The process will
continue with the modified model state captured by
m
◦
i
, and the mismatches ignored by the administra-
tor recorded in Ign
i
. After that, we will do the same
spread approach as for the automated adaptation.
After an adaptation (automated or manual), the
subsequent spread procedure presents effects as fol-
lows. 1) If two mismatches from two layers i and j
describes the same system fault, then the transforma-
tion of the adaptation result on i will no long cause the
original mismatches on j, and thus the mismatches
caused by the same source do not need to be resolved
twice. 2) If the adaptation on one layer i requires
the complementary modifications on other one j, the
evaluation on the transformation result m
o
j
will add
new mismatches to the mismatch set Msm
j
to indicate
the required complement modification. If a new mis-
match has a fix logic, the required modification will
be automatically performed, otherwise, the mismatch
will be a hint for further manual adaptation to com-
plete the modification. 3) If an adaptation on one layer
i is illegal because its complementary modification on
another layer j (say msm
j
) cannot be resolved, then
the administrator will have to ignore j, without any
modification. In this situation, the backward transfor-
mation from j to i will roll the model state back on i,
and throw the original mismatch again. This tells the
administrator on layer i that his adaptation has failed.
The Undoability property of bidirectional transforma-
tion (Stevens, 2007) guarantees that such unsuccess-
ful adaptation can be clearly rolled back.
5 EVALUATION
5.1 The CMS Case Study
We implemented the approach on a simulated crisis
management system. The simulation had the similar
function and structure as described by Popescu et al.
(Popescu et al., 2012). For the sake of simplicity, we
implemented it based on the Spring platform
4
. In the
Business Layer, the processes were specified and ex-
ecuted based on Apache Camel
5
. The activities and
lanes mapped to the end points and routes in Camel,
and the delegation was defined as the reference from
an end point to another route. In the Service Layer,
we implement the services as Java Beans, Servlets,
or by the workflows defined by Camel (the services
that maps to lanes). The services were specified in
the Spring configuration files, which also embedded
the registration relation. Finally, in the Infrastructure
layer, the Beans and Servlets were running Tomcat
servers.
We implemented the approach based on the
Eclipse Modeling Framework (EMF
6
). We repre-
sented the information from each layer as an EMF
model, and implemented a simple runtime model en-
gine to maintain the causal connection: For the higher
two layers, the engine translates XML configuration
files to EMF model, and vice versa, and for the infras-
tructure layer, the engine retrieves and updates system
state via server APIs and configuration files. Based
on the EMF runtime model, we implemented the con-
4
http://www.springsource.org
5
http://camel.apache.org
6
http://www.eclipse.org/modeling/emf/
ModelDrivenEngineeringofCross-LayerMonitoringandAdaptation
337