You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@metron.apache.org by Ali Nazemian <al...@gmail.com> on 2018/06/13 14:29:18 UTC

Using Java Rest Client instead of Transport Client for Elasticsearch

Hi All,


I have noticed that the recommendation from Elasticsearch team is changed
to use Java Rest Client instead of Transport one. The rationale behind it
looks convincing and it can also help Metron to be more decoupled from
Elasticsearch roadmap, so Metron users can upgrade Elasticsearch with
minimum dependency to Metron support.

https://www.elastic.co/blog/state-of-the-official-elasticsearch-java-clients

P.S: Transport client will be deprecated in ES 7 and will be removed
completely on 8.


Regards,
Ali

Re: Using Java Rest Client instead of Transport Client for Elasticsearch

Posted by Ali Nazemian <al...@gmail.com>.
It looks like it's possible to use Xpack credentials and use Rest clients.

https://www.elastic.co/guide/en/elasticsearch/client/java-rest/master/java-rest-high-getting-started-initialization.html
https://www.elastic.co/guide/en/elasticsearch/client/java-rest/master/java-rest-low-usage-initialization.html



For example:

*final* *CredentialsProvider** credentialsProvider **=* *new*
*BasicCredentialsProvider**();*

*credentialsProvider**.**setCredentials**(**AuthScope**.**ANY**,*

        *new* *UsernamePasswordCredentials**(**"user"**,* *"password"**));*



*RestClientBuilder** builder **=* *RestClient**.**builder**(**new*
*HttpHost**(**"localhost"**,* *9200**))*

        *.**setHttpClientConfigCallback**(**new*
*RestClientBuilder**.**HttpClientConfigCallback**()* *{*

            *@Override*

            *public* *HttpAsyncClientBuilder**
customizeHttpClient**(**HttpAsyncClientBuilder** httpClientBuilder**)*
*{*

                *return**
httpClientBuilder**.**setDefaultCredentialsProvider**(**credentialsProvider**);*

            *}*

        *});*



*RestHighLevelClient** client **=* *new* *RestHighLevelClient**(**builder**);*


Cheers,
Ali

On Thu, Jun 14, 2018 at 2:28 PM Ali Nazemian <al...@gmail.com> wrote:

> Hi Michael and Casey,
>
> It looks like ES believe Java Rest Client is mature enough to be pushed to
> different products at this stage. However, I haven't used it personally. I
> will share the question regarding x-pack support with Elasticsearch
> engineers to see if there is any issue regarding that.
>
> Cheers,
> Ali
>
> On Thu, Jun 14, 2018 at 4:26 AM, Michael Miklavcic <
> michael.miklavcic@gmail.com> wrote:
>
>> I think there is some level of support for auth via their REST api, but I
>> don't see anything specific to X-Pack as you mentioned. However, the major
>> reason we did not adopt it at the time of upgrade was because a number of
>> features were not available to REST yet and the effort to simultaneously
>> upgrade ES and migrate the API to REST was an effort decidedly too large
>> for the scope of the PR at the time.
>>
>>
>>
>> On Wed, Jun 13, 2018 at 8:39 AM, Casey Stella <ce...@gmail.com> wrote:
>>
>> > It was my understanding was that ES x-pack only supports the transport
>> > client (e.g.
>> > https://www.elastic.co/guide/en/x-pack/current/java-clients.html).  I
>> > think
>> > that was a major reason why we chose to go that route.  I might be wrong
>> > though.
>> >
>> > On Wed, Jun 13, 2018 at 10:30 AM Ali Nazemian <al...@gmail.com>
>> > wrote:
>> >
>> > > Hi All,
>> > >
>> > >
>> > > I have noticed that the recommendation from Elasticsearch team is
>> changed
>> > > to use Java Rest Client instead of Transport one. The rationale
>> behind it
>> > > looks convincing and it can also help Metron to be more decoupled from
>> > > Elasticsearch roadmap, so Metron users can upgrade Elasticsearch with
>> > > minimum dependency to Metron support.
>> > >
>> > >
>> > > https://www.elastic.co/blog/state-of-the-official-
>> > elasticsearch-java-clients
>> > >
>> > > P.S: Transport client will be deprecated in ES 7 and will be removed
>> > > completely on 8.
>> > >
>> > >
>> > > Regards,
>> > > Ali
>> > >
>> >
>>
>
>
>
> --
> A.Nazemian
>


-- 
A.Nazemian

Re: Using Java Rest Client instead of Transport Client for Elasticsearch

Posted by Ali Nazemian <al...@gmail.com>.
Hi Michael and Casey,

It looks like ES believe Java Rest Client is mature enough to be pushed to
different products at this stage. However, I haven't used it personally. I
will share the question regarding x-pack support with Elasticsearch
engineers to see if there is any issue regarding that.

Cheers,
Ali

On Thu, Jun 14, 2018 at 4:26 AM, Michael Miklavcic <
michael.miklavcic@gmail.com> wrote:

> I think there is some level of support for auth via their REST api, but I
> don't see anything specific to X-Pack as you mentioned. However, the major
> reason we did not adopt it at the time of upgrade was because a number of
> features were not available to REST yet and the effort to simultaneously
> upgrade ES and migrate the API to REST was an effort decidedly too large
> for the scope of the PR at the time.
>
>
>
> On Wed, Jun 13, 2018 at 8:39 AM, Casey Stella <ce...@gmail.com> wrote:
>
> > It was my understanding was that ES x-pack only supports the transport
> > client (e.g.
> > https://www.elastic.co/guide/en/x-pack/current/java-clients.html).  I
> > think
> > that was a major reason why we chose to go that route.  I might be wrong
> > though.
> >
> > On Wed, Jun 13, 2018 at 10:30 AM Ali Nazemian <al...@gmail.com>
> > wrote:
> >
> > > Hi All,
> > >
> > >
> > > I have noticed that the recommendation from Elasticsearch team is
> changed
> > > to use Java Rest Client instead of Transport one. The rationale behind
> it
> > > looks convincing and it can also help Metron to be more decoupled from
> > > Elasticsearch roadmap, so Metron users can upgrade Elasticsearch with
> > > minimum dependency to Metron support.
> > >
> > >
> > > https://www.elastic.co/blog/state-of-the-official-
> > elasticsearch-java-clients
> > >
> > > P.S: Transport client will be deprecated in ES 7 and will be removed
> > > completely on 8.
> > >
> > >
> > > Regards,
> > > Ali
> > >
> >
>



-- 
A.Nazemian

Re: Using Java Rest Client instead of Transport Client for Elasticsearch

Posted by Michael Miklavcic <mi...@gmail.com>.
I think there is some level of support for auth via their REST api, but I
don't see anything specific to X-Pack as you mentioned. However, the major
reason we did not adopt it at the time of upgrade was because a number of
features were not available to REST yet and the effort to simultaneously
upgrade ES and migrate the API to REST was an effort decidedly too large
for the scope of the PR at the time.



On Wed, Jun 13, 2018 at 8:39 AM, Casey Stella <ce...@gmail.com> wrote:

> It was my understanding was that ES x-pack only supports the transport
> client (e.g.
> https://www.elastic.co/guide/en/x-pack/current/java-clients.html).  I
> think
> that was a major reason why we chose to go that route.  I might be wrong
> though.
>
> On Wed, Jun 13, 2018 at 10:30 AM Ali Nazemian <al...@gmail.com>
> wrote:
>
> > Hi All,
> >
> >
> > I have noticed that the recommendation from Elasticsearch team is changed
> > to use Java Rest Client instead of Transport one. The rationale behind it
> > looks convincing and it can also help Metron to be more decoupled from
> > Elasticsearch roadmap, so Metron users can upgrade Elasticsearch with
> > minimum dependency to Metron support.
> >
> >
> > https://www.elastic.co/blog/state-of-the-official-
> elasticsearch-java-clients
> >
> > P.S: Transport client will be deprecated in ES 7 and will be removed
> > completely on 8.
> >
> >
> > Regards,
> > Ali
> >
>

Re: Using Java Rest Client instead of Transport Client for Elasticsearch

Posted by Casey Stella <ce...@gmail.com>.
It was my understanding was that ES x-pack only supports the transport
client (e.g.
https://www.elastic.co/guide/en/x-pack/current/java-clients.html).  I think
that was a major reason why we chose to go that route.  I might be wrong
though.

On Wed, Jun 13, 2018 at 10:30 AM Ali Nazemian <al...@gmail.com> wrote:

> Hi All,
>
>
> I have noticed that the recommendation from Elasticsearch team is changed
> to use Java Rest Client instead of Transport one. The rationale behind it
> looks convincing and it can also help Metron to be more decoupled from
> Elasticsearch roadmap, so Metron users can upgrade Elasticsearch with
> minimum dependency to Metron support.
>
>
> https://www.elastic.co/blog/state-of-the-official-elasticsearch-java-clients
>
> P.S: Transport client will be deprecated in ES 7 and will be removed
> completely on 8.
>
>
> Regards,
> Ali
>