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 void validateOptions() throws ConfigurationException { for (Entry<String, String> e : this.configOptions.entrySet()) { if (e.getKey().equalsIgnoreCase("replication_factor")) throw new ConfigurationException("replication_factor is an option for SimpleStrategy, not NetworkTopologyStrategy"); validateReplicationFactor(e.getValue()); } }
private boolean hasSufficientReplicas(Map<String, Set<InetAddress>> dcReplicas, Multimap<String, InetAddress> allEndpoints) { for (String dc : datacenters.keySet()) if (!hasSufficientReplicas(dc, dcReplicas, allEndpoints)) return false; return true; }
private boolean hasSufficientReplicas(String dc, Map<String, Set<InetAddress>> dcReplicas, Multimap<String, InetAddress> allEndpoints) { return dcReplicas.get(dc).size() >= Math.min(allEndpoints.get(dc).size(), getReplicationFactor(dc)); }
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; }
int nodeCount = sizeOrZero(allEndpoints.get(dc)); DatacenterEndpoints dcEndpoints = new DatacenterEndpoints(rf, sizeOrZero(racks.get(dc)), nodeCount, replicas, seenRacks); dcs.put(dc, dcEndpoints); ++dcsToFill;
private int localQuorumFor(Keyspace keyspace, String dc) { return (keyspace.getReplicationStrategy() instanceof NetworkTopologyStrategy) ? (((NetworkTopologyStrategy) keyspace.getReplicationStrategy()).getReplicationFactor(dc) / 2) + 1 : quorumFor(keyspace); }
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; }
int nodeCount = sizeOrZero(allEndpoints.get(dc)); DatacenterEndpoints dcEndpoints = new DatacenterEndpoints(rf, sizeOrZero(racks.get(dc)), nodeCount, replicas, seenRacks); dcs.put(dc, dcEndpoints); ++dcsToFill;
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(); } }
private int localQuorumFor(Keyspace keyspace, String dc) { return (keyspace.getReplicationStrategy() instanceof NetworkTopologyStrategy) ? (((NetworkTopologyStrategy) keyspace.getReplicationStrategy()).getReplicationFactor(dc) / 2) + 1 : quorumFor(keyspace); }
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; }
public void validateOptions() throws ConfigurationException { for (Entry<String, String> e : this.configOptions.entrySet()) { if (e.getKey().equalsIgnoreCase("replication_factor")) throw new ConfigurationException("replication_factor is an option for SimpleStrategy, not NetworkTopologyStrategy"); validateReplicationFactor(e.getValue()); } }
int nodeCount = sizeOrZero(allEndpoints.get(dc)); DatacenterEndpoints dcEndpoints = new DatacenterEndpoints(rf, sizeOrZero(racks.get(dc)), nodeCount, replicas, seenRacks); dcs.put(dc, dcEndpoints); ++dcsToFill;
}}; Iterator<Token> tokenIter = TokenMetadata.ringIterator(tokenMetadata.sortedTokens(), searchToken, false); while (tokenIter.hasNext() && !hasSufficientReplicas(dcReplicas, allEndpoints)) String dc = snitch.getDatacenter(ep); if (!datacenters.containsKey(dc) || hasSufficientReplicas(dc, dcReplicas, allEndpoints)) continue; while (skippedIt.hasNext() && !hasSufficientReplicas(dc, dcReplicas, allEndpoints))
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(); } }
private int localQuorumFor(Keyspace keyspace, String dc) { return (keyspace.getReplicationStrategy() instanceof NetworkTopologyStrategy) ? (((NetworkTopologyStrategy) keyspace.getReplicationStrategy()).getReplicationFactor(dc) / 2) + 1 : quorumFor(keyspace); }
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; }
public void validateOptions() throws ConfigurationException { for (Entry<String, String> e : this.configOptions.entrySet()) { if (e.getKey().equalsIgnoreCase("replication_factor")) throw new ConfigurationException("replication_factor is an option for SimpleStrategy, not NetworkTopologyStrategy"); validateReplicationFactor(e.getValue()); } }
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(); } }