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 voidactivateResource()Called by the framework to inform that the resource should start its lifecyclevoidaddDemandListener(IDemandListener listener)voidaddDemandModifyingBehavior(DemandModifyingBehavior behavior)Adds a DemandModifyingBehavior which can be used during the demand calculation.voidaddOverallUtilizationListener(IOverallUtilizationListener listener)voidaddStateListener(IStateListener listener, int instance)protected voidassertAvailability()Asserts that the resource is currently available; if not, an EnvironmentFailureException is thrown.protected abstract doublecalculateDemand(double demand)Template method.voidconsumeResource(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.IActiveResourcecreateActiveResource(SimuComModel simuComModel)Subclasses are responsible for creating theIActiveResourceto use internally.voiddeactivateResource()Called by the framework to inform the resource that the simulation has been stopped.voiddemandCompleted(de.uka.ipd.sdq.scheduler.ISchedulableProcess simProcess)protected voidfireDemand(double demand)protected voidfireOverallUtilization(double resourceDemand, double totalTime)protected voidfireStateEvent(long queueLength, int instance)StringgetDescription()intgetNumberOfInstances()longgetQueueLength(int coreID)abstract doublegetRemainingDemandForProcess(SimuComSimProcess thread)StringgetResourceTypeId()Returns the id of the resource type (e.g.abstract de.uka.ipd.sdq.scheduler.IActiveResourcegetScheduledResource()StringgetSchedulingStrategyID()de.uka.ipd.sdq.scheduler.IActiveResourcegetUnderlyingResource()Returns the underlying resourcebooleanisAvailable()Retrieves the current availability status of this resource.booleanisRequiredByContainer()Asks if a processing resource is required by its surrounding container.voidremoveDemandModifyingBehavior(DemandModifyingBehavior behavior)Removes a DemandModifyingBehavior.voidsetAvailable(boolean isAvailable)Marks the resource as being available or unavailable.voidupdate(long state, int instanceId)abstract voidupdateDemand(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 theIActiveResourceto use internally. Is called in the constructor.- Returns:
- the
IActiveResourceresource 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:IResourceDemandModifiableAdds a DemandModifyingBehavior which can be used during the demand calculation.- Specified by:
addDemandModifyingBehaviorin interfaceIResourceDemandModifiable- Parameters:
behavior- the DemandModifyingBehavior
-
removeDemandModifyingBehavior
public void removeDemandModifyingBehavior(DemandModifyingBehavior behavior)
Description copied from interface:IResourceDemandModifiableRemoves a DemandModifyingBehavior.- Specified by:
removeDemandModifyingBehaviorin 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:
updatein interfacede.uka.ipd.sdq.scheduler.sensors.IActiveResourceStateSensor
-
demandCompleted
public void demandCompleted(de.uka.ipd.sdq.scheduler.ISchedulableProcess simProcess)
- Specified by:
demandCompletedin 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
typeIDvariables should be renamed totypeNameor similar!
-
getSchedulingStrategyID
public String getSchedulingStrategyID()
-
getQueueLength
public long getQueueLength(int coreID)
-
-