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 2021/06/25 10:18:03 UTC

[GitHub] [shardingsphere-elasticjob] skaic opened a new issue #1910: ElasticJobExecutor execute have some different between SingleSharding and MultipleSharding

skaic opened a new issue #1910:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/1910


   ## Question
   
   look here:
   
   ```
   @Slf4j
   public final class ElasticJobExecutor {
     ......
     private void process(final JobConfiguration jobConfig, final ShardingContexts shardingContexts, final ExecutionSource executionSource) {
           Collection<Integer> items = shardingContexts.getShardingItemParameters().keySet();
           if (1 == items.size()) {
               int item = shardingContexts.getShardingItemParameters().keySet().iterator().next();
               JobExecutionEvent jobExecutionEvent = new JobExecutionEvent(IpUtils.getHostName(), IpUtils.getIp(), shardingContexts.getTaskId(), jobConfig.getJobName(), executionSource, item);
               process(jobConfig, shardingContexts, item, jobExecutionEvent);
               return;
           }
           CountDownLatch latch = new CountDownLatch(items.size());
           for (int each : items) {
               JobExecutionEvent jobExecutionEvent = new JobExecutionEvent(IpUtils.getHostName(), IpUtils.getIp(), shardingContexts.getTaskId(), jobConfig.getJobName(), executionSource, each);
               ExecutorService executorService = executorContext.get(ExecutorService.class);
               if (executorService.isShutdown()) {
                   return;
               }
               executorService.submit(() -> {
                   try {
                       process(jobConfig, shardingContexts, each, jobExecutionEvent);
                   } finally {
                       latch.countDown();
                   }
               });
           }
           try {
               latch.await();
           } catch (final InterruptedException ex) {
               Thread.currentThread().interrupt();
           }
       }
       ......
   }
   ```
   
   When `shardingContexts.getShardingItemParameters` size is 1 ,  process is run in currentThread。
   Then  `shardingContexts.getShardingItemParameters` size not‘s 1, process is run in ExecutorService.Thread。
   
   I  want to SingleSharding  process keep pace with  MultipleSharding process , what do you think?


-- 
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] skaic closed issue #1910: ElasticJobExecutor execute have some different between SingleSharding and MultipleSharding

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


   


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

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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



[GitHub] [shardingsphere-elasticjob] TeslaCN commented on issue #1910: ElasticJobExecutor execute have some different between SingleSharding and MultipleSharding

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


   I think submitting a task to the thread pool may cause a thread context switch, which is unnecessary for a single shard.


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

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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



[GitHub] [shardingsphere-elasticjob] TeslaCN commented on issue #1910: ElasticJobExecutor execute have some different between SingleSharding and MultipleSharding

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


   I think submitting a task to the thread pool may cause a thread context switch, which is unnecessary for a single shard.


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

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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



[GitHub] [shardingsphere-elasticjob] skaic closed issue #1910: ElasticJobExecutor execute have some different between SingleSharding and MultipleSharding

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


   


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

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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