You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Shawn Heisey <so...@elyograg.org> on 2014/01/04 22:30:29 UTC

Migrating to HttpClient 4.3.1 from 4.2.6 - Solr

Recently the Lucene-Solr projectupgraded HttpClientin our codebase from
4.2.6 to 4.3.1.

https://issues.apache.org/jira/browse/SOLR-5590

Although this did not require any java code changes and seems to have
occurred without any new test failures, it will come as no surprise to
anyone here that this has resulted in lots and lots of deprecations in
existing code.

I am attempting to fix this situation, but I am coming up pretty empty
while looking for comprehensive information on how to migrate.  I made a
small start after a lot of research:

https://issues.apache.org/jira/browse/SOLR-5604

It seems that there is no longer any non-deprecated way to change
default parameters on an existing HttpClient object, and what few
examples I can find suggest changing parameters on the request, not the
client.  Using HttpClientBuilder is going to require a fairly
significant paradigm shift for Solr, and I could really use a migration
guide or some extremely comprehensive examples.

Are there any more significant deprecations coming in the foreseeable
future that we should prepare for now?  I know that nobody can reliably
predict the future, but if I can write code that stands a chance of
continuing to be functional through the next two major HC versions, I'd
like to.

Thanks,
Shawn


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Migrating to HttpClient 4.3.1 from 4.2.6 - Solr

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2014-01-09 at 11:07 -0700, Shawn Heisey wrote:
> On 1/5/2014 9:03 AM, Oleg Kalnichevski wrote:
> > That is intended. HttpClient instances are expected to be immutable 
> > (not their dependencies though). This helps make them thread safe 
> > without incurring an overhead of synchronization. One should customize 
> > individual requests or execution contexts and never meddle with 
> > HttpClient instances. 
> 
> Thank you for your reply.
> 
> This is why I say it will be quite a paradigm shift for Solr.  Solr is 
> *almost* there in that usually those settings are only changed when the 
> server object is first created, but typically it's done by creating the 
> HttpClient object and then modifying its defaults.  Now the "create the 
> SolrServer and/or HttpClient with appropriate defaults" paradigm will 
> need to be 100% explicit.

It does not have to be. There is nothing that should prevent you from
using a factory pattern or a builder pattern in order to apply
reasonable defaults when creating HttpClient instances while giving the
users an option to override those properties they care about.

But the main point is that HttpClient instances should rarely need to
change, if at all. Most of configuration should take place at the
request (HttpRequest) or the session (HttpContext) level. I do not think
this is such a major paradigm shift.

> How much of a bad idea would it be to create a new HttpClient object 
> when a default parameter at the SolrServer level needs to change, 
> turning the old one into collectable garbage?  I don't like the idea, 
> just curious.
> 

HttpClient instances are very expensive to create. One ought to re-use
them as much as possible. Would not it be better to change HttpContext
instead?

Oleg

> > There is no migration guide but HttpClient programming principles are 
> > covered here 
> > http://hc.apache.org/httpcomponents-client-4.3.x/tutorial/html/index.html 
> 
> I think it's going to take me a while before I can fully wrap my head 
> around what to do here.  I look forward to figuring it all out and 
> learning a lot in the process.
> 
> Thanks,
> Shawn
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Migrating to HttpClient 4.3.1 from 4.2.6 - Solr

Posted by Shawn Heisey <so...@elyograg.org>.
On 1/5/2014 9:03 AM, Oleg Kalnichevski wrote:
> That is intended. HttpClient instances are expected to be immutable 
> (not their dependencies though). This helps make them thread safe 
> without incurring an overhead of synchronization. One should customize 
> individual requests or execution contexts and never meddle with 
> HttpClient instances. 

Thank you for your reply.

This is why I say it will be quite a paradigm shift for Solr.  Solr is 
*almost* there in that usually those settings are only changed when the 
server object is first created, but typically it's done by creating the 
HttpClient object and then modifying its defaults.  Now the "create the 
SolrServer and/or HttpClient with appropriate defaults" paradigm will 
need to be 100% explicit.

How much of a bad idea would it be to create a new HttpClient object 
when a default parameter at the SolrServer level needs to change, 
turning the old one into collectable garbage?  I don't like the idea, 
just curious.

> There is no migration guide but HttpClient programming principles are 
> covered here 
> http://hc.apache.org/httpcomponents-client-4.3.x/tutorial/html/index.html 

I think it's going to take me a while before I can fully wrap my head 
around what to do here.  I look forward to figuring it all out and 
learning a lot in the process.

Thanks,
Shawn


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Migrating to HttpClient 4.3.1 from 4.2.6 - Solr

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Sat, 2014-01-04 at 14:30 -0700, Shawn Heisey wrote:
> Recently the Lucene-Solr projectupgraded HttpClientin our codebase from
> 4.2.6 to 4.3.1.
> 
> https://issues.apache.org/jira/browse/SOLR-5590
> 
> Although this did not require any java code changes and seems to have
> occurred without any new test failures, it will come as no surprise to
> anyone here that this has resulted in lots and lots of deprecations in
> existing code.
> 
> I am attempting to fix this situation, but I am coming up pretty empty
> while looking for comprehensive information on how to migrate.  I made a
> small start after a lot of research:
> 
> https://issues.apache.org/jira/browse/SOLR-5604
> 
> It seems that there is no longer any non-deprecated way to change
> default parameters on an existing HttpClient object, and what few
> examples I can find suggest changing parameters on the request, not the
> client. 

That is intended. HttpClient instances are expected to be immutable (not
their dependencies though). This helps make them thread safe without
incurring an overhead of synchronization. One should customize
individual requests or execution contexts and never meddle with
HttpClient instances.

>  Using HttpClientBuilder is going to require a fairly
> significant paradigm shift for Solr, and I could really use a migration
> guide or some extremely comprehensive examples.
> 

There is no migration guide but HttpClient programming principles are
covered here

http://hc.apache.org/httpcomponents-client-4.3.x/tutorial/html/index.html

> Are there any more significant deprecations coming in the foreseeable
> future that we should prepare for now?  I know that nobody can reliably
> predict the future, but if I can write code that stands a chance of
> continuing to be functional through the next two major HC versions, I'd
> like to.
> 

No, no major API changes are planned for the 4.x series of releases. The
release of HttpClient 4.0 was rushed (which is a long and unpleasant
story) and many aspects of 4.0 APIs were not fully worked out. 4.3 is
essentially what 4.0 should have been.  

One can expected some APIs changes in 5.x series but 5.0 cannot be
expected any time soon, if ever.

I will happily help you with migration to 4.3 if you have any specific
questions of issues. I will also keep an eye on SOLR-5604

Cheers

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org