Class AbstractActiveResource
- java.lang.Object
-
- de.uka.ipd.sdq.simulation.abstractsimengine.SimulationElement
-
- de.uka.ipd.sdq.simulation.abstractsimengine.AbstractSimEntityDelegator
-
- edu.kit.ipd.sdq.eventsim.entities.EventSimEntity
-
- edu.kit.ipd.sdq.eventsim.resources.entities.AbstractActiveResource
-
- All Implemented Interfaces:
de.uka.ipd.sdq.simulation.abstractsimengine.IEntity
- Direct Known Subclasses:
SimActiveResource
,SimLinkingResource
public abstract class AbstractActiveResource extends EventSimEntity
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class edu.kit.ipd.sdq.eventsim.entities.EventSimEntity
EventSimEntity.EntityLifecyclePhase
-
-
Field Summary
Fields Modifier and Type Field Description protected de.uka.ipd.sdq.scheduler.IActiveResource
schedulerResource
the encapsulated scheduler resource
-
Constructor Summary
Constructors Constructor Description AbstractActiveResource(de.uka.ipd.sdq.simulation.abstractsimengine.ISimulationModel simulationModel, String namePrefix, de.uka.ipd.sdq.scheduler.IActiveResource schedulerResource, org.palladiosimulator.pcm.resourcetype.SchedulingPolicy schedulingStrategy, int numberOfInstances)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addDemandListener(IDemandListener listener)
void
addStateListener(IStateListener listener, int instance)
protected abstract double
calculateConcreteDemand(double abstractDemand, int resourceServiceId)
void
consumeResource(SimulatedProcess process, double abstractDemand, int resourceServiceID, Procedure onServedCallback)
Processes the specified demand issued by the given process.void
deactivateResource()
Called to notify this resource that the simulation run has stopped.protected void
fireDemand(de.uka.ipd.sdq.scheduler.ISchedulableProcess process, double demand, int resourceServiceID)
Notifies the demand listeners that the specified demand has been requested.protected void
fireStateEvent(long state, int instance)
Notifies the state listeners that the state of the specified instance has changed.int
getNumberOfInstances()
long
getQueueLength(int instanceId)
org.palladiosimulator.pcm.resourcetype.SchedulingPolicy
getSchedulingStrategy()
protected void
setupStateListenerAdapter(de.uka.ipd.sdq.scheduler.IActiveResource resource)
Translates theIActiveResourceStateSensor
listener to theIStateListener
.-
Methods inherited from class edu.kit.ipd.sdq.eventsim.entities.EventSimEntity
addEntityListener, equals, getEntityId, getLifecyclePhase, getName, hashCode, notifyEnteredSystem, notifyLeftSystem, removeEntityListener, resetIdGenerator, toString
-
-
-
-
Constructor Detail
-
AbstractActiveResource
public AbstractActiveResource(de.uka.ipd.sdq.simulation.abstractsimengine.ISimulationModel simulationModel, String namePrefix, de.uka.ipd.sdq.scheduler.IActiveResource schedulerResource, org.palladiosimulator.pcm.resourcetype.SchedulingPolicy schedulingStrategy, int numberOfInstances)
-
-
Method Detail
-
setupStateListenerAdapter
protected void setupStateListenerAdapter(de.uka.ipd.sdq.scheduler.IActiveResource resource)
Translates theIActiveResourceStateSensor
listener to theIStateListener
. As a result, allIStateListener
of this resource get notified if the encapsulated scheduler resource fires aIActiveResourceStateSensor
event.
-
consumeResource
public void consumeResource(SimulatedProcess process, double abstractDemand, int resourceServiceID, Procedure onServedCallback)
Processes the specified demand issued by the given process.- Parameters:
process
- the process that has requested the demandabstractDemand
- the demandresourceServiceID
- the resource service IDonServedCallback
- called when the requested demand has been served
-
calculateConcreteDemand
protected abstract double calculateConcreteDemand(double abstractDemand, int resourceServiceId)
-
getNumberOfInstances
public int getNumberOfInstances()
- Returns:
- the number of instances (e.g., cores in case of a processor) that constitute this resource.
-
getQueueLength
public long getQueueLength(int instanceId)
- Returns:
- the number of jobs in the resource's queue waiting to be processed. TODO: check, if this value is rather the queue length plus (!) the number of jobs being processed at the moment.
-
getSchedulingStrategy
public org.palladiosimulator.pcm.resourcetype.SchedulingPolicy getSchedulingStrategy()
-
addDemandListener
public void addDemandListener(IDemandListener listener)
-
addStateListener
public void addStateListener(IStateListener listener, int instance)
-
fireDemand
protected void fireDemand(de.uka.ipd.sdq.scheduler.ISchedulableProcess process, double demand, int resourceServiceID)
Notifies the demand listeners that the specified demand has been requested.- Parameters:
process
- the requesting processdemand
- the requested demandresourceServiceID
- the resource service id
-
fireStateEvent
protected void fireStateEvent(long state, int instance)
Notifies the state listeners that the state of the specified instance has changed.- Parameters:
state
- the resource's queue lengthinstance
- the affected resource instance
-
deactivateResource
public void deactivateResource()
Called to notify this resource that the simulation run has stopped.
-
-