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 { ...@@ -36,6 +36,7 @@ public class AdaptationControl {
private static final String PROP_ADAPTATION_PROCESS_NAME = "process.name"; private static final String PROP_ADAPTATION_PROCESS_NAME = "process.name";
private static final String PROP_MAX_ITERATIONS = "process.maxiterations"; private static final String PROP_MAX_ITERATIONS = "process.maxiterations";
private static final String PROP_TRIGGERING_EVENT_TYPE = "event.type"; 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); private static Logger logger = Logger.getLogger(AdaptationControl.class);
...@@ -54,6 +55,7 @@ public class AdaptationControl { ...@@ -54,6 +55,7 @@ public class AdaptationControl {
private int iteration = 0; private int iteration = 0;
private int maxIterations = 0; private int maxIterations = 0;
private boolean qosDegradationAcceptable = false;
private Event cause; private Event cause;
/** /**
...@@ -148,7 +150,7 @@ public class AdaptationControl { ...@@ -148,7 +150,7 @@ public class AdaptationControl {
* @return * @return
*/ */
public boolean isObjectiveFulfilled() { 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()); boolean flag = ObjectivesHelper.isObjectiveFulfilled(cause, perfDataRepoHandler.getCurrentSystemState());
if (flag) if (flag)
logger.info("Problem that caused event " + cause.getName() + " has been solved, Objective is fulfilled."); logger.info("Problem that caused event " + cause.getName() + " has been solved, Objective is fulfilled.");
...@@ -201,8 +203,13 @@ public class AdaptationControl { ...@@ -201,8 +203,13 @@ public class AdaptationControl {
// and/or assign bad weight. // and/or assign bad weight.
if (evaluator.slaViolated(tactic)) { if (evaluator.slaViolated(tactic)) {
logger.warn("QoS degradation detected after applying tactic " + tactic.getName()); logger.warn("QoS degradation detected after applying tactic " + tactic.getName());
executor.undoPreviousTactic(); if (qosDegradationAcceptable) {
evaluator.punishTactic(tactic); logger.debug("QoS degradation is acceptable!");
} else {
logger.debug("Undoing previous tactic because of QoS degradation");
executor.undoPreviousTactic();
evaluator.punishTactic(tactic);
}
} else { } else {
evaluator.evaluate(tactic); evaluator.evaluate(tactic);
} }
...@@ -234,6 +241,7 @@ public class AdaptationControl { ...@@ -234,6 +241,7 @@ public class AdaptationControl {
adaptationProcessXmiFilePath = properties.getProperty(PROP_ADAPTATION_PROCESS_XMI_FILE_PATH_NAME); adaptationProcessXmiFilePath = properties.getProperty(PROP_ADAPTATION_PROCESS_XMI_FILE_PATH_NAME);
performanceDataRepoXmiFilePath = properties.getProperty(PROP_PERF_DATA_REPO_XMI_FILE_PATH_NAME); performanceDataRepoXmiFilePath = properties.getProperty(PROP_PERF_DATA_REPO_XMI_FILE_PATH_NAME);
maxIterations = Integer.parseInt(properties.getProperty(PROP_MAX_ITERATIONS)); maxIterations = Integer.parseInt(properties.getProperty(PROP_MAX_ITERATIONS));
qosDegradationAcceptable = Boolean.parseBoolean(properties.getProperty(PROP_QOS_DEGRADATION));
eventType = properties.getProperty(PROP_TRIGGERING_EVENT_TYPE).trim(); eventType = properties.getProperty(PROP_TRIGGERING_EVENT_TYPE).trim();
logger.debug("Maximum iterations till abort: " + maxIterations); logger.debug("Maximum iterations till abort: " + maxIterations);
} }
......
...@@ -258,8 +258,7 @@ public class DmmModelActionHandler implements IActionHandler { ...@@ -258,8 +258,7 @@ public class DmmModelActionHandler implements IActionHandler {
} }
private Entity scaleInContainerTemplate(ContainerTemplate template) { private Entity scaleInContainerTemplate(ContainerTemplate template) {
Container referringContainer = template.getReferringContainers().get( Container referringContainer = template.getReferringContainers().get(0);
template.getReferringContainers().size() - 1);
RuntimeEnvironment removedRe = null; RuntimeEnvironment removedRe = null;
if (referringContainer != null && referringContainer instanceof RuntimeEnvironment) { if (referringContainer != null && referringContainer instanceof RuntimeEnvironment) {
removedRe = DmmModelChanger.scaleInRuntimeEnvironmentInstance((RuntimeEnvironment) referringContainer); removedRe = DmmModelChanger.scaleInRuntimeEnvironmentInstance((RuntimeEnvironment) referringContainer);
......
...@@ -91,6 +91,29 @@ public class DmmModelActionHelper { ...@@ -91,6 +91,29 @@ public class DmmModelActionHelper {
return null; 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) { public static NamedElement findEntityWithName(NamedElement element, String name) {
if (element.getName().equals(name)) if (element.getName().equals(name))
...@@ -161,7 +184,8 @@ public class DmmModelActionHelper { ...@@ -161,7 +184,8 @@ public class DmmModelActionHelper {
* @return All Container Instances referring to the same ContainerTemplate * @return All Container Instances referring to the same ContainerTemplate
*/ */
public static List<Container> queryContainersWithSimilarTemplate(Container container) { 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, List<EObject> tempList = new ArrayList<EObject>(OclEvaluationHelper.query(container, queryExpression,
container.eClass())); container.eClass()));
List<Container> resultList = new ArrayList<Container>(tempList.size()); List<Container> resultList = new ArrayList<Container>(tempList.size());
...@@ -196,25 +220,27 @@ public class DmmModelActionHelper { ...@@ -196,25 +220,27 @@ public class DmmModelActionHelper {
* *
* @param containerTemplate * @param containerTemplate
* @param adaptationScope * @param adaptationScope
* @param targets * @param targets
* @return * @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 // Get all containers referring to the template
List<Container> containers = containerTemplate.getReferringContainers(); List<Container> containers = containerTemplate.getReferringContainers();
List<Entity> variants = ((SetOfConfigurations) targets).getVariants(); List<Entity> variants = ((SetOfConfigurations) targets).getVariants();
// Prepare the list of migration targets // Prepare the list of migration targets
List<Container> migrationTargets = new ArrayList<Container>(); List<Container> migrationTargets = new ArrayList<Container>();
for (Entity entity : variants) { for (Entity entity : variants) {
migrationTargets.add((Container) entity); migrationTargets.add((Container) entity);
} }
for (Container container : containers) { for (Container container : containers) {
// Remove container from migration targets // Remove container from migration targets
List<Container> migrationTargetCandidates = excludeSelfContainmentFromTargetList(container, migrationTargets); List<Container> migrationTargetCandidates = excludeSelfContainmentFromTargetList(container,
migrationTargets);
// If there are migration targets left // If there are migration targets left
if (migrationTargetCandidates.size() > 0) { if (migrationTargetCandidates.size() > 0) {
switch (adaptationScope) { switch (adaptationScope) {
......
...@@ -101,7 +101,7 @@ public class DmmModelChanger { ...@@ -101,7 +101,7 @@ public class DmmModelChanger {
public static RuntimeEnvironment scaleInRuntimeEnvironmentInstance(RuntimeEnvironment runtimeEnvironment) { public static RuntimeEnvironment scaleInRuntimeEnvironmentInstance(RuntimeEnvironment runtimeEnvironment) {
List<Container> similarContainers = DmmModelActionHelper.queryContainersWithSimilarTemplate(runtimeEnvironment); List<Container> similarContainers = DmmModelActionHelper.queryContainersWithSimilarTemplate(runtimeEnvironment);
List<RuntimeEnvironment> containedEntities = DmmModelActionHelper.filterAndConvertRuntimeEnvironment(similarContainers); List<RuntimeEnvironment> containedEntities = DmmModelActionHelper.filterAndConvertRuntimeEnvironment(similarContainers);
RuntimeEnvironment similarEntity = DmmModelActionHelper.filterCopiedRuntimeEnvironment(containedEntities, runtimeEnvironment); RuntimeEnvironment similarEntity = DmmModelActionHelper.filterRuntimeEnvironment(containedEntities, runtimeEnvironment);
if (similarEntity != null) { if (similarEntity != null) {
runtimeEnvironment.getTemplate().getReferringContainers().remove(similarEntity); runtimeEnvironment.getTemplate().getReferringContainers().remove(similarEntity);
similarEntity.getContainedIn().getContains().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