diff --git a/edu.kit.ipd.descartes.adaptation/src/edu/kit/ipd/descartes/adaptation/AdaptationControl.java b/edu.kit.ipd.descartes.adaptation/src/edu/kit/ipd/descartes/adaptation/AdaptationControl.java index 230d40d26c262c63cca90f01c92dcf4abc31da1c..5dc0abed24b6d17b30d95dde81349ecc7b4d5d7f 100644 --- a/edu.kit.ipd.descartes.adaptation/src/edu/kit/ipd/descartes/adaptation/AdaptationControl.java +++ b/edu.kit.ipd.descartes.adaptation/src/edu/kit/ipd/descartes/adaptation/AdaptationControl.java @@ -158,15 +158,11 @@ public class AdaptationControl { wFunction.updateWeight(tactic); } - - private void processResults(WeightedTactic tactic) { - // TODO Parse the new analysis results into the Performance Data - // Repository Impact latestImpact = PerfDataRepoHelper.getImpactAt(perfDataRepo, iteration); - // Connect parsed results to the executed tactic - tactic.setLastImpact(latestImpact); + if (latestImpact != null) + tactic.setLastImpact(latestImpact); } private void analyzeModel() { diff --git a/edu.kit.ipd.descartes.adaptation/src/edu/kit/ipd/descartes/adaptation/model/util/DmmModelChanger.java b/edu.kit.ipd.descartes.adaptation/src/edu/kit/ipd/descartes/adaptation/model/util/DmmModelChanger.java index c46f07f74b0978fe567ffbad2a1bbbbbaf364e14..00d1336cd5751a9c85d65403c23685389fcdaf33 100644 --- a/edu.kit.ipd.descartes.adaptation/src/edu/kit/ipd/descartes/adaptation/model/util/DmmModelChanger.java +++ b/edu.kit.ipd.descartes.adaptation/src/edu/kit/ipd/descartes/adaptation/model/util/DmmModelChanger.java @@ -21,11 +21,11 @@ import edu.kit.ipd.descartes.mm.adaptationpoints.ModelVariableConfigurationRange import edu.kit.ipd.descartes.mm.containerrepository.ContainerTemplate; import edu.kit.ipd.descartes.mm.resourceconfiguration.ConfigurationSpecification; import edu.kit.ipd.descartes.mm.resourceconfiguration.NumberOfParallelProcessingUnits; +import edu.kit.ipd.descartes.mm.resourceconfiguration.ResourceconfigurationPackage; import edu.kit.ipd.descartes.mm.resourcelandscape.Container; import edu.kit.ipd.descartes.mm.resourcelandscape.RuntimeEnvironment; public class DmmModelChanger { - /** * Denotes a Container as a copy of another by @@ -43,19 +43,22 @@ public class DmmModelChanger { */ public static void scaleModelVariable(ModelVariableConfigurationRange range, AdaptationDirection direction) throws OperationNotPerformedException { - scaleModelVariable(range.getAdaptableEntity(), range, direction); + + switch (range.getAdaptableEntity().eClass().getClassifierID()) { + case ResourceconfigurationPackage.NUMBER_OF_PARALLEL_PROCESSING_UNITS: + adaptNumberOfCores(range.getAdaptableEntity(), range, direction); + break; + default: + logger.error("SCALING THIS TYPE OF MODEL VARIABLE HAS NOT BEEN IMPLEMENTED YET!"); + break; + } } - - private static void scaleModelVariable(AdaptableEntity adaptedEntity, ModelVariableConfigurationRange range, AdaptationDirection direction) - throws OperationNotPerformedException { - /* - * TODO: 1) Find all subtypes of AdaptableEntity 2) Add switch/case logic to instantiate the - * correct class - */ - // Here I assume that I found the correct class + + private static void adaptNumberOfCores(AdaptableEntity adaptedEntity, ModelVariableConfigurationRange range, + AdaptationDirection direction) throws OperationNotPerformedException { NumberOfParallelProcessingUnits adaptableModelEntity = (NumberOfParallelProcessingUnits) adaptedEntity; Entity containingEntity = (Entity) adaptableModelEntity.getProcessingResourceSpec().getParentResourceSpecification().eContainer(); - + Integer currentValue = adaptableModelEntity.getNumber(); Integer maxValue = (int) Math.floor(range.getMaxValue()); Integer minValue = (int) Math.ceil(range.getMinValue()); @@ -167,14 +170,14 @@ public class DmmModelChanger { container = pickRandomReferringContainer(actuallyConfiguredInstance); break; case LEAST_UTILIZED_FIRST: - logger.error("NOT IMPLEMENTED YET"); // TODO + logger.error("NOT IMPLEMENTED YET"); break; case MOST_UTILIZED_FIRST: - logger.error("NOT IMPLEMENTED YET"); // TODO + logger.error("NOT IMPLEMENTED YET"); break; default: logger.error("No adaptation operation defined for " + scope.getLiteral() + ", " - + direction.getLiteral()); // TODO + + direction.getLiteral()); break; } if (container != null) @@ -237,7 +240,7 @@ public class DmmModelChanger { if (changedElement != null && changedElement instanceof AdaptableEntity) { AdaptableEntity adaptableEntity = (AdaptableEntity) changedElement; try { - scaleModelVariable(adaptableEntity, range, direction); + adaptNumberOfCores(adaptableEntity, range, direction); // in case operation was not executed, e.g. because min was reached } catch (OperationNotPerformedException e) { //undo copy of config spec diff --git a/edu.kit.ipd.descartes.adaptation/src/edu/kit/ipd/descartes/adaptation/util/PerfDataRepoHelper.java b/edu.kit.ipd.descartes.adaptation/src/edu/kit/ipd/descartes/adaptation/util/PerfDataRepoHelper.java index 1848c10125b8df3111f57ccdd6a12d19786c0678..beced5ec0010a2ddd9cb7b4f0ffae4aee0fc4b1b 100644 --- a/edu.kit.ipd.descartes.adaptation/src/edu/kit/ipd/descartes/adaptation/util/PerfDataRepoHelper.java +++ b/edu.kit.ipd.descartes.adaptation/src/edu/kit/ipd/descartes/adaptation/util/PerfDataRepoHelper.java @@ -38,9 +38,8 @@ public class PerfDataRepoHelper { */ public static Impact getImpactAt(PerformanceDataRepository perfDataRepo, int position) { EList<Impact> impactHistory = perfDataRepo.getImpactHistory(); - // FIXME: Add more data to PerfDataRepo if (position > impactHistory.size() - 1) - return impactHistory.get(0); + return null; return impactHistory.get(position); } }