Class HarddriveStorage

java.lang.Object
org.cloudbus.cloudsim.resources.HarddriveStorage
All Implemented Interfaces:
FileStorage, Resource, ResourceCapacity
Direct Known Subclasses:
SanStorage

public class HarddriveStorage extends Object implements FileStorage
An implementation of a Hard Drive (HD) storage device with a specific capacity (in Megabytes). It simulates the behavior of a typical hard drive. The default values for this storage are those of a "Maxtor DiamondMax 10 ATA" hard disk with the following parameters:
  • latency = 4.17 ms
  • avg seek time = 9 m/s
  • max transfer rate = 1064 Megabits/sec (133 MBytes/sec)
Since:
CloudSim Toolkit 1.0
Author:
Uros Cibej, Anthony Sulistio, Manoel Campos da Silva Filho
  • Constructor Details

    • HarddriveStorage

      public HarddriveStorage(String name, long capacity) throws IllegalArgumentException
      Creates a new hard drive storage with a given name and capacity.
      Parameters:
      name - the name of the new hard drive storage
      capacity - the capacity in MByte
      Throws:
      IllegalArgumentException - when the name and the capacity are not valid
    • HarddriveStorage

      public HarddriveStorage(long capacity) throws IllegalArgumentException
      Creates a new hard drive storage with a given capacity. In this case the name of the storage is a default name.
      Parameters:
      capacity - the capacity in MByte
      Throws:
      IllegalArgumentException - when the name and the capacity are not valid
  • Method Details

    • getName

      public String getName()
      Returns:
      the name of the storage device
    • getLatency

      public double getLatency()
      Description copied from interface: FileStorage
      Gets the rotational latency of this storage in seconds (if any).
      Specified by:
      getLatency in interface FileStorage
      Returns:
      the read latency in seconds
    • setLatency

      public FileStorage setLatency(double latency)
      Description copied from interface: FileStorage
      Sets the rotational latency of this storage in seconds (if any).
      Specified by:
      setLatency in interface FileStorage
      Parameters:
      latency - the new latency in seconds
      Returns:
    • getMaxTransferRate

      public double getMaxTransferRate()
      Description copied from interface: FileStorage
      Gets the maximum local transfer rate of the storage in Mega-bits/sec, i.e., the physical device reading speed.
      Specified by:
      getMaxTransferRate in interface FileStorage
      Returns:
      the maximum transfer rate in Mega-bits/sec
      See Also:
    • setMaxTransferRate

      public FileStorage setMaxTransferRate(double maxTransferRate)
      Description copied from interface: FileStorage
      Sets the maximum transfer rate of this storage system in Mega-bits/sec, i.e., the physical device reading speed.

      Despite disk transfer rate is usually defined in MBytes/sec, it's being used Mbits/sec everywhere to avoid confusions, since Host, Vm, Switch and SanStorage use such a data unit.

      Specified by:
      setMaxTransferRate in interface FileStorage
      Parameters:
      maxTransferRate - the maximum transfer rate in Mbits/sec
      Returns:
    • setAvgSeekTime

      public FileStorage setAvgSeekTime(double seekTime)
      Sets the average seek time of the storage in seconds.
      Parameters:
      seekTime - the average seek time in seconds
      Returns:
    • setAvgSeekTime

      public FileStorage setAvgSeekTime(double seekTime, ContinuousDistribution gen)
      Sets the average seek time and a new generator of seek times in seconds. The generator determines a randomized seek time.
      Parameters:
      seekTime - the average seek time in seconds
      gen - the ContinuousGenerator which generates seek times
      Returns:
    • getAvgSeekTime

      public double getAvgSeekTime()
      Gets the average seek time of the hard drive in seconds.
      Returns:
      the average seek time in seconds
    • getSeekTime

      public double getSeekTime(int fileSize)
      Get the seek time for a file with the defined size. Given a file size in MByte, this method returns a seek time for the file in seconds.
      Parameters:
      fileSize - the size of a file in MByte
      Returns:
      the seek time in seconds
    • getTransferTime

      public double getTransferTime(int fileSize)
      Description copied from interface: FileStorage
      Gets the transfer time of a given file.
      Specified by:
      getTransferTime in interface FileStorage
      Parameters:
      fileSize - the size of the file to compute the transfer time (in MByte)
      Returns:
      the transfer time in seconds
    • getTransferTime

      protected final double getTransferTime(int fileSize, double speed)
      Gets the time to transfer a file (in MBytes) according to a given transfer speed (in Mbits/sec).
      Parameters:
      fileSize - the size of the file to compute the transfer time (in MBytes)
      speed - the speed (in MBits/sec) to compute the time to transfer the file
      Returns:
      the transfer time in seconds
    • getCapacity

      public long getCapacity()
      Description copied from interface: ResourceCapacity
      Gets the total capacity of the resource.
      Specified by:
      getCapacity in interface ResourceCapacity
      Returns:
      the total resource capacity
    • getAvailableResource

      public long getAvailableResource()
      Description copied from interface: Resource
      Gets the amount of the resource that is available (free).
      Specified by:
      getAvailableResource in interface Resource
      Returns:
      the amount of available resource
    • getAllocatedResource

      public long getAllocatedResource()
      Description copied from interface: Resource
      Gets the current total amount of allocated resource.
      Specified by:
      getAllocatedResource in interface Resource
      Returns:
      amount of allocated resource
    • isAmountAvailable

      public boolean isAmountAvailable(long amountToCheck)
      Description copied from interface: Resource
      Checks if there is a specific amount of resource available (free).
      Specified by:
      isAmountAvailable in interface Resource
      Parameters:
      amountToCheck - the amount of resource to check if is free.
      Returns:
      true if the specified amount is free; false otherwise
    • isAmountAvailable

      public boolean isAmountAvailable(double amountToCheck)
      Description copied from interface: Resource
      Checks if there is a specific amount of resource available (free), where such amount is a double value that will be converted to long.

      This method is just a shorthand to avoid explicitly converting a double to long.

      Specified by:
      isAmountAvailable in interface Resource
      Parameters:
      amountToCheck - the amount of resource to check if is free.
      Returns:
      true if the specified amount is free; false otherwise
      See Also:
    • isFull

      public boolean isFull()
      Description copied from interface: Resource
      Checks if the resource is full or not.
      Specified by:
      isFull in interface Resource
      Returns:
      true if the storage is full, false otherwise
    • getStorage

      public SimpleStorage getStorage()
      The internal storage that just manages the HD capacity and used space. The HarddriveStorage (HD) does not extends such class to avoid its capacity and available amount of space to be changed indiscriminately. The available space is update according to files added or removed from the HD.
    • getUnit

      public String getUnit()
      Description copied from interface: Resource
      Gets the measurement unit of this resource.
      Specified by:
      getUnit in interface Resource
      Returns: