mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Corrected cassandra example's indent.
This commit is contained in:
parent
b930d58fcb
commit
59bab9bde4
@ -65,12 +65,10 @@ public class KubernetesSeedProvider implements SeedProvider {
|
||||
*/
|
||||
private List<InetAddress> defaultSeeds;
|
||||
|
||||
|
||||
private TrustManager[] trustAll;
|
||||
|
||||
private HostnameVerifier trustAllHosts;
|
||||
|
||||
|
||||
/**
|
||||
* Create new Seeds
|
||||
* @param params
|
||||
@ -80,23 +78,22 @@ public class KubernetesSeedProvider implements SeedProvider {
|
||||
// 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; }
|
||||
}
|
||||
};
|
||||
// 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;
|
||||
}
|
||||
};
|
||||
trustAllHosts = new HostnameVerifier() {
|
||||
public boolean verify(String hostname, SSLSession session) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Call kubernetes API to collect a list of seed providers
|
||||
* @return list of seed providers
|
||||
@ -133,14 +130,10 @@ public class KubernetesSeedProvider implements SeedProvider {
|
||||
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));
|
||||
|
||||
@ -151,29 +144,22 @@ public class KubernetesSeedProvider implements SeedProvider {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
@ -187,24 +173,19 @@ public class KubernetesSeedProvider implements SeedProvider {
|
||||
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);
|
||||
}
|
||||
@ -269,6 +250,4 @@ public class KubernetesSeedProvider implements SeedProvider {
|
||||
static class Endpoints {
|
||||
public List<Subset> subsets;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user