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


   > > 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.
   > 
   > I agree with some of your views,but i think that,if the code Clearly 
indicate the use like `if (isLinuxPlatform()) { try { final Class<?> 
providerClazz = Class.forName("sun.nio.ch.EPollSelectorProvider");`
   > 
   > i think the use like this,The user has no choice,The effect is that the 
user uses EPollSelectorProvider on the linux platform,so much code can use 
Selector.open() instead, and why user must use EPollSelectorProvider in linux 
as the only choose ? may be they can use custom selector,so i think we need 
clear some unnecessory code
   
   I agree with you, `Selector.open()` is much simpler and clean.


----------------------------------------------------------------
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:
[email protected]


Reply via email to