You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by al...@apache.org on 2014/10/09 14:33:23 UTC
git commit: Notify DT subscribers when a column family is truncated
Repository: cassandra
Updated Branches:
refs/heads/cassandra-2.0 fc0bb1520 -> cced4ba15
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.0
Commit: cced4ba15bc5db7395f5981d01393757c3e0332e
Parents: fc0bb15
Author: Sam Tunnicliffe <sa...@beobal.com>
Authored: Thu Oct 9 15:31:28 2014 +0300
Committer: Aleksey Yeschenko <al...@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;
+ }
+}