use of org.palladiosimulator.pcm.resourceenvironment.ResourceContainer in project iobserve-analysis by research-iobserve.
the class DeallocateActionScript method execute.
@Override
public void execute() throws RunScriptOnNodesException, IOException {
final ResourceContainer container = this.action.getOldAllocationContext().getResourceContainer_AllocationContext();
final ResourceContainerCloud cloudContainer = this.getResourceContainerCloud(container);
final ComputeService client = this.getComputeServiceForContainer(cloudContainer);
final String assemblyContextName = this.action.getSourceAssemblyContext().getEntityName();
// nothing
if (!this.data.getDeallocatedContexts().contains(assemblyContextName)) {
client.runScriptOnNodesMatching(node -> node.getGroup().equals(cloudContainer.getGroupName()), this.getDeallocateScript(this.action.getSourceAssemblyContext()));
this.data.getDeallocatedContexts().add(assemblyContextName);
}
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceContainer in project iobserve-analysis by research-iobserve.
the class MigrateActionScript method execute.
@Override
public void execute() throws RunScriptOnNodesException {
final ResourceContainer sourceContainer = this.action.getSourceAllocationContext().getResourceContainer_AllocationContext();
final ResourceContainer targetContainer = this.action.getNewAllocationContext().getResourceContainer_AllocationContext();
final ResourceContainerCloud sourceCloudContainer = this.getResourceContainerCloud(sourceContainer);
final ResourceContainerCloud targetCloudContainer = this.getResourceContainerCloud(targetContainer);
final ComputeService client = this.getComputeServiceForContainer(sourceCloudContainer);
final String assemblyContextName = this.action.getSourceAssemblyContext().getEntityName();
// If the assembly context has already been migrated, do nothing
if (!this.data.getMigratedContexts().contains(assemblyContextName)) {
client.runScriptOnNodesMatching(node -> node.getGroup().equals(sourceCloudContainer.getGroupName()), this.getScript(AdaptationData.PRE_MIGRATE_SCRIPT_NAME, this.action.getSourceAssemblyContext()));
client.runScriptOnNodesMatching(node -> node.getGroup().equals(targetCloudContainer.getGroupName()), this.getScript(AdaptationData.POST_MIGRATE_SCRIPT_NAME, this.action.getSourceAssemblyContext()));
// TODO add possibility to open up ports defined in a config file
this.data.getMigratedContexts().add(assemblyContextName);
}
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceContainer in project iobserve-analysis by research-iobserve.
the class ResourceEnvironmentDataFactory method createResourceContainer.
private static ResourceContainer createResourceContainer() {
/**
* optional test resource container with value
*/
final ResourceContainer container = ResourceenvironmentFactory.eINSTANCE.createResourceContainer();
container.setEntityName(ResourceEnvironmentDataFactory.RESOURCE_CONTAINER_NAME);
container.setId(ResourceEnvironmentDataFactory.RESOURCE_CONAINTER_ID);
return container;
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceContainer in project iobserve-analysis by research-iobserve.
the class TerminateActionScript method execute.
@Override
public void execute() throws RunScriptOnNodesException {
final ResourceContainer container = this.action.getSourceResourceContainer();
final ResourceContainerCloud cloudContainer = this.getResourceContainerCloud(container);
final ComputeService client = this.getComputeServiceForContainer(cloudContainer);
// If the container group has already been terminated, do nothing
if (!this.data.getTerminatedGroups().contains(ModelHelper.getGroupName(cloudContainer))) {
client.runScriptOnNodesMatching(node -> node.getGroup().equals(cloudContainer.getGroupName()), this.getScript(AdaptationData.NODE_PRE_TERMINATE_SCRIPT_NAME));
client.destroyNodesMatching(node -> node.getGroup().equals(cloudContainer.getGroupName()));
this.data.getTerminatedGroups().add(cloudContainer.getGroupName());
}
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceContainer in project iobserve-analysis by research-iobserve.
the class AllocationVisualizationStageTest method setupAndInitServer.
/**
* Initialize test data and stub necessary method calls.
*
* @throws MalformedURLException
* if the creation of the URL fails.
*/
@Before
public void setupAndInitServer() throws MalformedURLException {
final URL changelogURL = new URL("http://" + AllocationVisualizationStageTest.OUTPUT_HOSTNAME + ":" + AllocationVisualizationStageTest.OUTPUT_PORT + "/v1/systems/" + AllocationVisualizationStageTest.SYSTEM_ID + "/changelogs");
this.allocationVisualizationStage = new AllocationVisualizationStage(changelogURL, AllocationVisualizationStageTest.SYSTEM_ID);
/**
* list of test resource container
*/
final ResourceContainer testResourceContainer = ResourceenvironmentFactory.eINSTANCE.createResourceContainer();
testResourceContainer.setEntityName("test_nodeName");
testResourceContainer.setId("test_nodeId");
this.testResourceContainerList.add(testResourceContainer);
/**
* input events
*/
this.inputEvents.add(testResourceContainer);
// stubbing
Mockito.when(this.mockedResourceContainerModelProvider.readOnlyComponentByName(ResourceContainer.class, AllocationVisualizationStageTest.SERVICE)).thenReturn(this.testResourceContainerList);
}
Aggregations