alanwang67 commented on code in PR #4476:
URL: https://github.com/apache/cassandra/pull/4476#discussion_r2632724761


##########
test/distributed/org/apache/cassandra/distributed/test/ColumnFamilyStoreMBeansTest.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.distributed.test;
+
+import org.junit.*;
+
+import org.apache.cassandra.db.ColumnFamilyStore;
+import org.apache.cassandra.db.Keyspace;
+import org.apache.cassandra.distributed.Cluster;
+
+import java.io.IOException;
+
+import static org.apache.cassandra.distributed.api.Feature.GOSSIP;
+import static org.apache.cassandra.distributed.api.Feature.NETWORK;
+
+public class ColumnFamilyStoreMBeansTest extends TestBaseImpl
+{
+    private static Cluster CLUSTER;
+
+    @BeforeClass
+    public static void setup() throws IOException
+    {
+        CLUSTER = init(Cluster.build(1).withConfig(c ->
+                        c.with(GOSSIP, NETWORK))
+                .start());
+
+        CLUSTER.schemaChange(withKeyspace("DROP KEYSPACE %s"));
+        CLUSTER.schemaChange(withKeyspace("CREATE KEYSPACE %s WITH replication 
= {'class': 'SimpleStrategy', 'replication_factor': 1}"));
+        CLUSTER.schemaChange(withKeyspace("CREATE TABLE %s.cf (k text, c1 
text, c2 text, PRIMARY KEY (k)) WITH compaction = {'class': 
'UnifiedCompactionStrategy', 'scaling_parameters': 'L10'}"));
+
+        for (int i = 0; i < 10000; i++)
+            CLUSTER.get(1).executeInternal(withKeyspace("INSERT INTO %s.cf (k, 
c1, c2) VALUES (?, 'value1', 'value2');"), Integer.toString(i));
+
+        CLUSTER.get(1).nodetool("flush");
+    }
+
+    @Test
+    public void testPerLevelAverageTokenSpace() throws Throwable
+    {
+        CLUSTER.get(1).runOnInstance(() -> {
+            ColumnFamilyStore cfs = 
Keyspace.open(KEYSPACE).getColumnFamilyStore("cf");
+            double[] perLevelAvgTokenSpace = cfs.getPerLevelAvgTokenSpace();
+            assert(perLevelAvgTokenSpace.length > 0);
+            for (int i = 0; i < perLevelAvgTokenSpace.length; i++)
+                Assert.assertTrue(perLevelAvgTokenSpace[i] > 0);
+        });
+    }
+
+    @Test
+    public void testGetPerLevelMaxDensityThreshold() throws Throwable
+    {
+        CLUSTER.get(1).runOnInstance(() -> {
+            ColumnFamilyStore cfs = 
Keyspace.open(KEYSPACE).getColumnFamilyStore("cf");
+            Assert.assertTrue(cfs.getPerLevelMaxDensityThreshold().length > 0);
+        });

Review Comment:
   My understanding is that the max density threshold in UCS is calculated 
dynamically based on some runtime values `double maxDensity = 
controller.getMaxLevelDensity(0, 
controller.getBaseSstableSize(controller.getFanout(0)) / 
shardManager.localSpaceCoverage());`. I think if I were to calculate and check 
that the two values correspond I would end up doing something similar to what 
is done in `getPerLevelMaxDensityThreshold`. 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to