public abstract class AbstractScheduledResource extends SimuComEntity implements de.uka.ipd.sdq.scheduler.sensors.IActiveResourceStateSensor
Constructor and Description |
---|
AbstractScheduledResource(SimuComModel myModel,
java.lang.String typeID,
java.lang.String resourceContainerID,
java.lang.String resourceTypeID,
java.lang.String description,
java.lang.String schedulingStrategyID,
int numberOfInstances,
boolean requiredByContainer) |
Modifier and Type | Method and Description |
---|---|
void |
activateResource()
Called by the framework to inform that the resource should start its lifecycle
|
void |
addDemandListener(IDemandListener listener) |
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.
|
abstract void |
consumeResource(SimuComSimProcess thread,
int resourceServiceID,
java.util.Map<java.lang.String,java.io.Serializable> parameterMap,
double demand)
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 the
IActiveResource 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) |
java.lang.String |
getDescription() |
int |
getNumberOfInstances() |
long |
getQueueLength(int coreID) |
abstract double |
getRemainingDemandForProcess(SimuComSimProcess thread) |
java.lang.String |
getResourceTypeId()
Returns the id of the resource type (e.g.
|
abstract de.uka.ipd.sdq.scheduler.IActiveResource |
getScheduledResource() |
java.lang.String |
getSchedulingStrategyID() |
de.uka.ipd.sdq.scheduler.IActiveResource |
getUnderlyingResource()
Returns the underlying resource
|
boolean |
isAvailable()
Retrieves the current availability status of this resource.
|
boolean |
isRequiredByContainer()
Asks if a processing resource is required by its surrounding container.
|
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) |
getModel
public AbstractScheduledResource(SimuComModel myModel, java.lang.String typeID, java.lang.String resourceContainerID, java.lang.String resourceTypeID, java.lang.String description, java.lang.String schedulingStrategyID, int numberOfInstances, boolean requiredByContainer)
public de.uka.ipd.sdq.scheduler.IActiveResource getUnderlyingResource()
protected abstract de.uka.ipd.sdq.scheduler.IActiveResource createActiveResource(SimuComModel simuComModel)
IActiveResource
to use internally. Is
called in the constructor.IActiveResource
resource to use as determined by the subclasses.public abstract void consumeResource(SimuComSimProcess thread, int resourceServiceID, java.util.Map<java.lang.String,java.io.Serializable> parameterMap, double demand)
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.demand
- The resource demand the client wishes to be processed by the resourcepublic abstract double getRemainingDemandForProcess(SimuComSimProcess thread)
public abstract void updateDemand(SimuComSimProcess thread, double demand)
protected abstract double calculateDemand(double demand)
demand
- The demand issued to this resource in units understood by the resourcepublic void activateResource()
public void deactivateResource()
IStateListener#stateChanged()
event.public abstract de.uka.ipd.sdq.scheduler.IActiveResource getScheduledResource()
public void setAvailable(boolean isAvailable)
isAvailable
- the target state to setpublic boolean isAvailable()
public boolean isRequiredByContainer()
protected void assertAvailability()
public java.lang.String getDescription()
public int getNumberOfInstances()
public void addStateListener(IStateListener listener, int instance)
public void addOverallUtilizationListener(IOverallUtilizationListener listener)
protected void fireStateEvent(long queueLength, int instance)
IStateListener
protected void fireOverallUtilization(double resourceDemand, double totalTime)
public void addDemandListener(IDemandListener listener)
protected void fireDemand(double demand)
public void update(long state, int instanceId)
update
in interface de.uka.ipd.sdq.scheduler.sensors.IActiveResourceStateSensor
public void demandCompleted(de.uka.ipd.sdq.scheduler.ISchedulableProcess simProcess)
demandCompleted
in interface de.uka.ipd.sdq.scheduler.sensors.IActiveResourceStateSensor
public java.lang.String getResourceTypeId()
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 to typeName
or similar!
public java.lang.String getSchedulingStrategyID()
public long getQueueLength(int coreID)