use of org.iobserve.adaptation.data.graph.ComponentNode in project iobserve-analysis by research-iobserve.
the class AdaptationCalculation method compareComponents.
private void compareComponents(final Set<ComponentNode> components) {
for (final ComponentNode reDeplComp : components) {
final ComponentNode runComp = this.runtimeComponentNodes.get(reDeplComp.getAssemblyContextID());
if (runComp == null) {
// Replicate, since ID does not yet exits
final AssemblyContextAction action = AssemblyContextActionFactory.generateReplicateAction(runComp, reDeplComp);
this.acActions.add(action);
} else if (!runComp.equals(reDeplComp)) {
// Components differ, so check what actions need to be done!
if (!runComp.getRepositoryComponentID().equals(reDeplComp.getRepositoryComponentID())) {
// AssemblyContexts contain different RepositoryComponents
final AssemblyContextAction action = AssemblyContextActionFactory.generateChangeRepositoryComponentAction(runComp, reDeplComp);
this.acActions.add(action);
}
if (!runComp.getHostServer().getResourceContainerID().equals(reDeplComp.getHostServer().getResourceContainerID())) {
// AssemblyContexts are hosted on different Servers
final AssemblyContextAction action = AssemblyContextActionFactory.generateMigrateAction(runComp, reDeplComp);
this.acActions.add(action);
}
}
this.runtimeComponentNodes.remove(reDeplComp.getAssemblyContextID(), runComp);
}
for (final ComponentNode runComp : this.runtimeComponentNodes.values()) {
// AssemblyContext does not exist anymore in redeployment model!
final AssemblyContextAction action = AssemblyContextActionFactory.generateDereplicateAction(runComp);
this.acActions.add(action);
}
}
use of org.iobserve.adaptation.data.graph.ComponentNode in project iobserve-analysis by research-iobserve.
the class AtomicActionComputationTest method testReplicateAction2AtomicActions.
/**
* replicate action conversion to atomic actions.
*
* @throws Exception
* on internal errors
*/
@Test
public void testReplicateAction2AtomicActions() throws Exception {
final SystemAdaptation systemAdaptationModel = SystemadaptationFactory.eINSTANCE.createSystemAdaptation();
final ExecutionPlan executionPlan;
final ComponentNode runtimeNode;
final ComponentNode redeploymentNode;
final ReplicateAction replicateAction;
// Replication specific setup
this.redeploymentModel.replicateCompBToRc2();
this.initializeModelGraphs();
runtimeNode = this.findComponentNodeByID(this.runtimeModel.getAlcxtBRc1().getId(), this.runtimeModelGraph.getComponents());
redeploymentNode = this.findComponentNodeByID(this.redeploymentModel.getAlcxtBRc2().getId(), this.redeploymentModelGraph.getComponents());
replicateAction = AssemblyContextActionFactory.generateReplicateAction(runtimeNode, redeploymentNode);
systemAdaptationModel.getActions().add(replicateAction);
// Execute stage
executionPlan = this.executeStage(systemAdaptationModel);
// Basic verification
Assert.assertThat(executionPlan.getActions().size(), Matchers.is(3));
Assert.assertTrue(executionPlan.getActions().get(0) instanceof DeployComponentAction);
Assert.assertTrue(executionPlan.getActions().get(1) instanceof MigrateComponentStateAction);
Assert.assertTrue(executionPlan.getActions().get(2) instanceof ConnectComponentAction);
}
use of org.iobserve.adaptation.data.graph.ComponentNode in project iobserve-analysis by research-iobserve.
the class ComposedActionComputationTest method testChangeRepositoryRule.
/**
* Test change repository rule.
*
* @throws Exception
* on internal errors.
*/
@Test
public void testChangeRepositoryRule() throws Exception {
final AdaptationData adaptationData;
final ComponentNode runtimeNode;
final ComponentNode redeploymentNode;
final SystemAdaptation actualOutput;
final ChangeRepositoryComponentAction actualAction;
final ChangeRepositoryComponentAction expectedAction;
// Perform change of component
this.redeploymentModel.changeRepositoryCompBxToCompBy();
adaptationData = this.createAdaptationData();
// Create expected output
runtimeNode = this.findComponentNodeByID(this.runtimeModel.getAlcxtBRc1().getId(), adaptationData.getRuntimeGraph().getComponents());
redeploymentNode = this.findComponentNodeByID(this.redeploymentModel.getAlcxtBRc1().getId(), adaptationData.getReDeploymentGraph().getComponents());
expectedAction = AssemblyContextActionFactory.generateChangeRepositoryComponentAction(runtimeNode, redeploymentNode);
// Execute stage
actualOutput = this.executeStage(adaptationData);
Assert.assertThat(actualOutput.getActions().size(), Matchers.is(1));
Assert.assertTrue(actualOutput.getActions().get(0) instanceof ChangeRepositoryComponentAction);
actualAction = (ChangeRepositoryComponentAction) actualOutput.getActions().get(0);
Assert.assertThat(actualAction.getTargetAllocationContext(), Matchers.is(expectedAction.getTargetAllocationContext()));
Assert.assertThat(actualAction.getTargetProvidingAllocationContexts(), Matchers.is(expectedAction.getTargetProvidingAllocationContexts()));
Assert.assertThat(actualAction.getTargetRequiringAllocationContexts(), Matchers.is(expectedAction.getTargetRequiringAllocationContexts()));
Assert.assertThat(actualAction.getSourceAllocationContext(), Matchers.is(expectedAction.getSourceAllocationContext()));
}
use of org.iobserve.adaptation.data.graph.ComponentNode in project iobserve-analysis by research-iobserve.
the class ComposedActionComputationTest method testDereplicationRule.
/**
* Test de-replication.
*
* @throws Exception
* on internal errors
*/
@Test
public void testDereplicationRule() throws Exception {
final AdaptationData adaptationData;
final ComponentNode runtimeNode;
final SystemAdaptation actualOutput;
final DereplicateAction actualAction;
final DereplicateAction expectedAction;
// Perform dereplication (simulated by replicating a component in the runtime model)
this.runtimeModel.replicateCompBToRc2();
adaptationData = this.createAdaptationData();
// Create expected output
runtimeNode = this.findComponentNodeByID(this.runtimeModel.getAlcxtBRc2().getId(), adaptationData.getRuntimeGraph().getComponents());
expectedAction = AssemblyContextActionFactory.generateDereplicateAction(runtimeNode);
// Execute stage
actualOutput = this.executeStage(adaptationData);
Assert.assertThat(actualOutput.getActions().size(), Matchers.is(1));
Assert.assertTrue(actualOutput.getActions().get(0) instanceof DereplicateAction);
actualAction = (DereplicateAction) actualOutput.getActions().get(0);
Assert.assertThat(actualAction.getTargetAllocationContext(), Matchers.is(expectedAction.getTargetAllocationContext()));
Assert.assertThat(actualAction.getTargetProvidingAllocationContexts(), Matchers.is(expectedAction.getTargetProvidingAllocationContexts()));
Assert.assertThat(actualAction.getTargetRequiringAllocationContexts(), Matchers.is(expectedAction.getTargetRequiringAllocationContexts()));
}
use of org.iobserve.adaptation.data.graph.ComponentNode in project iobserve-analysis by research-iobserve.
the class AtomicActionComputationTest method testDereplicateAction2AtomicActions.
/**
* dereplicate action conversion to atomic actions.
*
* @throws Exception
* on internal errors
*/
@Test
public void testDereplicateAction2AtomicActions() throws Exception {
final SystemAdaptation systemAdaptationModel = SystemadaptationFactory.eINSTANCE.createSystemAdaptation();
final ExecutionPlan executionPlan;
final ComponentNode runtimeNode;
final DereplicateAction dereplicateAction;
// Dereplication specific setup (simulated by replicating a component in the runtime model)
this.runtimeModel.replicateCompBToRc2();
this.initializeModelGraphs();
runtimeNode = this.findComponentNodeByID(this.runtimeModel.getAlcxtBRc1().getId(), this.runtimeModelGraph.getComponents());
dereplicateAction = AssemblyContextActionFactory.generateDereplicateAction(runtimeNode);
systemAdaptationModel.getActions().add(dereplicateAction);
// Execute stage
executionPlan = this.executeStage(systemAdaptationModel);
// Basic verification
Assert.assertThat(executionPlan.getActions().size(), Matchers.is(4));
Assert.assertTrue(executionPlan.getActions().get(0) instanceof BlockRequestsToComponentAction);
Assert.assertTrue(executionPlan.getActions().get(1) instanceof FinishComponentAction);
Assert.assertTrue(executionPlan.getActions().get(2) instanceof DisconnectComponentAction);
Assert.assertTrue(executionPlan.getActions().get(3) instanceof UndeployComponentAction);
}
Aggregations