Class NodeCapacityUtility
- java.lang.Object
-
- org.eclipse.mosaic.fed.cell.utility.NodeCapacityUtility
-
public final class NodeCapacityUtility extends Object
Static methods for handling the bandwidth calculation.
-
-
Constructor Summary
Constructors Constructor Description NodeCapacityUtility()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
consumeCapacityDown(CellConfiguration nodeCellConfiguration, long bandwidthToConsumeInBps)
This method consumes the capacity of a node in the downlink direction.static void
consumeCapacityUp(CellConfiguration nodeCellConfiguration, long consumeInBps)
This method consumes the capacity of a node in the uplink direction.static void
freeCapacityDown(CellConfiguration nodeCellConfiguration, long bandwidthToFreeInBps)
Frees the bandwidth for a given node in the downlink direction.static void
freeCapacityUp(CellConfiguration nodeCellConfiguration, long bandwidthToFreeInBps)
Frees the bandwidth for a given node in the uplink direction.static long
getAvailableDownlinkCapacity(CellConfiguration nodeCellConfiguration)
Returns the available bandwidth of a node in the downlink direction.static long
getAvailableUlCapacity(CellConfiguration nodeCellConfiguration)
Returns the available bandwidth of a node in the uplink direction.static boolean
isAvailable(TransmissionMode mode, CellConfiguration nodeCellConfiguration)
This methods checks whether the node has enough capacity left to allow a new transmission with this node.static boolean
isCapacitySufficient(TransmissionMode mode, CellConfiguration nodeCellConfiguration, long neededBandwidthInBps)
Checks whether the bandwidth is sufficient enough to perform the transmission.
-
-
-
Method Detail
-
isCapacitySufficient
public static boolean isCapacitySufficient(TransmissionMode mode, CellConfiguration nodeCellConfiguration, long neededBandwidthInBps)
Checks whether the bandwidth is sufficient enough to perform the transmission.- Parameters:
mode
- The mode of the transmissionnodeCellConfiguration
- The cell configuration of the node that is checkedneededBandwidthInBps
- The needed bandwidth in bit/s for the transmission- Returns:
- Returns true if the bandwidth of the node is sufficient for the transmission, returns false if the bandwidth of the node is not sufficient for the transmission
-
consumeCapacityUp
public static void consumeCapacityUp(CellConfiguration nodeCellConfiguration, long consumeInBps)
This method consumes the capacity of a node in the uplink direction.- Parameters:
nodeCellConfiguration
- The cell configuration of the node whose capacity is consumedconsumeInBps
- The capacity to consume in bit/s. The capacity has to be larger than zero to actually consume bandwidth. If the value for consume is negative, the cell configuration remains unchanged.
-
consumeCapacityDown
public static void consumeCapacityDown(CellConfiguration nodeCellConfiguration, long bandwidthToConsumeInBps)
This method consumes the capacity of a node in the downlink direction.- Parameters:
nodeCellConfiguration
- The cell configuration of the node whose capacity is consumedbandwidthToConsumeInBps
- The capacity to consume in bit/s. The capacity has to be larger than zero to actually consume bandwidth. If the value for consume is negative, the cell configuration remains unchanged.
-
freeCapacityUp
public static void freeCapacityUp(CellConfiguration nodeCellConfiguration, long bandwidthToFreeInBps)
Frees the bandwidth for a given node in the uplink direction. This method should normally be called when a message that consumed the bandwidth was successfully delivered.- Parameters:
nodeCellConfiguration
- The cell configuration of the node whose bandwidth should be freed.bandwidthToFreeInBps
- The capacity that should be freed in bit/s. The capacity has to be larger than zero to actually consume bandwidth. If the value for free is negative, the cell configuration remains unchanged.
-
freeCapacityDown
public static void freeCapacityDown(CellConfiguration nodeCellConfiguration, long bandwidthToFreeInBps)
Frees the bandwidth for a given node in the downlink direction. This method should normally be called when a message that consumed the bandwidth was successfully delivered.- Parameters:
nodeCellConfiguration
- The cell configuration of the node whose bandwidth should be freed.bandwidthToFreeInBps
- The capacity that should be freed in bit/s. The capacity has to be larger than zero to actually consume bandwidth. If the value for free is negative, the cell configuration remains unchanged.
-
isAvailable
public static boolean isAvailable(TransmissionMode mode, CellConfiguration nodeCellConfiguration)
This methods checks whether the node has enough capacity left to allow a new transmission with this node. If the available capacity of the node is below a threshold value, a new transmission is not possible and the node is not available for a new transmission.- Parameters:
mode
- The requested transmission of the transmission that the node should participate in.nodeCellConfiguration
- The cellConfiguration of the node that is checked for availability.- Returns:
- The method returns true, if the available capacity of the node is above the threshold for allowing a new transmission. Otherwise, the method returns false.
-
getAvailableUlCapacity
public static long getAvailableUlCapacity(CellConfiguration nodeCellConfiguration)
Returns the available bandwidth of a node in the uplink direction.- Parameters:
nodeCellConfiguration
- The cell configuration of the node whose bandwidth is requested.- Returns:
- The available uplink bandwidth of the node with the id in bit/s. If the node is not known, the returned value is 0.
-
getAvailableDownlinkCapacity
public static long getAvailableDownlinkCapacity(CellConfiguration nodeCellConfiguration)
Returns the available bandwidth of a node in the downlink direction.- Parameters:
nodeCellConfiguration
- The cell configuration of the node whose bandwidth is requested.- Returns:
- The available downlink bandwidth of the node with the id in bit/s. If the node is not known, the returned value is 0.
-
-