The LoadBalancingContext object
All DefaultBackgroundTaskLoadBalancingPlugin methods require that you
pass a LoadBalancingContext object as you execute the method. Public
interface LoadBalancingContext provides the following methods.
| Method | Returns | Description |
|---|---|---|
getAllComponents() |
List<ComponentInfo> |
Method returns a list of all components running in the cluster. |
requestTransferToThisServer(component) |
Boolean | Method requests the transfer of the given component to this server. Use the
getAllComponents and the
ComponentInfo.getServerId methods to obtain the current owner
of a component. The component transfer itself is an asynchronous process. This
method returns |
isAllowedToStartOnThisServer(component) |
Boolean | Method returns true if it is possible to start the given
component on the current server. |
getTransferInfo(component, unit,
timeout) |
TransferInfo |
Given a specific component (component), the method returns
information on the component transfer or null if the transfer
attempt timed out.Parameters timeout and unit provide the time to wait before the transfer request times out. |
scheduleComponentAvailabilityCheck(delay,
unit) |
-- | Method schedules a component availability check. If a component is available to
start, this method calls either of the following methods on the
BackgroundTaskLoadBalancingPlugin plugin:
Parameters delay and unit provide the time to wait before performing the availability check. |
The return
TransferInfo object has two useful methods:- getCurrentOwner - Method returns the current owner of the
component. If the method returns
null, it means that the component is already stopped. - getTargetOwner - Method returns the owner of the target component.
It cannot return
null.
