hu.mta.sztaki.lpds.cloud.simulator.iaas.constraints
Class AlterableResourceConstraints

java.lang.Object
  extended by hu.mta.sztaki.lpds.cloud.simulator.iaas.constraints.ResourceConstraints
      extended by hu.mta.sztaki.lpds.cloud.simulator.iaas.constraints.AlterableResourceConstraints
All Implemented Interfaces:
Comparable<ResourceConstraints>

public class AlterableResourceConstraints
extends ResourceConstraints

Provides an implementation of a resource constraints class that allows in place alterations on its instances

Author:
"Gabor Kecskemeti, Laboratory of Parallel and Distributed Systems, MTA SZTAKI (c) 2015"

Field Summary
private  double requiredCPUs
           
private  long requiredMemory
           
private  boolean requiredProcessingIsMinimum
           
private  double requiredProcessingPower
           
private  double totalProcessingPower
           
 
Constructor Summary
AlterableResourceConstraints(double cpu, double processing, boolean isMinimum, long memory)
          The main constructor to define alterable resource constraints
AlterableResourceConstraints(double cpu, double processing, long memory)
          A constructor to define resource constraints with exact amount of resources to start with
AlterableResourceConstraints(ResourceConstraints toCopy)
          Allows to make an arbitrary resourceconstraints object into an alterable one
 
Method Summary
 void add(List<ResourceConstraints> toAdd)
          Allows multiple RC objects to be added to this one with variable parameter length This operation expects a list of RC objects thus it is optimally used when the RC objects are stored in a List anyways.
 void add(ResourceConstraints... toAdd)
          Allows multiple RC objects to be added to this one with variable parameter length This operation is good when the RC objects are held in an array.
static AlterableResourceConstraints getNoResources()
          An easy way to get alterable constraints with zero resources - as a basis for calculations with RCs
 double getRequiredCPUs()
          Allows to query how many CPUs this constraints object represent
 long getRequiredMemory()
          Allows to query how much memory this constraints object represent
 double getRequiredProcessingPower()
          Allows to query the performance of a single CPU core represented by this constraints object represent
 double getTotalProcessingPower()
          The total processing power of all cores represented by this constraints object: total=cpus*processingpower
 boolean isRequiredProcessingIsMinimum()
          Determines if the specified amounts of resources are minimally or exactly required.
 void multiply(double times)
          Allows to increase/decrease the amount of cpu cores and required memory by this constraints object linearly
private  void simpleAddition(ResourceConstraints singleAdd)
          Allows a single resource constraints object to be added to this one WARNING: this is for internal purposes only.
 void singleAdd(ResourceConstraints toAdd)
          Allows a single resource constraints object to be added to this one
 void subtract(ResourceConstraints what)
          Subtracts another RC object from this one
private  void updateTotal()
          the total processing field is updated with this function.
 
Methods inherited from class hu.mta.sztaki.lpds.cloud.simulator.iaas.constraints.ResourceConstraints
compareTo, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

requiredCPUs

private double requiredCPUs

requiredProcessingPower

private double requiredProcessingPower

requiredProcessingIsMinimum

private boolean requiredProcessingIsMinimum

requiredMemory

private long requiredMemory

totalProcessingPower

private double totalProcessingPower
Constructor Detail

AlterableResourceConstraints

public AlterableResourceConstraints(double cpu,
                                    double processing,
                                    long memory)
A constructor to define resource constraints with exact amount of resources to start with

Parameters:
cpu - number of cores
processing - per core processing power in instructions/tick
memory - number of bytes

AlterableResourceConstraints

public AlterableResourceConstraints(double cpu,
                                    double processing,
                                    boolean isMinimum,
                                    long memory)
The main constructor to define alterable resource constraints

Parameters:
cpu - number of cores
processing - per core processing power in instructions/tick
isMinimum -
  • true if the constraints define an absolute minimum (i.e., the constraints object could represent any exact constraints object with at least as much memory/processors)
  • false if the constraints defined here are exactly defined no difference from them are accepted.
memory - number of bytes

AlterableResourceConstraints

public AlterableResourceConstraints(ResourceConstraints toCopy)
Allows to make an arbitrary resourceconstraints object into an alterable one

Parameters:
toCopy - the other resource constraints to copy
Method Detail

getNoResources

public static AlterableResourceConstraints getNoResources()
An easy way to get alterable constraints with zero resources - as a basis for calculations with RCs

Returns:
an alterable version of ConstantConstraints.noResources

multiply

public void multiply(double times)
Allows to increase/decrease the amount of cpu cores and required memory by this constraints object linearly

Parameters:
times - the number of times the cpu/memory count should be multiplied

simpleAddition

private void simpleAddition(ResourceConstraints singleAdd)
Allows a single resource constraints object to be added to this one WARNING: this is for internal purposes only. It does not update the total values for performance reasons!

Parameters:
singleAdd - the other resource constraints object to be added to this one

singleAdd

public void singleAdd(ResourceConstraints toAdd)
Allows a single resource constraints object to be added to this one

Parameters:
toAdd - the other resource constraints object to be added

add

public void add(ResourceConstraints... toAdd)
Allows multiple RC objects to be added to this one with variable parameter length This operation is good when the RC objects are held in an array. This way they don't need a conversion

Parameters:
toAdd - several resource constraints objects to be added

add

public void add(List<ResourceConstraints> toAdd)
Allows multiple RC objects to be added to this one with variable parameter length This operation expects a list of RC objects thus it is optimally used when the RC objects are stored in a List anyways.

Parameters:
toAdd - A list of several resource constraints objects to be added

subtract

public void subtract(ResourceConstraints what)
Subtracts another RC object from this one

Parameters:
what - the other party to subtract

updateTotal

private void updateTotal()
the total processing field is updated with this function. This is to be used for the internal operations of the class.


getRequiredCPUs

public double getRequiredCPUs()
Description copied from class: ResourceConstraints
Allows to query how many CPUs this constraints object represent

Specified by:
getRequiredCPUs in class ResourceConstraints
Returns:
the amount of CPU cores represented by the object

getRequiredProcessingPower

public double getRequiredProcessingPower()
Description copied from class: ResourceConstraints
Allows to query the performance of a single CPU core represented by this constraints object represent

Specified by:
getRequiredProcessingPower in class ResourceConstraints
Returns:
the performance of a CPU core in instructions/tick

isRequiredProcessingIsMinimum

public boolean isRequiredProcessingIsMinimum()
Description copied from class: ResourceConstraints
Determines if the specified amounts of resources are minimally or exactly required.

Specified by:
isRequiredProcessingIsMinimum in class ResourceConstraints
Returns:
  • true if the specified amount of resources could be over-fulfilled
  • false if the object represents an exact amount of resources

getRequiredMemory

public long getRequiredMemory()
Description copied from class: ResourceConstraints
Allows to query how much memory this constraints object represent

Specified by:
getRequiredMemory in class ResourceConstraints
Returns:
the amount in bytes

getTotalProcessingPower

public double getTotalProcessingPower()
Description copied from class: ResourceConstraints
The total processing power of all cores represented by this constraints object: total=cpus*processingpower

Specified by:
getTotalProcessingPower in class ResourceConstraints
Returns:
the total processing power in instructions/tick


Copyright © 2012–2015 University of Innsbruck & MTA SZTAKI. All rights reserved.