cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject [1/3] git commit: Add SSTableDeletingNotification to DataTracker
Date Thu, 12 Sep 2013 17:39:07 GMT
Updated Branches:
  refs/heads/trunk 816c03218 -> f3430d394


Add SSTableDeletingNotification to DataTracker

patch by Piotr Kołaczkowski; reviewed by Aleksey Yeschenko for
CASSANDRA-6010


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

Branch: refs/heads/trunk
Commit: f663a996c799bd93963a50b418ed5fcde2e48a40
Parents: 53e48ed
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Thu Sep 12 20:35:31 2013 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Thu Sep 12 20:35:31 2013 +0300

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../org/apache/cassandra/db/DataTracker.java    | 12 +++++--
 .../io/sstable/SSTableDeletingTask.java         |  8 +++--
 .../SSTableDeletingNotification.java            | 33 ++++++++++++++++++++
 4 files changed, 49 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/f663a996/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 1c09589..51be09d 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -15,6 +15,7 @@
  * Allow empty CQL3 batches (as no-op) (CASSANDRA-5994)
  * Support null in CQL3 functions (CASSANDRA-5910)
  * Replace the deprecated MapMaker with CacheLoader (CASSANDRA-6007)
+ * Add SSTableDeletingNotification to DataTracker (CASSANDRA-6010)
 
 
 1.2.9

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f663a996/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 7f6e94c..b2f52a9 100644
--- a/src/java/org/apache/cassandra/db/DataTracker.java
+++ b/src/java/org/apache/cassandra/db/DataTracker.java
@@ -34,6 +34,7 @@ import org.apache.cassandra.metrics.StorageMetrics;
 import org.apache.cassandra.notifications.INotification;
 import org.apache.cassandra.notifications.INotificationConsumer;
 import org.apache.cassandra.notifications.SSTableAddedNotification;
+import org.apache.cassandra.notifications.SSTableDeletingNotification;
 import org.apache.cassandra.notifications.SSTableListChangedNotification;
 import org.apache.cassandra.utils.Interval;
 import org.apache.cassandra.utils.IntervalTree;
@@ -412,11 +413,16 @@ public class DataTracker
 
     public void notifyAdded(SSTableReader added)
     {
+        INotification notification = new SSTableAddedNotification(added);
+        for (INotificationConsumer subscriber : subscribers)
+            subscriber.handleNotification(notification, this);
+    }
+
+    public void notifyDeleting(SSTableReader deleting)
+    {
+        INotification notification = new SSTableDeletingNotification(deleting);
         for (INotificationConsumer subscriber : subscribers)
-        {
-            INotification notification = new SSTableAddedNotification(added);
             subscriber.handleNotification(notification, this);
-        }
     }
 
     public void subscribe(INotificationConsumer consumer)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f663a996/src/java/org/apache/cassandra/io/sstable/SSTableDeletingTask.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableDeletingTask.java b/src/java/org/apache/cassandra/io/sstable/SSTableDeletingTask.java
index 2335b7d..8bdc733 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableDeletingTask.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableDeletingTask.java
@@ -41,13 +41,15 @@ public class SSTableDeletingTask implements Runnable
     // will be recognized as GCable.
     private static final Set<SSTableDeletingTask> failedTasks = new CopyOnWriteArraySet<SSTableDeletingTask>();
 
-    public final Descriptor desc;
-    public final Set<Component> components;
+    private final SSTableReader referent;
+    private final Descriptor desc;
+    private final Set<Component> components;
     private DataTracker tracker;
     private final long size;
 
     public SSTableDeletingTask(SSTableReader referent)
     {
+        this.referent = referent;
         this.desc = referent.descriptor;
         this.components = referent.components;
         this.size = referent.bytesOnDisk();
@@ -65,6 +67,8 @@ public class SSTableDeletingTask implements Runnable
 
     public void run()
     {
+        tracker.notifyDeleting(referent);
+
         // If we can't successfully delete the DATA component, set the task to be retried
later: see above
         File datafile = new File(desc.filenameFor(Component.DATA));
         if (!datafile.delete())

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f663a996/src/java/org/apache/cassandra/notifications/SSTableDeletingNotification.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/notifications/SSTableDeletingNotification.java
b/src/java/org/apache/cassandra/notifications/SSTableDeletingNotification.java
new file mode 100644
index 0000000..8b0f597
--- /dev/null
+++ b/src/java/org/apache/cassandra/notifications/SSTableDeletingNotification.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.notifications;
+
+import org.apache.cassandra.io.sstable.SSTableReader;
+
+/**
+ * Fired right before removing an SSTable.
+ */
+public class SSTableDeletingNotification implements INotification
+{
+    public final SSTableReader deleting;
+
+    public SSTableDeletingNotification(SSTableReader deleting)
+    {
+        this.deleting = deleting;
+    }
+}


Mime
View raw message