/// <summary> /// Gets a cluster object with the name /// </summary> /// <param name="clusterName">The name of the cluster</param> public static ClusterElement GetCluster(string clusterName) { List <string> fieldList = new List <string>(); ClusterElementCollection clusterConfigs = ESSection.Clusters; if (clusterConfigs == null) { throw new ConfigurationErrorsException("ElasticSearch cluster configuration cannot be found"); } ClusterElement requestedCluster = null; //Find the cluster foreach (ClusterElement cluster in clusterConfigs) { if (cluster.Name == clusterName) { requestedCluster = cluster; break; } } if (requestedCluster == null) { throw new ConfigurationErrorsException("ElasticSearch cluster, " + clusterName + ", cannot be found in configuration."); } return(requestedCluster); }
/// <summary> /// Gets all the nodes in a given cluster for a given search collection /// </summary> /// <param name="clusterName">The name of the cluster</param> public static Uri[] GetClusterNodes(string clusterName) { List <Uri> listOfNodes = new List <Uri>(); ClusterElementCollection clusterConfigs = ESSection.Clusters; if (clusterConfigs == null) { throw new ConfigurationErrorsException("ElasticSearch cluster configuration cannot be found"); } ClusterElement requestedCluster = null; //Find the cluster foreach (ClusterElement cluster in clusterConfigs) { if (cluster.Name == clusterName) { requestedCluster = cluster; break; } } if (requestedCluster == null) { throw new ConfigurationErrorsException("ElasticSearch cluster, " + clusterName + ", cannot be found in configuration."); } foreach (NodeElement node in requestedCluster.Nodes) { listOfNodes.Add(new Uri(node.NodeIP + ":" + node.Port)); } return(listOfNodes.ToArray()); }