2017-10-23 2 views
0

Flink에서 카운터를 추가하려고 시도한 것은 here입니다.하지만 counter.inc()는 Integer 대신 void를 반환합니다. 내 메트릭에 대한 코드는Flink 1.3.2에서 카운터를 추가 할 수 없습니다.

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(); 

    } 

답변

1

당신이 당신의 카운터에 값을 할당하면 그것은 더 잘 작동해야 다음과 같이 주어진다 : 당신은 the documentation이 도움이 될 수있는

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

.

관련 문제