You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2020/09/28 03:22:28 UTC

[GitHub] [rocketmq] medusar commented on issue #2306: get Selector don't need to judge by programming

medusar commented on issue #2306:
URL: https://github.com/apache/rocketmq/issues/2306#issuecomment-699747793


   Yes, the default `SelectorProvider` will choose the right `Selector` based on the system,  as for Linux, it will use `EPollSelectorProvider` if the kernel is 2.6 or newer otherwise it will choose `PollSelectorProvider`.
   But as the the JDK api says, users can specify their own SelectorProvider: 
   ```
   The first invocation of this method locates the default provider object as follows:
   
   If the system property java.nio.channels.spi.SelectorProvider is defined then it is taken to be the fully-qualified name of a concrete provider class. The class is loaded and instantiated; if this process fails then an unspecified error is thrown.
   
   If a provider class has been installed in a jar file that is visible to the system class loader, and that jar file contains a provider-configuration file named java.nio.channels.spi.SelectorProvider in the resource directory META-INF/services, then the first class name specified in that file is taken. The class is loaded and instantiated; if this process fails then an unspecified error is thrown.
   
   Finally, if no provider has been specified by any of the above means then the system-default provider class is instantiated and the result is returned.
   
   Subsequent invocations of this method return the provider that was returned by the first invocation.
   ```
   So, IMHO, if it is the purpose of RocketMQ to disable user-specified Selector and use `EPollSelectorProvider` regardless of user configuration, use only `Selector.open()` would not work.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org