hu.mta.sztaki.lpds.cloud.simulator.iaas.resourcemodel
Class ResourceSpreader

java.lang.Object
  extended by 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"

Nested Class Summary
static class ResourceSpreader.FreqSyncer
           
static interface ResourceSpreader.PowerBehaviorChangeListener
           
 
Field Summary
private  PowerState currentPowerBehavior
           
(package private) static int hashCounter
           
protected  long lastNotifTime
           
private  CopyOnWriteArrayList<ResourceSpreader.PowerBehaviorChangeListener> listeners
           
private  int myHashCode
           
private  ResourceSpreader.FreqSyncer mySyncer
           
protected  double negligableProcessing
           
protected  double perTickProcessingPower
          Maximum amount of resources to be shared among the consumption objects during a single tick.
private  boolean stillInDepGroup
           
 List<ResourceConsumption> toBeAdded
           
private  ArrayList<ResourceConsumption> toProcess
          The array of consumption objects that will share the processing power of this spreader.
private  double totalProcessed
           
private  ArrayList<ResourceConsumption> underAddition
           
 List<ResourceConsumption> underProcessing
           
(package private)  int underProcessingLen
           
private  ArrayList<ResourceConsumption> underRemoval
           
 
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)
           
private  void doProcessing(long currentFireCount)
           
protected abstract  ResourceSpreader getCounterPart(ResourceConsumption con)
           
 PowerState getCurrentPowerBehavior()
           
(package private) static int getHashandIncCounter()
           
 double getPerTickProcessingPower()
           
protected abstract  ResourceSpreader getSamePart(ResourceConsumption con)
           
 ResourceSpreader.FreqSyncer getSyncer()
           
 double getTotalProcessed()
           
 int hashCode()
           
protected  boolean isAcceptableConsumption(ResourceConsumption con)
           
protected abstract  boolean isConsumer()
           
protected abstract  double processSingleConsumption(ResourceConsumption con, long ticksPassed)
           
(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)
           
 void setCurrentPowerBehavior(PowerState newPowerBehavior)
           
protected  void setPerTickProcessingPower(double perTickProcessingPower)
           
protected abstract  long singleGroupwiseFreqUpdater()
           
 void subscribePowerBehaviorChangeEvents(ResourceSpreader.PowerBehaviorChangeListener pbcl)
           
 String toString()
           
 void unsubscribePowerBehaviorChangeEvents(ResourceSpreader.PowerBehaviorChangeListener pbcl)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

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
Constructor Detail

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
Method Detail

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.