public ClusterInformation GetClusterInformation() { var responses = new ServerDescriptionResponse[CacheClients.Count]; try { Parallel.For(0, CacheClients.Count, i => { var server = CacheClients[i].GetServerDescription(); responses[i] = server; }); } catch (AggregateException e) { if (e.InnerException != null) { if (e.InnerException is CacheException ex) { throw ex; } } } // check that all schemas are identical var reference = responses[0]; for (var i = 1; i < CacheClients.Count; i++) { foreach (var typeDescription in reference.KnownTypesByFullName) { if (!responses[i].KnownTypesByFullName[typeDescription.Key].Equals(typeDescription.Value)) { throw new CacheException( $"servers have different schemas: {responses[0].ServerProcessInfo.Host} <> {responses[i].ServerProcessInfo.Host} "); } } } return(new ClusterInformation(responses)); }
public CommandLineParser(ServerDescriptionResponse desc) { _knownTypes = desc?.KnownTypesByFullName; }
private void GetKnownTypes(IClient client) { try { var response = new ServerDescriptionResponse(); var stores = DataStores.Values; foreach (var store in stores) { response.AddTypeDescription(store.CollectionSchema); var info = new DataStoreInfo { Count = store.DataByPrimaryKey.Count, EvictionPolicy = store.EvictionType, EvictionPolicyDescription = store.EvictionPolicy.ToString(), FullTypeName = store.CollectionSchema.CollectionName, AvailableData = store.DomainDescription ?? new DomainDescription(null), DataCompression = store.CollectionSchema.UseCompression, HitCount = store.HitCount, ReadCount = store.ReadCount }; response.AddDataStoreInfo(info); } // add the special @ACTIVITY table (it may not be initialized in test environments) if (_serviceContainer.Log != null) { var activityInfo = new DataStoreInfo { FullTypeName = LogEntry.Table, Count = _serviceContainer.Log.ActivityTable.DataByPrimaryKey.Count }; response.AddDataStoreInfo(activityInfo); response.AddTypeDescription(_serviceContainer.Log.ActivityTable.CollectionSchema); } var currentProcess = Process.GetCurrentProcess(); var assembly = Assembly.GetAssembly(typeof(Server)); response.ServerProcessInfo = new ServerInfo { ConnectedClients = (int)ActiveConnections, StartTime = StartTime, Bits = IntPtr.Size * 8, Threads = currentProcess.Threads.Count, WorkingSet = currentProcess.WorkingSet64, VirtualMemory = currentProcess.VirtualMemorySize64, SoftwareVersion = assembly != null ? assembly.GetName().Version.ToString() : "" }; client.SendResponse(response); } catch (Exception ex) { client.SendResponse(new ExceptionResponse(ex)); } }