taskHBs = new HashMap<Integer, TkHbCacheTime>();
data.getTaskHeartbeatsCache().put(topologyId, taskHBs);
}
TkHbCacheTime taskHB = taskHBs.get(taskId);
if (taskHB == null) {
LOG.info("No task heartbeat cache " + idStr);
if (zkTaskHeartbeat == null) {
LOG.info("No ZK task hearbeat " + idStr);
return true;
}
taskHB = new TkHbCacheTime();
taskHB.update(zkTaskHeartbeat);
taskHBs.put(taskId, taskHB);
return false;
}
if (zkReportTime == null) {
LOG.debug("No ZK task heartbeat " + idStr);
// Task hasn't finish init
int nowSecs = TimeUtils.current_time_secs();
int assignSecs = taskHB.getTaskAssignedTime();
int waitInitTimeout = JStormUtils.parseInt(data.getConf().get(
Config.NIMBUS_TASK_LAUNCH_SECS));
if (nowSecs - assignSecs > waitInitTimeout) {
LOG.info(idStr + " failed to init ");
return true;
} else {
return false;
}
}
// the left is zkReportTime isn't null
// task has finished initialization
int nimbusTime = taskHB.getNimbusTime();
int reportTime = taskHB.getTaskReportedTime();
int nowSecs = TimeUtils.current_time_secs();
if (nimbusTime == 0) {
// taskHB no entry, first time
// update taskHB
taskHB.setNimbusTime(nowSecs);
taskHB.setTaskReportedTime(zkReportTime);
LOG.info("Update taskheartbeat to nimbus cache " + idStr);
return false;
}
if (reportTime != zkReportTime.intValue()) {
// zk has been updated the report time
taskHB.setNimbusTime(nowSecs);
taskHB.setTaskReportedTime(zkReportTime);
LOG.debug(idStr + ",nimbusTime " + nowSecs + ",zkReport:"
+ zkReportTime + ",report:" + reportTime);
return false;
}