/** returns the ports that this entity wants to use; * default implementation returns 22 plus first value for each PortAttributeSensorAndConfigKey config key PortRange. */ protected Collection<Integer> getRequiredOpenPorts() { Set<Integer> ports = MutableSet.of(22); for (ConfigKey k: getEntityType().getConfigKeys()) { if (PortRange.class.isAssignableFrom(k.getType())) { PortRange p = (PortRange)getConfig(k); if (p != null && !p.isEmpty()) ports.add(p.iterator().next()); } } log.debug("getRequiredOpenPorts detected default {} for {}", ports, this); return ports; }
@Override public String getSeeds() { Set<Entity> seeds = getConfig(CassandraNode.INITIAL_SEEDS); if (seeds==null) { log.warn("No seeds available when requested for "+this, new Throwable("source of no Cassandra seeds when requested")); return null; } String snitchName = getConfig(CassandraNode.ENDPOINT_SNITCH_NAME); MutableSet<String> seedsHostnames = MutableSet.of(); for (Entity entity : seeds) { // tried removing ourselves if there are other nodes, but that is a BAD idea! // blows up with a "java.lang.RuntimeException: No other nodes seen!" if (snitchName.equals("Ec2MultiRegionSnitch") || snitchName.contains("MultiCloudSnitch")) { // http://www.datastax.com/documentation/cassandra/2.0/mobile/cassandra/architecture/architectureSnitchEC2MultiRegion_c.html // says the seeds should be public IPs. seedsHostnames.add(entity.getAttribute(CassandraNode.ADDRESS)); } else if (requiresAlwaysPublicIp()) { seedsHostnames.add(entity.getAttribute(CassandraNode.HOSTNAME)); } else { String seedHostname = Machines.findSubnetOrPublicHostname(entity).get(); seedsHostnames.add(seedHostname); } } String result = Strings.join(seedsHostnames, ","); log.info("Seeds for {}: {}", this, result); return result; }
DependentConfiguration.attributeWhenReady(entity.getParent(), CassandraCluster.CURRENT_SEEDS)); } else { entity.setConfig(CassandraNode.INITIAL_SEEDS, MutableSet.<Entity>of(entity));