本文整理了Java中org.apache.kafka.common.Metric
类的一些代码示例,展示了Metric
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Metric
类的具体详情如下:
包路径:org.apache.kafka.common.Metric
类名称:Metric
[英]A metric tracked for monitoring purposes.
[中]为监视目的而跟踪的度量。
代码示例来源:origin: apache/flink
@Override
public Double getValue() {
return kafkaMetric.value();
}
}
代码示例来源:origin: apache/kafka
@Override
public void run() {
// Poll as fast as possible to reproduce ConcurrentModificationException
while (!doStop.get()) {
try {
int size = ((Double) metric.metricValue()).intValue();
observedSize.set(size);
} catch (Exception e) {
exceptionHolder.set(e);
return;
}
}
}
};
代码示例来源:origin: apache/flink
@Override
public Double getValue() {
return kafkaMetric.value();
}
代码示例来源:origin: apache/kafka
frequencies.record(config, i % 4 + 1, time.milliseconds());
assertEquals(0.25, (Double) metric1.metricValue(), DELTA);
assertEquals(0.25, (Double) metric2.metricValue(), DELTA);
assertEquals(0.25, (Double) metric3.metricValue(), DELTA);
assertEquals(0.25, (Double) metric4.metricValue(), DELTA);
frequencies.record(config, i % 2 + 1, time.milliseconds());
assertEquals(0.50, (Double) metric1.metricValue(), DELTA);
assertEquals(0.50, (Double) metric2.metricValue(), DELTA);
assertEquals(0.00, (Double) metric3.metricValue(), DELTA);
assertEquals(0.00, (Double) metric4.metricValue(), DELTA);
frequencies.record(config, 4.0, time.milliseconds());
assertEquals(0.25, (Double) metric1.metricValue(), DELTA);
assertEquals(0.25, (Double) metric2.metricValue(), DELTA);
assertEquals(0.00, (Double) metric3.metricValue(), DELTA);
assertEquals(0.50, (Double) metric4.metricValue(), DELTA);
代码示例来源:origin: apache/flink
@Override
public Double getValue() {
return kafkaMetric.value();
}
代码示例来源:origin: apache/kafka
sensor.record(i);
assertEquals(25, (Double) p25.metricValue(), 1.0);
assertEquals(50, (Double) p50.metricValue(), 1.0);
assertEquals(75, (Double) p75.metricValue(), 1.0);
assertEquals(0.0, (Double) p25.metricValue(), 1.0);
assertEquals(0.0, (Double) p50.metricValue(), 1.0);
assertEquals(0.0, (Double) p75.metricValue(), 1.0);
sensor.record(i);
assertEquals(25, (Double) p25.metricValue(), 1.0);
assertEquals(50, (Double) p50.metricValue(), 1.0);
assertEquals(75, (Double) p75.metricValue(), 1.0);
代码示例来源:origin: org.apache.flink/flink-connector-kafka-base
@Override
public Double getValue() {
return kafkaMetric.value();
}
}
代码示例来源:origin: sixt/ja-micro
private synchronized void checkAssignments() {
logger.debug("Checking partition assignments");
try {
KafkaConsumer<String, String> consumer = consumers.iterator().next();
Map<MetricName, ? extends Metric> metrics = consumer.metrics();
for (MetricName name : metrics.keySet()) {
if ("assigned-partitions".equals(name.name())) {
Metric metric = metrics.get(name);
Map<String, String> tags = name.tags();
String clientId = tags.get("client-id");
int partitionCount = ((Double)metric.metricValue()).intValue();
processDataPoint(clientId, partitionCount, Instant.now());
}
}
} catch (NoSuchElementException ex) {
}
}
代码示例来源:origin: org.apache.flink/flink-connector-kafka-base_2.10
@Override
public Double getValue() {
return kafkaMetric.value();
}
}
代码示例来源:origin: com.jkoolcloud/tnt4j
@Override
public KeyValueStats getStats(Map<String, Object> stats) {
super.getStats(stats);
if (isOpen()) {
Map<MetricName, ? extends Metric> kMetrics = producer.metrics();
Set<MetricName> keys = kMetrics.keySet();
for (MetricName kMetric : keys) {
stats.put(Utils.qualify(this, kMetric.group() + "/" + kMetric.name()),
kMetrics.get(kMetric).metricValue());
}
}
return this;
}
代码示例来源:origin: org.apache.flink/flink-connector-kafka-base_2.11
@Override
public Double getValue() {
return kafkaMetric.value();
}
}
代码示例来源:origin: org.apache.flink/flink-connector-kafka-0.11
@Override
public Double getValue() {
return kafkaMetric.value();
}
代码示例来源:origin: com.alibaba.blink/flink-connector-kafka-0.11
@Override
public Double getValue() {
return kafkaMetric.value();
}
代码示例来源:origin: org.apache.flink/flink-connector-kafka-0.11_2.11
@Override
public Double getValue() {
return kafkaMetric.value();
}
代码示例来源:origin: com.netflix.suro/suro-kafka-producer
@Override
public String getStat() {
Map<MetricName,? extends Metric> metrics = producer.metrics();
StringBuilder sb = new StringBuilder();
// add kafka producer stats, which are rates
for( Map.Entry<MetricName,? extends Metric> e : metrics.entrySet() ){
sb.append("kafka.").append(e.getKey()).append(": ").append(e.getValue().value()).append('\n');
}
return sb.toString();
}
代码示例来源:origin: allegro/hermes
private void registerGauge(Producer<byte[], byte[]> producer, HermesMetrics metrics, String gauge,
Predicate<Map.Entry<MetricName, ? extends Metric>> predicate) {
metrics.registerGauge(gauge, () -> {
Optional<? extends Map.Entry<MetricName, ? extends Metric>> first =
producer.metrics().entrySet().stream().filter(predicate).findFirst();
double value = first.isPresent() ? first.get().getValue().value() : 0.0;
return value < 0? 0.0 : value;
});
}
代码示例来源:origin: com.netflix.suro/suro-kafka-producer
@Override
public String getStat() {
Map<MetricName,? extends Metric> metrics = producer.metrics();
StringBuilder sb = new StringBuilder();
// add kafka producer stats, which are rates
for( Map.Entry<MetricName,? extends Metric> e : metrics.entrySet() ){
sb.append("kafka.").append(e.getKey()).append(": ").append(e.getValue().value()).append('\n');
}
// also report our counters
sb.append("messages-in-queue4sink: ").append( this.queue4Sink.size() ).append('\n');
sb.append("queued-jobs: ").append( this.jobQueue.size() ).append('\n');
sb.append("active-threads: ").append( this.senders.getActiveCount() ).append('\n');
sb.append("received-messages: ").append( this.receivedCount.get() ).append('\n');
sb.append("sent-messages: ").append( this.sentCount.get() ).append('\n');
sb.append("sent-bytes: ").append( this.sentByteCount.get() ).append('\n');
sb.append("dropped-messages: ").append( this.droppedCount.get() ).append('\n');
sb.append("requeued-messages: ").append( this.requeuedCount.get() ).append('\n');
return sb.toString();
}
}
代码示例来源:origin: org.apache.apex/malhar-kafka-common
stats[i].bytesPerSec = cMetrics.get(stats[i].bytePerSecMK).value();
stats[i].msgsPerSec = cMetrics.get(stats[i].msgPerSecMK).value();
代码示例来源:origin: com.hotels.road/road-onramp-kafka-impl
registry.gauge(name, metric, m -> m.value());
});
代码示例来源:origin: apache/apex-malhar
stats[i].bytesPerSec = cMetrics.get(stats[i].bytePerSecMK).value();
stats[i].msgsPerSec = cMetrics.get(stats[i].msgPerSecMK).value();
内容来源于网络,如有侵权,请联系作者删除!