private Map<String, Integer> countPerDCEndpoints(Keyspace keyspace, Iterable<InetAddress> liveEndpoints) { NetworkTopologyStrategy strategy = (NetworkTopologyStrategy) keyspace.getReplicationStrategy(); Map<String, Integer> dcEndpoints = new HashMap<String, Integer>(); for (String dc: strategy.getDatacenters()) dcEndpoints.put(dc, 0); for (InetAddress endpoint : liveEndpoints) { String dc = DatabaseDescriptor.getEndpointSnitch().getDatacenter(endpoint); dcEndpoints.put(dc, dcEndpoints.get(dc) + 1); } return dcEndpoints; }
private Map<String, Integer> countPerDCEndpoints(Keyspace keyspace, Iterable<InetAddress> liveEndpoints) { NetworkTopologyStrategy strategy = (NetworkTopologyStrategy) keyspace.getReplicationStrategy(); Map<String, Integer> dcEndpoints = new HashMap<String, Integer>(); for (String dc: strategy.getDatacenters()) dcEndpoints.put(dc, 0); for (InetAddress endpoint : liveEndpoints) { String dc = DatabaseDescriptor.getEndpointSnitch().getDatacenter(endpoint); dcEndpoints.put(dc, dcEndpoints.get(dc) + 1); } return dcEndpoints; }
private Map<String, Integer> countPerDCEndpoints(Keyspace keyspace, Iterable<InetAddress> liveEndpoints) { NetworkTopologyStrategy strategy = (NetworkTopologyStrategy) keyspace.getReplicationStrategy(); Map<String, Integer> dcEndpoints = new HashMap<String, Integer>(); for (String dc: strategy.getDatacenters()) dcEndpoints.put(dc, 0); for (InetAddress endpoint : liveEndpoints) { String dc = DatabaseDescriptor.getEndpointSnitch().getDatacenter(endpoint); dcEndpoints.put(dc, dcEndpoints.get(dc) + 1); } return dcEndpoints; }
private Map<String, Integer> countPerDCEndpoints(Keyspace keyspace, Iterable<InetAddress> liveEndpoints) { NetworkTopologyStrategy strategy = (NetworkTopologyStrategy) keyspace.getReplicationStrategy(); Map<String, Integer> dcEndpoints = new HashMap<String, Integer>(); for (String dc: strategy.getDatacenters()) dcEndpoints.put(dc, 0); for (InetAddress endpoint : liveEndpoints) { String dc = DatabaseDescriptor.getEndpointSnitch().getDatacenter(endpoint); dcEndpoints.put(dc, dcEndpoints.get(dc) + 1); } return dcEndpoints; }
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 DatacenterSyncWriteResponseHandler(Collection<InetAddress> naturalEndpoints, Collection<InetAddress> pendingEndpoints, ConsistencyLevel consistencyLevel, Keyspace keyspace, Runnable callback, WriteType writeType, long queryStartNanoTime) { // Response is been managed by the map so make it 1 for the superclass. super(keyspace, naturalEndpoints, pendingEndpoints, consistencyLevel, callback, writeType, queryStartNanoTime); assert consistencyLevel == ConsistencyLevel.EACH_QUORUM; NetworkTopologyStrategy strategy = (NetworkTopologyStrategy) keyspace.getReplicationStrategy(); for (String dc : strategy.getDatacenters()) { int rf = strategy.getReplicationFactor(dc); responses.put(dc, new AtomicInteger((rf / 2) + 1)); } // During bootstrap, we have to include the pending endpoints or we may fail the consistency level // guarantees (see #833) for (InetAddress pending : pendingEndpoints) { responses.get(snitch.getDatacenter(pending)).incrementAndGet(); } }
public DatacenterSyncWriteResponseHandler(Collection<InetAddress> naturalEndpoints, Collection<InetAddress> pendingEndpoints, ConsistencyLevel consistencyLevel, Keyspace keyspace, Runnable callback, WriteType writeType, long queryStartNanoTime) { // Response is been managed by the map so make it 1 for the superclass. super(keyspace, naturalEndpoints, pendingEndpoints, consistencyLevel, callback, writeType, queryStartNanoTime); assert consistencyLevel == ConsistencyLevel.EACH_QUORUM; NetworkTopologyStrategy strategy = (NetworkTopologyStrategy) keyspace.getReplicationStrategy(); for (String dc : strategy.getDatacenters()) { int rf = strategy.getReplicationFactor(dc); responses.put(dc, new AtomicInteger((rf / 2) + 1)); } // During bootstrap, we have to include the pending endpoints or we may fail the consistency level // guarantees (see #833) for (InetAddress pending : pendingEndpoints) { responses.get(snitch.getDatacenter(pending)).incrementAndGet(); } }
public DatacenterSyncWriteResponseHandler(Collection<InetAddress> naturalEndpoints, Collection<InetAddress> pendingEndpoints, ConsistencyLevel consistencyLevel, Keyspace keyspace, Runnable callback, WriteType writeType, long queryStartNanoTime) { // Response is been managed by the map so make it 1 for the superclass. super(keyspace, naturalEndpoints, pendingEndpoints, consistencyLevel, callback, writeType, queryStartNanoTime); assert consistencyLevel == ConsistencyLevel.EACH_QUORUM; NetworkTopologyStrategy strategy = (NetworkTopologyStrategy) keyspace.getReplicationStrategy(); for (String dc : strategy.getDatacenters()) { int rf = strategy.getReplicationFactor(dc); responses.put(dc, new AtomicInteger((rf / 2) + 1)); } // During bootstrap, we have to include the pending endpoints or we may fail the consistency level // guarantees (see #833) for (InetAddress pending : pendingEndpoints) { responses.get(snitch.getDatacenter(pending)).incrementAndGet(); } }
public DatacenterSyncWriteResponseHandler(Collection<InetAddress> naturalEndpoints, Collection<InetAddress> pendingEndpoints, ConsistencyLevel consistencyLevel, Keyspace keyspace, Runnable callback, WriteType writeType) { // Response is been managed by the map so make it 1 for the superclass. super(keyspace, naturalEndpoints, pendingEndpoints, consistencyLevel, callback, writeType); assert consistencyLevel == ConsistencyLevel.EACH_QUORUM; strategy = (NetworkTopologyStrategy) keyspace.getReplicationStrategy(); for (String dc : strategy.getDatacenters()) { int rf = strategy.getReplicationFactor(dc); responses.put(dc, new AtomicInteger((rf / 2) + 1)); } // During bootstrap, we have to include the pending endpoints or we may fail the consistency level // guarantees (see #833) for (InetAddress pending : pendingEndpoints) { responses.get(snitch.getDatacenter(pending)).incrementAndGet(); } }
for (String dc : strategy.getDatacenters()) n += localQuorumFor(keyspace, dc); return n;
for (String dc : strategy.getDatacenters()) n += localQuorumFor(keyspace, dc); return n;
for (String dc : strategy.getDatacenters()) n += localQuorumFor(keyspace, dc); return n;
for (String dc : strategy.getDatacenters()) n += localQuorumFor(keyspace, dc); return n;