private List<InetAddress> filterForEachQuorum(Keyspace keyspace, List<InetAddress> liveEndpoints, ReadRepairDecision readRepair) { NetworkTopologyStrategy strategy = (NetworkTopologyStrategy) keyspace.getReplicationStrategy(); // quickly drop out if read repair is GLOBAL, since we just use all of the live endpoints if (readRepair == ReadRepairDecision.GLOBAL) return liveEndpoints; Map<String, List<InetAddress>> dcsEndpoints = new HashMap<>(); for (String dc: strategy.getDatacenters()) dcsEndpoints.put(dc, new ArrayList<>()); for (InetAddress add : liveEndpoints) { String dc = DatabaseDescriptor.getEndpointSnitch().getDatacenter(add); dcsEndpoints.get(dc).add(add); } List<InetAddress> waitSet = new ArrayList<>(); for (Map.Entry<String, List<InetAddress>> dcEndpoints : dcsEndpoints.entrySet()) { List<InetAddress> dcEndpoint = dcEndpoints.getValue(); if (readRepair == ReadRepairDecision.DC_LOCAL && dcEndpoints.getKey().equals(DatabaseDescriptor.getLocalDataCenter())) waitSet.addAll(dcEndpoint); else waitSet.addAll(dcEndpoint.subList(0, Math.min(localQuorumFor(keyspace, dcEndpoints.getKey()), dcEndpoint.size()))); } return waitSet; }
private List<InetAddress> filterForEachQuorum(Keyspace keyspace, List<InetAddress> liveEndpoints, ReadRepairDecision readRepair) { NetworkTopologyStrategy strategy = (NetworkTopologyStrategy) keyspace.getReplicationStrategy(); // quickly drop out if read repair is GLOBAL, since we just use all of the live endpoints if (readRepair == ReadRepairDecision.GLOBAL) return liveEndpoints; Map<String, List<InetAddress>> dcsEndpoints = new HashMap<>(); for (String dc: strategy.getDatacenters()) dcsEndpoints.put(dc, new ArrayList<>()); for (InetAddress add : liveEndpoints) { String dc = DatabaseDescriptor.getEndpointSnitch().getDatacenter(add); dcsEndpoints.get(dc).add(add); } List<InetAddress> waitSet = new ArrayList<>(); for (Map.Entry<String, List<InetAddress>> dcEndpoints : dcsEndpoints.entrySet()) { List<InetAddress> dcEndpoint = dcEndpoints.getValue(); if (readRepair == ReadRepairDecision.DC_LOCAL && dcEndpoints.getKey().equals(DatabaseDescriptor.getLocalDataCenter())) waitSet.addAll(dcEndpoint); else waitSet.addAll(dcEndpoint.subList(0, Math.min(localQuorumFor(keyspace, dcEndpoints.getKey()), dcEndpoint.size()))); } return waitSet; }
private List<InetAddress> filterForEachQuorum(Keyspace keyspace, List<InetAddress> liveEndpoints, ReadRepairDecision readRepair) { NetworkTopologyStrategy strategy = (NetworkTopologyStrategy) keyspace.getReplicationStrategy(); // quickly drop out if read repair is GLOBAL, since we just use all of the live endpoints if (readRepair == ReadRepairDecision.GLOBAL) return liveEndpoints; Map<String, List<InetAddress>> dcsEndpoints = new HashMap<>(); for (String dc: strategy.getDatacenters()) dcsEndpoints.put(dc, new ArrayList<>()); for (InetAddress add : liveEndpoints) { String dc = DatabaseDescriptor.getEndpointSnitch().getDatacenter(add); dcsEndpoints.get(dc).add(add); } List<InetAddress> waitSet = new ArrayList<>(); for (Map.Entry<String, List<InetAddress>> dcEndpoints : dcsEndpoints.entrySet()) { List<InetAddress> dcEndpoint = dcEndpoints.getValue(); if (readRepair == ReadRepairDecision.DC_LOCAL && dcEndpoints.getKey().equals(DatabaseDescriptor.getLocalDataCenter())) waitSet.addAll(dcEndpoint); else waitSet.addAll(dcEndpoint.subList(0, Math.min(localQuorumFor(keyspace, dcEndpoints.getKey()), dcEndpoint.size()))); } return waitSet; }
public boolean isSufficientLiveNodes(Keyspace keyspace, Iterable<InetAddress> liveEndpoints) { switch (this) { case ANY: // local hint is acceptable, and local node is always live return true; case LOCAL_ONE: return countLocalEndpoints(liveEndpoints) >= 1; case LOCAL_QUORUM: return countLocalEndpoints(liveEndpoints) >= blockFor(keyspace); case EACH_QUORUM: if (keyspace.getReplicationStrategy() instanceof NetworkTopologyStrategy) { for (Map.Entry<String, Integer> entry : countPerDCEndpoints(keyspace, liveEndpoints).entrySet()) { if (entry.getValue() < localQuorumFor(keyspace, entry.getKey())) return false; } return true; } // Fallthough on purpose for SimpleStrategy default: return Iterables.size(liveEndpoints) >= blockFor(keyspace); } }
public boolean isSufficientLiveNodes(Keyspace keyspace, Iterable<InetAddress> liveEndpoints) { switch (this) { case ANY: // local hint is acceptable, and local node is always live return true; case LOCAL_ONE: return countLocalEndpoints(liveEndpoints) >= 1; case LOCAL_QUORUM: return countLocalEndpoints(liveEndpoints) >= blockFor(keyspace); case EACH_QUORUM: if (keyspace.getReplicationStrategy() instanceof NetworkTopologyStrategy) { for (Map.Entry<String, Integer> entry : countPerDCEndpoints(keyspace, liveEndpoints).entrySet()) { if (entry.getValue() < localQuorumFor(keyspace, entry.getKey())) return false; } return true; } // Fallthough on purpose for SimpleStrategy default: return Iterables.size(liveEndpoints) >= blockFor(keyspace); } }
int dcBlockFor = localQuorumFor(keyspace, entry.getKey()); int dcLive = entry.getValue(); if (dcLive < dcBlockFor)
int dcBlockFor = localQuorumFor(keyspace, entry.getKey()); int dcLive = entry.getValue(); if (dcLive < dcBlockFor)
int dcBlockFor = localQuorumFor(keyspace, entry.getKey()); int dcLive = entry.getValue(); if (dcLive < dcBlockFor)
int dcBlockFor = localQuorumFor(keyspace, entry.getKey()); int dcLive = entry.getValue(); if (dcLive < dcBlockFor)
public boolean isSufficientLiveNodes(Keyspace keyspace, Iterable<InetAddress> liveEndpoints) { switch (this) { case ANY: // local hint is acceptable, and local node is always live return true; case LOCAL_ONE: return countLocalEndpoints(liveEndpoints) >= 1; case LOCAL_QUORUM: return countLocalEndpoints(liveEndpoints) >= blockFor(keyspace); case EACH_QUORUM: if (keyspace.getReplicationStrategy() instanceof NetworkTopologyStrategy) { for (Map.Entry<String, Integer> entry : countPerDCEndpoints(keyspace, liveEndpoints).entrySet()) { if (entry.getValue() < localQuorumFor(keyspace, entry.getKey())) return false; } return true; } // Fallthough on purpose for SimpleStrategy default: return Iterables.size(liveEndpoints) >= blockFor(keyspace); } }
public boolean isSufficientLiveNodes(Keyspace keyspace, Iterable<InetAddress> liveEndpoints) { switch (this) { case ANY: // local hint is acceptable, and local node is always live return true; case LOCAL_ONE: return countLocalEndpoints(liveEndpoints) >= 1; case LOCAL_QUORUM: return countLocalEndpoints(liveEndpoints) >= blockFor(keyspace); case EACH_QUORUM: if (keyspace.getReplicationStrategy() instanceof NetworkTopologyStrategy) { for (Map.Entry<String, Integer> entry : countPerDCEndpoints(keyspace, liveEndpoints).entrySet()) { if (entry.getValue() < localQuorumFor(keyspace, entry.getKey())) return false; } return true; } // Fallthough on purpose for SimpleStrategy default: return Iterables.size(liveEndpoints) >= blockFor(keyspace); } }
case LOCAL_QUORUM: case LOCAL_SERIAL: return localQuorumFor(keyspace, DatabaseDescriptor.getLocalDataCenter()); case EACH_QUORUM: if (keyspace.getReplicationStrategy() instanceof NetworkTopologyStrategy) int n = 0; for (String dc : strategy.getDatacenters()) n += localQuorumFor(keyspace, dc); return n;
case LOCAL_QUORUM: case LOCAL_SERIAL: return localQuorumFor(keyspace, DatabaseDescriptor.getLocalDataCenter()); case EACH_QUORUM: if (keyspace.getReplicationStrategy() instanceof NetworkTopologyStrategy) int n = 0; for (String dc : strategy.getDatacenters()) n += localQuorumFor(keyspace, dc); return n;
case LOCAL_QUORUM: case LOCAL_SERIAL: return localQuorumFor(keyspace, DatabaseDescriptor.getLocalDataCenter()); case EACH_QUORUM: if (keyspace.getReplicationStrategy() instanceof NetworkTopologyStrategy) int n = 0; for (String dc : strategy.getDatacenters()) n += localQuorumFor(keyspace, dc); return n;
case LOCAL_QUORUM: case LOCAL_SERIAL: return localQuorumFor(keyspace, DatabaseDescriptor.getLocalDataCenter()); case EACH_QUORUM: if (keyspace.getReplicationStrategy() instanceof NetworkTopologyStrategy) int n = 0; for (String dc : strategy.getDatacenters()) n += localQuorumFor(keyspace, dc); return n;