Search in sources :

Example 26 with ResourceContainer

use of org.palladiosimulator.pcm.resourceenvironment.ResourceContainer in project iobserve-analysis by research-iobserve.

the class AllocationModification method modifyAllocationFixTerminations.

/**
 * @param terminatedResContainers
 * @return
 */
public int modifyAllocationFixTerminations(final List<ResourceContainer> terminatedResContainers) {
    int migrationsMade = 0;
    for (final ResourceContainer terminatedResCon : terminatedResContainers) {
        if (this.resContainer2AllocationContext.containsKey(terminatedResCon.getId())) {
            for (final AllocationContext allocation : this.resContainer2AllocationContext.get(terminatedResCon.getId())) {
                this.migrateToRandomResourceContainer(allocation);
                migrationsMade++;
            }
        }
    }
    return migrationsMade;
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 27 with ResourceContainer

use of org.palladiosimulator.pcm.resourceenvironment.ResourceContainer in project iobserve-analysis by research-iobserve.

the class AllocationModification method migrateToRandomResourceContainer.

/*
     *
     */
private void migrateToRandomResourceContainer(final AllocationContext allocation) {
    final int randomIndex = ThreadLocalRandom.current().nextInt(this.resContainer.length);
    final ResourceContainer replaceResCon = this.resContainer[randomIndex];
    allocation.setResourceContainer_AllocationContext(replaceResCon);
}
Also used : ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 28 with ResourceContainer

use of org.palladiosimulator.pcm.resourceenvironment.ResourceContainer in project iobserve-analysis by research-iobserve.

the class ResourceEnvironmentModification method modifyResEnvTerminate.

/**
 * @param terminations
 * @return
 */
public List<ResourceContainer> modifyResEnvTerminate(final int terminations) {
    final List<ResourceContainer> removedResourceContainers = new ArrayList<>();
    final EList<ResourceContainer> resourceContainers = this.resourceEnvironment.getResourceContainer_ResourceEnvironment();
    for (int i = 0; i < terminations; i++) {
        final int randomIndex = ThreadLocalRandom.current().nextInt(resourceContainers.size());
        final ResourceContainer removedResCon = resourceContainers.remove(randomIndex);
        removedResourceContainers.add(removedResCon);
        if (ResourceEnvironmentModification.LOGGER.isInfoEnabled()) {
            ResourceEnvironmentModification.LOGGER.info("REMOVING: \tResourceContainer: \t" + removedResCon.getId());
        }
    }
    return removedResourceContainers;
}
Also used : ArrayList(java.util.ArrayList) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 29 with ResourceContainer

use of org.palladiosimulator.pcm.resourceenvironment.ResourceContainer in project iobserve-analysis by research-iobserve.

the class AllocationFinishedStage method execute.

/**
 * Forwards the deployment event after the allocation is finished.
 *
 * @throws Exception
 *             exception
 */
@Override
protected void execute() throws Exception {
    final ResourceContainer resourceContainer = this.allocationFinishedInputPort.receive();
    final PCMDeployedEvent deployedEvent = this.deployedInputPort.receive();
    if (resourceContainer != null) {
        this.allocations.add(resourceContainer);
    }
    if (deployedEvent != null) {
        this.deployments.add(deployedEvent);
    }
    if (this.allocations.size() > 0 && this.deployments.size() > 0) {
        final PCMDeployedEvent deployed = this.deployments.poll();
        deployed.setResourceContainer(resourceContainer);
        this.deployedOutputPort.send(deployed);
    }
}
Also used : PCMDeployedEvent(org.iobserve.analysis.deployment.data.PCMDeployedEvent) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 30 with ResourceContainer

use of org.palladiosimulator.pcm.resourceenvironment.ResourceContainer in project iobserve-analysis by research-iobserve.

the class AllocationStage method execute.

/**
 * This method is triggered for every allocation event.
 *
 * @param event
 *            one allocation event to be processed
 * @throws MalformedURLException
 *             malformed url exception
 * @throws UnknownObjectException
 *             in case the allocation event is of an unknown type
 */
@Override
protected void execute(final IAllocationEvent event) throws MalformedURLException, UnknownObjectException {
    final URL url;
    if (event instanceof ContainerAllocationEvent) {
        url = new URL(((ContainerAllocationEvent) event).getUrl());
    } else {
        throw new UnknownObjectException(event.getClass() + " is not supported by the allocation filter.");
    }
    final String hostName = url.getHost();
    final Optional<ResourceContainer> resourceContainer = ResourceEnvironmentModelFactory.getResourceContainerByName(this.resourceEnvironmentModelGraphProvider.readOnlyRootComponent(ResourceEnvironment.class), hostName);
    if (!resourceContainer.isPresent()) {
        /**
         * new provider: update the resource environment graph.
         */
        final ResourceEnvironment resourceEnvironmentModelGraph = this.resourceEnvironmentModelGraphProvider.readOnlyRootComponent(ResourceEnvironment.class);
        final ResourceContainer newResourceContainer = ResourceEnvironmentModelFactory.createResourceContainer(resourceEnvironmentModelGraph, hostName);
        resourceEnvironmentModelGraph.getResourceContainer_ResourceEnvironment().add(newResourceContainer);
        this.resourceEnvironmentModelGraphProvider.updateComponent(ResourceEnvironment.class, resourceEnvironmentModelGraph);
        /**
         * signal allocation update.
         */
        this.allocationNotifyOutputPort.send(newResourceContainer);
        this.allocationOutputPort.send(event);
    } else {
        /**
         * error allocation already happened.
         */
        this.logger.debug("ResourceContainer %s was available." + hostName);
        final List<ProcessingResourceSpecification> procResSpec = resourceContainer.get().getActiveResourceSpecifications_ResourceContainer();
        for (int i = 0; i < procResSpec.size(); i++) {
            final String nodeGroupName = procResSpec.get(i).getActiveResourceType_ActiveResourceSpecification().getEntityName();
            this.logger.debug(nodeGroupName);
        }
        /**
         * Notify with existing container.
         */
        this.allocationNotifyOutputPort.send(resourceContainer.get());
    }
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) ContainerAllocationEvent(org.iobserve.common.record.ContainerAllocationEvent) ProcessingResourceSpecification(org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification) UnknownObjectException(java.rmi.activation.UnknownObjectException) URL(java.net.URL) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

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