You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Patrick Moore (JIRA)" <ji...@apache.org> on 2009/09/04 02:09:57 UTC

[jira] Created: (HTTPCORE-205) AbstractMultiworkerIOReactor needs optional Latch to signal when ready.

AbstractMultiworkerIOReactor needs optional Latch to signal when ready.
-----------------------------------------------------------------------

                 Key: HTTPCORE-205
                 URL: https://issues.apache.org/jira/browse/HTTPCORE-205
             Project: HttpComponents HttpCore
          Issue Type: Improvement
          Components: HttpCore NIO
    Affects Versions: 4.0.1
            Reporter: Patrick Moore


AbstractMultiworkerIOReactor may take some time getting ready ( needs to start threads for example ). In order to ensure that it is ready before starting to send requests, a CountDownLatch is needed.

This is important for our test suites which are launch the reactor and then immediately trying to hit it. ( and failing ) 

            for (int i = 0; i < this.workerCount; i++) {
                if (this.status != IOReactorStatus.ACTIVE) {
                    return;
                }
                this.threads[i].start();
            }
 LINE 303: this.countDownLatch.countDown(); <<<<<<<           
            for (;;) {
                int readyCount;
                try {
                    readyCount = this.selector.select(this.selectTimeout);
                } catch (InterruptedIOException ex) {
                    throw ex;
                } catch (IOException ex) {
                    throw new IOReactorException("Unexpected selector failure", ex);
                }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Updated: (HTTPCORE-205) AbstractMultiworkerIOReactor needs optional Latch to signal when ready.

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCORE-205?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski updated HTTPCORE-205:
---------------------------------------

    Fix Version/s: 4.1

Fair enough. Would you be willing to put together a patch for this feature?

Oleg

> AbstractMultiworkerIOReactor needs optional Latch to signal when ready.
> -----------------------------------------------------------------------
>
>                 Key: HTTPCORE-205
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-205
>             Project: HttpComponents HttpCore
>          Issue Type: Improvement
>          Components: HttpCore NIO
>    Affects Versions: 4.0.1
>            Reporter: Patrick Moore
>             Fix For: 4.1
>
>
> AbstractMultiworkerIOReactor may take some time getting ready ( needs to start threads for example ). In order to ensure that it is ready before starting to send requests, a CountDownLatch is needed.
> This is important for our test suites which are launch the reactor and then immediately trying to hit it. ( and failing ) 
>             for (int i = 0; i < this.workerCount; i++) {
>                 if (this.status != IOReactorStatus.ACTIVE) {
>                     return;
>                 }
>                 this.threads[i].start();
>             }
>  LINE 303: this.countDownLatch.countDown(); <<<<<<<           
>             for (;;) {
>                 int readyCount;
>                 try {
>                     readyCount = this.selector.select(this.selectTimeout);
>                 } catch (InterruptedIOException ex) {
>                     throw ex;
>                 } catch (IOException ex) {
>                     throw new IOReactorException("Unexpected selector failure", ex);
>                 }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (HTTPCORE-205) AbstractMultiworkerIOReactor needs optional Latch to signal when ready.

Posted by "Patrick Moore (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-205?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12751644#action_12751644 ] 

Patrick Moore commented on HTTPCORE-205:
----------------------------------------

Additionally the above suggestion would allow user to handle failures/successes differently. ( retry, use different port , etc. ) 

> AbstractMultiworkerIOReactor needs optional Latch to signal when ready.
> -----------------------------------------------------------------------
>
>                 Key: HTTPCORE-205
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-205
>             Project: HttpComponents HttpCore
>          Issue Type: Improvement
>          Components: HttpCore NIO
>    Affects Versions: 4.0.1
>            Reporter: Patrick Moore
>             Fix For: 4.1
>
>         Attachments: AbstractMultiworkerIOReactor.patch
>
>
> AbstractMultiworkerIOReactor may take some time getting ready ( needs to start threads for example ). In order to ensure that it is ready before starting to send requests, a CountDownLatch is needed.
> This is important for our test suites which are launch the reactor and then immediately trying to hit it. ( and failing ) 
>             for (int i = 0; i < this.workerCount; i++) {
>                 if (this.status != IOReactorStatus.ACTIVE) {
>                     return;
>                 }
>                 this.threads[i].start();
>             }
>  LINE 303: this.countDownLatch.countDown(); <<<<<<<           
>             for (;;) {
>                 int readyCount;
>                 try {
>                     readyCount = this.selector.select(this.selectTimeout);
>                 } catch (InterruptedIOException ex) {
>                     throw ex;
>                 } catch (IOException ex) {
>                     throw new IOReactorException("Unexpected selector failure", ex);
>                 }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Updated: (HTTPCORE-205) AbstractMultiworkerIOReactor needs optional Latch to signal when ready.

Posted by "Patrick Moore (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCORE-205?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Patrick Moore updated HTTPCORE-205:
-----------------------------------

    Attachment: AbstractMultiworkerIOReactor.patch

had to do a bit of hand edit to this patch file .. but it should do the trick.

> AbstractMultiworkerIOReactor needs optional Latch to signal when ready.
> -----------------------------------------------------------------------
>
>                 Key: HTTPCORE-205
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-205
>             Project: HttpComponents HttpCore
>          Issue Type: Improvement
>          Components: HttpCore NIO
>    Affects Versions: 4.0.1
>            Reporter: Patrick Moore
>             Fix For: 4.1
>
>         Attachments: AbstractMultiworkerIOReactor.patch
>
>
> AbstractMultiworkerIOReactor may take some time getting ready ( needs to start threads for example ). In order to ensure that it is ready before starting to send requests, a CountDownLatch is needed.
> This is important for our test suites which are launch the reactor and then immediately trying to hit it. ( and failing ) 
>             for (int i = 0; i < this.workerCount; i++) {
>                 if (this.status != IOReactorStatus.ACTIVE) {
>                     return;
>                 }
>                 this.threads[i].start();
>             }
>  LINE 303: this.countDownLatch.countDown(); <<<<<<<           
>             for (;;) {
>                 int readyCount;
>                 try {
>                     readyCount = this.selector.select(this.selectTimeout);
>                 } catch (InterruptedIOException ex) {
>                     throw ex;
>                 } catch (IOException ex) {
>                     throw new IOReactorException("Unexpected selector failure", ex);
>                 }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (HTTPCORE-205) AbstractMultiworkerIOReactor needs optional Latch to signal when ready.

Posted by "Patrick Moore (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-205?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12751643#action_12751643 ] 

Patrick Moore commented on HTTPCORE-205:
----------------------------------------

Hi Oleg --

I know you hate to hear this but ... because in the code I didn't see anything to point this out. 

I usually only get as far as javadoc with opensource (that is usually all the doc available). :-) When I was stepping through the code, I did not "notice" the ListenerEndPoint. (Suggestion here: in the java doc for:
   ListenerEndpoint listen(SocketAddress address);

add this:
   The returned ListenerEndPoint#waitFor() can be used to monitor when connection is available.
   see {@linkplain http://hc.apache.org/httpcomponents-core/tutorial/html/nio.html#d0e1207} for more examples.

-----------------------------------------------------------------------
I AGREE that ListenerEndPoint looks to be the more correct solution.

Some problems however:
 1) uses old wait-forever ( no ability to "give up" )
 2) Cannot monitor a set of ListenerEndPoints all at once.

I suggest:
1) create a ListenerEndPointImplementor with all the methods defined in ListenerEndPointImpl that are needed by ListeningIOReactor
2) create a ListeningIOReactor.listen(ListenerEndPointImplementor) 
3) remove references to ListenerEndPointImpl in the various other classes.

This should address the key needs.

> AbstractMultiworkerIOReactor needs optional Latch to signal when ready.
> -----------------------------------------------------------------------
>
>                 Key: HTTPCORE-205
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-205
>             Project: HttpComponents HttpCore
>          Issue Type: Improvement
>          Components: HttpCore NIO
>    Affects Versions: 4.0.1
>            Reporter: Patrick Moore
>             Fix For: 4.1
>
>         Attachments: AbstractMultiworkerIOReactor.patch
>
>
> AbstractMultiworkerIOReactor may take some time getting ready ( needs to start threads for example ). In order to ensure that it is ready before starting to send requests, a CountDownLatch is needed.
> This is important for our test suites which are launch the reactor and then immediately trying to hit it. ( and failing ) 
>             for (int i = 0; i < this.workerCount; i++) {
>                 if (this.status != IOReactorStatus.ACTIVE) {
>                     return;
>                 }
>                 this.threads[i].start();
>             }
>  LINE 303: this.countDownLatch.countDown(); <<<<<<<           
>             for (;;) {
>                 int readyCount;
>                 try {
>                     readyCount = this.selector.select(this.selectTimeout);
>                 } catch (InterruptedIOException ex) {
>                     throw ex;
>                 } catch (IOException ex) {
>                     throw new IOReactorException("Unexpected selector failure", ex);
>                 }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (HTTPCORE-205) AbstractMultiworkerIOReactor needs optional Latch to signal when ready.

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-205?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12751623#action_12751623 ] 

Oleg Kalnichevski commented on HTTPCORE-205:
--------------------------------------------

Patrick,

Actually why do care when the worker threads are started at all? What is important that the I/O reactor is ready to accept incoming connections. Why do not you simply use ListenerEndpoint#waitFor() method to wait for a listener to become ready? This, I believe, should eliminate the need for a countdown latch.

For details see

http://hc.apache.org/httpcomponents-core/tutorial/html/nio.html#d0e1207

Oleg

> AbstractMultiworkerIOReactor needs optional Latch to signal when ready.
> -----------------------------------------------------------------------
>
>                 Key: HTTPCORE-205
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-205
>             Project: HttpComponents HttpCore
>          Issue Type: Improvement
>          Components: HttpCore NIO
>    Affects Versions: 4.0.1
>            Reporter: Patrick Moore
>             Fix For: 4.1
>
>         Attachments: AbstractMultiworkerIOReactor.patch
>
>
> AbstractMultiworkerIOReactor may take some time getting ready ( needs to start threads for example ). In order to ensure that it is ready before starting to send requests, a CountDownLatch is needed.
> This is important for our test suites which are launch the reactor and then immediately trying to hit it. ( and failing ) 
>             for (int i = 0; i < this.workerCount; i++) {
>                 if (this.status != IOReactorStatus.ACTIVE) {
>                     return;
>                 }
>                 this.threads[i].start();
>             }
>  LINE 303: this.countDownLatch.countDown(); <<<<<<<           
>             for (;;) {
>                 int readyCount;
>                 try {
>                     readyCount = this.selector.select(this.selectTimeout);
>                 } catch (InterruptedIOException ex) {
>                     throw ex;
>                 } catch (IOException ex) {
>                     throw new IOReactorException("Unexpected selector failure", ex);
>                 }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (HTTPCORE-205) AbstractMultiworkerIOReactor needs optional Latch to signal when ready.

Posted by "Patrick Moore (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-205?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12751772#action_12751772 ] 

Patrick Moore commented on HTTPCORE-205:
----------------------------------------

re #1 ---I meant that you need a waitFor(int time, TimeUnit timeUnit) throws TimeoutException; method on ListenerEndPoint

re #2 -- by making interface that is more complete and not referencing ListenerEndPointImpl in the code, then the user can supply their own implementation of ListenerEndPoint that can be as fancy as they want ( so that you don't have to be ) 

Really this change is just about putting all the public ListenerEndPointImpl methods in the ListenerEndPoint interface (or a subinterface ListenerEndPointImplementor )

> AbstractMultiworkerIOReactor needs optional Latch to signal when ready.
> -----------------------------------------------------------------------
>
>                 Key: HTTPCORE-205
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-205
>             Project: HttpComponents HttpCore
>          Issue Type: Improvement
>          Components: HttpCore NIO
>    Affects Versions: 4.0.1
>            Reporter: Patrick Moore
>             Fix For: 4.1
>
>         Attachments: AbstractMultiworkerIOReactor.patch
>
>
> AbstractMultiworkerIOReactor may take some time getting ready ( needs to start threads for example ). In order to ensure that it is ready before starting to send requests, a CountDownLatch is needed.
> This is important for our test suites which are launch the reactor and then immediately trying to hit it. ( and failing ) 
>             for (int i = 0; i < this.workerCount; i++) {
>                 if (this.status != IOReactorStatus.ACTIVE) {
>                     return;
>                 }
>                 this.threads[i].start();
>             }
>  LINE 303: this.countDownLatch.countDown(); <<<<<<<           
>             for (;;) {
>                 int readyCount;
>                 try {
>                     readyCount = this.selector.select(this.selectTimeout);
>                 } catch (InterruptedIOException ex) {
>                     throw ex;
>                 } catch (IOException ex) {
>                     throw new IOReactorException("Unexpected selector failure", ex);
>                 }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (HTTPCORE-205) AbstractMultiworkerIOReactor needs optional Latch to signal when ready.

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-205?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12751789#action_12751789 ] 

Oleg Kalnichevski commented on HTTPCORE-205:
--------------------------------------------

> re #1 ---I meant that you need a waitFor(int time, TimeUnit timeUnit) throws TimeoutException; method on ListenerEndPoint

True. This is a fuck-up on my part. However given the fact that it takes only a few milliseconds for listener endpoint to become available or fail, absence of this method may not be a such big problem for most application.

> then the user can supply their own implementation of ListenerEndPoint

I am not convinced this is good idea. In this case a custom impl of ListeningIOReactor should be more appropriate.

Anyways, do feel free to submit a patch with changes you deem necessary. Please note we will not be able to commit such a patch until 5.0 if it breaks API compatibility with 4.x

Oleg

> AbstractMultiworkerIOReactor needs optional Latch to signal when ready.
> -----------------------------------------------------------------------
>
>                 Key: HTTPCORE-205
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-205
>             Project: HttpComponents HttpCore
>          Issue Type: Improvement
>          Components: HttpCore NIO
>    Affects Versions: 4.0.1
>            Reporter: Patrick Moore
>             Fix For: 4.1
>
>         Attachments: AbstractMultiworkerIOReactor.patch
>
>
> AbstractMultiworkerIOReactor may take some time getting ready ( needs to start threads for example ). In order to ensure that it is ready before starting to send requests, a CountDownLatch is needed.
> This is important for our test suites which are launch the reactor and then immediately trying to hit it. ( and failing ) 
>             for (int i = 0; i < this.workerCount; i++) {
>                 if (this.status != IOReactorStatus.ACTIVE) {
>                     return;
>                 }
>                 this.threads[i].start();
>             }
>  LINE 303: this.countDownLatch.countDown(); <<<<<<<           
>             for (;;) {
>                 int readyCount;
>                 try {
>                     readyCount = this.selector.select(this.selectTimeout);
>                 } catch (InterruptedIOException ex) {
>                     throw ex;
>                 } catch (IOException ex) {
>                     throw new IOReactorException("Unexpected selector failure", ex);
>                 }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Resolved: (HTTPCORE-205) AbstractMultiworkerIOReactor needs optional Latch to signal when ready.

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCORE-205?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski resolved HTTPCORE-205.
----------------------------------------

    Resolution: Won't Fix

>  1) uses old wait-forever ( no ability to "give up" )

I do not think this is the case. ListenerEndpoint#close() can be used to shut down the listener even before it is fully initialized

> 2) Cannot monitor a set of ListenerEndPoints all at once. 

I am not entirely sure the changes you are proposing would fix the problem.

I have made some changes to the javadocs based on your suggestions. If you are willing to work on a better implementation of ListenerEndPointsImpl feel free to raise a separate JIRA and submit a patch.

Oleg

> AbstractMultiworkerIOReactor needs optional Latch to signal when ready.
> -----------------------------------------------------------------------
>
>                 Key: HTTPCORE-205
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-205
>             Project: HttpComponents HttpCore
>          Issue Type: Improvement
>          Components: HttpCore NIO
>    Affects Versions: 4.0.1
>            Reporter: Patrick Moore
>             Fix For: 4.1
>
>         Attachments: AbstractMultiworkerIOReactor.patch
>
>
> AbstractMultiworkerIOReactor may take some time getting ready ( needs to start threads for example ). In order to ensure that it is ready before starting to send requests, a CountDownLatch is needed.
> This is important for our test suites which are launch the reactor and then immediately trying to hit it. ( and failing ) 
>             for (int i = 0; i < this.workerCount; i++) {
>                 if (this.status != IOReactorStatus.ACTIVE) {
>                     return;
>                 }
>                 this.threads[i].start();
>             }
>  LINE 303: this.countDownLatch.countDown(); <<<<<<<           
>             for (;;) {
>                 int readyCount;
>                 try {
>                     readyCount = this.selector.select(this.selectTimeout);
>                 } catch (InterruptedIOException ex) {
>                     throw ex;
>                 } catch (IOException ex) {
>                     throw new IOReactorException("Unexpected selector failure", ex);
>                 }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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