You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by "Steffen Heil (Mailinglisten)" <li...@steffen-heil.de> on 2013/02/25 21:25:58 UTC

How to do a clean connector shut down?

Hi

I need to start and stop a connector inside a servlet.
That works with the following code:

		final org.apache.catalina.connector.Connector nioConnector =
			new org.apache.catalina.connector.Connector(
"org.apache.coyote.http11.Http11NioProtocol" );
		nioConnector.setAttribute( "executor", "osiris4Executor" );
		nioConnector.setPort( port );
		nioConnector.setRedirectPort( 443 );
		service.addConnector( nioConnector );

Then I can access the application using that port.
I can also remove the connector again:

		try {
			nioConnector.stop();
		} catch ( LifecycleException e ) {
			e.printStackTrace();
		}
		service.removeConnector( nioConnector );

However, I seem to miss some step, because a
"NioBlockingSelector.BlockPoller-X" thread is left.
As I called the upper code in a testcase in a loop I ended up with lots of
such threads.

What do I have to do to completely remove a connector?

(BTW: How can I find and use an executor that is defined in server.xml using
the code above?)

Regards,
  Steffen



AW: How to do a clean connector shut down?

Posted by "Steffen Heil (Mailinglisten)" <li...@steffen-heil.de>.
Hi


> Tomcat version = ?

7.0.33 rev 1397285


> I'd call destroy()
> http://tomcat.apache.org/tomcat-7.0-
> doc/api/org/apache/catalina/Lifecycle.html

I do now, and it works now.
THANKS.


One more question: What about connections still being open, when the
connector is destroyed?
I expected the connections to get closed, but at least in my websocket I do
not receive a StreamInbound.onClose ...?

For comet connections on the other hand, I seem to receive an event
(type=END).

Is this a bug in the websocket implementation or did I miss something?


Regards,
  Steffen


Re: How to do a clean connector shut down?

Posted by Konstantin Kolinko <kn...@gmail.com>.
2013/2/26 Steffen Heil (Mailinglisten) <li...@steffen-heil.de>:
> Hi
>
> I need to start and stop a connector inside a servlet.
> That works with the following code:
>
>                 final org.apache.catalina.connector.Connector nioConnector =
>                         new org.apache.catalina.connector.Connector(
> "org.apache.coyote.http11.Http11NioProtocol" );
>                 nioConnector.setAttribute( "executor", "osiris4Executor" );
>                 nioConnector.setPort( port );
>                 nioConnector.setRedirectPort( 443 );
>                 service.addConnector( nioConnector );
>
> Then I can access the application using that port.
> I can also remove the connector again:
>
>                 try {
>                         nioConnector.stop();
>                 } catch ( LifecycleException e ) {
>                         e.printStackTrace();
>                 }
>                 service.removeConnector( nioConnector );
>
> However, I seem to miss some step, because a
> "NioBlockingSelector.BlockPoller-X" thread is left.
> As I called the upper code in a testcase in a loop I ended up with lots of
> such threads.
>

Tomcat version = ?

I'd call destroy()
http://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/Lifecycle.html


> What do I have to do to completely remove a connector?
>
> (BTW: How can I find and use an executor that is defined in server.xml using
> the code above?)

service.getExecutor(executorName)
nioConnector.getProtocolHandler().setExecutor(executor)

(as used by o.a.c.startup.ConnectorCreateRule )

Best regards,
Konstantin Kolinko

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