cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject cassandra git commit: Add nodetool replaybatchlog command
Date Tue, 16 Jun 2015 18:48:35 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 25dca4669 -> 07bb8f98e


Add nodetool replaybatchlog command

Patch by carlyeks; reviewed by tjake for CASSANDRA-9547


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/07bb8f98
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/07bb8f98
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/07bb8f98

Branch: refs/heads/trunk
Commit: 07bb8f98e07f10308d65c264fe29f8c5ee8d4f4f
Parents: 25dca46
Author: Carl Yeksigian <carl@apache.org>
Authored: Thu Jun 4 10:50:31 2015 -0400
Committer: T Jake Luciani <jake@apache.org>
Committed: Tue Jun 16 14:46:20 2015 -0400

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../apache/cassandra/db/BatchlogManager.java    |  6 +--
 .../cassandra/db/BatchlogManagerMBean.java      |  2 +-
 .../org/apache/cassandra/tools/NodeProbe.java   | 17 ++++++++
 .../org/apache/cassandra/tools/NodeTool.java    |  1 +
 .../tools/nodetool/ReplayBatchlog.java          | 42 ++++++++++++++++++++
 6 files changed, 65 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/07bb8f98/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 77ac9e8..c2e5c97 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0:
+ * Add nodetool command to replay batchlog (CASSANDRA-9547)
  * Make file buffer cache independent of paths being read (CASSANDRA-8897)
  * Remove deprecated legacy Hadoop code (CASSANDRA-9353)
  * Decommissioned nodes will not rejoin the cluster (CASSANDRA-8801)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/07bb8f98/src/java/org/apache/cassandra/db/BatchlogManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/BatchlogManager.java b/src/java/org/apache/cassandra/db/BatchlogManager.java
index dd84ac8..6038475 100644
--- a/src/java/org/apache/cassandra/db/BatchlogManager.java
+++ b/src/java/org/apache/cassandra/db/BatchlogManager.java
@@ -60,7 +60,7 @@ import static org.apache.cassandra.cql3.QueryProcessor.executeInternal;
 
 public class BatchlogManager implements BatchlogManagerMBean
 {
-    private static final String MBEAN_NAME = "org.apache.cassandra.db:type=BatchlogManager";
+    public static final String MBEAN_NAME = "org.apache.cassandra.db:type=BatchlogManager";
     private static final long REPLAY_INTERVAL = 60 * 1000; // milliseconds
     private static final int PAGE_SIZE = 128; // same as HHOM, for now, w/out using any heuristics.
TODO: set based on avg batch size.
 
@@ -112,9 +112,9 @@ public class BatchlogManager implements BatchlogManagerMBean
         return totalBatchesReplayed.longValue();
     }
 
-    public void forceBatchlogReplay()
+    public void forceBatchlogReplay() throws Exception
     {
-        startBatchlogReplay();
+        startBatchlogReplay().get();
     }
 
     public Future<?> startBatchlogReplay()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/07bb8f98/src/java/org/apache/cassandra/db/BatchlogManagerMBean.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/BatchlogManagerMBean.java b/src/java/org/apache/cassandra/db/BatchlogManagerMBean.java
index 2e60ba4..a688117 100644
--- a/src/java/org/apache/cassandra/db/BatchlogManagerMBean.java
+++ b/src/java/org/apache/cassandra/db/BatchlogManagerMBean.java
@@ -34,5 +34,5 @@ public interface BatchlogManagerMBean
     /**
      * Forces batchlog replay. Returns immediately if replay is already in progress.
      */
-    public void forceBatchlogReplay();
+    public void forceBatchlogReplay() throws Exception;
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/07bb8f98/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 14215dc..db22208 100644
--- a/src/java/org/apache/cassandra/tools/NodeProbe.java
+++ b/src/java/org/apache/cassandra/tools/NodeProbe.java
@@ -51,6 +51,8 @@ import javax.management.remote.JMXConnectorFactory;
 import javax.management.remote.JMXServiceURL;
 
 import org.apache.cassandra.concurrent.Stage;
+import org.apache.cassandra.db.BatchlogManager;
+import org.apache.cassandra.db.BatchlogManagerMBean;
 import org.apache.cassandra.db.ColumnFamilyStoreMBean;
 import org.apache.cassandra.db.HintedHandOffManager;
 import org.apache.cassandra.db.HintedHandOffManagerMBean;
@@ -111,6 +113,7 @@ public class NodeProbe implements AutoCloseable
     private CacheServiceMBean cacheService;
     private StorageProxyMBean spProxy;
     private HintedHandOffManagerMBean hhProxy;
+    private BatchlogManagerMBean bmProxy;
     private boolean failed;
 
     /**
@@ -198,6 +201,8 @@ public class NodeProbe implements AutoCloseable
             gcProxy = JMX.newMBeanProxy(mbeanServerConn, name, GCInspectorMXBean.class);
             name = new ObjectName(Gossiper.MBEAN_NAME);
             gossProxy = JMX.newMBeanProxy(mbeanServerConn, name, GossiperMBean.class);
+            name = new ObjectName(BatchlogManager.MBEAN_NAME);
+            bmProxy = JMX.newMBeanProxy(mbeanServerConn, name, BatchlogManagerMBean.class);
         }
         catch (MalformedObjectNameException e)
         {
@@ -1272,6 +1277,18 @@ public class NodeProbe implements AutoCloseable
             }
         }
     }
+
+    public void replayBatchlog() throws IOException
+    {
+        try
+        {
+            bmProxy.forceBatchlogReplay();
+        }
+        catch (Exception e)
+        {
+            throw new IOException(e);
+        }
+    }
 }
 
 class ColumnFamilyStoreMBeanIterator implements Iterator<Map.Entry<String, ColumnFamilyStoreMBean>>

http://git-wip-us.apache.org/repos/asf/cassandra/blob/07bb8f98/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 10c0915..dc3b876 100644
--- a/src/java/org/apache/cassandra/tools/NodeTool.java
+++ b/src/java/org/apache/cassandra/tools/NodeTool.java
@@ -96,6 +96,7 @@ public class NodeTool
                 RemoveNode.class,
                 Assassinate.class,
                 Repair.class,
+                ReplayBatchlog.class,
                 SetCacheCapacity.class,
                 SetHintedHandoffThrottleInKB.class,
                 SetCompactionThreshold.class,

http://git-wip-us.apache.org/repos/asf/cassandra/blob/07bb8f98/src/java/org/apache/cassandra/tools/nodetool/ReplayBatchlog.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/nodetool/ReplayBatchlog.java b/src/java/org/apache/cassandra/tools/nodetool/ReplayBatchlog.java
new file mode 100644
index 0000000..e3dcbd4
--- /dev/null
+++ b/src/java/org/apache/cassandra/tools/nodetool/ReplayBatchlog.java
@@ -0,0 +1,42 @@
+/*
+ * 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 java.io.IOError;
+import java.io.IOException;
+
+import io.airlift.command.Command;
+import org.apache.cassandra.tools.NodeProbe;
+import org.apache.cassandra.tools.NodeTool;
+
+@Command(name = "replaybatchlog", description = "Kick off batchlog replay and wait for finish")
+public class ReplayBatchlog extends NodeTool.NodeToolCmd
+{
+    protected void execute(NodeProbe probe)
+    {
+        try
+        {
+            probe.replayBatchlog();
+        }
+        catch (IOException e)
+        {
+            throw new IOError(e);
+        }
+    }
+}


Mime
View raw message