org.ocap.resource
Interface ResourceContentionHandler2

All Superinterfaces:
ResourceContentionHandler

public interface ResourceContentionHandler2
extends ResourceContentionHandler

A class implementing this interface decides which application(s) shall be allowed to reserve a resource.

An application which has been granted MonitorAppPermission("handler.resource") MAY set an instance of this interface as the current resource contention handler with the ResourceContentionManager.

The resolveResourceContention(ResourceUsage[], ResourceUsage[]) method SHALL be invoked to decide how to resolve conflicts due to one ore more enqueued requests (as MAY be enabled via ResourceContext.setRequestRetry(org.ocap.resource.RequestRetryCallback)) or simultaneous implicit reservations, and existing resource allocations. The ResourceContentionHandler.resolveResourceContention(ResourceUsage,ResourceUsage[]) method SHALL be invoked to decide how to resolve conflicts due to a single reservation request and existing resource allocations.

See Also:
ResourceContentionManager

Method Summary
 ResourceUsage[] resolveResourceContention(ResourceUsage[] batchRequests, ResourceUsage[] currentReservations)
          This method notifies the ResourceContentionHandler that resource contentions have occurred between one or more applications and system modules, except the Emergency Alert System (EAS) module.
 
Methods inherited from interface org.ocap.resource.ResourceContentionHandler
resolveResourceContention, resourceContentionWarning
 

Method Detail

resolveResourceContention

ResourceUsage[] resolveResourceContention(ResourceUsage[] batchRequests,
                                          ResourceUsage[] currentReservations)
This method notifies the ResourceContentionHandler that resource contentions have occurred between one or more applications and system modules, except the Emergency Alert System (EAS) module. EAS system module resource requests SHALL be given the highest priority by the implementation and resource requests by this module SHALL not be reported to the ResourceContentionHandler. In the case of one application, the same application is conflicting with itself and a registered ResourceContentionHandler SHALL be notified in this case.

Each entry in the batchRequests indicates a set of resources for which there is a current or outstanding reservation request by an application for a single activity. Each entry in the currentReservations indicates a set of resources reserved by an application for a single activity such as a resource usage by a single service context. There may be multiple entries in these lists from a single application. An entry may correspond to a current resource usage or resource reservations for a future activity.

A prioritized array of ResourceUsage instances is returned. The array is in priority order from highest to lowest indicating the priority order to be followed by the implementation while resolving the conflicts. When this method returns the implementation will iterate through each entry in the array in the order of priority, awarding resources as required by the activity represented by the resourceUsage. The ResourceContentionHandler may use information such as application priority or resource priority to prioritize the array of ResourceUsages returned. When the value returned is not null the ResourceContentionHandler MAY return an array containing all of the ResourceUsage objects passed to it, or it MAY return a subset of those objects.

Parameters:
batchRequests - The set of resource usage objects containing the attributes of the current outstanding resource request(s)
currentReservations - The set of resource usage objects that describe current resource reservations which are in conflict with the batchRequests. A ResourceUsage associated with a current reservation MAY belong to an application that has been destroyed. Use of the AppID contained within such a ResourceUsage with any of the methods in org.dvb.application.AppsDatabase MAY cause a failure status to be returned.
Returns:
A prioritized array of resource usage objects. The first entry has the highest priority. This function returns null if the contention handler wants the implementation to resolve the conflict.