@Override public boolean containsValue(Object value) { for (Set<V> set : map.values()) { if(set.contains(value)) { return true; } } return false; }
/** * @return {@link List<HostConnectionPool>} */ @Override public List<HostConnectionPool<CL>> getPools() { return ImmutableList.copyOf(hosts.values()); }
/** * @return {@link List<HostConnectionPool>} */ @Override public List<HostConnectionPool<CL>> getPools() { return ImmutableList.copyOf(hosts.values()); }
/** Returns <tt>true</tt> if this Map maps one or more keys to the specified * value. <em>Note</em>: This method requires a full internal traversal of the * hash table and is much slower than {@link #containsKey}. * @param val value whose presence in this map is to be tested * @return <tt>true</tt> if this map maps one or more keys to the specified value * @throws NullPointerException if the specified value is null */ @Override public boolean containsValue( final Object val ) { if( val == null ) throw new NullPointerException(); for( TypeV V : values() ) if( V == val || V.equals(val) ) return true; return false; }
/** Returns <tt>true</tt> if this Map maps one or more keys to the specified * value. <em>Note</em>: This method requires a full internal traversal of the * hash table and is much slower than {@link #containsKey}. * @param val value whose presence in this map is to be tested * @return <tt>true</tt> if this map maps one or more keys to the specified value * @throws NullPointerException if the specified value is null */ @Override public boolean containsValue( final Object val ) { if( val == null ) throw new NullPointerException(); for( TypeV V : values() ) if( V == val || V.equals(val) ) return true; return false; }
/** Returns <tt>true</tt> if this Map maps one or more keys to the specified * value. <em>Note</em>: This method requires a full internal traversal of the * hash table and is much slower than {@link #containsKey}. * @param val value whose presence in this map is to be tested * @return <tt>true</tt> if this map maps one or more keys to the specified value * @throws NullPointerException if the specified value is null */ @Override public boolean containsValue( final Object val ) { if( val == null ) throw new NullPointerException(); for( TypeV V : values() ) if( V == val || V.equals(val) ) return true; return false; }
/** * Returns <tt>true</tt> if this Map maps one or more keys to the specified value. <em>Note</em>: This method requires * a full internal traversal of the hash table and is much slower than {@link #containsKey}. * * @param val value whose presence in this map is to be tested * @return <tt>true</tt> if this map maps one or more keys to the specified value * @throws NullPointerException if the specified value is null */ @Override public boolean containsValue(final Object val) { if (val == null) throw new NullPointerException(); for (TypeV V : values()) if (V == val || V.equals(val)) return true; return false; }
@Override public synchronized void refresh() { allPools.refresh(); for (TokenHostConnectionPoolPartition<CL> partition : tokenToPartitionMap.values()) { partition.refresh(); } }
@Override public synchronized void refresh() { allPools.refresh(); for (TokenHostConnectionPoolPartition<CL> partition : tokenToPartitionMap.values()) { partition.refresh(); } }
@Override public synchronized void removePool(HostConnectionPool<CL> pool) { allPools.removePool(pool); for (TokenHostConnectionPoolPartition<CL> partition : tokenToPartitionMap.values()) { partition.removePool(pool); } }
@Override public synchronized void removePool(HostConnectionPool<CL> pool) { allPools.removePool(pool); for (TokenHostConnectionPoolPartition<CL> partition : tokenToPartitionMap.values()) { partition.removePool(pool); } }
List<TokenHostConnectionPoolPartition<CL>> partitions = Lists.newArrayList(tokenToPartitionMap.values()); Collections.sort(partitions, partitionComparator); this.allPools.setPools(allPools);
List<TokenHostConnectionPoolPartition<CL>> partitions = Lists.newArrayList(tokenToPartitionMap.values()); Collections.sort(partitions, partitionComparator); this.allPools.setPools(allPools);
/** * @param ring */ @Override public synchronized void setHosts(Collection<Host> ring) { // Temporary list of hosts to remove. Any host not in the new ring will // be removed Set<Host> hostsToRemove = Sets.newHashSet(hosts.keySet()); // Add new hosts. boolean changed = false; for (Host host : ring) { if (addHost(host, false)) changed = true; hostsToRemove.remove(host); } // Remove any hosts that are no longer in the ring for (Host host : hostsToRemove) { removeHost(host, false); changed = true; } if (changed) { topology.setPools(hosts.values()); rebuildPartitions(); } }
/** * @param ring */ @Override public synchronized void setHosts(Collection<Host> ring) { // Temporary list of hosts to remove. Any host not in the new ring will // be removed Set<Host> hostsToRemove = Sets.newHashSet(hosts.keySet()); // Add new hosts. boolean changed = false; for (Host host : ring) { if (addHost(host, false)) changed = true; hostsToRemove.remove(host); } // Remove any hosts that are no longer in the ring for (Host host : hostsToRemove) { removeHost(host, false); changed = true; } if (changed) { topology.setPools(hosts.values()); rebuildPartitions(); } }