internal static IEnumerable <PackedObject> LoadObjects(IDataClient @this, string jsonPath, [NotNull] string collectionName) { if (collectionName == null) { throw new ArgumentNullException(nameof(collectionName)); } var json = File.ReadAllText(jsonPath); var array = JArray.Parse(json); var info = @this.GetClusterInformation(); var schemaByName = info.Schema.ToDictionary(td => td.CollectionName.ToLower()); if (!schemaByName.ContainsKey(collectionName.ToLower())) { throw new CacheException($"Collection {collectionName} not found"); } CollectionSchema collectionSchema = schemaByName[collectionName]; foreach (var item in array.Children <JObject>()) { var cachedObject = PackedObject.PackJson(item.ToString(), collectionSchema); yield return(cachedObject); } }
internal override IDataClient TryExecute(IDataClient client) { if (!CanExecute) { return(null); } Dbg.CheckThat(Params.Count <= 1); try { Profiler.IsActive = true; Profiler.Start("DESC"); var serverInfo = client.GetClusterInformation(); Profiler.End(); if (Params.Count == 1) { var tableName = Params[0]; foreach (var typeDescription in serverInfo.Schema) { if (tableName.ToUpper() == typeDescription.CollectionName.ToUpper()) { LogTypeInfo(typeDescription); break; } } } else { foreach (var info in serverInfo.ServersStatus) { Logger.Write(""); Logger.Write("Server process"); Logger.Write("------------------------------------------------------------------"); //Logger.Write(" server name = {0}", serverInfo.ServerProcessInfo.Host); Logger.Write(" image type = {0} bits", info.Bits); Logger.Write(" started at = {0}", info.StartTime); Logger.Write(" active clients = {0}", info.ConnectedClients); Logger.Write(" threads = {0}", info.Threads); Logger.Write(" physical memory = {0} MB", info.WorkingSet / 1000000); Logger.Write(" virtual memory = {0} MB", info.VirtualMemory / 1000000); Logger.Write("software version = {0} ", info.SoftwareVersion); Logger.Write(""); } Logger.Write("Tables"); var header = $"| {"Name",35} | {"Zip",5} |"; var line = new string('-', header.Length); Logger.Write(line); Logger.Write(header); Logger.Write(line); foreach (var typeDescription in serverInfo.Schema) { var compression = typeDescription.UseCompression.ToString(); Logger.Write("| {0,35} | {1,5} |", typeDescription.CollectionName, compression ); } Logger.Write(line); } Logger.Write("The call took {0} milliseconds", Profiler.TotalTimeMilliseconds); } catch (Exception ex) { Profiler.End(); Logger.WriteEror("Can not execute DESC : {0}", ex.Message); return(null); } return(client); }
public ClusterInformation GetClusterDescription() { return(Client.GetClusterInformation()); }