Repository: cassandra Updated Branches: refs/heads/trunk 5e59b238f -> 3a79a027c
Really fix CM.setConcurrentCompactors, include test coverage for such Fixes 979af884 and b80ef9b25 for CASSANDRA-12248 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/3a79a027 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/3a79a027 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/3a79a027 Branch: refs/heads/trunk Commit: 3a79a027c7db2b8007a8ae4e19002c3edbf63d8e Parents: 5e59b23 Author: Nate McCall <zznat...@gmail.com> Authored: Thu Sep 29 12:52:24 2016 +1300 Committer: Nate McCall <zznat...@gmail.com> Committed: Thu Sep 29 12:52:24 2016 +1300 ---------------------------------------------------------------------- .../cassandra/db/compaction/CompactionManager.java | 14 ++++++++++++-- .../cassandra/db/compaction/CompactionsTest.java | 11 +++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a79a027/src/java/org/apache/cassandra/db/compaction/CompactionManager.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java index 148a4fb..2f3b32f 100644 --- a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java +++ b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java @@ -1865,8 +1865,18 @@ public class CompactionManager implements CompactionManagerMBean public void setConcurrentCompactors(int value) { - executor.setMaximumPoolSize(value); - executor.setCorePoolSize(value); + if (value > executor.getCorePoolSize()) + { + // we are increasing the value + executor.setMaximumPoolSize(value); + executor.setCorePoolSize(value); + } + else if (value < executor.getCorePoolSize()) + { + // we are reducing the value + executor.setCorePoolSize(value); + executor.setMaximumPoolSize(value); + } } public int getCoreCompactorThreads() http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a79a027/test/unit/org/apache/cassandra/db/compaction/CompactionsTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/compaction/CompactionsTest.java b/test/unit/org/apache/cassandra/db/compaction/CompactionsTest.java index 198b01b..cc81263 100644 --- a/test/unit/org/apache/cassandra/db/compaction/CompactionsTest.java +++ b/test/unit/org/apache/cassandra/db/compaction/CompactionsTest.java @@ -641,4 +641,15 @@ public class CompactionsTest 200, 209, 300, 301))); } + + @Test + public void testConcurrencySettings() + { + CompactionManager.instance.setConcurrentCompactors(2); + assertEquals(2, CompactionManager.instance.getCoreCompactorThreads()); + CompactionManager.instance.setConcurrentCompactors(3); + assertEquals(3, CompactionManager.instance.getCoreCompactorThreads()); + CompactionManager.instance.setConcurrentCompactors(1); + assertEquals(1, CompactionManager.instance.getCoreCompactorThreads()); + } }