You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2021/12/03 14:16:02 UTC

[GitHub] [cassandra] blerer commented on a change in pull request #1276: CASSANDRA-17048: UUID based sstable generation numbers

blerer commented on a change in pull request #1276:
URL: https://github.com/apache/cassandra/pull/1276#discussion_r761960234



##########
File path: test/unit/org/apache/cassandra/cql3/CQLTester.java
##########
@@ -603,6 +603,11 @@ public ColumnFamilyStore getCurrentColumnFamilyStore(String keyspace)
              : Keyspace.open(keyspace).getColumnFamilyStore(currentTable);

Review comment:
       Should be replaced by `getColumnFamilyStore`

##########
File path: src/java/org/apache/cassandra/db/SystemKeyspaceMigrator41.java
##########
@@ -0,0 +1,179 @@
+/*
+ * 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.db;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Optional;
+import java.util.function.Function;
+
+import com.google.common.annotations.VisibleForTesting;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.cql3.QueryProcessor;
+import org.apache.cassandra.cql3.UntypedResultSet;
+import org.apache.cassandra.db.marshal.BytesType;
+import org.apache.cassandra.db.marshal.Int32Type;
+import org.apache.cassandra.db.marshal.UTF8Type;
+import org.apache.cassandra.db.marshal.UUIDType;
+import org.apache.cassandra.io.sstable.SequenceBasedSSTableUniqueIdentifier;
+import org.apache.cassandra.schema.SchemaConstants;
+
+/**
+ * Migrate 3.0 versions of some tables to 4.1. In this case it's just extra columns and some keys
+ * that are changed.
+ * <p>
+ * Can't just add the additional columns because they are primary key columns and C* doesn't support changing
+ * key columns even if it's just clustering columns.
+ */
+public class SystemKeyspaceMigrator41
+{
+    private static final Logger logger = LoggerFactory.getLogger(SystemKeyspaceMigrator41.class);
+
+    private SystemKeyspaceMigrator41()
+    {
+    }
+
+    public static void migrate()
+    {
+        migratePeers();
+        migratePeerEvents();
+        migrateTransferredRanges();
+        migrateAvailableRanges();
+        migrateSSTableActivity();
+    }
+
+    @VisibleForTesting
+    static void migratePeers()
+    {
+        migrateTable(SystemKeyspace.LEGACY_PEERS,
+                     SystemKeyspace.PEERS_V2,
+                     new String[]{ "peer",
+                                   "peer_port",
+                                   "data_center",
+                                   "host_id",
+                                   "preferred_ip",
+                                   "preferred_port",
+                                   "rack",
+                                   "release_version",
+                                   "native_address",
+                                   "native_port",
+                                   "schema_version",
+                                   "tokens" },
+                     row -> Collections.singletonList(new Object[]{ row.has("peer") ? row.getInetAddress("peer") : null,
+                                                                    DatabaseDescriptor.getStoragePort(),
+                                                                    row.has("data_center") ? row.getString("data_center") : null,
+                                                                    row.has("host_id") ? row.getUUID("host_id") : null,
+                                                                    row.has("preferred_ip") ? row.getInetAddress("preferred_ip") : null,
+                                                                    DatabaseDescriptor.getStoragePort(),
+                                                                    row.has("rack") ? row.getString("rack") : null,
+                                                                    row.has("release_version") ? row.getString("release_version") : null,
+                                                                    row.has("rpc_address") ? row.getInetAddress("rpc_address") : null,
+                                                                    DatabaseDescriptor.getNativeTransportPort(),
+                                                                    row.has("schema_version") ? row.getUUID("schema_version") : null,
+                                                                    row.has("tokens") ? row.getSet("tokens", UTF8Type.instance) : null }));
+    }
+
+    @VisibleForTesting
+    static void migratePeerEvents()
+    {
+        migrateTable(SystemKeyspace.LEGACY_PEER_EVENTS,
+                     SystemKeyspace.PEER_EVENTS_V2,
+                     new String[]{ "peer",
+                                   "peer_port",
+                                   "hints_dropped" },
+                     row -> Collections.singletonList(
+                     new Object[]{ row.has("peer") ? row.getInetAddress("peer") : null,
+                                   DatabaseDescriptor.getStoragePort(),
+                                   row.has("hints_dropped") ? row.getMap("hints_dropped", UUIDType.instance, Int32Type.instance) : null }
+                     ));
+    }
+
+    @VisibleForTesting
+    static void migrateTransferredRanges()
+    {
+        migrateTable(SystemKeyspace.LEGACY_TRANSFERRED_RANGES,
+                     SystemKeyspace.TRANSFERRED_RANGES_V2,
+                     new String[]{ "operation", "peer", "peer_port", "keyspace_name", "ranges" },
+                     row -> Collections.singletonList(new Object[]{ row.has("operation") ? row.getString("operation") : null,
+                                                                    row.has("peer") ? row.getInetAddress("peer") : null,
+                                                                    DatabaseDescriptor.getStoragePort(),
+                                                                    row.has("keyspace_name") ? row.getString("keyspace_name") : null,
+                                                                    row.has("ranges") ? row.getSet("ranges", BytesType.instance) : null }));
+    }
+
+    @VisibleForTesting
+    static void migrateAvailableRanges()
+    {
+        migrateTable(SystemKeyspace.LEGACY_AVAILABLE_RANGES,
+                     SystemKeyspace.AVAILABLE_RANGES_V2,
+                     new String[]{ "keyspace_name", "full_ranges", "transient_ranges" },
+                     row -> Collections.singletonList(new Object[]{ row.getString("keyspace_name"),
+                                                                    Optional.ofNullable(row.getSet("ranges", BytesType.instance)).orElse(Collections.emptySet()),
+                                                                    Collections.emptySet() }));
+    }
+
+    @VisibleForTesting
+    static void migrateSSTableActivity()

Review comment:
       Any plan to test that scenario?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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