This is an automated email from the ASF dual-hosted git repository. bereng pushed a commit to branch cassandra-4.0 in repository https://gitbox.apache.org/repos/asf/cassandra.git
commit f80b177f6f615724c445ed16d2b0cb7b48461375 Merge: 433274b 23b61a5 Author: Bereng <berenguerbl...@gmail.com> AuthorDate: Thu Aug 19 07:36:07 2021 +0200 Merge branch 'cassandra-3.11' into cassandra-4.0 src/java/org/apache/cassandra/schema/SchemaKeyspace.java | 4 +--- .../org/apache/cassandra/schema/SchemaKeyspaceTest.java | 13 +++++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --cc src/java/org/apache/cassandra/schema/SchemaKeyspace.java index 65e9adb,68c0b07..e8c22b1 --- a/src/java/org/apache/cassandra/schema/SchemaKeyspace.java +++ b/src/java/org/apache/cassandra/schema/SchemaKeyspace.java @@@ -39,12 -41,10 +39,11 @@@ import org.apache.cassandra.db.filter.C import org.apache.cassandra.db.marshal.*; import org.apache.cassandra.db.partitions.*; import org.apache.cassandra.db.rows.*; -import org.apache.cassandra.db.filter.ColumnFilter; -import org.apache.cassandra.db.view.View; -import org.apache.cassandra.exceptions.ConfigurationException; import org.apache.cassandra.exceptions.InvalidRequestException; - import org.apache.cassandra.exceptions.StartupException; +import org.apache.cassandra.service.reads.SpeculativeRetryPolicy; +import org.apache.cassandra.schema.ColumnMetadata.ClusteringOrder; +import org.apache.cassandra.schema.Keyspaces.KeyspacesDiff; +import org.apache.cassandra.service.reads.repair.ReadRepairStrategy; import org.apache.cassandra.transport.ProtocolVersion; import org.apache.cassandra.utils.ByteBufferUtil; import org.apache.cassandra.utils.FBUtilities; @@@ -52,11 -53,9 +51,10 @@@ import static java.lang.String.format; import static java.util.stream.Collectors.toList; +import static java.util.stream.Collectors.toSet; + - import static org.apache.cassandra.cql3.ColumnIdentifier.maybeQuote; import static org.apache.cassandra.cql3.QueryProcessor.executeInternal; import static org.apache.cassandra.cql3.QueryProcessor.executeOnceInternal; -import static org.apache.cassandra.schema.CQLTypeParser.parse; /** * system_schema.* tables and methods for manipulating them. @@@ -390,12 -377,12 +388,12 @@@ public final class SchemaKeyspac private static ReadCommand getReadCommandForTableSchema(String schemaTableName) { ColumnFamilyStore cfs = getSchemaCFS(schemaTableName); - return PartitionRangeReadCommand.allDataRead(cfs.metadata, FBUtilities.nowInSeconds()); + return PartitionRangeReadCommand.allDataRead(cfs.metadata(), FBUtilities.nowInSeconds()); } - static Collection<Mutation> convertSchemaToMutations() - public static synchronized Collection<Mutation> convertSchemaToMutations() ++ static synchronized Collection<Mutation> convertSchemaToMutations() { - Map<DecoratedKey, Mutation> mutationMap = new HashMap<>(); + Map<DecoratedKey, Mutation.PartitionUpdateCollector> mutationMap = new HashMap<>(); for (String table : ALL) convertSchemaToMutations(mutationMap, table); diff --cc test/unit/org/apache/cassandra/schema/SchemaKeyspaceTest.java index bf62203,19f06e5..c0c56aa --- a/test/unit/org/apache/cassandra/schema/SchemaKeyspaceTest.java +++ b/test/unit/org/apache/cassandra/schema/SchemaKeyspaceTest.java @@@ -19,10 -19,16 +19,12 @@@ package org.apache.cassandra.schema; import java.io.IOException; + import java.lang.reflect.Method; + import java.lang.reflect.Modifier; import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Set; -import java.util.UUID; import com.google.common.collect.ImmutableMap; @@@ -61,7 -94,55 +63,18 @@@ public class SchemaKeyspaceTes SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD1)); } + /** See CASSANDRA-16856. Make sure schema pulls are synchronized to prevent concurrent schema pull/writes + * + * @throws Exception + */ + @Test + public void testSchemaPullSynchoricity() throws Exception + { + Method method = SchemaKeyspace.class.getDeclaredMethod("convertSchemaToMutations"); + assertTrue(Modifier.isSynchronized(method.getModifiers())); + } + @Test - public void testThriftConversion() throws Exception - { - CfDef cfDef = new CfDef().setDefault_validation_class(AsciiType.class.getCanonicalName()) - .setComment("Test comment") - .setColumn_metadata(columnDefs) - .setKeyspace(KEYSPACE1) - .setName(CF_STANDARD1); - - // convert Thrift to CFMetaData - CFMetaData cfMetaData = ThriftConversion.fromThrift(cfDef); - - CfDef thriftCfDef = new CfDef(); - thriftCfDef.keyspace = KEYSPACE1; - thriftCfDef.name = CF_STANDARD1; - thriftCfDef.default_validation_class = cfDef.default_validation_class; - thriftCfDef.comment = cfDef.comment; - thriftCfDef.column_metadata = new ArrayList<>(); - for (ColumnDef columnDef : columnDefs) - { - ColumnDef c = new ColumnDef(); - c.name = ByteBufferUtil.clone(columnDef.name); - c.validation_class = columnDef.getValidation_class(); - c.index_name = columnDef.getIndex_name(); - c.index_type = IndexType.KEYS; - thriftCfDef.column_metadata.add(c); - } - - CfDef converted = ThriftConversion.toThrift(cfMetaData); - - assertEquals(thriftCfDef.keyspace, converted.keyspace); - assertEquals(thriftCfDef.name, converted.name); - assertEquals(thriftCfDef.default_validation_class, converted.default_validation_class); - assertEquals(thriftCfDef.comment, converted.comment); - assertEquals(new HashSet<>(thriftCfDef.column_metadata), new HashSet<>(converted.column_metadata)); - } - - @Test public void testConversionsInverses() throws Exception { for (String keyspaceName : Schema.instance.getNonSystemKeyspaces()) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org