public boolean addIfNotNull(V e) { if (e!=null) return add(e); return false; }
public Builder<V> addAll(Iterable<? extends V> iterable) { if (iterable instanceof Collection) { result.addAll((Collection<? extends V>) iterable); } else { for (V v : iterable) { result.add(v); } } return this; }
/** @deprecated since 0.6.0 ambiguous with {@link #addAll(Iterable)}; * use {@link #add(Object, Object, Object...)} */ public Builder<V> addAll(V... values) { for (V v : values) { result.add(v); } return this; }
public Builder<V> add(V value) { result.add(value); return this; }
public static <V> MutableSet<V> of(V v1) { MutableSet<V> result = new MutableSet<V>(); result.add(v1); return result; }
@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; }