Skip to content

Commit

Permalink
Add BrokerSetAwareGoal (#1809)
Browse files Browse the repository at this point in the history
  • Loading branch information
mohitpali authored Jul 11, 2022
1 parent ee241b3 commit 3f379ef
Show file tree
Hide file tree
Showing 43 changed files with 2,757 additions and 114 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ project(':cruise-control') {
implementation 'io.swagger.parser.v3:swagger-parser-v3:2.0.30'
implementation 'io.github.classgraph:classgraph:4.8.141'
implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation 'com.google.guava:guava:31.1-jre'
// Temporary pin for vulnerability
implementation 'com.fasterxml.jackson.core:jackson-databind:2.12.6.1'

Expand Down
1 change: 1 addition & 0 deletions checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
<suppressions>
<suppress checks="RegexpHeader" files="com[\\/]linkedin[\\/]kafka[\\/]cruisecontrol[\\/]testutils"/>
<suppress checks="MemberName" files="BrokerCapacityConfigFileResolver.java"/>
<suppress checks="MemberName" files="BrokerSetFileResolver.java"/>
</suppressions>
9 changes: 9 additions & 0 deletions config/brokerSets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"brokerSets":[
{
"brokerSetId": "brokerSet0",
"brokerIds": [0],
"doc": "This block contains broker ids that belong to BrokerSet 0"
}
]
}
2 changes: 1 addition & 1 deletion config/cruisecontrol.properties
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ capacity.config.file=config/capacityJBOD.json
default.goals=com.linkedin.kafka.cruisecontrol.analyzer.goals.RackAwareGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.ReplicaCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.DiskCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.NetworkInboundCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.NetworkOutboundCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.CpuCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.ReplicaDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.PotentialNwOutGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.DiskUsageDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.NetworkInboundUsageDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.NetworkOutboundUsageDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.CpuUsageDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.TopicReplicaDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.LeaderReplicaDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.LeaderBytesInDistributionGoal

# The list of supported goals
goals=com.linkedin.kafka.cruisecontrol.analyzer.goals.RackAwareGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.RackAwareDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.ReplicaCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.DiskCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.NetworkInboundCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.NetworkOutboundCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.CpuCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.ReplicaDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.PotentialNwOutGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.DiskUsageDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.NetworkInboundUsageDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.NetworkOutboundUsageDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.CpuUsageDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.TopicReplicaDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.LeaderReplicaDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.LeaderBytesInDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.kafkaassigner.KafkaAssignerDiskUsageDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.kafkaassigner.KafkaAssignerEvenRackAwareGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.PreferredLeaderElectionGoal
goals=com.linkedin.kafka.cruisecontrol.analyzer.goals.BrokerSetAwareGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.RackAwareGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.RackAwareDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.ReplicaCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.DiskCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.NetworkInboundCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.NetworkOutboundCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.CpuCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.ReplicaDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.PotentialNwOutGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.DiskUsageDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.NetworkInboundUsageDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.NetworkOutboundUsageDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.CpuUsageDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.TopicReplicaDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.LeaderReplicaDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.LeaderBytesInDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.kafkaassigner.KafkaAssignerDiskUsageDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.kafkaassigner.KafkaAssignerEvenRackAwareGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.PreferredLeaderElectionGoal

# The list of supported intra-broker goals
intra.broker.goals=com.linkedin.kafka.cruisecontrol.analyzer.goals.IntraBrokerDiskCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.IntraBrokerDiskUsageDistributionGoal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
package com.linkedin.kafka.cruisecontrol.analyzer;

import com.linkedin.kafka.cruisecontrol.common.Resource;
import com.linkedin.kafka.cruisecontrol.config.BrokerSetResolver;
import com.linkedin.kafka.cruisecontrol.config.KafkaCruiseControlConfig;
import com.linkedin.kafka.cruisecontrol.config.ReplicaToBrokerSetMappingPolicy;
import com.linkedin.kafka.cruisecontrol.config.constants.AnalyzerConfig;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -34,6 +36,8 @@ public class BalancingConstraint {
private final Pattern _topicsWithMinLeadersPerBrokerPattern;
private final int _minTopicLeadersPerBroker;
private final long _fastModePerBrokerMoveTimeoutMs;
private final BrokerSetResolver _brokerSetResolver;
private final ReplicaToBrokerSetMappingPolicy _replicaToBrokerSetMappingPolicy;

/**
* Constructor for Balancing Constraint.
Expand Down Expand Up @@ -79,6 +83,11 @@ public BalancingConstraint(KafkaCruiseControlConfig config) {
_minTopicLeadersPerBroker = config.getInt(AnalyzerConfig.MIN_TOPIC_LEADERS_PER_BROKER_CONFIG);
// Set default value for the per broker move timeout in fast mode in milliseconds
_fastModePerBrokerMoveTimeoutMs = config.getLong(AnalyzerConfig.FAST_MODE_PER_BROKER_MOVE_TIMEOUT_MS_CONFIG);
// BrokerSet Data resolver class
_brokerSetResolver = config.getConfiguredInstance(AnalyzerConfig.BROKER_SET_RESOLVER_CLASS_CONFIG, BrokerSetResolver.class);
// Replica to Broker Set mapping policy class
_replicaToBrokerSetMappingPolicy = config.getConfiguredInstance(AnalyzerConfig.REPLICA_TO_BROKER_SET_MAPPING_POLICY_CLASS_CONFIG,
ReplicaToBrokerSetMappingPolicy.class);
}

Properties setProps(Properties props) {
Expand Down Expand Up @@ -110,6 +119,8 @@ Properties setProps(Properties props) {
props.put(AnalyzerConfig.TOPICS_WITH_MIN_LEADERS_PER_BROKER_CONFIG, _topicsWithMinLeadersPerBrokerPattern.pattern());
props.put(AnalyzerConfig.MIN_TOPIC_LEADERS_PER_BROKER_CONFIG, Integer.toString(_minTopicLeadersPerBroker));
props.put(AnalyzerConfig.FAST_MODE_PER_BROKER_MOVE_TIMEOUT_MS_CONFIG, Long.toString(_fastModePerBrokerMoveTimeoutMs));
props.put(AnalyzerConfig.BROKER_SET_RESOLVER_CLASS_CONFIG, _brokerSetResolver.getClass().getName());
props.put(AnalyzerConfig.REPLICA_TO_BROKER_SET_MAPPING_POLICY_CLASS_CONFIG, _replicaToBrokerSetMappingPolicy.getClass().getName());
return props;
}

Expand Down Expand Up @@ -242,6 +253,20 @@ public long fastModePerBrokerMoveTimeoutMs() {
return _fastModePerBrokerMoveTimeoutMs;
}

/**
* @return The Broker Set Resolver.
*/
public BrokerSetResolver brokerSetResolver() {
return _brokerSetResolver;
}

/**
* @return The Replica to Broker Set mapping policy.
*/
public ReplicaToBrokerSetMappingPolicy replicaToBrokerSetMappingPolicy() {
return _replicaToBrokerSetMappingPolicy;
}

/**
* Set resource balance percentage for the given resource.
*
Expand Down Expand Up @@ -302,14 +327,17 @@ public String toString() {
+ "topicReplicaBalancePercentage=%.4f,topicReplicaBalanceGap=[%d,%d],"
+ "goalViolationDistributionThresholdMultiplier=%.4f,"
+ "topicsWithMinLeadersPerBrokerPattern=%s,"
+ "minTopicLeadersPerBroker=%d,fastModePerBrokerMoveTimeoutMs=%d]",
+ "minTopicLeadersPerBroker=%d,fastModePerBrokerMoveTimeoutMs=%d,"
+ "brokerSetDataStore=%s,"
+ "replicaToBrokerSetMappingPolicy=%s]",
_resourceBalancePercentage.get(Resource.CPU), _resourceBalancePercentage.get(Resource.DISK),
_resourceBalancePercentage.get(Resource.NW_IN), _resourceBalancePercentage.get(Resource.NW_OUT),
_capacityThreshold.get(Resource.CPU), _capacityThreshold.get(Resource.DISK),
_capacityThreshold.get(Resource.NW_IN), _capacityThreshold.get(Resource.NW_OUT),
_maxReplicasPerBroker, _replicaBalancePercentage, _leaderReplicaBalancePercentage,
_topicReplicaBalancePercentage, _topicReplicaBalanceMinGap, _topicReplicaBalanceMaxGap,
_goalViolationDistributionThresholdMultiplier, _topicsWithMinLeadersPerBrokerPattern.pattern(),
_minTopicLeadersPerBroker, _fastModePerBrokerMoveTimeoutMs);
_minTopicLeadersPerBroker, _fastModePerBrokerMoveTimeoutMs, _brokerSetResolver.getClass().getName(),
_replicaToBrokerSetMappingPolicy.getClass().getName());
}
}
Loading

0 comments on commit 3f379ef

Please sign in to comment.