if (!insert) {
m_logger.warn(String.format("Error when insert domain %s info", domain));
}
}
Hostinfo info = m_hostinfoService.findByIp(ip);
if (info == null) {
m_hostinfoService.insert(domain, ip);
} else {
String oldDomain = info.getDomain();
if (!domain.equals(oldDomain) && !Constants.CAT.equals(oldDomain)) {
// only work on online environment
long current = System.currentTimeMillis();
Date lastModifiedDate = info.getLastModifiedDate();
if (lastModifiedDate != null && (current - lastModifiedDate.getTime()) > ONE_HOUR) {
m_hostinfoService.update(info.getId(), domain, ip);
m_logger.info(String.format("old domain is %s , change ip %s to %s", oldDomain, ip, domain));
}
}
}
}