Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions driver-core/src/main/java/com/datastax/driver/core/Cluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,38 @@ public Builder addContactPoints(String... addresses) {
return this;
}

/**
* Adds a contact point - or many if it host resolves to multiple <code>InetAddress</code>s (A records).
* <p>
*
* If the host name points to a dns records with multiple a-records, all InetAddresses
* returned will be used. Make sure that all resulting <code>InetAddress</code>s returned
* points to the same cluster and datacenter.
* <p>
* See {@link Builder#addContactPoint} for more details on contact
* points and thrown exceptions
*
* @param address address of the nodes to look up InetAddresses from to add as contact points.
* @return this Builder.
*
*
* @see Builder#addContactPoint
*/
public Builder addContactPoints(String address) {
// We explicitely check for nulls because InetAdress.getByName() will happily
// accept it and use localhost (while a null here almost likely mean a user error,
// not "connect to localhost")
if (address == null)
throw new NullPointerException();

try {
addContactPoints(InetAddress.getAllByName(address));
} catch (UnknownHostException e) {
throw new IllegalArgumentException(e.getMessage());
}
return this;
}

/**
* Adds contact points.
* <p>
Expand Down