TeslaCN edited a comment on pull request #1873:
URL: 
https://github.com/apache/shardingsphere-elasticjob/pull/1873#issuecomment-822927794


   I deployed 3 nodes in Docker. Killed one when the job was running. But NPE 
occurred and the failover didn't worked. Did I missed something?
   
   My Job:
   ```java
   @Slf4j
   public final class FailoverMain {
   
       private static final CoordinatorRegistryCenter REGISTRY_CENTER = 
Configurations.getCoordinatorRegistryCenter();
   
       private static final int SLEEP_SECONDS = 20;
   
       public static void main(final String[] args) {
           SimpleJob job = shardingContext -> {
               log.info("Start {}", shardingContext);
               for (int i = 0; i < SLEEP_SECONDS; i++) {
                   try {
                       Thread.sleep(1000);
                       log.info("Handling {}", 
shardingContext.getShardingItem());
                   } catch (final InterruptedException ex) {
                       Thread.currentThread().interrupt();
                       ex.printStackTrace();
                   }
               }
               log.info("Done {}", shardingContext);
           };
           new ScheduleJobBootstrap(REGISTRY_CENTER, job, 
jobConfiguration()).schedule();
       }
   
       private static JobConfiguration jobConfiguration() {
           return JobConfiguration.newBuilder("failover-job", 3)
                   .cron("0 * * * * ?")
                   .jobErrorHandlerType("LOG")
                   .monitorExecution(false)
                   .overwrite(true)
                   .failover(true)
                   .maxTimeDiffSeconds(1)
                   
.addExtraConfigurations(Configurations.getTracingConfiguration())
                   .build();
       }
   }
   ```
   
   ```
   02:27:08.871 [Curator-SafeNotifyService-0] ERROR 
org.apache.curator.framework.listen.MappingListenerManager - Listener 
(org.apache.shardingsphere.elasticjob.lite.internal.failover.FailoverListenerManager$JobCrashedJobListener@698122b2)
 threw an exception
   java.lang.NullPointerException: null
        at java.io.StringReader.<init>(StringReader.java:50) ~[?:1.8.0_275]
        at org.yaml.snakeyaml.reader.StreamReader.<init>(StreamReader.java:63) 
~[snakeyaml-1.26.jar:?]
        at org.yaml.snakeyaml.Yaml.loadAs(Yaml.java:452) ~[snakeyaml-1.26.jar:?]
        at 
org.apache.shardingsphere.elasticjob.infra.yaml.YamlEngine.unmarshal(YamlEngine.java:50)
 ~[elasticjob-infra-common-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
        at 
org.apache.shardingsphere.elasticjob.lite.internal.sharding.ShardingService.getCrashedShardingItems(ShardingService.java:185)
 ~[elasticjob-lite-core-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
        at 
org.apache.shardingsphere.elasticjob.lite.internal.failover.FailoverListenerManager$JobCrashedJobListener.dataChanged(FailoverListenerManager.java:86)
 ~[elasticjob-lite-core-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
        at 
org.apache.shardingsphere.elasticjob.lite.internal.listener.AbstractJobListener.event(AbstractJobListener.java:40)
 ~[elasticjob-lite-core-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
        at 
org.apache.curator.framework.recipes.cache.CuratorCacheImpl.lambda$null$8(CuratorCacheImpl.java:286)
 ~[curator-recipes-5.1.0.jar:5.1.0]
        at 
org.apache.curator.framework.listen.MappingListenerManager.lambda$forEach$0(MappingListenerManager.java:92)
 ~[curator-framework-5.1.0.jar:5.1.0]
        at 
org.apache.curator.framework.listen.MappingListenerManager.forEach(MappingListenerManager.java:89)
 ~[curator-framework-5.1.0.jar:5.1.0]
        at 
org.apache.curator.framework.listen.StandardListenerManager.forEach(StandardListenerManager.java:89)
 ~[curator-framework-5.1.0.jar:5.1.0]
        at 
org.apache.curator.framework.recipes.cache.CuratorCacheImpl.lambda$callListeners$10(CuratorCacheImpl.java:293)
 ~[curator-recipes-5.1.0.jar:5.1.0]
        at 
java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1640)
 [?:1.8.0_275]
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 
[?:1.8.0_275]
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 
[?:1.8.0_275]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_275]
   ```


-- 
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:
us...@infra.apache.org


Reply via email to