簡體   English   中英

無法在 Flink 1.3.2 中添加計數器

[英]unable to add counter in Flink 1.3.2

我想提到的弗林克來添加計數器在這里,但問題是,counter.inc()的返回void而不是整數。 我的指標代碼如下

    private  static class myMetric extends RichMapFunction<String,Integer> {
       private Counter counter ;

        @Override
        public void open(Configuration parameters) throws Exception {
            super.open(parameters);
            this.getRuntimeContext().
                    getMetricGroup().
                    counter("countit");
        }

        @Override
        public Integer map(String s) throws Exception {

            return this.counter.inc();

        }
    }

如果您為計數器分配一個值,它應該會更好地工作:

    this.counter = getRuntimeContext()
      .getMetricGroup()
      .counter("countit");

您可能會發現文檔很有幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM