Search in sources :

Example 26 with AllocationContext

use of org.palladiosimulator.pcm.allocation.AllocationContext in project iobserve-analysis by research-iobserve.

the class AllocationModelFactory method addAllocationContext.

/**
 * Add an {@link AllocationContext} for the given {@link ResourceContainer} and
 * {@link AssemblyContext} if they are absent to this model. No check for duplication is done!
 *
 * @param model
 *            allocation model
 * @param resContainer
 *            container
 * @param asmCtx
 *            assembly context
 */
public static void addAllocationContext(final Allocation model, final ResourceContainer resContainer, final AssemblyContext asmCtx) {
    final AllocationFactory factory = AllocationFactory.eINSTANCE;
    final AllocationContext allocationCtx = factory.createAllocationContext();
    allocationCtx.setEntityName(asmCtx.getEntityName());
    allocationCtx.setAssemblyContext_AllocationContext(asmCtx);
    allocationCtx.setResourceContainer_AllocationContext(resContainer);
    model.getAllocationContexts_Allocation().add(allocationCtx);
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) AllocationFactory(org.palladiosimulator.pcm.allocation.AllocationFactory)

Example 27 with AllocationContext

use of org.palladiosimulator.pcm.allocation.AllocationContext in project iobserve-analysis by research-iobserve.

the class AllocationGeneration method generateAllocationContext.

/*
     *
     */
private AllocationContext generateAllocationContext(final AssemblyContext assemblyContext) {
    final AllocationContext allocationContext = AllocationGeneration.ALLOCATION_FACTORY.createAllocationContext();
    allocationContext.setAssemblyContext_AllocationContext(assemblyContext);
    final int randomIndex = ThreadLocalRandom.current().nextInt(this.resContainer.length);
    allocationContext.setResourceContainer_AllocationContext(this.resContainer[randomIndex]);
    allocationContext.setEntityName(assemblyContext.getEntityName() + " @ " + this.resContainer[randomIndex].getEntityName());
    return allocationContext;
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext)

Example 28 with AllocationContext

use of org.palladiosimulator.pcm.allocation.AllocationContext in project iobserve-analysis by research-iobserve.

the class AllocationModification method initResContainer2AllocationContext.

private void initResContainer2AllocationContext() {
    this.resContainer2AllocationContext = new HashMap<>();
    this.assemblyCon2AllocationContext = new HashMap<>();
    for (final AllocationContext ac : this.allocationModel.getAllocationContexts_Allocation()) {
        final ResourceContainer resCon = ac.getResourceContainer_AllocationContext();
        if (!this.resContainer2AllocationContext.containsKey(resCon.getId())) {
            this.resContainer2AllocationContext.put(resCon.getId(), new LinkedList<AllocationContext>());
        }
        this.resContainer2AllocationContext.get(resCon.getId()).add(ac);
        final AssemblyContext assemblyCon = ac.getAssemblyContext_AllocationContext();
        if (!this.assemblyCon2AllocationContext.containsKey(assemblyCon.getId())) {
            this.assemblyCon2AllocationContext.put(assemblyCon.getId(), ac);
        } else {
            throw new RuntimeException("An assembly context was found twice during assembly context analysis!");
        }
    }
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 29 with AllocationContext

use of org.palladiosimulator.pcm.allocation.AllocationContext 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 30 with AllocationContext

use of org.palladiosimulator.pcm.allocation.AllocationContext in project iobserve-analysis by research-iobserve.

the class AllocationModification method modifyAllocationMigrate.

/**
 * @param migarions
 * @return
 */
public int modifyAllocationMigrate(final int migarions) {
    int migrationsMade = 0;
    final Set<AllocationContext> usedAllocationContexts = new HashSet<>();
    final EList<AllocationContext> allocationContexts = this.allocationModel.getAllocationContexts_Allocation();
    for (int i = 0; i < migarions; i++) {
        AllocationContext ac = null;
        for (int j = 0; ac != null && j < allocationContexts.size() * 10; j++) {
            final int randomIndex = ThreadLocalRandom.current().nextInt(allocationContexts.size());
            if (!usedAllocationContexts.contains(allocationContexts.get(randomIndex))) {
                ac = allocationContexts.get(randomIndex);
            }
            if (ac != null) {
                this.migrateToRandomResourceContainer(ac);
                migrationsMade++;
            }
        }
    }
    return migrationsMade;
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) HashSet(java.util.HashSet)

Aggregations

AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)48 AssemblyContext (org.palladiosimulator.pcm.core.composition.AssemblyContext)16 Set (java.util.Set)11 OperationSignature (org.palladiosimulator.pcm.repository.OperationSignature)11 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)11 HashSet (java.util.HashSet)10 HashMap (java.util.HashMap)9 Allocation (org.palladiosimulator.pcm.allocation.Allocation)9 Test (org.junit.Test)7 LinkedHashSet (java.util.LinkedHashSet)4 ProbeManagementData (org.iobserve.service.privacy.violation.data.ProbeManagementData)4 Edge (org.iobserve.service.privacy.violation.transformation.analysisgraph.Edge)4 DBException (org.iobserve.model.persistence.DBException)3 InvocationException (org.iobserve.model.persistence.neo4j.InvocationException)3 ControlEventCreationFailedException (org.iobserve.service.privacy.violation.exceptions.ControlEventCreationFailedException)3 Vertex (org.iobserve.service.privacy.violation.transformation.analysisgraph.Vertex)3 RepositoryComponent (org.palladiosimulator.pcm.repository.RepositoryComponent)3 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)3 LinkedList (java.util.LinkedList)2 AllocationEntry (org.iobserve.model.correspondence.AllocationEntry)2