예제 #1
0
            public override IResponse RefreshFromConnection(ElasticClient cli)
            {
                var infos = cli.NodeInfo(NodesInfo.All);

                Name = infos.ClusterName;
                if (infos.Nodes != null)
                {
                    Nodes = infos.Nodes.Select(node => new NodeInfoWrap
                        {
                            GUID = node.Key,
                            Name = node.Value.Name,
                            Hostname = node.Value.Hostname,
                            VersionString = node.Value.Version,
                            Info = node.Value,
                        }).OrderBy(node => node.Name).ToList();
                }

                var stats = cli.NodeStats(NodeInfoStats.All);
                Name = stats.ClusterName;
                if (stats.Nodes != null)
                {
                    foreach (var ns in stats.Nodes)
                    {
                        var ni = Nodes.FirstOrDefault(n => n.GUID == ns.Key);
                        if (ni != null)
                        {
                            ni.Stats = ns.Value;
                        }
                        else
                        {
                            Nodes.Add(new NodeInfoWrap
                                {
                                    GUID = ns.Key,
                                    Name = ns.Value.Name,
                                    Hostname = ns.Value.Hostname,
                                    Stats = ns.Value
                                });
                        }
                    }
                    Nodes = Nodes.OrderBy(n => n.Name).ToList();
                }
                return stats;
            }