{
InetAddress ia = InetAddress.getLocalHost();
String hostname = ia.getHostName();//获取本机的hostname
String logName = "index";
LocalhostLogId id = new LocalhostLogId(hostname, logName);
LocalhostLog indexLog = localhostLogDAO.findById(id);
if(indexLog ==null)//本机还没有作索引,直接创建索引
{
creatIndex4MeasurePoints();//创建索引
indexLog = new LocalhostLog(id);//新建日志的记录
Timestamp currentTime = new Timestamp(new Date().getTime());
indexLog.setChangeTime(currentTime);//时间全部设成当前时间
indexLog.setLastUpdate(currentTime);
indexLog.setCurrentUpdate(currentTime);
localhostLogDAO.merge(indexLog);
}
else//找到本机的索引日志记录
{
Date indexUpdate = indexLog.getCurrentUpdate();//maybe bug!!!
List<MaintainLog> maintainLogs = maintainLogDAO.findAll();
for(MaintainLog maintain:maintainLogs)
{
if(indexUpdate.getTime()<maintain.getCurrentUpdate().getTime())//这一条maintainLog有更新
{
creatIndex4MeasurePoints();
indexLog.setChangeTime(maintain.getChangeTime());
indexLog.setLastUpdate(indexLog.getCurrentUpdate());
indexLog.setCurrentUpdate(new Timestamp(new Date().getTime()));
localhostLogDAO.merge(indexLog);
break;
}
else
{