Class 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 list
      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.
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CyclicResourceSelectionRule

        public CyclicResourceSelectionRule()
    • 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 interface ResourceSelectionRuleIfc
        Parameters:
        amtNeeded -
        Returns:
      • 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 interface ResourceSelectionRuleIfc
        Returns: