A component is any Java class whose lifetime is controlled by the container, see the Developer Guide for an introduction. Components are specified and configured in services.xml and can have other components, and config (represented by generated "Config" classes) injected at construction time, and in turn be injected into other components.
Whenever a component or a resource your component depends on is changed by a redeployment, your component is reconstructed. Once all changed components are reconstructed, new requests are atomically switched to use the new set and the old ones are destructed.
If you have multiple constructors in your component, annotate the one to use for injection by
Identifiable components must implement com.yahoo.component.Component, and components that need to destruct resources at removal must subclass com.yahoo.component.AbstractComponent and implement deconstruct().
Vespa defined various component types (superclasses) for common tasks:
The processing framework can be used to create general composable synchronous request-response systems. Searchers and search chains are an instantiation (through subclasses) of this general framework for a specific domain. Processors are invoked synchronously and the response is a tree of arbitrary data elements. Custom output formats can be defined by adding renderers.
Renderers convert a Response (or query Result) into a serialized form sent over the network.
Renderers are subclasses of
Searchers processes Queries and their Results. Since they are synchronous, they can issue multiple queries serially or in parallel to e.g. implement federation or decorate queries with information fetched from a content cluster. Searchers are composed into search chains defined in services.xml. A query request selects a particular search chain which implements the logic of that query. Read more.
Document processors processes incoming document operations. Similar to Searchers and Processors they can be composed in chains, but document processors are asynchronous. Read more.
A binding matches a request URI to the correct filter chain or request handler, and route outgoing requests to the correct client. For instance, the binding http://*/* would match any HTTP request, while http://*/processing would only match that specific path. If several bindings match, the most specific one is chosen.
A filter is a lightweight request checker. It may set some specific request property, or it may do security checking and simply block requests missing some mandatory property or header.
Clients, or client providers, are implementations of clients for different protocols, or special rules for given protocols. When a JDisc application acts as a client, e.g. fetches a web page from another host, it is a client provider that handles the transaction. Bindings are used, as with request handlers and filters, to choose the correct client, matching protocol, server, etc., and then hands off the request to the client provider. There is no problem in using arbitrary other types of clients for external services in processors and request handlers.
This illustrates a typical component configuration set up by the Vespa container:
The network layer associates a Request with a response handler and routes it to the correct type of request handler (typically based on URI binding patterns).
If an application needs lightweight request-response processing using decomposition by a series of chained logical units, the processing framework is the correct family of components to use. The request will be routed from ProcessingHandler through one or more chains of Processor instances. The exact format of the output is customizable using a Renderer.
If doing queries, SearchHandler will create a Query object, route that to the pertinent chain of Searcher instances, and associate the returned Result with the correct Renderer instance for optional customization of the output format.
The DocumentProcessingHandler is usually invoked from messagebus, and used for feeding documents into an index or storage. The incoming data is used to build a Document object, and this is then feed through a chain of DocumentProcessor instances.
If building an application with custom HTTP APIs, for instance arbitrary REST APIs, the easiest way is building a custom RequestHandler. This gets the Request, which is basically a set of key-value pairs, and returns a stream of arbitrary data back to the network.
These components are available from Vespa to applications in various contexts.
Configuration is injected into components as
||Use to emit metrics from a component. Find an example in the metrics guide.|
||Use to keep values that are logged periodically. Support for min/max/avg/sum and histograms, see statistics.|
Inject a Linguistics component like
||Provides the application's Athenz-identity and gives access to identity/role certificate and tokens.|
A client for ZooKeeper. For use in container clusters that have ZooKeeper enabled. See using ZooKeeper.
||Default threadpool for processing requests in threaded request handler|
||Use this to gain control over the service status (up/down) to be emitted from this container.|
||Jdisc core interface for metrics. Required by all sub-classes of ThreadedRequestHandler.|
|Available in containers having
||To execute new queries from code. Read more.|
||Use to inject a set of Models, see Stateless Model Evaluation.|
|Available in containers having
||To use the Document API.|
|Available in the Vespa Cloud|
||Secret store interface - use this to get secrets and list secret versions.|
||Provides information about the environment the component is running in. Read more.|
Components as well as many other artifacts in the container can be versioned. This document explains the format and semantics of these versions and how they are referred.
Versions are on the form:
version ::= major [ "." minor [ "." micro [ "." qualifier ]]]
micro are integers
qualifier is any string.
A version is appended to an id separated by a colon. In cases where a file is created for each component version, the colon is replaced by a dash in the file name.
Versions are ordered first by major, then minor, then micro and then
by doing a lexical ordering on the qualifier.
This means that
a:1 < a:1.0 < a:1.0.0 < a:1.1 < a:1.1.0 < a:2
Whenever component is referenced by id (in code or configuration),
a fully or partially specified version may be included in the reference
by using the form
Such references are resolved using the following rules:
Example: Given a component with id
a having these versions:
[1.1, 1.2, 1.2, 1.3.test, 2.0]
awill resolve to
a:1will resolve to
In some cases, there is a need for merging multiple references into one. An example is inheritance of chains of version references, where multiple inherited chains may reference the same component.
Two version references are said to be compatible if one is a prefix of the other. In this case the most specific version is used. If they are not compatible they are conflicting. Example:
<search> <searcher id="Searcher:2.3" class="com.yahoo.search.example.Searcher" bundle="the name in <artifactId> in your pom.xml" /> <searcher id="Searcher:2.4" class="com.yahoo.search.example.Searcher" bundle="the name in <artifactId> in your pom.xml" /> <chain id="parenta"> <searcher id="Searcher:2"> bundle="the name in <artifactId> in your pom.xml" </searcher> </chain> <chain id="parentb"> <searcher id="Searcher:2.3"> bundle="the name in <artifactId> in your pom.xml" </searcher> </chain> <chain id="parentc"> <searcher id="Searcher:2.4"> bundle="the name in <artifactId> in your pom.xml" </searcher> </chain> <!-- This chain will get Searcher:2.3 --> <chain id="childa" inherits="parenta parentb" /> <!-- Error, as Searcher:2.3 and Searcher:2.4 are conflicting --> <chain id="childb" inherits="parentb parentc" /> </search>