Skip to content
Snippets Groups Projects
Commit 7d79a9bc authored by Nikolaus Huber's avatar Nikolaus Huber
Browse files

refactorings to delete also the last runtimeenvironment referred by an adaptation point

git-svn-id: https://se1.informatik.uni-wuerzburg.de/usvn/svn/code/code/DMM/trunk@12328 9e42b895-fcda-4063-8a3b-11be15eb1bbd
parent 570a5ef6
No related branches found
No related tags found
No related merge requests found
......@@ -36,6 +36,7 @@ public class AdaptationControl {
private static final String PROP_ADAPTATION_PROCESS_NAME = "process.name";
private static final String PROP_MAX_ITERATIONS = "process.maxiterations";
private static final String PROP_TRIGGERING_EVENT_TYPE = "event.type";
private static final String PROP_QOS_DEGRADATION = "qosdegradation.accept";
private static Logger logger = Logger.getLogger(AdaptationControl.class);
......@@ -54,6 +55,7 @@ public class AdaptationControl {
private int iteration = 0;
private int maxIterations = 0;
private boolean qosDegradationAcceptable = false;
private Event cause;
/**
......@@ -148,7 +150,7 @@ public class AdaptationControl {
* @return
*/
public boolean isObjectiveFulfilled() {
logger.debug("Checking if objective is fulfilled...");
logger.debug("Checking if objective <<" + cause.getTriggers().getObjective().getName() + ">> is fulfilled...");
boolean flag = ObjectivesHelper.isObjectiveFulfilled(cause, perfDataRepoHandler.getCurrentSystemState());
if (flag)
logger.info("Problem that caused event " + cause.getName() + " has been solved, Objective is fulfilled.");
......@@ -201,8 +203,13 @@ public class AdaptationControl {
// and/or assign bad weight.
if (evaluator.slaViolated(tactic)) {
logger.warn("QoS degradation detected after applying tactic " + tactic.getName());
executor.undoPreviousTactic();
evaluator.punishTactic(tactic);
if (qosDegradationAcceptable) {
logger.debug("QoS degradation is acceptable!");
} else {
logger.debug("Undoing previous tactic because of QoS degradation");
executor.undoPreviousTactic();
evaluator.punishTactic(tactic);
}
} else {
evaluator.evaluate(tactic);
}
......@@ -234,6 +241,7 @@ public class AdaptationControl {
adaptationProcessXmiFilePath = properties.getProperty(PROP_ADAPTATION_PROCESS_XMI_FILE_PATH_NAME);
performanceDataRepoXmiFilePath = properties.getProperty(PROP_PERF_DATA_REPO_XMI_FILE_PATH_NAME);
maxIterations = Integer.parseInt(properties.getProperty(PROP_MAX_ITERATIONS));
qosDegradationAcceptable = Boolean.parseBoolean(properties.getProperty(PROP_QOS_DEGRADATION));
eventType = properties.getProperty(PROP_TRIGGERING_EVENT_TYPE).trim();
logger.debug("Maximum iterations till abort: " + maxIterations);
}
......
......@@ -258,8 +258,7 @@ public class DmmModelActionHandler implements IActionHandler {
}
private Entity scaleInContainerTemplate(ContainerTemplate template) {
Container referringContainer = template.getReferringContainers().get(
template.getReferringContainers().size() - 1);
Container referringContainer = template.getReferringContainers().get(0);
RuntimeEnvironment removedRe = null;
if (referringContainer != null && referringContainer instanceof RuntimeEnvironment) {
removedRe = DmmModelChanger.scaleInRuntimeEnvironmentInstance((RuntimeEnvironment) referringContainer);
......
......@@ -91,6 +91,29 @@ public class DmmModelActionHelper {
return null;
}
public static RuntimeEnvironment filterRuntimeEnvironment(List<RuntimeEnvironment> candidates,
RuntimeEnvironment comparatorRE) {
// Filter RE with copy mark first
RuntimeEnvironment reWithCopyMark = filterCopiedRuntimeEnvironment(candidates, comparatorRE);
if (reWithCopyMark != null) {
return reWithCopyMark;
} else {
// If there is no copy mark, filter an RE with different ID
for (RuntimeEnvironment re : candidates) {
if (re.getId() != comparatorRE.getId()
// && EcoreUtil.equals(comparatorRE.getConfigSpec(), re.getConfigSpec())
// && EcoreUtil.equals(comparatorRE.getContainedIn(), re.getContainedIn())
&& EcoreUtil.equals(comparatorRE.getTemplate(), re.getTemplate())) {
return re;
}
}
}
// If no matches have been found, return the comparator element
return comparatorRE;
}
public static NamedElement findEntityWithName(NamedElement element, String name) {
if (element.getName().equals(name))
......@@ -161,7 +184,8 @@ public class DmmModelActionHelper {
* @return All Container Instances referring to the same ContainerTemplate
*/
public static List<Container> queryContainersWithSimilarTemplate(Container container) {
String queryExpression = "RuntimeEnvironment.allInstances()->select( re | re.template = self.template and re.id <> self.id)";
// String queryExpression = "RuntimeEnvironment.allInstances()->select( re | re.template = self.template and re.id <> self.id)";
String queryExpression = "RuntimeEnvironment.allInstances()->select( re | re.template = self.template)";
List<EObject> tempList = new ArrayList<EObject>(OclEvaluationHelper.query(container, queryExpression,
container.eClass()));
List<Container> resultList = new ArrayList<Container>(tempList.size());
......@@ -196,25 +220,27 @@ public class DmmModelActionHelper {
*
* @param containerTemplate
* @param adaptationScope
* @param targets
* @param targets
* @return
*/
public static Container findSuitableContainer(ContainerTemplate containerTemplate, AdaptationScope adaptationScope, VariationType targets) {
public static Container findSuitableContainer(ContainerTemplate containerTemplate, AdaptationScope adaptationScope,
VariationType targets) {
// Get all containers referring to the template
List<Container> containers = containerTemplate.getReferringContainers();
List<Entity> variants = ((SetOfConfigurations) targets).getVariants();
// Prepare the list of migration targets
List<Container> migrationTargets = new ArrayList<Container>();
for (Entity entity : variants) {
migrationTargets.add((Container) entity);
}
for (Container container : containers) {
// Remove container from migration targets
List<Container> migrationTargetCandidates = excludeSelfContainmentFromTargetList(container, migrationTargets);
List<Container> migrationTargetCandidates = excludeSelfContainmentFromTargetList(container,
migrationTargets);
// If there are migration targets left
if (migrationTargetCandidates.size() > 0) {
switch (adaptationScope) {
......
......@@ -101,7 +101,7 @@ public class DmmModelChanger {
public static RuntimeEnvironment scaleInRuntimeEnvironmentInstance(RuntimeEnvironment runtimeEnvironment) {
List<Container> similarContainers = DmmModelActionHelper.queryContainersWithSimilarTemplate(runtimeEnvironment);
List<RuntimeEnvironment> containedEntities = DmmModelActionHelper.filterAndConvertRuntimeEnvironment(similarContainers);
RuntimeEnvironment similarEntity = DmmModelActionHelper.filterCopiedRuntimeEnvironment(containedEntities, runtimeEnvironment);
RuntimeEnvironment similarEntity = DmmModelActionHelper.filterRuntimeEnvironment(containedEntities, runtimeEnvironment);
if (similarEntity != null) {
runtimeEnvironment.getTemplate().getReferringContainers().remove(similarEntity);
similarEntity.getContainedIn().getContains().remove(similarEntity);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment