apache / shardingsphere-elasticjob

Distributed scheduled job
Apache License 2.0
8.12k stars 3.28k forks source link

Elasticjob unable to get local IP address, runtime In JDK version 1.8.0_40 #1858

Closed yangzhoucyl closed 2 months ago

yangzhoucyl commented 3 years ago

Bug Report

Which version of ElasticJob did you use?

Which project did you use? ElasticJob-Lite or ElasticJob-Cloud?

Expected behavior

Actual behavior

org.apache.shardingsphere.elasticjob.infra.env.HostException: ip is null

at org.apache.shardingsphere.elasticjob.infra.env.IpUtils.getIp(IpUtils.java:68)

Reason analyze (If you can)

Version before jdk1.8.0_74 `InetAddress.isReachable()` returns incorrectly

Steps to reproduce the behavior.

org.apache.shardingsphere.elasticjob.infra.env.HostException: ip is null

at org.apache.shardingsphere.elasticjob.infra.env.IpUtils.getIp(IpUtils.java:68)
at org.apache.shardingsphere.elasticjob.infra.env.IpUtilsTest.assertGetIp(IpUtilsTest.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)

Example codes for reproduce this issue (such as a github link).

Zihao-Liu commented 3 years ago

How about Using Socket connect to some open ports like 22, 80, etc. after InetAddress.isReachable() return false

TeslaCN commented 3 years ago

How about Using Socket connect to some open ports like 22, 80, etc. after InetAddress.isReachable() return false

This may not work. The final goal is find a proper IP for current environment. Testing reachable is just a way to do that.

sunkai-cai commented 3 years ago

I think the "isReachable" method has not been worthy of checking local network。Maybe better to check the networdAddress of regCenter.

doctormacky commented 2 years ago

same issue in Mac

stack trace log:

15:16:23.919 [main-SendThread(127.0.0.1:2181)] DEBUG org.apache.zookeeper.ClientCnxn - Reading reply session id: 0x100002f22d70008, packet:: clientPath:/elastic-job-demo/javaHttpJob/config serverPath:/elastic-job-demo/javaHttpJob/config finished:false header:: 13,12  replyHeader:: 13,21,0  request:: '/elastic-job-demo/javaHttpJob/config,F  response:: v{},s{6,6,1642575279023,1642575279023,0,0,0,0,392,0,6} 
Exception in thread "main" org.apache.shardingsphere.elasticjob.infra.env.HostException: ip is null
    at org.apache.shardingsphere.elasticjob.infra.env.IpUtils.getIp(IpUtils.java:70)
    at org.apache.shardingsphere.elasticjob.infra.handler.sharding.JobInstance.<init>(JobInstance.java:44)
    at org.apache.shardingsphere.elasticjob.lite.internal.schedule.JobScheduler.registerStartUpInfo(JobScheduler.java:176)
    at org.apache.shardingsphere.elasticjob.lite.internal.schedule.JobScheduler.createJobScheduleController(JobScheduler.java:140)
    at org.apache.shardingsphere.elasticjob.lite.internal.schedule.JobScheduler.<init>(JobScheduler.java:104)
    at org.apache.shardingsphere.elasticjob.lite.api.bootstrap.impl.ScheduleJobBootstrap.<init>(ScheduleJobBootstrap.java:40)
    at com.ibm.cloud.security.job.Main.main(Main.java:18)
15:16:37.261 [main-SendThread(127.0.0.1:2181)] DEBUG org.apache.zookeeper.ClientCnxn - Got ping response for session id: 0x100002f22d70008 after 5ms.
icetea916 commented 2 years ago

There is the same problem in a windows system with JDK version 1.8.0_73, but there is no problem in another windows system with JDK version 1.8.0_131.

After I upgrade the JDK to 1.8.0_131, the program can start normally.

Maven dependency:

<dependency>
    <groupId>org.apache.shardingsphere.elasticjob</groupId>
    <artifactId>elasticjob-lite-spring-boot-starter</artifactId>
    <version>3.0.1</version>
</dependency>

Exception log (jdk=1.8.0_73)

09:52:40.675 [main] INFO  o.q.i.StdSchedulerFactory - [instantiate,1362] - Quartz scheduler 'demoSimpleJob' initialized from an externally provided properties instance.
09:52:40.675 [main] INFO  o.q.i.StdSchedulerFactory - [instantiate,1366] - Quartz scheduler version: 2.3.1
09:52:40.683 [main] INFO  o.a.c.u.Compatibility - [<clinit>,47] - Using org.apache.zookeeper.server.quorum.MultipleAddresses
09:52:41.010 [main] ERROR o.s.b.SpringApplication - [reportFailure,823] - Application run failed
org.apache.shardingsphere.elasticjob.infra.env.HostException: ip is null
    at org.apache.shardingsphere.elasticjob.infra.env.IpUtils.getIp(IpUtils.java:70)
    at org.apache.shardingsphere.elasticjob.infra.handler.sharding.JobInstance.<init>(JobInstance.java:44)
    at org.apache.shardingsphere.elasticjob.lite.internal.schedule.JobScheduler.registerStartUpInfo(JobScheduler.java:176)
    at org.apache.shardingsphere.elasticjob.lite.internal.schedule.JobScheduler.createJobScheduleController(JobScheduler.java:140)
    at org.apache.shardingsphere.elasticjob.lite.internal.schedule.JobScheduler.<init>(JobScheduler.java:90)
    at org.apache.shardingsphere.elasticjob.lite.api.bootstrap.impl.ScheduleJobBootstrap.<init>(ScheduleJobBootstrap.java:36)
    at org.apache.shardingsphere.elasticjob.lite.spring.boot.job.ElasticJobBootstrapConfiguration.registerClassedJob(ElasticJobBootstrapConfiguration.java:108)
    at org.apache.shardingsphere.elasticjob.lite.spring.boot.job.ElasticJobBootstrapConfiguration.constructJobBootstraps(ElasticJobBootstrapConfiguration.java:91)
    at org.apache.shardingsphere.elasticjob.lite.spring.boot.job.ElasticJobBootstrapConfiguration.createJobBootstrapBeans(ElasticJobBootstrapConfiguration.java:64)
    at org.apache.shardingsphere.elasticjob.lite.spring.boot.job.ElasticJobBootstrapConfiguration.afterSingletonsInstantiated(ElasticJobBootstrapConfiguration.java:52)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:862)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204)
    at com.szpt.task.SzptTaskApplication.main(SzptTaskApplication.java:13)
09:52:41.012 [main] INFO  o.q.c.QuartzScheduler - [shutdown,666] - Scheduler quartzScheduler_$_NON_CLUSTERED shutting down.
09:52:41.012 [main] INFO  o.q.c.QuartzScheduler - [standby,585] - Scheduler quartzScheduler_$_NON_CLUSTERED paused.
09:52:41.012 [main] INFO  o.q.c.QuartzScheduler - [shutdown,740] - Scheduler quartzScheduler_$_NON_CLUSTERED shutdown complete.
09:52:41.527 [Curator-Framework-0] INFO  o.a.c.f.i.CuratorFrameworkImpl - [backgroundOperationsLoop,964] - backgroundOperationsLoop exiting
09:52:41.645 [main-EventThread] INFO  o.a.z.ClientCnxn - [run,566] - EventThread shut down for session: 0x10cfa647f780009
09:52:41.645 [main] INFO  o.a.z.ZooKeeper - [close,1618] - Session: 0x10cfa647f780009 closed

Normal log (jdk=1.8.0_131)

13:07:30.325 [main] INFO  o.a.s.e.l.i.s.JobShutdownHookPlugin - [registerShutdownHook,75] - Registering Quartz shutdown hook. demoSimpleJob
13:07:30.325 [main] INFO  o.q.s.RAMJobStore - [initialize,155] - RAMJobStore initialized.
13:07:30.325 [main] INFO  o.q.c.QuartzScheduler - [initialize,294] - Scheduler meta-data: Quartz Scheduler (v2.3.1) 'demoSimpleJob' with instanceId 'NON_CLUSTERED'
  Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
  NOT STARTED.
  Currently in standby mode.
  Number of jobs executed: 0
  Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 1 threads.
  Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.

13:07:30.325 [main] INFO  o.q.i.StdSchedulerFactory - [instantiate,1362] - Quartz scheduler 'demoSimpleJob' initialized from an externally provided properties instance.
13:07:30.325 [main] INFO  o.q.i.StdSchedulerFactory - [instantiate,1366] - Quartz scheduler version: 2.3.1
13:07:30.340 [main] INFO  o.a.c.u.Compatibility - [<clinit>,47] - Using org.apache.zookeeper.server.quorum.MultipleAddresses
13:07:30.684 [main] INFO  o.q.i.StdSchedulerFactory - [instantiate,1208] - Using default implementation for ThreadExecutor
13:07:30.684 [main] INFO  o.q.c.SchedulerSignalerImpl - [<init>,61] - Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
13:07:30.684 [main] INFO  o.q.c.QuartzScheduler - [<init>,229] - Quartz Scheduler v.2.3.1 created.
linghengqian commented 11 months ago
bairwqbh commented 4 months ago

都是中国人,为什么不用中文交流?

linghengqian commented 4 months ago
linghengqian commented 2 months ago

Since both ElasticJob Cloud and mesos integration modules have been removed from the master branch, close the current issue.