/// <summary> /// Add node(s) referenced by seed host aliases. In most cases, aliases reference /// a single node. If round robin DNS configuration is used, the seed host may have /// several aliases that reference different nodes in the cluster. /// </summary> public void SeedNodes(Cluster cluster, Host host, List <Node> list) { IPAddress[] addresses = SetAliases(cluster, host); Exception exception = null; bool found = false; foreach (IPAddress address in addresses) { try { ValidateAlias(cluster, address, host.port); found = true; if (!FindNodeName(list, name)) { // New node found. Node node = cluster.CreateNode(this); cluster.AddAliases(node); list.Add(node); } else { // Node already referenced. Close connection. conn.Close(); } } catch (Exception e) { // Log and continue to next address. if (Log.DebugEnabled()) { Log.Debug("Alias " + address + " failed: " + Util.GetErrorMessage(e)); } if (exception == null) { exception = e; } } } if (!found) { // Exception can't be null here because SetAliases()/Connection.GetHostAddresses() // will throw exception if aliases length is zero. throw exception; } }
/// <summary> /// Add node(s) referenced by seed host aliases. In most cases, aliases reference /// a single node. If round robin DNS configuration is used, the seed host may have /// several aliases that reference different nodes in the cluster. /// </summary> public void SeedNodes(Cluster cluster, Host host, List<Node> list) { IPAddress[] addresses = SetAliases(cluster, host); Exception exception = null; bool found = false; foreach (IPAddress address in addresses) { try { ValidateAlias(cluster, address, host.port); found = true; if (!FindNodeName(list, name)) { // New node found. Node node = cluster.CreateNode(this); cluster.AddAliases(node); list.Add(node); } else { // Node already referenced. Close connection. conn.Close(); } } catch (Exception e) { // Log and continue to next address. if (Log.DebugEnabled()) { Log.Debug("Alias " + address + " failed: " + Util.GetErrorMessage(e)); } if (exception == null) { exception = e; } } } if (!found) { // Exception can't be null here because SetAliases()/Connection.GetHostAddresses() // will throw exception if aliases length is zero. throw exception; } }