in software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeImpl.java [141:180]
protected void setCloudPreferredSensorNames() {
if (detectedCloudSensors.get()) return;
synchronized (detectedCloudSensors) {
if (detectedCloudSensors.get()) return;
MachineProvisioningLocation<?> loc = getProvisioningLocation();
if (loc != null) {
try {
Method method = loc.getClass().getMethod("getProvider");
method.setAccessible(true);
String provider = (String) method.invoke(loc);
String result = "(nothing special)";
if (provider!=null) {
if (provider.contains("rackspace") || provider.contains("cloudservers") || provider.contains("softlayer")) {
/* These clouds have 2 NICs and it has to be consistent, so use public IP here to allow external access;
* (TODO internal access could be configured to improve performance / lower cost,
* if we know all nodes are visible to each other) */
if (getConfig(LISTEN_ADDRESS_SENSOR)==null)
config().set(LISTEN_ADDRESS_SENSOR, CassandraNode.ADDRESS.getName());
if (getConfig(BROADCAST_ADDRESS_SENSOR)==null)
config().set(BROADCAST_ADDRESS_SENSOR, CassandraNode.ADDRESS.getName());
result = "public IP for both listen and broadcast";
} else if (provider.contains("google-compute")) {
/* Google nodes cannot reach themselves/each-other on the public IP,
* and there is no hostname, so use private IP here */
if (getConfig(LISTEN_ADDRESS_SENSOR)==null)
config().set(LISTEN_ADDRESS_SENSOR, CassandraNode.SUBNET_HOSTNAME.getName());
if (getConfig(BROADCAST_ADDRESS_SENSOR)==null)
config().set(BROADCAST_ADDRESS_SENSOR, CassandraNode.SUBNET_HOSTNAME.getName());
result = "private IP for both listen and broadcast";
}
}
log.debug("Cassandra NICs inferred {} for {}; using location {}, based on provider {}", new Object[] {result, this, loc, provider});
} catch (Exception e) {
log.debug("Cassandra NICs auto-detection failed for {} in location {}: {}", new Object[] {this, loc, e});
}
}
detectedCloudSensors.set(true);
}
}