public abstract class AbstractHostLBSPolicy extends AbstractLBSPolicy
Modifier and Type | Class and Description |
---|---|
static interface |
AbstractHostLBSPolicy.InitParams |
journalRef, serviceIDRef, serviceTableRef
Constructor and Description |
---|
AbstractHostLBSPolicy() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
conditionallyForwardReadRequest(HALoadBalancerServlet servlet,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Hook provides the
IHALoadBalancerPolicy with an opportunity to
forward a read-request to the local service rather than proxying the
request to a service selected by the load balancer (a local forward has
less overhead than proxying to either the local host or a remote service,
which makes it more efficient under some circumstances to handle the
read-request on the service where it was originally received). |
protected void |
conditionallyUpdateServiceTable()
Extended to conditionally update the
hostTableRef iff it does
not exist or is empty. |
void |
destroy()
Destroy the policy (stop any asynchronous processing, release any
resources).
|
protected abstract String |
getDefaultScoringRule()
Return the name of the
IHostScoringRule that provides default
value for the AbstractHostLBSPolicy.InitParams.HOST_SCORING_RULE configuration
parameter. |
protected long |
getHostDiscoveryDelay()
The delay between discovery cycles that updates our local knowledge of
the load on each host.
|
protected abstract Map<String,IHostMetrics> |
getHostReportForKnownServices(IHostScoringRule scoringRule,
ServiceScore[] serviceScores)
Return a map from the known canonical hostnames (as self-reported by the
services) of the joined services to the
IHostMetrics s for those
hosts. |
String |
getReaderURI(javax.servlet.http.HttpServletRequest req)
Return the Request-URL to which a read-only request will
be proxied.
|
void |
init(javax.servlet.ServletConfig servletConfig,
IIndexManager indexManager)
Initialize the policy.
|
void |
setLocalForwardThreshold(double newValue) |
protected void |
toString(StringBuilder sb)
Extension hook for
AbstractLBSPolicy.toString() - implementation MUST NOT block. |
protected void |
updateHostTable()
Update the per-host scoring table.
|
protected void |
updateServiceTable()
Overridden to also update the hosts table in case we add/remove a service
and the set of hosts that cover the member services is changed as a
result.
|
getJournal, getLeaderURI, getLocalServiceScore, getServiceScoreForHostname, notify, service, toString
protected abstract String getDefaultScoringRule()
IHostScoringRule
that provides default
value for the AbstractHostLBSPolicy.InitParams.HOST_SCORING_RULE
configuration
parameter.
Note: The policy needs to be specific to the LBS implementation since the names of the host metrics depend on the system that is being used to collect and report them.
protected long getHostDiscoveryDelay()
protected void toString(StringBuilder sb)
AbstractLBSPolicy
AbstractLBSPolicy.toString()
- implementation MUST NOT block.toString
in class AbstractLBSPolicy
sb
- Buffer where you can write additional state.public void init(javax.servlet.ServletConfig servletConfig, IIndexManager indexManager) throws javax.servlet.ServletException
IHAPolicyLifeCycle
init
in interface IHAPolicyLifeCycle
init
in class AbstractLBSPolicy
javax.servlet.ServletException
public void destroy()
IHAPolicyLifeCycle
destroy
in interface IHAPolicyLifeCycle
destroy
in class AbstractLBSPolicy
public void setLocalForwardThreshold(double newValue)
protected void conditionallyUpdateServiceTable()
hostTableRef
iff it does
not exist or is empty.conditionallyUpdateServiceTable
in class AbstractLBSPolicy
protected void updateServiceTable()
updateServiceTable
in class AbstractLBSPolicy
AbstractLBSPolicy.serviceTableRef
protected void updateHostTable()
hostTableRef
public String getReaderURI(javax.servlet.http.HttpServletRequest req)
IHALoadBalancerPolicy
req
- The request.null
if we could not
find a service to which we could proxy this request.protected boolean conditionallyForwardReadRequest(HALoadBalancerServlet servlet, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException
IHALoadBalancerPolicy
with an opportunity to
forward a read-request to the local service rather than proxying the
request to a service selected by the load balancer (a local forward has
less overhead than proxying to either the local host or a remote service,
which makes it more efficient under some circumstances to handle the
read-request on the service where it was originally received).
If the normalized availability for this host is over a configured threshold, then we forward the request to the local service. This help to reduce the latency of the request since it is not being proxied.
conditionallyForwardReadRequest
in class AbstractLBSPolicy
IOException
AbstractHostLBSPolicy.InitParams.LOCAL_FORWARD_THRESHOLD
protected abstract Map<String,IHostMetrics> getHostReportForKnownServices(IHostScoringRule scoringRule, ServiceScore[] serviceScores)
IHostMetrics
s for those
hosts.scoringRule
- The IHostScoringRule
to be applied.serviceScores
- The set of known services.UUID
and
the host metrics were combined into the map once for each
service.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.