cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1000909 - in /cassandra/trunk: CHANGES.txt src/java/org/apache/cassandra/db/ExpiringColumn.java test/unit/org/apache/cassandra/db/RowTest.java
Date Fri, 24 Sep 2010 15:30:36 GMT
Author: jbellis
Date: Fri Sep 24 15:30:35 2010
New Revision: 1000909

URL: http://svn.apache.org/viewvc?rev=1000909&view=rev
Log:
treat expired columns as deleted.  patch by Sylvain Lebresne; reviewed by jbellis for CASSANDRA-1539

Modified:
    cassandra/trunk/CHANGES.txt
    cassandra/trunk/src/java/org/apache/cassandra/db/ExpiringColumn.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/RowTest.java

Modified: cassandra/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=1000909&r1=1000908&r2=1000909&view=diff
==============================================================================
--- cassandra/trunk/CHANGES.txt (original)
+++ cassandra/trunk/CHANGES.txt Fri Sep 24 15:30:35 2010
@@ -87,6 +87,7 @@
  * Close intra-node sockets when connection is broken (CASSANDRA-1528)
  * RPM packaging spec file (CASSANDRA-786)
  * weighted request scheduler (CASSANDRA-1485)
+ * treat expired columns as deleted (CASSANDRA-1539)
 
 
 0.7-beta1

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/ExpiringColumn.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/ExpiringColumn.java?rev=1000909&r1=1000908&r2=1000909&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/ExpiringColumn.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/ExpiringColumn.java Fri Sep 24 15:30:35
2010
@@ -113,4 +113,17 @@ public class ExpiringColumn extends Colu
         sb.append(timeToLive);
         return sb.toString();
     }
+
+    @Override
+    public IClock getMarkedForDeleteAt()
+    {
+        if (isMarkedForDelete())
+        {
+            return clock;
+        }
+        else
+        {
+            throw new IllegalStateException("column is not marked for delete");
+        }
+    }
 }

Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/RowTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/RowTest.java?rev=1000909&r1=1000908&r2=1000909&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/db/RowTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/db/RowTest.java Fri Sep 24 15:30:35 2010
@@ -24,6 +24,7 @@ import org.apache.cassandra.SchemaLoader
 import org.junit.Test;
 
 import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.fail;
 import org.apache.cassandra.db.marshal.AsciiType;
 import static org.apache.cassandra.Util.column;
 
@@ -71,4 +72,24 @@ public class RowTest extends SchemaLoade
         assert Arrays.equals(cf1.getColumn("one".getBytes()).value(), "B".getBytes());
         assert Arrays.equals(cf1.getColumn("two".getBytes()).value(), "C".getBytes());
     }
+
+    @Test
+    public void testExpiringColumnExpiration()
+    {
+        Column c = new ExpiringColumn("one".getBytes(), "A".getBytes(), new TimestampClock(0),
1);
+        assert !c.isMarkedForDelete();
+
+        try
+        {
+            // Because we keep the local deletion time with a precision of a
+            // second, we could have to wait 2 seconds in worst case scenario.
+            Thread.sleep(2000);
+        }
+        catch (InterruptedException e)
+        {
+            fail("Cannot test column expiration if you wake me up too early");
+        }
+
+        assert c.isMarkedForDelete() && c.getMarkedForDeleteAt().equals(new TimestampClock(0));
+    }
 }



Mime
View raw message