public TokenPartitionedTopology(Partitioner partitioner, LatencyScoreStrategy strategy) { this.strategy = strategy; this.partitioner = partitioner; this.allPools = new TokenHostConnectionPoolPartition<CL>(null, this.strategy); }
@SuppressWarnings("unchecked") @Override public int compare(Object arg0, Object arg1) { TokenHostConnectionPoolPartition<CL> partition0 = (TokenHostConnectionPoolPartition<CL>) arg0; TokenHostConnectionPoolPartition<CL> partition1 = (TokenHostConnectionPoolPartition<CL>) arg1; return partition0.id().compareTo(partition1.id()); } };
/** * list of all active pools * @return {@link List<HostConnectionPool>} */ @Override public List<HostConnectionPool<CL>> getActivePools() { return ImmutableList.copyOf(topology.getAllPools().getPools()); }
for (HostConnectionPool<CL> pool : ring) { allPools.add(pool); if (!this.allPools.hasPool(pool)) didChange = true; didChange = true; if (partition.setPools(entry.getValue())) didChange = true; List<TokenHostConnectionPoolPartition<CL>> partitions = Lists.newArrayList(tokenToPartitionMap.values()); Collections.sort(partitions, partitionComparator); this.allPools.setPools(allPools); refresh(); this.sortedRing.set(Collections.unmodifiableList(partitions));
@Override public synchronized void refresh() { allPools.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 addPool(HostConnectionPool<CL> pool) { allPools.addPool(pool); }
@SuppressWarnings("unchecked") @Override /** * Update the list of pools using the provided mapping of start token to collection of hosts * that own the token */ public synchronized boolean setPools(Collection<HostConnectionPool<CL>> ring) { boolean didChange = false; Set<HostConnectionPool<CL>> allPools = Sets.newHashSet(); // Create a mapping of end token to a list of hosts that own the token for (HostConnectionPool<CL> pool : ring) { allPools.add(pool); if (!this.allPools.hasPool(pool)) didChange = true; } return didChange; }
/** * list of all active pools * @return {@link List<HostConnectionPool>} */ @Override public List<HostConnectionPool<CL>> getActivePools() { return ImmutableList.copyOf(topology.getAllPools().getPools()); }
for (HostConnectionPool<CL> pool : ring) { allPools.add(pool); if (!this.allPools.hasPool(pool)) didChange = true; didChange = true; if (partition.setPools(entry.getValue())) didChange = true; List<TokenHostConnectionPoolPartition<CL>> partitions = Lists.newArrayList(tokenToPartitionMap.values()); Collections.sort(partitions, partitionComparator); this.allPools.setPools(allPools); refresh(); this.sortedRing.set(Collections.unmodifiableList(partitions));
@Override public synchronized void refresh() { allPools.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 addPool(HostConnectionPool<CL> pool) { allPools.addPool(pool); }
@SuppressWarnings("unchecked") @Override /** * Update the list of pools using the provided mapping of start token to collection of hosts * that own the token */ public synchronized boolean setPools(Collection<HostConnectionPool<CL>> ring) { boolean didChange = false; Set<HostConnectionPool<CL>> allPools = Sets.newHashSet(); // Create a mapping of end token to a list of hosts that own the token for (HostConnectionPool<CL> pool : ring) { allPools.add(pool); if (!this.allPools.hasPool(pool)) didChange = true; } return didChange; }
@Override public String apply(TokenHostConnectionPoolPartition<CL> input) { return input.id().toString() + "\n"; } }), ","));
public BagExecuteWithFailover(ConnectionPoolConfiguration config) throws ConnectionException { super(config, monitor); size = topology.getAllPools().getPools().size(); retryCountdown = Math.min(config.getMaxFailoverCount(), size); if (retryCountdown < 0) retryCountdown = size; }