private void UpdateGridDataSource() { lock (dataList) { if ((tvNodes.Items.Count == 0) || (tvNodes.SelectedValue == null)) { ClearGrid(); return; } Func <Node, bool> nodeFinder = (x => x.EndPoint.ToString().CompareTo(tvNodes.SelectedValue) == 0); Node node = _nodeTracker.ActiveNodes.First <Node>(nodeFinder); if (node == null) { return; } dataList.Clear(); //for this node, get the active data from the node string endPoint = string.Format("net.tcp://{0}:{1}/HoCCacheService", node.EndPoint.ToString(), node.ServicePort); CacheService.CacheServiceClient nodeService = new CacheService.CacheServiceClient(new NetTcpBinding(SecurityMode.None), new EndpointAddress(endPoint)); try { nodeService.Open(); CacheHealth cacheHealth = nodeService.GetCacheHealth(); dataList.Add(new KeyValuePair <string, string>("Machine Name", cacheHealth.MachineName)); dataList.Add(new KeyValuePair <string, string>("Host", tvNodes.SelectedValue.ToString())); dataList.Add(new KeyValuePair <string, string>("Heartbeat Heard at", node.HeartBeatLastHeardAt.ToLongTimeString())); dataList.Add(new KeyValuePair <string, string>("Service Port", node.ServicePort.ToString())); dataList.Add(new KeyValuePair <string, string>("Node State", node.NodeState.ToString())); dataList.Add(new KeyValuePair <string, string>("Object Count", cacheHealth.ObjectCount.ToString())); dataList.Add(new KeyValuePair <string, string>("Object(s) Size", cacheHealth.TotalObjectSize.ToString() + "Bytes")); dataList.Add(new KeyValuePair <string, string>("Process Working Set", cacheHealth.ProcessWorkingSet.ToString() + "K")); dataList.Add(new KeyValuePair <string, string>("Eviction Strategy", cacheHealth.EvictionStrategy)); if (cacheHealth.EvictionLastAt == DateTime.MinValue) { dataList.Add(new KeyValuePair <string, string>("Last Eviction Time", "never")); } else { dataList.Add(new KeyValuePair <string, string>("Last Eviction Time", cacheHealth.EvictionLastAt.ToLongTimeString())); } UpdateStatusMessage("Updated status for " + tvNodes.SelectedValue.ToString()); } catch (Exception E) { UpdateStatusMessage("Error when connecting to " + tvNodes.SelectedValue.ToString()); } } }
public CacheHealth GetCacheHealth() { long objectSize = (from cacheItem in _localCache select cacheItem.Value.Value.Value.LongLength).Sum(); CacheHealth cacheHealth = new CacheHealth() { ObjectCount = _localCache.Count, TotalObjectSize = objectSize, EvictionStrategy = _evictor.EvictionClass, ProcessWorkingSet = _workingSetCounter.RawValue / 1024, EvictionLastAt = _evictor.LastRunTime, MachineName = Environment.MachineName }; return(cacheHealth); }