public PartitionMetric(RawMetricType rawMetricType, long time, int brokerId, String topic, int partition, double value) { super(rawMetricType, time, brokerId, value); if (rawMetricType.metricScope() != RawMetricType.MetricScope.PARTITION) { throw new IllegalArgumentException(String.format("Cannot construct a PartitionMetric for %s whose scope is %s", rawMetricType, rawMetricType.metricScope())); } _topic = topic; _partition = partition; }
public BrokerMetric(RawMetricType rawMetricType, long time, int brokerId, double value) { super(rawMetricType, time, brokerId, value); if (rawMetricType.metricScope() != RawMetricType.MetricScope.BROKER) { throw new IllegalArgumentException(String.format("Cannot construct a BrokerMetric for %s whose scope is %s", rawMetricType, rawMetricType.metricScope())); } }
private void checkMetricScope(RawMetricType rawMetricType, MetricScope expectedMetricScope) { if (rawMetricType.metricScope() != expectedMetricScope) { throw new IllegalArgumentException(String.format("Metric scope %s does not match the expected metric scope %s", rawMetricType.metricScope(), expectedMetricScope)); } }
public TopicMetric(RawMetricType rawMetricType, long time, int brokerId, String topic, double value) { super(rawMetricType, time, brokerId, value); if (rawMetricType.metricScope() != RawMetricType.MetricScope.TOPIC) { throw new IllegalArgumentException(String.format("Cannot construct a TopicMetric for %s whose scope is %s", rawMetricType, rawMetricType.metricScope())); } _topic = topic; }
private static List<RawMetricType> buildMetricTypeList(MetricScope metricScope) { List<RawMetricType> brokerMetricTypes = new ArrayList<>(); for (RawMetricType type : RawMetricType.values()) { if (type.metricScope() == metricScope) { brokerMetricTypes.add(type); } } return brokerMetricTypes; } }
private static SortedMap<Byte, Set<RawMetricType>> buildBrokerMetricTypesDiffByVersion() { SortedMap<Byte, Set<RawMetricType>> buildBrokerMetricTypesDiffByVersion = new TreeMap<>(); for (RawMetricType type : RawMetricType.values()) { if (type.metricScope() == BROKER) { buildBrokerMetricTypesDiffByVersion.computeIfAbsent(type.supportedVersionSince(), t -> new HashSet<>()).add(type); } } return buildBrokerMetricTypesDiffByVersion; }
private void recordMetric(CruiseControlMetric ccm) { RawMetricType rawMetricType = ccm.rawMetricType(); switch (rawMetricType.metricScope()) { case BROKER: _brokerMetrics.recordCruiseControlMetric(ccm); break; case TOPIC: TopicMetric tm = (TopicMetric) ccm; _dotHandledTopicMetrics.computeIfAbsent(tm.topic(), t -> new RawMetricsHolder()) .recordCruiseControlMetric(ccm); break; case PARTITION: PartitionMetric pm = (PartitionMetric) ccm; _dotHandledPartitionMetrics.computeIfAbsent(new TopicPartition(pm.topic(), pm.partition()), tp -> new RawMetricsHolder()) .recordCruiseControlMetric(ccm); _dotHandledTopicsWithPartitionSizeReported.add(pm.topic()); break; default: throw new IllegalStateException(String.format("Should never be here. Unrecognized metric scope %s", rawMetricType.metricScope())); } }
public TopicMetric(RawMetricType rawMetricType, long time, int brokerId, String topic, double value) { super(rawMetricType, time, brokerId, value); if (rawMetricType.metricScope() != RawMetricType.MetricScope.TOPIC) { throw new IllegalArgumentException(String.format("Cannot construct a TopicMetric for %s whose scope is %s", rawMetricType, rawMetricType.metricScope())); } _topic = topic; }
public BrokerMetric(RawMetricType rawMetricType, long time, int brokerId, double value) { super(rawMetricType, time, brokerId, value); if (rawMetricType.metricScope() != RawMetricType.MetricScope.BROKER) { throw new IllegalArgumentException(String.format("Cannot construct a BrokerMetric for %s whose scope is %s", rawMetricType, rawMetricType.metricScope())); } }
public PartitionMetric(RawMetricType rawMetricType, long time, int brokerId, String topic, int partition, double value) { super(rawMetricType, time, brokerId, value); if (rawMetricType.metricScope() != RawMetricType.MetricScope.PARTITION) { throw new IllegalArgumentException(String.format("Cannot construct a PartitionMetric for %s whose scope is %s", rawMetricType, rawMetricType.metricScope())); } _topic = topic; _partition = partition; }
private static List<RawMetricType> buildMetricTypeList(MetricScope metricScope) { List<RawMetricType> brokerMetricTypes = new ArrayList<>(); for (RawMetricType type : RawMetricType.values()) { if (type.metricScope() == metricScope) { brokerMetricTypes.add(type); } } return brokerMetricTypes; } }
private static SortedMap<Byte, Set<RawMetricType>> buildBrokerMetricTypesDiffByVersion() { SortedMap<Byte, Set<RawMetricType>> buildBrokerMetricTypesDiffByVersion = new TreeMap<>(); for (RawMetricType type : RawMetricType.values()) { if (type.metricScope() == BROKER) { buildBrokerMetricTypesDiffByVersion.computeIfAbsent(type.supportedVersionSince(), t -> new HashSet<>()).add(type); } } return buildBrokerMetricTypesDiffByVersion; }