cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject [cassandra] branch trunk updated: Repair history tables should have TTL and TWCS
Date Wed, 08 Apr 2020 08:20:16 GMT
This is an automated email from the ASF dual-hosted git repository.

marcuse pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 25aa10c  Repair history tables should have TTL and TWCS
25aa10c is described below

commit 25aa10c9c12c294ff5998d481a0618193c66b5c2
Author: Marcus Eriksson <marcuse@apache.org>
AuthorDate: Thu Apr 2 14:17:40 2020 +0200

    Repair history tables should have TTL and TWCS
    
    Patch by marcuse; reviewed by Jon Meredith for CASSANDRA-12701
---
 CHANGES.txt                                        |  1 +
 .../repair/SystemDistributedKeyspace.java          | 25 ++++++++++++++++------
 .../apache/cassandra/schema/CompactionParams.java  |  6 ++++++
 3 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index ab71308..acac895 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 4.0-alpha4
+ * Repair history tables should have TTL and TWCS (CASSANDRA-12701)
  * Fix cqlsh erroring out on Python 3.7 due to webbrowser module being absent (CASSANDRA-15572)
  * Fix IMH#acquireCapacity() to return correct Outcome when endpoint reserve runs out (CASSANDRA-15607)
  * Fix nodetool describering output (CASSANDRA-15682)
diff --git a/src/java/org/apache/cassandra/repair/SystemDistributedKeyspace.java b/src/java/org/apache/cassandra/repair/SystemDistributedKeyspace.java
index a28a637..2e3b981 100644
--- a/src/java/org/apache/cassandra/repair/SystemDistributedKeyspace.java
+++ b/src/java/org/apache/cassandra/repair/SystemDistributedKeyspace.java
@@ -28,9 +28,11 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
+import java.util.concurrent.TimeUnit;
 
 import com.google.common.base.Joiner;
 import com.google.common.collect.Lists;
+import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Sets;
 
 import org.slf4j.Logger;
@@ -47,6 +49,7 @@ import org.apache.cassandra.dht.Token;
 import org.apache.cassandra.gms.Gossiper;
 import org.apache.cassandra.locator.InetAddressAndPort;
 import org.apache.cassandra.repair.messages.RepairOption;
+import org.apache.cassandra.schema.CompactionParams;
 import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.schema.KeyspaceParams;
 import org.apache.cassandra.schema.SchemaConstants;
@@ -77,8 +80,9 @@ public final class SystemDistributedKeyspace
      * gen 2: (pre-)add coordinator_port and participants_v2 columns to repair_history in
3.0, 3.11, 4.0
      * gen 3: gc_grace_seconds raised from 0 to 10 days in CASSANDRA-12954 in 3.11.0
      * gen 4: compression chunk length reduced to 16KiB, memtable_flush_period_in_ms now
unset on all tables in 4.0
+     * gen 5: add ttl and TWCS to repair_history tables
      */
-    public static final long GENERATION = 4;
+    public static final long GENERATION = 5;
 
     public static final String REPAIR_HISTORY = "repair_history";
 
@@ -105,7 +109,11 @@ public final class SystemDistributedKeyspace
                      + "status text,"
                      + "started_at timestamp,"
                      + "finished_at timestamp,"
-                     + "PRIMARY KEY ((keyspace_name, columnfamily_name), id))");
+                     + "PRIMARY KEY ((keyspace_name, columnfamily_name), id))")
+        .defaultTimeToLive((int) TimeUnit.DAYS.toSeconds(30))
+        .compaction(CompactionParams.twcs(ImmutableMap.of("compaction_window_unit","DAYS",
+                                                          "compaction_window_size","1")))
+        .build();
 
     private static final TableMetadata ParentRepairHistory =
         parse(PARENT_REPAIR_HISTORY,
@@ -121,7 +129,11 @@ public final class SystemDistributedKeyspace
                      + "requested_ranges set<text>,"
                      + "successful_ranges set<text>,"
                      + "options map<text, text>,"
-                     + "PRIMARY KEY (parent_id))");
+                     + "PRIMARY KEY (parent_id))")
+        .defaultTimeToLive((int) TimeUnit.DAYS.toSeconds(30))
+        .compaction(CompactionParams.twcs(ImmutableMap.of("compaction_window_unit","DAYS",
+                                                          "compaction_window_size","1")))
+        .build();
 
     private static final TableMetadata ViewBuildStatus =
         parse(VIEW_BUILD_STATUS,
@@ -131,14 +143,13 @@ public final class SystemDistributedKeyspace
                      + "view_name text,"
                      + "host_id uuid,"
                      + "status text,"
-                     + "PRIMARY KEY ((keyspace_name, view_name), host_id))");
+                     + "PRIMARY KEY ((keyspace_name, view_name), host_id))").build();
 
-    private static TableMetadata parse(String table, String description, String cql)
+    private static TableMetadata.Builder parse(String table, String description, String cql)
     {
         return CreateTableStatement.parse(format(cql, table), SchemaConstants.DISTRIBUTED_KEYSPACE_NAME)
                                    .id(TableId.forSystemTable(SchemaConstants.DISTRIBUTED_KEYSPACE_NAME,
table))
-                                   .comment(description)
-                                   .build();
+                                   .comment(description);
     }
 
     public static KeyspaceMetadata metadata()
diff --git a/src/java/org/apache/cassandra/schema/CompactionParams.java b/src/java/org/apache/cassandra/schema/CompactionParams.java
index da05667..a9efff3 100644
--- a/src/java/org/apache/cassandra/schema/CompactionParams.java
+++ b/src/java/org/apache/cassandra/schema/CompactionParams.java
@@ -31,6 +31,7 @@ import org.slf4j.LoggerFactory;
 import org.apache.cassandra.db.compaction.AbstractCompactionStrategy;
 import org.apache.cassandra.db.compaction.LeveledCompactionStrategy;
 import org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy;
+import org.apache.cassandra.db.compaction.TimeWindowCompactionStrategy;
 import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.utils.FBUtilities;
 
@@ -117,6 +118,11 @@ public final class CompactionParams
         return create(LeveledCompactionStrategy.class, options);
     }
 
+    public static CompactionParams twcs(Map<String, String> options)
+    {
+        return create(TimeWindowCompactionStrategy.class, options);
+    }
+
     public int minCompactionThreshold()
     {
         String threshold = options.get(Option.MIN_THRESHOLD.toString());


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


Mime
View raw message