mirror of https://github.com/apache/cassandra
Merge branch 'cassandra-2.1' into cassandra-2.2
Conflicts: src/java/org/apache/cassandra/db/compaction/CompactionManager.java test/unit/org/apache/cassandra/db/compaction/AntiCompactionTest.java
This commit is contained in:
commit
362da9bbc1
|
|
@ -468,12 +468,18 @@ public class CompactionManager implements CompactionManagerMBean
|
|||
Iterator<SSTableReader> sstableIterator = sstables.iterator();
|
||||
try
|
||||
{
|
||||
List<Range<Token>> normalizedRanges = Range.normalize(ranges);
|
||||
|
||||
while (sstableIterator.hasNext())
|
||||
{
|
||||
SSTableReader sstable = sstableIterator.next();
|
||||
for (Range<Token> r : Range.normalize(ranges))
|
||||
|
||||
Range<Token> sstableRange = new Range<>(sstable.first.getToken(), sstable.last.getToken());
|
||||
|
||||
boolean shouldAnticompact = false;
|
||||
|
||||
for (Range<Token> r : normalizedRanges)
|
||||
{
|
||||
Range<Token> sstableRange = new Range<>(sstable.first.getToken(), sstable.last.getToken());
|
||||
if (r.contains(sstableRange))
|
||||
{
|
||||
logger.info("SSTable {} fully contained in range {}, mutating repairedAt instead of anticompacting", sstable, r);
|
||||
|
|
@ -481,20 +487,22 @@ public class CompactionManager implements CompactionManagerMBean
|
|||
sstable.reloadSSTableMetadata();
|
||||
mutatedRepairStatuses.add(sstable);
|
||||
sstableIterator.remove();
|
||||
shouldAnticompact = true;
|
||||
break;
|
||||
}
|
||||
else if (!sstableRange.intersects(r))
|
||||
{
|
||||
logger.info("SSTable {} ({}) does not intersect repaired range {}, not touching repairedAt.", sstable, sstableRange, r);
|
||||
nonAnticompacting.add(sstable);
|
||||
sstableIterator.remove();
|
||||
break;
|
||||
}
|
||||
else
|
||||
else if (sstableRange.intersects(r))
|
||||
{
|
||||
logger.info("SSTable {} ({}) will be anticompacted on range {}", sstable, sstableRange, r);
|
||||
shouldAnticompact = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!shouldAnticompact)
|
||||
{
|
||||
logger.info("SSTable {} ({}) does not intersect repaired ranges {}, not touching repairedAt.", sstable, sstableRange, normalizedRanges);
|
||||
nonAnticompacting.add(sstable);
|
||||
sstableIterator.remove();
|
||||
}
|
||||
}
|
||||
cfs.getTracker().notifySSTableRepairedStatusChanged(mutatedRepairStatuses);
|
||||
txn.cancel(Sets.union(nonAnticompacting, mutatedRepairStatuses));
|
||||
|
|
|
|||
|
|
@ -292,14 +292,14 @@ public class AntiCompactionTest
|
|||
Collection<SSTableReader> sstables = store.getUnrepairedSSTables();
|
||||
assertEquals(store.getSSTables().size(), sstables.size());
|
||||
|
||||
Range<Token> range = new Range<Token>(new BytesToken("-10".getBytes()), new BytesToken("-1".getBytes()));
|
||||
Range<Token> range = new Range<Token>(new BytesToken("-1".getBytes()), new BytesToken("-10".getBytes()));
|
||||
List<Range<Token>> ranges = Arrays.asList(range);
|
||||
|
||||
|
||||
try (LifecycleTransaction txn = store.getTracker().tryModify(sstables, OperationType.ANTICOMPACTION);
|
||||
Refs<SSTableReader> refs = Refs.ref(sstables))
|
||||
{
|
||||
CompactionManager.instance.performAnticompaction(store, ranges, refs, txn, 0);
|
||||
CompactionManager.instance.performAnticompaction(store, ranges, refs, txn, 1);
|
||||
}
|
||||
|
||||
assertThat(store.getSSTables().size(), is(10));
|
||||
|
|
|
|||
Loading…
Reference in New Issue