Merge branch 'cassandra-3.0' into trunk

This commit is contained in:
Robert Stupp 2016-06-15 11:47:37 +02:00
commit 4210a25a90
4 changed files with 22 additions and 12 deletions

View File

@ -16,11 +16,11 @@ Merged from 3.0:
Merged from 2.2:
* StorageService shutdown hook should use a volatile variable (CASSANDRA-11984)
Merged from 2.1:
* Cache local ranges when calculating repair neighbors (CASSANDRA-11934)
* Allow LWT operation on static column with only partition keys (CASSANDRA-10532)
* Create interval tree over canonical sstables to avoid missing sstables during streaming (CASSANDRA-11886)
* cqlsh COPY FROM: shutdown parent cluster after forking, to avoid corrupting SSL connections (CASSANDRA-11749)
3.7
* Support multiple folders for user defined compaction tasks (CASSANDRA-11765)
* Fix race in CompactionStrategyManager's pause/resume (CASSANDRA-11922)

View File

@ -148,11 +148,16 @@ public class RepairRunnable extends WrappedRunnable implements ProgressEventNoti
final Set<InetAddress> allNeighbors = new HashSet<>();
List<Pair<Set<InetAddress>, ? extends Collection<Range<Token>>>> commonRanges = new ArrayList<>();
//pre-calculate output of getLocalRanges and pass it to getNeighbors to increase performance and prevent
//calculation multiple times
Collection<Range<Token>> keyspaceLocalRanges = storageService.getLocalRanges(keyspace);
try
{
for (Range<Token> range : options.getRanges())
{
Set<InetAddress> neighbors = ActiveRepairService.getNeighbors(keyspace, range,
Set<InetAddress> neighbors = ActiveRepairService.getNeighbors(keyspace, keyspaceLocalRanges, range,
options.getDataCenters(),
options.getHosts());

View File

@ -177,17 +177,20 @@ public class ActiveRepairService implements IEndpointStateChangeSubscriber, IFai
* Return all of the neighbors with whom we share the provided range.
*
* @param keyspaceName keyspace to repair
* @param keyspaceLocalRanges local-range for given keyspaceName
* @param toRepair token to repair
* @param dataCenters the data centers to involve in the repair
*
* @return neighbors with whom we share the provided range
*/
public static Set<InetAddress> getNeighbors(String keyspaceName, Range<Token> toRepair, Collection<String> dataCenters, Collection<String> hosts)
public static Set<InetAddress> getNeighbors(String keyspaceName, Collection<Range<Token>> keyspaceLocalRanges,
Range<Token> toRepair, Collection<String> dataCenters,
Collection<String> hosts)
{
StorageService ss = StorageService.instance;
Map<Range<Token>, List<InetAddress>> replicaSets = ss.getRangeToAddressMap(keyspaceName);
Range<Token> rangeSuperSet = null;
for (Range<Token> range : ss.getLocalRanges(keyspaceName))
for (Range<Token> range : keyspaceLocalRanges)
{
if (range.contains(toRepair))
{

View File

@ -97,7 +97,7 @@ public class ActiveRepairServiceTest
Set<InetAddress> neighbors = new HashSet<>();
for (Range<Token> range : ranges)
{
neighbors.addAll(ActiveRepairService.getNeighbors(KEYSPACE5, range, null, null));
neighbors.addAll(ActiveRepairService.getNeighbors(KEYSPACE5, ranges, range, null, null));
}
assertEquals(expected, neighbors);
}
@ -120,7 +120,7 @@ public class ActiveRepairServiceTest
Set<InetAddress> neighbors = new HashSet<>();
for (Range<Token> range : ranges)
{
neighbors.addAll(ActiveRepairService.getNeighbors(KEYSPACE5, range, null, null));
neighbors.addAll(ActiveRepairService.getNeighbors(KEYSPACE5, ranges, range, null, null));
}
assertEquals(expected, neighbors);
}
@ -142,7 +142,7 @@ public class ActiveRepairServiceTest
Set<InetAddress> neighbors = new HashSet<>();
for (Range<Token> range : ranges)
{
neighbors.addAll(ActiveRepairService.getNeighbors(KEYSPACE5, range, Arrays.asList(DatabaseDescriptor.getLocalDataCenter()), null));
neighbors.addAll(ActiveRepairService.getNeighbors(KEYSPACE5, ranges, range, Arrays.asList(DatabaseDescriptor.getLocalDataCenter()), null));
}
assertEquals(expected, neighbors);
}
@ -170,7 +170,7 @@ public class ActiveRepairServiceTest
Set<InetAddress> neighbors = new HashSet<>();
for (Range<Token> range : ranges)
{
neighbors.addAll(ActiveRepairService.getNeighbors(KEYSPACE5, range, Arrays.asList(DatabaseDescriptor.getLocalDataCenter()), null));
neighbors.addAll(ActiveRepairService.getNeighbors(KEYSPACE5, ranges, range, Arrays.asList(DatabaseDescriptor.getLocalDataCenter()), null));
}
assertEquals(expected, neighbors);
}
@ -191,10 +191,11 @@ public class ActiveRepairServiceTest
expected.remove(FBUtilities.getBroadcastAddress());
Collection<String> hosts = Arrays.asList(FBUtilities.getBroadcastAddress().getCanonicalHostName(),expected.get(0).getCanonicalHostName());
Collection<Range<Token>> ranges = StorageService.instance.getLocalRanges(KEYSPACE5);
assertEquals(expected.get(0), ActiveRepairService.getNeighbors(KEYSPACE5,
StorageService.instance.getLocalRanges(KEYSPACE5).iterator().next(),
null, hosts).iterator().next());
assertEquals(expected.get(0), ActiveRepairService.getNeighbors(KEYSPACE5, ranges,
ranges.iterator().next(),
null, hosts).iterator().next());
}
@Test(expected = IllegalArgumentException.class)
@ -203,7 +204,8 @@ public class ActiveRepairServiceTest
addTokens(2 * Keyspace.open(KEYSPACE5).getReplicationStrategy().getReplicationFactor());
//Dont give local endpoint
Collection<String> hosts = Arrays.asList("127.0.0.3");
ActiveRepairService.getNeighbors(KEYSPACE5, StorageService.instance.getLocalRanges(KEYSPACE5).iterator().next(), null, hosts);
Collection<Range<Token>> ranges = StorageService.instance.getLocalRanges(KEYSPACE5);
ActiveRepairService.getNeighbors(KEYSPACE5, ranges, ranges.iterator().next(), null, hosts);
}
Set<InetAddress> addTokens(int max) throws Throwable