@ThreadSafe public class SbcResourceManager extends Object implements BalancerResourceManager
SbcEventQueue
thread.Modifier and Type | Field and Description |
---|---|
protected static org.slf4j.Logger |
LOG |
Constructor and Description |
---|
SbcResourceManager(SbcEventQueue resubmitQ) |
Modifier and Type | Method and Description |
---|---|
void |
clearAllResourcesAndWaiters()
Forget about all current resource values and resource waiters.
|
Deque<SbcEvent> |
eventWaiters(SbcResource<?> resourceId)
Access the list of events waiting on an SbcResource.
|
<R> Optional<R> |
maybeGetResourceValue(SbcResource<R> resourceId)
Look up the current value of the given SbcResource.
|
<R> void |
provideResource(SbcResource<R> resourceId,
R resourceValue)
Provide the given SbcResource (associate the SbcResource name with a value).
|
void |
waitOnResource(SbcResource<?> resourceId,
SbcEvent event)
Wait for a
provideResource(SbcResource, Object) call to be made on a specified SbcResource. |
public SbcResourceManager(SbcEventQueue resubmitQ)
public <R> void provideResource(SbcResource<R> resourceId, R resourceValue)
provideResource
in interface BalancerResourceManager
R
- the type of the resource's valueresourceId
- the identifier for the SbcResource being providedresourceValue
- the value to assign to the resourceId.public <R> Optional<R> maybeGetResourceValue(SbcResource<R> resourceId)
maybeGetResourceValue
in interface BalancerResourceManager
R
- the type of the resource valueresourceId
- the identifier for the SbcResource beingpublic void waitOnResource(SbcResource<?> resourceId, SbcEvent event)
provideResource(SbcResource, Object)
call to be made on a specified SbcResource.
This method DOES NOT affect ongoing execution (if any) of event
, so if it's called by the event that wishes to wait,
the event should stop execution immediately after this.waitOnResource
in interface BalancerResourceManager
resourceId
- the SbcResource which needs to be provided. Waiting on the NONE resource will not suspend the event.event
- the SbcEvent that is waiting on the SbcResource. This SbcEvent will be submitted for execution once the SbcResource is provided.public void clearAllResourcesAndWaiters()
clearAllResourcesAndWaiters
in interface BalancerResourceManager
public Deque<SbcEvent> eventWaiters(SbcResource<?> resourceId)
resourceId
- the SbcResource to get waiters for.