Package org.onosproject.net.resource
Interface ResourceService
-
- All Superinterfaces:
ListenerService<ResourceEvent,ResourceListener>
,ResourceQueryService
@Beta public interface ResourceService extends ResourceQueryService, ListenerService<ResourceEvent,ResourceListener>
Service for allocating/releasing resource(s) and retrieving allocation(s) and availability.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.util.List<ResourceAllocation>
allocate(ResourceConsumer consumer, java.util.List<? extends Resource> resources)
Transactionally allocates the specified resources to the specified user.default java.util.Optional<ResourceAllocation>
allocate(ResourceConsumer consumer, Resource resource)
Allocates the specified resource to the specified user.default java.util.List<ResourceAllocation>
allocate(ResourceConsumer consumer, Resource... resources)
Transactionally allocates the specified resources to the specified user.boolean
release(java.util.List<ResourceAllocation> allocations)
Transactionally releases the specified resource allocations.default boolean
release(ResourceAllocation allocation)
Releases the specified resource allocation.default boolean
release(ResourceAllocation... allocations)
Transactionally releases the specified resource allocations.boolean
release(ResourceConsumer consumer)
Transactionally releases the resources allocated to the specified consumer.-
Methods inherited from interface org.onosproject.event.ListenerService
addListener, removeListener
-
Methods inherited from interface org.onosproject.net.resource.ResourceQueryService
getAvailableResources, getAvailableResources, getAvailableResourceValues, getRegisteredResources, getResourceAllocations, getResourceAllocations, getResourceAllocations, isAvailable
-
-
-
-
Method Detail
-
allocate
default java.util.Optional<ResourceAllocation> allocate(ResourceConsumer consumer, Resource resource)
Allocates the specified resource to the specified user.- Parameters:
consumer
- resource user which the resource is allocated toresource
- resource to be allocated- Returns:
- allocation information enclosed by Optional. If the allocation fails, the return value is empty
-
allocate
java.util.List<ResourceAllocation> allocate(ResourceConsumer consumer, java.util.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 toresources
- resources to be allocated- Returns:
- non-empty list of allocation information if succeeded, otherwise empty list
-
allocate
default java.util.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 toresources
- 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(java.util.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
-
-