|
||||||||||
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.ResourceConsumption
public class ResourceConsumption
This class is part of the unified resource consumption model of DISSECT-CF. The instances of this class represent an individual resource consumption in the system. The visibility of the class and its members are defined so the compiler does not need to generate access methods for the members thus allowing fast and prompt changes in its contents. Upon setting up the consumption, every instance is registered at the provider and the consumer resource spreaders. Once the consumption is completed these registrations should be dropped. WARNING this is an internal representation of the consumption. This class is not supposed to be used outside of the context of the Unified resource consumption model of DISSECT-CF. Instead one should use: VirtualMachine.newComputeTask(), NetworkNode.initTransfer() and similar functions.
Nested Class Summary | |
---|---|
static interface |
ResourceConsumption.ConsumptionEvent
This interface allows its implementors to get notified when a consumption completes. |
Field Summary | |
---|---|
private long |
completionDistance
The number of ticks it is expected to take that renders both underProcessing and toBeProcessed as 0 (i.e., the time when the initially specified amount of resources are completely utilized). |
private ResourceSpreader |
consumer
The consumer which receives the resources of this consumption. |
(package private) double |
consumerLimit
the processing limit imposed because of the consumer WARNING: this is necessary for the internal behavior of MaxMinFairSpreader |
(package private) ResourceConsumption.ConsumptionEvent |
ev
The event to be fired when there is nothing left to process in this consumption. |
private double |
halfRealLimit
1/2*realLimit |
private double |
hardLimit
the minimum of the perTickProcessing power of the provider/consumer |
(package private) boolean |
inassginmentprocess
A helper field to show if the consumer/providerLimit fields are under update by MaxMinFairSpreader.assignProcessingPower() WARNING: this is necessary for the internal behavior of MaxMinFairSpreader |
static Comparator<ResourceConsumption> |
limitComparator
This comparator class provides a simple comparison tool for two resource consumptions based on their real limits. |
(package private) double |
limithelper
the amount of processing that can be surely done by both the provider and the consumer. |
private double |
processingLimit
the maximum amount of processing that could be sent from toBeProcessed to underProcessing in a tick |
private ResourceSpreader |
provider
The provider which offers the resources for this consumption. |
(package private) double |
providerLimit
The processing limit imposed because of the provider WARNING: this is necessary for the internal behavior of MaxMinFairSpreader |
private double |
realLimit
The processing limit at the particular moment of time (this is set by the scheduler) This limit is derived from the provider/consumerLimits. |
private boolean |
registered
shows if the consumption object actually participates in the resource sharing machanism. |
private double |
requestedLimit
the user requested processing limit |
private boolean |
resumable
shows if the consumption was suspended (true) or not. |
private double |
toBeProcessed
The remaining unprocessed entities (e.g., remaining bytes of a transfer) NOTE: as this consumption is generic, it is actually the provider/consumer pair that determines what is the unit of this field |
(package private) boolean |
unassigned
A helper field to show if the particular resource consumption still participates in the scheduling process or if it has already finalized its realLimit value. |
private double |
underProcessing
The currently processing entities (e.g., a network buffer) NOTE: as this consumption is generic, it is actually the provider/consumer pair that determines what is the unit of this field |
static double |
unlimitedProcessing
If a resource consumption is not supposed to be limited by anything but the actual resource providers/consumers then this limit could be used in its constructor. |
Constructor Summary | |
---|---|
ResourceConsumption(double total,
double limit,
ResourceSpreader consumer,
ResourceSpreader provider,
ResourceConsumption.ConsumptionEvent e)
This constructor describes the basic properties of an individual resource consumption. |
Method Summary | |
---|---|
private void |
calcCompletionDistance()
Updates the completion distance field, should be called every time the real limit is updated or when the amount of unprocessed consumption changes. |
void |
cancel()
terminates the consumption, deregisters it from its consumer/provider pair and ensures that it can no longer be registered |
(package private) double |
doConsumerProcessing(long ticksPassed)
This function simulates how the consumer utilizes the resources from its provider. |
(package private) double |
doProviderProcessing(long ticksPassed)
This function simulates how the provider offers the resources for its consumer. |
long |
getCompletionDistance()
Retrieves the number of ticks it is expected to take that renders both underProcessing and toBeProcessed as 0 (i.e., the time when the initially specified amount of resources are completely utilized). |
ResourceSpreader |
getConsumer()
Queries the consumer associated with this resource consumption. |
double |
getHardLimit()
Determines the hard processing limit for this resource consumption. |
double |
getProcessingLimit()
Retrieves the maximum amount of processing that could be sent from toBeProcessed to underProcessing in a single tick |
ResourceSpreader |
getProvider()
Queries the provider associated with this resource consumption. |
double |
getRealLimit()
Retrieves the processing limit at the particular moment of time (just queries the value last set by the scheduler) |
double |
getToBeProcessed()
Determines the amount of processing for which no resources were offered from the provider so far. |
double |
getUnderProcessing()
Determines the amount of resoruces already offered by the provider but not yet used by the consumer. |
double |
getUnProcessed()
Returns the amount of processing still remaining in this resource consumption. |
boolean |
isRegistered()
Determines if the object is registered and resources are used because of this consumption object |
boolean |
isResumable()
Allows to query whether this resource consumption was cancelled or not |
boolean |
registerConsumption()
Initiates the processing of a resource consumption. |
void |
setConsumer(ResourceSpreader consumer)
Allows to set a consumer for the consumption if the consumption is not yet under way. |
void |
setProvider(ResourceSpreader provider)
Allows to set a provider for the consumption if the consumption is not yet under way. |
private void |
setRealLimit(double rL)
Simultaneously updates the real limit (the instantaneous processing limit determined by the low level scheduler of the unified resoruce sharing model of DISSECT-CF) value as well as the halfreallimit field. |
void |
suspend()
Terminates the consumption but ensures that it will be resumable later on. |
String |
toString()
Provides a nice formatted output of the resource consumption showing how much processing is under way, how much is still held back and what is the current real limit set by the scheduler. |
private void |
updateHardLimit()
Provides a unified update method for the hard processing limit (which will become the minimum of the provider's/consumer's per tick processing power) of this consumption. |
(package private) double |
updateRealLimit(boolean updateCD)
Sets the real limit based on the scheduler set provider and consumer limits (the smaller is used as real). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Comparator<ResourceConsumption> limitComparator
public static final double unlimitedProcessing
private double underProcessing
private double toBeProcessed
private double processingLimit
private double requestedLimit
private double hardLimit
private double realLimit
private double halfRealLimit
private long completionDistance
double providerLimit
double consumerLimit
double limithelper
boolean unassigned
boolean inassginmentprocess
final ResourceConsumption.ConsumptionEvent ev
private ResourceSpreader consumer
private ResourceSpreader provider
private boolean resumable
private boolean registered
Constructor Detail |
---|
public ResourceConsumption(double total, double limit, ResourceSpreader consumer, ResourceSpreader provider, ResourceConsumption.ConsumptionEvent e)
total
- The amount of processing to be done during the lifetime of the
just created objectlimit
- the maximum amount of processing allowable for this particular
resource consumption (this allows the specification of an
upper limit of any consumption). If there is no upper limit
needed then this value should be set with the value of the
unlimitedProcessing field.consumer
- the consumer that will benefit from the resource consumption.
This field could be null, then the consumer must be set with
the setConsumer() function.provider
- the provider which will offer its resources for the consumer.
This field could be null, then the provider must be set with
the setProvider() function.e
- Specify here the event to be fired when the just created
object completes its transfers. With this event it is possible
to notify the entity who initiated the transfer. This event
object cannot be null. If there is no special event handling
is needed then just create a ConsumptionEventAdapter.Method Detail |
---|
private void updateHardLimit()
public boolean registerConsumption()
public double getUnProcessed()
public void cancel()
public void suspend()
public void setProvider(ResourceSpreader provider)
provider
- the provider to be used for offering the resources for the
consumptionpublic void setConsumer(ResourceSpreader consumer)
consumer
- the consumer to be used for utilizing the resources received
through this resource consumption object.private void calcCompletionDistance()
double doProviderProcessing(long ticksPassed)
ticksPassed
- the number of ticks to be simulated (i.e. how many times we
should multiply realLimit) before offering the resources to
the underprocessing field.
double doConsumerProcessing(long ticksPassed)
ticksPassed
- the number of ticks to be simulated (i.e. how many times we
should multiply realLimit) before utilizing the resources from
the underprocessing field.
public double getToBeProcessed()
public double getUnderProcessing()
public double getProcessingLimit()
public double getRealLimit()
public long getCompletionDistance()
public ResourceSpreader getConsumer()
public ResourceSpreader getProvider()
private void setRealLimit(double rL)
rL
- the value to be set as real limitdouble updateRealLimit(boolean updateCD)
updateCD
- true tells the system to update the completion distance
alongside the real limit setup. This more frequent update on
the real limit than the completion distance is calculated.
IMPORTANT: if set to false then it is expected that the
scheduler will call the updateRealLimit at least once more
with a true parameter. Failing to do so the consumption object
will become broken.
IllegalStateException
- if the real limit would become 0public String toString()
toString
in class Object
public boolean isRegistered()
public boolean isResumable()
public double getHardLimit()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |