/// <summary> /// 将数据放入缓存 /// </summary> /// <param name="tcpmessage"></param> public static void CacheData() { try { DateTime curdt = DateTime.Now; //将采集器天数据批量加入缓存 CollectorDayDataService.GetInstance().batchToCache(BaseMessage.collectordayDataMap); LogUtil.writeline("memcached collectordayDataMap用时:" + (DateTime.Now.Subtract(curdt).TotalSeconds)); } catch (Exception e) { LogUtil.error("batch Cache day data error:" + e.Message); } try { DateTime curdt = DateTime.Now; //DeviceDayDataService.GetInstance().batchToCache(BaseMessage.devicedayDataMapList); ////将设备天数据批量放入缓存 DeviceDayDataCacheHandler ddch = null; for (int i=0;i<50;i++) { if (cacheDayOjectMap.ContainsKey(i)) ddch = cacheDayOjectMap[i]; else { ddch = new DeviceDayDataCacheHandler(i); cacheDayOjectMap[i] = ddch; } Thread m_thread = new Thread(new ThreadStart(ddch.batchToCacheList)); m_thread.Name = "memcache Handel Thread-" + i; m_thread.Start(); } int times = 0; bool iswork = isWork(); //如果线程都在工作并且持续时间一分钟之内继续循环,否则跳出循环,进行以后动作,add by qhb in 20120927 for 解析其中有个现场死了,整个程序 //就停在这里了。 while (iswork && times < 60) { times++; iswork = isWork(); Thread.Sleep(1000); } LogUtil.writeline("memcached devicedayDataMap用时:" + (DateTime.Now.Subtract(curdt).TotalSeconds)); } catch (Exception e) { LogUtil.error("batch Cache device day data error:" + e.Message); } try { DateTime curdt = DateTime.Now; //缓存采集器实时数据 CollectorRunDataService.GetInstance().batchCache(BaseMessage.collectorRunDataMap.Values); LogUtil.writeline("memcached collectorRunDataMap用时:" + (DateTime.Now.Subtract(curdt).TotalSeconds)); } catch (Exception e) { LogUtil.error("batch Cache run data error:" + e.Message); } try { DateTime curdt = DateTime.Now; //批量保存设备实时数据到缓存 DeviceRunDataService.GetInstance().BatchCache(BaseMessage.deviceRunDataMap.Values); LogUtil.writeline("memcached deviceRunDataMap用时:" + (DateTime.Now.Subtract(curdt).TotalSeconds)); } catch (Exception e) { LogUtil.error("batch Cache device run data error:" + e.Message); } try { FaultService.GetInstance().batchSave(BaseMessage.faultList); BaseMessage.faultList.Clear(); } catch (Exception e) { LogUtil.info("batch Cache fualt error:" + e.Message); } try { DateTime curdt = DateTime.Now; //将设备最大值统计数据放入缓存 DeviceDataCountService.GetInstance().batchCache(BaseMessage.deviceDataCounts); BaseMessage.deviceDataCounts.Clear(); LogUtil.writeline("memcached deviceDataCounts用时:" + (DateTime.Now.Subtract(curdt).TotalSeconds)); } catch (Exception e) { LogUtil.error("save max value error:" + e.Message); } //将本地内存数据放入缓存后,就要清理本地内存,否有内存溢出问题 //clearDayDataMap(); //每次缓存后 同时将同步到memcahced if (syndata != null && syndata.Equals("true")) { SynDataService.GetInstance().synRunData(); } }
/// <summary> /// 将数据放入缓存 /// </summary> /// <param name="tcpmessage"></param> public static void CacheData() { try { DateTime curdt = DateTime.Now; //将采集器天数据批量加入缓存 CollectorDayDataService.GetInstance().batchToCache(BaseMessage.collectordayDataMap); LogUtil.writeline("memcached collectordayDataMap用时:" + (DateTime.Now.Subtract(curdt).TotalSeconds)); } catch (Exception e) { LogUtil.error("batch Cache day data error:" + e.Message); } try { DateTime curdt = DateTime.Now; //DeviceDayDataService.GetInstance().batchToCache(BaseMessage.devicedayDataMapList); ////将设备天数据批量放入缓存 DeviceDayDataCacheHandler ddch = null; for (int i=0;i<50;i++) { if (cacheDayOjectMap.ContainsKey(i)) ddch = cacheDayOjectMap[i]; else { ddch = new DeviceDayDataCacheHandler(i); cacheDayOjectMap[i] = ddch; } Thread m_thread = new Thread(new ThreadStart(ddch.batchToCacheList)); m_thread.Name = "memcache Handel Thread-" + i; m_thread.Start(); } while (isWork()) { Thread.Sleep(1000); } LogUtil.writeline("memcached devicedayDataMap用时:" + (DateTime.Now.Subtract(curdt).TotalSeconds)); } catch (Exception e) { LogUtil.error("batch Cache device day data error:" + e.Message); } try { DateTime curdt = DateTime.Now; //缓存采集器实时数据 CollectorRunDataService.GetInstance().batchCache(BaseMessage.collectorRunDataMap.Values); LogUtil.writeline("memcached collectorRunDataMap用时:" + (DateTime.Now.Subtract(curdt).TotalSeconds)); } catch (Exception e) { LogUtil.error("batch Cache run data error:" + e.Message); } try { DateTime curdt = DateTime.Now; //批量保存设备实时数据到缓存 DeviceRunDataService.GetInstance().BatchCache(BaseMessage.deviceRunDataMap.Values); LogUtil.writeline("memcached deviceRunDataMap用时:" + (DateTime.Now.Subtract(curdt).TotalSeconds)); } catch (Exception e) { LogUtil.error("batch Cache device run data error:" + e.Message); } try { FaultService.GetInstance().batchSave(BaseMessage.faultList); BaseMessage.faultList.Clear(); } catch (Exception e) { LogUtil.info("batch Cache fualt error:" + e.Message); } try { DateTime curdt = DateTime.Now; //将设备最大值统计数据放入缓存 DeviceDataCountService.GetInstance().batchCache(BaseMessage.deviceDataCounts); BaseMessage.deviceDataCounts.Clear(); LogUtil.writeline("memcached deviceDataCounts用时:" + (DateTime.Now.Subtract(curdt).TotalSeconds)); } catch (Exception e) { LogUtil.error("save max value error:" + e.Message); } clearDayDataMap(); }
/// <summary> /// 将数据放入缓存 /// </summary> /// <param name="tcpmessage"></param> public static void CacheData() { try { DateTime curdt = DateTime.Now; //将采集器天数据批量加入缓存 CollectorDayDataService.GetInstance().batchToCache(BaseMessage.collectordayDataMap); LogUtil.writeline("memcached collectordayDataMap用时:" + (DateTime.Now.Subtract(curdt).TotalSeconds)); } catch (Exception e) { LogUtil.error("batch Cache day data error:" + e.Message); } try { DateTime curdt = DateTime.Now; //DeviceDayDataService.GetInstance().batchToCache(BaseMessage.devicedayDataMapList); ////将设备天数据批量放入缓存 DeviceDayDataCacheHandler ddch = null; for (int i = 0; i < 50; i++) { if (cacheDayOjectMap.ContainsKey(i)) { ddch = cacheDayOjectMap[i]; } else { ddch = new DeviceDayDataCacheHandler(i); cacheDayOjectMap[i] = ddch; } Thread m_thread = new Thread(new ThreadStart(ddch.batchToCacheList)); m_thread.Name = "memcache Handel Thread-" + i; m_thread.Start(); } int times = 0; bool iswork = isWork(); //如果线程都在工作并且持续时间一分钟之内继续循环,否则跳出循环,进行以后动作,add by qhb in 20120927 for 解析其中有个现场死了,整个程序 //就停在这里了。 while (iswork && times < 60) { times++; iswork = isWork(); Thread.Sleep(1000); } LogUtil.writeline("memcached devicedayDataMap用时:" + (DateTime.Now.Subtract(curdt).TotalSeconds)); } catch (Exception e) { LogUtil.error("batch Cache device day data error:" + e.Message); } try { DateTime curdt = DateTime.Now; //缓存采集器实时数据 CollectorRunDataService.GetInstance().batchCache(BaseMessage.collectorRunDataMap.Values); LogUtil.writeline("memcached collectorRunDataMap用时:" + (DateTime.Now.Subtract(curdt).TotalSeconds)); } catch (Exception e) { LogUtil.error("batch Cache run data error:" + e.Message); } try { DateTime curdt = DateTime.Now; //批量保存设备实时数据到缓存 DeviceRunDataService.GetInstance().BatchCache(BaseMessage.deviceRunDataMap.Values); LogUtil.writeline("memcached deviceRunDataMap用时:" + (DateTime.Now.Subtract(curdt).TotalSeconds)); } catch (Exception e) { LogUtil.error("batch Cache device run data error:" + e.Message); } try { FaultService.GetInstance().batchSave(BaseMessage.faultList); BaseMessage.faultList.Clear(); } catch (Exception e) { LogUtil.info("batch Cache fualt error:" + e.Message); } try { DateTime curdt = DateTime.Now; //将设备最大值统计数据放入缓存 DeviceDataCountService.GetInstance().batchCache(BaseMessage.deviceDataCounts); BaseMessage.deviceDataCounts.Clear(); LogUtil.writeline("memcached deviceDataCounts用时:" + (DateTime.Now.Subtract(curdt).TotalSeconds)); } catch (Exception e) { LogUtil.error("save max value error:" + e.Message); } //将本地内存数据放入缓存后,就要清理本地内存,否有内存溢出问题 //clearDayDataMap(); //每次缓存后 同时将同步到memcahced if (syndata != null && syndata.Equals("true")) { SynDataService.GetInstance().synRunData(); } }
/// <summary> /// 将数据放入缓存 /// </summary> /// <param name="tcpmessage"></param> public static void CacheData() { try { DateTime curdt = DateTime.Now; //将采集器天数据批量加入缓存 CollectorDayDataService.GetInstance().batchToCache(BaseMessage.collectordayDataMap); LogUtil.writeline("memcached collectordayDataMap用时:" + (DateTime.Now.Subtract(curdt).TotalSeconds)); } catch (Exception e) { LogUtil.error("batch Cache day data error:" + e.Message); } try { DateTime curdt = DateTime.Now; //DeviceDayDataService.GetInstance().batchToCache(BaseMessage.devicedayDataMapList); ////将设备天数据批量放入缓存 DeviceDayDataCacheHandler ddch = null; for (int i = 0; i < 50; i++) { if (cacheDayOjectMap.ContainsKey(i)) { ddch = cacheDayOjectMap[i]; } else { ddch = new DeviceDayDataCacheHandler(i); cacheDayOjectMap[i] = ddch; } Thread m_thread = new Thread(new ThreadStart(ddch.batchToCacheList)); m_thread.Name = "memcache Handel Thread-" + i; m_thread.Start(); } while (isWork()) { Thread.Sleep(1000); } LogUtil.writeline("memcached devicedayDataMap用时:" + (DateTime.Now.Subtract(curdt).TotalSeconds)); } catch (Exception e) { LogUtil.error("batch Cache device day data error:" + e.Message); } try { DateTime curdt = DateTime.Now; //缓存采集器实时数据 CollectorRunDataService.GetInstance().batchCache(BaseMessage.collectorRunDataMap.Values); LogUtil.writeline("memcached collectorRunDataMap用时:" + (DateTime.Now.Subtract(curdt).TotalSeconds)); } catch (Exception e) { LogUtil.error("batch Cache run data error:" + e.Message); } try { DateTime curdt = DateTime.Now; //批量保存设备实时数据到缓存 DeviceRunDataService.GetInstance().BatchCache(BaseMessage.deviceRunDataMap.Values); LogUtil.writeline("memcached deviceRunDataMap用时:" + (DateTime.Now.Subtract(curdt).TotalSeconds)); } catch (Exception e) { LogUtil.error("batch Cache device run data error:" + e.Message); } try { FaultService.GetInstance().batchSave(BaseMessage.faultList); BaseMessage.faultList.Clear(); } catch (Exception e) { LogUtil.info("batch Cache fualt error:" + e.Message); } try { DateTime curdt = DateTime.Now; //将设备最大值统计数据放入缓存 DeviceDataCountService.GetInstance().batchCache(BaseMessage.deviceDataCounts); BaseMessage.deviceDataCounts.Clear(); LogUtil.writeline("memcached deviceDataCounts用时:" + (DateTime.Now.Subtract(curdt).TotalSeconds)); } catch (Exception e) { LogUtil.error("save max value error:" + e.Message); } clearDayDataMap(); }