mirror of https://github.com/apache/druid.git
Merge pull request #899 from metamx/fix-log
fix crazy amounts of logging when coordinator loses leadership
This commit is contained in:
commit
37e5678870
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package io.druid.server.coordinator.helper;
|
package io.druid.server.coordinator.helper;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.metamx.emitter.EmittingLogger;
|
import com.metamx.emitter.EmittingLogger;
|
||||||
import io.druid.metadata.MetadataRuleManager;
|
import io.druid.metadata.MetadataRuleManager;
|
||||||
import io.druid.server.coordinator.CoordinatorStats;
|
import io.druid.server.coordinator.CoordinatorStats;
|
||||||
|
@ -37,6 +38,7 @@ import java.util.List;
|
||||||
public class DruidCoordinatorRuleRunner implements DruidCoordinatorHelper
|
public class DruidCoordinatorRuleRunner implements DruidCoordinatorHelper
|
||||||
{
|
{
|
||||||
private static final EmittingLogger log = new EmittingLogger(DruidCoordinatorRuleRunner.class);
|
private static final EmittingLogger log = new EmittingLogger(DruidCoordinatorRuleRunner.class);
|
||||||
|
private static int MAX_MISSING_RULES = 10;
|
||||||
|
|
||||||
private final ReplicationThrottler replicatorThrottler;
|
private final ReplicationThrottler replicatorThrottler;
|
||||||
|
|
||||||
|
@ -87,6 +89,9 @@ public class DruidCoordinatorRuleRunner implements DruidCoordinatorHelper
|
||||||
// Run through all matched rules for available segments
|
// Run through all matched rules for available segments
|
||||||
DateTime now = new DateTime();
|
DateTime now = new DateTime();
|
||||||
MetadataRuleManager databaseRuleManager = paramsWithReplicationManager.getDatabaseRuleManager();
|
MetadataRuleManager databaseRuleManager = paramsWithReplicationManager.getDatabaseRuleManager();
|
||||||
|
|
||||||
|
final List<String> segmentsWithMissingRules = Lists.newArrayListWithCapacity(MAX_MISSING_RULES);
|
||||||
|
int missingRules = 0;
|
||||||
for (DataSegment segment : paramsWithReplicationManager.getAvailableSegments()) {
|
for (DataSegment segment : paramsWithReplicationManager.getAvailableSegments()) {
|
||||||
List<Rule> rules = databaseRuleManager.getRulesWithDefault(segment.getDataSource());
|
List<Rule> rules = databaseRuleManager.getRulesWithDefault(segment.getDataSource());
|
||||||
boolean foundMatchingRule = false;
|
boolean foundMatchingRule = false;
|
||||||
|
@ -99,11 +104,18 @@ public class DruidCoordinatorRuleRunner implements DruidCoordinatorHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!foundMatchingRule) {
|
if (!foundMatchingRule) {
|
||||||
log.makeAlert("Unable to find a matching rule!")
|
if (segmentsWithMissingRules.size() < MAX_MISSING_RULES) {
|
||||||
.addData("dataSource", segment.getDataSource())
|
segmentsWithMissingRules.add(segment.getIdentifier());
|
||||||
.addData("segment", segment.getIdentifier())
|
|
||||||
.emit();
|
|
||||||
}
|
}
|
||||||
|
missingRules++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!segmentsWithMissingRules.isEmpty()) {
|
||||||
|
log.makeAlert("Unable to find matching rules!")
|
||||||
|
.addData("segmentsWithMissingRulesCount", missingRules)
|
||||||
|
.addData("segmentsWithMissingRules", segmentsWithMissingRules)
|
||||||
|
.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
return paramsWithReplicationManager.buildFromExisting()
|
return paramsWithReplicationManager.buildFromExisting()
|
||||||
|
|
Loading…
Reference in New Issue