Interface RequestReactorIfc

  • All Known Implementing Classes:
    RequestReactorAdapter

    public interface RequestReactorIfc
    This interface essentially provides a mechanism for ResourceUnits to communicate with the user of the resource. Prepared - prepared to use a resource Waiting = waiting for resource, can only transition to Using or Canceled Rejected = rejected after creation, no further transitions Canceled = canceled after allocation or prepared, no further transitions Allocated = using the resource, may preempt, cancel, or complete Preempted = using the resource but preempted, can resume or cancel Completed = completed its life-cycle, no further transitions Whenever a Request is sent to a ResourceUnit, as it changes state these interaction methods are called. This gives objects that submit requests to resources to react if needed to these changes in state for the associated request. For example, if a request is preempted, there may be additional actions that the sender of the request might want to do that is not handled in the standard logic associated with the ResourceUnit. Also, the sender of the request can respond upon completion of the request and then perform other activities. Rejections will automatically throw an exception unless handled via the rejected() method
    • Method Detail

      • prepared

        void prepared​(Request request)
        Called when the request is placed in the prepared state. The request is now prepared to use the resource.
        Parameters:
        request - the request
      • enqueued

        void enqueued​(Request request,
                      Queue<Request> queue)
        Called when the request is placed in the waiting state
        Parameters:
        request - the request
        queue - the queue that was entered
      • dequeued

        void dequeued​(Request request,
                      Queue<Request> queue)
        Called when the request is dequeued from the waiting state
        Parameters:
        request - the request
        queue - the queue that was exited
      • rejected

        default void rejected​(Request request)
        Called when the request is placed in the rejected state. The default behavior is to throw an IllegalStateException. Rejection generally means that there was a mismatch between what the request specified for the preemption rule and what the resource permits. Not every mismatch is an error, so users can override this method to provide alternate reaction to a rejection.
        Parameters:
        request - the request
      • canceled

        void canceled​(Request request)
        Called when the request is placed in the canceled state
        Parameters:
        request - the request
      • preempted

        void preempted​(Request request)
        Called when the request is placed in the preempted state
        Parameters:
        request - the request
      • resumed

        void resumed​(Request request)
        Called when the request is resumed from the preempted state
        Parameters:
        request - the request
      • allocated

        void allocated​(Request request)
        Called when the request is placed in the using state
        Parameters:
        request - the request
      • completed

        void completed​(Request request)
        Called when the request is placed in the completed state
        Parameters:
        request - the request