LoginSignup
13
13

More than 5 years have passed since last update.

[Apache Solr] Jettyについて

Posted at

Apache Solr

Apache Solr は デフォルトでJettyがサーブレットとしてついています。
Tomcatに変える人もいるようですが、Jettyもなかなか性能がいいようなので、
Jettyについて調べたことのメモです。

Jetty とは

Jetty は、100%Javaで開発されたJava Servletコンテナ/Webサーバである。WebSocketなどのプロトコルもサポートする。Jetty はオープンソースプロジェクトとして開発され、Apache 2.0 License でリリースされている。JBoss、Apache Geronimoといった他のプロジェクトでも利用されている。
単純で効率的な組み込みやすいWebサーバとなるよう意図して開発されている。サイズが小さいので、組み込み型 Java アプリケーションにWebサービスを提供するのに適している。
その一方で、Apache HadoopやGoogle App Engineといった大規模でスケーラビリティが重視されるサービスにおいても採用されている[2]。
2009年1月、WebtideはJettyのコアコンポーネントをcodehausからEclipse Foundationに移管することを発表した。

サーブレットの一種でTomcatと双璧をなしているらしい。GAEで採用されているのはびっくりした。
Hadoopもそうなんだね。それならSolrがJettyで動いてても不思議じゃない気がしてきた。

データソースの設定

JETTY_HOME/
+contexts/
| +testds.xml(※1)
+lib/
| +ext/(※2)
| +commons-dbcp-1.4.jar
| +commons-ppol-1.5.4.jar
| +postgresql-8.3-605.jdbc4.jar
|
+webapps/
+testds/(※3)
+WEB-INF/
+web.xml
※1: アプリケーションコンテキストの設定の中でデータソースに関する設定を記述します。
※2: データソースを利用するためのコネクションプールやJDBCドライバのjarファイルを置きます。
※3: web.xmlにresource-ref要素の設定を行います(これはTomcatなどの他のAPサーバと同じです)

上記のような構成になっている模様。
たしかにSolrもこんな感じになってた。

/solr-4.7.0/example の下は、
$ tree
.
├── README.txt
├── contexts
│   └── solr-jetty-context.xml ◀
├── etc
│   ├── create-solrtest.keystore.sh
│   ├── jetty.xml
│   ├── solrtest.keystore
│   └── webdefault.xml
├── example-DIH
├── example-schemaless
├── exampledocs
├── lib ◀
│   ├── ext
│   │   ├── jcl-over-slf4j-1.6.6.jar
│   │   ├── jul-to-slf4j-1.6.6.jar
│   │   ├── log4j-1.2.16.jar
│   │   ├── slf4j-api-1.6.6.jar
│   │   └── slf4j-log4j12-1.6.6.jar
│   ├── jetty-continuation-8.1.10.v20130312.jar
│   ├── jetty-deploy-8.1.10.v20130312.jar
│   ├── jetty-http-8.1.10.v20130312.jar
│   ├── jetty-io-8.1.10.v20130312.jar
│   ├── jetty-jmx-8.1.10.v20130312.jar
│   ├── jetty-security-8.1.10.v20130312.jar
│   ├── jetty-server-8.1.10.v20130312.jar
│   ├── jetty-servlet-8.1.10.v20130312.jar
│   ├── jetty-util-8.1.10.v20130312.jar
│   ├── jetty-webapp-8.1.10.v20130312.jar
│   ├── jetty-xml-8.1.10.v20130312.jar
│   └── servlet-api-3.0.jar
├── logs
├── multicore
├── resources
├── scripts
├── solr
├── solr-webapp
├── start.jar
└── webapps ◀
└── solr.war

こんな風になっており、上のJettyのデータ構造を参考にすると、
◀「黒矢印」をつけた部分が Jetty 用の設定だということがわかる。

コンテキスト

コンテキストパスが、/solr
実行warが、/webapps/solr.war
defaultsDescriptorが、/etc/webdefault.xml
tempDirectoryが、/solr-webapp
と書いてあるだけ。短い。

vim contexts/solr-jetty-context.xml

solr-jetty-context.xml
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Set name="contextPath"><SystemProperty name="hostContext" default="/solr"/></Set>
  <Set name="war"><SystemProperty name="jetty.home"/>/webapps/solr.war</Set>
  <Set name="defaultsDescriptor"><SystemProperty name="jetty.home"/>/etc/webdefault.xml</Set>
  <Set name="tempDirectory"><Property name="jetty.home" default="."/>/solr-webapp</Set>
</Configure>

war

ということでSolrをJettyで動かした時、warがメインで動いていることがわかった。

次はwarの中身について解説する。

参考リンク

http://ja.wikipedia.org/wiki/Jetty
http://ultimania.org/trac/yuna/wiki/java/Jetty

13
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
13