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
delegateFields inherited from interface de.uka.ipd.sdq.simulation.abstractsimengine.IEntity
NULL -
Constructor Summary
ConstructorsConstructorDescriptionAbstractScheduledResource(SimuComModel myModel, String typeID, String resourceContainerID, String resourceTypeID, String description, String schedulingStrategyID, int numberOfInstances, boolean requiredByContainer) -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled by the framework to inform that the resource should start its lifecyclevoidaddDemandListener(IDemandListener listener) voidAdds a DemandModifyingBehavior which can be used during the demand calculation.voidvoidaddStateListener(IStateListener listener, int instance) protected voidAsserts 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.voidCalled 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) intlonggetQueueLength(int coreID) abstract doubleReturns the id of the resource type (e.g.abstract de.uka.ipd.sdq.scheduler.IActiveResourcede.uka.ipd.sdq.scheduler.IActiveResourceReturns the underlying resourcebooleanRetrieves the current availability status of this resource.booleanAsks if a processing resource is required by its surrounding container.voidRemoves 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
getModelMethods inherited from class de.uka.ipd.sdq.simulation.abstractsimengine.AbstractSimEntityDelegator
getEncapsulatedEntity, isScheduled, rescheduleMethods 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 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
Description copied from interface:IResourceDemandModifiableAdds a DemandModifyingBehavior which can be used during the demand calculation.- Specified by:
addDemandModifyingBehaviorin interfaceIResourceDemandModifiable- Parameters:
behavior- the DemandModifyingBehavior
-
removeDemandModifyingBehavior
Description copied from interface:IResourceDemandModifiableRemoves a DemandModifyingBehavior.- Specified by:
removeDemandModifyingBehaviorin 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:
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
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
-
getQueueLength
public long getQueueLength(int coreID)
-