1818
1919package com .qlangtech .plugins .incr .flink .metrics ;
2020
21+ import com .qlangtech .tis .cloud .ITISCoordinator ;
22+ import com .qlangtech .tis .realtime .yarn .rpc .MasterJob ;
23+ import com .qlangtech .tis .realtime .yarn .rpc .UpdateCounterMap ;
24+ import com .tis .hadoop .rpc .RpcServiceReference ;
25+ import com .tis .hadoop .rpc .StatusRpcClientFactory ;
2126import org .apache .flink .metrics .CharacterFilter ;
2227import org .apache .flink .metrics .Counter ;
28+ import org .apache .flink .metrics .Metric ;
2329import org .apache .flink .metrics .MetricConfig ;
2430import org .apache .flink .metrics .MetricGroup ;
2531import org .apache .flink .metrics .reporter .AbstractReporter ;
2632import org .apache .flink .metrics .reporter .Scheduled ;
2733
2834import java .util .Map ;
35+ import java .util .Optional ;
2936
3037/**
3138 * https://github.com/datavane/tis/issues/397
@@ -39,9 +46,30 @@ public String filterCharacters(String s) {
3946 return CharacterFilter .NO_OP_FILTER .filterCharacters (s );
4047 }
4148
49+ private RpcServiceReference rpcService ;
50+
4251 @ Override
4352 public void open (MetricConfig metricConfig ) {
4453
54+ try {
55+ ITISCoordinator coordinator = ITISCoordinator .create (true , Optional .empty ());
56+ this .rpcService = StatusRpcClientFactory .getService (coordinator );
57+ } catch (Exception e ) {
58+ throw new RuntimeException (e );
59+ }
60+ }
61+
62+ @ Override
63+ public void notifyOfAddedMetric (Metric metric , String metricName , MetricGroup group ) {
64+ //<jobmanager>
65+ // <job.JobName.jobID>
66+ // <task.TaskName>
67+ // <operator.OperatorName>
68+ // <subtask_index>
69+
70+ String [] scope = group .getScopeComponents ();
71+ // 输出示例:["jobmanager", "job_MyJob", "task_Source", "operator_Map", "0"]
72+ super .notifyOfAddedMetric (metric , metricName , group );
4573 }
4674
4775 @ Override
@@ -51,7 +79,36 @@ public void close() {
5179
5280 @ Override
5381 public void report () {
82+ UpdateCounterMap upateCounter = null ;
83+
84+ UpdateCounterMap updateCounterMap = new UpdateCounterMap ();
85+ // updateCounterMap.setGcCounter(BasicONSListener.getGarbageCollectionCount());
86+ // updateCounterMap.setFrom(hostName);
87+ // long currentTimeInSec = ConsumeDataKeeper.getCurrentTimeInSec();
88+ // updateCounterMap.setUpdateTime(currentTimeInSec);
89+ // 汇总一个节点中所有索引的增量信息
90+ // for (IOnsListenerStatus l : incrChannels) {
91+ // TableSingleDataIndexStatus tableUpdateCounter = new TableSingleDataIndexStatus();
92+ // tableUpdateCounter.setBufferQueueRemainingCapacity(l.getBufferQueueRemainingCapacity());
93+ // tableUpdateCounter.setBufferQueueUsedSize(l.getBufferQueueUsedSize());
94+ // tableUpdateCounter.setConsumeErrorCount((int) l.getConsumeErrorCount());
95+ // tableUpdateCounter.setIgnoreRowsCount((int) l.getIgnoreRowsCount());
96+ // tableUpdateCounter.setUUID(this.indexUUID.get(l.getCollectionName()));
97+ // tableUpdateCounter.setTis30sAvgRT(((BasicONSListener) l).getTis30sAvgRT());
98+ // // 汇总一个索引中所有focus table的增量信息
99+ // for (Map.Entry<String, IIncreaseCounter> entry : l.getUpdateStatic()) {
100+ // // IncrCounter tableIncrCounter = new
101+ // // IncrCounter((int)entry.getValue().getIncreasePastLast());
102+ // // tableIncrCounter.setAccumulationCount(entry.getValue().getAccumulation());
103+ // // tableUpdateCounter.put(entry.getKey(), tableIncrCounter);
104+ // // 只记录一个消费总量和当前时间
105+ // tableUpdateCounter.put(entry.getKey(), entry.getValue().getAccumulation());
106+ // }
107+ // tableUpdateCounter.put(TABLE_CONSUME_COUNT, ((BasicONSListener) l).getTableConsumeCount());
108+ // updateCounterMap.addTableCounter(l.getCollectionName(), tableUpdateCounter);
109+ // }
54110
111+ // MasterJob masterJob = this.rpcService.reportStatus(upateCounter);
55112 for (Map .Entry <Counter , String > entry : counters .entrySet ()) {
56113 Counter counter = entry .getKey ();
57114 String metricName = entry .getValue ();
0 commit comments