|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecthu.mta.sztaki.lpds.cloud.simulator.iaas.resourcemodel.ResourceSpreader
public abstract class ResourceSpreader
This class is part of the unified resource consumption model of DISSECT-CF. This class provides a foundation for ensuring equal access to resource limited devices (such as network interfaces, cpus or disks) for all ongoing resource consumptions. Resource processing is actually handled by the processSingleConsumption function which must be implemented externally for performance. This allows the resource consumption simulation code to run with less conditional statements in its core. While it also allows to efficiently add new features later on.
Nested Class Summary | |
---|---|
static class |
ResourceSpreader.FreqSyncer
This class is the core part of the unified resource consumption model of DISSECT-CF. |
Field Summary | |
---|---|
private PowerState |
currentPowerBehavior
The power behavior that currently models the resource spreader's energy characteristics. |
(package private) static int |
hashCounter
A continuously increasing simple hash value to be used by the next resource spreader object created |
protected long |
lastNotifTime
The last time there were some processing operations done by this object. |
private int |
myHashCode
The hashcode of the actual resource spreader to be used in java's built in hashCode function |
private ResourceSpreader.FreqSyncer |
mySyncer
The influence group in which this resource spreader belongs. |
protected double |
negligableProcessing
For floating point operations using the perTickProcessingPower this defines the precision, ie. |
protected double |
perTickProcessingPower
Maximum amount of resources to be shared among the consumption objects during a single tick. |
private StateDependentEventHandler<PowerBehaviorChangeListener,org.apache.commons.lang3.tuple.Pair<ResourceSpreader,PowerState>> |
powerBehaviorListenerManager
This is the notification handler object that belongs to this particular resource spreader. |
private boolean |
stillInDepGroup
A helper field that allows the rapid discovery of influence groups by the group's freq syncer object |
List<ResourceConsumption> |
toBeAdded
Public, unmodifiable list of just deregistered resource consumptions |
List<ResourceConsumption> |
toBeRemoved
Public, unmodifiable list of just registered resource consumptions |
private ArrayList<ResourceConsumption> |
toProcess
The array of consumption objects that will share the processing power of this spreader. |
private double |
totalProcessed
Shows how much processing this spreader done in its lifetime. |
private ArrayList<ResourceConsumption> |
underAddition
The resource consumptions that got registered to this spreader in the last tick |
List<ResourceConsumption> |
underProcessing
The unalterable array of resource consumption objects. |
(package private) int |
underProcessingLen
the length of the list of toProcess. |
private ArrayList<ResourceConsumption> |
underRemoval
The resource consumptions that got deregistered from this spreader in the last tick |
Constructor Summary | |
---|---|
ResourceSpreader(double initialProcessingPower)
This constructor just saves the processing power that can be spread in every tick by the newly instantiated spreader. |
Method Summary | |
---|---|
(package private) static void |
cancelConsumption(ResourceConsumption con)
Organizes the coordinated removal of this consumption from the underProcessing list. |
private void |
doProcessing(long currentFireCount)
The main resource processing loop. |
protected abstract ResourceSpreader |
getCounterPart(ResourceConsumption con)
If it is unknown whether we are a provider or a consumer (this is usually the case in the generic resource spreader class or anyone outsed the actual provider/consumer implementations) then it is useful to figure out the counter part who also participates in the same resource consumption processing operation. |
PowerState |
getCurrentPowerBehavior()
Queries the current power behavior object |
(package private) static int |
getHashandIncCounter()
Manages the increment of the hashCounter and offers the latest hash code for new objects WARNING: as this function does not check if a hash value is already given or not there might be hash collisions if there are so many resource spreaders created that the hashcounter overflows. |
double |
getPerTickProcessingPower()
Determines the current processing power of this resource spreader |
protected abstract ResourceSpreader |
getSamePart(ResourceConsumption con)
The function gets that particular resource spreader from the given resource consumption object that is the same kind (i.e., provider/consumer) as the resource spreader that calls for this function. |
ResourceSpreader.FreqSyncer |
getSyncer()
Determines the influence group this resource spreader is participating in. |
double |
getTotalProcessed()
Returns the total amount of resources processed (i.e., via all past and present resource consumption objects) by this resource spreader object at the time instance this call is made. |
int |
hashCode()
Returns the constant hashcode that was generated for this object during its instantiation. |
protected boolean |
isAcceptableConsumption(ResourceConsumption con)
Allows the rejection of the registration of some resource consumptions. |
protected abstract boolean |
isConsumer()
Determines if a particular resource spreader is acting as a consumer or not. |
protected abstract double |
processSingleConsumption(ResourceConsumption con,
long ticksPassed)
This function is expected to realign the underProcessing and toBeProcessed fields of the ResourceConsumption object it receives. |
(package private) static boolean |
registerConsumption(ResourceConsumption con)
When a new consumption is initiated it must be registered to the corresponding spreader with this function. |
protected void |
removeTheseConsumptions(ResourceConsumption[] conList,
int len)
Allows the management of the underRemoval list. |
void |
setCurrentPowerBehavior(PowerState newPowerBehavior)
Allows to change the power behavior of the resource spreader. |
protected void |
setPerTickProcessingPower(double perTickProcessingPower)
Allows to set the current processing power of this resource spreader WARNING: this is not intended to be used for altering the performance of the spreader while it participates in resource consumption processing |
protected abstract long |
singleGroupwiseFreqUpdater()
The entry to the lowest level schedulers in DISSECT-CF. |
void |
subscribePowerBehaviorChangeEvents(PowerBehaviorChangeListener pbcl)
allows interested parties to receive power behavior change events by subscribing with a listener object. |
String |
toString()
Provides a nice formatted single line representation of the spreader. |
void |
unsubscribePowerBehaviorChangeEvents(PowerBehaviorChangeListener pbcl)
allows parties that got uninterested to cancel the reception of new power behavior change events by unsubscribing with a listener object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected double perTickProcessingPower
protected double negligableProcessing
private final ArrayList<ResourceConsumption> toProcess
public final List<ResourceConsumption> underProcessing
int underProcessingLen
private ResourceSpreader.FreqSyncer mySyncer
private ArrayList<ResourceConsumption> underAddition
private ArrayList<ResourceConsumption> underRemoval
public final List<ResourceConsumption> toBeRemoved
public final List<ResourceConsumption> toBeAdded
private PowerState currentPowerBehavior
private final StateDependentEventHandler<PowerBehaviorChangeListener,org.apache.commons.lang3.tuple.Pair<ResourceSpreader,PowerState>> powerBehaviorListenerManager
protected long lastNotifTime
private double totalProcessed
private boolean stillInDepGroup
static int hashCounter
private final int myHashCode
Constructor Detail |
---|
public ResourceSpreader(double initialProcessingPower)
initialProcessingPower
- Maximum usable bandwidth in a during a single timing eventMethod Detail |
---|
public final ResourceSpreader.FreqSyncer getSyncer()
protected abstract long singleGroupwiseFreqUpdater()
protected final void removeTheseConsumptions(ResourceConsumption[] conList, int len)
conList
- the resource consumptions that must be dropped (either because
they complete or because they are cancelled)len
- the number of items in the consumption list.static boolean registerConsumption(ResourceConsumption con)
con
- The consumption object to be registered
protected boolean isAcceptableConsumption(ResourceConsumption con)
con
- the consumption that is asked to be registered
static void cancelConsumption(ResourceConsumption con)
con
- the consumption to be removed from its processing
consumer/provider pair.private void doProcessing(long currentFireCount)
currentFireCount
- the time at which this processing task must take place.protected abstract double processSingleConsumption(ResourceConsumption con, long ticksPassed)
con
- the resource consumption to be realignedticksPassed
- the time passed since the last processing request
protected abstract ResourceSpreader getCounterPart(ResourceConsumption con)
con
- The consumption object for which we would like to know the
other party that participates in the processing with us.
protected abstract ResourceSpreader getSamePart(ResourceConsumption con)
con
- The consumption object on which this call will operate
protected abstract boolean isConsumer()
public double getTotalProcessed()
public double getPerTickProcessingPower()
protected void setPerTickProcessingPower(double perTickProcessingPower)
perTickProcessingPower
- the new processing power of this resource spreader. The new
value has no unit, the unit depends on the user of the
spreader (e.g. in networking it could be bytes/tick)public PowerState getCurrentPowerBehavior()
public void setCurrentPowerBehavior(PowerState newPowerBehavior)
newPowerBehavior
- the new power behavior to be set. Null values are not allowed!public void subscribePowerBehaviorChangeEvents(PowerBehaviorChangeListener pbcl)
pbcl
- the new listener objectpublic void unsubscribePowerBehaviorChangeEvents(PowerBehaviorChangeListener pbcl)
pbcl
- the old listener objectpublic String toString()
toString
in class Object
static int getHashandIncCounter()
public final int hashCode()
hashCode
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |