Exemplo n.º 1
0
            public override ElasticResponse RefreshFromConnection(SearchClient cli)
            {
                var infos = cli.GetClusterNodeInfo().Data;

                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,
                        BuildString   = node.Value.Build,
                        Attributes    = node.Value.Attributes,
                        Info          = node.Value,
                    }).OrderBy(node => node.Name).ToList();
                }

                var rawStats = cli.GetClusterNodeStats();
                var stats    = rawStats.Data;

                if (stats != null)
                {
                    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(rawStats);
            }
Exemplo n.º 2
0
            public override ElasticResponse RefreshFromConnection(SearchClient cli)
            {
                var infos = cli.GetClusterNodeInfo().Data;
                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,
                            BuildString = node.Value.Build,
                            Attributes = node.Value.Attributes,
                            Info = node.Value,
                        }).OrderBy(node => node.Name).ToList();
                }

                var rawStats = cli.GetClusterNodeStats();
                var stats = rawStats.Data;
                if (stats != null)
                {
                    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 rawStats;
            }