cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zzn...@apache.org
Subject cassandra git commit: Add command to get/set the number of concurrent compactors
Date Tue, 27 Sep 2016 01:13:21 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 43ad488a5 -> 979af884e


Add command to get/set the number of concurrent compactors

Patch by Dikang Gu; reviewed by Nate McCall 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/979af884
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/979af884
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/979af884

Branch: refs/heads/trunk
Commit: 979af884ee4ecef78a21c4bd58992d053256f8f0
Parents: 43ad488
Author: Dikang Gu <dikang85@gmail.com>
Authored: Sun Sep 25 22:05:38 2016 -0700
Committer: Nate McCall <zznate.m@gmail.com>
Committed: Tue Sep 27 14:10:40 2016 +1300

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 NEWS.txt                                        |  1 +
 .../org/apache/cassandra/config/Config.java     |  2 +-
 .../cassandra/config/DatabaseDescriptor.java    |  5 +++
 .../db/compaction/CompactionManager.java        |  6 ++++
 .../cassandra/service/StorageService.java       | 13 +++++++
 .../cassandra/service/StorageServiceMBean.java  |  3 ++
 .../org/apache/cassandra/tools/NodeProbe.java   | 10 ++++++
 .../org/apache/cassandra/tools/NodeTool.java    |  2 ++
 .../tools/nodetool/GetConcurrentCompactors.java | 33 +++++++++++++++++
 .../tools/nodetool/SetConcurrentCompactors.java | 38 ++++++++++++++++++++
 11 files changed, 113 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/979af884/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index f9fed90..0a7f9b0 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.10
+ * Tune compaction thread count via nodetool (CASSANDRA-12248)
  * Add +=/-= shortcut syntax for update queries (CASSANDRA-12232)
  * Include repair session IDs in repair start message (CASSANDRA-12532)
  * Add a blocking task to Index, run before joining the ring (CASSANDRA-12039)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/979af884/NEWS.txt
----------------------------------------------------------------------
diff --git a/NEWS.txt b/NEWS.txt
index 4bcb197..ad0f2be 100644
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -18,6 +18,7 @@ using the provided 'sstableupgrade' tool.
 
 New features
 ------------
+   - Runtime modification of concurrent_compactors is now available via nodetool
    - Support for the assignment operators +=/-= has been added for update queries.
    - An Index implementation may now provide a task which runs prior to joining
      the ring. See CASSANDRA-12039

http://git-wip-us.apache.org/repos/asf/cassandra/blob/979af884/src/java/org/apache/cassandra/config/Config.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/Config.java b/src/java/org/apache/cassandra/config/Config.java
index e6b3638..35a17a5 100644
--- a/src/java/org/apache/cassandra/config/Config.java
+++ b/src/java/org/apache/cassandra/config/Config.java
@@ -176,7 +176,7 @@ public class Config
     public volatile int batch_size_warn_threshold_in_kb = 5;
     public volatile int batch_size_fail_threshold_in_kb = 50;
     public Integer unlogged_batch_across_partitions_warn_threshold = 10;
-    public Integer concurrent_compactors;
+    public volatile Integer concurrent_compactors;
     public volatile Integer compaction_throughput_mb_per_sec = 16;
     public volatile Integer compaction_large_partition_warning_threshold_mb = 100;
     public Integer min_free_space_per_drive_in_mb = 50;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/979af884/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
index 963d564..880cb1e 100644
--- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
+++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
@@ -1495,6 +1495,11 @@ public class DatabaseDescriptor
         return conf.concurrent_compactors;
     }
 
+    public static void setConcurrentCompactors(int value)
+    {
+        conf.concurrent_compactors = value;
+    }
+
     public static int getCompactionThroughputMbPerSec()
     {
         return conf.compaction_throughput_mb_per_sec;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/979af884/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 27058d2..bad0bdf 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
@@ -1863,6 +1863,12 @@ public class CompactionManager implements CompactionManagerMBean
         }
     }
 
+    public void setConcurrentCompactors(int value)
+    {
+        executor.setCorePoolSize(value);
+        executor.setMaximumPoolSize(value);
+    }
+
     public int getCoreCompactorThreads()
     {
         return executor.getCorePoolSize();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/979af884/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java
index 4f11800..2e982ed 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -1414,6 +1414,19 @@ public class StorageService extends NotificationBroadcasterSupport
implements IE
         CompactionManager.instance.setRate(value);
     }
 
+    public int getConcurrentCompactors()
+    {
+        return DatabaseDescriptor.getConcurrentCompactors();
+    }
+
+    public void setConcurrentCompactors(int value)
+    {
+        if (value <= 0)
+            throw new IllegalArgumentException("Number of concurrent compactors should be
greater than 0.");
+        DatabaseDescriptor.setConcurrentCompactors(value);
+        CompactionManager.instance.setConcurrentCompactors(value);
+    }
+
     public boolean isIncrementalBackupsEnabled()
     {
         return DatabaseDescriptor.isIncrementalBackupsEnabled();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/979af884/src/java/org/apache/cassandra/service/StorageServiceMBean.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageServiceMBean.java b/src/java/org/apache/cassandra/service/StorageServiceMBean.java
index 527417c..2243a96 100644
--- a/src/java/org/apache/cassandra/service/StorageServiceMBean.java
+++ b/src/java/org/apache/cassandra/service/StorageServiceMBean.java
@@ -560,6 +560,9 @@ public interface StorageServiceMBean extends NotificationEmitter
     public int getCompactionThroughputMbPerSec();
     public void setCompactionThroughputMbPerSec(int value);
 
+    public int getConcurrentCompactors();
+    public void setConcurrentCompactors(int value);
+
     public boolean isIncrementalBackupsEnabled();
     public void setIncrementalBackupsEnabled(boolean value);
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/979af884/src/java/org/apache/cassandra/tools/NodeProbe.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/NodeProbe.java b/src/java/org/apache/cassandra/tools/NodeProbe.java
index 5d6dff0..ed23c04 100644
--- a/src/java/org/apache/cassandra/tools/NodeProbe.java
+++ b/src/java/org/apache/cassandra/tools/NodeProbe.java
@@ -994,6 +994,16 @@ public class NodeProbe implements AutoCloseable
         return ssProxy.getCompactionThroughputMbPerSec();
     }
 
+    public void setConcurrentCompactors(int value)
+    {
+        ssProxy.setConcurrentCompactors(value);
+    }
+
+    public int getConcurrentCompactors()
+    {
+        return ssProxy.getConcurrentCompactors();
+    }
+
     public long getTimeout(String type)
     {
         switch (type)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/979af884/src/java/org/apache/cassandra/tools/NodeTool.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/NodeTool.java b/src/java/org/apache/cassandra/tools/NodeTool.java
index cde4ee5..23e6df3 100644
--- a/src/java/org/apache/cassandra/tools/NodeTool.java
+++ b/src/java/org/apache/cassandra/tools/NodeTool.java
@@ -105,6 +105,8 @@ public class NodeTool
                 SetHintedHandoffThrottleInKB.class,
                 SetCompactionThreshold.class,
                 SetCompactionThroughput.class,
+                GetConcurrentCompactors.class,
+                SetConcurrentCompactors.class,
                 SetTimeout.class,
                 SetStreamThroughput.class,
                 SetInterDCStreamThroughput.class,

http://git-wip-us.apache.org/repos/asf/cassandra/blob/979af884/src/java/org/apache/cassandra/tools/nodetool/GetConcurrentCompactors.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/nodetool/GetConcurrentCompactors.java b/src/java/org/apache/cassandra/tools/nodetool/GetConcurrentCompactors.java
new file mode 100644
index 0000000..8f4d5e4
--- /dev/null
+++ b/src/java/org/apache/cassandra/tools/nodetool/GetConcurrentCompactors.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.tools.nodetool;
+
+import io.airlift.command.Command;
+import org.apache.cassandra.tools.NodeProbe;
+import org.apache.cassandra.tools.NodeTool.NodeToolCmd;
+
+@Command(name = "getconcurrentcompactors", description = "Get the number of concurrent compactors
in the system.")
+public class GetConcurrentCompactors extends NodeToolCmd
+{
+    protected void execute(NodeProbe probe)
+    {
+        System.out.println("Current concurrent compactors in the system is: \n" +
+                           probe.getConcurrentCompactors());
+    }
+}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/979af884/src/java/org/apache/cassandra/tools/nodetool/SetConcurrentCompactors.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/nodetool/SetConcurrentCompactors.java b/src/java/org/apache/cassandra/tools/nodetool/SetConcurrentCompactors.java
new file mode 100644
index 0000000..56fafe1
--- /dev/null
+++ b/src/java/org/apache/cassandra/tools/nodetool/SetConcurrentCompactors.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.tools.nodetool;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import io.airlift.command.Arguments;
+import io.airlift.command.Command;
+import org.apache.cassandra.tools.NodeProbe;
+import org.apache.cassandra.tools.NodeTool;
+
+@Command(name = "setconcurrentcompactors", description = "Set number of concurrent compactors
in the system.")
+public class SetConcurrentCompactors extends NodeTool.NodeToolCmd
+{
+    @Arguments(title = "concurrent_compactors", usage = "<value>", description = "Number
of concurrent compactors, greater than 0.", required = true)
+    private Integer concurrentCompactors = null;
+
+    protected void execute(NodeProbe probe)
+    {
+        checkArgument(concurrentCompactors > 0, "concurrent_compactors should be great
than 0.");
+        probe.setConcurrentCompactors(concurrentCompactors);
+    }
+}


Mime
View raw message