cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject [1/2] git commit: Notify DT subscribers when a column family is truncated
Date Thu, 09 Oct 2014 12:35:24 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 f92a457a3 -> 5a33a9ad2


Notify DT subscribers when a column family is truncated

patch by Sam Tunnicliffe; reviewed by Aleksey Yeschenko for
CASSANDRA-8088


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

Branch: refs/heads/cassandra-2.1
Commit: cced4ba15bc5db7395f5981d01393757c3e0332e
Parents: fc0bb15
Author: Sam Tunnicliffe <sam@beobal.com>
Authored: Thu Oct 9 15:31:28 2014 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Thu Oct 9 15:33:05 2014 +0300

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../apache/cassandra/db/ColumnFamilyStore.java  |  2 ++
 .../org/apache/cassandra/db/DataTracker.java    |  7 +++++
 .../notifications/TruncationNotification.java   | 32 ++++++++++++++++++++
 4 files changed, 42 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/cced4ba1/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 7deea86..1c2231d 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.0.11:
+ * Notify DT subscribers when a column family is truncated (CASSANDRA-8088)
  * Add sanity check of $JAVA on startup (CASSANDRA-7676)
  * Schedule fat client schema pull on join (CASSANDRA-7993)
  * Don't reset nodes' versions when closing IncomingTcpConnections

http://git-wip-us.apache.org/repos/asf/cassandra/blob/cced4ba1/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index 3da44de..d0ff951 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -2035,6 +2035,8 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
                 logger.debug("Discarding sstable data for truncated CF + indexes");
 
                 final long truncatedAt = System.currentTimeMillis();
+                data.notifyTruncated(truncatedAt);
+
                 if (DatabaseDescriptor.isAutoSnapshot())
                     snapshot(Keyspace.getTimestampedSnapshotName(name));
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/cced4ba1/src/java/org/apache/cassandra/db/DataTracker.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/DataTracker.java b/src/java/org/apache/cassandra/db/DataTracker.java
index d41181b..f6d2c75 100644
--- a/src/java/org/apache/cassandra/db/DataTracker.java
+++ b/src/java/org/apache/cassandra/db/DataTracker.java
@@ -475,6 +475,13 @@ public class DataTracker
             subscriber.handleNotification(notification, this);
     }
 
+    public void notifyTruncated(long truncatedAt)
+    {
+        INotification notification = new TruncationNotification(truncatedAt);
+        for (INotificationConsumer subscriber : subscribers)
+            subscriber.handleNotification(notification, this);
+    }
+
     public void subscribe(INotificationConsumer consumer)
     {
         subscribers.add(consumer);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/cced4ba1/src/java/org/apache/cassandra/notifications/TruncationNotification.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/notifications/TruncationNotification.java b/src/java/org/apache/cassandra/notifications/TruncationNotification.java
new file mode 100644
index 0000000..345dd17
--- /dev/null
+++ b/src/java/org/apache/cassandra/notifications/TruncationNotification.java
@@ -0,0 +1,32 @@
+/*
+ * 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.notifications;
+
+/**
+ * Fired during truncate, after the memtable has been flushed but before any
+ * snapshot is taken and SSTables are discarded
+ */
+public class TruncationNotification implements INotification
+{
+    public final long truncatedAt;
+
+    public TruncationNotification(long truncatedAt)
+    {
+        this.truncatedAt = truncatedAt;
+    }
+}


Mime
View raw message