public abstract class ClusterSearcher<T> extends PingableSearcher implements NodeManager<T>
This replaces the usual searcher methods by ones which have the same contract and semantics but which takes an additional parameter which is the Connection selected by the cluster searcher which the method should use. Overrides of these connection methods must not call the super methods to pass on but must use the methods on execution.
The type argument is the class (of any type) representing the connections. The connection objects should implement a good toString to ease diagnostics.
Modifier and Type | Class and Description |
---|---|
private class |
ClusterSearcher.Pinger |
Modifier and Type | Field and Description |
---|---|
private Hasher<T> |
hasher |
private ClusterMonitor<T> |
monitor |
Constructor and Description |
---|
ClusterSearcher(com.yahoo.component.ComponentId id,
List<T> connections,
boolean internal)
Creates a new cluster searcher
|
ClusterSearcher(com.yahoo.component.ComponentId id,
List<T> connections,
Hasher<T> hasher,
boolean internal) |
Modifier and Type | Method and Description |
---|---|
void |
deconstruct() |
private void |
doFill(T connection,
Result result,
String summaryClass,
Execution execution) |
void |
failed(T node)
NodeManager method, called from ClusterMonitor
|
void |
fill(Result result,
String summaryClass,
Execution execution)
Fill hit properties with data using the given summary class.
|
protected abstract void |
fill(Result result,
String summaryClass,
Execution execution,
T connection)
Perform the fill against the given connection.
|
protected T |
getFirstConnection(Hasher.NodeList<T> nodes,
int code,
int trynum,
Query query) |
Hasher<T> |
getHasher()
Returns the hasher used internally in this.
|
ClusterMonitor<T> |
getMonitor()
Returns the monitor of these nodes
|
protected void |
log(Level level,
Object... objects) |
protected abstract Pong |
ping(Ping ping,
T connection)
Pings this connection.
|
void |
ping(T p,
Executor executor)
Pinging a node, called from ClusterMonitor
|
protected Result |
robustSearch(Query query,
Execution execution,
T connection)
Call search(Query,Execution,T) and handle any exceptions returned which
we do not want to propagate upwards By default this catches all runtime
exceptions and puts them into the result
|
Result |
search(Query query,
Execution execution)
Override this to implement your searcher.
|
protected Result |
search(Query query,
Execution execution,
ErrorMessage message)
This is called (instead of search(quer,execution,connextion) to handle
searches where no (suitable) backend was available.
|
protected abstract Result |
search(Query query,
Execution execution,
T connection)
Perform the search against the given connection.
|
protected boolean |
shouldRetry(Query query,
Result result)
Returns whether this query and result should be retried against another
connection if possible.
|
protected boolean |
timedOut(Query query)
Returns true if this query has timed out now
|
void |
working(T node)
NodeManager method, called from ClusterMonitor
|
ping
ensureFilled, getLogger, process, toString
getAnnotatedDependencies, getDefaultAnnotatedDependencies, getDependencies, initDependencies
clone, compareTo, getClassName, getId, getIdString, hasInitializedId, initId, isDeconstructable, setIsDeconstructable
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
pingIterationCompleted
private final ClusterMonitor<T> monitor
public ClusterSearcher(com.yahoo.component.ComponentId id, List<T> connections, boolean internal)
id
- the id of this searcherconnections
- the connections of the clusterinternal
- whether or not this cluster is internal (part of the same installation)public final void ping(T p, Executor executor)
ping
in interface NodeManager<T>
protected abstract Pong ping(Ping ping, T connection)
protected T getFirstConnection(Hasher.NodeList<T> nodes, int code, int trynum, Query query)
public final Result search(Query query, Execution execution)
Searcher
Searcher implementation subclasses will, depending on their type of logic, do one of the following:
Hits come in two kinds - concrete hits are actual content of the kind requested by the user, meta hits are hits which provides information about the collection of hits, on the query, the service and so on.
The query specifies a window into a larger result list that must be returned from the searcher through hits and offset; Searchers which returns list of hits in the top level in the result must return at least hits number of hits (or if impossible; all that are available), starting at the given offset. In addition, searchers are allowed to return any number of meta hits (although this number is expected to be low). For hits contained in nested hit groups, the concept of a window defined by hits and offset is not well defined and does not apply.
Error handling in searchers:
protected boolean shouldRetry(Query query, Result result)
protected Result search(Query query, Execution execution, ErrorMessage message)
protected Result robustSearch(Query query, Execution execution, T connection)
protected abstract Result search(Query query, Execution execution, T connection)
public final void fill(Result result, String summaryClass, Execution execution)
Searcher
This needs to be overridden by federating searchers to contact search sources again by propagating the fill call down through the search chain, and by source searchers which talks to fill capable backends to request the data to be filled. Other searchers do not need to override this.
protected abstract void fill(Result result, String summaryClass, Execution execution, T connection)
public void working(T node)
working
in interface NodeManager<T>
public void failed(T node)
failed
in interface NodeManager<T>
public Hasher<T> getHasher()
public ClusterMonitor<T> getMonitor()
protected boolean timedOut(Query query)
public void deconstruct()
deconstruct
in class com.yahoo.component.AbstractComponent
Copyright © 2018. All rights reserved.