Permalink
Browse files

make GC_GRACE_IN_SECONDS customizable in storage.conf.

patch by jbellis; reviewed by Eric Evans for #33
  • Loading branch information...
1 parent d75fa88 commit d0ad5f6e602b7ad75a2a5c2483b3a115986784e9 Jonathan Ellis committed Apr 17, 2009
View
@@ -45,6 +45,12 @@
<BootstrapFileDirectory>/var/cassandra/bootstrap</BootstrapFileDirectory>
<StagingFileDirectory>/var/cassandra/staging</StagingFileDirectory>
<CommitLogFastSync>false</CommitLogFastSync>
+ <!-- Time to wait before garbage-collection deletion markers.
+ Set this to a large enough value that you are confident
+ that the deletion marker will be propagated to all replicas
+ by the time this many seconds has elapsed, even in the
+ face of hardware failures. The default value is ten days. -->
+ <GCGraceSeconds>864000</GCGraceSeconds>
<Tables>
<Table Name = "Table1">
<ColumnFamily ColumnSort="Name" Name="Standard1"/>
@@ -27,14 +27,11 @@
import org.apache.cassandra.db.ColumnFamily;
import org.apache.cassandra.db.Table;
import org.apache.cassandra.db.TypeInfo;
-import org.apache.cassandra.db.DBManager;
import org.apache.cassandra.db.SystemTable;
-import org.apache.cassandra.db.Table.TableMetadata;
import org.apache.cassandra.utils.FileUtils;
import org.apache.cassandra.utils.XMLUtils;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.apache.cassandra.io.*;
/**
@@ -116,10 +113,12 @@
private static String jobTrackerHost_;
/* Zookeeper session timeout. */
private static int zkSessionTimeout_ = 30000;
-
+ /* time to wait before garbage collecting tombstones (deletion markers) */
+ private static int gcGraceInSeconds_ = 10 * 24 * 3600; // 10 days
+
// the path qualified config file (storage-conf.xml) name
private static String configFileName_;
-
+
static
{
try
@@ -148,6 +147,10 @@
/* Job Jar file location */
jobJarFileLocation_ = xmlUtils.getNodeValue("/Storage/JobJarFileLocation");
+ String gcGrace = xmlUtils.getNodeValue("/Storage/GCGraceSeconds");
+ if ( gcGrace != null )
+ gcGraceInSeconds_ = Integer.parseInt(gcGrace);
+
/* Zookeeper's session timeout */
String zkSessionTimeout = xmlUtils.getNodeValue("/Storage/ZookeeperSessionTimeout");
if ( zkSessionTimeout != null )
@@ -462,6 +465,11 @@ private static void storeMetadata() throws IOException
}
}
+ public static int getGcGraceInSeconds()
+ {
+ return gcGraceInSeconds_;
+ }
+
public static String getHashingStrategy()
{
return hashingStrategy_;
@@ -616,8 +616,6 @@ private static ColumnFamily resolveAndRemoveDeleted(List<ColumnFamily> columnFam
return removeDeleted(cf);
}
- static final int GC_GRACE_IN_SECONDS = 10 * 24 * 3600; // 10 days
-
/*
This is complicated because we need to preserve deleted columns, supercolumns, and columnfamilies
until they have been deleted for at least GC_GRACE_IN_SECONDS. But, we do not need to preserve
@@ -626,7 +624,7 @@ private static ColumnFamily resolveAndRemoveDeleted(List<ColumnFamily> columnFam
*/
static ColumnFamily removeDeleted(ColumnFamily cf)
{
- return removeDeleted(cf, (int)(System.currentTimeMillis() / 1000) - GC_GRACE_IN_SECONDS);
+ return removeDeleted(cf, (int)(System.currentTimeMillis() / 1000) - DatabaseDescriptor.getGcGraceInSeconds());
}
static ColumnFamily removeDeleted(ColumnFamily cf, int gcBefore)

0 comments on commit d0ad5f6

Please sign in to comment.