use of org.iobserve.analysis.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) {
// Allocate, since ID does not yet exits
final AssemblyContextAction action = AssemblyContextActionFactory.generateAllocateAction(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.generateDeallocateAction(runComp);
this.acActions.add(action);
}
}
use of org.iobserve.analysis.data.graph.ComponentNode in project iobserve-analysis by research-iobserve.
the class ResourceContainerActionFactory method createReplicateAction.
/**
* Create replicate action.
*
* @param runtimeServer
* source server
* @param reDeploymentServer
* target server
* @return the action
*/
public static ReplicateAction createReplicateAction(final DeploymentNode runtimeServer, final DeploymentNode reDeploymentServer) {
final SystemadaptationFactory factory = SystemadaptationFactory.eINSTANCE;
final ReplicateAction action = factory.createReplicateAction();
ResourceContainerActionFactory.setSourceResourceContainer(action, runtimeServer.getResourceContainerID());
final Allocation runtimeAllocModel = ActionFactory.getRuntimeModels().getAllocationModel();
for (final ComponentNode component : runtimeServer.getContainingComponents()) {
final AllocationContext oldAllocationContext = ActionFactory.getAllocationContext(component.getAllocationContextID(), runtimeAllocModel);
action.getSourceAllocationContext().add(oldAllocationContext);
}
final Allocation reDeplAllocModel = ActionFactory.getRedeploymentModels().getAllocationModel();
for (final ComponentNode component : reDeploymentServer.getContainingComponents()) {
final AllocationContext newAllocationContext = ActionFactory.getAllocationContext(component.getAllocationContextID(), reDeplAllocModel);
action.getSourceAllocationContext().add(newAllocationContext);
}
final ResourceEnvironment resEnvModel = ActionFactory.getRedeploymentModels().getResourceEnvironmentModel();
final ResourceContainer newResourceContainer = ActionFactory.getResourceContainer(reDeploymentServer.getResourceContainerID(), resEnvModel);
action.setNewResourceContainer(newResourceContainer);
return action;
}
Aggregations