com.ace.moab.api.global
Class MoabLimits<T extends java.lang.Number>

java.lang.Object
  extended by com.ace.moab.api.global.MoabLimits<T>
Type Parameters:
T -
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<MoabLimits<T>>

public class MoabLimits<T extends java.lang.Number>
extends java.lang.Object
implements java.lang.Comparable<MoabLimits<T>>, java.io.Serializable

Represents hard and soft limits in Moab. This class attempts to mimic the same limit properties Moab applies to its limits. From the Moab documentation: 'If no soft limit is specified or the soft limit is less constraining than the hard limit, the soft limit is set equal to the hard limit.' This means that user-specified soft limits can and will be automatically changed to fit inside the hard limits set.

Setting soft limits that contradict hard limits will not throw any exceptions, but this class will internally change the soft limits to be compatible with the existing hard limits. In other words, setters to soft limits will never change hard limits, but it might not change it to equal the inputs.

Setting hard limits might cause the soft limits to be updated (if they are less strict).

Author:
Scott Brown
See Also:
Serialized Form

Constructor Summary
MoabLimits(T hardMin, T hardMax)
          Creates hard limits as specified by the input parameters.
MoabLimits(T softMin, T softMax, T hardMin, T hardMax)
          Creates hard and soft limits as specified by the input parameters.
 
Method Summary
 int compareTo(MoabLimits<T> o)
           
 T getHardMax()
          Get the hard maximum value.
 T getHardMin()
          Get the hard minimum value.
 com.moab.api.util.NumberRange<T> getHardRange()
          Return the hard limit range (min to max)
 T getSoftMax()
          Get the soft maximum value.
 T getSoftMin()
          Get the soft minimum value.
 com.moab.api.util.NumberRange<T> getSoftRange()
          Return the soft limit range (min to max).
 void setHardMax(T hardMax)
          Sets the hard maximum limit.
 void setHardMin(T hardMin)
          Sets the hard minimum limit.
 void setSoftMax(T softMax)
          Attempts to set the soft maximum limit.
 void setSoftMin(T softMin)
          Attempts to set the soft minimum limit.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MoabLimits

public MoabLimits(T softMin,
                  T softMax,
                  T hardMin,
                  T hardMax)
Creates hard and soft limits as specified by the input parameters. Soft limits could be modified to correspond with hard limits.

Parameters:
softMin - The soft minimum value. Moab can violate this value if extra resources exist.
softMax - The soft maximum value. Moab can violate this value if extra resources exist.
hardMin - The hard minimum value. Cannot be violated.
hardMax - The hard maximum value. Cannot be violated.

MoabLimits

public MoabLimits(T hardMin,
                  T hardMax)
Creates hard limits as specified by the input parameters. The soft limits are then just copies of these hard limits.

Parameters:
hardMin - The hard minimum value. Cannot be violated.
hardMax - The hard maximum value. Cannot be violated.
Method Detail

compareTo

public int compareTo(MoabLimits<T> o)
Specified by:
compareTo in interface java.lang.Comparable<MoabLimits<T extends java.lang.Number>>

getHardRange

public com.moab.api.util.NumberRange<T> getHardRange()
Return the hard limit range (min to max)

Returns:
the hard limit range.

getSoftRange

public com.moab.api.util.NumberRange<T> getSoftRange()
Return the soft limit range (min to max).

Returns:
the soft limit range.

setSoftMin

public void setSoftMin(T softMin)
Attempts to set the soft minimum limit. If the value is less then the hard min, the soft min is set to the hard min. If the input value is greater than the hard max, the soft min is set to the hard max. Also, the soft max might be updated if it is less than the input value.

Parameters:
softMin - The new soft minimum value.

setSoftMax

public void setSoftMax(T softMax)
Attempts to set the soft maximum limit. If the value is less then the hard min, the soft soft max is set to the hard min. If the input value is greater than the hard max, the soft max is set to the hard max. Also, the soft min might be updated if it is greater than the input value.

Parameters:
softMax - The new soft maximum value.

setHardMin

public void setHardMin(T hardMin)
Sets the hard minimum limit. If the new hard minimum is greater than the soft minimum, the soft minimum is updated to the new hard minimum. Setting the soft minimum may also update the soft maximum. Setting the hard minimum might update the hard maximum as well.

Theoretically, this method could change the soft min, soft max, hard min, and hard max.

Parameters:
hardMin - The new hard minimum value.

setHardMax

public void setHardMax(T hardMax)
Sets the hard maximum limit. If the new hard maximum is less than the soft maximum, the soft max is updated to the new hard max. Setting the soft max may also update the soft min. Setting the hard maximum might update the hard min as well.

Theoretically, this method could change the soft min, soft max, hard min, and hard max.

Parameters:
hardMax - The new hard maximum value.

getSoftMin

public T getSoftMin()
Get the soft minimum value.

Returns:
the soft minimum value.

getSoftMax

public T getSoftMax()
Get the soft maximum value.

Returns:
the soft maximum value.

getHardMin

public T getHardMin()
Get the hard minimum value.

Returns:
the hard minimum value.

getHardMax

public T getHardMax()
Get the hard maximum value.

Returns:
the hard maximum value.


Copyright © 2001-2009 Cluster Resources, Inc. All Rights Reserved.