Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import de.fakeller.palladio.builder.EntityHierarchicalBuilder;
import de.fakeller.palladio.builder.repository.seff.ResourceDemandBuilder;
import de.fakeller.palladio.builder.util.random.RandomVariable;
import org.palladiosimulator.pcm.repository.BasicComponent;
import org.palladiosimulator.pcm.seff.ServiceEffectSpecification;

Expand All @@ -24,4 +25,13 @@ public interface ComponentBuilder extends EntityHierarchicalBuilder<ComponentBui
* Creates a {@link ServiceEffectSpecification} for the provided operation.
*/
ResourceDemandBuilder<ComponentBuilder> withServiceEffectSpecification(SignatureBuilder affectedOperation);

/**
* Adds a passive resource to the component.
*/
PassiveResourceBuilder withPassiveResource(final String name);

default PassiveResourceBuilder withPassiveResource(final String name, final RandomVariable capacity) {
return withPassiveResource(name).withCapacity(capacity);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package de.fakeller.palladio.builder.repository;

import de.fakeller.palladio.builder.EntityHierarchicalBuilder;
import de.fakeller.palladio.builder.util.random.RandomVariable;
import org.palladiosimulator.pcm.repository.PassiveResource;

/**
* Allows to add {@link PassiveResource}s to a {@link ComponentBuilder}.
*/
public interface PassiveResourceBuilder extends EntityHierarchicalBuilder<PassiveResourceBuilder, PassiveResource, ComponentBuilder> {

PassiveResourceBuilder withCapacity(RandomVariable capacity);
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package de.fakeller.palladio.builder.repository.impl;

import de.fakeller.palladio.builder.AbstractHierarchicalBuilder;
import de.fakeller.palladio.builder.repository.ComponentBuilder;
import de.fakeller.palladio.builder.repository.InterfaceBuilder;
import de.fakeller.palladio.builder.repository.RepositoryBuilder;
import de.fakeller.palladio.builder.repository.SignatureBuilder;
import de.fakeller.palladio.builder.repository.*;
import de.fakeller.palladio.builder.repository.seff.ResourceDemandBuilder;
import de.fakeller.palladio.builder.repository.seff.impl.ResourceDemandBuilderImpl;
import org.palladiosimulator.pcm.repository.BasicComponent;
Expand Down Expand Up @@ -64,4 +61,9 @@ public ResourceDemandBuilder<ComponentBuilder> withServiceEffectSpecification(fi
// todo: assert that affected operation is provided by an interface of this component
return ResourceDemandBuilderImpl.rootResourceDemand(this, affectedOperation);
}

@Override
public PassiveResourceBuilder withPassiveResource(final String name) {
return new PassiveResourceBuilderImpl(this).withEntityName(name);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package de.fakeller.palladio.builder.repository.impl;

import de.fakeller.palladio.builder.AbstractHierarchicalBuilder;
import de.fakeller.palladio.builder.repository.ComponentBuilder;
import de.fakeller.palladio.builder.repository.PassiveResourceBuilder;
import de.fakeller.palladio.builder.util.random.RandomVariable;
import org.palladiosimulator.pcm.repository.PassiveResource;
import org.palladiosimulator.pcm.repository.RepositoryFactory;

/**
* @author Fabian Keller
*/
public class PassiveResourceBuilderImpl extends AbstractHierarchicalBuilder<PassiveResourceBuilder, PassiveResource, ComponentBuilder> implements PassiveResourceBuilder {

PassiveResourceBuilderImpl(final ComponentBuilder belongsTo) {
super(belongsTo);
}

@Override
protected PassiveResource newEModel() {
return RepositoryFactory.eINSTANCE.createPassiveResource();
}

@Override
protected void registerParent() {
this.eModel.setBasicComponent_PassiveResource(this.belongsTo.getReference());
this.belongsTo.getReference().getPassiveResource_BasicComponent().add(this.eModel);
}


@Override
public PassiveResourceBuilder withCapacity(final RandomVariable capacity) {
this.eModel.setCapacity_PassiveResource(capacity.get());
return this;
}

@Override
public ComponentBuilder end() {
return this.belongsTo;
}

@Override
public PassiveResource getReference() {
return this.eModel;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package de.fakeller.palladio.builder.repository.seff;

import de.fakeller.palladio.builder.EntityHierarchicalBuilder;
import de.fakeller.palladio.builder.repository.seff.impl.LoopBuilderImpl;
import de.fakeller.palladio.builder.util.random.RandomVariable;
import org.palladiosimulator.pcm.seff.LoopAction;

/**
* Used to build {@link LoopAction}s. A loop action allows to loop the nested resource demand builder for the specified
* number of times.
*/
public interface LoopBuilder<P extends ResourceDemandBuilder<?>> extends EntityHierarchicalBuilder<LoopBuilder<P>, LoopAction, P> {

LoopBuilderImpl<P> withIterationCount(final RandomVariable iterationCount);

ResourceDemandBuilder<LoopBuilder<P>> withLoopBody();
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ default BranchBuilder<ResourceDemandBuilder<PARENT>> branch(final String name) {
return branch().withEntityName(name);
}

LoopBuilder<ResourceDemandBuilder<PARENT>> loop();

default LoopBuilder<ResourceDemandBuilder<PARENT>> loop(final String name) {
return loop().withEntityName(name);
}

ResourceDemandBuilder<PARENT> stop();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import de.fakeller.palladio.builder.repository.seff.BranchBuilder;
import de.fakeller.palladio.builder.repository.seff.ResourceDemandBuilder;
import de.fakeller.palladio.builder.util.RandomVariableFactory;
import de.fakeller.palladio.builder.util.random.RandomVariableFactory;
import org.palladiosimulator.pcm.seff.BranchAction;
import org.palladiosimulator.pcm.seff.GuardedBranchTransition;
import org.palladiosimulator.pcm.seff.SeffFactory;
Expand All @@ -22,7 +22,7 @@ public ResourceDemandBuilder<BranchBuilder<PARENT>> createBranch(final String na
// create branch object for new branch
final GuardedBranchTransition curBranch = SeffFactory.eINSTANCE.createGuardedBranchTransition();
curBranch.setEntityName(name);
curBranch.setBranchCondition_GuardedBranchTransition(RandomVariableFactory.expression(branchConditionExpression));
curBranch.setBranchCondition_GuardedBranchTransition(RandomVariableFactory.factory().expression(branchConditionExpression).get());
// link model
curBranch.setBranchAction_AbstractBranchTransition(this.eModel);
this.eModel.getBranches_Branch().add(curBranch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import de.fakeller.palladio.builder.repository.failure.SoftwareInducedFailureBuilder;
import de.fakeller.palladio.builder.repository.seff.InternalActionBuilder;
import de.fakeller.palladio.builder.repository.seff.ResourceDemandBuilder;
import de.fakeller.palladio.builder.util.RandomVariableFactory;
import de.fakeller.palladio.builder.util.random.RandomVariableFactory;
import de.fakeller.palladio.environment.util.PalladioResourceRepository;
import org.palladiosimulator.pcm.reliability.InternalFailureOccurrenceDescription;
import org.palladiosimulator.pcm.reliability.ReliabilityFactory;
Expand Down Expand Up @@ -44,7 +44,7 @@ private InternalActionBuilder<PARENT> withDemand(final ProcessingResourceType re
// create model
final ParametricResourceDemand prd = SeffPerformanceFactory.eINSTANCE.createParametricResourceDemand();
prd.setRequiredResource_ParametricResourceDemand(resourceType);
prd.setSpecification_ParametericResourceDemand(RandomVariableFactory.expression(demandSpecification));
prd.setSpecification_ParametericResourceDemand(RandomVariableFactory.factory().expression(demandSpecification).get());

// link model
prd.setAction_ParametricResourceDemand(this.eModel);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package de.fakeller.palladio.builder.repository.seff.impl;

import de.fakeller.palladio.builder.repository.seff.LoopBuilder;
import de.fakeller.palladio.builder.repository.seff.ResourceDemandBuilder;
import de.fakeller.palladio.builder.util.random.RandomVariable;
import org.palladiosimulator.pcm.seff.LoopAction;
import org.palladiosimulator.pcm.seff.SeffFactory;

/**
* @author Fabian Keller
*/
public class LoopBuilderImpl<PARENT extends ResourceDemandBuilder<?>> implements LoopBuilder<PARENT> {

private final PARENT belongsTo;
private final LoopAction eModel;

public LoopBuilderImpl(final PARENT belongsTo) {
this.belongsTo = belongsTo;
this.eModel = SeffFactory.eINSTANCE.createLoopAction();
}

@Override
public LoopBuilderImpl<PARENT> withIterationCount(final RandomVariable iterationCount) {
this.eModel.setIterationCount_LoopAction(iterationCount.get());
return this;
}

@Override
public ResourceDemandBuilder<LoopBuilder<PARENT>> withLoopBody() {
// create nested resource demanding behavior
final ResourceDemandBuilder<LoopBuilder<PARENT>> nested = ResourceDemandBuilderImpl.nestedResourceDemand(this);
// link nested model
this.eModel.setBodyBehaviour_Loop(nested.getReference());
nested.getReference().setAbstractLoopAction_ResourceDemandingBehaviour(this.eModel);

return nested;
}

@Override
public PARENT end() {
return this.belongsTo;
}

@Override
public LoopAction getReference() {
return this.eModel;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
import de.fakeller.palladio.builder.BuilderException;
import de.fakeller.palladio.builder.repository.ComponentBuilder;
import de.fakeller.palladio.builder.repository.SignatureBuilder;
import de.fakeller.palladio.builder.repository.seff.BranchBuilder;
import de.fakeller.palladio.builder.repository.seff.ExternalCallBuilder;
import de.fakeller.palladio.builder.repository.seff.InternalActionBuilder;
import de.fakeller.palladio.builder.repository.seff.ResourceDemandBuilder;
import de.fakeller.palladio.builder.repository.seff.*;
import org.palladiosimulator.pcm.seff.AbstractAction;
import org.palladiosimulator.pcm.seff.ResourceDemandingBehaviour;
import org.palladiosimulator.pcm.seff.ResourceDemandingSEFF;
Expand Down Expand Up @@ -123,6 +120,14 @@ public BranchBuilder<ResourceDemandBuilder<PARENT>> branch() {
return builder;
}

@Override
public LoopBuilder<ResourceDemandBuilder<PARENT>> loop() {
assertPredecessor();
final LoopBuilderImpl<ResourceDemandBuilder<PARENT>> builder = new LoopBuilderImpl<>(this);
enqueueAction(builder.getReference());
return builder;
}


// // BUILDER API METHODS // //

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import de.fakeller.palladio.builder.resourceenvironment.ContainerBuilder;
import de.fakeller.palladio.builder.resourceenvironment.LinkBuilder;
import de.fakeller.palladio.builder.resourceenvironment.ResourceEnvironmentBuilder;
import de.fakeller.palladio.builder.util.RandomVariableFactory;
import de.fakeller.palladio.builder.util.random.RandomVariableFactory;
import de.fakeller.palladio.environment.util.PalladioResourceRepository;
import org.palladiosimulator.pcm.core.PCMRandomVariable;
import org.palladiosimulator.pcm.resourceenvironment.CommunicationLinkResourceSpecification;
Expand Down Expand Up @@ -51,14 +51,14 @@ public LinkBuilder between(final ContainerBuilder... containers) {

@Override
public LinkBuilder withLatency(final double latency) {
final PCMRandomVariable rnd = RandomVariableFactory.fromDouble(latency);
final PCMRandomVariable rnd = RandomVariableFactory.factory().fromDouble(latency).get();
this.spec.setLatency_CommunicationLinkResourceSpecification(rnd);
return this;
}

@Override
public LinkBuilder withThroughput(final double throughput) {
final PCMRandomVariable rnd = RandomVariableFactory.fromDouble(throughput);
final PCMRandomVariable rnd = RandomVariableFactory.factory().fromDouble(throughput).get();
this.spec.setThroughput_CommunicationLinkResourceSpecification(rnd);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import de.fakeller.palladio.builder.resourceenvironment.ContainerBuilder;
import de.fakeller.palladio.builder.resourceenvironment.ProcessingResourceBuilder;
import de.fakeller.palladio.builder.util.RandomVariableFactory;
import de.fakeller.palladio.builder.util.random.RandomVariableFactory;
import de.fakeller.palladio.environment.util.PalladioResourceRepository;
import org.palladiosimulator.pcm.core.PCMRandomVariable;
import org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification;
Expand Down Expand Up @@ -30,7 +30,7 @@ public ProcessingResourceBuilderImpl(final ContainerBuilder belongsTo) {

@Override
public ProcessingResourceBuilder withProcessingRate(final double processingRate) {
final PCMRandomVariable rnd = RandomVariableFactory.fromDouble(processingRate);
final PCMRandomVariable rnd = RandomVariableFactory.factory().fromDouble(processingRate).get();
this.eModel.setProcessingRate_ProcessingResourceSpecification(rnd);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.fakeller.palladio.builder.usage;

import de.fakeller.palladio.builder.EntityHierarchicalBuilder;
import de.fakeller.palladio.builder.util.random.RandomVariable;
import org.palladiosimulator.pcm.usagemodel.UsageScenario;

/**
Expand All @@ -11,4 +12,6 @@ public interface ScenarioBuilder extends EntityHierarchicalBuilder<ScenarioBuild
BehaviourBuilder withBehaviour();

ScenarioBuilder withOpenWorkload(double interArrivalTime);

ScenarioBuilder withClosedWorkload(final int population, final RandomVariable thinkTime);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import de.fakeller.palladio.builder.usage.BehaviourBuilder;
import de.fakeller.palladio.builder.usage.ScenarioBuilder;
import de.fakeller.palladio.builder.usage.UsageBuilder;
import de.fakeller.palladio.builder.util.RandomVariableFactory;
import de.fakeller.palladio.builder.util.random.RandomVariable;
import de.fakeller.palladio.builder.util.random.RandomVariableFactory;
import org.palladiosimulator.pcm.usagemodel.ClosedWorkload;
import org.palladiosimulator.pcm.usagemodel.OpenWorkload;
import org.palladiosimulator.pcm.usagemodel.UsageScenario;
import org.palladiosimulator.pcm.usagemodel.UsagemodelFactory;
Expand Down Expand Up @@ -45,7 +47,21 @@ public BehaviourBuilder withBehaviour() {
public ScenarioBuilder withOpenWorkload(final double interArrivalTime) {
// create model
final OpenWorkload wl = UsagemodelFactory.eINSTANCE.createOpenWorkload();
wl.setInterArrivalTime_OpenWorkload(RandomVariableFactory.exp(interArrivalTime));
wl.setInterArrivalTime_OpenWorkload(RandomVariableFactory.factory().exp(interArrivalTime).get());

// link model
this.eModel.setWorkload_UsageScenario(wl);
wl.setUsageScenario_Workload(this.eModel);

return this;
}

@Override
public ScenarioBuilder withClosedWorkload(final int population, final RandomVariable thinkTime) {
// create model
final ClosedWorkload wl = UsagemodelFactory.eINSTANCE.createClosedWorkload();
wl.setPopulation(population);
wl.setThinkTime_ClosedWorkload(thinkTime.get());

// link model
this.eModel.setWorkload_UsageScenario(wl);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package de.fakeller.palladio.builder.util.impl;

import de.fakeller.palladio.builder.util.RandomVariableFactory;
import de.fakeller.palladio.builder.util.VariableUsageFactory;
import de.fakeller.palladio.builder.util.random.RandomVariableFactory;
import de.uka.ipd.sdq.stoex.StoexFactory;
import de.uka.ipd.sdq.stoex.VariableReference;
import org.palladiosimulator.pcm.parameter.ParameterFactory;
Expand All @@ -20,7 +20,7 @@ public VariableUsage valueUsage(final String variableName, final String specific
// create characterisation
characterisation.setType(VariableCharacterisationType.VALUE);
characterisation.setVariableUsage_VariableCharacterisation(varusg);
characterisation.setSpecification_VariableCharacterisation(RandomVariableFactory.expression(specification));
characterisation.setSpecification_VariableCharacterisation(RandomVariableFactory.factory().expression(specification).get());

// create var reference
final VariableReference varref = StoexFactory.eINSTANCE.createVariableReference();
Expand Down
Loading