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/09 01:10:47 UTC

[GitHub] [shardingsphere-elasticjob] wwj-go opened a new pull request #1547: Redesign SPI factory to make them into one class (#1537)

wwj-go opened a new pull request #1547:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1547


   Fixes #1537.
   
   Changes proposed in this pull request:
   
      Redesign SPI factory to make logic about their TypedSPI into ElasticJobServiceLoader. The SPI factory class are:
   - `JobShardingStrategyFactory`
   - `JobExecutorServiceHandlerFactory`
   - `JobErrorHandlerFactory`
   - `ElasticJobListenerFactory`
   
   The situation of `JobItemExecutorFactory `is a bit complicated and will be completed in subsequent 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



[GitHub] [shardingsphere-elasticjob] codecov-io commented on pull request #1547: Redesign SPI factory to make them into one class (#1537)

Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #1547:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1547#issuecomment-705917166


   # [Codecov](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547?src=pr&el=h1) Report
   > Merging [#1547](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547?src=pr&el=desc) into [master](https://codecov.io/gh/apache/shardingsphere-elasticjob/commit/11532014e40561ea4bb46e93a2592e5b072a6f8c?el=desc) will **decrease** coverage by `0.13%`.
   > The diff coverage is `62.06%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547/graphs/tree.svg?width=650&height=150&src=pr&token=8ZMVc4Yo4Z)](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #1547      +/-   ##
   ============================================
   - Coverage     85.30%   85.17%   -0.14%     
   + Complexity      102      101       -1     
   ============================================
     Files           247      247              
     Lines          5676     5685       +9     
     Branches        890      892       +2     
   ============================================
     Hits           4842     4842              
   - Misses          524      530       +6     
   - Partials        310      313       +3     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | [...cjob/infra/listener/ElasticJobListenerFactory.java](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547/diff?src=pr&el=tree#diff-ZWxhc3RpY2pvYi1pbmZyYS9lbGFzdGljam9iLWluZnJhLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZWxhc3RpY2pvYi9pbmZyYS9saXN0ZW5lci9FbGFzdGljSm9iTGlzdGVuZXJGYWN0b3J5LmphdmE=) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (ø)` | |
   | [.../elasticjob/infra/spi/ElasticJobServiceLoader.java](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547/diff?src=pr&el=tree#diff-ZWxhc3RpY2pvYi1pbmZyYS9lbGFzdGljam9iLWluZnJhLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZWxhc3RpY2pvYi9pbmZyYS9zcGkvRWxhc3RpY0pvYlNlcnZpY2VMb2FkZXIuamF2YQ==) | `34.37% <52.63%> (+34.37%)` | `0.00 <0.00> (ø)` | |
   | [...asticjob/error/handler/JobErrorHandlerFactory.java](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547/diff?src=pr&el=tree#diff-ZWxhc3RpY2pvYi1lcnJvci1oYW5kbGVyL2VsYXN0aWNqb2ItZXJyb3ItaGFuZGxlci10eXBlL2VsYXN0aWNqb2ItZXJyb3ItaGFuZGxlci1nZW5lcmFsL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9lbGFzdGljam9iL2Vycm9yL2hhbmRsZXIvSm9iRXJyb3JIYW5kbGVyRmFjdG9yeS5qYXZh) | `100.00% <100.00%> (ø)` | `0.00 <0.00> (ø)` | |
   | [...a/handler/sharding/JobShardingStrategyFactory.java](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547/diff?src=pr&el=tree#diff-ZWxhc3RpY2pvYi1pbmZyYS9lbGFzdGljam9iLWluZnJhLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZWxhc3RpY2pvYi9pbmZyYS9oYW5kbGVyL3NoYXJkaW5nL0pvYlNoYXJkaW5nU3RyYXRlZ3lGYWN0b3J5LmphdmE=) | `100.00% <100.00%> (ø)` | `0.00 <0.00> (ø)` | |
   | [...r/threadpool/JobExecutorServiceHandlerFactory.java](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547/diff?src=pr&el=tree#diff-ZWxhc3RpY2pvYi1pbmZyYS9lbGFzdGljam9iLWluZnJhLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZWxhc3RpY2pvYi9pbmZyYS9oYW5kbGVyL3RocmVhZHBvb2wvSm9iRXhlY3V0b3JTZXJ2aWNlSGFuZGxlckZhY3RvcnkuamF2YQ==) | `100.00% <100.00%> (ø)` | `0.00 <0.00> (ø)` | |
   | [...sticjob/reg/zookeeper/ZookeeperRegistryCenter.java](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547/diff?src=pr&el=tree#diff-ZWxhc3RpY2pvYi1pbmZyYS9lbGFzdGljam9iLXJlZ2lzdHJ5LWNlbnRlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZWxhc3RpY2pvYi9yZWcvem9va2VlcGVyL1pvb2tlZXBlclJlZ2lzdHJ5Q2VudGVyLmphdmE=) | `72.44% <0.00%> (-0.79%)` | `32.00% <0.00%> (-1.00%)` | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547?src=pr&el=footer). Last update [1153201...77e2632](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
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] codecov-io commented on pull request #1547: Redesign SPI factory to make them into one class (#1537)

Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #1547:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1547#issuecomment-705917166


   # [Codecov](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547?src=pr&el=h1) Report
   > Merging [#1547](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547?src=pr&el=desc) into [master](https://codecov.io/gh/apache/shardingsphere-elasticjob/commit/11532014e40561ea4bb46e93a2592e5b072a6f8c?el=desc) will **decrease** coverage by `0.13%`.
   > The diff coverage is `62.06%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547/graphs/tree.svg?width=650&height=150&src=pr&token=8ZMVc4Yo4Z)](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #1547      +/-   ##
   ============================================
   - Coverage     85.30%   85.17%   -0.14%     
   + Complexity      102      101       -1     
   ============================================
     Files           247      247              
     Lines          5676     5685       +9     
     Branches        890      892       +2     
   ============================================
     Hits           4842     4842              
   - Misses          524      530       +6     
   - Partials        310      313       +3     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | [...cjob/infra/listener/ElasticJobListenerFactory.java](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547/diff?src=pr&el=tree#diff-ZWxhc3RpY2pvYi1pbmZyYS9lbGFzdGljam9iLWluZnJhLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZWxhc3RpY2pvYi9pbmZyYS9saXN0ZW5lci9FbGFzdGljSm9iTGlzdGVuZXJGYWN0b3J5LmphdmE=) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (ø)` | |
   | [.../elasticjob/infra/spi/ElasticJobServiceLoader.java](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547/diff?src=pr&el=tree#diff-ZWxhc3RpY2pvYi1pbmZyYS9lbGFzdGljam9iLWluZnJhLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZWxhc3RpY2pvYi9pbmZyYS9zcGkvRWxhc3RpY0pvYlNlcnZpY2VMb2FkZXIuamF2YQ==) | `34.37% <52.63%> (+34.37%)` | `0.00 <0.00> (ø)` | |
   | [...asticjob/error/handler/JobErrorHandlerFactory.java](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547/diff?src=pr&el=tree#diff-ZWxhc3RpY2pvYi1lcnJvci1oYW5kbGVyL2VsYXN0aWNqb2ItZXJyb3ItaGFuZGxlci10eXBlL2VsYXN0aWNqb2ItZXJyb3ItaGFuZGxlci1nZW5lcmFsL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9lbGFzdGljam9iL2Vycm9yL2hhbmRsZXIvSm9iRXJyb3JIYW5kbGVyRmFjdG9yeS5qYXZh) | `100.00% <100.00%> (ø)` | `0.00 <0.00> (ø)` | |
   | [...a/handler/sharding/JobShardingStrategyFactory.java](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547/diff?src=pr&el=tree#diff-ZWxhc3RpY2pvYi1pbmZyYS9lbGFzdGljam9iLWluZnJhLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZWxhc3RpY2pvYi9pbmZyYS9oYW5kbGVyL3NoYXJkaW5nL0pvYlNoYXJkaW5nU3RyYXRlZ3lGYWN0b3J5LmphdmE=) | `100.00% <100.00%> (ø)` | `0.00 <0.00> (ø)` | |
   | [...r/threadpool/JobExecutorServiceHandlerFactory.java](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547/diff?src=pr&el=tree#diff-ZWxhc3RpY2pvYi1pbmZyYS9lbGFzdGljam9iLWluZnJhLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZWxhc3RpY2pvYi9pbmZyYS9oYW5kbGVyL3RocmVhZHBvb2wvSm9iRXhlY3V0b3JTZXJ2aWNlSGFuZGxlckZhY3RvcnkuamF2YQ==) | `100.00% <100.00%> (ø)` | `0.00 <0.00> (ø)` | |
   | [...sticjob/reg/zookeeper/ZookeeperRegistryCenter.java](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547/diff?src=pr&el=tree#diff-ZWxhc3RpY2pvYi1pbmZyYS9lbGFzdGljam9iLXJlZ2lzdHJ5LWNlbnRlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZWxhc3RpY2pvYi9yZWcvem9va2VlcGVyL1pvb2tlZXBlclJlZ2lzdHJ5Q2VudGVyLmphdmE=) | `72.44% <0.00%> (-0.79%)` | `32.00% <0.00%> (-1.00%)` | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547?src=pr&el=footer). Last update [1153201...77e2632](https://codecov.io/gh/apache/shardingsphere-elasticjob/pull/1547?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
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 pull request #1547: Redesign SPI factory to make them into one class (#1537)

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on pull request #1547:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1547#issuecomment-705913915


   I thought #1537 is going to remove those factory classes.
   @terrymanu 


----------------------------------------------------------------
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 pull request #1547: Redesign SPI factory to make them into one class (#1537)

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on pull request #1547:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1547#issuecomment-705913915


   I thought #1537 is going to remove those factory classes.
   @terrymanu 


----------------------------------------------------------------
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 a change in pull request #1547: Redesign SPI factory to make them into one class (#1537)

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on a change in pull request #1547:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1547#discussion_r502119684



##########
File path: elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/listener/ElasticJobListenerFactory.java
##########
@@ -40,6 +40,6 @@
      * @return optional job listener instance
      */
     public static Optional<ElasticJobListener> createListener(final String type) {
-        return ElasticJobServiceLoader.newServiceInstances(ElasticJobListener.class).stream().filter(listener -> listener.getType().equalsIgnoreCase(type)).findFirst();
+        return Optional.of(ElasticJobServiceLoader.newTypedServiceInstance(ElasticJobListener.class, type));

Review comment:
       `Optional.of()` will throw exception if parameter is null, which makes caller invoke `orElseThrow` is meaningless.

##########
File path: elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-general/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/JobErrorHandlerFactory.java
##########
@@ -48,8 +48,8 @@
         }
         return newHandlerInstance(type);
     }
-    

Review comment:
       Keep indents (including blank lines) consistent with the previous one, please.
   Ref https://shardingsphere.apache.org/community/en/contribute/code-conduct/




----------------------------------------------------------------
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 pull request #1547: Redesign SPI factory to make them into one class (#1537)

Posted by GitBox <gi...@apache.org>.
wwj-go closed pull request #1547:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1547


   


----------------------------------------------------------------
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 pull request #1547: Redesign SPI factory to make them into one class (#1537)

Posted by GitBox <gi...@apache.org>.
wwj-go closed pull request #1547:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1547


   


----------------------------------------------------------------
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 a change in pull request #1547: Redesign SPI factory to make them into one class (#1537)

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on a change in pull request #1547:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1547#discussion_r502119684



##########
File path: elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/listener/ElasticJobListenerFactory.java
##########
@@ -40,6 +40,6 @@
      * @return optional job listener instance
      */
     public static Optional<ElasticJobListener> createListener(final String type) {
-        return ElasticJobServiceLoader.newServiceInstances(ElasticJobListener.class).stream().filter(listener -> listener.getType().equalsIgnoreCase(type)).findFirst();
+        return Optional.of(ElasticJobServiceLoader.newTypedServiceInstance(ElasticJobListener.class, type));

Review comment:
       `Optional.of()` will throw exception if parameter is null, which makes caller invoke `orElseThrow` is meaningless.

##########
File path: elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-general/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/JobErrorHandlerFactory.java
##########
@@ -48,8 +48,8 @@
         }
         return newHandlerInstance(type);
     }
-    

Review comment:
       Keep indents (including blank lines) consistent with the previous one, please.
   Ref https://shardingsphere.apache.org/community/en/contribute/code-conduct/




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