[DOCS] Added transport client info for X-Pack (elastic/x-pack-elasticsearch#2737)

* [DOCS] Added transport client info for X-Pack

* [DOCS] Relocated X-Pack java client info

* [DOCS] Added transport client deprecation info

Original commit: elastic/x-pack-elasticsearch@416aab1d76
This commit is contained in:
Lisa Cawley 2017-10-12 13:18:44 +01:00 committed by GitHub
parent 0299886388
commit 604229cd4d
4 changed files with 132 additions and 108 deletions

View File

@ -220,6 +220,8 @@ For more information, see
{xpack-ref}/setting-up-authentication.html#set-built-in-user-passwords[Setting Built-in User Passwords]. {xpack-ref}/setting-up-authentication.html#set-built-in-user-passwords[Setting Built-in User Passwords].
-- --
. Optional: <<setup-xpack-client, Configure the Java Client>>.
. {kibana-ref}/installing-xpack-kb.html[Install {xpack} on {kib}]. . {kibana-ref}/installing-xpack-kb.html[Install {xpack} on {kib}].
. {logstash-ref}/installing-xpack-log.html[Install {xpack} on Logstash]. . {logstash-ref}/installing-xpack-log.html[Install {xpack} on Logstash].

View File

@ -16,120 +16,21 @@ NOTE: Using the Java Node Client with secured clusters is not recommended or
To use the transport client with a secured cluster, you need to: To use the transport client with a secured cluster, you need to:
[[java-transport-client-role]] [[java-transport-client-role]]
. <<xpack-javaclient, Set up the client for use with {xpack}>>.
. Configure a user with the privileges required to start the transport client. . Configure a user with the privileges required to start the transport client.
A default `transport_client` role is built-in to {xpack} that grants the A default `transport_client` role is built-in to {xpack} that grants the
appropriate cluster permissions for the transport client to work with the secured appropriate cluster permissions for the transport client to work with the secured
cluster. The transport client uses the _Nodes Info API_ to fetch information about cluster. The transport client uses the _Nodes Info API_ to fetch information about
the nodes in the cluster. the nodes in the cluster.
. Add the {xpack} transport JAR file to your CLASSPATH. You can download the {xpack}
distribution and extract the JAR file manually or you can get it from the
https://artifacts.elastic.co/maven/org/elasticsearch/client/x-pack-transport/{version}/x-pack-transport-{version}.jar[Elasticsearch Maven repository].
+
As with any dependency, you will also need its transitive dependencies. Refer to the
https://artifacts.elastic.co/maven/org/elasticsearch/client/x-pack-transport/{version}/x-pack-transport-{version}.pom[X-Pack POM file
for your version] when downloading for offline usage.
--
If you are using Maven, you need to add the {xpack} JAR file as a dependency in
your project's `pom.xml` file:
[source,xml]
--------------------------------------------------------------
<project ...>
<repositories>
<!-- add the elasticsearch repo -->
<repository>
<id>elasticsearch-releases</id>
<url>https://artifacts.elastic.co/maven</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
...
</repositories>
...
<dependencies>
<!-- add the x-pack jar as a dependency -->
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>x-pack-transport</artifactId>
<version>{version}</version>
</dependency>
...
</dependencies>
...
</project>
--------------------------------------------------------------
If you are using Gradle, you need to add the {xpack} JAR file as a dependency in
your `build.gradle` file:
[source,groovy]
--------------------------------------------------------------
repositories {
/* ... Any other repositories ... */
// Add the Elasticsearch Maven Repository
maven {
url "https://artifacts.elastic.co/maven"
}
}
dependencies {
compile "org.elasticsearch.client:x-pack-transport:{version}"
/* ... */
}
--------------------------------------------------------------
--
If you are using a repository manager such as https://www.sonatype.com/nexus-repository-oss[Nexus OSS] within your
company, you need to add the repository as per the following screenshot:
image::images/nexus.png["Adding the Elastic repo in Nexus",link="images/nexus.png"]
Then in your project's `pom.xml` if using maven, add the following repositories and dependencies definitions:
[source,xml]
--------------------------------------------------------------
<dependencies>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>x-pack-transport</artifactId>
<version>{version}</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>local-nexus</id>
<name>Elastic Local Nexus</name>
<url>http://0.0.0.0:8081/repository/elasticsearch/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
--------------------------------------------------------------
. Set up the transport client. At a minimum, you must configure `xpack.security.user` to . Set up the transport client. At a minimum, you must configure `xpack.security.user` to
include the name and password of your transport client user in your requests. The include the name and password of your transport client user in your requests. The
following snippet configures the user credentials globally--every request following snippet configures the user credentials globally--every request
submitted with this client includes the `transport_client_user` credentials in submitted with this client includes the `transport_client_user` credentials in
its headers. its headers.
+ +
--
[source,java] [source,java]
------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------
import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient; import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient;
@ -143,20 +44,20 @@ TransportClient client = new PreBuiltXPackTransportClient(Settings.builder()
.addTransportAddress(new InetSocketTransportAddress("localhost", 9300)) .addTransportAddress(new InetSocketTransportAddress("localhost", 9300))
.addTransportAddress(new InetSocketTransportAddress("localhost", 9301)); .addTransportAddress(new InetSocketTransportAddress("localhost", 9301));
------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------
+
WARNING: If you configure a transport client without SSL, passwords are sent in WARNING: If you configure a transport client without SSL, passwords are sent in
clear text. clear text.
+
You can also add an `Authorization` header to each request. If you've configured You can also add an `Authorization` header to each request. If you've configured
global authorization credentials, the `Authorization` header overrides the global global authorization credentials, the `Authorization` header overrides the global
authentication credentials. This is useful when an application has multiple users authentication credentials. This is useful when an application has multiple users
who access Elasticsearch using the same client. You can set the global token to who access Elasticsearch using the same client. You can set the global token to
a user that only has the `transport_client` role, and add the `transport_client` a user that only has the `transport_client` role, and add the `transport_client`
role to the individual users. role to the individual users.
+
For example, the following snippet adds the `Authorization` header to a search For example, the following snippet adds the `Authorization` header to a search
request: request:
+
[source,java] [source,java]
-------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------
import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.SecureString;
@ -181,6 +82,7 @@ String token = basicAuthHeaderValue("test_user", new SecureString("x-pack-test-p
client.filterWithHeader(Collections.singletonMap("Authorization", token)) client.filterWithHeader(Collections.singletonMap("Authorization", token))
.prepareSearch().get(); .prepareSearch().get();
-------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------
--
. Enable SSL to authenticate clients and encrypt communications. To enable SSL, . Enable SSL to authenticate clients and encrypt communications. To enable SSL,
you need to: you need to:
@ -188,9 +90,10 @@ you need to:
.. Configure the paths to the client's key and certificate in addition to the certificate authorities. .. Configure the paths to the client's key and certificate in addition to the certificate authorities.
Client authentication requires every client to have a certification signed by a trusted CA. Client authentication requires every client to have a certification signed by a trusted CA.
+ +
--
NOTE: Client authentication is enabled by default. For information about NOTE: Client authentication is enabled by default. For information about
disabling client authentication, see <<disabling-client-auth, Disabling Client Authentication>>. disabling client authentication, see <<disabling-client-auth, Disabling Client Authentication>>.
+
[source,java] [source,java]
-------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------
import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient; import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient;
@ -205,11 +108,12 @@ TransportClient client = new PreBuiltXPackTransportClient(Settings.builder()
... ...
.build()); .build());
-------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------
--
+
.. Enable the SSL transport by setting `xpack.security.transport.ssl.enabled` to `true` in the .. Enable the SSL transport by setting `xpack.security.transport.ssl.enabled` to `true` in the
client configuration. client configuration.
+ +
--
[source,java] [source,java]
-------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------
import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient; import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient;
@ -227,6 +131,7 @@ TransportClient client = new PreBuiltXPackTransportClient(Settings.builder()
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300)) .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300))
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9301)) .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9301))
-------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------
--
[float] [float]
[[disabling-client-auth]] [[disabling-client-auth]]

View File

@ -0,0 +1,116 @@
[role="xpack"]
[[setup-xpack-client]]
== Configuring {xpack} Java Clients
If you want to use a Java {ref}/transport-client.html[transport client] with a
cluster where {xpack} is installed, then you must download and configure the
{xpack} transport client.
WARNING: The `TransportClient` is aimed to be replaced by the Java High Level REST
Client, which executes HTTP requests instead of serialized Java requests. The
`TransportClient` will be deprecated in upcoming versions of {es}.
. Add the {xpack} transport JAR file to your *CLASSPATH*. You can download the {xpack}
distribution and extract the JAR file manually or you can get it from the
https://artifacts.elastic.co/maven/org/elasticsearch/client/x-pack-transport/{version}/x-pack-transport-{version}.jar[Elasticsearc Maven repository].
As with any dependency, you will also need its transitive dependencies. Refer to the
https://artifacts.elastic.co/maven/org/elasticsearch/client/x-pack-transport/{version}/x-pack-transport-{version}.pom[X-Pack POM file
for your version] when downloading for offline usage.
. If you are using Maven, you need to add the {xpack} JAR file as a dependency in
your project's `pom.xml` file:
+
--
[source,xml]
--------------------------------------------------------------
<project ...>
<repositories>
<!-- add the elasticsearch repo -->
<repository>
<id>elasticsearch-releases</id>
<url>https://artifacts.elastic.co/maven</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
...
</repositories>
...
<dependencies>
<!-- add the x-pack jar as a dependency -->
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>x-pack-transport</artifactId>
<version>{version}</version>
</dependency>
...
</dependencies>
...
</project>
--------------------------------------------------------------
--
. If you are using Gradle, you need to add the {xpack} JAR file as a dependency in
your `build.gradle` file:
+
--
[source,groovy]
--------------------------------------------------------------
repositories {
/* ... Any other repositories ... */
// Add the Elasticsearch Maven Repository
maven {
url "https://artifacts.elastic.co/maven"
}
}
dependencies {
compile "org.elasticsearch.client:x-pack-transport:{version}"
/* ... */
}
--------------------------------------------------------------
--
. If you are using a repository manager such as https://www.sonatype.com/nexus-repository-oss[Nexus OSS] within your
company, you need to add the repository as per the following screenshot:
+
--
image::security/images/nexus.png["Adding the Elastic repo in Nexus",link="images/nexus.png"]
Then in your project's `pom.xml` if using maven, add the following repositories and dependencies definitions:
[source,xml]
--------------------------------------------------------------
<dependencies>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>x-pack-transport</artifactId>
<version>{version}</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>local-nexus</id>
<name>Elastic Local Nexus</name>
<url>http://0.0.0.0:8081/repository/elasticsearch/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
--------------------------------------------------------------
--
. If you are using {security}, there are more configuration steps. See
{xpack-ref}/java-clients.html[Java Client and Security].

View File

@ -12,3 +12,4 @@ easy-to-install package. To access this functionality, you must
include::installing-xes.asciidoc[] include::installing-xes.asciidoc[]
include::settings/configuring-xes.asciidoc[] include::settings/configuring-xes.asciidoc[]
include::setup-xclient.asciidoc[]