The following table shows the versions of elasticsearch and jetty that Jetty Plugin was built with.
Jetty Plugin | Elasticsearch | Jetty |
---|---|---|
master | 0.19.2.RC2 | 7.4.5.v20110725 |
0.18.1-0.18.6 | 0.18.5 | 7.4.5.v20110725 |
0.18.0 | 0.18.4 | 7.4.5.v20110725 |
Jetty plugin consists of two modules that can be used independently: JettyHttpServerTransport and FilterHttpTransportModule.
JettyHttpServerTransportModule can be used as a replacement for NettyHttpServerTransport. It embeds a fully functional and configurable Jetty 7.4.5 server and includes two jetty handlers that simplify configuration and usage of jetty with elasticsearch: JettyHttpServerTransportHandler and RestConstraintSecurityHandler.
JettyHttpServerTransportHandler is Jetty handler that redirects all requests to elasticsearch. It can be used in conjunction with RestConstraintSecurityHandler. RestConstraintSecurityHandler is based on and quite similar to standard jetty ConstraintSecurityHandler. However, its handling of pathSpecs in constraints is better suited for elasticsearch. ConstraintSecurityHandler can only handle wildcards at the end of the url or if file extension is specified, which makes it unsuitable any indexing operation constraints. RestConstraintSecurityHandler is treating pathSpec the same way as ElasticSearch does and can use ElasticSearch url mapping syntax to specify constraint paths.
FilterHttpTransportModule intercepts all requests that HttpServerTransport sends to elasticsearch. It can maintained a chain of filters and can be used with jetty as well as netty transports. By default, FilterHttpTransportModule is configured to work with jetty. This plugin comes with two sample filters: LoggingFitlerHttpServerAdapter and TimeoutFilterHttpServerAdapter.
Jetty plugin can be installed as any other ES plugin using bin/plugin utility:
bin/plugin -install sonian/elasticsearch-jetty/0.18.6
After Jetty plugin is installed, it has to be enabled in elasticsearch.yml file by adding the following line:
http.type: com.sonian.elasticsearch.http.jetty.JettyHttpServerTransportModule
The embedded jetty is configured using standard jetty.xml file. By default, this file has to be located in the ES config directory. An alternative location can be specified using the sonian.elasticsearch.http.jetty.config
setting. In order to function properly, the Jetty configuration has to create JettyHttpServerTransportHandler
and add at least one internet connector. See jetty-minimal.xml for a minimal functional configuration. ElasticSearch is using the first available internet connector to determine bind and publish addresses of the http transport.
To get started, download jetty-minimal.xml file into config directory of elasticsearch home and rename it to jetty.xml. Now elasticsearch can be started.
curl https://raw.github.com/sonian/elasticsearch-jetty/master/config/jetty-minimal.xml -o config/jetty.xml
A more advanced configuration can be found in the config/elasticsearch.yml file. It meant to be used with the following jetty configuration file config/jetty.xml.
The sample configuraiton file shows how to enable request logging filter. By default, this filter is logging all rest requests at the INFO level into the same logging file as all other ElasticSearch messages. It’s possible to redirect request logging into a separate file. See config/logging.yml for more details.
Jetty plugin exposes several ES settings as Jetty properties that can be used in Jetty configuration files using <Property name="property.name"/>
es.home
– ElasticSearch home directoryes.config
– ElasticSearch configuration directoryes.data
– ElasticSearch data directoryes.cluster.data
– ElasticSearch data directory for the clusteres.cluster
– Cluster namejetty.bing_host
– Http bind host, if the settingsonian.elasticsearch.http.jetty.bind_host
is not specified, ElasticSearch will try to use values specified inhttp.bind_host
andhttp.host
settings.jetty.port
– Http port, if the settingsonian.elasticsearch.http.jetty.port
is not specified, ElasticSearch will try to use http.port or default to 9200-9300. If port is specified in form of the range, ElasticSearch will try to start Jetty with each individual port number iterating through the range.jetty.*
– all other settings specified insonian.elasticsearch.http.jetty.
are exposed as Jetty properties. For example, the settingsonian.elasticsearch.http.jetty.foo
can be referred to in Jetty configuration as .
Join elasticsearch-jetty group for questions and discussions related to this plugin.
Here’s a list of currently known links that attempt to automate the process of installing ES & the elasticsearch-jetty plugin:
- https://github.com/pulkitsinghal/cookbook-elasticsearch
- can also be mixed & matched to install/configure the following plugins: head, river-couchdb & cloud-aws