smiklosovic commented on code in PR #4950:
URL: https://github.com/apache/cassandra/pull/4950#discussion_r3616855953
##########
src/java/org/apache/cassandra/tcm/CMSOperations.java:
##########
@@ -162,13 +163,38 @@ public void resumeReconfigureCms()
@Override
public void reconfigureCMS(int rf)
{
- cms.reconfigureCMS(ReplicationParams.simpleMeta(rf,
ClusterMetadata.current().directory.knownDatacenters()));
+ ReplicationParams params = ReplicationParams.simpleMeta(rf,
ClusterMetadata.current().directory.knownDatacenters());
+ guardMinimumCmsSize(params);
+ cms.reconfigureCMS(params);
}
@Override
public void reconfigureCMS(Map<String, Integer> rf)
{
- cms.reconfigureCMS(ReplicationParams.ntsMeta(rf));
+ ReplicationParams params = ReplicationParams.ntsMeta(rf);
+ guardMinimumCmsSize(params);
+ cms.reconfigureCMS(params);
+ }
+
+ /**
+ * Enforces the minimum CMS size guardrail against an operator-requested
reconfiguration. This is only applied to
+ * explicit reconfigure requests (nodetool / JMX), not to the automatic
reconfiguration that happens on topology
+ * changes, which reuses the already-committed replication params.
+ */
+ private void guardMinimumCmsSize(ReplicationParams params)
+ {
+ ClusterMetadata metadata = ClusterMetadata.current();
+ int minCmsSize =
DatabaseDescriptor.getGuardrailsConfig().getMinimumCmsSizeFailThreshold();
Review Comment:
`Interesting usage. I would use MinThreshold API here and called
`Guardrails.instance.minimumCmsSize.failValue|warnValue` instead. We would then
introduced `CMSSizeThreshold` guardrail class extending `MinThreshold` with
overridden methods.
Or at least getting `int minCmsSize` from `Guardrails.instance` +
appropriate getter if above is overkill.
--
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]