Class AbstractScheduledResource
- java.lang.Object
-
- de.uka.ipd.sdq.simulation.abstractsimengine.SimulationElement
-
- de.uka.ipd.sdq.simulation.abstractsimengine.AbstractSimEntityDelegator
-
- de.uka.ipd.sdq.simucomframework.entities.SimuComEntity
-
- de.uka.ipd.sdq.simucomframework.resources.AbstractScheduledResource
-
- All Implemented Interfaces:
de.uka.ipd.sdq.scheduler.sensors.IActiveResourceStateSensor
,IResourceDemandModifiable
,de.uka.ipd.sdq.simulation.abstractsimengine.IEntity
- Direct Known Subclasses:
ScheduledResource
,SimulatedLinkingResource
public abstract class AbstractScheduledResource extends SimuComEntity implements de.uka.ipd.sdq.scheduler.sensors.IActiveResourceStateSensor, IResourceDemandModifiable
Base class of all resources which have their own scheduler, i.e., active resources in the PCM. Contains generic code to instrument the resource to report its results to the sensorframework
-
-
Constructor Summary
Constructors Constructor Description AbstractScheduledResource(SimuComModel myModel, String typeID, String resourceContainerID, String resourceTypeID, String description, String schedulingStrategyID, int numberOfInstances, boolean requiredByContainer)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
activateResource()
Called by the framework to inform that the resource should start its lifecyclevoid
addDemandListener(IDemandListener listener)
void
addDemandModifyingBehavior(DemandModifyingBehavior behavior)
Adds a DemandModifyingBehavior which can be used during the demand calculation.void
addOverallUtilizationListener(IOverallUtilizationListener listener)
void
addStateListener(IStateListener listener, int instance)
protected void
assertAvailability()
Asserts that the resource is currently available; if not, an EnvironmentFailureException is thrown.protected abstract double
calculateDemand(double demand)
Template method.void
consumeResource(SimuComSimProcess thread, int resourceServiceID, Map<String,Serializable> parameterMap, double abstractDemand)
Called by client of this resource to make the resource simulate resource processing.protected abstract de.uka.ipd.sdq.scheduler.IActiveResource
createActiveResource(SimuComModel simuComModel)
Subclasses are responsible for creating theIActiveResource
to use internally.void
deactivateResource()
Called by the framework to inform the resource that the simulation has been stopped.void
demandCompleted(de.uka.ipd.sdq.scheduler.ISchedulableProcess simProcess)
protected void
fireDemand(double demand)
protected void
fireOverallUtilization(double resourceDemand, double totalTime)
protected void
fireStateEvent(long queueLength, int instance)
String
getDescription()
int
getNumberOfInstances()
long
getQueueLength(int coreID)
abstract double
getRemainingDemandForProcess(SimuComSimProcess thread)
String
getResourceTypeId()
Returns the id of the resource type (e.g.abstract de.uka.ipd.sdq.scheduler.IActiveResource
getScheduledResource()
String
getSchedulingStrategyID()
de.uka.ipd.sdq.scheduler.IActiveResource
getUnderlyingResource()
Returns the underlying resourceboolean
isAvailable()
Retrieves the current availability status of this resource.boolean
isRequiredByContainer()
Asks if a processing resource is required by its surrounding container.void
removeDemandModifyingBehavior(DemandModifyingBehavior behavior)
Removes a DemandModifyingBehavior.void
setAvailable(boolean isAvailable)
Marks the resource as being available or unavailable.void
update(long state, int instanceId)
abstract void
updateDemand(SimuComSimProcess thread, double demand)
-
Methods inherited from class de.uka.ipd.sdq.simucomframework.entities.SimuComEntity
getModel
-
-
-
-
Method Detail
-
getUnderlyingResource
public de.uka.ipd.sdq.scheduler.IActiveResource getUnderlyingResource()
Returns the underlying resource- Returns:
- aResource
-
createActiveResource
protected abstract de.uka.ipd.sdq.scheduler.IActiveResource createActiveResource(SimuComModel simuComModel)
Subclasses are responsible for creating theIActiveResource
to use internally. Is called in the constructor.- Returns:
- the
IActiveResource
resource to use as determined by the subclasses.
-
consumeResource
public void consumeResource(SimuComSimProcess thread, int resourceServiceID, Map<String,Serializable> parameterMap, double abstractDemand)
Called by client of this resource to make the resource simulate resource processing. This is the queueing network service center part of our simulation. Allows passing of additional parameters.- Parameters:
thread
- The thread or job requesting the processing of its demandresourceServiceID
- The id of the resource service to be called for resource consumptionparameterMap
- Additional parameters which can be used by the resource. Map can be empty.abstractDemand
- The resource demand the client wishes to be processed by the resource
-
addDemandModifyingBehavior
public void addDemandModifyingBehavior(DemandModifyingBehavior behavior)
Description copied from interface:IResourceDemandModifiable
Adds a DemandModifyingBehavior which can be used during the demand calculation.- Specified by:
addDemandModifyingBehavior
in interfaceIResourceDemandModifiable
- Parameters:
behavior
- the DemandModifyingBehavior
-
removeDemandModifyingBehavior
public void removeDemandModifyingBehavior(DemandModifyingBehavior behavior)
Description copied from interface:IResourceDemandModifiable
Removes a DemandModifyingBehavior.- Specified by:
removeDemandModifyingBehavior
in interfaceIResourceDemandModifiable
- Parameters:
behavior
- the DemandModifyingBehavior
-
getRemainingDemandForProcess
public abstract double getRemainingDemandForProcess(SimuComSimProcess thread)
-
updateDemand
public abstract void updateDemand(SimuComSimProcess thread, double demand)
-
calculateDemand
protected abstract double calculateDemand(double demand)
Template method. Implementers have to use the given demand and return the time span needed to process the demand on this resource.- Parameters:
demand
- The demand issued to this resource in units understood by the resource- Returns:
- The service time, given in seconds
-
activateResource
public void activateResource()
Called by the framework to inform that the resource should start its lifecycle
-
deactivateResource
public void deactivateResource()
Called by the framework to inform the resource that the simulation has been stopped. Fires aIStateListener#stateChanged()
event.
-
getScheduledResource
public abstract de.uka.ipd.sdq.scheduler.IActiveResource getScheduledResource()
-
setAvailable
public void setAvailable(boolean isAvailable)
Marks the resource as being available or unavailable.- Parameters:
isAvailable
- the target state to set
-
isAvailable
public boolean isAvailable()
Retrieves the current availability status of this resource.- Returns:
- TRUE if the resource is available; FALSE otherwise
-
isRequiredByContainer
public boolean isRequiredByContainer()
Asks if a processing resource is required by its surrounding container.- Returns:
- TRUE if resource is required; FALSE otherwise
-
assertAvailability
protected void assertAvailability()
Asserts that the resource is currently available; if not, an EnvironmentFailureException is thrown.
-
getDescription
public String getDescription()
-
getNumberOfInstances
public int getNumberOfInstances()
-
addStateListener
public void addStateListener(IStateListener listener, int instance)
-
addOverallUtilizationListener
public void addOverallUtilizationListener(IOverallUtilizationListener listener)
-
fireStateEvent
protected void fireStateEvent(long queueLength, int instance)
- See Also:
IStateListener
-
fireOverallUtilization
protected void fireOverallUtilization(double resourceDemand, double totalTime)
-
addDemandListener
public void addDemandListener(IDemandListener listener)
-
fireDemand
protected void fireDemand(double demand)
-
update
public void update(long state, int instanceId)
- Specified by:
update
in interfacede.uka.ipd.sdq.scheduler.sensors.IActiveResourceStateSensor
-
demandCompleted
public void demandCompleted(de.uka.ipd.sdq.scheduler.ISchedulableProcess simProcess)
- Specified by:
demandCompleted
in interfacede.uka.ipd.sdq.scheduler.sensors.IActiveResourceStateSensor
-
getResourceTypeId
public String getResourceTypeId()
Returns the id of the resource type (e.g. "_oro4gG3fEdy4YaaT-RYrLQ" for the "CPU" resource type).Be warned that this method's name may be confusing since it interprets the term "resource type id" different to the rest of SimuCom! In SimuCom, the variable name "typeID" is mostly used to refer to the name (!) of a resource type, i.e. "CPU", not "_oro4g...".
TODO: the
typeID
variables should be renamed totypeName
or similar!
-
getSchedulingStrategyID
public String getSchedulingStrategyID()
-
getQueueLength
public long getQueueLength(int coreID)
-
-