voldemort.utils.pool
Interface AsyncResourceRequest<V>


public interface AsyncResourceRequest<V>

Interface for asynchronous requests for resources. Exactly one of useResource, handleTimeout, or handleException expected to be invoked before, or soon after, deadline specified by getDeadlineNs. Ideally, useResource is only invoked before the deadline. Ideally, handleTimeout is invoked soon after the deadline. If owners of an object with this interface need to take action after some specified timeout, then the owner needs to set their own timer.


Method Summary
 long getDeadlineNs()
           
 void handleException(java.lang.Exception e)
          Invoked upon exception trying to process resource request.
 void handleTimeout()
          Invoked sometime (soon) after deadline.
 void useResource(V resource)
          To be invoked with resource to use before deadline.
 

Method Detail

useResource

void useResource(V resource)
To be invoked with resource to use before deadline.

Parameters:
resource - resource should not be null.

handleTimeout

void handleTimeout()
Invoked sometime (soon) after deadline.


handleException

void handleException(java.lang.Exception e)
Invoked upon exception trying to process resource request. Invoked before or (soon) after the deadline.

Parameters:
e -

getDeadlineNs

long getDeadlineNs()
Returns:
Deadline (in nanoseconds), after which handleTimeout() should be invoked.


Jay Kreps, Roshan Sumbaly, Alex Feinberg, Bhupesh Bansal, Lei Gao, Chinmay Soman, Vinoth Chandar, Zhongjie Wu