You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by "djatnieks (via GitHub)" <gi...@apache.org> on 2023/07/06 03:12:52 UTC
[GitHub] [cassandra] djatnieks opened a new pull request, #2467: CASSANDRA-18617 Disable the deprecated keyspace/table thresholds and convert them to Guardrails
djatnieks opened a new pull request, #2467:
URL: https://github.com/apache/cassandra/pull/2467
Thanks for sending a pull request! Here are some tips if you're new here:
* Ensure you have added or run the [appropriate tests](https://cassandra.apache.org/_/development/testing.html) for your PR.
* Be sure to keep the PR description updated to reflect all changes.
* Write your PR title to summarize what this PR proposes.
* If possible, provide a concise example to reproduce the issue for a faster review.
* Read our [contributor guidelines](https://cassandra.apache.org/_/development/index.html)
* If you're making a documentation change, see our [guide to documentation contribution](https://cassandra.apache.org/_/development/documentation.html)
Commit messages should follow the following format:
```
<One sentence description, usually Jira title or CHANGES.txt summary>
<Optional lengthier description (context on patch)>
patch by <Authors>; reviewed by <Reviewers> for CASSANDRA-#####
Co-authored-by: Name1 <email1>
Co-authored-by: Name2 <email2>
```
The [Cassandra Jira](https://issues.apache.org/jira/projects/CASSANDRA/issues/)
--
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
[GitHub] [cassandra] djatnieks commented on a diff in pull request #2467: CASSANDRA-18617 Disable the deprecated keyspace/table thresholds and convert them to Guardrails
Posted by "djatnieks (via GitHub)" <gi...@apache.org>.
djatnieks commented on code in PR #2467:
URL: https://github.com/apache/cassandra/pull/2467#discussion_r1261617829
##########
test/unit/org/apache/cassandra/cql3/SystemKeyspaceTablesNamesTest.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.cql3;
+
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.cassandra.auth.AuthKeyspace;
+import org.apache.cassandra.db.SystemKeyspace;
+import org.apache.cassandra.schema.Schema;
+import org.apache.cassandra.schema.SchemaConstants;
+import org.apache.cassandra.schema.SchemaKeyspaceTables;
+import org.apache.cassandra.schema.SystemDistributedKeyspace;
+import org.apache.cassandra.tracing.TraceKeyspace;
+
+import static org.junit.Assert.assertTrue;
+
+public class SystemKeyspaceTablesNamesTest extends CQLTester
+{
+ @BeforeClass
+ public static void setUp()
+ {
+ // Needed for distributed keyspaces
+ requireNetwork();
+ }
+
+ @Test
+ public void testSystemKeyspaceTableNames()
+ {
+ Set<String> tables = Schema.instance.getKeyspaceMetadata(SchemaConstants.SYSTEM_KEYSPACE_NAME).tables
+ .stream().map(t -> t.name).collect(Collectors.toSet());
Review Comment:
Just wanted to mention I kept individual test methods for each keyspace - I thought about putting them all together, but I somewhat like that each gets checked independently.
--
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
[GitHub] [cassandra] djatnieks commented on a diff in pull request #2467: CASSANDRA-18617 Disable the deprecated keyspace/table thresholds and convert them to Guardrails
Posted by "djatnieks (via GitHub)" <gi...@apache.org>.
djatnieks commented on code in PR #2467:
URL: https://github.com/apache/cassandra/pull/2467#discussion_r1261611429
##########
src/java/org/apache/cassandra/service/StorageServiceMBean.java:
##########
@@ -1124,16 +1124,6 @@ public void enableAuditLog(String loggerName, String includedKeyspaces, String e
public boolean autoOptimisePreviewRepairStreams();
public void setAutoOptimisePreviewRepairStreams(boolean enabled);
- // warning thresholds will be replaced by equivalent guardrails
Review Comment:
Hmm, yes, I think you are right about that. I was thinking that legacy values from the config would have been converted already, and users would want to work with current guardrail values. But, as you point out, that changes the semantics of the api, and since we are leaving the api methods deprecated they should work the same.
--
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
[GitHub] [cassandra] djatnieks commented on a diff in pull request #2467: CASSANDRA-18617 Disable the deprecated keyspace/table thresholds and convert them to Guardrails
Posted by "djatnieks (via GitHub)" <gi...@apache.org>.
djatnieks commented on code in PR #2467:
URL: https://github.com/apache/cassandra/pull/2467#discussion_r1260334692
##########
test/unit/org/apache/cassandra/cql3/SystemKeyspaceTablesNamesTest.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.cql3;
+
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.cassandra.auth.AuthKeyspace;
+import org.apache.cassandra.db.SystemKeyspace;
+import org.apache.cassandra.schema.Schema;
+import org.apache.cassandra.schema.SchemaConstants;
+import org.apache.cassandra.schema.SchemaKeyspaceTables;
+import org.apache.cassandra.schema.SystemDistributedKeyspace;
+import org.apache.cassandra.tracing.TraceKeyspace;
+
+import static org.junit.Assert.assertTrue;
+
+public class SystemKeyspaceTablesNamesTest extends CQLTester
+{
+ @BeforeClass
+ public static void setUp()
+ {
+ // Needed for distributed keyspaces
+ requireNetwork();
+ }
+
+ @Test
+ public void testSystemKeyspaceTableNames()
+ {
+ Set<String> tables = Schema.instance.getKeyspaceMetadata(SchemaConstants.SYSTEM_KEYSPACE_NAME).tables
+ .stream().map(t -> t.name).collect(Collectors.toSet());
Review Comment:
Good idea ... and I think some additional refactoring will improve it some more.
--
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
[GitHub] [cassandra] djatnieks commented on a diff in pull request #2467: CASSANDRA-18617 Disable the deprecated keyspace/table thresholds and convert them to Guardrails
Posted by "djatnieks (via GitHub)" <gi...@apache.org>.
djatnieks commented on code in PR #2467:
URL: https://github.com/apache/cassandra/pull/2467#discussion_r1260340431
##########
src/java/org/apache/cassandra/service/StorageServiceMBean.java:
##########
@@ -1124,16 +1124,6 @@ public void enableAuditLog(String loggerName, String includedKeyspaces, String e
public boolean autoOptimisePreviewRepairStreams();
public void setAutoOptimisePreviewRepairStreams(boolean enabled);
- // warning thresholds will be replaced by equivalent guardrails
Review Comment:
Good point - I'll try doing that.
I guess they should be left `@Deprecated` since this maintains an existing api and is not meant to be an official guardrails api.
--
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
[GitHub] [cassandra] adelapena commented on a diff in pull request #2467: CASSANDRA-18617 Disable the deprecated keyspace/table thresholds and convert them to Guardrails
Posted by "adelapena (via GitHub)" <gi...@apache.org>.
adelapena commented on code in PR #2467:
URL: https://github.com/apache/cassandra/pull/2467#discussion_r1259477767
##########
test/unit/org/apache/cassandra/cql3/SystemKeyspaceTablesNamesTest.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.cql3;
+
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.cassandra.auth.AuthKeyspace;
+import org.apache.cassandra.db.SystemKeyspace;
+import org.apache.cassandra.schema.Schema;
+import org.apache.cassandra.schema.SchemaConstants;
+import org.apache.cassandra.schema.SchemaKeyspaceTables;
+import org.apache.cassandra.schema.SystemDistributedKeyspace;
+import org.apache.cassandra.tracing.TraceKeyspace;
+
+import static org.junit.Assert.assertTrue;
+
+public class SystemKeyspaceTablesNamesTest extends CQLTester
+{
+ @BeforeClass
+ public static void setUp()
+ {
+ // Needed for distributed keyspaces
+ requireNetwork();
+ }
+
+ @Test
+ public void testSystemKeyspaceTableNames()
+ {
+ Set<String> tables = Schema.instance.getKeyspaceMetadata(SchemaConstants.SYSTEM_KEYSPACE_NAME).tables
+ .stream().map(t -> t.name).collect(Collectors.toSet());
Review Comment:
This block is more or less repeated in all the tests, producing a warning about the chance of the `KeyspaceMetadata` being null. We could put it in a utility method:
```java
private static Set<String> tableNames(String keyspaceName)
{
KeyspaceMetadata keyspace = Schema.instance.getKeyspaceMetadata(keyspaceName);
assertNotNull(keyspace);
return keyspace.tables.stream().map(t -> t.name).collect(Collectors.toSet());
}
```
--
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
[GitHub] [cassandra] adelapena commented on a diff in pull request #2467: CASSANDRA-18617 Disable the deprecated keyspace/table thresholds and convert them to Guardrails
Posted by "adelapena (via GitHub)" <gi...@apache.org>.
adelapena commented on code in PR #2467:
URL: https://github.com/apache/cassandra/pull/2467#discussion_r1261057703
##########
src/java/org/apache/cassandra/service/StorageServiceMBean.java:
##########
@@ -1124,16 +1124,6 @@ public void enableAuditLog(String loggerName, String includedKeyspaces, String e
public boolean autoOptimisePreviewRepairStreams();
public void setAutoOptimisePreviewRepairStreams(boolean enabled);
- // warning thresholds will be replaced by equivalent guardrails
Review Comment:
I also think they should be left `@Deprecated`, since they are only for backward compatibility. If we directly translate the arguments of those methods to the guardrail thresholds we are changing their meaning, since they used to count system keyspace/tables.
I think the setter methods on `StorageService` should subtract the number of system keyspaces/tables. Conversely, the getters should add the number of system keyspaces/tables to the guardrail number. That way the MBean methods would behave the same way they used to, being a JMX version of the old config properties.
--
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
[GitHub] [cassandra] smiklosovic closed pull request #2467: CASSANDRA-18617 Disable the deprecated keyspace/table thresholds and convert them to Guardrails
Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic closed pull request #2467: CASSANDRA-18617 Disable the deprecated keyspace/table thresholds and convert them to Guardrails
URL: https://github.com/apache/cassandra/pull/2467
--
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
[GitHub] [cassandra] djatnieks commented on a diff in pull request #2467: CASSANDRA-18617 Disable the deprecated keyspace/table thresholds and convert them to Guardrails
Posted by "djatnieks (via GitHub)" <gi...@apache.org>.
djatnieks commented on code in PR #2467:
URL: https://github.com/apache/cassandra/pull/2467#discussion_r1260340431
##########
src/java/org/apache/cassandra/service/StorageServiceMBean.java:
##########
@@ -1124,16 +1124,6 @@ public void enableAuditLog(String loggerName, String includedKeyspaces, String e
public boolean autoOptimisePreviewRepairStreams();
public void setAutoOptimisePreviewRepairStreams(boolean enabled);
- // warning thresholds will be replaced by equivalent guardrails
Review Comment:
Good point - I'll try doing that
--
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
[GitHub] [cassandra] adelapena commented on a diff in pull request #2467: CASSANDRA-18617 Disable the deprecated keyspace/table thresholds and convert them to Guardrails
Posted by "adelapena (via GitHub)" <gi...@apache.org>.
adelapena commented on code in PR #2467:
URL: https://github.com/apache/cassandra/pull/2467#discussion_r1262340674
##########
test/unit/org/apache/cassandra/cql3/SystemKeyspaceTablesNamesTest.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.cql3;
+
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.cassandra.auth.AuthKeyspace;
+import org.apache.cassandra.db.SystemKeyspace;
+import org.apache.cassandra.schema.Schema;
+import org.apache.cassandra.schema.SchemaConstants;
+import org.apache.cassandra.schema.SchemaKeyspaceTables;
+import org.apache.cassandra.schema.SystemDistributedKeyspace;
+import org.apache.cassandra.tracing.TraceKeyspace;
+
+import static org.junit.Assert.assertTrue;
+
+public class SystemKeyspaceTablesNamesTest extends CQLTester
+{
+ @BeforeClass
+ public static void setUp()
+ {
+ // Needed for distributed keyspaces
+ requireNetwork();
+ }
+
+ @Test
+ public void testSystemKeyspaceTableNames()
+ {
+ Set<String> tables = Schema.instance.getKeyspaceMetadata(SchemaConstants.SYSTEM_KEYSPACE_NAME).tables
+ .stream().map(t -> t.name).collect(Collectors.toSet());
Review Comment:
It looks perfect to me 👍
##########
test/unit/org/apache/cassandra/cql3/SystemKeyspaceTablesNamesTest.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.cql3;
+
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.cassandra.auth.AuthKeyspace;
+import org.apache.cassandra.db.SystemKeyspace;
+import org.apache.cassandra.schema.Schema;
+import org.apache.cassandra.schema.SchemaConstants;
+import org.apache.cassandra.schema.SchemaKeyspaceTables;
+import org.apache.cassandra.schema.SystemDistributedKeyspace;
+import org.apache.cassandra.tracing.TraceKeyspace;
+
+import static org.junit.Assert.assertTrue;
+
+public class SystemKeyspaceTablesNamesTest extends CQLTester
+{
+ @BeforeClass
+ public static void setUp()
+ {
+ // Needed for distributed keyspaces
+ requireNetwork();
+ }
+
+ @Test
+ public void testSystemKeyspaceTableNames()
+ {
+ Set<String> tables = Schema.instance.getKeyspaceMetadata(SchemaConstants.SYSTEM_KEYSPACE_NAME).tables
+ .stream().map(t -> t.name).collect(Collectors.toSet());
Review Comment:
It looks perfect to me 👍
--
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
[GitHub] [cassandra] adelapena commented on a diff in pull request #2467: CASSANDRA-18617 Disable the deprecated keyspace/table thresholds and convert them to Guardrails
Posted by "adelapena (via GitHub)" <gi...@apache.org>.
adelapena commented on code in PR #2467:
URL: https://github.com/apache/cassandra/pull/2467#discussion_r1261062917
##########
test/unit/org/apache/cassandra/cql3/SystemKeyspaceTablesNamesTest.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.cql3;
+
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.cassandra.auth.AuthKeyspace;
+import org.apache.cassandra.db.SystemKeyspace;
+import org.apache.cassandra.schema.Schema;
+import org.apache.cassandra.schema.SchemaConstants;
+import org.apache.cassandra.schema.SchemaKeyspaceTables;
+import org.apache.cassandra.schema.SystemDistributedKeyspace;
+import org.apache.cassandra.tracing.TraceKeyspace;
+
+import static org.junit.Assert.assertTrue;
+
+public class SystemKeyspaceTablesNamesTest extends CQLTester
+{
+ @BeforeClass
+ public static void setUp()
+ {
+ // Needed for distributed keyspaces
+ requireNetwork();
+ }
+
+ @Test
+ public void testSystemKeyspaceTableNames()
+ {
+ Set<String> tables = Schema.instance.getKeyspaceMetadata(SchemaConstants.SYSTEM_KEYSPACE_NAME).tables
+ .stream().map(t -> t.name).collect(Collectors.toSet());
Review Comment:
The refactored test looks nice. Just a nit, `tablesFromSchema` could be inlined into `assertExpectedTablesInKeyspace`, and that one could be `static`:
```java
private static void assertExpectedTablesInKeyspace(String keyspaceName, String expectedTableSource, Set<String> expectedTables)
{
KeyspaceMetadata keyspace = Schema.instance.getKeyspaceMetadata(keyspaceName);
assertNotNull(keyspace);
Set<String> actualKeyspaceTables = keyspace.tables.stream().map(t -> t.name).collect(Collectors.toSet());
Sets.SetView<String> diff = Sets.difference(actualKeyspaceTables, expectedTables);
assertTrue(format("The following tables are missing from %s: %s", expectedTableSource, diff), diff.isEmpty());
diff = Sets.difference(expectedTables, actualKeyspaceTables);
assertTrue(format("The following tables are in %s but should not be: %s", expectedTableSource, diff), diff.isEmpty());
}
```
--
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
[GitHub] [cassandra] adelapena commented on a diff in pull request #2467: CASSANDRA-18617 Disable the deprecated keyspace/table thresholds and convert them to Guardrails
Posted by "adelapena (via GitHub)" <gi...@apache.org>.
adelapena commented on code in PR #2467:
URL: https://github.com/apache/cassandra/pull/2467#discussion_r1259477767
##########
test/unit/org/apache/cassandra/cql3/SystemKeyspaceTablesNamesTest.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.cql3;
+
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.cassandra.auth.AuthKeyspace;
+import org.apache.cassandra.db.SystemKeyspace;
+import org.apache.cassandra.schema.Schema;
+import org.apache.cassandra.schema.SchemaConstants;
+import org.apache.cassandra.schema.SchemaKeyspaceTables;
+import org.apache.cassandra.schema.SystemDistributedKeyspace;
+import org.apache.cassandra.tracing.TraceKeyspace;
+
+import static org.junit.Assert.assertTrue;
+
+public class SystemKeyspaceTablesNamesTest extends CQLTester
+{
+ @BeforeClass
+ public static void setUp()
+ {
+ // Needed for distributed keyspaces
+ requireNetwork();
+ }
+
+ @Test
+ public void testSystemKeyspaceTableNames()
+ {
+ Set<String> tables = Schema.instance.getKeyspaceMetadata(SchemaConstants.SYSTEM_KEYSPACE_NAME).tables
+ .stream().map(t -> t.name).collect(Collectors.toSet());
Review Comment:
This block is more or less repeated in all the tests, producing a warning about the chance of the `KeyspaceMetadata` being null. We could put it a utility method:
```java
private static Set<String> tableNames(String keyspaceName)
{
KeyspaceMetadata keyspace = Schema.instance.getKeyspaceMetadata(keyspaceName);
assertNotNull(keyspace);
return keyspace.tables.stream().map(t -> t.name).collect(Collectors.toSet());
}
```
##########
src/java/org/apache/cassandra/service/StorageServiceMBean.java:
##########
@@ -1124,16 +1124,6 @@ public void enableAuditLog(String loggerName, String includedKeyspaces, String e
public boolean autoOptimisePreviewRepairStreams();
public void setAutoOptimisePreviewRepairStreams(boolean enabled);
- // warning thresholds will be replaced by equivalent guardrails
Review Comment:
I think we should keep the JMX methods, since it's a public API. We could change their implementation in `StorageService` to use the getters and setters in `Guardrails.instance` instead of using `DatabaseDescriptor`.
##########
src/java/org/apache/cassandra/schema/SchemaConstants.java:
##########
@@ -126,4 +129,23 @@ public static Set<String> getSystemKeyspaces()
{
return Sets.union(Sets.union(LOCAL_SYSTEM_KEYSPACE_NAMES, REPLICATED_SYSTEM_KEYSPACE_NAMES), VIRTUAL_SYSTEM_KEYSPACE_NAMES);
}
+
+ /**
+ * Returns the set of local and replicated system keyspace names
+ * @return all local and replicated system keyspace names
+ */
+ public static Set<String> getLocalAndReplicatedSystemKeyspaceNames()
+ {
+ return Sets.union(LOCAL_SYSTEM_KEYSPACE_NAMES, REPLICATED_SYSTEM_KEYSPACE_NAMES);
+ }
+
+ /**
+ * Returns the set of all local and replicated system table names
+ * @return all local and replicated system table names
+ */
+ public static Set<String> getLocalAndReplicatedSystemTableNames()
+ {
+ return Sets.union(Sets.union(SystemKeyspace.TABLE_NAMES, ImmutableSet.copyOf(SchemaKeyspaceTables.ALL)),
Review Comment:
Nit: The four nested usages of `Sets.union` aren't probably the easier thing to read. Perhaps we could use instead something like:
```java
return ImmutableSet.<String>builder()
.addAll(SystemKeyspace.TABLE_NAMES)
.addAll(SchemaKeyspaceTables.ALL)
.addAll(TraceKeyspace.TABLE_NAMES)
.addAll(AuthKeyspace.TABLE_NAMES)
.addAll(SystemDistributedKeyspace.TABLE_NAMES)
.build();
```
##########
test/unit/org/apache/cassandra/cql3/SystemKeyspaceTablesNamesTest.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.cql3;
+
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.cassandra.auth.AuthKeyspace;
+import org.apache.cassandra.db.SystemKeyspace;
+import org.apache.cassandra.schema.Schema;
+import org.apache.cassandra.schema.SchemaConstants;
+import org.apache.cassandra.schema.SchemaKeyspaceTables;
+import org.apache.cassandra.schema.SystemDistributedKeyspace;
+import org.apache.cassandra.tracing.TraceKeyspace;
+
+import static org.junit.Assert.assertTrue;
+
+public class SystemKeyspaceTablesNamesTest extends CQLTester
Review Comment:
It's nice to have thins test :)
--
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