use of com.linkedin.cruisecontrol.detector.metricanomaly.MetricAnomaly in project cruise-control by linkedin.
the class SlowBrokerFinder method createSlowBrokerAnomalies.
private Set<MetricAnomaly<BrokerEntity>> createSlowBrokerAnomalies(Set<BrokerEntity> detectedMetricAnomalies, int clusterSize) {
Set<MetricAnomaly<BrokerEntity>> detectedSlowBrokers = new HashSet<>();
Map<BrokerEntity, Long> brokersToDemote = new HashMap<>();
Map<BrokerEntity, Long> brokersToRemove = new HashMap<>();
for (BrokerEntity broker : detectedMetricAnomalies) {
// Report anomaly if slowness score reaches threshold for broker decommission/demotion.
int slownessScore = _brokerSlownessScore.get(broker);
if (slownessScore == _slowBrokerDecommissionScore) {
brokersToRemove.put(broker, _detectedSlowBrokers.get(broker));
} else if (slownessScore >= _slowBrokerDemotionScore) {
brokersToDemote.put(broker, _detectedSlowBrokers.get(broker));
}
}
// Update number of slow brokers with the given type.
int numBrokersToDemoteOrRemove = brokersToDemote.size() + brokersToRemove.size();
_numSlowBrokersByType.put(MetricAnomalyType.PERSISTENT, brokersToRemove.size());
_numSlowBrokersByType.put(MetricAnomalyType.RECENT, brokersToDemote.size());
_numSlowBrokersByType.put(MetricAnomalyType.SUSPECT, _detectedSlowBrokers.size() - numBrokersToDemoteOrRemove);
// Otherwise report anomaly with brokers to be removed/demoted.
if (numBrokersToDemoteOrRemove > clusterSize * _selfHealingUnfixableRatio) {
brokersToRemove.forEach(brokersToDemote::put);
detectedSlowBrokers.add(createSlowBrokersAnomaly(brokersToDemote, false, false));
} else {
if (!brokersToDemote.isEmpty()) {
detectedSlowBrokers.add(createSlowBrokersAnomaly(brokersToDemote, true, false));
}
if (!brokersToRemove.isEmpty()) {
detectedSlowBrokers.add(createSlowBrokersAnomaly(brokersToRemove, _slowBrokerRemovalEnabled, true));
}
}
return detectedSlowBrokers;
}
Aggregations