You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Malaka Gallage <mp...@gmail.com> on 2014/11/10 13:03:02 UTC
Adding a Callback to Trigger on Reusing a Connection
Hello everyone,
I'm using NIO version 4.2.5 and I'm facing a little problem. I have some
operations to be executed on HttpAsyncRequestExecutor#connected and I have
implemented those operations now. But the problem occurs when I use
keepalive connections. I want these operations to be executed on reusing an
established connection from the pool too.
To achieve this, I have added a callback method called onReusingPoolEntry()
to AbstractNIOConnPool which is executed when reusing an established
connection from the pool.
Code :
private boolean processPendingRequest(final LeaseRequest<T, C, E> request) {
..................
........
if (entry != null) {
this.available.remove(entry);
this.leased.add(entry);
future.completed(entry);
onReusingPoolEntry(entry);
return true;
}
.........
.................
}
protected void onReusingPoolEntry(E entry) {}
I suggest to add this feature to the NIO code base too. WDYT?
Thanks
Malaka
--
Regards,
*Malaka GallageSoftware Engineer*
*AdroitLogic Lanka (Pvt) Ltd.*
[image: Facebook] <https://www.facebook.com/malaka.gallage> [image: Twitter]
<http://twitter.com/#%21/MalakaGallage> [image: LinkedIn]
<http://www.linkedin.com/profile/view?id=91872322&trk=tab_pro> [image:
Blogger] <http://swordofpoet.blogspot.com/>
Skype : malaka.gallage
Mobile : +94 718 796 378
Re: Adding a Callback to Trigger on Reusing a Connection
Posted by Malaka Gallage <mp...@gmail.com>.
Hi Oleg,
A pull request is made as per the suggestion.
https://github.com/apache/httpcore/pull/6
Thanks
Malaka
On Mon, Nov 10, 2014 at 7:08 PM, Oleg Kalnichevski <ol...@apache.org> wrote:
> On Mon, 2014-11-10 at 17:33 +0530, Malaka Gallage wrote:
> > Hello everyone,
> >
> > I'm using NIO version 4.2.5 and I'm facing a little problem. I have some
> > operations to be executed on HttpAsyncRequestExecutor#connected and I
> have
> > implemented those operations now. But the problem occurs when I use
> > keepalive connections. I want these operations to be executed on reusing
> an
> > established connection from the pool too.
> >
> > To achieve this, I have added a callback method called
> onReusingPoolEntry()
> > to AbstractNIOConnPool which is executed when reusing an established
> > connection from the pool.
> >
> > Code :
> >
> > private boolean processPendingRequest(final LeaseRequest<T, C, E>
> request) {
> > ..................
> > ........
> > if (entry != null) {
> > this.available.remove(entry);
> > this.leased.add(entry);
> > future.completed(entry);
> > onReusingPoolEntry(entry);
> > return true;
> > }
> > .........
> > .................
> > }
> >
> > protected void onReusingPoolEntry(E entry) {}
>
> >
> > I suggest to add this feature to the NIO code base too. WDYT?
> >
> > Thanks
> > Malaka
> >
>
> Sounds reasonable enough. Feel free to raise a PR at GitHub for this
> change. Please note that you should be working with the 4.4.x branch,
> which is to become the official stable branch soon.
>
> Oleg
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>
>
--
Regards,
*Malaka GallageSoftware Engineer*
*AdroitLogic Lanka (Pvt) Ltd.*
[image: Facebook] <https://www.facebook.com/malaka.gallage> [image: Twitter]
<http://twitter.com/#%21/MalakaGallage> [image: LinkedIn]
<http://www.linkedin.com/profile/view?id=91872322&trk=tab_pro> [image:
Blogger] <http://swordofpoet.blogspot.com/>
Skype : malaka.gallage
Mobile : +94 718 796 378
Re: Adding a Callback to Trigger on Reusing a Connection
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2014-11-10 at 17:33 +0530, Malaka Gallage wrote:
> Hello everyone,
>
> I'm using NIO version 4.2.5 and I'm facing a little problem. I have some
> operations to be executed on HttpAsyncRequestExecutor#connected and I have
> implemented those operations now. But the problem occurs when I use
> keepalive connections. I want these operations to be executed on reusing an
> established connection from the pool too.
>
> To achieve this, I have added a callback method called onReusingPoolEntry()
> to AbstractNIOConnPool which is executed when reusing an established
> connection from the pool.
>
> Code :
>
> private boolean processPendingRequest(final LeaseRequest<T, C, E> request) {
> ..................
> ........
> if (entry != null) {
> this.available.remove(entry);
> this.leased.add(entry);
> future.completed(entry);
> onReusingPoolEntry(entry);
> return true;
> }
> .........
> .................
> }
>
> protected void onReusingPoolEntry(E entry) {}
>
> I suggest to add this feature to the NIO code base too. WDYT?
>
> Thanks
> Malaka
>
Sounds reasonable enough. Feel free to raise a PR at GitHub for this
change. Please note that you should be working with the 4.4.x branch,
which is to become the official stable branch soon.
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org