Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrected cassandra example's indent. #23909

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,10 @@ public class KubernetesSeedProvider implements SeedProvider {
*/
private List<InetAddress> defaultSeeds;


private TrustManager[] trustAll;

private HostnameVerifier trustAllHosts;


/**
* Create new Seeds
* @param params
Expand All @@ -80,22 +78,21 @@ public KubernetesSeedProvider(Map<String, String> params) {
// Create default seeds
defaultSeeds = createDefaultSeeds();

// TODO: Load the CA cert when it is available on all platforms.
trustAll = new TrustManager[] {
new X509TrustManager() {
public void checkServerTrusted(X509Certificate[] certs, String authType) {}
public void checkClientTrusted(X509Certificate[] certs, String authType) {}
public X509Certificate[] getAcceptedIssuers() { return null; }
}
};

trustAllHosts = new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
}
};
}
// TODO: Load the CA cert when it is available on all platforms.
trustAll = new TrustManager[] {
new X509TrustManager() {
public void checkServerTrusted(X509Certificate[] certs, String authType) {}
public void checkClientTrusted(X509Certificate[] certs, String authType) {}
public X509Certificate[] getAcceptedIssuers() { return null; }
}
};

trustAllHosts = new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
}
};
}

/**
* Call kubernetes API to collect a list of seed providers
Expand Down Expand Up @@ -133,14 +130,10 @@ public List<InetAddress> getSeeds() {
Endpoints endpoints = mapper.readValue(conn.getInputStream(), Endpoints.class);

if (endpoints != null) {

// Here is a problem point, endpoints.subsets can be null in first node cases.

if (endpoints.subsets != null && !endpoints.subsets.isEmpty()){

for (Subset subset : endpoints.subsets) {
if (subset.addresses != null && !subset.addresses.isEmpty()) {

for (Address address : subset.addresses) {
seeds.add(InetAddress.getByName(address.ip));

Expand All @@ -151,29 +144,22 @@ public List<InetAddress> getSeeds() {
}
}
}

}

logger.info("Available num endpoints: " + seeds.size());

logger.info("Available num endpoints: " + seeds.size());
} else {

logger.warn("Endpoints are not available using default seeds in cassandra.yaml");
logger.warn("Endpoints are not available using default seeds in cassandra.yaml");
return Collections.unmodifiableList(defaultSeeds);

}
}
} catch (IOException | NoSuchAlgorithmException | KeyManagementException ex) {
logger.warn("Request to kubernetes apiserver failed, using default seeds in cassandra.yaml", ex);
logger.warn("Request to kubernetes apiserver failed, using default seeds in cassandra.yaml", ex);
return Collections.unmodifiableList(defaultSeeds);
}

if (seeds.size() == 0) {

// If we got nothing, we might be the first instance, in that case
// fall back on the seeds that were passed in cassandra.yaml.
// If we got nothing, we might be the first instance, in that case
// fall back on the seeds that were passed in cassandra.yaml.
logger.warn("Seeds are not available using default seeds in cassandra.yaml");
return Collections.unmodifiableList(defaultSeeds);

}

return Collections.unmodifiableList(seeds);
Expand All @@ -187,24 +173,19 @@ public List<InetAddress> getSeeds() {
protected List<InetAddress> createDefaultSeeds()
{
Config conf;
try
{
try {
conf = loadConfig();
}
catch (Exception e)
{
catch (Exception e) {
throw new AssertionError(e);
}
String[] hosts = conf.seed_provider.parameters.get("seeds").split(",", -1);
List<InetAddress> seeds = new ArrayList<InetAddress>();
for (String host : hosts)
{
try
{
for (String host : hosts) {
try {
seeds.add(InetAddress.getByName(host.trim()));
}
catch (UnknownHostException ex)
{
catch (UnknownHostException ex) {
// not fatal... DD will bark if there end up being zero seeds.
logger.warn("Seed provider couldn't lookup host {}", host);
}
Expand Down Expand Up @@ -269,6 +250,4 @@ static class Subset {
static class Endpoints {
public List<Subset> subsets;
}


}