org.apache.flink.metrics.Gauge类的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(323)

本文整理了Java中org.apache.flink.metrics.Gauge类的一些代码示例,展示了Gauge类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Gauge类的具体详情如下:
包路径:org.apache.flink.metrics.Gauge
类名称:Gauge

Gauge介绍

[英]A Gauge is a Metric that calculates a specific value at a point in time.
[中]仪表是一种在某个时间点计算特定值的度量。

代码示例

代码示例来源:origin: apache/flink

/**
   * Visibility of this method must not be changed
   * since we deliberately not map it to json object in a Datadog-defined format.
   */
  @Override
  public Number getMetricValue() {
    return gauge.getValue();
  }
}

代码示例来源:origin: apache/flink

@Override
  public Object getValue() {
    return gauge.getValue();
  }
}

代码示例来源:origin: apache/flink

@Override
public T getValue() {
  return this.gauge.getValue();
}

代码示例来源:origin: apache/flink

private void reportGauge(final String name, final Gauge<?> gauge) {
  Object value = gauge.getValue();
  if (value != null) {
    send(name, value.toString());
  }
}

代码示例来源:origin: apache/flink

@Override
  public double get() {
    final Object value = gauge.getValue();
    if (value == null) {
      log.debug("Gauge {} is null-valued, defaulting to 0.", gauge);
      return 0;
    }
    if (value instanceof Double) {
      return (double) value;
    }
    if (value instanceof Number) {
      return ((Number) value).doubleValue();
    }
    if (value instanceof Boolean) {
      return ((Boolean) value) ? 1 : 0;
    }
    log.debug("Invalid type for Gauge {}: {}, only number types and booleans are supported by this reporter.",
      gauge, value.getClass().getName());
    return 0;
  }
};

代码示例来源:origin: apache/flink

for (Map.Entry<Gauge<?>, String> metric : gauges.entrySet()) {
  builder
    .append(metric.getValue()).append(": ").append(metric.getKey().getValue())
    .append(lineSeparator);

代码示例来源:origin: apache/flink

assertEquals(0L, entry.getKey().getValue());
} else if (entry.getValue().contains(MetricNames.TASK_SLOTS_TOTAL)) {
  assertEquals(1L, entry.getKey().getValue());
} else if (entry.getValue().contains(MetricNames.NUM_REGISTERED_TASK_MANAGERS)) {
  assertEquals(1L, entry.getKey().getValue());
} else if (entry.getValue().contains(MetricNames.NUM_RUNNING_JOBS)) {
  assertEquals(1L, entry.getKey().getValue());

代码示例来源:origin: apache/flink

Assert.assertEquals(Long.MIN_VALUE, taskInputWatermarkGauge.getValue().longValue());
Assert.assertEquals(Long.MIN_VALUE, headInputWatermarkGauge.getValue().longValue());
Assert.assertEquals(Long.MIN_VALUE, headInput1WatermarkGauge.getValue().longValue());
Assert.assertEquals(Long.MIN_VALUE, headInput2WatermarkGauge.getValue().longValue());
Assert.assertEquals(Long.MIN_VALUE, headOutputWatermarkGauge.getValue().longValue());
Assert.assertEquals(Long.MIN_VALUE, chainedInputWatermarkGauge.getValue().longValue());
Assert.assertEquals(Long.MIN_VALUE, chainedOutputWatermarkGauge.getValue().longValue());
Assert.assertEquals(Long.MIN_VALUE, taskInputWatermarkGauge.getValue().longValue());
Assert.assertEquals(Long.MIN_VALUE, headInputWatermarkGauge.getValue().longValue());
Assert.assertEquals(1L, headInput1WatermarkGauge.getValue().longValue());
Assert.assertEquals(Long.MIN_VALUE, headInput2WatermarkGauge.getValue().longValue());
Assert.assertEquals(Long.MIN_VALUE, headOutputWatermarkGauge.getValue().longValue());
Assert.assertEquals(Long.MIN_VALUE, chainedInputWatermarkGauge.getValue().longValue());
Assert.assertEquals(Long.MIN_VALUE, chainedOutputWatermarkGauge.getValue().longValue());
Assert.assertEquals(1L, taskInputWatermarkGauge.getValue().longValue());
Assert.assertEquals(1L, headInputWatermarkGauge.getValue().longValue());
Assert.assertEquals(1L, headInput1WatermarkGauge.getValue().longValue());
Assert.assertEquals(2L, headInput2WatermarkGauge.getValue().longValue());
Assert.assertEquals(1L, headOutputWatermarkGauge.getValue().longValue());
Assert.assertEquals(1L, chainedInputWatermarkGauge.getValue().longValue());
Assert.assertEquals(2L, chainedOutputWatermarkGauge.getValue().longValue());
Assert.assertEquals(2L, taskInputWatermarkGauge.getValue().longValue());
Assert.assertEquals(2L, headInputWatermarkGauge.getValue().longValue());
Assert.assertEquals(3L, headInput1WatermarkGauge.getValue().longValue());
Assert.assertEquals(2L, headInput2WatermarkGauge.getValue().longValue());
Assert.assertEquals(2L, headOutputWatermarkGauge.getValue().longValue());

代码示例来源:origin: apache/flink

.size());
Assert.assertEquals(Long.MIN_VALUE, taskInputWatermarkGauge.getValue().longValue());
Assert.assertEquals(Long.MIN_VALUE, headInputWatermarkGauge.getValue().longValue());
Assert.assertEquals(Long.MIN_VALUE, headOutputWatermarkGauge.getValue().longValue());
Assert.assertEquals(Long.MIN_VALUE, chainedInputWatermarkGauge.getValue().longValue());
Assert.assertEquals(Long.MIN_VALUE, chainedOutputWatermarkGauge.getValue().longValue());
Assert.assertEquals(1L, taskInputWatermarkGauge.getValue().longValue());
Assert.assertEquals(1L, headInputWatermarkGauge.getValue().longValue());
Assert.assertEquals(2L, headOutputWatermarkGauge.getValue().longValue());
Assert.assertEquals(2L, chainedInputWatermarkGauge.getValue().longValue());
Assert.assertEquals(4L, chainedOutputWatermarkGauge.getValue().longValue());
Assert.assertEquals(2L, taskInputWatermarkGauge.getValue().longValue());
Assert.assertEquals(2L, headInputWatermarkGauge.getValue().longValue());
Assert.assertEquals(4L, headOutputWatermarkGauge.getValue().longValue());
Assert.assertEquals(4L, chainedInputWatermarkGauge.getValue().longValue());
Assert.assertEquals(8L, chainedOutputWatermarkGauge.getValue().longValue());

代码示例来源:origin: org.apache.flink/flink-metrics-jmx

@Override
  public Object getValue() {
    return gauge.getValue();
  }
}

代码示例来源:origin: com.alibaba.blink/flink-metrics-dropwizard

@Override
public T getValue() {
  return this.gauge.getValue();
}

代码示例来源:origin: org.apache.flink/flink-runtime_2.10

private static void serializeGauge(DataOutput out, QueryScopeInfo info, String name, Gauge<?> gauge) throws IOException {
  Object value = gauge.getValue();
  if (value == null) {
    throw new NullPointerException("Value returned by gauge " + name + " was null.");
  }
  String stringValue = gauge.getValue().toString();
  if (stringValue == null) {
    throw new NullPointerException("toString() of the value returned by gauge " + name + " returned null.");
  }
  serializeMetricInfo(out, info);
  out.writeUTF(name);
  out.writeUTF(stringValue);
}

代码示例来源:origin: com.alibaba.blink/flink-runtime

private static void serializeGauge(DataOutput out, QueryScopeInfo info, String name, Gauge<?> gauge) throws IOException {
  Object value = gauge.getValue();
  if (value == null) {
    throw new NullPointerException("Value returned by gauge " + name + " was null.");
  }
  String stringValue = value.toString();
  if (stringValue == null) {
    throw new NullPointerException("toString() of the value returned by gauge " + name + " returned null.");
  }
  serializeMetricInfo(out, info);
  out.writeUTF(name);
  out.writeUTF(stringValue);
}

代码示例来源:origin: org.apache.flink/flink-runtime

private static void serializeGauge(DataOutput out, QueryScopeInfo info, String name, Gauge<?> gauge) throws IOException {
  Object value = gauge.getValue();
  if (value == null) {
    throw new NullPointerException("Value returned by gauge " + name + " was null.");
  }
  String stringValue = value.toString();
  if (stringValue == null) {
    throw new NullPointerException("toString() of the value returned by gauge " + name + " returned null.");
  }
  serializeMetricInfo(out, info);
  out.writeUTF(name);
  out.writeUTF(stringValue);
}

代码示例来源:origin: org.apache.flink/flink-runtime_2.11

private static void serializeGauge(DataOutput out, QueryScopeInfo info, String name, Gauge<?> gauge) throws IOException {
  Object value = gauge.getValue();
  if (value == null) {
    throw new NullPointerException("Value returned by gauge " + name + " was null.");
  }
  String stringValue = value.toString();
  if (stringValue == null) {
    throw new NullPointerException("toString() of the value returned by gauge " + name + " returned null.");
  }
  serializeMetricInfo(out, info);
  out.writeUTF(name);
  out.writeUTF(stringValue);
}

代码示例来源:origin: org.apache.beam/beam-runners-flink_2.11

public static String toString(Metric metric) {
  if (metric instanceof Counter) {
   return Long.toString(((Counter) metric).getCount());
  } else if (metric instanceof Gauge) {
   return ((Gauge) metric).getValue().toString();
  } else if (metric instanceof Meter) {
   return Double.toString(((Meter) metric).getRate());
  } else if (metric instanceof Histogram) {
   HistogramStatistics stats = ((Histogram) metric).getStatistics();
   return String.format(
     "count=%d, min=%d, max=%d, mean=%f, stddev=%f, p50=%f, p75=%f, p95=%f",
     stats.size(),
     stats.getMin(),
     stats.getMax(),
     stats.getMean(),
     stats.getStdDev(),
     stats.getQuantile(0.5),
     stats.getQuantile(0.75),
     stats.getQuantile(0.95));
  } else {
   throw new IllegalStateException(
     String.format(
       "Cannot remove unknown metric type %s. This indicates that the reporter "
         + "does not support this metric type.",
       metric.getClass().getName()));
  }
 }
}

相关文章

Gauge类方法