Skip to content

Commit

Permalink
Merge branch 'cassandra-3.11' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
pauloricardomg committed Feb 15, 2017
2 parents a0827fb + ef9df6e commit 31eac78
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 31 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -37,6 +37,7 @@
* More fixes to the TokenAllocator (CASSANDRA-12990)
* NoReplicationTokenAllocator should work with zero replication factor (CASSANDRA-12983)
Merged from 3.0:
* Use keyspace replication settings on system.size_estimates table (CASSANDRA-9639)
* Add vm.max_map_count StartupCheck (CASSANDRA-13008)
* Obfuscate password in stress-graphs (CASSANDRA-12233)
* Hint related logging should include the IP address of the destination in addition to
Expand Down
11 changes: 8 additions & 3 deletions NEWS.txt
Expand Up @@ -22,9 +22,6 @@ New features
See CASSANDRA-11936
- Support for arithmetic operations on number has been added. See CASSANDRA-11935

3.11
====

Upgrading
---------
- Cassandra 4.0 removed support for the deprecated Thrift interface. Amongst
Expand All @@ -47,6 +44,14 @@ Upgrading
repaired. For incremental repairs, anticompaction is run at the beginning
of the repair, instead of at the end.

3.11.0
======

Upgrading
---------
- Primary ranges in the system.size_estimates table are now based on the keyspace
replication settings and adjacent ranges are no longer merged (CASSANDRA-9639).

3.10
====

Expand Down
54 changes: 27 additions & 27 deletions src/java/org/apache/cassandra/db/SizeEstimatesRecorder.java
Expand Up @@ -68,12 +68,10 @@ public void run()

logger.trace("Recording size estimates");

// find primary token ranges for the local node.
Collection<Token> localTokens = StorageService.instance.getLocalTokens();
Collection<Range<Token>> localRanges = metadata.getPrimaryRangesFor(localTokens);

for (Keyspace keyspace : Keyspace.nonLocalStrategy())
{
Collection<Range<Token>> localRanges = StorageService.instance.getPrimaryRangesForEndpoint(keyspace.getName(),
FBUtilities.getBroadcastAddress());
for (ColumnFamilyStore table : keyspace.getColumnFamilyStores())
{
long start = System.nanoTime();
Expand All @@ -90,37 +88,39 @@ public void run()
@SuppressWarnings("resource")
private void recordSizeEstimates(ColumnFamilyStore table, Collection<Range<Token>> localRanges)
{
List<Range<Token>> unwrappedRanges = Range.normalize(localRanges);
// for each local primary range, estimate (crudely) mean partition size and partitions count.
Map<Range<Token>, Pair<Long, Long>> estimates = new HashMap<>(localRanges.size());
for (Range<Token> range : unwrappedRanges)
for (Range<Token> localRange : localRanges)
{
// filter sstables that have partitions in this range.
Refs<SSTableReader> refs = null;
long partitionsCount, meanPartitionSize;

try
for (Range<Token> unwrappedRange : localRange.unwrap())
{
while (refs == null)
// filter sstables that have partitions in this range.
Refs<SSTableReader> refs = null;
long partitionsCount, meanPartitionSize;

try
{
while (refs == null)
{
Iterable<SSTableReader> sstables = table.getTracker().getView().select(SSTableSet.CANONICAL);
SSTableIntervalTree tree = SSTableIntervalTree.build(sstables);
Range<PartitionPosition> r = Range.makeRowRange(unwrappedRange);
Iterable<SSTableReader> canonicalSSTables = View.sstablesInBounds(r.left, r.right, tree);
refs = Refs.tryRef(canonicalSSTables);
}

// calculate the estimates.
partitionsCount = estimatePartitionsCount(refs, unwrappedRange);
meanPartitionSize = estimateMeanPartitionSize(refs);
}
finally
{
Iterable<SSTableReader> sstables = table.getTracker().getView().select(SSTableSet.CANONICAL);
SSTableIntervalTree tree = SSTableIntervalTree.build(sstables);
Range<PartitionPosition> r = Range.makeRowRange(range);
Iterable<SSTableReader> canonicalSSTables = View.sstablesInBounds(r.left, r.right, tree);
refs = Refs.tryRef(canonicalSSTables);
if (refs != null)
refs.release();
}

// calculate the estimates.
partitionsCount = estimatePartitionsCount(refs, range);
meanPartitionSize = estimateMeanPartitionSize(refs);
}
finally
{
if (refs != null)
refs.release();
estimates.put(unwrappedRange, Pair.create(partitionsCount, meanPartitionSize));
}

estimates.put(range, Pair.create(partitionsCount, meanPartitionSize));
}

// atomically update the estimates.
Expand Down
Expand Up @@ -266,7 +266,10 @@ public static Set<InetAddress> getNeighbors(String keyspaceName, Collection<Rang
}
else if (range.intersects(toRepair))
{
throw new IllegalArgumentException("Requested range intersects a local range but is not fully contained in one; this would lead to imprecise repair");
throw new IllegalArgumentException(String.format("Requested range %s intersects a local range (%s) " +
"but is not fully contained in one; this would lead to " +
"imprecise repair. keyspace: %s", toRepair.toString(),
range.toString(), keyspaceName));
}
}
if (rangeSuperSet == null || !replicaSets.containsKey(rangeSuperSet))
Expand Down

0 comments on commit 31eac78

Please sign in to comment.