private void InnerSendNotify(CacheNotifyData[] notifyDataArray) { if (CacheNotifierSettings.GetConfig().EnableMmfNotifier) { Logger logger = null; try { logger = LoggerFactory.Create("MmfCache"); } catch (SystemSupportException) { } CacheNotifyDataMap.WriteCacheNotifyData(notifyDataArray); if (logger != null) { foreach (CacheNotifyData notifyData in notifyDataArray) { logger.Write(CreateLogEntity(notifyData)); } } } }
/// <summary> /// 获取数据 /// </summary> /// <returns></returns> public override CacheNotifyData[] GetData() { CacheNotifyData[] result = MemoryMappedFileCacheNotifyFetcher.NullNotifyData; if (CacheNotifierSettings.GetConfig().EnableMmfNotifier) { result = CacheNotifyDataMap.ReadCacheNotifyData(ref this.lastTicks); UdpCacheNotifier.TotalCounters.MmfReceivedItemsCounter.IncrementBy(result.Length); UdpCacheNotifier.TotalCounters.MmfReceivedCountPerSecond.IncrementBy(result.Length); UdpCacheNotifier.AppInstanceCounters.MmfReceivedItemsCounter.IncrementBy(result.Length); UdpCacheNotifier.AppInstanceCounters.MmfReceivedCountPerSecond.IncrementBy(result.Length); } return(result); }
/// <summary> /// 获取数据 /// </summary> /// <returns></returns> public override CacheNotifyData[] GetData() { CacheNotifyData[] result = CacheNotifyData.EmptyData; try { byte[] recBuffer = udp.Receive(ref bindedEndPoint); CacheNotifyData data = CacheNotifyData.FromBuffer(recBuffer); result = new CacheNotifyData[] { data }; UdpCacheNotifier.TotalCounters.UdpReceivedItemsCounter.Increment(); UdpCacheNotifier.TotalCounters.UdpReceivedCountPerSecond.Increment(); UdpCacheNotifier.AppInstanceCounters.UdpReceivedItemsCounter.Increment(); UdpCacheNotifier.AppInstanceCounters.UdpReceivedCountPerSecond.Increment(); CacheNotifierSettings settings = CacheNotifierSettings.GetConfig(); if (settings.ForwardUdpToMmf && settings.EnableMmfNotifier) { CacheNotifyDataMap.WriteNotExistCacheNotifyData(DateTime.Now.Ticks, result); UdpCacheNotifier.TotalCounters.ForwardedUdpToMmfItems.Increment(); UdpCacheNotifier.TotalCounters.ForwardUdpToMmfCountPerSecond.Increment(); UdpCacheNotifier.AppInstanceCounters.ForwardedUdpToMmfItems.Increment(); UdpCacheNotifier.AppInstanceCounters.ForwardUdpToMmfCountPerSecond.Increment(); } } catch (SocketException ex) { if (ex.SocketErrorCode != SocketError.TimedOut) { throw; } } return(result); }