parent
c596229d88
commit
3d9252115b
@ -1,28 +1,29 @@
|
|||||||
package com.xxl.job.admin.core.id;
|
package com.xxl.job.admin.core.id;
|
||||||
|
|
||||||
import com.xxl.job.admin.core.id.service.MachineService;
|
import java.util.Date;
|
||||||
import com.xxl.job.admin.core.model.XxlJobMachine;
|
|
||||||
import com.xxl.job.admin.core.util.MachineUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.Date;
|
import com.xxl.job.admin.core.id.service.MachineService;
|
||||||
|
import com.xxl.job.admin.core.model.XxlJobMachine;
|
||||||
|
import com.xxl.job.admin.core.util.MachineUtils;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
public class HeartBeat {
|
public class HeartBeat {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MachineService machineService;
|
private MachineService machineService;
|
||||||
|
|
||||||
@Scheduled(fixedDelay = 10000)
|
@Scheduled(fixedDelay = 10000)
|
||||||
public void checkMachineSurvive(){
|
public void checkMachineSurvive() {
|
||||||
String machineIp = MachineUtils.get();
|
String machineIp = MachineUtils.getIP();
|
||||||
XxlJobMachine xxlJobMachine = machineService.selectByMachineIp(machineIp);
|
XxlJobMachine xxlJobMachine = machineService.selectByMachineIp(machineIp);
|
||||||
if(xxlJobMachine != null){
|
if (xxlJobMachine != null) {
|
||||||
machineService.update(machineIp,new Date());
|
machineService.update(machineIp, new Date());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in new issue