Package jsl.modeling.elements.entity
Class CyclicResourceSelectionRule
- java.lang.Object
-
- jsl.modeling.elements.entity.CyclicResourceSelectionRule
-
- All Implemented Interfaces:
ResourceSelectionRuleIfc
public class CyclicResourceSelectionRule extends java.lang.Object implements ResourceSelectionRuleIfc
-
-
Constructor Summary
Constructors Constructor Description CyclicResourceSelectionRule()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAvailableResource(java.util.List<Resource> list, Resource resource)
Places the supplied resource (if resource.hasAvailableUnits()) in the listResource
selectAvailableResource(java.util.List<Resource> list)
Selects an available resource or null if none are available The default is to find the first available resource that has the maximum available units.Resource
selectAvailableResource(java.util.List<Resource> list, int amtNeeded)
Returns the next available resource to be used for allocating to requests, null if none are found that can satisfy the request.
-
-
-
Method Detail
-
selectAvailableResource
public Resource selectAvailableResource(java.util.List<Resource> list, int amtNeeded)
Returns the next available resource to be used for allocating to requests, null if none are found that can satisfy the request. The default selection method is to cycle through the resources in the order in which they were RELEASED. The idle resource set starts in the order the resources were added to the resource set and assumes that the first resource listed was the resource that was allocated the longest time in the past, and so on. For example, if the set of idle resources has the following list: Resource B Resource A Resource C Then C was the most recently used, resource A the next most recently used, and resource B the oldest used. Resource B will be next allocated, if it can satisfy the amount of the request. If not, Resource A will be checked, and so forth until a resource that can satisfy the request is found. Thus, it is entirely possible that B will not be the next recommended resource. The selected resource is added to the end of the list after it is released. Note that the the order can vary with this list depending on the order in which the resources are released. To provide alternative behavior either override this method, or provide a ResourceSelectionRuleIfc The default behavior is to return the first available resource that can fully supply the amount needed- Specified by:
selectAvailableResource
in interfaceResourceSelectionRuleIfc
- Parameters:
amtNeeded
-- Returns:
-
addAvailableResource
public void addAvailableResource(java.util.List<Resource> list, Resource resource)
Description copied from interface:ResourceSelectionRuleIfc
Places the supplied resource (if resource.hasAvailableUnits()) in the list- Specified by:
addAvailableResource
in interfaceResourceSelectionRuleIfc
-
selectAvailableResource
public Resource selectAvailableResource(java.util.List<Resource> list)
Selects an available resource or null if none are available The default is to find the first available resource that has the maximum available units. To change this either override this method or supply a ResourceSelectionRuleIfc- Specified by:
selectAvailableResource
in interfaceResourceSelectionRuleIfc
- Returns:
-
-