Search in sources :

Example 11 with ResourceContainer

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);
    }
}
Also used : ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud) ComputeService(org.jclouds.compute.ComputeService) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 12 with ResourceContainer

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);
    }
}
Also used : ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud) ComputeService(org.jclouds.compute.ComputeService) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 13 with ResourceContainer

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;
}
Also used : ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 14 with ResourceContainer

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());
    }
}
Also used : ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud) ComputeService(org.jclouds.compute.ComputeService) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 15 with ResourceContainer

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);
}
Also used : URL(java.net.URL) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer) Before(org.junit.Before)

Aggregations

ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)35 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)16 LinkingResource (org.palladiosimulator.pcm.resourceenvironment.LinkingResource)8 Test (org.junit.Test)7 AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)7 ResourceContainerCloud (org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud)6 ComputeService (org.jclouds.compute.ComputeService)5 Allocation (org.palladiosimulator.pcm.allocation.Allocation)5 AssemblyContext (org.palladiosimulator.pcm.core.composition.AssemblyContext)5 URL (java.net.URL)3 ContainerAllocationEvent (org.iobserve.common.record.ContainerAllocationEvent)3 UnknownObjectException (java.rmi.activation.UnknownObjectException)2 ArrayList (java.util.ArrayList)2 SystemadaptationFactory (org.iobserve.planning.systemadaptation.SystemadaptationFactory)2 ProcessingResourceSpecification (org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification)2 System (org.palladiosimulator.pcm.system.System)2 File (java.io.File)1 URI (org.eclipse.emf.common.util.URI)1 DDiagramElement (org.eclipse.sirius.diagram.DDiagramElement)1 DEdge (org.eclipse.sirius.diagram.DEdge)1