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
-
Field Summary
Fields inherited from class de.uka.ipd.sdq.simulation.abstractsimengine.AbstractSimEntityDelegator
delegate
Fields inherited from interface de.uka.ipd.sdq.simulation.abstractsimengine.IEntity
NULL
-
Constructor Summary
ConstructorDescriptionAbstractScheduledResource
(SimuComModel myModel, String typeID, String resourceContainerID, String resourceTypeID, String description, String schedulingStrategyID, int numberOfInstances, boolean requiredByContainer) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Called by the framework to inform that the resource should start its lifecyclevoid
addDemandListener
(IDemandListener listener) void
Adds a DemandModifyingBehavior which can be used during the demand calculation.void
void
addStateListener
(IStateListener listener, int instance) protected void
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
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) int
long
getQueueLength
(int coreID) abstract double
Returns the id of the resource type (e.g.abstract de.uka.ipd.sdq.scheduler.IActiveResource
de.uka.ipd.sdq.scheduler.IActiveResource
Returns the underlying resourceboolean
Retrieves the current availability status of this resource.boolean
Asks if a processing resource is required by its surrounding container.void
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
Methods inherited from class de.uka.ipd.sdq.simulation.abstractsimengine.AbstractSimEntityDelegator
getEncapsulatedEntity, isScheduled, reschedule
Methods inherited from class de.uka.ipd.sdq.simulation.abstractsimengine.SimulationElement
getName
-
Constructor Details
-
AbstractScheduledResource
-
-
Method Details
-
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
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
Description copied from interface:IResourceDemandModifiable
Removes a DemandModifyingBehavior.- Specified by:
removeDemandModifyingBehavior
in interfaceIResourceDemandModifiable
- Parameters:
behavior
- the DemandModifyingBehavior
-
getRemainingDemandForProcess
-
updateDemand
-
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
-
getNumberOfInstances
public int getNumberOfInstances() -
addStateListener
-
addOverallUtilizationListener
-
fireStateEvent
protected void fireStateEvent(long queueLength, int instance) - See Also:
-
fireOverallUtilization
protected void fireOverallUtilization(double resourceDemand, double totalTime) -
addDemandListener
-
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
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
-
getQueueLength
public long getQueueLength(int coreID)
-