Interface ResourceService

    • Method Detail

      • allocate

        default Optional<ResourceAllocation> allocate​(ResourceConsumer consumer,
                                                      Resource resource)
        Allocates the specified resource to the specified user.
        Parameters:
        consumer - resource user which the resource is allocated to
        resource - resource to be allocated
        Returns:
        allocation information enclosed by Optional. If the allocation fails, the return value is empty
      • allocate

        List<ResourceAllocation> allocate​(ResourceConsumer consumer,
                                          List<? extends Resource> resources)
        Transactionally allocates the specified resources to the specified user. All allocations are made when this method succeeds, or no allocation is made when this method fails.
        Parameters:
        consumer - resource user which the resources are allocated to
        resources - resources to be allocated
        Returns:
        non-empty list of allocation information if succeeded, otherwise empty list
      • allocate

        default List<ResourceAllocation> allocate​(ResourceConsumer consumer,
                                                  Resource... resources)
        Transactionally allocates the specified resources to the specified user. All allocations are made when this method succeeds, or no allocation is made when this method fails.
        Parameters:
        consumer - resource user which the resources are allocated to
        resources - resources to be allocated
        Returns:
        non-empty list of allocation information if succeeded, otherwise empty list
      • release

        default boolean release​(ResourceAllocation allocation)
        Releases the specified resource allocation.
        Parameters:
        allocation - resource allocation to be released
        Returns:
        true if succeeded, otherwise false
      • release

        boolean release​(List<ResourceAllocation> allocations)
        Transactionally releases the specified resource allocations. All allocations are released when this method succeeded, or no allocation is released when this method fails.
        Parameters:
        allocations - resource allocations to be released
        Returns:
        true if succeeded, otherwise false
      • release

        default boolean release​(ResourceAllocation... allocations)
        Transactionally releases the specified resource allocations. All allocations are released when this method succeeded, or no allocation is released when this method fails.
        Parameters:
        allocations - resource allocations to be released
        Returns:
        true if succeeded, otherwise false
      • release

        boolean release​(ResourceConsumer consumer)
        Transactionally releases the resources allocated to the specified consumer. All allocations are released when this method succeeded, or no allocation is released when this method fails.
        Parameters:
        consumer - consumer whose allocated resources are to be released
        Returns:
        true if succeeded, otherwise false