You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/10/08 02:19:51 UTC

[GitHub] [shardingsphere-elasticjob] wwj-go opened a new issue #1546: Implement a new SPI mechanism to replace Java native SPI mechanism

wwj-go opened a new issue #1546:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/1546


   Java's native SPI mechanism has the following disadvantages:
   1. Cannot be loaded on demand. Although `ServiceLoader `does lazy loading, it can basically only be obtained by traversal, that is, all the implementation classes of the interface have to be loaded and instantiated once. If you do not want to use certain implementation classes, or the instantiation of certain classes is time-consuming, java SPI is not a good choice.
   2. The way to obtain a certain implementation class is not flexible enough, it can only be obtained in the form of Iterator, and the corresponding implementation class cannot be obtained according to a certain parameter. In order to realize the function, it is usually necessary to wrap a layer on it, such as `JobItemExecutorFactory`, `JobShardingStrategyFactory`, etc., which is easy to cause duplication of code.
   3. It is not safe for multiple concurrent and multithreaded instances to use the `ServiceLoader `class.
   
   Based on the above reasons, it is necessary to implement another SPI mechanism to work with elastic-job to solve these problems.


----------------------------------------------------------------
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



[GitHub] [shardingsphere-elasticjob] wwj-go closed issue #1546: Implement a new SPI mechanism to replace Java native SPI mechanism

Posted by GitBox <gi...@apache.org>.
wwj-go closed issue #1546:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/1546


   


----------------------------------------------------------------
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



[GitHub] [shardingsphere-elasticjob] wwj-go edited a comment on issue #1546: Implement a new SPI mechanism to replace Java native SPI mechanism

Posted by GitBox <gi...@apache.org>.
wwj-go edited a comment on issue #1546:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/1546#issuecomment-705395078


   @TeslaCN hi,thanks for your reply. I have read the code you said in https://github.com/apache/shardingsphere , and I find that someone have merge it into this project named `ElasticJobServiceLoader`. 
   Personally, from a performance perspective,I think its not a good design.
   1.` register(final Class<T> service)` just save the classes not instances,this is equivalent to saying that instantiation of java SPI is not necessary and is a waste.
   2. Every time call  `newServiceInstances(final Class<T> service)`  will reinstantiate all implements and for the caller like `ElasticJobListenerFactory、 JobErrorHandlerFactory`, just use one implement and discard the rest , it is a serious waste.
   
   
   


----------------------------------------------------------------
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



[GitHub] [shardingsphere-elasticjob] wwj-go commented on issue #1546: Implement a new SPI mechanism to replace Java native SPI mechanism

Posted by GitBox <gi...@apache.org>.
wwj-go commented on issue #1546:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/1546#issuecomment-705896473


   Thanks for your reply,I have got it.
   
   > It is true of the disadvantages of SPI as you said, but there are still lots of advantages of SPI.
   > I only want to discuss the main advantage, `SPI is the standard way of Java extension, developers do not need learn any extra knowledge to understand this way`.
   > So I prefer use the standard way to do extension in ElasticJob.
   
   


----------------------------------------------------------------
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



[GitHub] [shardingsphere-elasticjob] wwj-go edited a comment on issue #1546: Implement a new SPI mechanism to replace Java native SPI mechanism

Posted by GitBox <gi...@apache.org>.
wwj-go edited a comment on issue #1546:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/1546#issuecomment-705395078


   @TeslaCN hi,thanks for your reply. I have read the code you said in https://github.com/apache/shardingsphere , and I find that someone have merge it into this project named `ElasticJobServiceLoader`. 
   Personally, from a performance perspective,I think its not a good design.
   1.` register(final Class<T> service)` just save the classes not instances,this is equivalent to saying that instantiation of java SPI is not necessary and is a waste.
   2. Every time call  `newServiceInstances(final Class<T> service)`  will reinstantiate all implements and for the caller like `ElasticJobListenerFactory、 JobErrorHandlerFactory`, just use one implement and discard the rest , it is a serious waste.
   
   
   


----------------------------------------------------------------
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



[GitHub] [shardingsphere-elasticjob] TeslaCN removed a comment on issue #1546: Implement a new SPI mechanism to replace Java native SPI mechanism

Posted by GitBox <gi...@apache.org>.
TeslaCN removed a comment on issue #1546:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/1546#issuecomment-705407285


   Please contact wechat ss_assistant_1 to join us.


----------------------------------------------------------------
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



[GitHub] [shardingsphere-elasticjob] TeslaCN removed a comment on issue #1546: Implement a new SPI mechanism to replace Java native SPI mechanism

Posted by GitBox <gi...@apache.org>.
TeslaCN removed a comment on issue #1546:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/1546#issuecomment-705407285


   Please contact wechat ss_assistant_1 to join us.


----------------------------------------------------------------
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



[GitHub] [shardingsphere-elasticjob] wwj-go commented on issue #1546: Implement a new SPI mechanism to replace Java native SPI mechanism

Posted by GitBox <gi...@apache.org>.
wwj-go commented on issue #1546:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/1546#issuecomment-705395078


   @TeslaCN hi,thanks for your reply. I have read the code you said in https://github.com/apache/shardingsphere , and I find that someone have merge it into this project named `ElasticJobServiceLoader`. 
   Personally, from a performance perspective,I think its not a good design.
   1.` register(final Class<T> service)` just save the classes not instances,this is equivalent to saying that instantiation of java SPI is not necessary and is a waste.
   2. Every time call  `newServiceInstances(final Class<T> service)`  will reinstantiate all implements and for the caller like `ElasticJobListenerFactory、 JobErrorHandlerFactory`, just use the first implement and discard the rest , it is a serious waste.
   
   
   


----------------------------------------------------------------
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



[GitHub] [shardingsphere-elasticjob] wwj-go commented on issue #1546: Implement a new SPI mechanism to replace Java native SPI mechanism

Posted by GitBox <gi...@apache.org>.
wwj-go commented on issue #1546:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/1546#issuecomment-705294312


   hi @Technoboy-  , I have implemented an SPI loading mechanism to adapt to elastic-job, can you assign this task to me?


----------------------------------------------------------------
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



[GitHub] [shardingsphere-elasticjob] wwj-go commented on issue #1546: Implement a new SPI mechanism to replace Java native SPI mechanism

Posted by GitBox <gi...@apache.org>.
wwj-go commented on issue #1546:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/1546#issuecomment-705395078






----------------------------------------------------------------
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



[GitHub] [shardingsphere-elasticjob] TeslaCN commented on issue #1546: Implement a new SPI mechanism to replace Java native SPI mechanism

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on issue #1546:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/1546#issuecomment-705345807


   Personally I think that:
   1. Those implementations of interfaces are highly modular (such as 'elasticjob-error-handler-email'). Users just introduce the dependencies as needed.
   2. A certain implementation can be distinguished by a string based type defined in 'TypedSPI'. Iterator is acceptable because factory methods are invoke less frequently.
   3. The current factories using static block to institate instances.
   
   You may consider referencing the SPI registry in https://github.com/apache/shardingsphere.


----------------------------------------------------------------
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



[GitHub] [shardingsphere-elasticjob] TeslaCN commented on issue #1546: Implement a new SPI mechanism to replace Java native SPI mechanism

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on issue #1546:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/1546#issuecomment-705345807






----------------------------------------------------------------
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



[GitHub] [shardingsphere-elasticjob] terrymanu commented on issue #1546: Implement a new SPI mechanism to replace Java native SPI mechanism

Posted by GitBox <gi...@apache.org>.
terrymanu commented on issue #1546:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/1546#issuecomment-705472224


   It is true of the disadvantages of SPI as you said, but there are still lots of advantages of SPI.
   I only want to discuss the main advantage, `SPI  is the standard way of Java extension, developers do not need learn any extra knowledge to understand this way`.
   So I prefer use the standard way to do extension in ElasticJob. 
   


----------------------------------------------------------------
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



[GitHub] [shardingsphere-elasticjob] terrymanu commented on issue #1546: Implement a new SPI mechanism to replace Java native SPI mechanism

Posted by GitBox <gi...@apache.org>.
terrymanu commented on issue #1546:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/1546#issuecomment-705472224


   It is true of the disadvantages of SPI as you said, but there are still lots of advantages of SPI.
   I only want to discuss the main advantage, `SPI  is the standard way of Java extension, developers do not need learn any extra knowledge to understand this way`.
   So I prefer use the standard way to do extension in ElasticJob. 
   


----------------------------------------------------------------
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



[GitHub] [shardingsphere-elasticjob] TeslaCN commented on issue #1546: Implement a new SPI mechanism to replace Java native SPI mechanism

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on issue #1546:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/1546#issuecomment-705407285


   Please contact wechat ss_assistant_1 to join us.


----------------------------------------------------------------
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



[GitHub] [shardingsphere-elasticjob] wwj-go closed issue #1546: Implement a new SPI mechanism to replace Java native SPI mechanism

Posted by GitBox <gi...@apache.org>.
wwj-go closed issue #1546:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/1546


   


----------------------------------------------------------------
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