hu.mta.sztaki.lpds.cloud.simulator.iaas.resourcemodel
Class ResourceSpreader
java.lang.Object
hu.mta.sztaki.lpds.cloud.simulator.iaas.resourcemodel.ResourceSpreader
- Direct Known Subclasses:
- MaxMinFairSpreader
public abstract class ResourceSpreader
- extends Object
This class ensures 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.
- Author:
- "Gabor Kecskemeti, Distributed and Parallel Systems Group, University of Innsbruck (c) 2013"
"Gabor Kecskemeti, Laboratory of Parallel and Distributed Systems, MTA SZTAKI (c) 2012"
Constructor Summary |
ResourceSpreader(double initialProcessingPower)
This constructor just saves the processing power that can be spread in
every tick by the newly instantiated spreader. |
perTickProcessingPower
protected double perTickProcessingPower
- Maximum amount of resources to be shared among the consumption objects
during a single tick.
negligableProcessing
protected double negligableProcessing
toProcess
private final ArrayList<ResourceConsumption> toProcess
- The array of consumption objects that will share the processing power of
this spreader. The order is not guaranteed!
underProcessing
public final List<ResourceConsumption> underProcessing
underProcessingLen
int underProcessingLen
mySyncer
private ResourceSpreader.FreqSyncer mySyncer
underAddition
private ArrayList<ResourceConsumption> underAddition
underRemoval
private ArrayList<ResourceConsumption> underRemoval
toBeAdded
public final List<ResourceConsumption> toBeAdded
currentPowerBehavior
private PowerState currentPowerBehavior
listeners
private CopyOnWriteArrayList<ResourceSpreader.PowerBehaviorChangeListener> listeners
lastNotifTime
protected long lastNotifTime
totalProcessed
private double totalProcessed
stillInDepGroup
private boolean stillInDepGroup
hashCounter
static int hashCounter
myHashCode
private int myHashCode
ResourceSpreader
public ResourceSpreader(double initialProcessingPower)
- This constructor just saves the processing power that can be spread in
every tick by the newly instantiated spreader.
- Parameters:
initialProcessingPower
- Maximum usable bandwidth in a during a single timing event
getSyncer
public final ResourceSpreader.FreqSyncer getSyncer()
singleGroupwiseFreqUpdater
protected abstract long singleGroupwiseFreqUpdater()
removeTheseConsumptions
protected final void removeTheseConsumptions(ResourceConsumption[] conList,
int len)
registerConsumption
static boolean registerConsumption(ResourceConsumption con)
- When a new consumption is initiated it must be registered to the
corresponding spreader with this function.
The consumption object is added to the array of current consumptions.
This function also makes sure that the timing events arrive if this is
the first object in the array.
WARNING: This function should not be called by anyone else but the
registration function of the resource consumption! (Otherwise duplicate
registrations could happen!)
- Parameters:
con
- The consumption object to be registered
isAcceptableConsumption
protected boolean isAcceptableConsumption(ResourceConsumption con)
cancelConsumption
static void cancelConsumption(ResourceConsumption con)
doProcessing
private void doProcessing(long currentFireCount)
processSingleConsumption
protected abstract double processSingleConsumption(ResourceConsumption con,
long ticksPassed)
getCounterPart
protected abstract ResourceSpreader getCounterPart(ResourceConsumption con)
getSamePart
protected abstract ResourceSpreader getSamePart(ResourceConsumption con)
isConsumer
protected abstract boolean isConsumer()
getTotalProcessed
public double getTotalProcessed()
getPerTickProcessingPower
public double getPerTickProcessingPower()
setPerTickProcessingPower
protected void setPerTickProcessingPower(double perTickProcessingPower)
getCurrentPowerBehavior
public PowerState getCurrentPowerBehavior()
setCurrentPowerBehavior
public void setCurrentPowerBehavior(PowerState newPowerBehavior)
subscribePowerBehaviorChangeEvents
public void subscribePowerBehaviorChangeEvents(ResourceSpreader.PowerBehaviorChangeListener pbcl)
unsubscribePowerBehaviorChangeEvents
public void unsubscribePowerBehaviorChangeEvents(ResourceSpreader.PowerBehaviorChangeListener pbcl)
toString
public String toString()
- Overrides:
toString
in class Object
getHashandIncCounter
static int getHashandIncCounter()
hashCode
public final int hashCode()
- Overrides:
hashCode
in class Object
Copyright © 2012–2015 University of Innsbruck & MTA SZTAKI. All rights reserved.