public static <V> MutableSet<V> of(V v1, V v2) { MutableSet<V> result = new MutableSet<V>(); result.add(v1); result.add(v2); return result; }
public EqualToAny(Iterable<? extends T> vals) { this.vals = MutableSet.copyOf(vals); // so allows nulls } @Override
@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; }
@Override protected Object createCollection(Class type) { return new MutableSet<Object>(); } }
public boolean addIfNotNull(V e) { if (e!=null) return add(e); return false; }
@Override public Set<Class<?>> getAdditionalInterfaces() { return Collections.unmodifiableSet(MutableSet.<Class<?>>builder() .addAll(super.getAdditionalInterfaces()) .addAll(delegate.getAdditionalInterfaces()) .build()); }
/** 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; }
/** @deprecated since 0.6.0 ambiguous with {@link #removeAll(Iterable)}; * use <code>removeAll(Arrays.asList(Object, Object, Object...))</code> */ public Builder<V> removeAll(V... values) { for (V v : values) { result.remove(v); } return this; }
public MutableSet<V> build() { return new MutableSet<V>(result); } }
Set<String> result = MutableSet.<String> builder(). addAll(getJmxJavaConfigOptions()). addAll(getCustomJavaConfigOptions()).
DependentConfiguration.attributeWhenReady(entity.getParent(), CassandraCluster.CURRENT_SEEDS)); } else { entity.setConfig(CassandraNode.INITIAL_SEEDS, MutableSet.<Entity>of(entity));
public Builder<V> remove(V val) { result.remove(val); return this; }
public static <V> MutableSet<V> of(V v1, V v2, V v3, V ...vMore) { MutableSet<V> result = new MutableSet<V>(); result.add(v1); result.add(v2); result.add(v3); for (V vi: vMore) result.add(vi); return result; }
public static <V> MutableSet<V> of() { return new MutableSet<V>(); }
/** @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; }
@SuppressWarnings("unchecked") public <T extends Entity> T createEntityProxy(EntitySpec<T> spec, T entity) { // TODO Don't want the proxy to have to implement EntityLocal, but required by how // AbstractEntity.parent is used (e.g. parent.getAllConfig) ClassLoader classloader = (spec.getImplementation() != null ? spec.getImplementation() : spec.getType()).getClassLoader(); MutableSet.Builder<Class<?>> builder = MutableSet.<Class<?>>builder() .add(EntityProxy.class, Entity.class, EntityLocal.class, EntityInternal.class); if (spec.getType().isInterface()) { builder.add(spec.getType()); } else { log.warn("EntitySpec declared in terms of concrete type "+spec.getType()+"; should be supplied in terms of interface"); } builder.addAll(spec.getAdditionalInterfaces()); Set<Class<?>> interfaces = builder.build(); return (T) java.lang.reflect.Proxy.newProxyInstance( classloader, interfaces.toArray(new Class[interfaces.size()]), new EntityProxyImpl(entity)); }
if (targetEntityProvider instanceof DynamicGroup) ((DynamicGroup) targetEntityProvider).rescanEntities(); Set<Entity> pool = MutableSet.copyOf(targetEntityProvider instanceof Group ? ((Group)targetEntityProvider).getMembers(): targetEntityProvider.getChildren()); if (log.isDebugEnabled()) log.debug("GeoDns {} refreshing targets, pool now {}", this, pool); Set<Entity> previousOnes = MutableSet.copyOf(targetHosts.keySet()); for (Entity e: pool) { previousOnes.remove(e);