Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package me.prettyprint.cassandra.connection;
 
 import java.util.List;
 import java.util.Set;
public class LeastActiveBalancingPolicy implements LoadBalancingPolicy {
    List<ConcurrentHClientPoolvals = new ArrayList<ConcurrentHClientPool>(pools); 
      Collections.sort(valsnew Comparator<ConcurrentHClientPool>() {      
        public int compare(ConcurrentHClientPool o1ConcurrentHClientPool o2) {
          if ( o1.getNumActive() < o2.getNumActive() ) {
            return -1;
          } else if ( o1.getNumActive() > o2.getNumActive() ) {
            return 1;
          }
          return 0;
      }            
    });
    Iterator<ConcurrentHClientPooliterator = vals.iterator();
    ConcurrentHClientPool concurrentHClientPool = iterator.next();
    if ( excludeHosts != null && excludeHosts.size() > 0 ) {          
      while (iterator.hasNext()) {
        concurrentHClientPool = (ConcurrentHClientPooliterator.next();
        if ( !excludeHosts.contains(concurrentHClientPool.getCassandraHost()) ) {
          break;
        }
      }
    }
    return concurrentHClientPool;
  }
New to GrepCode? Check out our FAQ X